ibde.h (5416B)
1 /* 2 * 3 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 4 * 5 * Copyright 2007-2019 Broadcom Inc. All rights reserved. 6 */ 7 8 #ifndef __IBDE_H__ 9 #define __IBDE_H__ 10 11 #include <sal/types.h> 12 13 /* 14 * Represents a collection of devices 15 */ 16 17 typedef struct ibde_dev_s { 18 uint16 device; 19 uint8 rev; 20 sal_vaddr_t base_address; 21 sal_vaddr_t base_address1; 22 sal_vaddr_t base_address2; 23 } ibde_dev_t; 24 25 26 typedef struct ibde_s { 27 28 const char *(*name)(void); 29 30 /* Returns the number of devices available */ 31 /* Each device is is accessed through a handle */ 32 /* Handles are assumed to index the array of devices */ 33 34 /* Support SWITCH or ETHERNET or CPU devices */ 35 int (*num_devices)(int type); 36 #define BDE_ALL_DEVICES 0 37 #define BDE_SWITCH_DEVICES 1 38 #define BDE_ETHER_DEVICES 2 39 #define BDE_CPU_DEVICES 3 40 41 const ibde_dev_t *(*get_dev)(int d); 42 43 /* 44 * Get types of underlaying devices. 45 * A combination of bus type and functional type is returned. 46 * In case of bus type, support PCI and SPI device types. 47 * In case of functional type, specify if underlaying device is 48 * a switching or ethernet device. 49 */ 50 uint32 (*get_dev_type)(int d); 51 #define BDE_PCI_DEV_TYPE SAL_PCI_DEV_TYPE /* PCI device */ 52 #define BDE_SPI_DEV_TYPE SAL_SPI_DEV_TYPE /* SPI device */ 53 #define BDE_EB_DEV_TYPE SAL_EB_DEV_TYPE /* EB device */ 54 #define BDE_ICS_DEV_TYPE SAL_ICS_DEV_TYPE /* ICS device */ 55 #define BDE_MII_DEV_TYPE SAL_MII_DEV_TYPE /* MII device */ 56 #define BDE_I2C_DEV_TYPE SAL_I2C_DEV_TYPE /* I2C device */ 57 #define BDE_AXI_DEV_TYPE SAL_AXI_DEV_TYPE /* AXI device */ 58 #define BDE_EMMI_DEV_TYPE SAL_EMMI_DEV_TYPE /* EMMI device */ 59 #define BDE_DEV_BUS_ALT SAL_DEV_BUS_ALT /* Alternate Access */ 60 #define BDE_DEV_BUS_MSI SAL_DEV_BUS_MSI /* Message-signaled interrupts */ 61 62 #define BDE_DEV_BUS_TYPE_MASK SAL_DEV_BUS_TYPE_MASK 63 64 #define BDE_SWITCH_DEV_TYPE SAL_SWITCH_DEV_TYPE /* Switch device */ 65 #define BDE_ETHER_DEV_TYPE SAL_ETHER_DEV_TYPE /* Ethernet device */ 66 #define BDE_CPU_DEV_TYPE SAL_CPU_DEV_TYPE /* CPU device */ 67 68 #define BDE_BYTE_SWAP 0x01000000 /* SW byte swap */ 69 #define BDE_NO_IPROC 0x02000000 /* Device uses two BARs, but is not iProc */ 70 71 #define BDE_8MB_REG_SPACE 0x10000000 /* 8MB sized CMIC BAR */ 72 #define BDE_256K_REG_SPACE 0x20000000 /* Map 256K (v 64K) */ 73 #define BDE_128K_REG_SPACE 0x40000000 /* Map 128K (v 64K) */ 74 #define BDE_320K_REG_SPACE 0x80000000 /* Map 256K+64K */ 75 76 /* Bus supports only 16bit reads */ 77 #define BDE_DEV_BUS_RD_16BIT SAL_DEV_BUS_RD_16BIT 78 79 /* Bus supports only 16bit writes */ 80 #define BDE_DEV_BUS_WR_16BIT SAL_DEV_BUS_WR_16BIT 81 82 /* Backward compatibility */ 83 #define BDE_ET_DEV_TYPE BDE_MII_DEV_TYPE 84 85 #define BDE_DEV_MEM_MAPPED(_d) \ 86 ((_d) & (BDE_PCI_DEV_TYPE | BDE_ICS_DEV_TYPE | BDE_EB_DEV_TYPE |\ 87 BDE_EMMI_DEV_TYPE | BDE_AXI_DEV_TYPE)) 88 89 /* 90 * PCI Bus Access 91 */ 92 uint32 (*pci_conf_read)(int d, uint32 addr); 93 int (*pci_conf_write)(int d, uint32 addr, uint32 data); 94 void (*pci_bus_features)(int d, int *be_pio, int *be_packet, 95 int *be_other); 96 97 uint32 (*read)(int d, uint32 addr); 98 int (*write)(int d, uint32 addr, uint32 data); 99 100 uint32* (*salloc)(int d, int size, const char *name); 101 void (*sfree)(int d, void *ptr); 102 int (*sflush)(int d, void *addr, int length); 103 int (*sinval)(int d, void *addr, int length); 104 105 int (*interrupt_connect)(int d, void (*)(void*), void *data); 106 int (*interrupt_disconnect)(int d); 107 108 sal_paddr_t (*l2p)(int d, void *laddr); 109 void* (*p2l)(int d, sal_paddr_t paddr); 110 111 /* 112 * SPI Access via SMP 113 */ 114 int (*spi_read)(int d, uint32 addr, uint8 *buf, int len); 115 int (*spi_write)(int d, uint32 addr, uint8 *buf, int len); 116 /* Special SPI access addresses */ 117 #define BDE_DEV_OP_EMMI_INIT SAL_DEV_OP_EMMI_INIT 118 119 /* 120 * iProc register access 121 */ 122 uint32 (*iproc_read)(int d, uint32 addr); 123 int (*iproc_write)(int d, uint32 addr, uint32 data); 124 125 /* 126 * Shared memory access 127 */ 128 uint32 (*shmem_read)(int dev, uint32 addr, uint8 *buf, uint32 len); 129 void (*shmem_write)(int dev, uint32 addr, uint8 *buf, uint32 len); 130 sal_vaddr_t (*shmem_map)(int dev, uint32 addr, uint32 size); 131 132 /* 133 * cmic 134 */ 135 int (*get_cmic_ver)(int d, uint32 *ver); 136 137 /* 138 * I2C operations on the Device, assuming it is connected by I2C to the CPU. 139 */ 140 /* Read from the internal device Address space using I2C */ 141 int (*i2c_device_read)( 142 int dev, /* The device ID to access */ 143 uint32 addr, /* The address to access in the internal device address space */ 144 uint32 *value);/* the value to be read. */ 145 /* Write to the internal device Address space using I2C */ 146 int (*i2c_device_write)( 147 int dev, /* The device ID to access */ 148 uint32 addr, /* The address to access in the internal device address space */ 149 uint32 value); /* the value to be written. */ 150 151 } ibde_t; 152 153 154 /* System BDE */ 155 extern ibde_t *bde; 156 157 158 #endif /* __IBDE_H__ */