Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1 | #ifndef WILC_WLAN_H |
| 2 | #define WILC_WLAN_H |
| 3 | |
Greg Kroah-Hartman | 36a24b4 | 2015-08-14 19:26:20 -0700 | [diff] [blame] | 4 | #include "wilc_oswrapper.h" |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 5 | |
| 6 | |
| 7 | #define ISWILC1000(id) (((id & 0xfffff000) == 0x100000) ? 1 : 0) |
| 8 | |
| 9 | |
| 10 | /******************************************** |
| 11 | * |
| 12 | * Mac eth header length |
| 13 | * |
| 14 | ********************************************/ |
| 15 | #define DRIVER_HANDLER_SIZE 4 |
| 16 | #define MAX_MAC_HDR_LEN 26 /* QOS_MAC_HDR_LEN */ |
| 17 | #define SUB_MSDU_HEADER_LENGTH 14 |
| 18 | #define SNAP_HDR_LEN 8 |
| 19 | #define ETHERNET_HDR_LEN 14 |
| 20 | #define WORD_ALIGNMENT_PAD 0 |
| 21 | |
| 22 | #define ETH_ETHERNET_HDR_OFFSET (MAX_MAC_HDR_LEN + SUB_MSDU_HEADER_LENGTH + \ |
| 23 | SNAP_HDR_LEN - ETHERNET_HDR_LEN + WORD_ALIGNMENT_PAD) |
| 24 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 25 | #define HOST_HDR_OFFSET 4 |
| 26 | #define ETHERNET_HDR_LEN 14 |
| 27 | #define IP_HDR_LEN 20 |
| 28 | #define IP_HDR_OFFSET ETHERNET_HDR_LEN |
| 29 | #define UDP_HDR_OFFSET (IP_HDR_LEN + IP_HDR_OFFSET) |
| 30 | #define UDP_HDR_LEN 8 |
| 31 | #define UDP_DATA_OFFSET (UDP_HDR_OFFSET + UDP_HDR_LEN) |
| 32 | #define ETH_CONFIG_PKT_HDR_LEN UDP_DATA_OFFSET |
| 33 | |
| 34 | #define ETH_CONFIG_PKT_HDR_OFFSET (ETH_ETHERNET_HDR_OFFSET + \ |
| 35 | ETH_CONFIG_PKT_HDR_LEN) |
| 36 | #define ACTION 0xD0 |
| 37 | #define PROBE_REQ 0x40 |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 38 | |
| 39 | /******************************************** |
| 40 | * |
| 41 | * Endian Conversion |
| 42 | * |
| 43 | ********************************************/ |
| 44 | |
| 45 | #define BYTE_SWAP(val) ((((val) & 0x000000FF) << 24) + \ |
| 46 | (((val) & 0x0000FF00) << 8) + \ |
| 47 | (((val) & 0x00FF0000) >> 8) + \ |
| 48 | (((val) & 0xFF000000) >> 24)) |
| 49 | |
| 50 | /******************************************** |
| 51 | * |
| 52 | * Register Defines |
| 53 | * |
| 54 | ********************************************/ |
| 55 | #define WILC_PERIPH_REG_BASE 0x1000 |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 56 | #define WILC_CHANGING_VIR_IF (0x108c) |
| 57 | #define WILC_CHIPID (WILC_PERIPH_REG_BASE) |
| 58 | #define WILC_GLB_RESET_0 (WILC_PERIPH_REG_BASE + 0x400) |
| 59 | #define WILC_PIN_MUX_0 (WILC_PERIPH_REG_BASE + 0x408) |
| 60 | #define WILC_HOST_TX_CTRL (WILC_PERIPH_REG_BASE + 0x6c) |
| 61 | #define WILC_HOST_RX_CTRL_0 (WILC_PERIPH_REG_BASE + 0x70) |
| 62 | #define WILC_HOST_RX_CTRL_1 (WILC_PERIPH_REG_BASE + 0x74) |
| 63 | #define WILC_HOST_VMM_CTL (WILC_PERIPH_REG_BASE + 0x78) |
| 64 | #define WILC_HOST_RX_CTRL (WILC_PERIPH_REG_BASE + 0x80) |
| 65 | #define WILC_HOST_RX_EXTRA_SIZE (WILC_PERIPH_REG_BASE + 0x84) |
| 66 | #define WILC_HOST_TX_CTRL_1 (WILC_PERIPH_REG_BASE + 0x88) |
| 67 | #define WILC_MISC (WILC_PERIPH_REG_BASE + 0x428) |
| 68 | #define WILC_INTR_REG_BASE (WILC_PERIPH_REG_BASE + 0xa00) |
| 69 | #define WILC_INTR_ENABLE (WILC_INTR_REG_BASE) |
| 70 | #define WILC_INTR2_ENABLE (WILC_INTR_REG_BASE + 4) |
| 71 | |
| 72 | #define WILC_INTR_POLARITY (WILC_INTR_REG_BASE + 0x10) |
| 73 | #define WILC_INTR_TYPE (WILC_INTR_REG_BASE + 0x20) |
| 74 | #define WILC_INTR_CLEAR (WILC_INTR_REG_BASE + 0x30) |
| 75 | #define WILC_INTR_STATUS (WILC_INTR_REG_BASE + 0x40) |
| 76 | |
| 77 | #define WILC_VMM_TBL_SIZE 64 |
| 78 | #define WILC_VMM_TX_TBL_BASE (0x150400) |
| 79 | #define WILC_VMM_RX_TBL_BASE (0x150500) |
| 80 | |
| 81 | #define WILC_VMM_BASE 0x150000 |
| 82 | #define WILC_VMM_CORE_CTL (WILC_VMM_BASE) |
| 83 | #define WILC_VMM_TBL_CTL (WILC_VMM_BASE + 0x4) |
| 84 | #define WILC_VMM_TBL_ENTRY (WILC_VMM_BASE + 0x8) |
| 85 | #define WILC_VMM_TBL0_SIZE (WILC_VMM_BASE + 0xc) |
| 86 | #define WILC_VMM_TO_HOST_SIZE (WILC_VMM_BASE + 0x10) |
| 87 | #define WILC_VMM_CORE_CFG (WILC_VMM_BASE + 0x14) |
| 88 | #define WILC_VMM_TBL_ACTIVE (WILC_VMM_BASE + 040) |
| 89 | #define WILC_VMM_TBL_STATUS (WILC_VMM_BASE + 0x44) |
| 90 | |
| 91 | #define WILC_SPI_REG_BASE 0xe800 |
| 92 | #define WILC_SPI_CTL (WILC_SPI_REG_BASE) |
| 93 | #define WILC_SPI_MASTER_DMA_ADDR (WILC_SPI_REG_BASE + 0x4) |
| 94 | #define WILC_SPI_MASTER_DMA_COUNT (WILC_SPI_REG_BASE + 0x8) |
| 95 | #define WILC_SPI_SLAVE_DMA_ADDR (WILC_SPI_REG_BASE + 0xc) |
| 96 | #define WILC_SPI_SLAVE_DMA_COUNT (WILC_SPI_REG_BASE + 0x10) |
| 97 | #define WILC_SPI_TX_MODE (WILC_SPI_REG_BASE + 0x20) |
| 98 | #define WILC_SPI_PROTOCOL_CONFIG (WILC_SPI_REG_BASE + 0x24) |
| 99 | #define WILC_SPI_INTR_CTL (WILC_SPI_REG_BASE + 0x2c) |
| 100 | |
| 101 | #define WILC_SPI_PROTOCOL_OFFSET (WILC_SPI_PROTOCOL_CONFIG - WILC_SPI_REG_BASE) |
| 102 | |
| 103 | #define WILC_AHB_DATA_MEM_BASE 0x30000 |
| 104 | #define WILC_AHB_SHARE_MEM_BASE 0xd0000 |
| 105 | |
Chaehyun Lim | c3ca637 | 2015-09-20 15:51:19 +0900 | [diff] [blame^] | 106 | #define WILC_VMM_TBL_RX_SHADOW_BASE WILC_AHB_SHARE_MEM_BASE |
| 107 | #define WILC_VMM_TBL_RX_SHADOW_SIZE (256) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 108 | |
| 109 | #define WILC_GP_REG_0 0x149c |
| 110 | #define WILC_GP_REG_1 0x14a0 |
| 111 | |
| 112 | #define rHAVE_SDIO_IRQ_GPIO_BIT (0) |
| 113 | #define rHAVE_USE_PMU_BIT (1) |
| 114 | #define rHAVE_SLEEP_CLK_SRC_RTC_BIT (2) |
| 115 | #define rHAVE_SLEEP_CLK_SRC_XO_BIT (3) |
| 116 | #define rHAVE_EXT_PA_INV_TX_RX_BIT (4) |
| 117 | #define rHAVE_LEGACY_RF_SETTINGS_BIT (5) |
| 118 | #define rHAVE_XTAL_24_BIT (6) |
| 119 | #define rHAVE_DISABLE_WILC_UART_BIT (7) |
| 120 | |
| 121 | |
| 122 | #define WILC_HAVE_SDIO_IRQ_GPIO (1 << rHAVE_SDIO_IRQ_GPIO_BIT) |
| 123 | #define WILC_HAVE_USE_PMU (1 << rHAVE_USE_PMU_BIT) |
| 124 | #define WILC_HAVE_SLEEP_CLK_SRC_RTC (1 << rHAVE_SLEEP_CLK_SRC_RTC_BIT) |
| 125 | #define WILC_HAVE_SLEEP_CLK_SRC_XO (1 << rHAVE_SLEEP_CLK_SRC_XO_BIT) |
| 126 | #define WILC_HAVE_EXT_PA_INV_TX_RX (1 << rHAVE_EXT_PA_INV_TX_RX_BIT) |
| 127 | #define WILC_HAVE_LEGACY_RF_SETTINGS (1 << rHAVE_LEGACY_RF_SETTINGS_BIT) |
| 128 | #define WILC_HAVE_XTAL_24 (1 << rHAVE_XTAL_24_BIT) |
| 129 | #define WILC_HAVE_DISABLE_WILC_UART (1 << rHAVE_DISABLE_WILC_UART_BIT) |
| 130 | |
| 131 | |
| 132 | /******************************************** |
| 133 | * |
| 134 | * Wlan Defines |
| 135 | * |
| 136 | ********************************************/ |
| 137 | #define WILC_CFG_PKT 1 |
| 138 | #define WILC_NET_PKT 0 |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 139 | #define WILC_MGMT_PKT 2 |
| 140 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 141 | #define WILC_CFG_SET 1 |
| 142 | #define WILC_CFG_QUERY 0 |
| 143 | |
| 144 | #define WILC_CFG_RSP 1 |
| 145 | #define WILC_CFG_RSP_STATUS 2 |
| 146 | #define WILC_CFG_RSP_SCAN 3 |
| 147 | |
| 148 | #ifdef WILC_SDIO |
| 149 | #define WILC_PLL_TO 4 |
| 150 | #else |
| 151 | #define WILC_PLL_TO 2 |
| 152 | #endif |
| 153 | |
| 154 | |
| 155 | #define ABORT_INT (1 << 31) |
| 156 | |
| 157 | /*******************************************/ |
| 158 | /* E0 and later Interrupt flags. */ |
| 159 | /*******************************************/ |
| 160 | /*******************************************/ |
| 161 | /* E0 and later Interrupt flags. */ |
| 162 | /* IRQ Status word */ |
| 163 | /* 15:0 = DMA count in words. */ |
| 164 | /* 16: INT0 flag */ |
| 165 | /* 17: INT1 flag */ |
| 166 | /* 18: INT2 flag */ |
| 167 | /* 19: INT3 flag */ |
| 168 | /* 20: INT4 flag */ |
| 169 | /* 21: INT5 flag */ |
| 170 | /*******************************************/ |
| 171 | #define IRG_FLAGS_OFFSET 16 |
| 172 | #define IRQ_DMA_WD_CNT_MASK ((1ul << IRG_FLAGS_OFFSET) - 1) |
| 173 | #define INT_0 (1 << (IRG_FLAGS_OFFSET)) |
| 174 | #define INT_1 (1 << (IRG_FLAGS_OFFSET + 1)) |
| 175 | #define INT_2 (1 << (IRG_FLAGS_OFFSET + 2)) |
| 176 | #define INT_3 (1 << (IRG_FLAGS_OFFSET + 3)) |
| 177 | #define INT_4 (1 << (IRG_FLAGS_OFFSET + 4)) |
| 178 | #define INT_5 (1 << (IRG_FLAGS_OFFSET + 5)) |
| 179 | #define MAX_NUM_INT (6) |
| 180 | |
| 181 | /*******************************************/ |
| 182 | /* E0 and later Interrupt flags. */ |
| 183 | /* IRQ Clear word */ |
| 184 | /* 0: Clear INT0 */ |
| 185 | /* 1: Clear INT1 */ |
| 186 | /* 2: Clear INT2 */ |
| 187 | /* 3: Clear INT3 */ |
| 188 | /* 4: Clear INT4 */ |
| 189 | /* 5: Clear INT5 */ |
| 190 | /* 6: Select VMM table 1 */ |
| 191 | /* 7: Select VMM table 2 */ |
| 192 | /* 8: Enable VMM */ |
| 193 | /*******************************************/ |
| 194 | #define CLR_INT0 (1 << 0) |
| 195 | #define CLR_INT1 (1 << 1) |
| 196 | #define CLR_INT2 (1 << 2) |
| 197 | #define CLR_INT3 (1 << 3) |
| 198 | #define CLR_INT4 (1 << 4) |
| 199 | #define CLR_INT5 (1 << 5) |
| 200 | #define SEL_VMM_TBL0 (1 << 6) |
| 201 | #define SEL_VMM_TBL1 (1 << 7) |
| 202 | #define EN_VMM (1 << 8) |
| 203 | |
| 204 | #define DATA_INT_EXT INT_0 |
| 205 | #define PLL_INT_EXT INT_1 |
| 206 | #define SLEEP_INT_EXT INT_2 |
| 207 | #define ALL_INT_EXT (DATA_INT_EXT | PLL_INT_EXT | SLEEP_INT_EXT) |
| 208 | #define NUM_INT_EXT (3) |
| 209 | |
| 210 | #define DATA_INT_CLR CLR_INT0 |
| 211 | #define PLL_INT_CLR CLR_INT1 |
| 212 | #define SLEEP_INT_CLR CLR_INT2 |
| 213 | |
| 214 | #define ENABLE_RX_VMM (SEL_VMM_TBL1 | EN_VMM) |
| 215 | #define ENABLE_TX_VMM (SEL_VMM_TBL0 | EN_VMM) |
| 216 | |
| 217 | |
| 218 | /*time for expiring the semaphores of cfg packets*/ |
| 219 | #define CFG_PKTS_TIMEOUT 2000 |
| 220 | /******************************************** |
| 221 | * |
| 222 | * Debug Type |
| 223 | * |
| 224 | ********************************************/ |
Chaehyun Lim | fbc2fe1 | 2015-09-15 14:06:16 +0900 | [diff] [blame] | 225 | typedef void (*wilc_debug_func)(u32, char *, ...); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 226 | |
| 227 | /******************************************** |
| 228 | * |
| 229 | * Tx/Rx Queue Structure |
| 230 | * |
| 231 | ********************************************/ |
| 232 | |
| 233 | struct txq_entry_t { |
| 234 | struct txq_entry_t *next; |
| 235 | struct txq_entry_t *prev; |
| 236 | int type; |
| 237 | int tcp_PendingAck_index; |
Chaehyun Lim | 51e825f | 2015-09-15 14:06:14 +0900 | [diff] [blame] | 238 | u8 *buffer; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 239 | int buffer_size; |
| 240 | void *priv; |
| 241 | int status; |
| 242 | void (*tx_complete_func)(void *, int); |
| 243 | }; |
| 244 | |
| 245 | struct rxq_entry_t { |
| 246 | struct rxq_entry_t *next; |
Chaehyun Lim | 51e825f | 2015-09-15 14:06:14 +0900 | [diff] [blame] | 247 | u8 *buffer; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 248 | int buffer_size; |
| 249 | }; |
| 250 | |
| 251 | /******************************************** |
| 252 | * |
| 253 | * Host IF Structure |
| 254 | * |
| 255 | ********************************************/ |
| 256 | |
| 257 | typedef struct { |
| 258 | int (*hif_init)(wilc_wlan_inp_t *, wilc_debug_func); |
| 259 | int (*hif_deinit)(void *); |
Chaehyun Lim | fbc2fe1 | 2015-09-15 14:06:16 +0900 | [diff] [blame] | 260 | int (*hif_read_reg)(u32, u32 *); |
| 261 | int (*hif_write_reg)(u32, u32); |
| 262 | int (*hif_block_rx)(u32, u8 *, u32); |
| 263 | int (*hif_block_tx)(u32, u8 *, u32); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 264 | int (*hif_sync)(void); |
| 265 | int (*hif_clear_int)(void); |
Chaehyun Lim | fbc2fe1 | 2015-09-15 14:06:16 +0900 | [diff] [blame] | 266 | int (*hif_read_int)(u32 *); |
| 267 | int (*hif_clear_int_ext)(u32); |
| 268 | int (*hif_read_size)(u32 *); |
| 269 | int (*hif_block_tx_ext)(u32, u8 *, u32); |
| 270 | int (*hif_block_rx_ext)(u32, u8 *, u32); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 271 | int (*hif_sync_ext)(int); |
| 272 | void (*hif_set_max_bus_speed)(void); |
| 273 | void (*hif_set_default_bus_speed)(void); |
| 274 | } wilc_hif_func_t; |
| 275 | |
| 276 | /******************************************** |
| 277 | * |
| 278 | * Configuration Structure |
| 279 | * |
| 280 | ********************************************/ |
| 281 | |
| 282 | #define MAX_CFG_FRAME_SIZE 1468 |
| 283 | |
| 284 | typedef struct { |
Chaehyun Lim | 51e825f | 2015-09-15 14:06:14 +0900 | [diff] [blame] | 285 | u8 ether_header[14]; |
| 286 | u8 ip_header[20]; |
| 287 | u8 udp_header[8]; |
| 288 | u8 wid_header[8]; |
| 289 | u8 frame[MAX_CFG_FRAME_SIZE]; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 290 | } wilc_cfg_frame_t; |
| 291 | |
| 292 | typedef struct { |
Chaehyun Lim | fbc2fe1 | 2015-09-15 14:06:16 +0900 | [diff] [blame] | 293 | int (*wlan_tx)(u8 *, u32, wilc_tx_complete_func_t); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 294 | } wilc_wlan_cfg_func_t; |
| 295 | |
| 296 | typedef struct { |
| 297 | int type; |
Chaehyun Lim | fbc2fe1 | 2015-09-15 14:06:16 +0900 | [diff] [blame] | 298 | u32 seq_no; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 299 | } wilc_cfg_rsp_t; |
| 300 | |
| 301 | typedef struct { |
Chaehyun Lim | fbc2fe1 | 2015-09-15 14:06:16 +0900 | [diff] [blame] | 302 | int (*cfg_wid_set)(u8 *, u32, u16, u8 *, int); |
| 303 | int (*cfg_wid_get)(u8 *, u32, u16); |
| 304 | int (*cfg_wid_get_val)(u16, u8 *, u32); |
Chaehyun Lim | 51e825f | 2015-09-15 14:06:14 +0900 | [diff] [blame] | 305 | int (*rx_indicate)(u8 *, int, wilc_cfg_rsp_t *); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 306 | int (*cfg_init)(wilc_debug_func); |
| 307 | } wilc_cfg_func_t; |
| 308 | |
| 309 | #endif |