20 #ifndef _MWIFIEX_SDIO_H
21 #define _MWIFIEX_SDIO_H
31 #define SD8786_DEFAULT_FW_NAME "mrvl/sd8786_uapsta.bin"
32 #define SD8787_DEFAULT_FW_NAME "mrvl/sd8787_uapsta.bin"
33 #define SD8797_DEFAULT_FW_NAME "mrvl/sd8797_uapsta.bin"
39 #define RD_BITMAP_L 0x04
40 #define RD_BITMAP_U 0x05
41 #define WR_BITMAP_L 0x06
42 #define WR_BITMAP_U 0x07
43 #define RD_LEN_P0_L 0x08
44 #define RD_LEN_P0_U 0x09
46 #define MWIFIEX_SDIO_IO_PORT_MASK 0xfffff
48 #define MWIFIEX_SDIO_BYTE_MODE_MASK 0x80000000
51 #define CTRL_PORT_MASK 0x0001
52 #define DATA_PORT_MASK 0xfffe
54 #define MAX_MP_REGS 64
57 #define SDIO_MP_AGGR_DEF_PKT_LIMIT 8
59 #define SDIO_MP_TX_AGGR_DEF_BUF_SIZE (8192)
62 #define SDIO_MP_RX_AGGR_DEF_BUF_SIZE (16384)
65 #define AUTO_RE_ENABLE_INT BIT(4)
69 #define IO_PORT_0_REG 0x78
71 #define IO_PORT_1_REG 0x79
73 #define IO_PORT_2_REG 0x7A
76 #define CONFIGURATION_REG 0x00
78 #define HOST_TO_CARD_EVENT (0x1U << 3)
80 #define HOST_WO_CMD53_FINISH_HOST (0x1U << 2)
82 #define HOST_POWER_UP (0x1U << 1)
84 #define HOST_POWER_DOWN (0x1U << 0)
87 #define HOST_INT_MASK_REG 0x02
89 #define UP_LD_HOST_INT_MASK (0x1U)
91 #define DN_LD_HOST_INT_MASK (0x2U)
93 #define HOST_INT_ENABLE (UP_LD_HOST_INT_MASK | DN_LD_HOST_INT_MASK)
95 #define HOST_INT_DISABLE 0xff
98 #define HOST_INTSTATUS_REG 0x03
100 #define UP_LD_HOST_INT_STATUS (0x1U)
102 #define DN_LD_HOST_INT_STATUS (0x2U)
105 #define HOST_INT_RSR_REG 0x01
107 #define UP_LD_HOST_INT_RSR (0x1U)
108 #define SDIO_INT_MASK 0x3F
111 #define HOST_INT_STATUS_REG 0x28
113 #define UP_LD_CRC_ERR (0x1U << 2)
115 #define UP_LD_RESTART (0x1U << 1)
117 #define DN_LD_RESTART (0x1U << 0)
120 #define CARD_STATUS_REG 0x30
122 #define CARD_IO_READY (0x1U << 3)
124 #define CIS_CARD_RDY (0x1U << 2)
126 #define UP_LD_CARD_RDY (0x1U << 1)
128 #define DN_LD_CARD_RDY (0x1U << 0)
131 #define HOST_INTERRUPT_MASK_REG 0x34
133 #define HOST_POWER_INT_MASK (0x1U << 3)
135 #define ABORT_CARD_INT_MASK (0x1U << 2)
137 #define UP_LD_CARD_INT_MASK (0x1U << 1)
139 #define DN_LD_CARD_INT_MASK (0x1U << 0)
142 #define CARD_INTERRUPT_STATUS_REG 0x38
144 #define POWER_UP_INT (0x1U << 4)
146 #define POWER_DOWN_INT (0x1U << 3)
149 #define CARD_INTERRUPT_RSR_REG 0x3c
151 #define POWER_UP_RSR (0x1U << 4)
153 #define POWER_DOWN_RSR (0x1U << 3)
156 #define CARD_MISC_CFG_REG 0x6C
159 #define HOST_F1_RD_BASE_0 0x0040
161 #define HOST_F1_RD_BASE_1 0x0041
163 #define HOST_F1_CARD_RDY 0x0020
166 #define CARD_FW_STATUS0_REG 0x60
168 #define CARD_FW_STATUS1_REG 0x61
170 #define CARD_RX_LEN_REG 0x62
172 #define CARD_RX_UNIT_REG 0x63
175 #define MAX_WRITE_IOMEM_RETRY 2
178 #define MP_TX_AGGR_IN_PROGRESS(a) (a->mpa_tx.pkt_cnt > 0)
181 #define MP_TX_AGGR_BUF_HAS_ROOM(a, len) ((a->mpa_tx.buf_len+len) \
182 <= a->mpa_tx.buf_size)
185 #define MP_TX_AGGR_BUF_PUT(a, payload, pkt_len, port) do { \
186 memmove(&a->mpa_tx.buf[a->mpa_tx.buf_len], \
188 a->mpa_tx.buf_len += pkt_len; \
189 if (!a->mpa_tx.pkt_cnt) \
190 a->mpa_tx.start_port = port; \
191 if (a->mpa_tx.start_port <= port) \
192 a->mpa_tx.ports |= (1<<(a->mpa_tx.pkt_cnt)); \
194 a->mpa_tx.ports |= (1<<(a->mpa_tx.pkt_cnt+1+(MAX_PORT - \
196 a->mpa_tx.pkt_cnt++; \
200 #define MP_TX_AGGR_PKT_LIMIT_REACHED(a) \
201 (a->mpa_tx.pkt_cnt == a->mpa_tx.pkt_aggr_limit)
204 #define MP_TX_AGGR_PORT_LIMIT_REACHED(a) ((a->curr_wr_port < \
205 a->mpa_tx.start_port) && (((MAX_PORT - \
206 a->mpa_tx.start_port) + a->curr_wr_port) >= \
207 SDIO_MP_AGGR_DEF_PKT_LIMIT))
210 #define MP_TX_AGGR_BUF_RESET(a) do { \
211 a->mpa_tx.pkt_cnt = 0; \
212 a->mpa_tx.buf_len = 0; \
213 a->mpa_tx.ports = 0; \
214 a->mpa_tx.start_port = 0; \
218 #define MP_RX_AGGR_PKT_LIMIT_REACHED(a) \
219 (a->mpa_rx.pkt_cnt == a->mpa_rx.pkt_aggr_limit)
222 #define MP_RX_AGGR_PORT_LIMIT_REACHED(a) ((a->curr_rd_port < \
223 a->mpa_rx.start_port) && (((MAX_PORT - \
224 a->mpa_rx.start_port) + a->curr_rd_port) >= \
225 SDIO_MP_AGGR_DEF_PKT_LIMIT))
228 #define MP_RX_AGGR_IN_PROGRESS(a) (a->mpa_rx.pkt_cnt > 0)
231 #define MP_RX_AGGR_BUF_HAS_ROOM(a, rx_len) \
232 ((a->mpa_rx.buf_len+rx_len) <= a->mpa_rx.buf_size)
235 #define MP_RX_AGGR_SETUP(a, skb, port) do { \
236 a->mpa_rx.buf_len += skb->len; \
237 if (!a->mpa_rx.pkt_cnt) \
238 a->mpa_rx.start_port = port; \
239 if (a->mpa_rx.start_port <= port) \
240 a->mpa_rx.ports |= (1<<(a->mpa_rx.pkt_cnt)); \
242 a->mpa_rx.ports |= (1<<(a->mpa_rx.pkt_cnt+1)); \
243 a->mpa_rx.skb_arr[a->mpa_rx.pkt_cnt] = skb; \
244 a->mpa_rx.len_arr[a->mpa_rx.pkt_cnt] = skb->len; \
245 a->mpa_rx.pkt_cnt++; \
249 #define MP_RX_AGGR_BUF_RESET(a) do { \
250 a->mpa_rx.pkt_cnt = 0; \
251 a->mpa_rx.buf_len = 0; \
252 a->mpa_rx.ports = 0; \
253 a->mpa_rx.start_port = 0; \