hw.h 30 KB

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