1e3ec7017SPing-Ke Shih /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2e3ec7017SPing-Ke Shih /* Copyright(c) 2020  Realtek Corporation
3e3ec7017SPing-Ke Shih  */
4e3ec7017SPing-Ke Shih 
5e3ec7017SPing-Ke Shih #ifndef __RTW89_PCI_H__
6e3ec7017SPing-Ke Shih #define __RTW89_PCI_H__
7e3ec7017SPing-Ke Shih 
8e3ec7017SPing-Ke Shih #include "txrx.h"
9e3ec7017SPing-Ke Shih 
10e3ec7017SPing-Ke Shih #define MDIO_PG0_G1 0
11e3ec7017SPing-Ke Shih #define MDIO_PG1_G1 1
12e3ec7017SPing-Ke Shih #define MDIO_PG0_G2 2
13e3ec7017SPing-Ke Shih #define MDIO_PG1_G2 3
148f308ae3SChia-Yuan Li #define RAC_CTRL_PPR			0x00
158f308ae3SChia-Yuan Li #define RAC_ANA0A			0x0A
168f308ae3SChia-Yuan Li #define B_BAC_EQ_SEL			BIT(5)
178f308ae3SChia-Yuan Li #define RAC_ANA0C			0x0C
188f308ae3SChia-Yuan Li #define B_PCIE_BIT_PSAVE		BIT(15)
19e3ec7017SPing-Ke Shih #define RAC_ANA10			0x10
208f308ae3SChia-Yuan Li #define B_PCIE_BIT_PINOUT_DIS		BIT(3)
21740c431cSPing-Ke Shih #define RAC_REG_REV2			0x1B
22740c431cSPing-Ke Shih #define BAC_CMU_EN_DLY_MASK		GENMASK(15, 12)
23740c431cSPing-Ke Shih #define PCIE_DPHY_DLY_25US		0x1
24e3ec7017SPing-Ke Shih #define RAC_ANA19			0x19
258f308ae3SChia-Yuan Li #define B_PCIE_BIT_RD_SEL		BIT(2)
269e6e66ffSPing-Ke Shih #define RAC_REG_FLD_0			0x1D
279e6e66ffSPing-Ke Shih #define BAC_AUTOK_N_MASK		GENMASK(3, 2)
289e6e66ffSPing-Ke Shih #define PCIE_AUTOK_4			0x3
29e3ec7017SPing-Ke Shih #define RAC_ANA1F			0x1F
30e3ec7017SPing-Ke Shih #define RAC_ANA24			0x24
31e3ec7017SPing-Ke Shih #define B_AX_DEGLITCH			GENMASK(11, 8)
32e3ec7017SPing-Ke Shih #define RAC_ANA26			0x26
33e3ec7017SPing-Ke Shih #define B_AX_RXEN			GENMASK(15, 14)
34e3ec7017SPing-Ke Shih #define RAC_CTRL_PPR_V1			0x30
35e3ec7017SPing-Ke Shih #define B_AX_CLK_CALIB_EN		BIT(12)
36e3ec7017SPing-Ke Shih #define B_AX_CALIB_EN			BIT(13)
37e3ec7017SPing-Ke Shih #define B_AX_DIV			GENMASK(15, 14)
38e3ec7017SPing-Ke Shih #define RAC_SET_PPR_V1			0x31
39e3ec7017SPing-Ke Shih 
40e3ec7017SPing-Ke Shih #define R_AX_DBI_FLAG			0x1090
41e3ec7017SPing-Ke Shih #define B_AX_DBI_RFLAG			BIT(17)
42e3ec7017SPing-Ke Shih #define B_AX_DBI_WFLAG			BIT(16)
43e3ec7017SPing-Ke Shih #define B_AX_DBI_WREN_MSK		GENMASK(15, 12)
44e3ec7017SPing-Ke Shih #define B_AX_DBI_ADDR_MSK		GENMASK(11, 2)
45e3ec7017SPing-Ke Shih #define R_AX_DBI_WDATA			0x1094
46e3ec7017SPing-Ke Shih #define R_AX_DBI_RDATA			0x1098
47e3ec7017SPing-Ke Shih 
48e3ec7017SPing-Ke Shih #define R_AX_MDIO_WDATA			0x10A4
49e3ec7017SPing-Ke Shih #define R_AX_MDIO_RDATA			0x10A6
50e3ec7017SPing-Ke Shih 
51e1e7a574SPing-Ke Shih #define R_AX_PCIE_PS_CTRL_V1		0x3008
52e1e7a574SPing-Ke Shih #define B_AX_CMAC_EXIT_L1_EN		BIT(7)
53e1e7a574SPing-Ke Shih #define B_AX_DMAC0_EXIT_L1_EN		BIT(6)
54e1e7a574SPing-Ke Shih #define B_AX_SEL_XFER_PENDING		BIT(3)
55e1e7a574SPing-Ke Shih #define B_AX_SEL_REQ_ENTR_L1		BIT(2)
56e1e7a574SPing-Ke Shih #define B_AX_SEL_REQ_EXIT_L1		BIT(0)
57e1e7a574SPing-Ke Shih 
588f308ae3SChia-Yuan Li #define R_AX_PCIE_MIX_CFG_V1		0x300C
598f308ae3SChia-Yuan Li #define B_AX_ASPM_CTRL_L1		BIT(17)
608f308ae3SChia-Yuan Li #define B_AX_ASPM_CTRL_L0		BIT(16)
618f308ae3SChia-Yuan Li #define B_AX_ASPM_CTRL_MASK		GENMASK(17, 16)
628f308ae3SChia-Yuan Li #define B_AX_XFER_PENDING_FW		BIT(11)
638f308ae3SChia-Yuan Li #define B_AX_XFER_PENDING		BIT(10)
648f308ae3SChia-Yuan Li #define B_AX_REQ_EXIT_L1		BIT(9)
658f308ae3SChia-Yuan Li #define B_AX_REQ_ENTR_L1		BIT(8)
668f308ae3SChia-Yuan Li #define B_AX_L1SUB_DISABLE		BIT(0)
678f308ae3SChia-Yuan Li 
68843059d8SChin-Yen Lee #define R_AX_L1_CLK_CTRL		0x3010
69843059d8SChin-Yen Lee #define B_AX_CLK_REQ_N			BIT(1)
70843059d8SChin-Yen Lee 
71740c431cSPing-Ke Shih #define R_AX_PCIE_BG_CLR		0x303C
72740c431cSPing-Ke Shih #define B_AX_BG_CLR_ASYNC_M3		BIT(4)
73740c431cSPing-Ke Shih 
74843059d8SChin-Yen Lee #define R_AX_PCIE_LAT_CTRL		0x3044
75843059d8SChin-Yen Lee #define B_AX_CLK_REQ_SEL_OPT		BIT(1)
76843059d8SChin-Yen Lee #define B_AX_CLK_REQ_SEL		BIT(0)
77843059d8SChin-Yen Lee 
78740c431cSPing-Ke Shih #define R_AX_PCIE_IO_RCY_M1 0x3100
79740c431cSPing-Ke Shih #define B_AX_PCIE_IO_RCY_P_M1 BIT(5)
80740c431cSPing-Ke Shih #define B_AX_PCIE_IO_RCY_WDT_P_M1 BIT(4)
81740c431cSPing-Ke Shih #define B_AX_PCIE_IO_RCY_WDT_MODE_M1 BIT(3)
82740c431cSPing-Ke Shih #define B_AX_PCIE_IO_RCY_TRIG_M1 BIT(0)
83740c431cSPing-Ke Shih 
84740c431cSPing-Ke Shih #define R_AX_PCIE_WDT_TIMER_M1 0x3104
85740c431cSPing-Ke Shih #define B_AX_PCIE_WDT_TIMER_M1_MASK GENMASK(31, 0)
86740c431cSPing-Ke Shih 
87740c431cSPing-Ke Shih #define R_AX_PCIE_IO_RCY_M2 0x310C
88740c431cSPing-Ke Shih #define B_AX_PCIE_IO_RCY_P_M2 BIT(5)
89740c431cSPing-Ke Shih #define B_AX_PCIE_IO_RCY_WDT_P_M2 BIT(4)
90740c431cSPing-Ke Shih #define B_AX_PCIE_IO_RCY_WDT_MODE_M2 BIT(3)
91740c431cSPing-Ke Shih #define B_AX_PCIE_IO_RCY_TRIG_M2 BIT(0)
92740c431cSPing-Ke Shih 
93740c431cSPing-Ke Shih #define R_AX_PCIE_WDT_TIMER_M2 0x3110
94740c431cSPing-Ke Shih #define B_AX_PCIE_WDT_TIMER_M2_MASK GENMASK(31, 0)
95740c431cSPing-Ke Shih 
96740c431cSPing-Ke Shih #define R_AX_PCIE_IO_RCY_E0 0x3118
97740c431cSPing-Ke Shih #define B_AX_PCIE_IO_RCY_P_E0 BIT(5)
98740c431cSPing-Ke Shih #define B_AX_PCIE_IO_RCY_WDT_P_E0 BIT(4)
99740c431cSPing-Ke Shih #define B_AX_PCIE_IO_RCY_WDT_MODE_E0 BIT(3)
100740c431cSPing-Ke Shih #define B_AX_PCIE_IO_RCY_TRIG_E0 BIT(0)
101740c431cSPing-Ke Shih 
102740c431cSPing-Ke Shih #define R_AX_PCIE_WDT_TIMER_E0 0x311C
103740c431cSPing-Ke Shih #define B_AX_PCIE_WDT_TIMER_E0_MASK GENMASK(31, 0)
104740c431cSPing-Ke Shih 
105740c431cSPing-Ke Shih #define R_AX_PCIE_IO_RCY_S1 0x3124
106740c431cSPing-Ke Shih #define B_AX_PCIE_IO_RCY_RP_S1 BIT(7)
107740c431cSPing-Ke Shih #define B_AX_PCIE_IO_RCY_WP_S1 BIT(6)
108740c431cSPing-Ke Shih #define B_AX_PCIE_IO_RCY_WDT_RP_S1 BIT(5)
109740c431cSPing-Ke Shih #define B_AX_PCIE_IO_RCY_WDT_WP_S1 BIT(4)
110740c431cSPing-Ke Shih #define B_AX_PCIE_IO_RCY_WDT_MODE_S1 BIT(3)
111740c431cSPing-Ke Shih #define B_AX_PCIE_IO_RCY_RTRIG_S1 BIT(1)
112740c431cSPing-Ke Shih #define B_AX_PCIE_IO_RCY_WTRIG_S1 BIT(0)
113740c431cSPing-Ke Shih 
114740c431cSPing-Ke Shih #define R_AX_PCIE_WDT_TIMER_S1 0x3128
115740c431cSPing-Ke Shih #define B_AX_PCIE_WDT_TIMER_S1_MASK GENMASK(31, 0)
116740c431cSPing-Ke Shih 
11722a66e7cSPing-Ke Shih #define R_RAC_DIRECT_OFFSET_G1 0x3800
1188f308ae3SChia-Yuan Li #define FILTER_OUT_EQ_MASK GENMASK(14, 10)
11922a66e7cSPing-Ke Shih #define R_RAC_DIRECT_OFFSET_G2 0x3880
1208f308ae3SChia-Yuan Li #define REG_FILTER_OUT_MASK GENMASK(6, 2)
1218f308ae3SChia-Yuan Li #define RAC_MULT 2
12222a66e7cSPing-Ke Shih 
123e3ec7017SPing-Ke Shih #define RTW89_PCI_WR_RETRY_CNT		20
124e3ec7017SPing-Ke Shih 
125e3ec7017SPing-Ke Shih /* Interrupts */
126e3ec7017SPing-Ke Shih #define R_AX_HIMR0 0x01A0
127768992ebSPing-Ke Shih #define B_AX_WDT_TIMEOUT_INT_EN BIT(22)
128e3ec7017SPing-Ke Shih #define B_AX_HALT_C2H_INT_EN BIT(21)
129e3ec7017SPing-Ke Shih #define R_AX_HISR0 0x01A4
130e3ec7017SPing-Ke Shih 
131948e521cSPing-Ke Shih #define R_AX_HIMR1 0x01A8
132948e521cSPing-Ke Shih #define B_AX_GPIO18_INT_EN BIT(2)
133948e521cSPing-Ke Shih #define B_AX_GPIO17_INT_EN BIT(1)
134948e521cSPing-Ke Shih #define B_AX_GPIO16_INT_EN BIT(0)
135948e521cSPing-Ke Shih 
136948e521cSPing-Ke Shih #define R_AX_HISR1 0x01AC
137948e521cSPing-Ke Shih #define B_AX_GPIO18_INT BIT(2)
138948e521cSPing-Ke Shih #define B_AX_GPIO17_INT BIT(1)
139948e521cSPing-Ke Shih #define B_AX_GPIO16_INT BIT(0)
140948e521cSPing-Ke Shih 
141e3ec7017SPing-Ke Shih #define R_AX_MDIO_CFG			0x10A0
142e3ec7017SPing-Ke Shih #define B_AX_MDIO_PHY_ADDR_MASK		GENMASK(13, 12)
143e3ec7017SPing-Ke Shih #define B_AX_MDIO_RFLAG			BIT(9)
144e3ec7017SPing-Ke Shih #define B_AX_MDIO_WFLAG			BIT(8)
145e3ec7017SPing-Ke Shih #define B_AX_MDIO_ADDR_MASK		GENMASK(4, 0)
146e3ec7017SPing-Ke Shih 
147e3ec7017SPing-Ke Shih #define R_AX_PCIE_HIMR00	0x10B0
148948e521cSPing-Ke Shih #define R_AX_HAXI_HIMR00 0x10B0
149e3ec7017SPing-Ke Shih #define B_AX_HC00ISR_IND_INT_EN		BIT(27)
150e3ec7017SPing-Ke Shih #define B_AX_HD1ISR_IND_INT_EN		BIT(26)
151e3ec7017SPing-Ke Shih #define B_AX_HD0ISR_IND_INT_EN		BIT(25)
152e3ec7017SPing-Ke Shih #define B_AX_HS0ISR_IND_INT_EN		BIT(24)
153e3ec7017SPing-Ke Shih #define B_AX_RETRAIN_INT_EN		BIT(21)
154e3ec7017SPing-Ke Shih #define B_AX_RPQBD_FULL_INT_EN		BIT(20)
155e3ec7017SPing-Ke Shih #define B_AX_RDU_INT_EN			BIT(19)
156e3ec7017SPing-Ke Shih #define B_AX_RXDMA_STUCK_INT_EN		BIT(18)
157e3ec7017SPing-Ke Shih #define B_AX_TXDMA_STUCK_INT_EN		BIT(17)
158e3ec7017SPing-Ke Shih #define B_AX_PCIE_HOTRST_INT_EN		BIT(16)
159e3ec7017SPing-Ke Shih #define B_AX_PCIE_FLR_INT_EN		BIT(15)
160e3ec7017SPing-Ke Shih #define B_AX_PCIE_PERST_INT_EN		BIT(14)
161e3ec7017SPing-Ke Shih #define B_AX_TXDMA_CH12_INT_EN		BIT(13)
162e3ec7017SPing-Ke Shih #define B_AX_TXDMA_CH9_INT_EN		BIT(12)
163e3ec7017SPing-Ke Shih #define B_AX_TXDMA_CH8_INT_EN		BIT(11)
164e3ec7017SPing-Ke Shih #define B_AX_TXDMA_ACH7_INT_EN		BIT(10)
165e3ec7017SPing-Ke Shih #define B_AX_TXDMA_ACH6_INT_EN		BIT(9)
166e3ec7017SPing-Ke Shih #define B_AX_TXDMA_ACH5_INT_EN		BIT(8)
167e3ec7017SPing-Ke Shih #define B_AX_TXDMA_ACH4_INT_EN		BIT(7)
168e3ec7017SPing-Ke Shih #define B_AX_TXDMA_ACH3_INT_EN		BIT(6)
169e3ec7017SPing-Ke Shih #define B_AX_TXDMA_ACH2_INT_EN		BIT(5)
170e3ec7017SPing-Ke Shih #define B_AX_TXDMA_ACH1_INT_EN		BIT(4)
171e3ec7017SPing-Ke Shih #define B_AX_TXDMA_ACH0_INT_EN		BIT(3)
172e3ec7017SPing-Ke Shih #define B_AX_RPQDMA_INT_EN		BIT(2)
173e3ec7017SPing-Ke Shih #define B_AX_RXP1DMA_INT_EN		BIT(1)
174e3ec7017SPing-Ke Shih #define B_AX_RXDMA_INT_EN		BIT(0)
175e3ec7017SPing-Ke Shih 
176e3ec7017SPing-Ke Shih #define R_AX_PCIE_HISR00	0x10B4
177948e521cSPing-Ke Shih #define R_AX_HAXI_HISR00 0x10B4
178e3ec7017SPing-Ke Shih #define B_AX_HC00ISR_IND_INT		BIT(27)
179e3ec7017SPing-Ke Shih #define B_AX_HD1ISR_IND_INT		BIT(26)
180e3ec7017SPing-Ke Shih #define B_AX_HD0ISR_IND_INT		BIT(25)
181e3ec7017SPing-Ke Shih #define B_AX_HS0ISR_IND_INT		BIT(24)
182e3ec7017SPing-Ke Shih #define B_AX_RETRAIN_INT		BIT(21)
183e3ec7017SPing-Ke Shih #define B_AX_RPQBD_FULL_INT		BIT(20)
184e3ec7017SPing-Ke Shih #define B_AX_RDU_INT			BIT(19)
185e3ec7017SPing-Ke Shih #define B_AX_RXDMA_STUCK_INT		BIT(18)
186e3ec7017SPing-Ke Shih #define B_AX_TXDMA_STUCK_INT		BIT(17)
187e3ec7017SPing-Ke Shih #define B_AX_PCIE_HOTRST_INT		BIT(16)
188e3ec7017SPing-Ke Shih #define B_AX_PCIE_FLR_INT		BIT(15)
189e3ec7017SPing-Ke Shih #define B_AX_PCIE_PERST_INT		BIT(14)
190e3ec7017SPing-Ke Shih #define B_AX_TXDMA_CH12_INT		BIT(13)
191e3ec7017SPing-Ke Shih #define B_AX_TXDMA_CH9_INT		BIT(12)
192e3ec7017SPing-Ke Shih #define B_AX_TXDMA_CH8_INT		BIT(11)
193e3ec7017SPing-Ke Shih #define B_AX_TXDMA_ACH7_INT		BIT(10)
194e3ec7017SPing-Ke Shih #define B_AX_TXDMA_ACH6_INT		BIT(9)
195e3ec7017SPing-Ke Shih #define B_AX_TXDMA_ACH5_INT		BIT(8)
196e3ec7017SPing-Ke Shih #define B_AX_TXDMA_ACH4_INT		BIT(7)
197e3ec7017SPing-Ke Shih #define B_AX_TXDMA_ACH3_INT		BIT(6)
198e3ec7017SPing-Ke Shih #define B_AX_TXDMA_ACH2_INT		BIT(5)
199e3ec7017SPing-Ke Shih #define B_AX_TXDMA_ACH1_INT		BIT(4)
200e3ec7017SPing-Ke Shih #define B_AX_TXDMA_ACH0_INT		BIT(3)
201e3ec7017SPing-Ke Shih #define B_AX_RPQDMA_INT			BIT(2)
202e3ec7017SPing-Ke Shih #define B_AX_RXP1DMA_INT		BIT(1)
203e3ec7017SPing-Ke Shih #define B_AX_RXDMA_INT			BIT(0)
204e3ec7017SPing-Ke Shih 
205f7333fc2SChia-Yuan Li #define R_AX_HAXI_IDCT_MSK 0x10B8
206f7333fc2SChia-Yuan Li #define B_AX_TXBD_LEN0_ERR_IDCT_MSK BIT(3)
207f7333fc2SChia-Yuan Li #define B_AX_TXBD_4KBOUND_ERR_IDCT_MSK BIT(2)
208f7333fc2SChia-Yuan Li #define B_AX_RXMDA_STUCK_IDCT_MSK BIT(1)
209f7333fc2SChia-Yuan Li #define B_AX_TXMDA_STUCK_IDCT_MSK BIT(0)
210f7333fc2SChia-Yuan Li 
211f7333fc2SChia-Yuan Li #define R_AX_HAXI_IDCT 0x10BC
212f7333fc2SChia-Yuan Li #define B_AX_TXBD_LEN0_ERR_IDCT BIT(3)
213f7333fc2SChia-Yuan Li #define B_AX_TXBD_4KBOUND_ERR_IDCT BIT(2)
214f7333fc2SChia-Yuan Li #define B_AX_RXMDA_STUCK_IDCT BIT(1)
215f7333fc2SChia-Yuan Li #define B_AX_TXMDA_STUCK_IDCT BIT(0)
216f7333fc2SChia-Yuan Li 
217948e521cSPing-Ke Shih #define R_AX_HAXI_HIMR10 0x11E0
218948e521cSPing-Ke Shih #define B_AX_TXDMA_CH11_INT_EN_V1 BIT(1)
219948e521cSPing-Ke Shih #define B_AX_TXDMA_CH10_INT_EN_V1 BIT(0)
220948e521cSPing-Ke Shih 
221e3ec7017SPing-Ke Shih #define R_AX_PCIE_HIMR10	0x13B0
222e3ec7017SPing-Ke Shih #define B_AX_HC10ISR_IND_INT_EN		BIT(28)
223e3ec7017SPing-Ke Shih #define B_AX_TXDMA_CH11_INT_EN		BIT(12)
224e3ec7017SPing-Ke Shih #define B_AX_TXDMA_CH10_INT_EN		BIT(11)
225e3ec7017SPing-Ke Shih 
226e3ec7017SPing-Ke Shih #define R_AX_PCIE_HISR10	0x13B4
227e3ec7017SPing-Ke Shih #define B_AX_HC10ISR_IND_INT		BIT(28)
228e3ec7017SPing-Ke Shih #define B_AX_TXDMA_CH11_INT		BIT(12)
229e3ec7017SPing-Ke Shih #define B_AX_TXDMA_CH10_INT		BIT(11)
230e3ec7017SPing-Ke Shih 
231948e521cSPing-Ke Shih #define R_AX_PCIE_HIMR00_V1 0x30B0
232948e521cSPing-Ke Shih #define B_AX_HCI_AXIDMA_INT_EN BIT(29)
233948e521cSPing-Ke Shih #define B_AX_HC00ISR_IND_INT_EN_V1 BIT(28)
234948e521cSPing-Ke Shih #define B_AX_HD1ISR_IND_INT_EN_V1 BIT(27)
235948e521cSPing-Ke Shih #define B_AX_HD0ISR_IND_INT_EN_V1 BIT(26)
236948e521cSPing-Ke Shih #define B_AX_HS1ISR_IND_INT_EN BIT(25)
237948e521cSPing-Ke Shih #define B_AX_PCIE_DBG_STE_INT_EN BIT(13)
238948e521cSPing-Ke Shih 
239948e521cSPing-Ke Shih #define R_AX_PCIE_HISR00_V1 0x30B4
240948e521cSPing-Ke Shih #define B_AX_HCI_AXIDMA_INT BIT(29)
241948e521cSPing-Ke Shih #define B_AX_HC00ISR_IND_INT_V1 BIT(28)
242948e521cSPing-Ke Shih #define B_AX_HD1ISR_IND_INT_V1 BIT(27)
243948e521cSPing-Ke Shih #define B_AX_HD0ISR_IND_INT_V1 BIT(26)
244948e521cSPing-Ke Shih #define B_AX_HS1ISR_IND_INT BIT(25)
245948e521cSPing-Ke Shih #define B_AX_PCIE_DBG_STE_INT BIT(13)
246948e521cSPing-Ke Shih 
247e3ec7017SPing-Ke Shih /* TX/RX */
24852edbb9fSPing-Ke Shih #define R_AX_DRV_FW_HSK_0	0x01B0
24952edbb9fSPing-Ke Shih #define R_AX_DRV_FW_HSK_1	0x01B4
25052edbb9fSPing-Ke Shih #define R_AX_DRV_FW_HSK_2	0x01B8
25152edbb9fSPing-Ke Shih #define R_AX_DRV_FW_HSK_3	0x01BC
25252edbb9fSPing-Ke Shih #define R_AX_DRV_FW_HSK_4	0x01C0
25352edbb9fSPing-Ke Shih #define R_AX_DRV_FW_HSK_5	0x01C4
25452edbb9fSPing-Ke Shih #define R_AX_DRV_FW_HSK_6	0x01C8
25552edbb9fSPing-Ke Shih #define R_AX_DRV_FW_HSK_7	0x01CC
25652edbb9fSPing-Ke Shih 
257e3ec7017SPing-Ke Shih #define R_AX_RXQ_RXBD_IDX	0x1050
258e3ec7017SPing-Ke Shih #define R_AX_RPQ_RXBD_IDX	0x1054
259e3ec7017SPing-Ke Shih #define R_AX_ACH0_TXBD_IDX	0x1058
260e3ec7017SPing-Ke Shih #define R_AX_ACH1_TXBD_IDX	0x105C
261e3ec7017SPing-Ke Shih #define R_AX_ACH2_TXBD_IDX	0x1060
262e3ec7017SPing-Ke Shih #define R_AX_ACH3_TXBD_IDX	0x1064
263e3ec7017SPing-Ke Shih #define R_AX_ACH4_TXBD_IDX	0x1068
264e3ec7017SPing-Ke Shih #define R_AX_ACH5_TXBD_IDX	0x106C
265e3ec7017SPing-Ke Shih #define R_AX_ACH6_TXBD_IDX	0x1070
266e3ec7017SPing-Ke Shih #define R_AX_ACH7_TXBD_IDX	0x1074
267e3ec7017SPing-Ke Shih #define R_AX_CH8_TXBD_IDX	0x1078 /* Management Queue band 0 */
268e3ec7017SPing-Ke Shih #define R_AX_CH9_TXBD_IDX	0x107C /* HI Queue band 0 */
269e3ec7017SPing-Ke Shih #define R_AX_CH10_TXBD_IDX	0x137C /* Management Queue band 1 */
270e3ec7017SPing-Ke Shih #define R_AX_CH11_TXBD_IDX	0x1380 /* HI Queue band 1 */
271e3ec7017SPing-Ke Shih #define R_AX_CH12_TXBD_IDX	0x1080 /* FWCMD Queue */
27297d61bf9SPing-Ke Shih #define R_AX_CH10_TXBD_IDX_V1	0x11D0
27397d61bf9SPing-Ke Shih #define R_AX_CH11_TXBD_IDX_V1	0x11D4
27497d61bf9SPing-Ke Shih #define R_AX_RXQ_RXBD_IDX_V1	0x1218
27597d61bf9SPing-Ke Shih #define R_AX_RPQ_RXBD_IDX_V1	0x121C
276e3ec7017SPing-Ke Shih #define TXBD_HW_IDX_MASK	GENMASK(27, 16)
277e3ec7017SPing-Ke Shih #define TXBD_HOST_IDX_MASK	GENMASK(11, 0)
278e3ec7017SPing-Ke Shih 
279e3ec7017SPing-Ke Shih #define R_AX_ACH0_TXBD_DESA_L	0x1110
280e3ec7017SPing-Ke Shih #define R_AX_ACH0_TXBD_DESA_H	0x1114
281e3ec7017SPing-Ke Shih #define R_AX_ACH1_TXBD_DESA_L	0x1118
282e3ec7017SPing-Ke Shih #define R_AX_ACH1_TXBD_DESA_H	0x111C
283e3ec7017SPing-Ke Shih #define R_AX_ACH2_TXBD_DESA_L	0x1120
284e3ec7017SPing-Ke Shih #define R_AX_ACH2_TXBD_DESA_H	0x1124
285e3ec7017SPing-Ke Shih #define R_AX_ACH3_TXBD_DESA_L	0x1128
286e3ec7017SPing-Ke Shih #define R_AX_ACH3_TXBD_DESA_H	0x112C
287e3ec7017SPing-Ke Shih #define R_AX_ACH4_TXBD_DESA_L	0x1130
288e3ec7017SPing-Ke Shih #define R_AX_ACH4_TXBD_DESA_H	0x1134
289e3ec7017SPing-Ke Shih #define R_AX_ACH5_TXBD_DESA_L	0x1138
290e3ec7017SPing-Ke Shih #define R_AX_ACH5_TXBD_DESA_H	0x113C
291e3ec7017SPing-Ke Shih #define R_AX_ACH6_TXBD_DESA_L	0x1140
292e3ec7017SPing-Ke Shih #define R_AX_ACH6_TXBD_DESA_H	0x1144
293e3ec7017SPing-Ke Shih #define R_AX_ACH7_TXBD_DESA_L	0x1148
294e3ec7017SPing-Ke Shih #define R_AX_ACH7_TXBD_DESA_H	0x114C
295e3ec7017SPing-Ke Shih #define R_AX_CH8_TXBD_DESA_L	0x1150
296e3ec7017SPing-Ke Shih #define R_AX_CH8_TXBD_DESA_H	0x1154
297e3ec7017SPing-Ke Shih #define R_AX_CH9_TXBD_DESA_L	0x1158
298e3ec7017SPing-Ke Shih #define R_AX_CH9_TXBD_DESA_H	0x115C
299e3ec7017SPing-Ke Shih #define R_AX_CH10_TXBD_DESA_L	0x1358
300e3ec7017SPing-Ke Shih #define R_AX_CH10_TXBD_DESA_H	0x135C
301e3ec7017SPing-Ke Shih #define R_AX_CH11_TXBD_DESA_L	0x1360
302e3ec7017SPing-Ke Shih #define R_AX_CH11_TXBD_DESA_H	0x1364
303e3ec7017SPing-Ke Shih #define R_AX_CH12_TXBD_DESA_L	0x1160
304e3ec7017SPing-Ke Shih #define R_AX_CH12_TXBD_DESA_H	0x1164
305e3ec7017SPing-Ke Shih #define R_AX_RXQ_RXBD_DESA_L	0x1100
306e3ec7017SPing-Ke Shih #define R_AX_RXQ_RXBD_DESA_H	0x1104
307e3ec7017SPing-Ke Shih #define R_AX_RPQ_RXBD_DESA_L	0x1108
308e3ec7017SPing-Ke Shih #define R_AX_RPQ_RXBD_DESA_H	0x110C
30997d61bf9SPing-Ke Shih #define R_AX_RXQ_RXBD_DESA_L_V1 0x1220
31097d61bf9SPing-Ke Shih #define R_AX_RXQ_RXBD_DESA_H_V1 0x1224
31197d61bf9SPing-Ke Shih #define R_AX_RPQ_RXBD_DESA_L_V1 0x1228
31297d61bf9SPing-Ke Shih #define R_AX_RPQ_RXBD_DESA_H_V1 0x122C
31397d61bf9SPing-Ke Shih #define R_AX_ACH0_TXBD_DESA_L_V1 0x1230
31497d61bf9SPing-Ke Shih #define R_AX_ACH0_TXBD_DESA_H_V1 0x1234
31597d61bf9SPing-Ke Shih #define R_AX_ACH1_TXBD_DESA_L_V1 0x1238
31697d61bf9SPing-Ke Shih #define R_AX_ACH1_TXBD_DESA_H_V1 0x123C
31797d61bf9SPing-Ke Shih #define R_AX_ACH2_TXBD_DESA_L_V1 0x1240
31897d61bf9SPing-Ke Shih #define R_AX_ACH2_TXBD_DESA_H_V1 0x1244
31997d61bf9SPing-Ke Shih #define R_AX_ACH3_TXBD_DESA_L_V1 0x1248
32097d61bf9SPing-Ke Shih #define R_AX_ACH3_TXBD_DESA_H_V1 0x124C
32197d61bf9SPing-Ke Shih #define R_AX_ACH4_TXBD_DESA_L_V1 0x1250
32297d61bf9SPing-Ke Shih #define R_AX_ACH4_TXBD_DESA_H_V1 0x1254
32397d61bf9SPing-Ke Shih #define R_AX_ACH5_TXBD_DESA_L_V1 0x1258
32497d61bf9SPing-Ke Shih #define R_AX_ACH5_TXBD_DESA_H_V1 0x125C
32597d61bf9SPing-Ke Shih #define R_AX_ACH6_TXBD_DESA_L_V1 0x1260
32697d61bf9SPing-Ke Shih #define R_AX_ACH6_TXBD_DESA_H_V1 0x1264
32797d61bf9SPing-Ke Shih #define R_AX_ACH7_TXBD_DESA_L_V1 0x1268
32897d61bf9SPing-Ke Shih #define R_AX_ACH7_TXBD_DESA_H_V1 0x126C
32997d61bf9SPing-Ke Shih #define R_AX_CH8_TXBD_DESA_L_V1 0x1270
33097d61bf9SPing-Ke Shih #define R_AX_CH8_TXBD_DESA_H_V1 0x1274
33197d61bf9SPing-Ke Shih #define R_AX_CH9_TXBD_DESA_L_V1 0x1278
33297d61bf9SPing-Ke Shih #define R_AX_CH9_TXBD_DESA_H_V1 0x127C
33397d61bf9SPing-Ke Shih #define R_AX_CH12_TXBD_DESA_L_V1 0x1280
33497d61bf9SPing-Ke Shih #define R_AX_CH12_TXBD_DESA_H_V1 0x1284
33597d61bf9SPing-Ke Shih #define R_AX_CH10_TXBD_DESA_L_V1 0x1458
33697d61bf9SPing-Ke Shih #define R_AX_CH10_TXBD_DESA_H_V1 0x145C
33797d61bf9SPing-Ke Shih #define R_AX_CH11_TXBD_DESA_L_V1 0x1460
33897d61bf9SPing-Ke Shih #define R_AX_CH11_TXBD_DESA_H_V1 0x1464
339e3ec7017SPing-Ke Shih #define B_AX_DESC_NUM_MSK		GENMASK(11, 0)
340e3ec7017SPing-Ke Shih 
341e3ec7017SPing-Ke Shih #define R_AX_RXQ_RXBD_NUM	0x1020
342e3ec7017SPing-Ke Shih #define R_AX_RPQ_RXBD_NUM	0x1022
343e3ec7017SPing-Ke Shih #define R_AX_ACH0_TXBD_NUM	0x1024
344e3ec7017SPing-Ke Shih #define R_AX_ACH1_TXBD_NUM	0x1026
345e3ec7017SPing-Ke Shih #define R_AX_ACH2_TXBD_NUM	0x1028
346e3ec7017SPing-Ke Shih #define R_AX_ACH3_TXBD_NUM	0x102A
347e3ec7017SPing-Ke Shih #define R_AX_ACH4_TXBD_NUM	0x102C
348e3ec7017SPing-Ke Shih #define R_AX_ACH5_TXBD_NUM	0x102E
349e3ec7017SPing-Ke Shih #define R_AX_ACH6_TXBD_NUM	0x1030
350e3ec7017SPing-Ke Shih #define R_AX_ACH7_TXBD_NUM	0x1032
351e3ec7017SPing-Ke Shih #define R_AX_CH8_TXBD_NUM	0x1034
352e3ec7017SPing-Ke Shih #define R_AX_CH9_TXBD_NUM	0x1036
353e3ec7017SPing-Ke Shih #define R_AX_CH10_TXBD_NUM	0x1338
354e3ec7017SPing-Ke Shih #define R_AX_CH11_TXBD_NUM	0x133A
355e3ec7017SPing-Ke Shih #define R_AX_CH12_TXBD_NUM	0x1038
35697d61bf9SPing-Ke Shih #define R_AX_RXQ_RXBD_NUM_V1	0x1210
35797d61bf9SPing-Ke Shih #define R_AX_RPQ_RXBD_NUM_V1	0x1212
35897d61bf9SPing-Ke Shih #define R_AX_CH10_TXBD_NUM_V1	0x1438
35997d61bf9SPing-Ke Shih #define R_AX_CH11_TXBD_NUM_V1	0x143A
360e3ec7017SPing-Ke Shih 
361e3ec7017SPing-Ke Shih #define R_AX_ACH0_BDRAM_CTRL	0x1200
362e3ec7017SPing-Ke Shih #define R_AX_ACH1_BDRAM_CTRL	0x1204
363e3ec7017SPing-Ke Shih #define R_AX_ACH2_BDRAM_CTRL	0x1208
364e3ec7017SPing-Ke Shih #define R_AX_ACH3_BDRAM_CTRL	0x120C
365e3ec7017SPing-Ke Shih #define R_AX_ACH4_BDRAM_CTRL	0x1210
366e3ec7017SPing-Ke Shih #define R_AX_ACH5_BDRAM_CTRL	0x1214
367e3ec7017SPing-Ke Shih #define R_AX_ACH6_BDRAM_CTRL	0x1218
368e3ec7017SPing-Ke Shih #define R_AX_ACH7_BDRAM_CTRL	0x121C
369e3ec7017SPing-Ke Shih #define R_AX_CH8_BDRAM_CTRL	0x1220
370e3ec7017SPing-Ke Shih #define R_AX_CH9_BDRAM_CTRL	0x1224
371e3ec7017SPing-Ke Shih #define R_AX_CH10_BDRAM_CTRL	0x1320
372e3ec7017SPing-Ke Shih #define R_AX_CH11_BDRAM_CTRL	0x1324
373e3ec7017SPing-Ke Shih #define R_AX_CH12_BDRAM_CTRL	0x1228
37497d61bf9SPing-Ke Shih #define R_AX_ACH0_BDRAM_CTRL_V1 0x1300
37597d61bf9SPing-Ke Shih #define R_AX_ACH1_BDRAM_CTRL_V1 0x1304
37697d61bf9SPing-Ke Shih #define R_AX_ACH2_BDRAM_CTRL_V1 0x1308
37797d61bf9SPing-Ke Shih #define R_AX_ACH3_BDRAM_CTRL_V1 0x130C
37897d61bf9SPing-Ke Shih #define R_AX_ACH4_BDRAM_CTRL_V1 0x1310
37997d61bf9SPing-Ke Shih #define R_AX_ACH5_BDRAM_CTRL_V1 0x1314
38097d61bf9SPing-Ke Shih #define R_AX_ACH6_BDRAM_CTRL_V1 0x1318
38197d61bf9SPing-Ke Shih #define R_AX_ACH7_BDRAM_CTRL_V1 0x131C
38297d61bf9SPing-Ke Shih #define R_AX_CH8_BDRAM_CTRL_V1 0x1320
38397d61bf9SPing-Ke Shih #define R_AX_CH9_BDRAM_CTRL_V1 0x1324
38497d61bf9SPing-Ke Shih #define R_AX_CH12_BDRAM_CTRL_V1 0x1328
38597d61bf9SPing-Ke Shih #define R_AX_CH10_BDRAM_CTRL_V1 0x1420
38697d61bf9SPing-Ke Shih #define R_AX_CH11_BDRAM_CTRL_V1 0x1424
387e3ec7017SPing-Ke Shih #define BDRAM_SIDX_MASK		GENMASK(7, 0)
388e3ec7017SPing-Ke Shih #define BDRAM_MAX_MASK		GENMASK(15, 8)
389e3ec7017SPing-Ke Shih #define BDRAM_MIN_MASK		GENMASK(23, 16)
390e3ec7017SPing-Ke Shih 
391e3ec7017SPing-Ke Shih #define R_AX_PCIE_INIT_CFG1	0x1000
392e3ec7017SPing-Ke Shih #define B_AX_PCIE_RXRST_KEEP_REG	BIT(23)
393e3ec7017SPing-Ke Shih #define B_AX_PCIE_TXRST_KEEP_REG	BIT(22)
394e3ec7017SPing-Ke Shih #define B_AX_PCIE_PERST_KEEP_REG	BIT(21)
395e3ec7017SPing-Ke Shih #define B_AX_PCIE_FLR_KEEP_REG		BIT(20)
396e3ec7017SPing-Ke Shih #define B_AX_PCIE_TRAIN_KEEP_REG	BIT(19)
397e3ec7017SPing-Ke Shih #define B_AX_RXBD_MODE			BIT(18)
398e3ec7017SPing-Ke Shih #define B_AX_PCIE_MAX_RXDMA_MASK	GENMASK(16, 14)
399e3ec7017SPing-Ke Shih #define B_AX_RXHCI_EN			BIT(13)
400e3ec7017SPing-Ke Shih #define B_AX_LATENCY_CONTROL		BIT(12)
401e3ec7017SPing-Ke Shih #define B_AX_TXHCI_EN			BIT(11)
402e3ec7017SPing-Ke Shih #define B_AX_PCIE_MAX_TXDMA_MASK	GENMASK(10, 8)
403e3ec7017SPing-Ke Shih #define B_AX_TX_TRUNC_MODE		BIT(5)
404e3ec7017SPing-Ke Shih #define B_AX_RX_TRUNC_MODE		BIT(4)
405e3ec7017SPing-Ke Shih #define B_AX_RST_BDRAM			BIT(3)
406e3ec7017SPing-Ke Shih #define B_AX_DIS_RXDMA_PRE		BIT(2)
407e3ec7017SPing-Ke Shih 
408e3ec7017SPing-Ke Shih #define R_AX_TXDMA_ADDR_H	0x10F0
409e3ec7017SPing-Ke Shih #define R_AX_RXDMA_ADDR_H	0x10F4
410e3ec7017SPing-Ke Shih 
411e3ec7017SPing-Ke Shih #define R_AX_PCIE_DMA_STOP1	0x1010
412e3ec7017SPing-Ke Shih #define B_AX_STOP_PCIEIO		BIT(20)
413e3ec7017SPing-Ke Shih #define B_AX_STOP_WPDMA			BIT(19)
414e3ec7017SPing-Ke Shih #define B_AX_STOP_CH12			BIT(18)
415e3ec7017SPing-Ke Shih #define B_AX_STOP_CH9			BIT(17)
416e3ec7017SPing-Ke Shih #define B_AX_STOP_CH8			BIT(16)
417e3ec7017SPing-Ke Shih #define B_AX_STOP_ACH7			BIT(15)
418e3ec7017SPing-Ke Shih #define B_AX_STOP_ACH6			BIT(14)
419e3ec7017SPing-Ke Shih #define B_AX_STOP_ACH5			BIT(13)
420e3ec7017SPing-Ke Shih #define B_AX_STOP_ACH4			BIT(12)
421e3ec7017SPing-Ke Shih #define B_AX_STOP_ACH3			BIT(11)
422e3ec7017SPing-Ke Shih #define B_AX_STOP_ACH2			BIT(10)
423e3ec7017SPing-Ke Shih #define B_AX_STOP_ACH1			BIT(9)
424e3ec7017SPing-Ke Shih #define B_AX_STOP_ACH0			BIT(8)
425e3ec7017SPing-Ke Shih #define B_AX_STOP_RPQ			BIT(1)
426e3ec7017SPing-Ke Shih #define B_AX_STOP_RXQ			BIT(0)
427e3ec7017SPing-Ke Shih #define B_AX_TX_STOP1_ALL		GENMASK(18, 8)
4285280e481SChin-Yen Lee #define B_AX_TX_STOP1_MASK		(B_AX_STOP_ACH0 | B_AX_STOP_ACH1 | \
4295280e481SChin-Yen Lee 					 B_AX_STOP_ACH2 | B_AX_STOP_ACH3 | \
4305280e481SChin-Yen Lee 					 B_AX_STOP_ACH4 | B_AX_STOP_ACH5 | \
4315280e481SChin-Yen Lee 					 B_AX_STOP_ACH6 | B_AX_STOP_ACH7 | \
4325280e481SChin-Yen Lee 					 B_AX_STOP_CH8 | B_AX_STOP_CH9 | \
4335280e481SChin-Yen Lee 					 B_AX_STOP_CH12)
4345280e481SChin-Yen Lee #define B_AX_TX_STOP1_MASK_V1		(B_AX_STOP_ACH0 | B_AX_STOP_ACH1 | \
4355280e481SChin-Yen Lee 					 B_AX_STOP_ACH2 | B_AX_STOP_ACH3 | \
4365280e481SChin-Yen Lee 					 B_AX_STOP_CH8 | B_AX_STOP_CH9 | \
4375280e481SChin-Yen Lee 					 B_AX_STOP_CH12)
438e3ec7017SPing-Ke Shih 
439e3ec7017SPing-Ke Shih #define R_AX_PCIE_DMA_STOP2	0x1310
440e3ec7017SPing-Ke Shih #define B_AX_STOP_CH11			BIT(1)
441e3ec7017SPing-Ke Shih #define B_AX_STOP_CH10			BIT(0)
442e3ec7017SPing-Ke Shih #define B_AX_TX_STOP2_ALL		GENMASK(1, 0)
443e3ec7017SPing-Ke Shih 
444e3ec7017SPing-Ke Shih #define R_AX_TXBD_RWPTR_CLR1	0x1014
445e3ec7017SPing-Ke Shih #define B_AX_CLR_CH12_IDX		BIT(10)
446e3ec7017SPing-Ke Shih #define B_AX_CLR_CH9_IDX		BIT(9)
447e3ec7017SPing-Ke Shih #define B_AX_CLR_CH8_IDX		BIT(8)
448e3ec7017SPing-Ke Shih #define B_AX_CLR_ACH7_IDX		BIT(7)
449e3ec7017SPing-Ke Shih #define B_AX_CLR_ACH6_IDX		BIT(6)
450e3ec7017SPing-Ke Shih #define B_AX_CLR_ACH5_IDX		BIT(5)
451e3ec7017SPing-Ke Shih #define B_AX_CLR_ACH4_IDX		BIT(4)
452e3ec7017SPing-Ke Shih #define B_AX_CLR_ACH3_IDX		BIT(3)
453e3ec7017SPing-Ke Shih #define B_AX_CLR_ACH2_IDX		BIT(2)
454e3ec7017SPing-Ke Shih #define B_AX_CLR_ACH1_IDX		BIT(1)
455e3ec7017SPing-Ke Shih #define B_AX_CLR_ACH0_IDX		BIT(0)
456e3ec7017SPing-Ke Shih #define B_AX_TXBD_CLR1_ALL		GENMASK(10, 0)
457e3ec7017SPing-Ke Shih 
458e3ec7017SPing-Ke Shih #define R_AX_RXBD_RWPTR_CLR	0x1018
459e3ec7017SPing-Ke Shih #define B_AX_CLR_RPQ_IDX		BIT(1)
460e3ec7017SPing-Ke Shih #define B_AX_CLR_RXQ_IDX		BIT(0)
461e3ec7017SPing-Ke Shih #define B_AX_RXBD_CLR_ALL		GENMASK(1, 0)
462e3ec7017SPing-Ke Shih 
463e3ec7017SPing-Ke Shih #define R_AX_TXBD_RWPTR_CLR2	0x1314
464e3ec7017SPing-Ke Shih #define B_AX_CLR_CH11_IDX		BIT(1)
465e3ec7017SPing-Ke Shih #define B_AX_CLR_CH10_IDX		BIT(0)
466e3ec7017SPing-Ke Shih #define B_AX_TXBD_CLR2_ALL		GENMASK(1, 0)
467e3ec7017SPing-Ke Shih 
468e3ec7017SPing-Ke Shih #define R_AX_PCIE_DMA_BUSY1	0x101C
469e3ec7017SPing-Ke Shih #define B_AX_PCIEIO_RX_BUSY		BIT(22)
470e3ec7017SPing-Ke Shih #define B_AX_PCIEIO_TX_BUSY		BIT(21)
471e3ec7017SPing-Ke Shih #define B_AX_PCIEIO_BUSY		BIT(20)
472e3ec7017SPing-Ke Shih #define B_AX_WPDMA_BUSY			BIT(19)
4731e3f2055SChia-Yuan Li #define B_AX_CH12_BUSY			BIT(18)
4741e3f2055SChia-Yuan Li #define B_AX_CH9_BUSY			BIT(17)
4751e3f2055SChia-Yuan Li #define B_AX_CH8_BUSY			BIT(16)
4761e3f2055SChia-Yuan Li #define B_AX_ACH7_BUSY			BIT(15)
4771e3f2055SChia-Yuan Li #define B_AX_ACH6_BUSY			BIT(14)
4781e3f2055SChia-Yuan Li #define B_AX_ACH5_BUSY			BIT(13)
4791e3f2055SChia-Yuan Li #define B_AX_ACH4_BUSY			BIT(12)
4801e3f2055SChia-Yuan Li #define B_AX_ACH3_BUSY			BIT(11)
4811e3f2055SChia-Yuan Li #define B_AX_ACH2_BUSY			BIT(10)
4821e3f2055SChia-Yuan Li #define B_AX_ACH1_BUSY			BIT(9)
4831e3f2055SChia-Yuan Li #define B_AX_ACH0_BUSY			BIT(8)
4841e3f2055SChia-Yuan Li #define B_AX_RPQ_BUSY			BIT(1)
4851e3f2055SChia-Yuan Li #define B_AX_RXQ_BUSY			BIT(0)
48661bdf7aaSPing-Ke Shih #define DMA_BUSY1_CHECK		(B_AX_ACH0_BUSY | B_AX_ACH1_BUSY | B_AX_ACH2_BUSY | \
48761bdf7aaSPing-Ke Shih 				 B_AX_ACH3_BUSY | B_AX_ACH4_BUSY | B_AX_ACH5_BUSY | \
48861bdf7aaSPing-Ke Shih 				 B_AX_ACH6_BUSY | B_AX_ACH7_BUSY | B_AX_CH8_BUSY | \
48961bdf7aaSPing-Ke Shih 				 B_AX_CH9_BUSY | B_AX_CH12_BUSY)
49061bdf7aaSPing-Ke Shih #define DMA_BUSY1_CHECK_V1	(B_AX_ACH0_BUSY | B_AX_ACH1_BUSY | B_AX_ACH2_BUSY | \
49161bdf7aaSPing-Ke Shih 				 B_AX_ACH3_BUSY | B_AX_CH8_BUSY | B_AX_CH9_BUSY | \
49261bdf7aaSPing-Ke Shih 				 B_AX_CH12_BUSY)
493e3ec7017SPing-Ke Shih 
494e3ec7017SPing-Ke Shih #define R_AX_PCIE_DMA_BUSY2	0x131C
495e3ec7017SPing-Ke Shih #define B_AX_CH11_BUSY			BIT(1)
496e3ec7017SPing-Ke Shih #define B_AX_CH10_BUSY			BIT(0)
497e3ec7017SPing-Ke Shih 
498e3ec7017SPing-Ke Shih /* Configure */
499e3ec7017SPing-Ke Shih #define R_AX_PCIE_INIT_CFG2		0x1004
500e3ec7017SPing-Ke Shih #define B_AX_WD_ITVL_IDLE		GENMASK(27, 24)
501e3ec7017SPing-Ke Shih #define B_AX_WD_ITVL_ACT		GENMASK(19, 16)
502740c431cSPing-Ke Shih #define B_AX_PCIE_RX_APPLEN_MASK	GENMASK(13, 0)
503e3ec7017SPing-Ke Shih 
504e3ec7017SPing-Ke Shih #define R_AX_PCIE_PS_CTRL		0x1008
505e3ec7017SPing-Ke Shih #define B_AX_L1OFF_PWR_OFF_EN		BIT(5)
506e3ec7017SPing-Ke Shih 
507e3ec7017SPing-Ke Shih #define R_AX_INT_MIT_RX			0x10D4
508e3ec7017SPing-Ke Shih #define B_AX_RXMIT_RXP2_SEL		BIT(19)
509e3ec7017SPing-Ke Shih #define B_AX_RXMIT_RXP1_SEL		BIT(18)
510e3ec7017SPing-Ke Shih #define B_AX_RXTIMER_UNIT_MASK		GENMASK(17, 16)
511e3ec7017SPing-Ke Shih #define AX_RXTIMER_UNIT_64US		0
512e3ec7017SPing-Ke Shih #define AX_RXTIMER_UNIT_128US		1
513e3ec7017SPing-Ke Shih #define AX_RXTIMER_UNIT_256US		2
514e3ec7017SPing-Ke Shih #define AX_RXTIMER_UNIT_512US		3
515e3ec7017SPing-Ke Shih #define B_AX_RXCOUNTER_MATCH_MASK	GENMASK(15, 8)
516e3ec7017SPing-Ke Shih #define B_AX_RXTIMER_MATCH_MASK		GENMASK(7, 0)
517e3ec7017SPing-Ke Shih 
518e3ec7017SPing-Ke Shih #define R_AX_DBG_ERR_FLAG		0x11C4
519e3ec7017SPing-Ke Shih #define B_AX_PCIE_RPQ_FULL		BIT(29)
520e3ec7017SPing-Ke Shih #define B_AX_PCIE_RXQ_FULL		BIT(28)
521e3ec7017SPing-Ke Shih #define B_AX_CPL_STATUS_MASK		GENMASK(27, 25)
522e3ec7017SPing-Ke Shih #define B_AX_RX_STUCK			BIT(22)
523e3ec7017SPing-Ke Shih #define B_AX_TX_STUCK			BIT(21)
524e3ec7017SPing-Ke Shih #define B_AX_PCIEDBG_TXERR0		BIT(16)
525e3ec7017SPing-Ke Shih #define B_AX_PCIE_RXP1_ERR0		BIT(4)
526e3ec7017SPing-Ke Shih #define B_AX_PCIE_TXBD_LEN0		BIT(1)
527e3ec7017SPing-Ke Shih #define B_AX_PCIE_TXBD_4KBOUD_LENERR	BIT(0)
528e3ec7017SPing-Ke Shih 
529740c431cSPing-Ke Shih #define R_AX_TXBD_RWPTR_CLR2_V1		0x11C4
530740c431cSPing-Ke Shih #define B_AX_CLR_CH11_IDX		BIT(1)
531740c431cSPing-Ke Shih #define B_AX_CLR_CH10_IDX		BIT(0)
532740c431cSPing-Ke Shih 
533e3ec7017SPing-Ke Shih #define R_AX_LBC_WATCHDOG		0x11D8
534e3ec7017SPing-Ke Shih #define B_AX_LBC_TIMER			GENMASK(7, 4)
535e3ec7017SPing-Ke Shih #define B_AX_LBC_FLAG			BIT(1)
536e3ec7017SPing-Ke Shih #define B_AX_LBC_EN			BIT(0)
537e3ec7017SPing-Ke Shih 
538740c431cSPing-Ke Shih #define R_AX_RXBD_RWPTR_CLR_V1		0x1200
539740c431cSPing-Ke Shih #define B_AX_CLR_RPQ_IDX		BIT(1)
540740c431cSPing-Ke Shih #define B_AX_CLR_RXQ_IDX		BIT(0)
541740c431cSPing-Ke Shih 
542740c431cSPing-Ke Shih #define R_AX_HAXI_EXP_CTRL		0x1204
543740c431cSPing-Ke Shih #define B_AX_MAX_TAG_NUM_V1_MASK	GENMASK(2, 0)
544740c431cSPing-Ke Shih 
545e3ec7017SPing-Ke Shih #define R_AX_PCIE_EXP_CTRL		0x13F0
546e3ec7017SPing-Ke Shih #define B_AX_EN_CHKDSC_NO_RX_STUCK	BIT(20)
547e3ec7017SPing-Ke Shih #define B_AX_MAX_TAG_NUM		GENMASK(18, 16)
548e3ec7017SPing-Ke Shih #define B_AX_SIC_EN_FORCE_CLKREQ	BIT(4)
549e3ec7017SPing-Ke Shih 
550e3ec7017SPing-Ke Shih #define R_AX_PCIE_RX_PREF_ADV		0x13F4
551e3ec7017SPing-Ke Shih #define B_AX_RXDMA_PREF_ADV_EN		BIT(0)
552e3ec7017SPing-Ke Shih 
553e1757e80SPing-Ke Shih #define R_AX_PCIE_HRPWM_V1		0x30C0
554e1757e80SPing-Ke Shih #define R_AX_PCIE_CRPWM			0x30C4
555e1757e80SPing-Ke Shih 
556e3ec7017SPing-Ke Shih #define RTW89_PCI_TXBD_NUM_MAX		256
557e3ec7017SPing-Ke Shih #define RTW89_PCI_RXBD_NUM_MAX		256
558e3ec7017SPing-Ke Shih #define RTW89_PCI_TXWD_NUM_MAX		512
559e3ec7017SPing-Ke Shih #define RTW89_PCI_TXWD_PAGE_SIZE	128
560e3ec7017SPing-Ke Shih #define RTW89_PCI_ADDRINFO_MAX		4
561e3ec7017SPing-Ke Shih #define RTW89_PCI_RX_BUF_SIZE		11460
562e3ec7017SPing-Ke Shih 
563e3ec7017SPing-Ke Shih #define RTW89_PCI_POLL_BDRAM_RST_CNT	100
564e3ec7017SPing-Ke Shih #define RTW89_PCI_MULTITAG		8
565e3ec7017SPing-Ke Shih 
566e3ec7017SPing-Ke Shih /* PCIE CFG register */
5678f308ae3SChia-Yuan Li #define RTW89_PCIE_L1_STS_V1		0x80
5688f308ae3SChia-Yuan Li #define RTW89_BCFG_LINK_SPEED_MASK	GENMASK(19, 16)
5698f308ae3SChia-Yuan Li #define RTW89_PCIE_GEN1_SPEED		0x01
5708f308ae3SChia-Yuan Li #define RTW89_PCIE_GEN2_SPEED		0x02
5718f308ae3SChia-Yuan Li #define RTW89_PCIE_PHY_RATE		0x82
5728f308ae3SChia-Yuan Li #define RTW89_PCIE_PHY_RATE_MASK	GENMASK(1, 0)
573843059d8SChin-Yen Lee #define RTW89_PCIE_L1SS_STS_V1		0x0168
574843059d8SChin-Yen Lee #define RTW89_PCIE_BIT_ASPM_L11		BIT(3)
575843059d8SChin-Yen Lee #define RTW89_PCIE_BIT_ASPM_L12		BIT(2)
576843059d8SChin-Yen Lee #define RTW89_PCIE_BIT_PCI_L11		BIT(1)
577843059d8SChin-Yen Lee #define RTW89_PCIE_BIT_PCI_L12		BIT(0)
578e3ec7017SPing-Ke Shih #define RTW89_PCIE_ASPM_CTRL		0x070F
579e3ec7017SPing-Ke Shih #define RTW89_L1DLY_MASK		GENMASK(5, 3)
580e3ec7017SPing-Ke Shih #define RTW89_L0DLY_MASK		GENMASK(2, 0)
581e3ec7017SPing-Ke Shih #define RTW89_PCIE_TIMER_CTRL		0x0718
582e3ec7017SPing-Ke Shih #define RTW89_PCIE_BIT_L1SUB		BIT(5)
583e3ec7017SPing-Ke Shih #define RTW89_PCIE_L1_CTRL		0x0719
584e3ec7017SPing-Ke Shih #define RTW89_PCIE_BIT_CLK		BIT(4)
585e3ec7017SPing-Ke Shih #define RTW89_PCIE_BIT_L1		BIT(3)
586e3ec7017SPing-Ke Shih #define RTW89_PCIE_CLK_CTRL		0x0725
587e3ec7017SPing-Ke Shih #define RTW89_PCIE_RST_MSTATE		0x0B48
588e3ec7017SPing-Ke Shih #define RTW89_PCIE_BIT_CFG_RST_MSTATE	BIT(0)
5898f308ae3SChia-Yuan Li 
590e3ec7017SPing-Ke Shih #define INTF_INTGRA_MINREF_V1	90
591e3ec7017SPing-Ke Shih #define INTF_INTGRA_HOSTREF_V1	100
592e3ec7017SPing-Ke Shih 
593e3ec7017SPing-Ke Shih enum rtw89_pcie_phy {
594e3ec7017SPing-Ke Shih 	PCIE_PHY_GEN1,
595e3ec7017SPing-Ke Shih 	PCIE_PHY_GEN2,
596e3ec7017SPing-Ke Shih 	PCIE_PHY_GEN1_UNDEFINE = 0x7F,
597e3ec7017SPing-Ke Shih };
598e3ec7017SPing-Ke Shih 
599e3ec7017SPing-Ke Shih enum rtw89_pcie_l0sdly {
600e3ec7017SPing-Ke Shih 	PCIE_L0SDLY_1US = 0,
601e3ec7017SPing-Ke Shih 	PCIE_L0SDLY_2US = 1,
602e3ec7017SPing-Ke Shih 	PCIE_L0SDLY_3US = 2,
603e3ec7017SPing-Ke Shih 	PCIE_L0SDLY_4US = 3,
604e3ec7017SPing-Ke Shih 	PCIE_L0SDLY_5US = 4,
605e3ec7017SPing-Ke Shih 	PCIE_L0SDLY_6US = 5,
606e3ec7017SPing-Ke Shih 	PCIE_L0SDLY_7US = 6,
607e3ec7017SPing-Ke Shih };
608e3ec7017SPing-Ke Shih 
609e3ec7017SPing-Ke Shih enum rtw89_pcie_l1dly {
610e3ec7017SPing-Ke Shih 	PCIE_L1DLY_16US = 4,
611e3ec7017SPing-Ke Shih 	PCIE_L1DLY_32US = 5,
612e3ec7017SPing-Ke Shih 	PCIE_L1DLY_64US = 6,
613e3ec7017SPing-Ke Shih 	PCIE_L1DLY_HW_INFI = 7,
614e3ec7017SPing-Ke Shih };
615e3ec7017SPing-Ke Shih 
616e3ec7017SPing-Ke Shih enum rtw89_pcie_clkdly_hw {
617e3ec7017SPing-Ke Shih 	PCIE_CLKDLY_HW_0 = 0,
618e3ec7017SPing-Ke Shih 	PCIE_CLKDLY_HW_30US = 0x1,
619e3ec7017SPing-Ke Shih 	PCIE_CLKDLY_HW_50US = 0x2,
620e3ec7017SPing-Ke Shih 	PCIE_CLKDLY_HW_100US = 0x3,
621e3ec7017SPing-Ke Shih 	PCIE_CLKDLY_HW_150US = 0x4,
622e3ec7017SPing-Ke Shih 	PCIE_CLKDLY_HW_200US = 0x5,
623e3ec7017SPing-Ke Shih };
624e3ec7017SPing-Ke Shih 
625b9467e94SPing-Ke Shih enum mac_ax_bd_trunc_mode {
626b9467e94SPing-Ke Shih 	MAC_AX_BD_NORM,
627b9467e94SPing-Ke Shih 	MAC_AX_BD_TRUNC,
628b9467e94SPing-Ke Shih 	MAC_AX_BD_DEF = 0xFE
629b9467e94SPing-Ke Shih };
630b9467e94SPing-Ke Shih 
631b9467e94SPing-Ke Shih enum mac_ax_rxbd_mode {
632b9467e94SPing-Ke Shih 	MAC_AX_RXBD_PKT,
633b9467e94SPing-Ke Shih 	MAC_AX_RXBD_SEP,
634b9467e94SPing-Ke Shih 	MAC_AX_RXBD_DEF = 0xFE
635b9467e94SPing-Ke Shih };
636b9467e94SPing-Ke Shih 
637b9467e94SPing-Ke Shih enum mac_ax_tag_mode {
638b9467e94SPing-Ke Shih 	MAC_AX_TAG_SGL,
639b9467e94SPing-Ke Shih 	MAC_AX_TAG_MULTI,
640b9467e94SPing-Ke Shih 	MAC_AX_TAG_DEF = 0xFE
641b9467e94SPing-Ke Shih };
642b9467e94SPing-Ke Shih 
643b9467e94SPing-Ke Shih enum mac_ax_tx_burst {
644b9467e94SPing-Ke Shih 	MAC_AX_TX_BURST_16B = 0,
645b9467e94SPing-Ke Shih 	MAC_AX_TX_BURST_32B = 1,
646b9467e94SPing-Ke Shih 	MAC_AX_TX_BURST_64B = 2,
647b9467e94SPing-Ke Shih 	MAC_AX_TX_BURST_V1_64B = 0,
648b9467e94SPing-Ke Shih 	MAC_AX_TX_BURST_128B = 3,
649b9467e94SPing-Ke Shih 	MAC_AX_TX_BURST_V1_128B = 1,
650b9467e94SPing-Ke Shih 	MAC_AX_TX_BURST_256B = 4,
651b9467e94SPing-Ke Shih 	MAC_AX_TX_BURST_V1_256B = 2,
652b9467e94SPing-Ke Shih 	MAC_AX_TX_BURST_512B = 5,
653b9467e94SPing-Ke Shih 	MAC_AX_TX_BURST_1024B = 6,
654b9467e94SPing-Ke Shih 	MAC_AX_TX_BURST_2048B = 7,
655b9467e94SPing-Ke Shih 	MAC_AX_TX_BURST_DEF = 0xFE
656b9467e94SPing-Ke Shih };
657b9467e94SPing-Ke Shih 
658b9467e94SPing-Ke Shih enum mac_ax_rx_burst {
659b9467e94SPing-Ke Shih 	MAC_AX_RX_BURST_16B = 0,
660b9467e94SPing-Ke Shih 	MAC_AX_RX_BURST_32B = 1,
661b9467e94SPing-Ke Shih 	MAC_AX_RX_BURST_64B = 2,
662b9467e94SPing-Ke Shih 	MAC_AX_RX_BURST_V1_64B = 0,
663b9467e94SPing-Ke Shih 	MAC_AX_RX_BURST_128B = 3,
664b9467e94SPing-Ke Shih 	MAC_AX_RX_BURST_V1_128B = 1,
665b9467e94SPing-Ke Shih 	MAC_AX_RX_BURST_V1_256B = 0,
666b9467e94SPing-Ke Shih 	MAC_AX_RX_BURST_DEF = 0xFE
667b9467e94SPing-Ke Shih };
668b9467e94SPing-Ke Shih 
669b9467e94SPing-Ke Shih enum mac_ax_wd_dma_intvl {
670b9467e94SPing-Ke Shih 	MAC_AX_WD_DMA_INTVL_0S,
671b9467e94SPing-Ke Shih 	MAC_AX_WD_DMA_INTVL_256NS,
672b9467e94SPing-Ke Shih 	MAC_AX_WD_DMA_INTVL_512NS,
673b9467e94SPing-Ke Shih 	MAC_AX_WD_DMA_INTVL_768NS,
674b9467e94SPing-Ke Shih 	MAC_AX_WD_DMA_INTVL_1US,
675b9467e94SPing-Ke Shih 	MAC_AX_WD_DMA_INTVL_1_5US,
676b9467e94SPing-Ke Shih 	MAC_AX_WD_DMA_INTVL_2US,
677b9467e94SPing-Ke Shih 	MAC_AX_WD_DMA_INTVL_4US,
678b9467e94SPing-Ke Shih 	MAC_AX_WD_DMA_INTVL_8US,
679b9467e94SPing-Ke Shih 	MAC_AX_WD_DMA_INTVL_16US,
680b9467e94SPing-Ke Shih 	MAC_AX_WD_DMA_INTVL_DEF = 0xFE
681b9467e94SPing-Ke Shih };
682b9467e94SPing-Ke Shih 
683b9467e94SPing-Ke Shih enum mac_ax_multi_tag_num {
684b9467e94SPing-Ke Shih 	MAC_AX_TAG_NUM_1,
685b9467e94SPing-Ke Shih 	MAC_AX_TAG_NUM_2,
686b9467e94SPing-Ke Shih 	MAC_AX_TAG_NUM_3,
687b9467e94SPing-Ke Shih 	MAC_AX_TAG_NUM_4,
688b9467e94SPing-Ke Shih 	MAC_AX_TAG_NUM_5,
689b9467e94SPing-Ke Shih 	MAC_AX_TAG_NUM_6,
690b9467e94SPing-Ke Shih 	MAC_AX_TAG_NUM_7,
691b9467e94SPing-Ke Shih 	MAC_AX_TAG_NUM_8,
692b9467e94SPing-Ke Shih 	MAC_AX_TAG_NUM_DEF = 0xFE
693b9467e94SPing-Ke Shih };
694b9467e94SPing-Ke Shih 
695b9467e94SPing-Ke Shih enum mac_ax_lbc_tmr {
696b9467e94SPing-Ke Shih 	MAC_AX_LBC_TMR_8US = 0,
697b9467e94SPing-Ke Shih 	MAC_AX_LBC_TMR_16US,
698b9467e94SPing-Ke Shih 	MAC_AX_LBC_TMR_32US,
699b9467e94SPing-Ke Shih 	MAC_AX_LBC_TMR_64US,
700b9467e94SPing-Ke Shih 	MAC_AX_LBC_TMR_128US,
701b9467e94SPing-Ke Shih 	MAC_AX_LBC_TMR_256US,
702b9467e94SPing-Ke Shih 	MAC_AX_LBC_TMR_512US,
703b9467e94SPing-Ke Shih 	MAC_AX_LBC_TMR_1MS,
704b9467e94SPing-Ke Shih 	MAC_AX_LBC_TMR_2MS,
705b9467e94SPing-Ke Shih 	MAC_AX_LBC_TMR_4MS,
706b9467e94SPing-Ke Shih 	MAC_AX_LBC_TMR_8MS,
707b9467e94SPing-Ke Shih 	MAC_AX_LBC_TMR_DEF = 0xFE
708b9467e94SPing-Ke Shih };
709b9467e94SPing-Ke Shih 
710b9467e94SPing-Ke Shih enum mac_ax_pcie_func_ctrl {
711b9467e94SPing-Ke Shih 	MAC_AX_PCIE_DISABLE = 0,
712b9467e94SPing-Ke Shih 	MAC_AX_PCIE_ENABLE = 1,
713b9467e94SPing-Ke Shih 	MAC_AX_PCIE_DEFAULT = 0xFE,
714b9467e94SPing-Ke Shih 	MAC_AX_PCIE_IGNORE = 0xFF
715b9467e94SPing-Ke Shih };
716b9467e94SPing-Ke Shih 
717b9467e94SPing-Ke Shih enum mac_ax_io_rcy_tmr {
718b9467e94SPing-Ke Shih 	MAC_AX_IO_RCY_ANA_TMR_2MS = 24000,
719b9467e94SPing-Ke Shih 	MAC_AX_IO_RCY_ANA_TMR_4MS = 48000,
720b9467e94SPing-Ke Shih 	MAC_AX_IO_RCY_ANA_TMR_6MS = 72000,
721b9467e94SPing-Ke Shih 	MAC_AX_IO_RCY_ANA_TMR_DEF = 0xFE
722b9467e94SPing-Ke Shih };
723b9467e94SPing-Ke Shih 
724948e521cSPing-Ke Shih enum rtw89_pci_intr_mask_cfg {
725948e521cSPing-Ke Shih 	RTW89_PCI_INTR_MASK_RESET,
726948e521cSPing-Ke Shih 	RTW89_PCI_INTR_MASK_NORMAL,
727948e521cSPing-Ke Shih 	RTW89_PCI_INTR_MASK_LOW_POWER,
728948e521cSPing-Ke Shih 	RTW89_PCI_INTR_MASK_RECOVERY_START,
729948e521cSPing-Ke Shih 	RTW89_PCI_INTR_MASK_RECOVERY_COMPLETE,
730948e521cSPing-Ke Shih };
731948e521cSPing-Ke Shih 
732948e521cSPing-Ke Shih struct rtw89_pci_isrs;
733948e521cSPing-Ke Shih struct rtw89_pci;
734948e521cSPing-Ke Shih 
73552edbb9fSPing-Ke Shih struct rtw89_pci_bd_idx_addr {
73652edbb9fSPing-Ke Shih 	u32 tx_bd_addrs[RTW89_TXCH_NUM];
73752edbb9fSPing-Ke Shih 	u32 rx_bd_addrs[RTW89_RXCH_NUM];
73852edbb9fSPing-Ke Shih };
73952edbb9fSPing-Ke Shih 
74097d61bf9SPing-Ke Shih struct rtw89_pci_ch_dma_addr {
74197d61bf9SPing-Ke Shih 	u32 num;
74297d61bf9SPing-Ke Shih 	u32 idx;
74397d61bf9SPing-Ke Shih 	u32 bdram;
74497d61bf9SPing-Ke Shih 	u32 desa_l;
74597d61bf9SPing-Ke Shih 	u32 desa_h;
74697d61bf9SPing-Ke Shih };
74797d61bf9SPing-Ke Shih 
74897d61bf9SPing-Ke Shih struct rtw89_pci_ch_dma_addr_set {
74997d61bf9SPing-Ke Shih 	struct rtw89_pci_ch_dma_addr tx[RTW89_TXCH_NUM];
75097d61bf9SPing-Ke Shih 	struct rtw89_pci_ch_dma_addr rx[RTW89_RXCH_NUM];
75197d61bf9SPing-Ke Shih };
75297d61bf9SPing-Ke Shih 
7537f495de6SZong-Zhe Yang struct rtw89_pci_bd_ram {
7547f495de6SZong-Zhe Yang 	u8 start_idx;
7557f495de6SZong-Zhe Yang 	u8 max_num;
7567f495de6SZong-Zhe Yang 	u8 min_num;
7577f495de6SZong-Zhe Yang };
7587f495de6SZong-Zhe Yang 
7594a9e48acSPing-Ke Shih struct rtw89_pci_info {
760b9467e94SPing-Ke Shih 	enum mac_ax_bd_trunc_mode txbd_trunc_mode;
761b9467e94SPing-Ke Shih 	enum mac_ax_bd_trunc_mode rxbd_trunc_mode;
762b9467e94SPing-Ke Shih 	enum mac_ax_rxbd_mode rxbd_mode;
763b9467e94SPing-Ke Shih 	enum mac_ax_tag_mode tag_mode;
764b9467e94SPing-Ke Shih 	enum mac_ax_tx_burst tx_burst;
765b9467e94SPing-Ke Shih 	enum mac_ax_rx_burst rx_burst;
766b9467e94SPing-Ke Shih 	enum mac_ax_wd_dma_intvl wd_dma_idle_intvl;
767b9467e94SPing-Ke Shih 	enum mac_ax_wd_dma_intvl wd_dma_act_intvl;
768b9467e94SPing-Ke Shih 	enum mac_ax_multi_tag_num multi_tag_num;
769b9467e94SPing-Ke Shih 	enum mac_ax_pcie_func_ctrl lbc_en;
770b9467e94SPing-Ke Shih 	enum mac_ax_lbc_tmr lbc_tmr;
771b9467e94SPing-Ke Shih 	enum mac_ax_pcie_func_ctrl autok_en;
772b9467e94SPing-Ke Shih 	enum mac_ax_pcie_func_ctrl io_rcy_en;
773b9467e94SPing-Ke Shih 	enum mac_ax_io_rcy_tmr io_rcy_tmr;
774b9467e94SPing-Ke Shih 
775740c431cSPing-Ke Shih 	u32 init_cfg_reg;
776740c431cSPing-Ke Shih 	u32 txhci_en_bit;
777740c431cSPing-Ke Shih 	u32 rxhci_en_bit;
778740c431cSPing-Ke Shih 	u32 rxbd_mode_bit;
779740c431cSPing-Ke Shih 	u32 exp_ctrl_reg;
780740c431cSPing-Ke Shih 	u32 max_tag_num_mask;
781740c431cSPing-Ke Shih 	u32 rxbd_rwptr_clr_reg;
782740c431cSPing-Ke Shih 	u32 txbd_rwptr_clr2_reg;
7835280e481SChin-Yen Lee 	struct rtw89_reg_def dma_stop1;
7845280e481SChin-Yen Lee 	struct rtw89_reg_def dma_stop2;
78561bdf7aaSPing-Ke Shih 	struct rtw89_reg_def dma_busy1;
7861e3f2055SChia-Yuan Li 	u32 dma_busy2_reg;
7871e3f2055SChia-Yuan Li 	u32 dma_busy3_reg;
788740c431cSPing-Ke Shih 
789e1757e80SPing-Ke Shih 	u32 rpwm_addr;
790e1757e80SPing-Ke Shih 	u32 cpwm_addr;
7911bebcf08SPing-Ke Shih 	u32 tx_dma_ch_mask;
79252edbb9fSPing-Ke Shih 	const struct rtw89_pci_bd_idx_addr *bd_idx_addr_low_power;
79397d61bf9SPing-Ke Shih 	const struct rtw89_pci_ch_dma_addr_set *dma_addr_set;
7947f495de6SZong-Zhe Yang 	const struct rtw89_pci_bd_ram (*bd_ram_table)[RTW89_TXCH_NUM];
7956d5b5d62SPing-Ke Shih 
7960db862fbSPing-Ke Shih 	int (*ltr_set)(struct rtw89_dev *rtwdev, bool en);
7976d5b5d62SPing-Ke Shih 	u32 (*fill_txaddr_info)(struct rtw89_dev *rtwdev,
7986d5b5d62SPing-Ke Shih 				void *txaddr_info_addr, u32 total_len,
7996d5b5d62SPing-Ke Shih 				dma_addr_t dma, u8 *add_info_nr);
800948e521cSPing-Ke Shih 	void (*config_intr_mask)(struct rtw89_dev *rtwdev);
801948e521cSPing-Ke Shih 	void (*enable_intr)(struct rtw89_dev *rtwdev, struct rtw89_pci *rtwpci);
802948e521cSPing-Ke Shih 	void (*disable_intr)(struct rtw89_dev *rtwdev, struct rtw89_pci *rtwpci);
803948e521cSPing-Ke Shih 	void (*recognize_intrs)(struct rtw89_dev *rtwdev,
804948e521cSPing-Ke Shih 				struct rtw89_pci *rtwpci,
805948e521cSPing-Ke Shih 				struct rtw89_pci_isrs *isrs);
8064a9e48acSPing-Ke Shih };
8074a9e48acSPing-Ke Shih 
808e3ec7017SPing-Ke Shih struct rtw89_pci_tx_data {
809e3ec7017SPing-Ke Shih 	dma_addr_t dma;
810e3ec7017SPing-Ke Shih };
811e3ec7017SPing-Ke Shih 
812e3ec7017SPing-Ke Shih struct rtw89_pci_rx_info {
813e3ec7017SPing-Ke Shih 	dma_addr_t dma;
814e3ec7017SPing-Ke Shih 	u32 fs:1, ls:1, tag:11, len:14;
815e3ec7017SPing-Ke Shih };
816e3ec7017SPing-Ke Shih 
817e3ec7017SPing-Ke Shih #define RTW89_PCI_TXBD_OPTION_LS	BIT(14)
818e3ec7017SPing-Ke Shih 
819e3ec7017SPing-Ke Shih struct rtw89_pci_tx_bd_32 {
820e3ec7017SPing-Ke Shih 	__le16 length;
821e3ec7017SPing-Ke Shih 	__le16 option;
822e3ec7017SPing-Ke Shih 	__le32 dma;
823e3ec7017SPing-Ke Shih } __packed;
824e3ec7017SPing-Ke Shih 
825e3ec7017SPing-Ke Shih #define RTW89_PCI_TXWP_VALID		BIT(15)
826e3ec7017SPing-Ke Shih 
827e3ec7017SPing-Ke Shih struct rtw89_pci_tx_wp_info {
828e3ec7017SPing-Ke Shih 	__le16 seq0;
829e3ec7017SPing-Ke Shih 	__le16 seq1;
830e3ec7017SPing-Ke Shih 	__le16 seq2;
831e3ec7017SPing-Ke Shih 	__le16 seq3;
832e3ec7017SPing-Ke Shih } __packed;
833e3ec7017SPing-Ke Shih 
834e3ec7017SPing-Ke Shih #define RTW89_PCI_ADDR_MSDU_LS		BIT(15)
835e3ec7017SPing-Ke Shih #define RTW89_PCI_ADDR_LS		BIT(14)
836e3ec7017SPing-Ke Shih #define RTW89_PCI_ADDR_HIGH(a)		(((a) << 6) & GENMASK(13, 6))
837e3ec7017SPing-Ke Shih #define RTW89_PCI_ADDR_NUM(x)		((x) & GENMASK(5, 0))
838e3ec7017SPing-Ke Shih 
839e3ec7017SPing-Ke Shih struct rtw89_pci_tx_addr_info_32 {
840e3ec7017SPing-Ke Shih 	__le16 length;
841e3ec7017SPing-Ke Shih 	__le16 option;
842e3ec7017SPing-Ke Shih 	__le32 dma;
843e3ec7017SPing-Ke Shih } __packed;
844e3ec7017SPing-Ke Shih 
8456d5b5d62SPing-Ke Shih #define RTW89_TXADDR_INFO_NR_V1		10
8466d5b5d62SPing-Ke Shih 
8476d5b5d62SPing-Ke Shih struct rtw89_pci_tx_addr_info_32_v1 {
8486d5b5d62SPing-Ke Shih 	__le16 length_opt;
8496d5b5d62SPing-Ke Shih #define B_PCIADDR_LEN_V1_MASK		GENMASK(10, 0)
8506d5b5d62SPing-Ke Shih #define B_PCIADDR_HIGH_SEL_V1_MASK	GENMASK(14, 11)
8516d5b5d62SPing-Ke Shih #define B_PCIADDR_LS_V1_MASK		BIT(15)
8526d5b5d62SPing-Ke Shih #define TXADDR_INFO_LENTHG_V1_MAX	ALIGN_DOWN(BIT(11) - 1, 4)
8536d5b5d62SPing-Ke Shih 	__le16 dma_low_lsb;
8546d5b5d62SPing-Ke Shih 	__le16 dma_low_msb;
8556d5b5d62SPing-Ke Shih } __packed;
8566d5b5d62SPing-Ke Shih 
857e3ec7017SPing-Ke Shih #define RTW89_PCI_RPP_POLLUTED		BIT(31)
858e3ec7017SPing-Ke Shih #define RTW89_PCI_RPP_SEQ		GENMASK(30, 16)
859e3ec7017SPing-Ke Shih #define RTW89_PCI_RPP_TX_STATUS		GENMASK(15, 13)
860e3ec7017SPing-Ke Shih #define RTW89_TX_DONE			0x0
861e3ec7017SPing-Ke Shih #define RTW89_TX_RETRY_LIMIT		0x1
862e3ec7017SPing-Ke Shih #define RTW89_TX_LIFE_TIME		0x2
863e3ec7017SPing-Ke Shih #define RTW89_TX_MACID_DROP		0x3
864e3ec7017SPing-Ke Shih #define RTW89_PCI_RPP_QSEL		GENMASK(12, 8)
865e3ec7017SPing-Ke Shih #define RTW89_PCI_RPP_MACID		GENMASK(7, 0)
866e3ec7017SPing-Ke Shih 
867e3ec7017SPing-Ke Shih struct rtw89_pci_rpp_fmt {
868e3ec7017SPing-Ke Shih 	__le32 dword;
869e3ec7017SPing-Ke Shih } __packed;
870e3ec7017SPing-Ke Shih 
871e3ec7017SPing-Ke Shih struct rtw89_pci_rx_bd_32 {
872e3ec7017SPing-Ke Shih 	__le16 buf_size;
873e3ec7017SPing-Ke Shih 	__le16 rsvd;
874e3ec7017SPing-Ke Shih 	__le32 dma;
875e3ec7017SPing-Ke Shih } __packed;
876e3ec7017SPing-Ke Shih 
877e3ec7017SPing-Ke Shih #define RTW89_PCI_RXBD_FS		BIT(15)
878e3ec7017SPing-Ke Shih #define RTW89_PCI_RXBD_LS		BIT(14)
879e3ec7017SPing-Ke Shih #define RTW89_PCI_RXBD_WRITE_SIZE	GENMASK(13, 0)
880e3ec7017SPing-Ke Shih #define RTW89_PCI_RXBD_TAG		GENMASK(28, 16)
881e3ec7017SPing-Ke Shih 
882e3ec7017SPing-Ke Shih struct rtw89_pci_rxbd_info {
883e3ec7017SPing-Ke Shih 	__le32 dword;
884e3ec7017SPing-Ke Shih };
885e3ec7017SPing-Ke Shih 
886e3ec7017SPing-Ke Shih struct rtw89_pci_tx_wd {
887e3ec7017SPing-Ke Shih 	struct list_head list;
888e3ec7017SPing-Ke Shih 	struct sk_buff_head queue;
889e3ec7017SPing-Ke Shih 
890e3ec7017SPing-Ke Shih 	void *vaddr;
891e3ec7017SPing-Ke Shih 	dma_addr_t paddr;
892e3ec7017SPing-Ke Shih 	u32 len;
893e3ec7017SPing-Ke Shih 	u32 seq;
894e3ec7017SPing-Ke Shih };
895e3ec7017SPing-Ke Shih 
896e3ec7017SPing-Ke Shih struct rtw89_pci_dma_ring {
897e3ec7017SPing-Ke Shih 	void *head;
898e3ec7017SPing-Ke Shih 	u8 desc_size;
899e3ec7017SPing-Ke Shih 	dma_addr_t dma;
900e3ec7017SPing-Ke Shih 
901e4133f26SPing-Ke Shih 	struct rtw89_pci_ch_dma_addr addr;
902e3ec7017SPing-Ke Shih 
903e3ec7017SPing-Ke Shih 	u32 len;
904e3ec7017SPing-Ke Shih 	u32 wp; /* host idx */
905e3ec7017SPing-Ke Shih 	u32 rp; /* hw idx */
906e3ec7017SPing-Ke Shih };
907e3ec7017SPing-Ke Shih 
908e3ec7017SPing-Ke Shih struct rtw89_pci_tx_wd_ring {
909e3ec7017SPing-Ke Shih 	void *head;
910e3ec7017SPing-Ke Shih 	dma_addr_t dma;
911e3ec7017SPing-Ke Shih 
912e3ec7017SPing-Ke Shih 	struct rtw89_pci_tx_wd pages[RTW89_PCI_TXWD_NUM_MAX];
913e3ec7017SPing-Ke Shih 	struct list_head free_pages;
914e3ec7017SPing-Ke Shih 
915e3ec7017SPing-Ke Shih 	u32 page_size;
916e3ec7017SPing-Ke Shih 	u32 page_num;
917e3ec7017SPing-Ke Shih 	u32 curr_num;
918e3ec7017SPing-Ke Shih };
919e3ec7017SPing-Ke Shih 
920e3ec7017SPing-Ke Shih #define RTW89_RX_TAG_MAX		0x1fff
921e3ec7017SPing-Ke Shih 
922e3ec7017SPing-Ke Shih struct rtw89_pci_tx_ring {
923e3ec7017SPing-Ke Shih 	struct rtw89_pci_tx_wd_ring wd_ring;
924e3ec7017SPing-Ke Shih 	struct rtw89_pci_dma_ring bd_ring;
925e3ec7017SPing-Ke Shih 	struct list_head busy_pages;
926e3ec7017SPing-Ke Shih 	u8 txch;
927e3ec7017SPing-Ke Shih 	bool dma_enabled;
928e3ec7017SPing-Ke Shih 	u16 tag; /* range from 0x0001 ~ 0x1fff */
929e3ec7017SPing-Ke Shih 
930e3ec7017SPing-Ke Shih 	u64 tx_cnt;
931e3ec7017SPing-Ke Shih 	u64 tx_acked;
932e3ec7017SPing-Ke Shih 	u64 tx_retry_lmt;
933e3ec7017SPing-Ke Shih 	u64 tx_life_time;
934e3ec7017SPing-Ke Shih 	u64 tx_mac_id_drop;
935e3ec7017SPing-Ke Shih };
936e3ec7017SPing-Ke Shih 
937e3ec7017SPing-Ke Shih struct rtw89_pci_rx_ring {
938e3ec7017SPing-Ke Shih 	struct rtw89_pci_dma_ring bd_ring;
939e3ec7017SPing-Ke Shih 	struct sk_buff *buf[RTW89_PCI_RXBD_NUM_MAX];
940e3ec7017SPing-Ke Shih 	u32 buf_sz;
941e3ec7017SPing-Ke Shih 	struct sk_buff *diliver_skb;
942e3ec7017SPing-Ke Shih 	struct rtw89_rx_desc_info diliver_desc;
943e3ec7017SPing-Ke Shih };
944e3ec7017SPing-Ke Shih 
945e3ec7017SPing-Ke Shih struct rtw89_pci_isrs {
946948e521cSPing-Ke Shih 	u32 ind_isrs;
947e3ec7017SPing-Ke Shih 	u32 halt_c2h_isrs;
948e3ec7017SPing-Ke Shih 	u32 isrs[2];
949e3ec7017SPing-Ke Shih };
950e3ec7017SPing-Ke Shih 
951e3ec7017SPing-Ke Shih struct rtw89_pci {
952e3ec7017SPing-Ke Shih 	struct pci_dev *pdev;
953e3ec7017SPing-Ke Shih 
954e3ec7017SPing-Ke Shih 	/* protect HW irq related registers */
955e3ec7017SPing-Ke Shih 	spinlock_t irq_lock;
956e3ec7017SPing-Ke Shih 	/* protect TRX resources (exclude RXQ) */
957e3ec7017SPing-Ke Shih 	spinlock_t trx_lock;
958e3ec7017SPing-Ke Shih 	bool running;
959948e521cSPing-Ke Shih 	bool low_power;
96014f9f479SZong-Zhe Yang 	bool under_recovery;
961e3ec7017SPing-Ke Shih 	struct rtw89_pci_tx_ring tx_rings[RTW89_TXCH_NUM];
962e3ec7017SPing-Ke Shih 	struct rtw89_pci_rx_ring rx_rings[RTW89_RXCH_NUM];
963e3ec7017SPing-Ke Shih 	struct sk_buff_head h2c_queue;
964e3ec7017SPing-Ke Shih 	struct sk_buff_head h2c_release_queue;
96552edbb9fSPing-Ke Shih 	DECLARE_BITMAP(kick_map, RTW89_TXCH_NUM);
966e3ec7017SPing-Ke Shih 
967948e521cSPing-Ke Shih 	u32 ind_intrs;
968e3ec7017SPing-Ke Shih 	u32 halt_c2h_intrs;
969e3ec7017SPing-Ke Shih 	u32 intrs[2];
970e3ec7017SPing-Ke Shih 	void __iomem *mmap;
971e3ec7017SPing-Ke Shih };
972e3ec7017SPing-Ke Shih 
973e3ec7017SPing-Ke Shih static inline struct rtw89_pci_rx_info *RTW89_PCI_RX_SKB_CB(struct sk_buff *skb)
974e3ec7017SPing-Ke Shih {
975e3ec7017SPing-Ke Shih 	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
976e3ec7017SPing-Ke Shih 
977e3ec7017SPing-Ke Shih 	BUILD_BUG_ON(sizeof(struct rtw89_pci_tx_data) >
978e3ec7017SPing-Ke Shih 		     sizeof(info->status.status_driver_data));
979e3ec7017SPing-Ke Shih 
980e3ec7017SPing-Ke Shih 	return (struct rtw89_pci_rx_info *)skb->cb;
981e3ec7017SPing-Ke Shih }
982e3ec7017SPing-Ke Shih 
983e3ec7017SPing-Ke Shih static inline struct rtw89_pci_rx_bd_32 *
984e3ec7017SPing-Ke Shih RTW89_PCI_RX_BD(struct rtw89_pci_rx_ring *rx_ring, u32 idx)
985e3ec7017SPing-Ke Shih {
986e3ec7017SPing-Ke Shih 	struct rtw89_pci_dma_ring *bd_ring = &rx_ring->bd_ring;
987e3ec7017SPing-Ke Shih 	u8 *head = bd_ring->head;
988e3ec7017SPing-Ke Shih 	u32 desc_size = bd_ring->desc_size;
989e3ec7017SPing-Ke Shih 	u32 offset = idx * desc_size;
990e3ec7017SPing-Ke Shih 
991e3ec7017SPing-Ke Shih 	return (struct rtw89_pci_rx_bd_32 *)(head + offset);
992e3ec7017SPing-Ke Shih }
993e3ec7017SPing-Ke Shih 
994e3ec7017SPing-Ke Shih static inline void
995e3ec7017SPing-Ke Shih rtw89_pci_rxbd_increase(struct rtw89_pci_rx_ring *rx_ring, u32 cnt)
996e3ec7017SPing-Ke Shih {
997e3ec7017SPing-Ke Shih 	struct rtw89_pci_dma_ring *bd_ring = &rx_ring->bd_ring;
998e3ec7017SPing-Ke Shih 
999e3ec7017SPing-Ke Shih 	bd_ring->wp += cnt;
1000e3ec7017SPing-Ke Shih 
1001e3ec7017SPing-Ke Shih 	if (bd_ring->wp >= bd_ring->len)
1002e3ec7017SPing-Ke Shih 		bd_ring->wp -= bd_ring->len;
1003e3ec7017SPing-Ke Shih }
1004e3ec7017SPing-Ke Shih 
1005e3ec7017SPing-Ke Shih static inline struct rtw89_pci_tx_data *RTW89_PCI_TX_SKB_CB(struct sk_buff *skb)
1006e3ec7017SPing-Ke Shih {
1007*1ae5ca61SPo-Hao Huang 	struct rtw89_tx_skb_data *data = RTW89_TX_SKB_CB(skb);
1008e3ec7017SPing-Ke Shih 
1009*1ae5ca61SPo-Hao Huang 	return (struct rtw89_pci_tx_data *)data->hci_priv;
1010e3ec7017SPing-Ke Shih }
1011e3ec7017SPing-Ke Shih 
1012e3ec7017SPing-Ke Shih static inline struct rtw89_pci_tx_bd_32 *
1013e3ec7017SPing-Ke Shih rtw89_pci_get_next_txbd(struct rtw89_pci_tx_ring *tx_ring)
1014e3ec7017SPing-Ke Shih {
1015e3ec7017SPing-Ke Shih 	struct rtw89_pci_dma_ring *bd_ring = &tx_ring->bd_ring;
1016e3ec7017SPing-Ke Shih 	struct rtw89_pci_tx_bd_32 *tx_bd, *head;
1017e3ec7017SPing-Ke Shih 
1018e3ec7017SPing-Ke Shih 	head = bd_ring->head;
1019e3ec7017SPing-Ke Shih 	tx_bd = head + bd_ring->wp;
1020e3ec7017SPing-Ke Shih 
1021e3ec7017SPing-Ke Shih 	return tx_bd;
1022e3ec7017SPing-Ke Shih }
1023e3ec7017SPing-Ke Shih 
1024e3ec7017SPing-Ke Shih static inline struct rtw89_pci_tx_wd *
1025e3ec7017SPing-Ke Shih rtw89_pci_dequeue_txwd(struct rtw89_pci_tx_ring *tx_ring)
1026e3ec7017SPing-Ke Shih {
1027e3ec7017SPing-Ke Shih 	struct rtw89_pci_tx_wd_ring *wd_ring = &tx_ring->wd_ring;
1028e3ec7017SPing-Ke Shih 	struct rtw89_pci_tx_wd *txwd;
1029e3ec7017SPing-Ke Shih 
1030e3ec7017SPing-Ke Shih 	txwd = list_first_entry_or_null(&wd_ring->free_pages,
1031e3ec7017SPing-Ke Shih 					struct rtw89_pci_tx_wd, list);
1032e3ec7017SPing-Ke Shih 	if (!txwd)
1033e3ec7017SPing-Ke Shih 		return NULL;
1034e3ec7017SPing-Ke Shih 
1035e3ec7017SPing-Ke Shih 	list_del_init(&txwd->list);
1036e3ec7017SPing-Ke Shih 	txwd->len = 0;
1037e3ec7017SPing-Ke Shih 	wd_ring->curr_num--;
1038e3ec7017SPing-Ke Shih 
1039e3ec7017SPing-Ke Shih 	return txwd;
1040e3ec7017SPing-Ke Shih }
1041e3ec7017SPing-Ke Shih 
1042e3ec7017SPing-Ke Shih static inline void
1043e3ec7017SPing-Ke Shih rtw89_pci_enqueue_txwd(struct rtw89_pci_tx_ring *tx_ring,
1044e3ec7017SPing-Ke Shih 		       struct rtw89_pci_tx_wd *txwd)
1045e3ec7017SPing-Ke Shih {
1046e3ec7017SPing-Ke Shih 	struct rtw89_pci_tx_wd_ring *wd_ring = &tx_ring->wd_ring;
1047e3ec7017SPing-Ke Shih 
1048e3ec7017SPing-Ke Shih 	memset(txwd->vaddr, 0, wd_ring->page_size);
1049e3ec7017SPing-Ke Shih 	list_add_tail(&txwd->list, &wd_ring->free_pages);
1050e3ec7017SPing-Ke Shih 	wd_ring->curr_num++;
1051e3ec7017SPing-Ke Shih }
1052e3ec7017SPing-Ke Shih 
1053e3ec7017SPing-Ke Shih static inline bool rtw89_pci_ltr_is_err_reg_val(u32 val)
1054e3ec7017SPing-Ke Shih {
1055e3ec7017SPing-Ke Shih 	return val == 0xffffffff || val == 0xeaeaeaea;
1056e3ec7017SPing-Ke Shih }
1057e3ec7017SPing-Ke Shih 
1058e3ec7017SPing-Ke Shih extern const struct dev_pm_ops rtw89_pm_ops;
105997d61bf9SPing-Ke Shih extern const struct rtw89_pci_ch_dma_addr_set rtw89_pci_ch_dma_addr_set;
106097d61bf9SPing-Ke Shih extern const struct rtw89_pci_ch_dma_addr_set rtw89_pci_ch_dma_addr_set_v1;
10617f495de6SZong-Zhe Yang extern const struct rtw89_pci_bd_ram rtw89_bd_ram_table_dual[RTW89_TXCH_NUM];
10627f495de6SZong-Zhe Yang extern const struct rtw89_pci_bd_ram rtw89_bd_ram_table_single[RTW89_TXCH_NUM];
1063e3ec7017SPing-Ke Shih 
1064861e58c8SZong-Zhe Yang struct pci_device_id;
1065861e58c8SZong-Zhe Yang 
1066861e58c8SZong-Zhe Yang int rtw89_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id);
1067861e58c8SZong-Zhe Yang void rtw89_pci_remove(struct pci_dev *pdev);
10680db862fbSPing-Ke Shih int rtw89_pci_ltr_set(struct rtw89_dev *rtwdev, bool en);
10690db862fbSPing-Ke Shih int rtw89_pci_ltr_set_v1(struct rtw89_dev *rtwdev, bool en);
10706d5b5d62SPing-Ke Shih u32 rtw89_pci_fill_txaddr_info(struct rtw89_dev *rtwdev,
10716d5b5d62SPing-Ke Shih 			       void *txaddr_info_addr, u32 total_len,
10726d5b5d62SPing-Ke Shih 			       dma_addr_t dma, u8 *add_info_nr);
10736d5b5d62SPing-Ke Shih u32 rtw89_pci_fill_txaddr_info_v1(struct rtw89_dev *rtwdev,
10746d5b5d62SPing-Ke Shih 				  void *txaddr_info_addr, u32 total_len,
10756d5b5d62SPing-Ke Shih 				  dma_addr_t dma, u8 *add_info_nr);
1076948e521cSPing-Ke Shih void rtw89_pci_config_intr_mask(struct rtw89_dev *rtwdev);
1077948e521cSPing-Ke Shih void rtw89_pci_config_intr_mask_v1(struct rtw89_dev *rtwdev);
1078948e521cSPing-Ke Shih void rtw89_pci_enable_intr(struct rtw89_dev *rtwdev, struct rtw89_pci *rtwpci);
1079948e521cSPing-Ke Shih void rtw89_pci_disable_intr(struct rtw89_dev *rtwdev, struct rtw89_pci *rtwpci);
1080948e521cSPing-Ke Shih void rtw89_pci_enable_intr_v1(struct rtw89_dev *rtwdev, struct rtw89_pci *rtwpci);
1081948e521cSPing-Ke Shih void rtw89_pci_disable_intr_v1(struct rtw89_dev *rtwdev, struct rtw89_pci *rtwpci);
1082948e521cSPing-Ke Shih void rtw89_pci_recognize_intrs(struct rtw89_dev *rtwdev,
1083948e521cSPing-Ke Shih 			       struct rtw89_pci *rtwpci,
1084948e521cSPing-Ke Shih 			       struct rtw89_pci_isrs *isrs);
1085948e521cSPing-Ke Shih void rtw89_pci_recognize_intrs_v1(struct rtw89_dev *rtwdev,
1086948e521cSPing-Ke Shih 				  struct rtw89_pci *rtwpci,
1087948e521cSPing-Ke Shih 				  struct rtw89_pci_isrs *isrs);
10886d5b5d62SPing-Ke Shih 
10896d5b5d62SPing-Ke Shih static inline
10906d5b5d62SPing-Ke Shih u32 rtw89_chip_fill_txaddr_info(struct rtw89_dev *rtwdev,
10916d5b5d62SPing-Ke Shih 				void *txaddr_info_addr, u32 total_len,
10926d5b5d62SPing-Ke Shih 				dma_addr_t dma, u8 *add_info_nr)
10936d5b5d62SPing-Ke Shih {
10946d5b5d62SPing-Ke Shih 	const struct rtw89_pci_info *info = rtwdev->pci_info;
10956d5b5d62SPing-Ke Shih 
10966d5b5d62SPing-Ke Shih 	return info->fill_txaddr_info(rtwdev, txaddr_info_addr, total_len,
10976d5b5d62SPing-Ke Shih 				      dma, add_info_nr);
10986d5b5d62SPing-Ke Shih }
1099861e58c8SZong-Zhe Yang 
1100948e521cSPing-Ke Shih static inline void rtw89_chip_config_intr_mask(struct rtw89_dev *rtwdev,
1101948e521cSPing-Ke Shih 					       enum rtw89_pci_intr_mask_cfg cfg)
1102948e521cSPing-Ke Shih {
1103948e521cSPing-Ke Shih 	struct rtw89_pci *rtwpci = (struct rtw89_pci *)rtwdev->priv;
1104948e521cSPing-Ke Shih 	const struct rtw89_pci_info *info = rtwdev->pci_info;
1105948e521cSPing-Ke Shih 
1106948e521cSPing-Ke Shih 	switch (cfg) {
1107948e521cSPing-Ke Shih 	default:
1108948e521cSPing-Ke Shih 	case RTW89_PCI_INTR_MASK_RESET:
1109948e521cSPing-Ke Shih 		rtwpci->low_power = false;
1110948e521cSPing-Ke Shih 		rtwpci->under_recovery = false;
1111948e521cSPing-Ke Shih 		break;
1112948e521cSPing-Ke Shih 	case RTW89_PCI_INTR_MASK_NORMAL:
1113948e521cSPing-Ke Shih 		rtwpci->low_power = false;
1114948e521cSPing-Ke Shih 		break;
1115948e521cSPing-Ke Shih 	case RTW89_PCI_INTR_MASK_LOW_POWER:
1116948e521cSPing-Ke Shih 		rtwpci->low_power = true;
1117948e521cSPing-Ke Shih 		break;
1118948e521cSPing-Ke Shih 	case RTW89_PCI_INTR_MASK_RECOVERY_START:
1119948e521cSPing-Ke Shih 		rtwpci->under_recovery = true;
1120948e521cSPing-Ke Shih 		break;
1121948e521cSPing-Ke Shih 	case RTW89_PCI_INTR_MASK_RECOVERY_COMPLETE:
1122948e521cSPing-Ke Shih 		rtwpci->under_recovery = false;
1123948e521cSPing-Ke Shih 		break;
1124948e521cSPing-Ke Shih 	}
1125948e521cSPing-Ke Shih 
1126948e521cSPing-Ke Shih 	rtw89_debug(rtwdev, RTW89_DBG_HCI,
1127948e521cSPing-Ke Shih 		    "Configure PCI interrupt mask mode low_power=%d under_recovery=%d\n",
1128948e521cSPing-Ke Shih 		    rtwpci->low_power, rtwpci->under_recovery);
1129948e521cSPing-Ke Shih 
1130948e521cSPing-Ke Shih 	info->config_intr_mask(rtwdev);
1131948e521cSPing-Ke Shih }
1132948e521cSPing-Ke Shih 
1133948e521cSPing-Ke Shih static inline
1134948e521cSPing-Ke Shih void rtw89_chip_enable_intr(struct rtw89_dev *rtwdev, struct rtw89_pci *rtwpci)
1135948e521cSPing-Ke Shih {
1136948e521cSPing-Ke Shih 	const struct rtw89_pci_info *info = rtwdev->pci_info;
1137948e521cSPing-Ke Shih 
1138948e521cSPing-Ke Shih 	info->enable_intr(rtwdev, rtwpci);
1139948e521cSPing-Ke Shih }
1140948e521cSPing-Ke Shih 
1141948e521cSPing-Ke Shih static inline
1142948e521cSPing-Ke Shih void rtw89_chip_disable_intr(struct rtw89_dev *rtwdev, struct rtw89_pci *rtwpci)
1143948e521cSPing-Ke Shih {
1144948e521cSPing-Ke Shih 	const struct rtw89_pci_info *info = rtwdev->pci_info;
1145948e521cSPing-Ke Shih 
1146948e521cSPing-Ke Shih 	info->disable_intr(rtwdev, rtwpci);
1147948e521cSPing-Ke Shih }
1148948e521cSPing-Ke Shih 
1149948e521cSPing-Ke Shih static inline
1150948e521cSPing-Ke Shih void rtw89_chip_recognize_intrs(struct rtw89_dev *rtwdev,
1151948e521cSPing-Ke Shih 				struct rtw89_pci *rtwpci,
1152948e521cSPing-Ke Shih 				struct rtw89_pci_isrs *isrs)
1153948e521cSPing-Ke Shih {
1154948e521cSPing-Ke Shih 	const struct rtw89_pci_info *info = rtwdev->pci_info;
1155948e521cSPing-Ke Shih 
1156948e521cSPing-Ke Shih 	info->recognize_intrs(rtwdev, rtwpci, isrs);
1157948e521cSPing-Ke Shih }
1158948e521cSPing-Ke Shih 
1159e3ec7017SPing-Ke Shih #endif
1160