1 /* SPDX-License-Identifier: ISC */
2 /*
3  * Copyright (C) 2022 MediaTek Inc.
4  */
5 
6 #ifndef __MT7996_REGS_H
7 #define __MT7996_REGS_H
8 
9 struct __map {
10 	u32 phys;
11 	u32 mapped;
12 	u32 size;
13 };
14 
15 struct __base {
16 	u32 band_base[__MT_MAX_BAND];
17 };
18 
19 /* used to differentiate between generations */
20 struct mt7996_reg_desc {
21 	const struct __base *base;
22 	const struct __map *map;
23 	u32 map_size;
24 };
25 
26 enum base_rev {
27 	WF_AGG_BASE,
28 	WF_ARB_BASE,
29 	WF_TMAC_BASE,
30 	WF_RMAC_BASE,
31 	WF_DMA_BASE,
32 	WF_WTBLOFF_BASE,
33 	WF_ETBF_BASE,
34 	WF_LPON_BASE,
35 	WF_MIB_BASE,
36 	__MT_REG_BASE_MAX,
37 };
38 
39 #define __BASE(_id, _band)			(dev->reg.base[(_id)].band_base[(_band)])
40 
41 #define MT_MCU_INT_EVENT			0x2108
42 #define MT_MCU_INT_EVENT_DMA_STOPPED		BIT(0)
43 #define MT_MCU_INT_EVENT_DMA_INIT		BIT(1)
44 #define MT_MCU_INT_EVENT_RESET_DONE		BIT(3)
45 
46 /* PLE */
47 #define MT_PLE_BASE				0x820c0000
48 #define MT_PLE(ofs)				(MT_PLE_BASE + (ofs))
49 
50 #define MT_FL_Q_EMPTY				MT_PLE(0x360)
51 #define MT_FL_Q0_CTRL				MT_PLE(0x3e0)
52 #define MT_FL_Q2_CTRL				MT_PLE(0x3e8)
53 #define MT_FL_Q3_CTRL				MT_PLE(0x3ec)
54 
55 #define MT_PLE_FREEPG_CNT			MT_PLE(0x380)
56 #define MT_PLE_FREEPG_HEAD_TAIL			MT_PLE(0x384)
57 #define MT_PLE_PG_HIF_GROUP			MT_PLE(0x00c)
58 #define MT_PLE_HIF_PG_INFO			MT_PLE(0x388)
59 
60 #define MT_PLE_AC_QEMPTY(ac, n)			MT_PLE(0x600 +	0x80 * (ac) + ((n) << 2))
61 #define MT_PLE_AMSDU_PACK_MSDU_CNT(n)		MT_PLE(0x10e0 + ((n) << 2))
62 
63 /* WF MDP TOP */
64 #define MT_MDP_BASE				0x820cc000
65 #define MT_MDP(ofs)				(MT_MDP_BASE + (ofs))
66 
67 #define MT_MDP_DCR2				MT_MDP(0x8e8)
68 #define MT_MDP_DCR2_RX_TRANS_SHORT		BIT(2)
69 
70 /* TMAC: band 0(0x820e4000), band 1(0x820f4000), band 2(0x830e4000) */
71 #define MT_WF_TMAC_BASE(_band)			__BASE(WF_TMAC_BASE, (_band))
72 #define MT_WF_TMAC(_band, ofs)			(MT_WF_TMAC_BASE(_band) + (ofs))
73 
74 #define MT_TMAC_TCR0(_band)			MT_WF_TMAC(_band, 0)
75 #define MT_TMAC_TCR0_TX_BLINK			GENMASK(7, 6)
76 
77 #define MT_TMAC_CDTR(_band)			MT_WF_TMAC(_band, 0x0c8)
78 #define MT_TMAC_ODTR(_band)			MT_WF_TMAC(_band, 0x0cc)
79 #define MT_TIMEOUT_VAL_PLCP			GENMASK(15, 0)
80 #define MT_TIMEOUT_VAL_CCA			GENMASK(31, 16)
81 
82 #define MT_TMAC_ICR0(_band)			MT_WF_TMAC(_band, 0x014)
83 #define MT_IFS_EIFS_OFDM			GENMASK(8, 0)
84 #define MT_IFS_RIFS				GENMASK(14, 10)
85 #define MT_IFS_SIFS				GENMASK(22, 16)
86 #define MT_IFS_SLOT				GENMASK(30, 24)
87 
88 #define MT_TMAC_ICR1(_band)			MT_WF_TMAC(_band, 0x018)
89 #define MT_IFS_EIFS_CCK				GENMASK(8, 0)
90 
91 /* WF DMA TOP: band 0(0x820e7000), band 1(0x820f7000), band 2(0x830e7000) */
92 #define MT_WF_DMA_BASE(_band)			__BASE(WF_DMA_BASE, (_band))
93 #define MT_WF_DMA(_band, ofs)			(MT_WF_DMA_BASE(_band) + (ofs))
94 
95 #define MT_DMA_DCR0(_band)			MT_WF_DMA(_band, 0x000)
96 #define MT_DMA_DCR0_RXD_G5_EN			BIT(23)
97 
98 #define MT_DMA_TCRF1(_band)			MT_WF_DMA(_band, 0x054)
99 #define MT_DMA_TCRF1_QIDX			GENMASK(15, 13)
100 
101 /* WTBLOFF TOP: band 0(0x820e9000), band 1(0x820f9000), band 2(0x830e9000) */
102 #define MT_WTBLOFF_BASE(_band)			__BASE(WF_WTBLOFF_BASE, (_band))
103 #define MT_WTBLOFF(_band, ofs)			(MT_WTBLOFF_BASE(_band) + (ofs))
104 
105 #define MT_WTBLOFF_RSCR(_band)			MT_WTBLOFF(_band, 0x008)
106 #define MT_WTBLOFF_RSCR_RCPI_MODE		GENMASK(31, 30)
107 #define MT_WTBLOFF_RSCR_RCPI_PARAM		GENMASK(25, 24)
108 
109 /* ETBF: band 0(0x820ea000), band 1(0x820fa000), band 2(0x830ea000) */
110 #define MT_WF_ETBF_BASE(_band)			__BASE(WF_ETBF_BASE, (_band))
111 #define MT_WF_ETBF(_band, ofs)			(MT_WF_ETBF_BASE(_band) + (ofs))
112 
113 #define MT_ETBF_RX_FB_CONT(_band)		MT_WF_ETBF(_band, 0x100)
114 #define MT_ETBF_RX_FB_BW			GENMASK(10, 8)
115 #define MT_ETBF_RX_FB_NC			GENMASK(7, 4)
116 #define MT_ETBF_RX_FB_NR			GENMASK(3, 0)
117 
118 /* LPON: band 0(0x820eb000), band 1(0x820fb000), band 2(0x830eb000) */
119 #define MT_WF_LPON_BASE(_band)			__BASE(WF_LPON_BASE, (_band))
120 #define MT_WF_LPON(_band, ofs)			(MT_WF_LPON_BASE(_band) + (ofs))
121 
122 #define MT_LPON_UTTR0(_band)			MT_WF_LPON(_band, 0x360)
123 #define MT_LPON_UTTR1(_band)			MT_WF_LPON(_band, 0x364)
124 #define MT_LPON_FRCR(_band)			MT_WF_LPON(_band, 0x37c)
125 
126 #define MT_LPON_TCR(_band, n)			MT_WF_LPON(_band, 0x0a8 + (((n) * 4) << 4))
127 #define MT_LPON_TCR_SW_MODE			GENMASK(1, 0)
128 #define MT_LPON_TCR_SW_WRITE			BIT(0)
129 #define MT_LPON_TCR_SW_ADJUST			BIT(1)
130 #define MT_LPON_TCR_SW_READ			GENMASK(1, 0)
131 
132 /* MIB: band 0(0x820ed000), band 1(0x820fd000), band 2(0x830ed000)*/
133 /* These counters are (mostly?) clear-on-read.  So, some should not
134  * be read at all in case firmware is already reading them.  These
135  * are commented with 'DNR' below. The DNR stats will be read by querying
136  * the firmware API for the appropriate message.  For counters the driver
137  * does read, the driver should accumulate the counters.
138  */
139 #define MT_WF_MIB_BASE(_band)			__BASE(WF_MIB_BASE, (_band))
140 #define MT_WF_MIB(_band, ofs)			(MT_WF_MIB_BASE(_band) + (ofs))
141 
142 #define MT_MIB_BSCR0(_band)			MT_WF_MIB(_band, 0x9cc)
143 #define MT_MIB_BSCR1(_band)			MT_WF_MIB(_band, 0x9d0)
144 #define MT_MIB_BSCR2(_band)			MT_WF_MIB(_band, 0x9d4)
145 #define MT_MIB_BSCR3(_band)			MT_WF_MIB(_band, 0x9d8)
146 #define MT_MIB_BSCR4(_band)			MT_WF_MIB(_band, 0x9dc)
147 #define MT_MIB_BSCR5(_band)			MT_WF_MIB(_band, 0x9e0)
148 #define MT_MIB_BSCR6(_band)			MT_WF_MIB(_band, 0x9e4)
149 #define MT_MIB_BSCR7(_band)			MT_WF_MIB(_band, 0x9e8)
150 #define MT_MIB_BSCR17(_band)			MT_WF_MIB(_band, 0xa10)
151 
152 #define MT_MIB_TSCR5(_band)			MT_WF_MIB(_band, 0x6c4)
153 #define MT_MIB_TSCR6(_band)			MT_WF_MIB(_band, 0x6c8)
154 #define MT_MIB_TSCR7(_band)			MT_WF_MIB(_band, 0x6d0)
155 
156 #define MT_MIB_RSCR1(_band)			MT_WF_MIB(_band, 0x7ac)
157 /* rx mpdu counter, full 32 bits */
158 #define MT_MIB_RSCR31(_band)			MT_WF_MIB(_band, 0x964)
159 #define MT_MIB_RSCR33(_band)			MT_WF_MIB(_band, 0x96c)
160 
161 #define MT_MIB_SDR6(_band)			MT_WF_MIB(_band, 0x020)
162 #define MT_MIB_SDR6_CHANNEL_IDL_CNT_MASK	GENMASK(15, 0)
163 
164 #define MT_MIB_RVSR0(_band)			MT_WF_MIB(_band, 0x720)
165 
166 #define MT_MIB_RSCR35(_band)			MT_WF_MIB(_band, 0x974)
167 #define MT_MIB_RSCR36(_band)			MT_WF_MIB(_band, 0x978)
168 
169 /* tx ampdu cnt, full 32 bits */
170 #define MT_MIB_TSCR0(_band)			MT_WF_MIB(_band, 0x6b0)
171 #define MT_MIB_TSCR2(_band)			MT_WF_MIB(_band, 0x6b8)
172 
173 /* counts all mpdus in ampdu, regardless of success */
174 #define MT_MIB_TSCR3(_band)			MT_WF_MIB(_band, 0x6bc)
175 
176 /* counts all successfully tx'd mpdus in ampdu */
177 #define MT_MIB_TSCR4(_band)			MT_WF_MIB(_band, 0x6c0)
178 
179 /* rx ampdu count, 32-bit */
180 #define MT_MIB_RSCR27(_band)			MT_WF_MIB(_band, 0x954)
181 
182 /* rx ampdu bytes count, 32-bit */
183 #define MT_MIB_RSCR28(_band)			MT_WF_MIB(_band, 0x958)
184 
185 /* rx ampdu valid subframe count */
186 #define MT_MIB_RSCR29(_band)			MT_WF_MIB(_band, 0x95c)
187 
188 /* rx ampdu valid subframe bytes count, 32bits */
189 #define MT_MIB_RSCR30(_band)			MT_WF_MIB(_band, 0x960)
190 
191 /* remaining windows protected stats */
192 #define MT_MIB_SDR27(_band)			MT_WF_MIB(_band, 0x080)
193 #define MT_MIB_SDR27_TX_RWP_FAIL_CNT		GENMASK(15, 0)
194 
195 #define MT_MIB_SDR28(_band)			MT_WF_MIB(_band, 0x084)
196 #define MT_MIB_SDR28_TX_RWP_NEED_CNT		GENMASK(15, 0)
197 
198 #define MT_MIB_RVSR1(_band)			MT_WF_MIB(_band, 0x724)
199 
200 /* rx blockack count, 32 bits */
201 #define MT_MIB_TSCR1(_band)			MT_WF_MIB(_band, 0x6b4)
202 
203 #define MT_MIB_BTSCR0(_band)			MT_WF_MIB(_band, 0x5e0)
204 #define MT_MIB_BTSCR5(_band)			MT_WF_MIB(_band, 0x788)
205 #define MT_MIB_BTSCR6(_band)			MT_WF_MIB(_band, 0x798)
206 
207 #define MT_MIB_BFTFCR(_band)			MT_WF_MIB(_band, 0x5d0)
208 
209 #define MT_TX_AGG_CNT(_band, n)			MT_WF_MIB(_band, 0xa28 + ((n) << 2))
210 #define MT_MIB_ARNG(_band, n)			MT_WF_MIB(_band, 0x0b0 + ((n) << 2))
211 #define MT_MIB_ARNCR_RANGE(val, n)		(((val) >> ((n) << 4)) & GENMASK(9, 0))
212 
213 /* UMIB */
214 #define MT_WF_UMIB_BASE				0x820cd000
215 #define MT_WF_UMIB(ofs)				(MT_WF_UMIB_BASE + (ofs))
216 
217 #define MT_UMIB_RPDCR(_band)			(MT_WF_UMIB(0x594) + (_band) * 0x164)
218 
219 /* WTBLON TOP */
220 #define MT_WTBLON_TOP_BASE			0x820d4000
221 #define MT_WTBLON_TOP(ofs)			(MT_WTBLON_TOP_BASE + (ofs))
222 #define MT_WTBLON_TOP_WDUCR			MT_WTBLON_TOP(0x370)
223 #define MT_WTBLON_TOP_WDUCR_GROUP		GENMASK(4, 0)
224 
225 #define MT_WTBL_UPDATE				MT_WTBLON_TOP(0x380)
226 #define MT_WTBL_UPDATE_WLAN_IDX			GENMASK(11, 0)
227 #define MT_WTBL_UPDATE_ADM_COUNT_CLEAR		BIT(14)
228 #define MT_WTBL_UPDATE_BUSY			BIT(31)
229 
230 /* WTBL */
231 #define MT_WTBL_BASE				0x820d8000
232 #define MT_WTBL_LMAC_ID				GENMASK(14, 8)
233 #define MT_WTBL_LMAC_DW				GENMASK(7, 2)
234 #define MT_WTBL_LMAC_OFFS(_id, _dw)		(MT_WTBL_BASE | \
235 						 FIELD_PREP(MT_WTBL_LMAC_ID, _id) | \
236 						 FIELD_PREP(MT_WTBL_LMAC_DW, _dw))
237 
238 /* AGG: band 0(0x820e2000), band 1(0x820f2000), band 2(0x830e2000) */
239 #define MT_WF_AGG_BASE(_band)			__BASE(WF_AGG_BASE, (_band))
240 #define MT_WF_AGG(_band, ofs)			(MT_WF_AGG_BASE(_band) + (ofs))
241 
242 #define MT_AGG_ACR0(_band)			MT_WF_AGG(_band, 0x054)
243 #define MT_AGG_ACR_CFEND_RATE			GENMASK(13, 0)
244 
245 /* ARB: band 0(0x820e3000), band 1(0x820f3000), band 2(0x830e3000) */
246 #define MT_WF_ARB_BASE(_band)			__BASE(WF_ARB_BASE, (_band))
247 #define MT_WF_ARB(_band, ofs)			(MT_WF_ARB_BASE(_band) + (ofs))
248 
249 #define MT_ARB_SCR(_band)			MT_WF_ARB(_band, 0x000)
250 #define MT_ARB_SCR_TX_DISABLE			BIT(8)
251 #define MT_ARB_SCR_RX_DISABLE			BIT(9)
252 
253 /* RMAC: band 0(0x820e5000), band 1(0x820f5000), band 2(0x830e5000), */
254 #define MT_WF_RMAC_BASE(_band)			__BASE(WF_RMAC_BASE, (_band))
255 #define MT_WF_RMAC(_band, ofs)			(MT_WF_RMAC_BASE(_band) + (ofs))
256 
257 #define MT_WF_RFCR(_band)			MT_WF_RMAC(_band, 0x000)
258 #define MT_WF_RFCR_DROP_STBC_MULTI		BIT(0)
259 #define MT_WF_RFCR_DROP_FCSFAIL			BIT(1)
260 #define MT_WF_RFCR_DROP_PROBEREQ		BIT(4)
261 #define MT_WF_RFCR_DROP_MCAST			BIT(5)
262 #define MT_WF_RFCR_DROP_BCAST			BIT(6)
263 #define MT_WF_RFCR_DROP_MCAST_FILTERED		BIT(7)
264 #define MT_WF_RFCR_DROP_A3_MAC			BIT(8)
265 #define MT_WF_RFCR_DROP_A3_BSSID		BIT(9)
266 #define MT_WF_RFCR_DROP_A2_BSSID		BIT(10)
267 #define MT_WF_RFCR_DROP_OTHER_BEACON		BIT(11)
268 #define MT_WF_RFCR_DROP_FRAME_REPORT		BIT(12)
269 #define MT_WF_RFCR_DROP_CTL_RSV			BIT(13)
270 #define MT_WF_RFCR_DROP_CTS			BIT(14)
271 #define MT_WF_RFCR_DROP_RTS			BIT(15)
272 #define MT_WF_RFCR_DROP_DUPLICATE		BIT(16)
273 #define MT_WF_RFCR_DROP_OTHER_BSS		BIT(17)
274 #define MT_WF_RFCR_DROP_OTHER_UC		BIT(18)
275 #define MT_WF_RFCR_DROP_OTHER_TIM		BIT(19)
276 #define MT_WF_RFCR_DROP_NDPA			BIT(20)
277 #define MT_WF_RFCR_DROP_UNWANTED_CTL		BIT(21)
278 
279 #define MT_WF_RFCR1(_band)			MT_WF_RMAC(_band, 0x004)
280 #define MT_WF_RFCR1_DROP_ACK			BIT(4)
281 #define MT_WF_RFCR1_DROP_BF_POLL		BIT(5)
282 #define MT_WF_RFCR1_DROP_BA			BIT(6)
283 #define MT_WF_RFCR1_DROP_CFEND			BIT(7)
284 #define MT_WF_RFCR1_DROP_CFACK			BIT(8)
285 
286 #define MT_WF_RMAC_MIB_AIRTIME0(_band)		MT_WF_RMAC(_band, 0x0380)
287 #define MT_WF_RMAC_MIB_RXTIME_CLR		BIT(31)
288 #define MT_WF_RMAC_MIB_ED_OFFSET		GENMASK(20, 16)
289 #define MT_WF_RMAC_MIB_OBSS_BACKOFF		GENMASK(15, 0)
290 
291 #define MT_WF_RMAC_MIB_AIRTIME1(_band)		MT_WF_RMAC(_band, 0x0384)
292 #define MT_WF_RMAC_MIB_NONQOSD_BACKOFF		GENMASK(31, 16)
293 
294 #define MT_WF_RMAC_MIB_AIRTIME3(_band)		MT_WF_RMAC(_band, 0x038c)
295 #define MT_WF_RMAC_MIB_QOS01_BACKOFF		GENMASK(31, 0)
296 
297 #define MT_WF_RMAC_MIB_AIRTIME4(_band)		MT_WF_RMAC(_band, 0x0390)
298 #define MT_WF_RMAC_MIB_QOS23_BACKOFF		GENMASK(31, 0)
299 
300 #define MT_WF_RMAC_RSVD0(_band)			MT_WF_RMAC(_band, 0x03e0)
301 #define MT_WF_RMAC_RSVD0_EIFS_CLR		BIT(21)
302 
303 /* WFDMA0 */
304 #define MT_WFDMA0_BASE				0xd4000
305 #define MT_WFDMA0(ofs)				(MT_WFDMA0_BASE + (ofs))
306 
307 #define MT_WFDMA0_RST				MT_WFDMA0(0x100)
308 #define MT_WFDMA0_RST_LOGIC_RST			BIT(4)
309 #define MT_WFDMA0_RST_DMASHDL_ALL_RST		BIT(5)
310 
311 #define MT_WFDMA0_BUSY_ENA			MT_WFDMA0(0x13c)
312 #define MT_WFDMA0_BUSY_ENA_TX_FIFO0		BIT(0)
313 #define MT_WFDMA0_BUSY_ENA_TX_FIFO1		BIT(1)
314 #define MT_WFDMA0_BUSY_ENA_RX_FIFO		BIT(2)
315 
316 #define MT_WFDMA0_RX_INT_PCIE_SEL		MT_WFDMA0(0x154)
317 #define MT_WFDMA0_RX_INT_SEL_RING3		BIT(3)
318 
319 #define MT_WFDMA0_GLO_CFG			MT_WFDMA0(0x208)
320 #define MT_WFDMA0_GLO_CFG_TX_DMA_EN		BIT(0)
321 #define MT_WFDMA0_GLO_CFG_RX_DMA_EN		BIT(2)
322 #define MT_WFDMA0_GLO_CFG_OMIT_TX_INFO		BIT(28)
323 #define MT_WFDMA0_GLO_CFG_OMIT_RX_INFO		BIT(27)
324 #define MT_WFDMA0_GLO_CFG_OMIT_RX_INFO_PFET2	BIT(21)
325 
326 #define WF_WFDMA0_GLO_CFG_EXT0			MT_WFDMA0(0x2b0)
327 #define WF_WFDMA0_GLO_CFG_EXT0_RX_WB_RXD	BIT(18)
328 #define WF_WFDMA0_GLO_CFG_EXT0_WED_MERGE_MODE	BIT(14)
329 
330 #define WF_WFDMA0_GLO_CFG_EXT1			MT_WFDMA0(0x2b4)
331 #define WF_WFDMA0_GLO_CFG_EXT1_CALC_MODE	BIT(31)
332 #define WF_WFDMA0_GLO_CFG_EXT1_TX_FCTRL_MODE	BIT(28)
333 
334 #define MT_WFDMA0_RST_DTX_PTR			MT_WFDMA0(0x20c)
335 #define MT_WFDMA0_PRI_DLY_INT_CFG0		MT_WFDMA0(0x2f0)
336 #define MT_WFDMA0_PRI_DLY_INT_CFG1		MT_WFDMA0(0x2f4)
337 #define MT_WFDMA0_PRI_DLY_INT_CFG2		MT_WFDMA0(0x2f8)
338 
339 /* WFDMA1 */
340 #define MT_WFDMA1_BASE				0xd5000
341 
342 /* WFDMA CSR */
343 #define MT_WFDMA_EXT_CSR_BASE			0xd7000
344 #define MT_WFDMA_EXT_CSR(ofs)			(MT_WFDMA_EXT_CSR_BASE + (ofs))
345 
346 #define MT_WFDMA_HOST_CONFIG			MT_WFDMA_EXT_CSR(0x30)
347 #define MT_WFDMA_HOST_CONFIG_PDMA_BAND		BIT(0)
348 
349 #define MT_WFDMA_EXT_CSR_HIF_MISC		MT_WFDMA_EXT_CSR(0x44)
350 #define MT_WFDMA_EXT_CSR_HIF_MISC_BUSY		BIT(0)
351 
352 #define MT_PCIE_RECOG_ID			0xd7090
353 #define MT_PCIE_RECOG_ID_MASK			GENMASK(30, 0)
354 #define MT_PCIE_RECOG_ID_SEM			BIT(31)
355 
356 /* WFDMA0 PCIE1 */
357 #define MT_WFDMA0_PCIE1_BASE			0xd8000
358 #define MT_WFDMA0_PCIE1(ofs)			(MT_WFDMA0_PCIE1_BASE + (ofs))
359 
360 #define MT_WFDMA0_PCIE1_BUSY_ENA		MT_WFDMA0_PCIE1(0x13c)
361 #define MT_WFDMA0_PCIE1_BUSY_ENA_TX_FIFO0	BIT(0)
362 #define MT_WFDMA0_PCIE1_BUSY_ENA_TX_FIFO1	BIT(1)
363 #define MT_WFDMA0_PCIE1_BUSY_ENA_RX_FIFO	BIT(2)
364 
365 /* WFDMA COMMON */
366 #define __RXQ(q)				((q) + __MT_MCUQ_MAX)
367 #define __TXQ(q)				(__RXQ(q) + __MT_RXQ_MAX)
368 
369 #define MT_Q_ID(q)				(dev->q_id[(q)])
370 #define MT_Q_BASE(q)				((dev->q_wfdma_mask >> (q)) & 0x1 ?	\
371 						 MT_WFDMA1_BASE : MT_WFDMA0_BASE)
372 
373 #define MT_MCUQ_ID(q)				MT_Q_ID(q)
374 #define MT_TXQ_ID(q)				MT_Q_ID(__TXQ(q))
375 #define MT_RXQ_ID(q)				MT_Q_ID(__RXQ(q))
376 
377 #define MT_MCUQ_RING_BASE(q)			(MT_Q_BASE(q) + 0x300)
378 #define MT_TXQ_RING_BASE(q)			(MT_Q_BASE(__TXQ(q)) + 0x300)
379 #define MT_RXQ_RING_BASE(q)			(MT_Q_BASE(__RXQ(q)) + 0x500)
380 
381 #define MT_MCUQ_EXT_CTRL(q)			(MT_Q_BASE(q) +	0x600 +	\
382 						 MT_MCUQ_ID(q) * 0x4)
383 #define MT_RXQ_BAND1_CTRL(q)			(MT_Q_BASE(__RXQ(q)) + 0x680 +	\
384 						 MT_RXQ_ID(q) * 0x4)
385 #define MT_TXQ_EXT_CTRL(q)			(MT_Q_BASE(__TXQ(q)) + 0x600 +	\
386 						 MT_TXQ_ID(q) * 0x4)
387 
388 #define MT_INT_SOURCE_CSR			MT_WFDMA0(0x200)
389 #define MT_INT_MASK_CSR				MT_WFDMA0(0x204)
390 
391 #define MT_INT1_SOURCE_CSR			MT_WFDMA0_PCIE1(0x200)
392 #define MT_INT1_MASK_CSR			MT_WFDMA0_PCIE1(0x204)
393 
394 #define MT_INT_RX_DONE_BAND0			BIT(12)
395 #define MT_INT_RX_DONE_BAND1			BIT(12)
396 #define MT_INT_RX_DONE_BAND2			BIT(13)
397 #define MT_INT_RX_DONE_WM			BIT(0)
398 #define MT_INT_RX_DONE_WA			BIT(1)
399 #define MT_INT_RX_DONE_WA_MAIN			BIT(2)
400 #define MT_INT_RX_DONE_WA_EXT			BIT(2)
401 #define MT_INT_RX_DONE_WA_TRI			BIT(3)
402 #define MT_INT_RX_TXFREE_MAIN			BIT(17)
403 #define MT_INT_RX_TXFREE_TRI			BIT(15)
404 #define MT_INT_MCU_CMD				BIT(29)
405 
406 #define MT_INT_RX(q)				(dev->q_int_mask[__RXQ(q)])
407 #define MT_INT_TX_MCU(q)			(dev->q_int_mask[(q)])
408 
409 #define MT_INT_RX_DONE_MCU			(MT_INT_RX(MT_RXQ_MCU) |	\
410 						 MT_INT_RX(MT_RXQ_MCU_WA))
411 
412 #define MT_INT_BAND0_RX_DONE			(MT_INT_RX(MT_RXQ_MAIN) |	\
413 						 MT_INT_RX(MT_RXQ_MAIN_WA))
414 
415 #define MT_INT_BAND1_RX_DONE			(MT_INT_RX(MT_RXQ_BAND1) |	\
416 						 MT_INT_RX(MT_RXQ_BAND1_WA) |	\
417 						 MT_INT_RX(MT_RXQ_MAIN_WA))
418 
419 #define MT_INT_BAND2_RX_DONE			(MT_INT_RX(MT_RXQ_BAND2) |	\
420 						 MT_INT_RX(MT_RXQ_BAND2_WA) |	\
421 						 MT_INT_RX(MT_RXQ_MAIN_WA))
422 
423 #define MT_INT_RX_DONE_ALL			(MT_INT_RX_DONE_MCU |		\
424 						 MT_INT_BAND0_RX_DONE |		\
425 						 MT_INT_BAND1_RX_DONE |		\
426 						 MT_INT_BAND2_RX_DONE)
427 
428 #define MT_INT_TX_DONE_FWDL			BIT(26)
429 #define MT_INT_TX_DONE_MCU_WM			BIT(27)
430 #define MT_INT_TX_DONE_MCU_WA			BIT(22)
431 #define MT_INT_TX_DONE_BAND0			BIT(30)
432 #define MT_INT_TX_DONE_BAND1			BIT(31)
433 #define MT_INT_TX_DONE_BAND2			BIT(15)
434 
435 #define MT_INT_TX_DONE_MCU			(MT_INT_TX_MCU(MT_MCUQ_WA) |	\
436 						 MT_INT_TX_MCU(MT_MCUQ_WM) |	\
437 						 MT_INT_TX_MCU(MT_MCUQ_FWDL))
438 
439 #define MT_MCU_CMD				MT_WFDMA0(0x1f0)
440 #define MT_MCU_CMD_STOP_DMA			BIT(2)
441 #define MT_MCU_CMD_RESET_DONE			BIT(3)
442 #define MT_MCU_CMD_RECOVERY_DONE		BIT(4)
443 #define MT_MCU_CMD_NORMAL_STATE			BIT(5)
444 #define MT_MCU_CMD_ERROR_MASK			GENMASK(5, 1)
445 
446 /* l1/l2 remap */
447 #define MT_HIF_REMAP_L1				0x155024
448 #define MT_HIF_REMAP_L1_MASK			GENMASK(31, 16)
449 #define MT_HIF_REMAP_L1_OFFSET			GENMASK(15, 0)
450 #define MT_HIF_REMAP_L1_BASE			GENMASK(31, 16)
451 #define MT_HIF_REMAP_BASE_L1			0x130000
452 
453 #define MT_HIF_REMAP_L2				0x1b4
454 #define MT_HIF_REMAP_L2_MASK			GENMASK(19, 0)
455 #define MT_HIF_REMAP_L2_OFFSET			GENMASK(11, 0)
456 #define MT_HIF_REMAP_L2_BASE			GENMASK(31, 12)
457 #define MT_HIF_REMAP_BASE_L2			0x1000
458 
459 #define MT_INFRA_BASE				0x18000000
460 #define MT_WFSYS0_PHY_START			0x18400000
461 #define MT_WFSYS1_PHY_START			0x18800000
462 #define MT_WFSYS1_PHY_END			0x18bfffff
463 #define MT_CBTOP1_PHY_START			0x70000000
464 #define MT_CBTOP1_PHY_END			0x77ffffff
465 #define MT_CBTOP2_PHY_START			0xf0000000
466 #define MT_CBTOP2_PHY_END			0xffffffff
467 #define MT_INFRA_MCU_START			0x7c000000
468 #define MT_INFRA_MCU_END			0x7c3fffff
469 
470 /* FW MODE SYNC */
471 #define MT_SWDEF_MODE				0x9143c
472 #define MT_SWDEF_NORMAL_MODE			0
473 
474 /* LED */
475 #define MT_LED_TOP_BASE				0x18013000
476 #define MT_LED_PHYS(_n)				(MT_LED_TOP_BASE + (_n))
477 
478 #define MT_LED_CTRL(_n)				MT_LED_PHYS(0x00 + ((_n) * 4))
479 #define MT_LED_CTRL_KICK			BIT(7)
480 #define MT_LED_CTRL_BLINK_MODE			BIT(2)
481 #define MT_LED_CTRL_POLARITY			BIT(1)
482 
483 #define MT_LED_TX_BLINK(_n)			MT_LED_PHYS(0x10 + ((_n) * 4))
484 #define MT_LED_TX_BLINK_ON_MASK			GENMASK(7, 0)
485 #define MT_LED_TX_BLINK_OFF_MASK		GENMASK(15, 8)
486 
487 #define MT_LED_EN(_n)				MT_LED_PHYS(0x40 + ((_n) * 4))
488 
489 #define MT_LED_GPIO_MUX2			0x70005058 /* GPIO 18 */
490 #define MT_LED_GPIO_MUX3			0x7000505C /* GPIO 26 */
491 #define MT_LED_GPIO_SEL_MASK			GENMASK(11, 8)
492 
493 /* MT TOP */
494 #define MT_TOP_BASE				0xe0000
495 #define MT_TOP(ofs)				(MT_TOP_BASE + (ofs))
496 
497 #define MT_TOP_LPCR_HOST_BAND(_band)		MT_TOP(0x10 + ((_band) * 0x10))
498 #define MT_TOP_LPCR_HOST_FW_OWN			BIT(0)
499 #define MT_TOP_LPCR_HOST_DRV_OWN		BIT(1)
500 #define MT_TOP_LPCR_HOST_FW_OWN_STAT		BIT(2)
501 
502 #define MT_TOP_LPCR_HOST_BAND_IRQ_STAT(_band)	MT_TOP(0x14 + ((_band) * 0x10))
503 #define MT_TOP_LPCR_HOST_BAND_STAT		BIT(0)
504 
505 #define MT_TOP_MISC				MT_TOP(0xf0)
506 #define MT_TOP_MISC_FW_STATE			GENMASK(2, 0)
507 
508 #define MT_HW_REV				0x70010204
509 #define MT_WF_SUBSYS_RST			0x70002600
510 
511 /* PCIE MAC */
512 #define MT_PCIE_MAC_BASE			0x74030000
513 #define MT_PCIE_MAC(ofs)			(MT_PCIE_MAC_BASE + (ofs))
514 #define MT_PCIE_MAC_INT_ENABLE			MT_PCIE_MAC(0x188)
515 
516 #define MT_PCIE1_MAC_BASE			0x74090000
517 #define MT_PCIE1_MAC(ofs)			(MT_PCIE1_MAC_BASE + (ofs))
518 
519 #define MT_PCIE1_MAC_INT_ENABLE			MT_PCIE1_MAC(0x188)
520 
521 /* PHYRX CTRL */
522 #define MT_WF_PHYRX_BAND_BASE			0x83080000
523 #define MT_WF_PHYRX_BAND(_band, ofs)		(MT_WF_PHYRX_BAND_BASE + \
524 						 ((_band) << 20) + (ofs))
525 
526 #define MT_WF_PHYRX_BAND_RX_CTRL1(_band)	MT_WF_PHYRX_BAND(_band, 0x2004)
527 #define MT_WF_PHYRX_BAND_RX_CTRL1_IPI_EN	GENMASK(2, 0)
528 #define MT_WF_PHYRX_BAND_RX_CTRL1_STSCNT_EN	GENMASK(11, 9)
529 
530 /* PHYRX CSD */
531 #define MT_WF_PHYRX_CSD_BASE			0x83000000
532 #define MT_WF_PHYRX_CSD(_band, _wf, ofs)	(MT_WF_PHYRX_CSD_BASE + \
533 						 ((_band) << 20) + \
534 						 ((_wf) << 16) + (ofs))
535 #define MT_WF_PHYRX_CSD_IRPI(_band, _wf)	MT_WF_PHYRX_CSD(_band, _wf, 0x1000)
536 
537 /* PHYRX CSD BAND */
538 #define MT_WF_PHYRX_CSD_BAND_RXTD12(_band)		MT_WF_PHYRX_BAND(_band, 0x8230)
539 #define MT_WF_PHYRX_CSD_BAND_RXTD12_IRPI_SW_CLR_ONLY	BIT(18)
540 #define MT_WF_PHYRX_CSD_BAND_RXTD12_IRPI_SW_CLR		BIT(29)
541 
542 #endif
543