1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
10 #include <linux/types.h>
12 /********************************************
14 * Mac eth header length
16 ********************************************/
17 #define MAX_MAC_HDR_LEN 26 /* QOS_MAC_HDR_LEN */
18 #define SUB_MSDU_HEADER_LENGTH 14
19 #define SNAP_HDR_LEN 8
20 #define ETHERNET_HDR_LEN 14
21 #define WORD_ALIGNMENT_PAD 0
23 #define ETH_ETHERNET_HDR_OFFSET (MAX_MAC_HDR_LEN + \
24 SUB_MSDU_HEADER_LENGTH + \
29 #define HOST_HDR_OFFSET 4
30 #define ETHERNET_HDR_LEN 14
32 #define IP_HDR_OFFSET ETHERNET_HDR_LEN
33 #define UDP_HDR_OFFSET (IP_HDR_LEN + IP_HDR_OFFSET)
35 #define UDP_DATA_OFFSET (UDP_HDR_OFFSET + UDP_HDR_LEN)
36 #define ETH_CONFIG_PKT_HDR_LEN UDP_DATA_OFFSET
38 #define ETH_CONFIG_PKT_HDR_OFFSET (ETH_ETHERNET_HDR_OFFSET + \
39 ETH_CONFIG_PKT_HDR_LEN)
41 /********************************************
45 ********************************************/
46 #define WILC_PERIPH_REG_BASE 0x1000
47 #define WILC_CHANGING_VIR_IF 0x108c
48 #define WILC_CHIPID WILC_PERIPH_REG_BASE
49 #define WILC_GLB_RESET_0 (WILC_PERIPH_REG_BASE + 0x400)
50 #define WILC_PIN_MUX_0 (WILC_PERIPH_REG_BASE + 0x408)
51 #define WILC_HOST_TX_CTRL (WILC_PERIPH_REG_BASE + 0x6c)
52 #define WILC_HOST_RX_CTRL_0 (WILC_PERIPH_REG_BASE + 0x70)
53 #define WILC_HOST_RX_CTRL_1 (WILC_PERIPH_REG_BASE + 0x74)
54 #define WILC_HOST_VMM_CTL (WILC_PERIPH_REG_BASE + 0x78)
55 #define WILC_HOST_RX_CTRL (WILC_PERIPH_REG_BASE + 0x80)
56 #define WILC_HOST_RX_EXTRA_SIZE (WILC_PERIPH_REG_BASE + 0x84)
57 #define WILC_HOST_TX_CTRL_1 (WILC_PERIPH_REG_BASE + 0x88)
58 #define WILC_MISC (WILC_PERIPH_REG_BASE + 0x428)
59 #define WILC_INTR_REG_BASE (WILC_PERIPH_REG_BASE + 0xa00)
60 #define WILC_INTR_ENABLE WILC_INTR_REG_BASE
61 #define WILC_INTR2_ENABLE (WILC_INTR_REG_BASE + 4)
63 #define WILC_INTR_POLARITY (WILC_INTR_REG_BASE + 0x10)
64 #define WILC_INTR_TYPE (WILC_INTR_REG_BASE + 0x20)
65 #define WILC_INTR_CLEAR (WILC_INTR_REG_BASE + 0x30)
66 #define WILC_INTR_STATUS (WILC_INTR_REG_BASE + 0x40)
68 #define WILC_VMM_TBL_SIZE 64
69 #define WILC_VMM_TX_TBL_BASE 0x150400
70 #define WILC_VMM_RX_TBL_BASE 0x150500
72 #define WILC_VMM_BASE 0x150000
73 #define WILC_VMM_CORE_CTL WILC_VMM_BASE
74 #define WILC_VMM_TBL_CTL (WILC_VMM_BASE + 0x4)
75 #define WILC_VMM_TBL_ENTRY (WILC_VMM_BASE + 0x8)
76 #define WILC_VMM_TBL0_SIZE (WILC_VMM_BASE + 0xc)
77 #define WILC_VMM_TO_HOST_SIZE (WILC_VMM_BASE + 0x10)
78 #define WILC_VMM_CORE_CFG (WILC_VMM_BASE + 0x14)
79 #define WILC_VMM_TBL_ACTIVE (WILC_VMM_BASE + 040)
80 #define WILC_VMM_TBL_STATUS (WILC_VMM_BASE + 0x44)
82 #define WILC_SPI_REG_BASE 0xe800
83 #define WILC_SPI_CTL WILC_SPI_REG_BASE
84 #define WILC_SPI_MASTER_DMA_ADDR (WILC_SPI_REG_BASE + 0x4)
85 #define WILC_SPI_MASTER_DMA_COUNT (WILC_SPI_REG_BASE + 0x8)
86 #define WILC_SPI_SLAVE_DMA_ADDR (WILC_SPI_REG_BASE + 0xc)
87 #define WILC_SPI_SLAVE_DMA_COUNT (WILC_SPI_REG_BASE + 0x10)
88 #define WILC_SPI_TX_MODE (WILC_SPI_REG_BASE + 0x20)
89 #define WILC_SPI_PROTOCOL_CONFIG (WILC_SPI_REG_BASE + 0x24)
90 #define WILC_SPI_INTR_CTL (WILC_SPI_REG_BASE + 0x2c)
92 #define WILC_SPI_PROTOCOL_OFFSET (WILC_SPI_PROTOCOL_CONFIG - \
95 #define WILC_AHB_DATA_MEM_BASE 0x30000
96 #define WILC_AHB_SHARE_MEM_BASE 0xd0000
98 #define WILC_VMM_TBL_RX_SHADOW_BASE WILC_AHB_SHARE_MEM_BASE
99 #define WILC_VMM_TBL_RX_SHADOW_SIZE 256
101 #define WILC_GP_REG_0 0x149c
102 #define WILC_GP_REG_1 0x14a0
104 #define WILC_HAVE_SDIO_IRQ_GPIO BIT(0)
105 #define WILC_HAVE_USE_PMU BIT(1)
106 #define WILC_HAVE_SLEEP_CLK_SRC_RTC BIT(2)
107 #define WILC_HAVE_SLEEP_CLK_SRC_XO BIT(3)
108 #define WILC_HAVE_EXT_PA_INV_TX_RX BIT(4)
109 #define WILC_HAVE_LEGACY_RF_SETTINGS BIT(5)
110 #define WILC_HAVE_XTAL_24 BIT(6)
111 #define WILC_HAVE_DISABLE_WILC_UART BIT(7)
112 #define WILC_HAVE_USE_IRQ_AS_HOST_WAKE BIT(8)
114 /********************************************
118 ********************************************/
119 #define WILC_CFG_PKT 1
120 #define WILC_NET_PKT 0
121 #define WILC_MGMT_PKT 2
123 #define WILC_CFG_SET 1
124 #define WILC_CFG_QUERY 0
126 #define WILC_CFG_RSP 1
127 #define WILC_CFG_RSP_STATUS 2
128 #define WILC_CFG_RSP_SCAN 3
130 #define WILC_PLL_TO_SDIO 4
131 #define WILC_PLL_TO_SPI 2
132 #define ABORT_INT BIT(31)
134 #define WILC_RX_BUFF_SIZE (96 * 1024)
135 #define WILC_TX_BUFF_SIZE (64 * 1024)
137 #define MODALIAS "WILC_SPI"
138 #define GPIO_NUM 0x44
139 /*******************************************/
140 /* E0 and later Interrupt flags. */
141 /*******************************************/
142 /*******************************************/
143 /* E0 and later Interrupt flags. */
144 /* IRQ Status word */
145 /* 15:0 = DMA count in words. */
152 /*******************************************/
153 #define IRG_FLAGS_OFFSET 16
154 #define IRQ_DMA_WD_CNT_MASK ((1ul << IRG_FLAGS_OFFSET) - 1)
155 #define INT_0 BIT(IRG_FLAGS_OFFSET)
156 #define INT_1 BIT(IRG_FLAGS_OFFSET + 1)
157 #define INT_2 BIT(IRG_FLAGS_OFFSET + 2)
158 #define INT_3 BIT(IRG_FLAGS_OFFSET + 3)
159 #define INT_4 BIT(IRG_FLAGS_OFFSET + 4)
160 #define INT_5 BIT(IRG_FLAGS_OFFSET + 5)
161 #define MAX_NUM_INT 6
163 /*******************************************/
164 /* E0 and later Interrupt flags. */
172 /* 6: Select VMM table 1 */
173 /* 7: Select VMM table 2 */
175 /*******************************************/
176 #define CLR_INT0 BIT(0)
177 #define CLR_INT1 BIT(1)
178 #define CLR_INT2 BIT(2)
179 #define CLR_INT3 BIT(3)
180 #define CLR_INT4 BIT(4)
181 #define CLR_INT5 BIT(5)
182 #define SEL_VMM_TBL0 BIT(6)
183 #define SEL_VMM_TBL1 BIT(7)
184 #define EN_VMM BIT(8)
186 #define DATA_INT_EXT INT_0
187 #define PLL_INT_EXT INT_1
188 #define SLEEP_INT_EXT INT_2
189 #define ALL_INT_EXT (DATA_INT_EXT | PLL_INT_EXT | SLEEP_INT_EXT)
190 #define NUM_INT_EXT 3
192 #define DATA_INT_CLR CLR_INT0
193 #define PLL_INT_CLR CLR_INT1
194 #define SLEEP_INT_CLR CLR_INT2
196 #define ENABLE_RX_VMM (SEL_VMM_TBL1 | EN_VMM)
197 #define ENABLE_TX_VMM (SEL_VMM_TBL0 | EN_VMM)
198 /*time for expiring the completion of cfg packets*/
199 #define WILC_CFG_PKTS_TIMEOUT msecs_to_jiffies(2000)
201 #define IS_MANAGMEMENT 0x100
202 #define IS_MANAGMEMENT_CALLBACK 0x080
203 #define IS_MGMT_STATUS_SUCCES 0x040
205 /********************************************
207 * Tx/Rx Queue Structure
209 ********************************************/
212 struct list_head list;
219 struct wilc_vif *vif;
220 void (*tx_complete_func)(void *priv, int status);
224 struct list_head list;
229 /********************************************
233 ********************************************/
235 struct wilc_hif_func {
236 int (*hif_init)(struct wilc *wilc, bool resume);
237 int (*hif_deinit)(struct wilc *wilc);
238 int (*hif_read_reg)(struct wilc *wilc, u32 addr, u32 *data);
239 int (*hif_write_reg)(struct wilc *wilc, u32 addr, u32 data);
240 int (*hif_block_rx)(struct wilc *wilc, u32 addr, u8 *buf, u32 size);
241 int (*hif_block_tx)(struct wilc *wilc, u32 addr, u8 *buf, u32 size);
242 int (*hif_read_int)(struct wilc *wilc, u32 *int_status);
243 int (*hif_clear_int_ext)(struct wilc *wilc, u32 val);
244 int (*hif_read_size)(struct wilc *wilc, u32 *size);
245 int (*hif_block_tx_ext)(struct wilc *wilc, u32 addr, u8 *buf, u32 size);
246 int (*hif_block_rx_ext)(struct wilc *wilc, u32 addr, u8 *buf, u32 size);
247 int (*hif_sync_ext)(struct wilc *wilc, int nint);
248 int (*enable_interrupt)(struct wilc *nic);
249 void (*disable_interrupt)(struct wilc *nic);
252 #define WILC_MAX_CFG_FRAME_SIZE 1468
254 struct tx_complete_data {
260 struct wilc_cfg_cmd_hdr {
264 __le32 driver_handler;
267 struct wilc_cfg_frame {
268 struct wilc_cfg_cmd_hdr hdr;
269 u8 frame[WILC_MAX_CFG_FRAME_SIZE];
272 struct wilc_cfg_rsp {
280 int wilc_wlan_firmware_download(struct wilc *wilc, const u8 *buffer,
282 int wilc_wlan_start(struct wilc *wilc);
283 int wilc_wlan_stop(struct wilc *wilc);
284 int wilc_wlan_txq_add_net_pkt(struct net_device *dev, void *priv, u8 *buffer,
286 void (*tx_complete_fn)(void *, int));
287 int wilc_wlan_handle_txq(struct wilc *wl, u32 *txq_count);
288 void wilc_handle_isr(struct wilc *wilc);
289 void wilc_wlan_cleanup(struct net_device *dev);
290 int wilc_wlan_cfg_set(struct wilc_vif *vif, int start, u16 wid, u8 *buffer,
291 u32 buffer_size, int commit, u32 drv_handler);
292 int wilc_wlan_cfg_get(struct wilc_vif *vif, int start, u16 wid, int commit,
294 int wilc_wlan_cfg_get_val(struct wilc *wl, u16 wid, u8 *buffer,
296 int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, void *priv, u8 *buffer,
297 u32 buffer_size, void (*func)(void *, int));
298 void wilc_chip_sleep_manually(struct wilc *wilc);
300 void wilc_enable_tcp_ack_filter(struct wilc_vif *vif, bool value);
301 int wilc_wlan_get_num_conn_ifcs(struct wilc *wilc);
302 netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct net_device *dev);
304 void wilc_wfi_p2p_rx(struct wilc_vif *vif, u8 *buff, u32 size);
305 void host_wakeup_notify(struct wilc *wilc);
306 void host_sleep_notify(struct wilc *wilc);
307 void chip_allow_sleep(struct wilc *wilc);
308 void chip_wakeup(struct wilc *wilc);
309 int wilc_send_config_pkt(struct wilc_vif *vif, u8 mode, struct wid *wids,
311 int wilc_wlan_init(struct net_device *dev);
312 u32 wilc_get_chipid(struct wilc *wilc, bool update);