wilc_wlan.h 10 KB

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