xref: /openbmc/linux/drivers/usb/dwc2/hw.h (revision 239480ab)
1 /*
2  * hw.h - DesignWare HS OTG Controller hardware definitions
3  *
4  * Copyright 2004-2013 Synopsys, Inc.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions, and the following disclaimer,
11  *    without modification.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. The names of the above-listed copyright holders may not be used
16  *    to endorse or promote products derived from this software without
17  *    specific prior written permission.
18  *
19  * ALTERNATIVELY, this software may be distributed under the terms of the
20  * GNU General Public License ("GPL") as published by the Free Software
21  * Foundation; either version 2 of the License, or (at your option) any
22  * later version.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
25  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
26  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
28  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
30  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
31  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35  */
36 
37 #ifndef __DWC2_HW_H__
38 #define __DWC2_HW_H__
39 
40 #define HSOTG_REG(x)	(x)
41 
42 #define GOTGCTL				HSOTG_REG(0x000)
43 #define GOTGCTL_CHIRPEN			BIT(27)
44 #define GOTGCTL_MULT_VALID_BC_MASK	(0x1f << 22)
45 #define GOTGCTL_MULT_VALID_BC_SHIFT	22
46 #define GOTGCTL_OTGVER			BIT(20)
47 #define GOTGCTL_BSESVLD			BIT(19)
48 #define GOTGCTL_ASESVLD			BIT(18)
49 #define GOTGCTL_DBNC_SHORT		BIT(17)
50 #define GOTGCTL_CONID_B			BIT(16)
51 #define GOTGCTL_DBNCE_FLTR_BYPASS	BIT(15)
52 #define GOTGCTL_DEVHNPEN		BIT(11)
53 #define GOTGCTL_HSTSETHNPEN		BIT(10)
54 #define GOTGCTL_HNPREQ			BIT(9)
55 #define GOTGCTL_HSTNEGSCS		BIT(8)
56 #define GOTGCTL_SESREQ			BIT(1)
57 #define GOTGCTL_SESREQSCS		BIT(0)
58 
59 #define GOTGINT				HSOTG_REG(0x004)
60 #define GOTGINT_DBNCE_DONE		BIT(19)
61 #define GOTGINT_A_DEV_TOUT_CHG		BIT(18)
62 #define GOTGINT_HST_NEG_DET		BIT(17)
63 #define GOTGINT_HST_NEG_SUC_STS_CHNG	BIT(9)
64 #define GOTGINT_SES_REQ_SUC_STS_CHNG	BIT(8)
65 #define GOTGINT_SES_END_DET		BIT(2)
66 
67 #define GAHBCFG				HSOTG_REG(0x008)
68 #define GAHBCFG_AHB_SINGLE		BIT(23)
69 #define GAHBCFG_NOTI_ALL_DMA_WRIT	BIT(22)
70 #define GAHBCFG_REM_MEM_SUPP		BIT(21)
71 #define GAHBCFG_P_TXF_EMP_LVL		BIT(8)
72 #define GAHBCFG_NP_TXF_EMP_LVL		BIT(7)
73 #define GAHBCFG_DMA_EN			BIT(5)
74 #define GAHBCFG_HBSTLEN_MASK		(0xf << 1)
75 #define GAHBCFG_HBSTLEN_SHIFT		1
76 #define GAHBCFG_HBSTLEN_SINGLE		0
77 #define GAHBCFG_HBSTLEN_INCR		1
78 #define GAHBCFG_HBSTLEN_INCR4		3
79 #define GAHBCFG_HBSTLEN_INCR8		5
80 #define GAHBCFG_HBSTLEN_INCR16		7
81 #define GAHBCFG_GLBL_INTR_EN		BIT(0)
82 #define GAHBCFG_CTRL_MASK		(GAHBCFG_P_TXF_EMP_LVL | \
83 					 GAHBCFG_NP_TXF_EMP_LVL | \
84 					 GAHBCFG_DMA_EN | \
85 					 GAHBCFG_GLBL_INTR_EN)
86 
87 #define GUSBCFG				HSOTG_REG(0x00C)
88 #define GUSBCFG_FORCEDEVMODE		BIT(30)
89 #define GUSBCFG_FORCEHOSTMODE		BIT(29)
90 #define GUSBCFG_TXENDDELAY		BIT(28)
91 #define GUSBCFG_ICTRAFFICPULLREMOVE	BIT(27)
92 #define GUSBCFG_ICUSBCAP		BIT(26)
93 #define GUSBCFG_ULPI_INT_PROT_DIS	BIT(25)
94 #define GUSBCFG_INDICATORPASSTHROUGH	BIT(24)
95 #define GUSBCFG_INDICATORCOMPLEMENT	BIT(23)
96 #define GUSBCFG_TERMSELDLPULSE		BIT(22)
97 #define GUSBCFG_ULPI_INT_VBUS_IND	BIT(21)
98 #define GUSBCFG_ULPI_EXT_VBUS_DRV	BIT(20)
99 #define GUSBCFG_ULPI_CLK_SUSP_M		BIT(19)
100 #define GUSBCFG_ULPI_AUTO_RES		BIT(18)
101 #define GUSBCFG_ULPI_FS_LS		BIT(17)
102 #define GUSBCFG_OTG_UTMI_FS_SEL		BIT(16)
103 #define GUSBCFG_PHY_LP_CLK_SEL		BIT(15)
104 #define GUSBCFG_USBTRDTIM_MASK		(0xf << 10)
105 #define GUSBCFG_USBTRDTIM_SHIFT		10
106 #define GUSBCFG_HNPCAP			BIT(9)
107 #define GUSBCFG_SRPCAP			BIT(8)
108 #define GUSBCFG_DDRSEL			BIT(7)
109 #define GUSBCFG_PHYSEL			BIT(6)
110 #define GUSBCFG_FSINTF			BIT(5)
111 #define GUSBCFG_ULPI_UTMI_SEL		BIT(4)
112 #define GUSBCFG_PHYIF16			BIT(3)
113 #define GUSBCFG_PHYIF8			(0 << 3)
114 #define GUSBCFG_TOUTCAL_MASK		(0x7 << 0)
115 #define GUSBCFG_TOUTCAL_SHIFT		0
116 #define GUSBCFG_TOUTCAL_LIMIT		0x7
117 #define GUSBCFG_TOUTCAL(_x)		((_x) << 0)
118 
119 #define GRSTCTL				HSOTG_REG(0x010)
120 #define GRSTCTL_AHBIDLE			BIT(31)
121 #define GRSTCTL_DMAREQ			BIT(30)
122 #define GRSTCTL_TXFNUM_MASK		(0x1f << 6)
123 #define GRSTCTL_TXFNUM_SHIFT		6
124 #define GRSTCTL_TXFNUM_LIMIT		0x1f
125 #define GRSTCTL_TXFNUM(_x)		((_x) << 6)
126 #define GRSTCTL_TXFFLSH			BIT(5)
127 #define GRSTCTL_RXFFLSH			BIT(4)
128 #define GRSTCTL_IN_TKNQ_FLSH		BIT(3)
129 #define GRSTCTL_FRMCNTRRST		BIT(2)
130 #define GRSTCTL_HSFTRST			BIT(1)
131 #define GRSTCTL_CSFTRST			BIT(0)
132 
133 #define GINTSTS				HSOTG_REG(0x014)
134 #define GINTMSK				HSOTG_REG(0x018)
135 #define GINTSTS_WKUPINT			BIT(31)
136 #define GINTSTS_SESSREQINT		BIT(30)
137 #define GINTSTS_DISCONNINT		BIT(29)
138 #define GINTSTS_CONIDSTSCHNG		BIT(28)
139 #define GINTSTS_LPMTRANRCVD		BIT(27)
140 #define GINTSTS_PTXFEMP			BIT(26)
141 #define GINTSTS_HCHINT			BIT(25)
142 #define GINTSTS_PRTINT			BIT(24)
143 #define GINTSTS_RESETDET		BIT(23)
144 #define GINTSTS_FET_SUSP		BIT(22)
145 #define GINTSTS_INCOMPL_IP		BIT(21)
146 #define GINTSTS_INCOMPL_SOOUT		BIT(21)
147 #define GINTSTS_INCOMPL_SOIN		BIT(20)
148 #define GINTSTS_OEPINT			BIT(19)
149 #define GINTSTS_IEPINT			BIT(18)
150 #define GINTSTS_EPMIS			BIT(17)
151 #define GINTSTS_RESTOREDONE		BIT(16)
152 #define GINTSTS_EOPF			BIT(15)
153 #define GINTSTS_ISOUTDROP		BIT(14)
154 #define GINTSTS_ENUMDONE		BIT(13)
155 #define GINTSTS_USBRST			BIT(12)
156 #define GINTSTS_USBSUSP			BIT(11)
157 #define GINTSTS_ERLYSUSP		BIT(10)
158 #define GINTSTS_I2CINT			BIT(9)
159 #define GINTSTS_ULPI_CK_INT		BIT(8)
160 #define GINTSTS_GOUTNAKEFF		BIT(7)
161 #define GINTSTS_GINNAKEFF		BIT(6)
162 #define GINTSTS_NPTXFEMP		BIT(5)
163 #define GINTSTS_RXFLVL			BIT(4)
164 #define GINTSTS_SOF			BIT(3)
165 #define GINTSTS_OTGINT			BIT(2)
166 #define GINTSTS_MODEMIS			BIT(1)
167 #define GINTSTS_CURMODE_HOST		BIT(0)
168 
169 #define GRXSTSR				HSOTG_REG(0x01C)
170 #define GRXSTSP				HSOTG_REG(0x020)
171 #define GRXSTS_FN_MASK			(0x7f << 25)
172 #define GRXSTS_FN_SHIFT			25
173 #define GRXSTS_PKTSTS_MASK		(0xf << 17)
174 #define GRXSTS_PKTSTS_SHIFT		17
175 #define GRXSTS_PKTSTS_GLOBALOUTNAK	1
176 #define GRXSTS_PKTSTS_OUTRX		2
177 #define GRXSTS_PKTSTS_HCHIN		2
178 #define GRXSTS_PKTSTS_OUTDONE		3
179 #define GRXSTS_PKTSTS_HCHIN_XFER_COMP	3
180 #define GRXSTS_PKTSTS_SETUPDONE		4
181 #define GRXSTS_PKTSTS_DATATOGGLEERR	5
182 #define GRXSTS_PKTSTS_SETUPRX		6
183 #define GRXSTS_PKTSTS_HCHHALTED		7
184 #define GRXSTS_HCHNUM_MASK		(0xf << 0)
185 #define GRXSTS_HCHNUM_SHIFT		0
186 #define GRXSTS_DPID_MASK		(0x3 << 15)
187 #define GRXSTS_DPID_SHIFT		15
188 #define GRXSTS_BYTECNT_MASK		(0x7ff << 4)
189 #define GRXSTS_BYTECNT_SHIFT		4
190 #define GRXSTS_EPNUM_MASK		(0xf << 0)
191 #define GRXSTS_EPNUM_SHIFT		0
192 
193 #define GRXFSIZ				HSOTG_REG(0x024)
194 #define GRXFSIZ_DEPTH_MASK		(0xffff << 0)
195 #define GRXFSIZ_DEPTH_SHIFT		0
196 
197 #define GNPTXFSIZ			HSOTG_REG(0x028)
198 /* Use FIFOSIZE_* constants to access this register */
199 
200 #define GNPTXSTS			HSOTG_REG(0x02C)
201 #define GNPTXSTS_NP_TXQ_TOP_MASK		(0x7f << 24)
202 #define GNPTXSTS_NP_TXQ_TOP_SHIFT		24
203 #define GNPTXSTS_NP_TXQ_SPC_AVAIL_MASK		(0xff << 16)
204 #define GNPTXSTS_NP_TXQ_SPC_AVAIL_SHIFT		16
205 #define GNPTXSTS_NP_TXQ_SPC_AVAIL_GET(_v)	(((_v) >> 16) & 0xff)
206 #define GNPTXSTS_NP_TXF_SPC_AVAIL_MASK		(0xffff << 0)
207 #define GNPTXSTS_NP_TXF_SPC_AVAIL_SHIFT		0
208 #define GNPTXSTS_NP_TXF_SPC_AVAIL_GET(_v)	(((_v) >> 0) & 0xffff)
209 
210 #define GI2CCTL				HSOTG_REG(0x0030)
211 #define GI2CCTL_BSYDNE			BIT(31)
212 #define GI2CCTL_RW			BIT(30)
213 #define GI2CCTL_I2CDATSE0		BIT(28)
214 #define GI2CCTL_I2CDEVADDR_MASK		(0x3 << 26)
215 #define GI2CCTL_I2CDEVADDR_SHIFT	26
216 #define GI2CCTL_I2CSUSPCTL		BIT(25)
217 #define GI2CCTL_ACK			BIT(24)
218 #define GI2CCTL_I2CEN			BIT(23)
219 #define GI2CCTL_ADDR_MASK		(0x7f << 16)
220 #define GI2CCTL_ADDR_SHIFT		16
221 #define GI2CCTL_REGADDR_MASK		(0xff << 8)
222 #define GI2CCTL_REGADDR_SHIFT		8
223 #define GI2CCTL_RWDATA_MASK		(0xff << 0)
224 #define GI2CCTL_RWDATA_SHIFT		0
225 
226 #define GPVNDCTL			HSOTG_REG(0x0034)
227 #define GGPIO				HSOTG_REG(0x0038)
228 #define GGPIO_STM32_OTG_GCCFG_PWRDWN	BIT(16)
229 
230 #define GUID				HSOTG_REG(0x003c)
231 #define GSNPSID				HSOTG_REG(0x0040)
232 #define GHWCFG1				HSOTG_REG(0x0044)
233 
234 #define GHWCFG2				HSOTG_REG(0x0048)
235 #define GHWCFG2_OTG_ENABLE_IC_USB		BIT(31)
236 #define GHWCFG2_DEV_TOKEN_Q_DEPTH_MASK		(0x1f << 26)
237 #define GHWCFG2_DEV_TOKEN_Q_DEPTH_SHIFT		26
238 #define GHWCFG2_HOST_PERIO_TX_Q_DEPTH_MASK	(0x3 << 24)
239 #define GHWCFG2_HOST_PERIO_TX_Q_DEPTH_SHIFT	24
240 #define GHWCFG2_NONPERIO_TX_Q_DEPTH_MASK	(0x3 << 22)
241 #define GHWCFG2_NONPERIO_TX_Q_DEPTH_SHIFT	22
242 #define GHWCFG2_MULTI_PROC_INT			BIT(20)
243 #define GHWCFG2_DYNAMIC_FIFO			BIT(19)
244 #define GHWCFG2_PERIO_EP_SUPPORTED		BIT(18)
245 #define GHWCFG2_NUM_HOST_CHAN_MASK		(0xf << 14)
246 #define GHWCFG2_NUM_HOST_CHAN_SHIFT		14
247 #define GHWCFG2_NUM_DEV_EP_MASK			(0xf << 10)
248 #define GHWCFG2_NUM_DEV_EP_SHIFT		10
249 #define GHWCFG2_FS_PHY_TYPE_MASK		(0x3 << 8)
250 #define GHWCFG2_FS_PHY_TYPE_SHIFT		8
251 #define GHWCFG2_FS_PHY_TYPE_NOT_SUPPORTED	0
252 #define GHWCFG2_FS_PHY_TYPE_DEDICATED		1
253 #define GHWCFG2_FS_PHY_TYPE_SHARED_UTMI		2
254 #define GHWCFG2_FS_PHY_TYPE_SHARED_ULPI		3
255 #define GHWCFG2_HS_PHY_TYPE_MASK		(0x3 << 6)
256 #define GHWCFG2_HS_PHY_TYPE_SHIFT		6
257 #define GHWCFG2_HS_PHY_TYPE_NOT_SUPPORTED	0
258 #define GHWCFG2_HS_PHY_TYPE_UTMI		1
259 #define GHWCFG2_HS_PHY_TYPE_ULPI		2
260 #define GHWCFG2_HS_PHY_TYPE_UTMI_ULPI		3
261 #define GHWCFG2_POINT2POINT			BIT(5)
262 #define GHWCFG2_ARCHITECTURE_MASK		(0x3 << 3)
263 #define GHWCFG2_ARCHITECTURE_SHIFT		3
264 #define GHWCFG2_SLAVE_ONLY_ARCH			0
265 #define GHWCFG2_EXT_DMA_ARCH			1
266 #define GHWCFG2_INT_DMA_ARCH			2
267 #define GHWCFG2_OP_MODE_MASK			(0x7 << 0)
268 #define GHWCFG2_OP_MODE_SHIFT			0
269 #define GHWCFG2_OP_MODE_HNP_SRP_CAPABLE		0
270 #define GHWCFG2_OP_MODE_SRP_ONLY_CAPABLE	1
271 #define GHWCFG2_OP_MODE_NO_HNP_SRP_CAPABLE	2
272 #define GHWCFG2_OP_MODE_SRP_CAPABLE_DEVICE	3
273 #define GHWCFG2_OP_MODE_NO_SRP_CAPABLE_DEVICE	4
274 #define GHWCFG2_OP_MODE_SRP_CAPABLE_HOST	5
275 #define GHWCFG2_OP_MODE_NO_SRP_CAPABLE_HOST	6
276 #define GHWCFG2_OP_MODE_UNDEFINED		7
277 
278 #define GHWCFG3				HSOTG_REG(0x004c)
279 #define GHWCFG3_DFIFO_DEPTH_MASK		(0xffff << 16)
280 #define GHWCFG3_DFIFO_DEPTH_SHIFT		16
281 #define GHWCFG3_OTG_LPM_EN			BIT(15)
282 #define GHWCFG3_BC_SUPPORT			BIT(14)
283 #define GHWCFG3_OTG_ENABLE_HSIC			BIT(13)
284 #define GHWCFG3_ADP_SUPP			BIT(12)
285 #define GHWCFG3_SYNCH_RESET_TYPE		BIT(11)
286 #define GHWCFG3_OPTIONAL_FEATURES		BIT(10)
287 #define GHWCFG3_VENDOR_CTRL_IF			BIT(9)
288 #define GHWCFG3_I2C				BIT(8)
289 #define GHWCFG3_OTG_FUNC			BIT(7)
290 #define GHWCFG3_PACKET_SIZE_CNTR_WIDTH_MASK	(0x7 << 4)
291 #define GHWCFG3_PACKET_SIZE_CNTR_WIDTH_SHIFT	4
292 #define GHWCFG3_XFER_SIZE_CNTR_WIDTH_MASK	(0xf << 0)
293 #define GHWCFG3_XFER_SIZE_CNTR_WIDTH_SHIFT	0
294 
295 #define GHWCFG4				HSOTG_REG(0x0050)
296 #define GHWCFG4_DESC_DMA_DYN			BIT(31)
297 #define GHWCFG4_DESC_DMA			BIT(30)
298 #define GHWCFG4_NUM_IN_EPS_MASK			(0xf << 26)
299 #define GHWCFG4_NUM_IN_EPS_SHIFT		26
300 #define GHWCFG4_DED_FIFO_EN			BIT(25)
301 #define GHWCFG4_DED_FIFO_SHIFT		25
302 #define GHWCFG4_SESSION_END_FILT_EN		BIT(24)
303 #define GHWCFG4_B_VALID_FILT_EN			BIT(23)
304 #define GHWCFG4_A_VALID_FILT_EN			BIT(22)
305 #define GHWCFG4_VBUS_VALID_FILT_EN		BIT(21)
306 #define GHWCFG4_IDDIG_FILT_EN			BIT(20)
307 #define GHWCFG4_NUM_DEV_MODE_CTRL_EP_MASK	(0xf << 16)
308 #define GHWCFG4_NUM_DEV_MODE_CTRL_EP_SHIFT	16
309 #define GHWCFG4_UTMI_PHY_DATA_WIDTH_MASK	(0x3 << 14)
310 #define GHWCFG4_UTMI_PHY_DATA_WIDTH_SHIFT	14
311 #define GHWCFG4_UTMI_PHY_DATA_WIDTH_8		0
312 #define GHWCFG4_UTMI_PHY_DATA_WIDTH_16		1
313 #define GHWCFG4_UTMI_PHY_DATA_WIDTH_8_OR_16	2
314 #define GHWCFG4_XHIBER				BIT(7)
315 #define GHWCFG4_HIBER				BIT(6)
316 #define GHWCFG4_MIN_AHB_FREQ			BIT(5)
317 #define GHWCFG4_POWER_OPTIMIZ			BIT(4)
318 #define GHWCFG4_NUM_DEV_PERIO_IN_EP_MASK	(0xf << 0)
319 #define GHWCFG4_NUM_DEV_PERIO_IN_EP_SHIFT	0
320 
321 #define GLPMCFG				HSOTG_REG(0x0054)
322 #define GLPMCFG_INV_SEL_HSIC		BIT(31)
323 #define GLPMCFG_HSIC_CONNECT		BIT(30)
324 #define GLPMCFG_RETRY_COUNT_STS_MASK	(0x7 << 25)
325 #define GLPMCFG_RETRY_COUNT_STS_SHIFT	25
326 #define GLPMCFG_SEND_LPM		BIT(24)
327 #define GLPMCFG_RETRY_COUNT_MASK	(0x7 << 21)
328 #define GLPMCFG_RETRY_COUNT_SHIFT	21
329 #define GLPMCFG_LPM_CHAN_INDEX_MASK	(0xf << 17)
330 #define GLPMCFG_LPM_CHAN_INDEX_SHIFT	17
331 #define GLPMCFG_SLEEP_STATE_RESUMEOK	BIT(16)
332 #define GLPMCFG_PRT_SLEEP_STS		BIT(15)
333 #define GLPMCFG_LPM_RESP_MASK		(0x3 << 13)
334 #define GLPMCFG_LPM_RESP_SHIFT		13
335 #define GLPMCFG_HIRD_THRES_MASK		(0x1f << 8)
336 #define GLPMCFG_HIRD_THRES_SHIFT	8
337 #define GLPMCFG_HIRD_THRES_EN			(0x10 << 8)
338 #define GLPMCFG_EN_UTMI_SLEEP		BIT(7)
339 #define GLPMCFG_REM_WKUP_EN		BIT(6)
340 #define GLPMCFG_HIRD_MASK		(0xf << 2)
341 #define GLPMCFG_HIRD_SHIFT		2
342 #define GLPMCFG_APPL_RESP		BIT(1)
343 #define GLPMCFG_LPM_CAP_EN		BIT(0)
344 
345 #define GPWRDN				HSOTG_REG(0x0058)
346 #define GPWRDN_MULT_VAL_ID_BC_MASK	(0x1f << 24)
347 #define GPWRDN_MULT_VAL_ID_BC_SHIFT	24
348 #define GPWRDN_ADP_INT			BIT(23)
349 #define GPWRDN_BSESSVLD			BIT(22)
350 #define GPWRDN_IDSTS			BIT(21)
351 #define GPWRDN_LINESTATE_MASK		(0x3 << 19)
352 #define GPWRDN_LINESTATE_SHIFT		19
353 #define GPWRDN_STS_CHGINT_MSK		BIT(18)
354 #define GPWRDN_STS_CHGINT		BIT(17)
355 #define GPWRDN_SRP_DET_MSK		BIT(16)
356 #define GPWRDN_SRP_DET			BIT(15)
357 #define GPWRDN_CONNECT_DET_MSK		BIT(14)
358 #define GPWRDN_CONNECT_DET		BIT(13)
359 #define GPWRDN_DISCONN_DET_MSK		BIT(12)
360 #define GPWRDN_DISCONN_DET		BIT(11)
361 #define GPWRDN_RST_DET_MSK		BIT(10)
362 #define GPWRDN_RST_DET			BIT(9)
363 #define GPWRDN_LNSTSCHG_MSK		BIT(8)
364 #define GPWRDN_LNSTSCHG			BIT(7)
365 #define GPWRDN_DIS_VBUS			BIT(6)
366 #define GPWRDN_PWRDNSWTCH		BIT(5)
367 #define GPWRDN_PWRDNRSTN		BIT(4)
368 #define GPWRDN_PWRDNCLMP		BIT(3)
369 #define GPWRDN_RESTORE			BIT(2)
370 #define GPWRDN_PMUACTV			BIT(1)
371 #define GPWRDN_PMUINTSEL		BIT(0)
372 
373 #define GDFIFOCFG			HSOTG_REG(0x005c)
374 #define GDFIFOCFG_EPINFOBASE_MASK	(0xffff << 16)
375 #define GDFIFOCFG_EPINFOBASE_SHIFT	16
376 #define GDFIFOCFG_GDFIFOCFG_MASK	(0xffff << 0)
377 #define GDFIFOCFG_GDFIFOCFG_SHIFT	0
378 
379 #define ADPCTL				HSOTG_REG(0x0060)
380 #define ADPCTL_AR_MASK			(0x3 << 27)
381 #define ADPCTL_AR_SHIFT			27
382 #define ADPCTL_ADP_TMOUT_INT_MSK	BIT(26)
383 #define ADPCTL_ADP_SNS_INT_MSK		BIT(25)
384 #define ADPCTL_ADP_PRB_INT_MSK		BIT(24)
385 #define ADPCTL_ADP_TMOUT_INT		BIT(23)
386 #define ADPCTL_ADP_SNS_INT		BIT(22)
387 #define ADPCTL_ADP_PRB_INT		BIT(21)
388 #define ADPCTL_ADPENA			BIT(20)
389 #define ADPCTL_ADPRES			BIT(19)
390 #define ADPCTL_ENASNS			BIT(18)
391 #define ADPCTL_ENAPRB			BIT(17)
392 #define ADPCTL_RTIM_MASK		(0x7ff << 6)
393 #define ADPCTL_RTIM_SHIFT		6
394 #define ADPCTL_PRB_PER_MASK		(0x3 << 4)
395 #define ADPCTL_PRB_PER_SHIFT		4
396 #define ADPCTL_PRB_DELTA_MASK		(0x3 << 2)
397 #define ADPCTL_PRB_DELTA_SHIFT		2
398 #define ADPCTL_PRB_DSCHRG_MASK		(0x3 << 0)
399 #define ADPCTL_PRB_DSCHRG_SHIFT		0
400 
401 #define HPTXFSIZ			HSOTG_REG(0x100)
402 /* Use FIFOSIZE_* constants to access this register */
403 
404 #define DPTXFSIZN(_a)			HSOTG_REG(0x104 + (((_a) - 1) * 4))
405 /* Use FIFOSIZE_* constants to access this register */
406 
407 /* These apply to the GNPTXFSIZ, HPTXFSIZ and DPTXFSIZN registers */
408 #define FIFOSIZE_DEPTH_MASK		(0xffff << 16)
409 #define FIFOSIZE_DEPTH_SHIFT		16
410 #define FIFOSIZE_STARTADDR_MASK		(0xffff << 0)
411 #define FIFOSIZE_STARTADDR_SHIFT	0
412 #define FIFOSIZE_DEPTH_GET(_x)		(((_x) >> 16) & 0xffff)
413 
414 /* Device mode registers */
415 
416 #define DCFG				HSOTG_REG(0x800)
417 #define DCFG_DESCDMA_EN			BIT(23)
418 #define DCFG_EPMISCNT_MASK		(0x1f << 18)
419 #define DCFG_EPMISCNT_SHIFT		18
420 #define DCFG_EPMISCNT_LIMIT		0x1f
421 #define DCFG_EPMISCNT(_x)		((_x) << 18)
422 #define DCFG_PERFRINT_MASK		(0x3 << 11)
423 #define DCFG_PERFRINT_SHIFT		11
424 #define DCFG_PERFRINT_LIMIT		0x3
425 #define DCFG_PERFRINT(_x)		((_x) << 11)
426 #define DCFG_DEVADDR_MASK		(0x7f << 4)
427 #define DCFG_DEVADDR_SHIFT		4
428 #define DCFG_DEVADDR_LIMIT		0x7f
429 #define DCFG_DEVADDR(_x)		((_x) << 4)
430 #define DCFG_NZ_STS_OUT_HSHK		BIT(2)
431 #define DCFG_DEVSPD_MASK		(0x3 << 0)
432 #define DCFG_DEVSPD_SHIFT		0
433 #define DCFG_DEVSPD_HS			0
434 #define DCFG_DEVSPD_FS			1
435 #define DCFG_DEVSPD_LS			2
436 #define DCFG_DEVSPD_FS48		3
437 
438 #define DCTL				HSOTG_REG(0x804)
439 #define DCTL_PWRONPRGDONE		BIT(11)
440 #define DCTL_CGOUTNAK			BIT(10)
441 #define DCTL_SGOUTNAK			BIT(9)
442 #define DCTL_CGNPINNAK			BIT(8)
443 #define DCTL_SGNPINNAK			BIT(7)
444 #define DCTL_TSTCTL_MASK		(0x7 << 4)
445 #define DCTL_TSTCTL_SHIFT		4
446 #define DCTL_GOUTNAKSTS			BIT(3)
447 #define DCTL_GNPINNAKSTS		BIT(2)
448 #define DCTL_SFTDISCON			BIT(1)
449 #define DCTL_RMTWKUPSIG			BIT(0)
450 
451 #define DSTS				HSOTG_REG(0x808)
452 #define DSTS_SOFFN_MASK			(0x3fff << 8)
453 #define DSTS_SOFFN_SHIFT		8
454 #define DSTS_SOFFN_LIMIT		0x3fff
455 #define DSTS_SOFFN(_x)			((_x) << 8)
456 #define DSTS_ERRATICERR			BIT(3)
457 #define DSTS_ENUMSPD_MASK		(0x3 << 1)
458 #define DSTS_ENUMSPD_SHIFT		1
459 #define DSTS_ENUMSPD_HS			0
460 #define DSTS_ENUMSPD_FS			1
461 #define DSTS_ENUMSPD_LS			2
462 #define DSTS_ENUMSPD_FS48		3
463 #define DSTS_SUSPSTS			BIT(0)
464 
465 #define DIEPMSK				HSOTG_REG(0x810)
466 #define DIEPMSK_NAKMSK			BIT(13)
467 #define DIEPMSK_BNAININTRMSK		BIT(9)
468 #define DIEPMSK_TXFIFOUNDRNMSK		BIT(8)
469 #define DIEPMSK_TXFIFOEMPTY		BIT(7)
470 #define DIEPMSK_INEPNAKEFFMSK		BIT(6)
471 #define DIEPMSK_INTKNEPMISMSK		BIT(5)
472 #define DIEPMSK_INTKNTXFEMPMSK		BIT(4)
473 #define DIEPMSK_TIMEOUTMSK		BIT(3)
474 #define DIEPMSK_AHBERRMSK		BIT(2)
475 #define DIEPMSK_EPDISBLDMSK		BIT(1)
476 #define DIEPMSK_XFERCOMPLMSK		BIT(0)
477 
478 #define DOEPMSK				HSOTG_REG(0x814)
479 #define DOEPMSK_BNAMSK			BIT(9)
480 #define DOEPMSK_BACK2BACKSETUP		BIT(6)
481 #define DOEPMSK_STSPHSERCVDMSK		BIT(5)
482 #define DOEPMSK_OUTTKNEPDISMSK		BIT(4)
483 #define DOEPMSK_SETUPMSK		BIT(3)
484 #define DOEPMSK_AHBERRMSK		BIT(2)
485 #define DOEPMSK_EPDISBLDMSK		BIT(1)
486 #define DOEPMSK_XFERCOMPLMSK		BIT(0)
487 
488 #define DAINT				HSOTG_REG(0x818)
489 #define DAINTMSK			HSOTG_REG(0x81C)
490 #define DAINT_OUTEP_SHIFT		16
491 #define DAINT_OUTEP(_x)			(1 << ((_x) + 16))
492 #define DAINT_INEP(_x)			(1 << (_x))
493 
494 #define DTKNQR1				HSOTG_REG(0x820)
495 #define DTKNQR2				HSOTG_REG(0x824)
496 #define DTKNQR3				HSOTG_REG(0x830)
497 #define DTKNQR4				HSOTG_REG(0x834)
498 #define DIEPEMPMSK			HSOTG_REG(0x834)
499 
500 #define DVBUSDIS			HSOTG_REG(0x828)
501 #define DVBUSPULSE			HSOTG_REG(0x82C)
502 
503 #define DIEPCTL0			HSOTG_REG(0x900)
504 #define DIEPCTL(_a)			HSOTG_REG(0x900 + ((_a) * 0x20))
505 
506 #define DOEPCTL0			HSOTG_REG(0xB00)
507 #define DOEPCTL(_a)			HSOTG_REG(0xB00 + ((_a) * 0x20))
508 
509 /* EP0 specialness:
510  * bits[29..28] - reserved (no SetD0PID, SetD1PID)
511  * bits[25..22] - should always be zero, this isn't a periodic endpoint
512  * bits[10..0]  - MPS setting different for EP0
513  */
514 #define D0EPCTL_MPS_MASK		(0x3 << 0)
515 #define D0EPCTL_MPS_SHIFT		0
516 #define D0EPCTL_MPS_64			0
517 #define D0EPCTL_MPS_32			1
518 #define D0EPCTL_MPS_16			2
519 #define D0EPCTL_MPS_8			3
520 
521 #define DXEPCTL_EPENA			BIT(31)
522 #define DXEPCTL_EPDIS			BIT(30)
523 #define DXEPCTL_SETD1PID		BIT(29)
524 #define DXEPCTL_SETODDFR		BIT(29)
525 #define DXEPCTL_SETD0PID		BIT(28)
526 #define DXEPCTL_SETEVENFR		BIT(28)
527 #define DXEPCTL_SNAK			BIT(27)
528 #define DXEPCTL_CNAK			BIT(26)
529 #define DXEPCTL_TXFNUM_MASK		(0xf << 22)
530 #define DXEPCTL_TXFNUM_SHIFT		22
531 #define DXEPCTL_TXFNUM_LIMIT		0xf
532 #define DXEPCTL_TXFNUM(_x)		((_x) << 22)
533 #define DXEPCTL_STALL			BIT(21)
534 #define DXEPCTL_SNP			BIT(20)
535 #define DXEPCTL_EPTYPE_MASK		(0x3 << 18)
536 #define DXEPCTL_EPTYPE_CONTROL		(0x0 << 18)
537 #define DXEPCTL_EPTYPE_ISO		(0x1 << 18)
538 #define DXEPCTL_EPTYPE_BULK		(0x2 << 18)
539 #define DXEPCTL_EPTYPE_INTERRUPT	(0x3 << 18)
540 
541 #define DXEPCTL_NAKSTS			BIT(17)
542 #define DXEPCTL_DPID			BIT(16)
543 #define DXEPCTL_EOFRNUM			BIT(16)
544 #define DXEPCTL_USBACTEP		BIT(15)
545 #define DXEPCTL_NEXTEP_MASK		(0xf << 11)
546 #define DXEPCTL_NEXTEP_SHIFT		11
547 #define DXEPCTL_NEXTEP_LIMIT		0xf
548 #define DXEPCTL_NEXTEP(_x)		((_x) << 11)
549 #define DXEPCTL_MPS_MASK		(0x7ff << 0)
550 #define DXEPCTL_MPS_SHIFT		0
551 #define DXEPCTL_MPS_LIMIT		0x7ff
552 #define DXEPCTL_MPS(_x)			((_x) << 0)
553 
554 #define DIEPINT(_a)			HSOTG_REG(0x908 + ((_a) * 0x20))
555 #define DOEPINT(_a)			HSOTG_REG(0xB08 + ((_a) * 0x20))
556 #define DXEPINT_SETUP_RCVD		BIT(15)
557 #define DXEPINT_NYETINTRPT		BIT(14)
558 #define DXEPINT_NAKINTRPT		BIT(13)
559 #define DXEPINT_BBLEERRINTRPT		BIT(12)
560 #define DXEPINT_PKTDRPSTS		BIT(11)
561 #define DXEPINT_BNAINTR			BIT(9)
562 #define DXEPINT_TXFIFOUNDRN		BIT(8)
563 #define DXEPINT_OUTPKTERR		BIT(8)
564 #define DXEPINT_TXFEMP			BIT(7)
565 #define DXEPINT_INEPNAKEFF		BIT(6)
566 #define DXEPINT_BACK2BACKSETUP		BIT(6)
567 #define DXEPINT_INTKNEPMIS		BIT(5)
568 #define DXEPINT_STSPHSERCVD		BIT(5)
569 #define DXEPINT_INTKNTXFEMP		BIT(4)
570 #define DXEPINT_OUTTKNEPDIS		BIT(4)
571 #define DXEPINT_TIMEOUT			BIT(3)
572 #define DXEPINT_SETUP			BIT(3)
573 #define DXEPINT_AHBERR			BIT(2)
574 #define DXEPINT_EPDISBLD		BIT(1)
575 #define DXEPINT_XFERCOMPL		BIT(0)
576 
577 #define DIEPTSIZ0			HSOTG_REG(0x910)
578 #define DIEPTSIZ0_PKTCNT_MASK		(0x3 << 19)
579 #define DIEPTSIZ0_PKTCNT_SHIFT		19
580 #define DIEPTSIZ0_PKTCNT_LIMIT		0x3
581 #define DIEPTSIZ0_PKTCNT(_x)		((_x) << 19)
582 #define DIEPTSIZ0_XFERSIZE_MASK		(0x7f << 0)
583 #define DIEPTSIZ0_XFERSIZE_SHIFT	0
584 #define DIEPTSIZ0_XFERSIZE_LIMIT	0x7f
585 #define DIEPTSIZ0_XFERSIZE(_x)		((_x) << 0)
586 
587 #define DOEPTSIZ0			HSOTG_REG(0xB10)
588 #define DOEPTSIZ0_SUPCNT_MASK		(0x3 << 29)
589 #define DOEPTSIZ0_SUPCNT_SHIFT		29
590 #define DOEPTSIZ0_SUPCNT_LIMIT		0x3
591 #define DOEPTSIZ0_SUPCNT(_x)		((_x) << 29)
592 #define DOEPTSIZ0_PKTCNT		BIT(19)
593 #define DOEPTSIZ0_XFERSIZE_MASK		(0x7f << 0)
594 #define DOEPTSIZ0_XFERSIZE_SHIFT	0
595 
596 #define DIEPTSIZ(_a)			HSOTG_REG(0x910 + ((_a) * 0x20))
597 #define DOEPTSIZ(_a)			HSOTG_REG(0xB10 + ((_a) * 0x20))
598 #define DXEPTSIZ_MC_MASK		(0x3 << 29)
599 #define DXEPTSIZ_MC_SHIFT		29
600 #define DXEPTSIZ_MC_LIMIT		0x3
601 #define DXEPTSIZ_MC(_x)			((_x) << 29)
602 #define DXEPTSIZ_PKTCNT_MASK		(0x3ff << 19)
603 #define DXEPTSIZ_PKTCNT_SHIFT		19
604 #define DXEPTSIZ_PKTCNT_LIMIT		0x3ff
605 #define DXEPTSIZ_PKTCNT_GET(_v)		(((_v) >> 19) & 0x3ff)
606 #define DXEPTSIZ_PKTCNT(_x)		((_x) << 19)
607 #define DXEPTSIZ_XFERSIZE_MASK		(0x7ffff << 0)
608 #define DXEPTSIZ_XFERSIZE_SHIFT		0
609 #define DXEPTSIZ_XFERSIZE_LIMIT		0x7ffff
610 #define DXEPTSIZ_XFERSIZE_GET(_v)	(((_v) >> 0) & 0x7ffff)
611 #define DXEPTSIZ_XFERSIZE(_x)		((_x) << 0)
612 
613 #define DIEPDMA(_a)			HSOTG_REG(0x914 + ((_a) * 0x20))
614 #define DOEPDMA(_a)			HSOTG_REG(0xB14 + ((_a) * 0x20))
615 
616 #define DTXFSTS(_a)			HSOTG_REG(0x918 + ((_a) * 0x20))
617 
618 #define PCGCTL				HSOTG_REG(0x0e00)
619 #define PCGCTL_IF_DEV_MODE		BIT(31)
620 #define PCGCTL_P2HD_PRT_SPD_MASK	(0x3 << 29)
621 #define PCGCTL_P2HD_PRT_SPD_SHIFT	29
622 #define PCGCTL_P2HD_DEV_ENUM_SPD_MASK	(0x3 << 27)
623 #define PCGCTL_P2HD_DEV_ENUM_SPD_SHIFT	27
624 #define PCGCTL_MAC_DEV_ADDR_MASK	(0x7f << 20)
625 #define PCGCTL_MAC_DEV_ADDR_SHIFT	20
626 #define PCGCTL_MAX_TERMSEL		BIT(19)
627 #define PCGCTL_MAX_XCVRSELECT_MASK	(0x3 << 17)
628 #define PCGCTL_MAX_XCVRSELECT_SHIFT	17
629 #define PCGCTL_PORT_POWER		BIT(16)
630 #define PCGCTL_PRT_CLK_SEL_MASK		(0x3 << 14)
631 #define PCGCTL_PRT_CLK_SEL_SHIFT	14
632 #define PCGCTL_ESS_REG_RESTORED		BIT(13)
633 #define PCGCTL_EXTND_HIBER_SWITCH	BIT(12)
634 #define PCGCTL_EXTND_HIBER_PWRCLMP	BIT(11)
635 #define PCGCTL_ENBL_EXTND_HIBER		BIT(10)
636 #define PCGCTL_RESTOREMODE		BIT(9)
637 #define PCGCTL_RESETAFTSUSP		BIT(8)
638 #define PCGCTL_DEEP_SLEEP		BIT(7)
639 #define PCGCTL_PHY_IN_SLEEP		BIT(6)
640 #define PCGCTL_ENBL_SLEEP_GATING	BIT(5)
641 #define PCGCTL_RSTPDWNMODULE		BIT(3)
642 #define PCGCTL_PWRCLMP			BIT(2)
643 #define PCGCTL_GATEHCLK			BIT(1)
644 #define PCGCTL_STOPPCLK			BIT(0)
645 
646 #define EPFIFO(_a)			HSOTG_REG(0x1000 + ((_a) * 0x1000))
647 
648 /* Host Mode Registers */
649 
650 #define HCFG				HSOTG_REG(0x0400)
651 #define HCFG_MODECHTIMEN		BIT(31)
652 #define HCFG_PERSCHEDENA		BIT(26)
653 #define HCFG_FRLISTEN_MASK		(0x3 << 24)
654 #define HCFG_FRLISTEN_SHIFT		24
655 #define HCFG_FRLISTEN_8				(0 << 24)
656 #define FRLISTEN_8_SIZE				8
657 #define HCFG_FRLISTEN_16			BIT(24)
658 #define FRLISTEN_16_SIZE			16
659 #define HCFG_FRLISTEN_32			(2 << 24)
660 #define FRLISTEN_32_SIZE			32
661 #define HCFG_FRLISTEN_64			(3 << 24)
662 #define FRLISTEN_64_SIZE			64
663 #define HCFG_DESCDMA			BIT(23)
664 #define HCFG_RESVALID_MASK		(0xff << 8)
665 #define HCFG_RESVALID_SHIFT		8
666 #define HCFG_ENA32KHZ			BIT(7)
667 #define HCFG_FSLSSUPP			BIT(2)
668 #define HCFG_FSLSPCLKSEL_MASK		(0x3 << 0)
669 #define HCFG_FSLSPCLKSEL_SHIFT		0
670 #define HCFG_FSLSPCLKSEL_30_60_MHZ	0
671 #define HCFG_FSLSPCLKSEL_48_MHZ		1
672 #define HCFG_FSLSPCLKSEL_6_MHZ		2
673 
674 #define HFIR				HSOTG_REG(0x0404)
675 #define HFIR_FRINT_MASK			(0xffff << 0)
676 #define HFIR_FRINT_SHIFT		0
677 #define HFIR_RLDCTRL			BIT(16)
678 
679 #define HFNUM				HSOTG_REG(0x0408)
680 #define HFNUM_FRREM_MASK		(0xffff << 16)
681 #define HFNUM_FRREM_SHIFT		16
682 #define HFNUM_FRNUM_MASK		(0xffff << 0)
683 #define HFNUM_FRNUM_SHIFT		0
684 #define HFNUM_MAX_FRNUM			0x3fff
685 
686 #define HPTXSTS				HSOTG_REG(0x0410)
687 #define TXSTS_QTOP_ODD			BIT(31)
688 #define TXSTS_QTOP_CHNEP_MASK		(0xf << 27)
689 #define TXSTS_QTOP_CHNEP_SHIFT		27
690 #define TXSTS_QTOP_TOKEN_MASK		(0x3 << 25)
691 #define TXSTS_QTOP_TOKEN_SHIFT		25
692 #define TXSTS_QTOP_TERMINATE		BIT(24)
693 #define TXSTS_QSPCAVAIL_MASK		(0xff << 16)
694 #define TXSTS_QSPCAVAIL_SHIFT		16
695 #define TXSTS_FSPCAVAIL_MASK		(0xffff << 0)
696 #define TXSTS_FSPCAVAIL_SHIFT		0
697 
698 #define HAINT				HSOTG_REG(0x0414)
699 #define HAINTMSK			HSOTG_REG(0x0418)
700 #define HFLBADDR			HSOTG_REG(0x041c)
701 
702 #define HPRT0				HSOTG_REG(0x0440)
703 #define HPRT0_SPD_MASK			(0x3 << 17)
704 #define HPRT0_SPD_SHIFT			17
705 #define HPRT0_SPD_HIGH_SPEED		0
706 #define HPRT0_SPD_FULL_SPEED		1
707 #define HPRT0_SPD_LOW_SPEED		2
708 #define HPRT0_TSTCTL_MASK		(0xf << 13)
709 #define HPRT0_TSTCTL_SHIFT		13
710 #define HPRT0_PWR			BIT(12)
711 #define HPRT0_LNSTS_MASK		(0x3 << 10)
712 #define HPRT0_LNSTS_SHIFT		10
713 #define HPRT0_RST			BIT(8)
714 #define HPRT0_SUSP			BIT(7)
715 #define HPRT0_RES			BIT(6)
716 #define HPRT0_OVRCURRCHG		BIT(5)
717 #define HPRT0_OVRCURRACT		BIT(4)
718 #define HPRT0_ENACHG			BIT(3)
719 #define HPRT0_ENA			BIT(2)
720 #define HPRT0_CONNDET			BIT(1)
721 #define HPRT0_CONNSTS			BIT(0)
722 
723 #define HCCHAR(_ch)			HSOTG_REG(0x0500 + 0x20 * (_ch))
724 #define HCCHAR_CHENA			BIT(31)
725 #define HCCHAR_CHDIS			BIT(30)
726 #define HCCHAR_ODDFRM			BIT(29)
727 #define HCCHAR_DEVADDR_MASK		(0x7f << 22)
728 #define HCCHAR_DEVADDR_SHIFT		22
729 #define HCCHAR_MULTICNT_MASK		(0x3 << 20)
730 #define HCCHAR_MULTICNT_SHIFT		20
731 #define HCCHAR_EPTYPE_MASK		(0x3 << 18)
732 #define HCCHAR_EPTYPE_SHIFT		18
733 #define HCCHAR_LSPDDEV			BIT(17)
734 #define HCCHAR_EPDIR			BIT(15)
735 #define HCCHAR_EPNUM_MASK		(0xf << 11)
736 #define HCCHAR_EPNUM_SHIFT		11
737 #define HCCHAR_MPS_MASK			(0x7ff << 0)
738 #define HCCHAR_MPS_SHIFT		0
739 
740 #define HCSPLT(_ch)			HSOTG_REG(0x0504 + 0x20 * (_ch))
741 #define HCSPLT_SPLTENA			BIT(31)
742 #define HCSPLT_COMPSPLT			BIT(16)
743 #define HCSPLT_XACTPOS_MASK		(0x3 << 14)
744 #define HCSPLT_XACTPOS_SHIFT		14
745 #define HCSPLT_XACTPOS_MID		0
746 #define HCSPLT_XACTPOS_END		1
747 #define HCSPLT_XACTPOS_BEGIN		2
748 #define HCSPLT_XACTPOS_ALL		3
749 #define HCSPLT_HUBADDR_MASK		(0x7f << 7)
750 #define HCSPLT_HUBADDR_SHIFT		7
751 #define HCSPLT_PRTADDR_MASK		(0x7f << 0)
752 #define HCSPLT_PRTADDR_SHIFT		0
753 
754 #define HCINT(_ch)			HSOTG_REG(0x0508 + 0x20 * (_ch))
755 #define HCINTMSK(_ch)			HSOTG_REG(0x050c + 0x20 * (_ch))
756 #define HCINTMSK_RESERVED14_31		(0x3ffff << 14)
757 #define HCINTMSK_FRM_LIST_ROLL		BIT(13)
758 #define HCINTMSK_XCS_XACT		BIT(12)
759 #define HCINTMSK_BNA			BIT(11)
760 #define HCINTMSK_DATATGLERR		BIT(10)
761 #define HCINTMSK_FRMOVRUN		BIT(9)
762 #define HCINTMSK_BBLERR			BIT(8)
763 #define HCINTMSK_XACTERR		BIT(7)
764 #define HCINTMSK_NYET			BIT(6)
765 #define HCINTMSK_ACK			BIT(5)
766 #define HCINTMSK_NAK			BIT(4)
767 #define HCINTMSK_STALL			BIT(3)
768 #define HCINTMSK_AHBERR			BIT(2)
769 #define HCINTMSK_CHHLTD			BIT(1)
770 #define HCINTMSK_XFERCOMPL		BIT(0)
771 
772 #define HCTSIZ(_ch)			HSOTG_REG(0x0510 + 0x20 * (_ch))
773 #define TSIZ_DOPNG			BIT(31)
774 #define TSIZ_SC_MC_PID_MASK		(0x3 << 29)
775 #define TSIZ_SC_MC_PID_SHIFT		29
776 #define TSIZ_SC_MC_PID_DATA0		0
777 #define TSIZ_SC_MC_PID_DATA2		1
778 #define TSIZ_SC_MC_PID_DATA1		2
779 #define TSIZ_SC_MC_PID_MDATA		3
780 #define TSIZ_SC_MC_PID_SETUP		3
781 #define TSIZ_PKTCNT_MASK		(0x3ff << 19)
782 #define TSIZ_PKTCNT_SHIFT		19
783 #define TSIZ_NTD_MASK			(0xff << 8)
784 #define TSIZ_NTD_SHIFT			8
785 #define TSIZ_SCHINFO_MASK		(0xff << 0)
786 #define TSIZ_SCHINFO_SHIFT		0
787 #define TSIZ_XFERSIZE_MASK		(0x7ffff << 0)
788 #define TSIZ_XFERSIZE_SHIFT		0
789 
790 #define HCDMA(_ch)			HSOTG_REG(0x0514 + 0x20 * (_ch))
791 
792 #define HCDMAB(_ch)			HSOTG_REG(0x051c + 0x20 * (_ch))
793 
794 #define HCFIFO(_ch)			HSOTG_REG(0x1000 + 0x1000 * (_ch))
795 
796 /**
797  * struct dwc2_dma_desc - DMA descriptor structure,
798  * used for both host and gadget modes
799  *
800  * @status: DMA descriptor status quadlet
801  * @buf:    DMA descriptor data buffer pointer
802  *
803  * DMA Descriptor structure contains two quadlets:
804  * Status quadlet and Data buffer pointer.
805  */
806 struct dwc2_dma_desc {
807 	u32 status;
808 	u32 buf;
809 } __packed;
810 
811 /* Host Mode DMA descriptor status quadlet */
812 
813 #define HOST_DMA_A			BIT(31)
814 #define HOST_DMA_STS_MASK		(0x3 << 28)
815 #define HOST_DMA_STS_SHIFT		28
816 #define HOST_DMA_STS_PKTERR		BIT(28)
817 #define HOST_DMA_EOL			BIT(26)
818 #define HOST_DMA_IOC			BIT(25)
819 #define HOST_DMA_SUP			BIT(24)
820 #define HOST_DMA_ALT_QTD		BIT(23)
821 #define HOST_DMA_QTD_OFFSET_MASK	(0x3f << 17)
822 #define HOST_DMA_QTD_OFFSET_SHIFT	17
823 #define HOST_DMA_ISOC_NBYTES_MASK	(0xfff << 0)
824 #define HOST_DMA_ISOC_NBYTES_SHIFT	0
825 #define HOST_DMA_NBYTES_MASK		(0x1ffff << 0)
826 #define HOST_DMA_NBYTES_SHIFT		0
827 #define HOST_DMA_NBYTES_LIMIT		131071
828 
829 /* Device Mode DMA descriptor status quadlet */
830 
831 #define DEV_DMA_BUFF_STS_MASK		(0x3 << 30)
832 #define DEV_DMA_BUFF_STS_SHIFT		30
833 #define DEV_DMA_BUFF_STS_HREADY		0
834 #define DEV_DMA_BUFF_STS_DMABUSY	1
835 #define DEV_DMA_BUFF_STS_DMADONE	2
836 #define DEV_DMA_BUFF_STS_HBUSY		3
837 #define DEV_DMA_STS_MASK		(0x3 << 28)
838 #define DEV_DMA_STS_SHIFT		28
839 #define DEV_DMA_STS_SUCC		0
840 #define DEV_DMA_STS_BUFF_FLUSH		1
841 #define DEV_DMA_STS_BUFF_ERR		3
842 #define DEV_DMA_L			BIT(27)
843 #define DEV_DMA_SHORT			BIT(26)
844 #define DEV_DMA_IOC			BIT(25)
845 #define DEV_DMA_SR			BIT(24)
846 #define DEV_DMA_MTRF			BIT(23)
847 #define DEV_DMA_ISOC_PID_MASK		(0x3 << 23)
848 #define DEV_DMA_ISOC_PID_SHIFT		23
849 #define DEV_DMA_ISOC_PID_DATA0		0
850 #define DEV_DMA_ISOC_PID_DATA2		1
851 #define DEV_DMA_ISOC_PID_DATA1		2
852 #define DEV_DMA_ISOC_PID_MDATA		3
853 #define DEV_DMA_ISOC_FRNUM_MASK		(0x7ff << 12)
854 #define DEV_DMA_ISOC_FRNUM_SHIFT	12
855 #define DEV_DMA_ISOC_TX_NBYTES_MASK	(0xfff << 0)
856 #define DEV_DMA_ISOC_TX_NBYTES_LIMIT	0xfff
857 #define DEV_DMA_ISOC_RX_NBYTES_MASK	(0x7ff << 0)
858 #define DEV_DMA_ISOC_RX_NBYTES_LIMIT	0x7ff
859 #define DEV_DMA_ISOC_NBYTES_SHIFT	0
860 #define DEV_DMA_NBYTES_MASK		(0xffff << 0)
861 #define DEV_DMA_NBYTES_SHIFT		0
862 #define DEV_DMA_NBYTES_LIMIT		0xffff
863 
864 #define MAX_DMA_DESC_NUM_GENERIC	64
865 #define MAX_DMA_DESC_NUM_HS_ISOC	256
866 
867 #endif /* __DWC2_HW_H__ */
868