xref: /wlan-driver/qca-wifi-host-cmn/hif/src/ce/ce_reg.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1*5113495bSYour Name /*
2*5113495bSYour Name  * Copyright (c) 2015-2020 The Linux Foundation. All rights reserved.
3*5113495bSYour Name  * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4*5113495bSYour Name  *
5*5113495bSYour Name  * Permission to use, copy, modify, and/or distribute this software for
6*5113495bSYour Name  * any purpose with or without fee is hereby granted, provided that the
7*5113495bSYour Name  * above copyright notice and this permission notice appear in all
8*5113495bSYour Name  * copies.
9*5113495bSYour Name  *
10*5113495bSYour Name  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11*5113495bSYour Name  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12*5113495bSYour Name  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13*5113495bSYour Name  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14*5113495bSYour Name  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15*5113495bSYour Name  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16*5113495bSYour Name  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17*5113495bSYour Name  * PERFORMANCE OF THIS SOFTWARE.
18*5113495bSYour Name  */
19*5113495bSYour Name 
20*5113495bSYour Name #ifndef __CE_REG_H__
21*5113495bSYour Name #define __CE_REG_H__
22*5113495bSYour Name 
23*5113495bSYour Name #define COPY_ENGINE_ID(COPY_ENGINE_BASE_ADDRESS) ((COPY_ENGINE_BASE_ADDRESS \
24*5113495bSYour Name 		- CE0_BASE_ADDRESS)/(CE1_BASE_ADDRESS - CE0_BASE_ADDRESS))
25*5113495bSYour Name 
26*5113495bSYour Name #define DST_WR_INDEX_ADDRESS    (scn->target_ce_def->d_DST_WR_INDEX_ADDRESS)
27*5113495bSYour Name #define SRC_WATERMARK_ADDRESS   (scn->target_ce_def->d_SRC_WATERMARK_ADDRESS)
28*5113495bSYour Name #define SRC_WATERMARK_LOW_MASK  (scn->target_ce_def->d_SRC_WATERMARK_LOW_MASK)
29*5113495bSYour Name #define SRC_WATERMARK_HIGH_MASK (scn->target_ce_def->d_SRC_WATERMARK_HIGH_MASK)
30*5113495bSYour Name #define DST_WATERMARK_LOW_MASK  (scn->target_ce_def->d_DST_WATERMARK_LOW_MASK)
31*5113495bSYour Name #define DST_WATERMARK_HIGH_MASK (scn->target_ce_def->d_DST_WATERMARK_HIGH_MASK)
32*5113495bSYour Name #define CURRENT_SRRI_ADDRESS    (scn->target_ce_def->d_CURRENT_SRRI_ADDRESS)
33*5113495bSYour Name #define CURRENT_DRRI_ADDRESS    (scn->target_ce_def->d_CURRENT_DRRI_ADDRESS)
34*5113495bSYour Name 
35*5113495bSYour Name #define SHADOW_VALUE0    (scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_VALUE_0)
36*5113495bSYour Name #define SHADOW_VALUE1    (scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_VALUE_1)
37*5113495bSYour Name #define SHADOW_VALUE2    (scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_VALUE_2)
38*5113495bSYour Name #define SHADOW_VALUE3    (scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_VALUE_3)
39*5113495bSYour Name #define SHADOW_VALUE4    (scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_VALUE_4)
40*5113495bSYour Name #define SHADOW_VALUE5    (scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_VALUE_5)
41*5113495bSYour Name #define SHADOW_VALUE6    (scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_VALUE_6)
42*5113495bSYour Name #define SHADOW_VALUE7    (scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_VALUE_7)
43*5113495bSYour Name #define SHADOW_VALUE8    (scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_VALUE_8)
44*5113495bSYour Name #define SHADOW_VALUE9    (scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_VALUE_9)
45*5113495bSYour Name #define SHADOW_VALUE10   (scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_VALUE_10)
46*5113495bSYour Name #define SHADOW_VALUE11   (scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_VALUE_11)
47*5113495bSYour Name #define SHADOW_VALUE12   (scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_VALUE_12)
48*5113495bSYour Name #define SHADOW_VALUE13   (scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_VALUE_13)
49*5113495bSYour Name #define SHADOW_VALUE14   (scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_VALUE_14)
50*5113495bSYour Name #define SHADOW_VALUE15   (scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_VALUE_15)
51*5113495bSYour Name #define SHADOW_VALUE16   (scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_VALUE_16)
52*5113495bSYour Name #define SHADOW_VALUE17   (scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_VALUE_17)
53*5113495bSYour Name #define SHADOW_VALUE18   (scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_VALUE_18)
54*5113495bSYour Name #define SHADOW_VALUE19   (scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_VALUE_19)
55*5113495bSYour Name #define SHADOW_VALUE20   (scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_VALUE_20)
56*5113495bSYour Name #define SHADOW_VALUE21   (scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_VALUE_21)
57*5113495bSYour Name #define SHADOW_VALUE22   (scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_VALUE_22)
58*5113495bSYour Name #define SHADOW_VALUE23   (scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_VALUE_23)
59*5113495bSYour Name #define SHADOW_ADDRESS0  (scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_ADDRESS_0)
60*5113495bSYour Name #define SHADOW_ADDRESS1  (scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_ADDRESS_1)
61*5113495bSYour Name #define SHADOW_ADDRESS2  (scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_ADDRESS_2)
62*5113495bSYour Name #define SHADOW_ADDRESS3  (scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_ADDRESS_3)
63*5113495bSYour Name #define SHADOW_ADDRESS4  (scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_ADDRESS_4)
64*5113495bSYour Name #define SHADOW_ADDRESS5  (scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_ADDRESS_5)
65*5113495bSYour Name #define SHADOW_ADDRESS6  (scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_ADDRESS_6)
66*5113495bSYour Name #define SHADOW_ADDRESS7  (scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_ADDRESS_7)
67*5113495bSYour Name #define SHADOW_ADDRESS8  (scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_ADDRESS_8)
68*5113495bSYour Name #define SHADOW_ADDRESS9  (scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_ADDRESS_9)
69*5113495bSYour Name #define SHADOW_ADDRESS10 \
70*5113495bSYour Name 			(scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_ADDRESS_10)
71*5113495bSYour Name #define SHADOW_ADDRESS11 \
72*5113495bSYour Name 			(scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_ADDRESS_11)
73*5113495bSYour Name #define SHADOW_ADDRESS12 \
74*5113495bSYour Name 			(scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_ADDRESS_12)
75*5113495bSYour Name #define SHADOW_ADDRESS13 \
76*5113495bSYour Name 			(scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_ADDRESS_13)
77*5113495bSYour Name #define SHADOW_ADDRESS14 \
78*5113495bSYour Name 			(scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_ADDRESS_14)
79*5113495bSYour Name #define SHADOW_ADDRESS15 \
80*5113495bSYour Name 			(scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_ADDRESS_15)
81*5113495bSYour Name #define SHADOW_ADDRESS16 \
82*5113495bSYour Name 			(scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_ADDRESS_16)
83*5113495bSYour Name #define SHADOW_ADDRESS17 \
84*5113495bSYour Name 			(scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_ADDRESS_17)
85*5113495bSYour Name #define SHADOW_ADDRESS18 \
86*5113495bSYour Name 			(scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_ADDRESS_18)
87*5113495bSYour Name #define SHADOW_ADDRESS19 \
88*5113495bSYour Name 			(scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_ADDRESS_19)
89*5113495bSYour Name #define SHADOW_ADDRESS20 \
90*5113495bSYour Name 			(scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_ADDRESS_20)
91*5113495bSYour Name #define SHADOW_ADDRESS21 \
92*5113495bSYour Name 			(scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_ADDRESS_21)
93*5113495bSYour Name #define SHADOW_ADDRESS22 \
94*5113495bSYour Name 			(scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_ADDRESS_22)
95*5113495bSYour Name #define SHADOW_ADDRESS23 \
96*5113495bSYour Name 			(scn->host_shadow_regs->d_A_LOCAL_SHADOW_REG_ADDRESS_23)
97*5113495bSYour Name 
98*5113495bSYour Name #define SHADOW_ADDRESS(i) \
99*5113495bSYour Name 			(SHADOW_ADDRESS0 + i*(SHADOW_ADDRESS1-SHADOW_ADDRESS0))
100*5113495bSYour Name 
101*5113495bSYour Name #define HOST_IS_SRC_RING_HIGH_WATERMARK_MASK \
102*5113495bSYour Name 	(scn->target_ce_def->d_HOST_IS_SRC_RING_HIGH_WATERMARK_MASK)
103*5113495bSYour Name #define HOST_IS_SRC_RING_LOW_WATERMARK_MASK \
104*5113495bSYour Name 	(scn->target_ce_def->d_HOST_IS_SRC_RING_LOW_WATERMARK_MASK)
105*5113495bSYour Name #define HOST_IS_DST_RING_HIGH_WATERMARK_MASK \
106*5113495bSYour Name 	(scn->target_ce_def->d_HOST_IS_DST_RING_HIGH_WATERMARK_MASK)
107*5113495bSYour Name #define HOST_IS_DST_RING_LOW_WATERMARK_MASK \
108*5113495bSYour Name 	(scn->target_ce_def->d_HOST_IS_DST_RING_LOW_WATERMARK_MASK)
109*5113495bSYour Name #define MISC_IS_ADDRESS         (scn->target_ce_def->d_MISC_IS_ADDRESS)
110*5113495bSYour Name #define HOST_IS_COPY_COMPLETE_MASK \
111*5113495bSYour Name 	(scn->target_ce_def->d_HOST_IS_COPY_COMPLETE_MASK)
112*5113495bSYour Name #define CE_WRAPPER_BASE_ADDRESS (scn->target_ce_def->d_CE_WRAPPER_BASE_ADDRESS)
113*5113495bSYour Name #define CE_WRAPPER_INTERRUPT_SUMMARY_ADDRESS \
114*5113495bSYour Name 	(scn->target_ce_def->d_CE_WRAPPER_INTERRUPT_SUMMARY_ADDRESS)
115*5113495bSYour Name #define CE_DDR_ADDRESS_FOR_RRI_LOW \
116*5113495bSYour Name 	(scn->target_ce_def->d_CE_DDR_ADDRESS_FOR_RRI_LOW)
117*5113495bSYour Name #define CE_DDR_ADDRESS_FOR_RRI_HIGH \
118*5113495bSYour Name 	(scn->target_ce_def->d_CE_DDR_ADDRESS_FOR_RRI_HIGH)
119*5113495bSYour Name #define HOST_IE_COPY_COMPLETE_MASK \
120*5113495bSYour Name 	(scn->target_ce_def->d_HOST_IE_COPY_COMPLETE_MASK)
121*5113495bSYour Name #define SR_BA_ADDRESS             (scn->target_ce_def->d_SR_BA_ADDRESS)
122*5113495bSYour Name #define SR_BA_ADDRESS_HIGH        (scn->target_ce_def->d_SR_BA_ADDRESS_HIGH)
123*5113495bSYour Name #define SR_SIZE_ADDRESS           (scn->target_ce_def->d_SR_SIZE_ADDRESS)
124*5113495bSYour Name #define CE_CTRL1_ADDRESS          (scn->target_ce_def->d_CE_CTRL1_ADDRESS)
125*5113495bSYour Name #define CE_CTRL1_DMAX_LENGTH_MASK \
126*5113495bSYour Name 	(scn->target_ce_def->d_CE_CTRL1_DMAX_LENGTH_MASK)
127*5113495bSYour Name #define DR_BA_ADDRESS             (scn->target_ce_def->d_DR_BA_ADDRESS)
128*5113495bSYour Name #define DR_BA_ADDRESS_HIGH        (scn->target_ce_def->d_DR_BA_ADDRESS_HIGH)
129*5113495bSYour Name #define DR_SIZE_ADDRESS           (scn->target_ce_def->d_DR_SIZE_ADDRESS)
130*5113495bSYour Name #define CE_CMD_REGISTER           (scn->target_ce_def->d_CE_CMD_REGISTER)
131*5113495bSYour Name #define CE_MSI_ADDRESS            (scn->target_ce_def->d_CE_MSI_ADDRESS)
132*5113495bSYour Name #define CE_MSI_ADDRESS_HIGH       (scn->target_ce_def->d_CE_MSI_ADDRESS_HIGH)
133*5113495bSYour Name #define CE_MSI_DATA               (scn->target_ce_def->d_CE_MSI_DATA)
134*5113495bSYour Name #define CE_MSI_ENABLE_BIT         (scn->target_ce_def->d_CE_MSI_ENABLE_BIT)
135*5113495bSYour Name #define CE_SRC_BATCH_TIMER_INT_SETUP \
136*5113495bSYour Name 	(scn->target_ce_def->d_CE_SRC_BATCH_TIMER_INT_SETUP)
137*5113495bSYour Name #define CE_DST_BATCH_TIMER_INT_SETUP \
138*5113495bSYour Name 	(scn->target_ce_def->d_CE_DST_BATCH_TIMER_INT_SETUP)
139*5113495bSYour Name #define MISC_IE_ADDRESS           (scn->target_ce_def->d_MISC_IE_ADDRESS)
140*5113495bSYour Name #define MISC_IS_AXI_ERR_MASK      (scn->target_ce_def->d_MISC_IS_AXI_ERR_MASK)
141*5113495bSYour Name #define MISC_IS_DST_ADDR_ERR_MASK \
142*5113495bSYour Name 	(scn->target_ce_def->d_MISC_IS_DST_ADDR_ERR_MASK)
143*5113495bSYour Name #define MISC_IS_SRC_LEN_ERR_MASK \
144*5113495bSYour Name 	(scn->target_ce_def->d_MISC_IS_SRC_LEN_ERR_MASK)
145*5113495bSYour Name #define MISC_IS_DST_MAX_LEN_VIO_MASK \
146*5113495bSYour Name 	(scn->target_ce_def->d_MISC_IS_DST_MAX_LEN_VIO_MASK)
147*5113495bSYour Name #define MISC_IS_DST_RING_OVERFLOW_MASK \
148*5113495bSYour Name 	(scn->target_ce_def->d_MISC_IS_DST_RING_OVERFLOW_MASK)
149*5113495bSYour Name #define MISC_IS_SRC_RING_OVERFLOW_MASK \
150*5113495bSYour Name 	(scn->target_ce_def->d_MISC_IS_SRC_RING_OVERFLOW_MASK)
151*5113495bSYour Name #define SRC_WATERMARK_LOW_LSB     (scn->target_ce_def->d_SRC_WATERMARK_LOW_LSB)
152*5113495bSYour Name #define SRC_WATERMARK_HIGH_LSB    (scn->target_ce_def->d_SRC_WATERMARK_HIGH_LSB)
153*5113495bSYour Name #define DST_WATERMARK_LOW_LSB     (scn->target_ce_def->d_DST_WATERMARK_LOW_LSB)
154*5113495bSYour Name #define DST_WATERMARK_HIGH_LSB    (scn->target_ce_def->d_DST_WATERMARK_HIGH_LSB)
155*5113495bSYour Name #define CE_WRAPPER_INTERRUPT_SUMMARY_HOST_MSI_MASK \
156*5113495bSYour Name 	(scn->target_ce_def->d_CE_WRAPPER_INTERRUPT_SUMMARY_HOST_MSI_MASK)
157*5113495bSYour Name #define CE_WRAPPER_INTERRUPT_SUMMARY_HOST_MSI_LSB  \
158*5113495bSYour Name 	(scn->target_ce_def->d_CE_WRAPPER_INTERRUPT_SUMMARY_HOST_MSI_LSB)
159*5113495bSYour Name #define CE_CTRL1_DMAX_LENGTH_LSB \
160*5113495bSYour Name 				(scn->target_ce_def->d_CE_CTRL1_DMAX_LENGTH_LSB)
161*5113495bSYour Name #define CE_CTRL1_IDX_UPD_EN  (scn->target_ce_def->d_CE_CTRL1_IDX_UPD_EN_MASK)
162*5113495bSYour Name #define CE_CTRL1_SRC_RING_BYTE_SWAP_EN_MASK \
163*5113495bSYour Name 	(scn->target_ce_def->d_CE_CTRL1_SRC_RING_BYTE_SWAP_EN_MASK)
164*5113495bSYour Name #define CE_CTRL1_DST_RING_BYTE_SWAP_EN_MASK \
165*5113495bSYour Name 	(scn->target_ce_def->d_CE_CTRL1_DST_RING_BYTE_SWAP_EN_MASK)
166*5113495bSYour Name #define CE_CTRL1_SRC_RING_BYTE_SWAP_EN_LSB \
167*5113495bSYour Name 	(scn->target_ce_def->d_CE_CTRL1_SRC_RING_BYTE_SWAP_EN_LSB)
168*5113495bSYour Name #define CE_CTRL1_DST_RING_BYTE_SWAP_EN_LSB \
169*5113495bSYour Name 	(scn->target_ce_def->d_CE_CTRL1_DST_RING_BYTE_SWAP_EN_LSB)
170*5113495bSYour Name #define WLAN_DEBUG_INPUT_SEL_OFFSET \
171*5113495bSYour Name 	(scn->targetdef->d_WLAN_DEBUG_INPUT_SEL_OFFSET)
172*5113495bSYour Name #define WLAN_DEBUG_INPUT_SEL_SRC_MSB \
173*5113495bSYour Name 	(scn->targetdef->d_WLAN_DEBUG_INPUT_SEL_SRC_MSB)
174*5113495bSYour Name #define WLAN_DEBUG_INPUT_SEL_SRC_LSB \
175*5113495bSYour Name 	(scn->targetdef->d_WLAN_DEBUG_INPUT_SEL_SRC_LSB)
176*5113495bSYour Name #define WLAN_DEBUG_INPUT_SEL_SRC_MASK \
177*5113495bSYour Name 	(scn->targetdef->d_WLAN_DEBUG_INPUT_SEL_SRC_MASK)
178*5113495bSYour Name #define WLAN_DEBUG_CONTROL_OFFSET  (scn->targetdef->d_WLAN_DEBUG_CONTROL_OFFSET)
179*5113495bSYour Name #define WLAN_DEBUG_CONTROL_ENABLE_MSB \
180*5113495bSYour Name 	(scn->targetdef->d_WLAN_DEBUG_CONTROL_ENABLE_MSB)
181*5113495bSYour Name #define WLAN_DEBUG_CONTROL_ENABLE_LSB \
182*5113495bSYour Name 	(scn->targetdef->d_WLAN_DEBUG_CONTROL_ENABLE_LSB)
183*5113495bSYour Name #define WLAN_DEBUG_CONTROL_ENABLE_MASK \
184*5113495bSYour Name 	(scn->targetdef->d_WLAN_DEBUG_CONTROL_ENABLE_MASK)
185*5113495bSYour Name #define WLAN_DEBUG_OUT_OFFSET    (scn->targetdef->d_WLAN_DEBUG_OUT_OFFSET)
186*5113495bSYour Name #define WLAN_DEBUG_OUT_DATA_MSB  (scn->targetdef->d_WLAN_DEBUG_OUT_DATA_MSB)
187*5113495bSYour Name #define WLAN_DEBUG_OUT_DATA_LSB  (scn->targetdef->d_WLAN_DEBUG_OUT_DATA_LSB)
188*5113495bSYour Name #define WLAN_DEBUG_OUT_DATA_MASK (scn->targetdef->d_WLAN_DEBUG_OUT_DATA_MASK)
189*5113495bSYour Name #define AMBA_DEBUG_BUS_OFFSET    (scn->targetdef->d_AMBA_DEBUG_BUS_OFFSET)
190*5113495bSYour Name #define AMBA_DEBUG_BUS_PCIE_DEBUG_SEL_MSB \
191*5113495bSYour Name 	(scn->targetdef->d_AMBA_DEBUG_BUS_PCIE_DEBUG_SEL_MSB)
192*5113495bSYour Name #define AMBA_DEBUG_BUS_PCIE_DEBUG_SEL_LSB \
193*5113495bSYour Name 	(scn->targetdef->d_AMBA_DEBUG_BUS_PCIE_DEBUG_SEL_LSB)
194*5113495bSYour Name #define AMBA_DEBUG_BUS_PCIE_DEBUG_SEL_MASK \
195*5113495bSYour Name 	(scn->targetdef->d_AMBA_DEBUG_BUS_PCIE_DEBUG_SEL_MASK)
196*5113495bSYour Name #define AMBA_DEBUG_BUS_SEL_MSB    (scn->targetdef->d_AMBA_DEBUG_BUS_SEL_MSB)
197*5113495bSYour Name #define AMBA_DEBUG_BUS_SEL_LSB    (scn->targetdef->d_AMBA_DEBUG_BUS_SEL_LSB)
198*5113495bSYour Name #define AMBA_DEBUG_BUS_SEL_MASK   (scn->targetdef->d_AMBA_DEBUG_BUS_SEL_MASK)
199*5113495bSYour Name #define CE_WRAPPER_DEBUG_OFFSET   \
200*5113495bSYour Name 				(scn->target_ce_def->d_CE_WRAPPER_DEBUG_OFFSET)
201*5113495bSYour Name #define CE_WRAPPER_DEBUG_SEL_MSB  \
202*5113495bSYour Name 				(scn->target_ce_def->d_CE_WRAPPER_DEBUG_SEL_MSB)
203*5113495bSYour Name #define CE_WRAPPER_DEBUG_SEL_LSB  \
204*5113495bSYour Name 				(scn->target_ce_def->d_CE_WRAPPER_DEBUG_SEL_LSB)
205*5113495bSYour Name #define CE_WRAPPER_DEBUG_SEL_MASK \
206*5113495bSYour Name 			(scn->target_ce_def->d_CE_WRAPPER_DEBUG_SEL_MASK)
207*5113495bSYour Name #define CE_DEBUG_OFFSET           (scn->target_ce_def->d_CE_DEBUG_OFFSET)
208*5113495bSYour Name #define CE_DEBUG_SEL_MSB          (scn->target_ce_def->d_CE_DEBUG_SEL_MSB)
209*5113495bSYour Name #define CE_DEBUG_SEL_LSB          (scn->target_ce_def->d_CE_DEBUG_SEL_LSB)
210*5113495bSYour Name #define CE_DEBUG_SEL_MASK         (scn->target_ce_def->d_CE_DEBUG_SEL_MASK)
211*5113495bSYour Name #define HOST_IE_ADDRESS           (scn->target_ce_def->d_HOST_IE_ADDRESS)
212*5113495bSYour Name #define HOST_IE_REG1_CE_LSB       (scn->target_ce_def->d_HOST_IE_REG1_CE_LSB)
213*5113495bSYour Name #define HOST_IE_ADDRESS_2         (scn->target_ce_def->d_HOST_IE_ADDRESS_2)
214*5113495bSYour Name #define HOST_IE_REG2_CE_LSB       (scn->target_ce_def->d_HOST_IE_REG2_CE_LSB)
215*5113495bSYour Name #define HOST_IE_ADDRESS_3         (scn->target_ce_def->d_HOST_IE_ADDRESS_3)
216*5113495bSYour Name #define HOST_IE_REG3_CE_LSB       (scn->target_ce_def->d_HOST_IE_REG3_CE_LSB)
217*5113495bSYour Name #define HOST_IS_ADDRESS           (scn->target_ce_def->d_HOST_IS_ADDRESS)
218*5113495bSYour Name #define HOST_CE_ADDRESS           (scn->target_ce_def->d_HOST_CE_ADDRESS)
219*5113495bSYour Name #define HOST_CMEM_ADDRESS         (scn->target_ce_def->d_HOST_CMEM_ADDRESS)
220*5113495bSYour Name #define PMM_SCRATCH_BASE	  (scn->target_ce_def->d_PMM_SCRATCH_BASE)
221*5113495bSYour Name 
222*5113495bSYour Name #define SRC_WATERMARK_LOW_SET(x) \
223*5113495bSYour Name 	(((x) << SRC_WATERMARK_LOW_LSB) & SRC_WATERMARK_LOW_MASK)
224*5113495bSYour Name #define SRC_WATERMARK_HIGH_SET(x) \
225*5113495bSYour Name 	(((x) << SRC_WATERMARK_HIGH_LSB) & SRC_WATERMARK_HIGH_MASK)
226*5113495bSYour Name #define DST_WATERMARK_LOW_SET(x) \
227*5113495bSYour Name 	(((x) << DST_WATERMARK_LOW_LSB) & DST_WATERMARK_LOW_MASK)
228*5113495bSYour Name #define DST_WATERMARK_HIGH_SET(x) \
229*5113495bSYour Name 	(((x) << DST_WATERMARK_HIGH_LSB) & DST_WATERMARK_HIGH_MASK)
230*5113495bSYour Name #define CE_WRAPPER_INTERRUPT_SUMMARY_HOST_MSI_GET(x) \
231*5113495bSYour Name 	(((x) & CE_WRAPPER_INTERRUPT_SUMMARY_HOST_MSI_MASK) >> \
232*5113495bSYour Name 		CE_WRAPPER_INTERRUPT_SUMMARY_HOST_MSI_LSB)
233*5113495bSYour Name #define CE_CTRL1_DMAX_LENGTH_SET(x) \
234*5113495bSYour Name 	(((x) << CE_CTRL1_DMAX_LENGTH_LSB) & CE_CTRL1_DMAX_LENGTH_MASK)
235*5113495bSYour Name #define CE_CTRL1_SRC_RING_BYTE_SWAP_EN_SET(x) \
236*5113495bSYour Name 	(((x) << CE_CTRL1_SRC_RING_BYTE_SWAP_EN_LSB) & \
237*5113495bSYour Name 		CE_CTRL1_SRC_RING_BYTE_SWAP_EN_MASK)
238*5113495bSYour Name #define CE_CTRL1_DST_RING_BYTE_SWAP_EN_SET(x) \
239*5113495bSYour Name 	(((x) << CE_CTRL1_DST_RING_BYTE_SWAP_EN_LSB) & \
240*5113495bSYour Name 		CE_CTRL1_DST_RING_BYTE_SWAP_EN_MASK)
241*5113495bSYour Name #define WLAN_DEBUG_INPUT_SEL_SRC_GET(x) \
242*5113495bSYour Name 	(((x) & WLAN_DEBUG_INPUT_SEL_SRC_MASK) >> \
243*5113495bSYour Name 		WLAN_DEBUG_INPUT_SEL_SRC_LSB)
244*5113495bSYour Name #define WLAN_DEBUG_INPUT_SEL_SRC_SET(x) \
245*5113495bSYour Name 	(((x) << WLAN_DEBUG_INPUT_SEL_SRC_LSB) & \
246*5113495bSYour Name 		WLAN_DEBUG_INPUT_SEL_SRC_MASK)
247*5113495bSYour Name #define WLAN_DEBUG_CONTROL_ENABLE_GET(x) \
248*5113495bSYour Name 	(((x) & WLAN_DEBUG_CONTROL_ENABLE_MASK) >> \
249*5113495bSYour Name 		WLAN_DEBUG_CONTROL_ENABLE_LSB)
250*5113495bSYour Name #define WLAN_DEBUG_CONTROL_ENABLE_SET(x) \
251*5113495bSYour Name 	(((x) << WLAN_DEBUG_CONTROL_ENABLE_LSB) & \
252*5113495bSYour Name 		WLAN_DEBUG_CONTROL_ENABLE_MASK)
253*5113495bSYour Name #define WLAN_DEBUG_OUT_DATA_GET(x) \
254*5113495bSYour Name 	(((x) & WLAN_DEBUG_OUT_DATA_MASK) >> WLAN_DEBUG_OUT_DATA_LSB)
255*5113495bSYour Name #define WLAN_DEBUG_OUT_DATA_SET(x) \
256*5113495bSYour Name 	(((x) << WLAN_DEBUG_OUT_DATA_LSB) & WLAN_DEBUG_OUT_DATA_MASK)
257*5113495bSYour Name #define AMBA_DEBUG_BUS_PCIE_DEBUG_SEL_GET(x) \
258*5113495bSYour Name 	(((x) & AMBA_DEBUG_BUS_PCIE_DEBUG_SEL_MASK) >> \
259*5113495bSYour Name 		AMBA_DEBUG_BUS_PCIE_DEBUG_SEL_LSB)
260*5113495bSYour Name #define AMBA_DEBUG_BUS_PCIE_DEBUG_SEL_SET(x) \
261*5113495bSYour Name 	(((x) << AMBA_DEBUG_BUS_PCIE_DEBUG_SEL_LSB) & \
262*5113495bSYour Name 		AMBA_DEBUG_BUS_PCIE_DEBUG_SEL_MASK)
263*5113495bSYour Name #define AMBA_DEBUG_BUS_SEL_GET(x) \
264*5113495bSYour Name 	(((x) & AMBA_DEBUG_BUS_SEL_MASK) >> AMBA_DEBUG_BUS_SEL_LSB)
265*5113495bSYour Name #define AMBA_DEBUG_BUS_SEL_SET(x) \
266*5113495bSYour Name 	(((x) << AMBA_DEBUG_BUS_SEL_LSB) & AMBA_DEBUG_BUS_SEL_MASK)
267*5113495bSYour Name #define CE_WRAPPER_DEBUG_SEL_GET(x) \
268*5113495bSYour Name 	(((x) & CE_WRAPPER_DEBUG_SEL_MASK) >> CE_WRAPPER_DEBUG_SEL_LSB)
269*5113495bSYour Name #define CE_WRAPPER_DEBUG_SEL_SET(x) \
270*5113495bSYour Name 	(((x) << CE_WRAPPER_DEBUG_SEL_LSB) & CE_WRAPPER_DEBUG_SEL_MASK)
271*5113495bSYour Name #define CE_DEBUG_SEL_GET(x) (((x) & CE_DEBUG_SEL_MASK) >> CE_DEBUG_SEL_LSB)
272*5113495bSYour Name #define CE_DEBUG_SEL_SET(x) (((x) << CE_DEBUG_SEL_LSB) & CE_DEBUG_SEL_MASK)
273*5113495bSYour Name #define HOST_IE_REG1_CE_BIT(_ce_id) (1 << (_ce_id + HOST_IE_REG1_CE_LSB))
274*5113495bSYour Name #define HOST_IE_REG2_CE_BIT(_ce_id) (1 << (_ce_id + HOST_IE_REG2_CE_LSB))
275*5113495bSYour Name #define HOST_IE_REG3_CE_BIT(_ce_id) (1 << (_ce_id + HOST_IE_REG3_CE_LSB))
276*5113495bSYour Name 
277*5113495bSYour Name uint32_t DEBUG_CE_SRC_RING_READ_IDX_GET(struct hif_softc *scn,
278*5113495bSYour Name 		uint32_t CE_ctrl_addr);
279*5113495bSYour Name uint32_t DEBUG_CE_DEST_RING_READ_IDX_GET(struct hif_softc *scn,
280*5113495bSYour Name 		uint32_t CE_ctrl_addr);
281*5113495bSYour Name 
282*5113495bSYour Name #define BITS0_TO_31(val) ((uint32_t)((uint64_t)(val)\
283*5113495bSYour Name 				     & (uint64_t)(0xFFFFFFFF)))
284*5113495bSYour Name #define BITS32_TO_35(val) ((uint32_t)(((uint64_t)(val)\
285*5113495bSYour Name 				     & (uint64_t)(0xF00000000))>>32))
286*5113495bSYour Name 
287*5113495bSYour Name #ifdef WLAN_40BIT_ADDRESSING_SUPPORT
288*5113495bSYour Name #define RRI_ON_DDR_PADDR_HIGH(val) (uint32_t)(((uint64_t)(val) >> 32) & 0xFF)
289*5113495bSYour Name #else
290*5113495bSYour Name #define RRI_ON_DDR_PADDR_HIGH(val) BITS32_TO_35(val)
291*5113495bSYour Name #endif
292*5113495bSYour Name #define RRI_ON_DDR_PADDR_LOW(val) BITS0_TO_31(val)
293*5113495bSYour Name 
294*5113495bSYour Name #ifdef WLAN_64BIT_DATA_SUPPORT
295*5113495bSYour Name #define VADDR_FOR_CE(scn, CE_ctrl_addr)\
296*5113495bSYour Name 	(((uint64_t *)((scn)->vaddr_rri_on_ddr)) + COPY_ENGINE_ID(CE_ctrl_addr))
297*5113495bSYour Name #define SRRI_FROM_DDR_ADDR(addr) ((*(addr)) & 0xFFFF)
298*5113495bSYour Name #define DRRI_FROM_DDR_ADDR(addr) (((*(addr)) >> 32) & 0xFFFF)
299*5113495bSYour Name #else
300*5113495bSYour Name #define VADDR_FOR_CE(scn, CE_ctrl_addr)\
301*5113495bSYour Name 	(((uint32_t *)((scn)->vaddr_rri_on_ddr)) + COPY_ENGINE_ID(CE_ctrl_addr))
302*5113495bSYour Name #define SRRI_FROM_DDR_ADDR(addr) ((*(addr)) & 0xFFFF)
303*5113495bSYour Name #define DRRI_FROM_DDR_ADDR(addr) (((*(addr))>>16) & 0xFFFF)
304*5113495bSYour Name #endif
305*5113495bSYour Name 
306*5113495bSYour Name #define CE_SRC_RING_READ_IDX_GET_FROM_REGISTER(scn, CE_ctrl_addr) \
307*5113495bSYour Name 	A_TARGET_READ(scn, (CE_ctrl_addr) + CURRENT_SRRI_ADDRESS)
308*5113495bSYour Name #define CE_DEST_RING_READ_IDX_GET_FROM_REGISTER(scn, CE_ctrl_addr) \
309*5113495bSYour Name 	A_TARGET_READ(scn, (CE_ctrl_addr) + CURRENT_DRRI_ADDRESS)
310*5113495bSYour Name 
311*5113495bSYour Name #ifdef ADRASTEA_RRI_ON_DDR
312*5113495bSYour Name #ifdef SHADOW_REG_DEBUG
313*5113495bSYour Name #define CE_SRC_RING_READ_IDX_GET_FROM_DDR(scn, CE_ctrl_addr)\
314*5113495bSYour Name 	DEBUG_CE_SRC_RING_READ_IDX_GET(scn, CE_ctrl_addr)
315*5113495bSYour Name #define CE_DEST_RING_READ_IDX_GET_FROM_DDR(scn, CE_ctrl_addr)\
316*5113495bSYour Name 	DEBUG_CE_DEST_RING_READ_IDX_GET(scn, CE_ctrl_addr)
317*5113495bSYour Name #else
318*5113495bSYour Name #define CE_SRC_RING_READ_IDX_GET_FROM_DDR(scn, CE_ctrl_addr)\
319*5113495bSYour Name 	SRRI_FROM_DDR_ADDR(VADDR_FOR_CE(scn, CE_ctrl_addr))
320*5113495bSYour Name #define CE_DEST_RING_READ_IDX_GET_FROM_DDR(scn, CE_ctrl_addr)\
321*5113495bSYour Name 	DRRI_FROM_DDR_ADDR(VADDR_FOR_CE(scn, CE_ctrl_addr))
322*5113495bSYour Name #endif
323*5113495bSYour Name 
324*5113495bSYour Name #ifndef QCA_WIFI_WCN6450
325*5113495bSYour Name unsigned int hif_get_src_ring_read_index(struct hif_softc *scn,
326*5113495bSYour Name 		uint32_t CE_ctrl_addr);
327*5113495bSYour Name unsigned int hif_get_dst_ring_read_index(struct hif_softc *scn,
328*5113495bSYour Name 		uint32_t CE_ctrl_addr);
329*5113495bSYour Name 
330*5113495bSYour Name #define CE_SRC_RING_READ_IDX_GET(scn, CE_ctrl_addr)\
331*5113495bSYour Name 	hif_get_src_ring_read_index(scn, CE_ctrl_addr)
332*5113495bSYour Name #define CE_DEST_RING_READ_IDX_GET(scn, CE_ctrl_addr)\
333*5113495bSYour Name 	hif_get_dst_ring_read_index(scn, CE_ctrl_addr)
334*5113495bSYour Name #else
335*5113495bSYour Name #define CE_SRC_RING_READ_IDX_GET(scn, CE_ctrl_addr)\
336*5113495bSYour Name 	CE_SRC_RING_READ_IDX_GET_FROM_DDR(scn, CE_ctrl_addr)
337*5113495bSYour Name #define CE_DEST_RING_READ_IDX_GET(scn, CE_ctrl_addr)\
338*5113495bSYour Name 	CE_DEST_RING_READ_IDX_GET_FROM_DDR(scn, CE_ctrl_addr)
339*5113495bSYour Name #endif
340*5113495bSYour Name #else
341*5113495bSYour Name #define CE_SRC_RING_READ_IDX_GET(scn, CE_ctrl_addr) \
342*5113495bSYour Name 	CE_SRC_RING_READ_IDX_GET_FROM_REGISTER(scn, CE_ctrl_addr)
343*5113495bSYour Name #define CE_DEST_RING_READ_IDX_GET(scn, CE_ctrl_addr)\
344*5113495bSYour Name 	CE_DEST_RING_READ_IDX_GET_FROM_REGISTER(scn, CE_ctrl_addr)
345*5113495bSYour Name 
346*5113495bSYour Name /*
347*5113495bSYour Name  * if RRI on DDR is not enabled, get idx from ddr defaults to
348*5113495bSYour Name  * using the register value & force wake must be used for
349*5113495bSYour Name  * non interrupt processing.
350*5113495bSYour Name  */
351*5113495bSYour Name #define CE_SRC_RING_READ_IDX_GET_FROM_DDR(scn, CE_ctrl_addr)\
352*5113495bSYour Name 	A_TARGET_READ(scn, (CE_ctrl_addr) + CURRENT_SRRI_ADDRESS)
353*5113495bSYour Name #endif
354*5113495bSYour Name 
355*5113495bSYour Name #ifdef WLAN_40BIT_ADDRESSING_SUPPORT
356*5113495bSYour Name #define CE_RING_BASE_ADDR_HIGH_MASK 0xFF
357*5113495bSYour Name #else
358*5113495bSYour Name #define CE_RING_BASE_ADDR_HIGH_MASK 0x1F
359*5113495bSYour Name #endif
360*5113495bSYour Name 
361*5113495bSYour Name #define CE_SRC_RING_BASE_ADDR_SET(scn, CE_ctrl_addr, addr) \
362*5113495bSYour Name 	A_TARGET_WRITE(scn, (CE_ctrl_addr) + SR_BA_ADDRESS, (addr))
363*5113495bSYour Name 
364*5113495bSYour Name #define CE_SRC_RING_BASE_ADDR_HIGH_SET(scn, CE_ctrl_addr, addr) \
365*5113495bSYour Name 	A_TARGET_WRITE(scn, (CE_ctrl_addr) + SR_BA_ADDRESS_HIGH, (addr))
366*5113495bSYour Name 
367*5113495bSYour Name #define CE_SRC_RING_BASE_ADDR_HIGH_GET(scn, CE_ctrl_addr) \
368*5113495bSYour Name 	A_TARGET_READ(scn, (CE_ctrl_addr) + SR_BA_ADDRESS_HIGH)
369*5113495bSYour Name 
370*5113495bSYour Name #define CE_SRC_RING_SZ_SET(scn, CE_ctrl_addr, n) \
371*5113495bSYour Name 	A_TARGET_WRITE(scn, (CE_ctrl_addr) + SR_SIZE_ADDRESS, (n))
372*5113495bSYour Name 
373*5113495bSYour Name #define CE_IDX_UPD_EN_DMAX_LEN_SET(scn, CE_ctrl_addr, n) \
374*5113495bSYour Name 	A_TARGET_WRITE(scn, (CE_ctrl_addr) + CE_CTRL1_ADDRESS, \
375*5113495bSYour Name 	   ((A_TARGET_READ(scn, (CE_ctrl_addr) + \
376*5113495bSYour Name 	   CE_CTRL1_ADDRESS) & ~CE_CTRL1_DMAX_LENGTH_MASK) | \
377*5113495bSYour Name 	   CE_CTRL1_DMAX_LENGTH_SET(n) | CE_CTRL1_IDX_UPD_EN))
378*5113495bSYour Name 
379*5113495bSYour Name #define CE_SRC_RING_DMAX_SET(scn, CE_ctrl_addr, n) \
380*5113495bSYour Name 	A_TARGET_WRITE(scn, (CE_ctrl_addr) + CE_CTRL1_ADDRESS, \
381*5113495bSYour Name 	   (A_TARGET_READ(scn, (CE_ctrl_addr) + \
382*5113495bSYour Name 	   CE_CTRL1_ADDRESS) & ~CE_CTRL1_DMAX_LENGTH_MASK) | \
383*5113495bSYour Name 	   CE_CTRL1_DMAX_LENGTH_SET(n))
384*5113495bSYour Name 
385*5113495bSYour Name #define CE_IDX_UPD_EN_SET(scn, CE_ctrl_addr)  \
386*5113495bSYour Name 	A_TARGET_WRITE(scn, (CE_ctrl_addr) + CE_CTRL1_ADDRESS, \
387*5113495bSYour Name 	(A_TARGET_READ(scn, (CE_ctrl_addr) + CE_CTRL1_ADDRESS) \
388*5113495bSYour Name 	| CE_CTRL1_IDX_UPD_EN))
389*5113495bSYour Name 
390*5113495bSYour Name #define CE_CMD_REGISTER_GET(scn, CE_ctrl_addr) \
391*5113495bSYour Name 	A_TARGET_READ(scn, (CE_ctrl_addr) + CE_CMD_REGISTER)
392*5113495bSYour Name 
393*5113495bSYour Name #define CE_CMD_REGISTER_SET(scn, CE_ctrl_addr, n) \
394*5113495bSYour Name 	A_TARGET_WRITE(scn, (CE_ctrl_addr) + CE_CMD_REGISTER, n)
395*5113495bSYour Name 
396*5113495bSYour Name #define CE_MSI_ADDR_LOW_SET(scn, CE_ctrl_addr, addr) \
397*5113495bSYour Name 	A_TARGET_WRITE(scn, (CE_ctrl_addr) + CE_MSI_ADDRESS, (addr))
398*5113495bSYour Name 
399*5113495bSYour Name #define CE_MSI_ADDR_HIGH_SET(scn, CE_ctrl_addr, addr) \
400*5113495bSYour Name 	A_TARGET_WRITE(scn, (CE_ctrl_addr) + CE_MSI_ADDRESS_HIGH, (addr))
401*5113495bSYour Name 
402*5113495bSYour Name #define CE_MSI_ADDR_HIGH_GET(scn, CE_ctrl_addr) \
403*5113495bSYour Name 	A_TARGET_READ(scn, (CE_ctrl_addr) + CE_MSI_ADDRESS_HIGH)
404*5113495bSYour Name 
405*5113495bSYour Name #define CE_MSI_DATA_SET(scn, CE_ctrl_addr, data) \
406*5113495bSYour Name 	A_TARGET_WRITE(scn, (CE_ctrl_addr) + CE_MSI_DATA, (data))
407*5113495bSYour Name 
408*5113495bSYour Name #define CE_MSI_EN_SET(scn, CE_ctrl_addr) \
409*5113495bSYour Name 	A_TARGET_WRITE(scn, (CE_ctrl_addr) + CE_CTRL1_ADDRESS, \
410*5113495bSYour Name 	(A_TARGET_READ(scn, (CE_ctrl_addr) + CE_CTRL1_ADDRESS) \
411*5113495bSYour Name 	| CE_MSI_ENABLE_BIT))
412*5113495bSYour Name 
413*5113495bSYour Name #define CE_SRC_BATCH_TIMER_THRESHOLD 0
414*5113495bSYour Name #define CE_SRC_BATCH_COUNTER_THRESHOLD 1
415*5113495bSYour Name #define CE_DST_BATCH_TIMER_THRESHOLD 512
416*5113495bSYour Name #define CE_DST_BATCH_COUNTER_THRESHOLD 0
417*5113495bSYour Name 
418*5113495bSYour Name #define CE_SRC_BATCH_TIMER_THRESH_MASK \
419*5113495bSYour Name 	(scn->target_ce_def->d_CE_SRC_BATCH_TIMER_THRESH_MASK)
420*5113495bSYour Name #define CE_SRC_BATCH_TIMER_THRESH_LSB \
421*5113495bSYour Name 	(scn->target_ce_def->d_CE_SRC_BATCH_TIMER_THRESH_LSB)
422*5113495bSYour Name #define CE_SRC_BATCH_COUNTER_THRESH_MASK \
423*5113495bSYour Name 	(scn->target_ce_def->d_CE_SRC_BATCH_COUNTER_THRESH_MASK)
424*5113495bSYour Name #define CE_SRC_BATCH_COUNTER_THRESH_LSB \
425*5113495bSYour Name 	(scn->target_ce_def->d_CE_SRC_BATCH_COUNTER_THRESH_LSB)
426*5113495bSYour Name #define CE_DST_BATCH_TIMER_THRESH_MASK \
427*5113495bSYour Name 	(scn->target_ce_def->d_CE_DST_BATCH_TIMER_THRESH_MASK)
428*5113495bSYour Name #define CE_DST_BATCH_TIMER_THRESH_LSB \
429*5113495bSYour Name 	(scn->target_ce_def->d_CE_DST_BATCH_TIMER_THRESH_LSB)
430*5113495bSYour Name #define CE_DST_BATCH_COUNTER_THRESH_MASK \
431*5113495bSYour Name 	(scn->target_ce_def->d_CE_DST_BATCH_COUNTER_THRESH_MASK)
432*5113495bSYour Name #define CE_DST_BATCH_COUNTER_THRESH_LSB \
433*5113495bSYour Name 	(scn->target_ce_def->d_CE_DST_BATCH_COUNTER_THRESH_LSB)
434*5113495bSYour Name 
435*5113495bSYour Name #define CE_CHANNEL_SRC_BATCH_TIMER_INT_SETUP_GET(scn, CE_ctrl_addr) \
436*5113495bSYour Name 	A_TARGET_READ(scn, (CE_ctrl_addr) + CE_SRC_BATCH_TIMER_INT_SETUP)
437*5113495bSYour Name #define CE_CHANNEL_DST_BATCH_TIMER_INT_SETUP_GET(scn, CE_ctrl_addr) \
438*5113495bSYour Name 	A_TARGET_READ(scn, (CE_ctrl_addr) + CE_DST_BATCH_TIMER_INT_SETUP)
439*5113495bSYour Name 
440*5113495bSYour Name #define CE_CHANNEL_SRC_BATCH_TIMER_INT_SETUP(scn, CE_ctrl_addr, data) \
441*5113495bSYour Name 	A_TARGET_WRITE(scn, (CE_ctrl_addr) + CE_SRC_BATCH_TIMER_INT_SETUP, data)
442*5113495bSYour Name #define CE_CHANNEL_DST_BATCH_TIMER_INT_SETUP(scn, CE_ctrl_addr, data) \
443*5113495bSYour Name 	A_TARGET_WRITE(scn, (CE_ctrl_addr) + CE_DST_BATCH_TIMER_INT_SETUP, data)
444*5113495bSYour Name 
445*5113495bSYour Name #define HOST_IE_SRC_TIMER_BATCH_MASK \
446*5113495bSYour Name 	(scn->target_ce_def->d_HOST_IE_SRC_TIMER_BATCH_MASK)
447*5113495bSYour Name #define HOST_IE_DST_TIMER_BATCH_MASK \
448*5113495bSYour Name 	(scn->target_ce_def->d_HOST_IE_DST_TIMER_BATCH_MASK)
449*5113495bSYour Name 
450*5113495bSYour Name #define CE_CHANNEL_SRC_TIMER_BATCH_INT_EN(scn, CE_ctrl_addr) \
451*5113495bSYour Name 	A_TARGET_WRITE(scn, (CE_ctrl_addr) + HOST_IE_ADDRESS, \
452*5113495bSYour Name 		       A_TARGET_READ(scn, \
453*5113495bSYour Name 		       (CE_ctrl_addr) + HOST_IE_ADDRESS) | \
454*5113495bSYour Name 		       HOST_IE_SRC_TIMER_BATCH_MASK)
455*5113495bSYour Name #define CE_CHANNEL_DST_TIMER_BATCH_INT_EN(scn, CE_ctrl_addr) \
456*5113495bSYour Name 	A_TARGET_WRITE(scn, (CE_ctrl_addr) + HOST_IE_ADDRESS, \
457*5113495bSYour Name 		       A_TARGET_READ(scn, \
458*5113495bSYour Name 		       (CE_ctrl_addr) + HOST_IE_ADDRESS) | \
459*5113495bSYour Name 		       HOST_IE_DST_TIMER_BATCH_MASK)
460*5113495bSYour Name 
461*5113495bSYour Name #define CE_CTRL_REGISTER1_SET(scn, CE_ctrl_addr, val) \
462*5113495bSYour Name 	A_TARGET_WRITE(scn, (CE_ctrl_addr) + CE_CTRL1_ADDRESS, val)
463*5113495bSYour Name 
464*5113495bSYour Name #define CE_CTRL_REGISTER1_GET(scn, CE_ctrl_addr) \
465*5113495bSYour Name 	A_TARGET_READ(scn, (CE_ctrl_addr) + CE_CTRL1_ADDRESS)
466*5113495bSYour Name 
467*5113495bSYour Name #define CE_SRC_RING_BYTE_SWAP_SET(scn, CE_ctrl_addr, n) \
468*5113495bSYour Name 	A_TARGET_WRITE(scn, (CE_ctrl_addr) + CE_CTRL1_ADDRESS, \
469*5113495bSYour Name 		       (A_TARGET_READ(scn, \
470*5113495bSYour Name 		       (CE_ctrl_addr) + CE_CTRL1_ADDRESS) \
471*5113495bSYour Name 		       & ~CE_CTRL1_SRC_RING_BYTE_SWAP_EN_MASK) | \
472*5113495bSYour Name 		       CE_CTRL1_SRC_RING_BYTE_SWAP_EN_SET(n))
473*5113495bSYour Name 
474*5113495bSYour Name #define CE_DEST_RING_BYTE_SWAP_SET(scn, CE_ctrl_addr, n) \
475*5113495bSYour Name 	A_TARGET_WRITE(scn, (CE_ctrl_addr)+CE_CTRL1_ADDRESS, \
476*5113495bSYour Name 		       (A_TARGET_READ(scn, \
477*5113495bSYour Name 		       (CE_ctrl_addr) + CE_CTRL1_ADDRESS) \
478*5113495bSYour Name 		       & ~CE_CTRL1_DST_RING_BYTE_SWAP_EN_MASK) | \
479*5113495bSYour Name 		       CE_CTRL1_DST_RING_BYTE_SWAP_EN_SET(n))
480*5113495bSYour Name 
481*5113495bSYour Name 
482*5113495bSYour Name #define CE_DEST_RING_BASE_ADDR_SET(scn, CE_ctrl_addr, addr) \
483*5113495bSYour Name 	A_TARGET_WRITE(scn, (CE_ctrl_addr) + DR_BA_ADDRESS, (addr))
484*5113495bSYour Name 
485*5113495bSYour Name #define CE_DEST_RING_BASE_ADDR_HIGH_SET(scn, CE_ctrl_addr, addr) \
486*5113495bSYour Name 	A_TARGET_WRITE(scn, (CE_ctrl_addr) + DR_BA_ADDRESS_HIGH, (addr))
487*5113495bSYour Name 
488*5113495bSYour Name #define CE_DEST_RING_BASE_ADDR_HIGH_GET(scn, CE_ctrl_addr) \
489*5113495bSYour Name 	A_TARGET_READ(scn, (CE_ctrl_addr) + DR_BA_ADDRESS_HIGH)
490*5113495bSYour Name 
491*5113495bSYour Name #define CE_DEST_RING_SZ_SET(scn, CE_ctrl_addr, n) \
492*5113495bSYour Name 	A_TARGET_WRITE(scn, (CE_ctrl_addr) + DR_SIZE_ADDRESS, (n))
493*5113495bSYour Name 
494*5113495bSYour Name #define CE_SRC_RING_HIGHMARK_SET(scn, CE_ctrl_addr, n) \
495*5113495bSYour Name 	A_TARGET_WRITE(scn, (CE_ctrl_addr) + SRC_WATERMARK_ADDRESS, \
496*5113495bSYour Name 		       (A_TARGET_READ(scn, \
497*5113495bSYour Name 		       (CE_ctrl_addr) + SRC_WATERMARK_ADDRESS) \
498*5113495bSYour Name 		       & ~SRC_WATERMARK_HIGH_MASK) | \
499*5113495bSYour Name 		       SRC_WATERMARK_HIGH_SET(n))
500*5113495bSYour Name 
501*5113495bSYour Name #define CE_SRC_RING_LOWMARK_SET(scn, CE_ctrl_addr, n) \
502*5113495bSYour Name 	A_TARGET_WRITE(scn, (CE_ctrl_addr) + SRC_WATERMARK_ADDRESS, \
503*5113495bSYour Name 		       (A_TARGET_READ(scn, \
504*5113495bSYour Name 		       (CE_ctrl_addr) + SRC_WATERMARK_ADDRESS) \
505*5113495bSYour Name 		       & ~SRC_WATERMARK_LOW_MASK) | \
506*5113495bSYour Name 		       SRC_WATERMARK_LOW_SET(n))
507*5113495bSYour Name 
508*5113495bSYour Name #define CE_DEST_RING_HIGHMARK_SET(scn, CE_ctrl_addr, n) \
509*5113495bSYour Name 	A_TARGET_WRITE(scn, (CE_ctrl_addr) + DST_WATERMARK_ADDRESS, \
510*5113495bSYour Name 		       (A_TARGET_READ(scn, \
511*5113495bSYour Name 		       (CE_ctrl_addr) + DST_WATERMARK_ADDRESS) \
512*5113495bSYour Name 		       & ~DST_WATERMARK_HIGH_MASK) | \
513*5113495bSYour Name 		       DST_WATERMARK_HIGH_SET(n))
514*5113495bSYour Name 
515*5113495bSYour Name #define CE_DEST_RING_LOWMARK_SET(scn, CE_ctrl_addr, n) \
516*5113495bSYour Name 	A_TARGET_WRITE(scn, (CE_ctrl_addr) + DST_WATERMARK_ADDRESS, \
517*5113495bSYour Name 		       (A_TARGET_READ(scn, \
518*5113495bSYour Name 		       (CE_ctrl_addr) + DST_WATERMARK_ADDRESS) \
519*5113495bSYour Name 		       & ~DST_WATERMARK_LOW_MASK) | \
520*5113495bSYour Name 		       DST_WATERMARK_LOW_SET(n))
521*5113495bSYour Name 
522*5113495bSYour Name #define CE_COPY_COMPLETE_INTR_ENABLE(scn, CE_ctrl_addr) \
523*5113495bSYour Name 	A_TARGET_WRITE(scn, (CE_ctrl_addr) + HOST_IE_ADDRESS, \
524*5113495bSYour Name 		       A_TARGET_READ(scn, \
525*5113495bSYour Name 		       (CE_ctrl_addr) + HOST_IE_ADDRESS) | \
526*5113495bSYour Name 		       HOST_IE_COPY_COMPLETE_MASK)
527*5113495bSYour Name 
528*5113495bSYour Name #define CE_COPY_COMPLETE_INTR_DISABLE(scn, CE_ctrl_addr) \
529*5113495bSYour Name 	A_TARGET_WRITE(scn, (CE_ctrl_addr) + HOST_IE_ADDRESS, \
530*5113495bSYour Name 		       A_TARGET_READ(scn, \
531*5113495bSYour Name 		       (CE_ctrl_addr) + HOST_IE_ADDRESS) \
532*5113495bSYour Name 		       & ~HOST_IE_COPY_COMPLETE_MASK)
533*5113495bSYour Name 
534*5113495bSYour Name #define CE_BASE_ADDRESS(CE_id) \
535*5113495bSYour Name 	CE0_BASE_ADDRESS + ((CE1_BASE_ADDRESS - \
536*5113495bSYour Name 	CE0_BASE_ADDRESS)*(CE_id))
537*5113495bSYour Name 
538*5113495bSYour Name #define CE_WATERMARK_INTR_ENABLE(scn, CE_ctrl_addr) \
539*5113495bSYour Name 	A_TARGET_WRITE(scn, (CE_ctrl_addr) + HOST_IE_ADDRESS, \
540*5113495bSYour Name 		       A_TARGET_READ(scn, \
541*5113495bSYour Name 		       (CE_ctrl_addr) + HOST_IE_ADDRESS) | \
542*5113495bSYour Name 		       CE_WATERMARK_MASK)
543*5113495bSYour Name 
544*5113495bSYour Name #define CE_WATERMARK_INTR_DISABLE(scn, CE_ctrl_addr)	\
545*5113495bSYour Name 	A_TARGET_WRITE(scn, (CE_ctrl_addr) + HOST_IE_ADDRESS, \
546*5113495bSYour Name 		       A_TARGET_READ(scn, \
547*5113495bSYour Name 		       (CE_ctrl_addr) + HOST_IE_ADDRESS) \
548*5113495bSYour Name 		       & ~CE_WATERMARK_MASK)
549*5113495bSYour Name 
550*5113495bSYour Name #define CE_ERROR_INTR_ENABLE(scn, CE_ctrl_addr) \
551*5113495bSYour Name 	A_TARGET_WRITE(scn, (CE_ctrl_addr) + MISC_IE_ADDRESS, \
552*5113495bSYour Name 		       A_TARGET_READ(scn, \
553*5113495bSYour Name 		       (CE_ctrl_addr) + MISC_IE_ADDRESS) | CE_ERROR_MASK)
554*5113495bSYour Name 
555*5113495bSYour Name #define CE_MISC_INT_STATUS_GET(scn, CE_ctrl_addr) \
556*5113495bSYour Name 	A_TARGET_READ(scn, (CE_ctrl_addr) + MISC_IS_ADDRESS)
557*5113495bSYour Name 
558*5113495bSYour Name #define CE_ENGINE_INT_STATUS_GET(scn, CE_ctrl_addr) \
559*5113495bSYour Name 	A_TARGET_READ(scn, (CE_ctrl_addr) + HOST_IS_ADDRESS)
560*5113495bSYour Name 
561*5113495bSYour Name #define CE_ENGINE_INT_STATUS_CLEAR(scn, CE_ctrl_addr, mask) \
562*5113495bSYour Name 	A_TARGET_WRITE(scn, (CE_ctrl_addr) + HOST_IS_ADDRESS, (mask))
563*5113495bSYour Name 
564*5113495bSYour Name #define CE_WATERMARK_MASK (HOST_IS_SRC_RING_LOW_WATERMARK_MASK  | \
565*5113495bSYour Name 			   HOST_IS_SRC_RING_HIGH_WATERMARK_MASK | \
566*5113495bSYour Name 			   HOST_IS_DST_RING_LOW_WATERMARK_MASK  | \
567*5113495bSYour Name 			   HOST_IS_DST_RING_HIGH_WATERMARK_MASK)
568*5113495bSYour Name 
569*5113495bSYour Name #define CE_ERROR_MASK     (MISC_IS_AXI_ERR_MASK           | \
570*5113495bSYour Name 			   MISC_IS_DST_ADDR_ERR_MASK      | \
571*5113495bSYour Name 			   MISC_IS_SRC_LEN_ERR_MASK       | \
572*5113495bSYour Name 			   MISC_IS_DST_MAX_LEN_VIO_MASK   | \
573*5113495bSYour Name 			   MISC_IS_DST_RING_OVERFLOW_MASK | \
574*5113495bSYour Name 			   MISC_IS_SRC_RING_OVERFLOW_MASK)
575*5113495bSYour Name 
576*5113495bSYour Name #define CE_SRC_RING_TO_DESC(baddr, idx) \
577*5113495bSYour Name 	(&(((struct CE_src_desc *)baddr)[idx]))
578*5113495bSYour Name #define CE_DEST_RING_TO_DESC(baddr, idx) \
579*5113495bSYour Name 	(&(((struct CE_dest_desc *)baddr)[idx]))
580*5113495bSYour Name 
581*5113495bSYour Name /* Ring arithmetic (modulus number of entries in ring, which is a pwr of 2). */
582*5113495bSYour Name #define CE_RING_DELTA(nentries_mask, fromidx, toidx) \
583*5113495bSYour Name 	(((int)(toidx)-(int)(fromidx)) & (nentries_mask))
584*5113495bSYour Name 
585*5113495bSYour Name #define CE_RING_IDX_INCR(nentries_mask, idx) \
586*5113495bSYour Name 	(((idx) + 1) & (nentries_mask))
587*5113495bSYour Name 
588*5113495bSYour Name #define CE_RING_IDX_ADD(nentries_mask, idx, num) \
589*5113495bSYour Name 	(((idx) + (num)) & (nentries_mask))
590*5113495bSYour Name 
591*5113495bSYour Name #define CE_INTERRUPT_SUMMARY(scn) \
592*5113495bSYour Name 	CE_WRAPPER_INTERRUPT_SUMMARY_HOST_MSI_GET( \
593*5113495bSYour Name 		A_TARGET_READ(scn, CE_WRAPPER_BASE_ADDRESS + \
594*5113495bSYour Name 		CE_WRAPPER_INTERRUPT_SUMMARY_ADDRESS))
595*5113495bSYour Name 
596*5113495bSYour Name #define READ_CE_DDR_ADDRESS_FOR_RRI_LOW(scn) \
597*5113495bSYour Name 	(A_TARGET_READ(scn, \
598*5113495bSYour Name 		       CE_WRAPPER_BASE_ADDRESS + CE_DDR_ADDRESS_FOR_RRI_LOW))
599*5113495bSYour Name 
600*5113495bSYour Name #define READ_CE_DDR_ADDRESS_FOR_RRI_HIGH(scn) \
601*5113495bSYour Name 	(A_TARGET_READ(scn, \
602*5113495bSYour Name 		       CE_WRAPPER_BASE_ADDRESS + CE_DDR_ADDRESS_FOR_RRI_HIGH))
603*5113495bSYour Name 
604*5113495bSYour Name #define WRITE_CE_DDR_ADDRESS_FOR_RRI_LOW(scn, val) \
605*5113495bSYour Name 	(A_TARGET_WRITE(scn, \
606*5113495bSYour Name 			CE_WRAPPER_BASE_ADDRESS + CE_DDR_ADDRESS_FOR_RRI_LOW, \
607*5113495bSYour Name 			val))
608*5113495bSYour Name 
609*5113495bSYour Name #define WRITE_CE_DDR_ADDRESS_FOR_RRI_HIGH(scn, val) \
610*5113495bSYour Name 	(A_TARGET_WRITE(scn, \
611*5113495bSYour Name 			CE_WRAPPER_BASE_ADDRESS + CE_DDR_ADDRESS_FOR_RRI_HIGH, \
612*5113495bSYour Name 			val))
613*5113495bSYour Name 
614*5113495bSYour Name /*Macro to increment CE packet errors*/
615*5113495bSYour Name #define OL_ATH_CE_PKT_ERROR_COUNT_INCR(_scn, _ce_ecode) \
616*5113495bSYour Name 	do { if (_ce_ecode == CE_RING_DELTA_FAIL) \
617*5113495bSYour Name 			(_scn->pkt_stats.ce_ring_delta_fail_count) \
618*5113495bSYour Name 			+= 1; } while (0)
619*5113495bSYour Name 
620*5113495bSYour Name /* Given a Copy Engine's ID, determine the interrupt number for that
621*5113495bSYour Name  * copy engine's interrupts.
622*5113495bSYour Name  */
623*5113495bSYour Name #define CE_ID_TO_INUM(id) (A_INUM_CE0_COPY_COMP_BASE + (id))
624*5113495bSYour Name #define CE_INUM_TO_ID(inum) ((inum) - A_INUM_CE0_COPY_COMP_BASE)
625*5113495bSYour Name #define CE0_BASE_ADDRESS         (scn->target_ce_def->d_CE0_BASE_ADDRESS)
626*5113495bSYour Name #define CE1_BASE_ADDRESS         (scn->target_ce_def->d_CE1_BASE_ADDRESS)
627*5113495bSYour Name 
628*5113495bSYour Name 
629*5113495bSYour Name #ifdef ADRASTEA_SHADOW_REGISTERS
630*5113495bSYour Name #define NUM_SHADOW_REGISTERS 24
631*5113495bSYour Name u32 shadow_sr_wr_ind_addr(struct hif_softc *scn, u32 ctrl_addr);
632*5113495bSYour Name u32 shadow_dst_wr_ind_addr(struct hif_softc *scn, u32 ctrl_addr);
633*5113495bSYour Name 
634*5113495bSYour Name #define CE_SRC_WR_IDX_OFFSET_GET(scn, CE_ctrl_addr) \
635*5113495bSYour Name 	shadow_sr_wr_ind_addr(scn, CE_ctrl_addr)
636*5113495bSYour Name #define CE_DST_WR_IDX_OFFSET_GET(scn, CE_ctrl_addr) \
637*5113495bSYour Name 	shadow_dst_wr_ind_addr(scn, CE_ctrl_addr)
638*5113495bSYour Name #else
639*5113495bSYour Name #define CE_SRC_WR_IDX_OFFSET_GET(scn, CE_ctrl_addr) \
640*5113495bSYour Name 	CE_ctrl_addr + SR_WR_INDEX_ADDRESS
641*5113495bSYour Name #define CE_DST_WR_IDX_OFFSET_GET(scn, CE_ctrl_addr) \
642*5113495bSYour Name 	CE_ctrl_addr + DST_WR_INDEX_ADDRESS
643*5113495bSYour Name #endif
644*5113495bSYour Name 
645*5113495bSYour Name #if defined(FEATURE_HIF_DELAYED_REG_WRITE)
646*5113495bSYour Name #define CE_SRC_RING_WRITE_IDX_SET(scn, CE_ctrl_addr, n) \
647*5113495bSYour Name 	A_TARGET_DELAYED_REG_WRITE(scn, CE_ctrl_addr, n)
648*5113495bSYour Name #define CE_DEST_RING_WRITE_IDX_SET(scn, CE_ctrl_addr, n) \
649*5113495bSYour Name 	A_TARGET_DELAYED_REG_WRITE(scn, CE_ctrl_addr, n)
650*5113495bSYour Name #elif defined(ADRASTEA_SHADOW_REGISTERS)
651*5113495bSYour Name #define CE_SRC_RING_WRITE_IDX_SET(scn, CE_ctrl_addr, n) \
652*5113495bSYour Name 	A_TARGET_WRITE(scn, shadow_sr_wr_ind_addr(scn, CE_ctrl_addr), n)
653*5113495bSYour Name #define CE_DEST_RING_WRITE_IDX_SET(scn, CE_ctrl_addr, n) \
654*5113495bSYour Name 	A_TARGET_WRITE(scn, shadow_dst_wr_ind_addr(scn, CE_ctrl_addr), n)
655*5113495bSYour Name #else
656*5113495bSYour Name #define CE_SRC_RING_WRITE_IDX_SET(scn, CE_ctrl_addr, n) \
657*5113495bSYour Name 	A_TARGET_WRITE(scn, (CE_ctrl_addr) + SR_WR_INDEX_ADDRESS, (n))
658*5113495bSYour Name #define CE_DEST_RING_WRITE_IDX_SET(scn, CE_ctrl_addr, n) \
659*5113495bSYour Name 	A_TARGET_WRITE(scn, (CE_ctrl_addr) + DST_WR_INDEX_ADDRESS, (n))
660*5113495bSYour Name #endif
661*5113495bSYour Name 
662*5113495bSYour Name /* The write index read is only needed during initialization because
663*5113495bSYour Name  * we keep track of the index that was last written.  Thus the register
664*5113495bSYour Name  * is the only hardware supported location to read the initial value from.
665*5113495bSYour Name  */
666*5113495bSYour Name #define CE_SRC_RING_WRITE_IDX_GET_FROM_REGISTER(scn, CE_ctrl_addr) \
667*5113495bSYour Name 	A_TARGET_READ(scn, (CE_ctrl_addr) + SR_WR_INDEX_ADDRESS)
668*5113495bSYour Name #define CE_DEST_RING_WRITE_IDX_GET_FROM_REGISTER(scn, CE_ctrl_addr) \
669*5113495bSYour Name 	A_TARGET_READ(scn, (CE_ctrl_addr) + DST_WR_INDEX_ADDRESS)
670*5113495bSYour Name 
671*5113495bSYour Name #endif /* __CE_REG_H__ */
672