dwc_otg_regs.h 70 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553
  1. /* ==========================================================================
  2. * $File: //dwh/usb_iip/dev/software/otg/linux/drivers/dwc_otg_regs.h $
  3. * $Revision: #97 $
  4. * $Date: 2011/10/24 $
  5. * $Change: 1871160 $
  6. *
  7. * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
  8. * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
  9. * otherwise expressly agreed to in writing between Synopsys and you.
  10. *
  11. * The Software IS NOT an item of Licensed Software or Licensed Product under
  12. * any End User Software License Agreement or Agreement for Licensed Product
  13. * with Synopsys or any supplement thereto. You are permitted to use and
  14. * redistribute this Software in source and binary forms, with or without
  15. * modification, provided that redistributions of source code must retain this
  16. * notice. You may not view, use, disclose, copy or distribute this file or
  17. * any information contained herein except pursuant to this license grant from
  18. * Synopsys. If you do not agree with this notice, including the disclaimer
  19. * below, then you are not authorized to use the Software.
  20. *
  21. * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
  22. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24. * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
  25. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  26. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  27. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  28. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  31. * DAMAGE.
  32. * ========================================================================== */
  33. #ifndef __DWC_OTG_REGS_H__
  34. #define __DWC_OTG_REGS_H__
  35. #include "dwc_otg_core_if.h"
  36. /**
  37. * @file
  38. *
  39. * This file contains the data structures for accessing the DWC_otg core registers.
  40. *
  41. * The application interfaces with the HS OTG core by reading from and
  42. * writing to the Control and Status Register (CSR) space through the
  43. * AHB Slave interface. These registers are 32 bits wide, and the
  44. * addresses are 32-bit-block aligned.
  45. * CSRs are classified as follows:
  46. * - Core Global Registers
  47. * - Device Mode Registers
  48. * - Device Global Registers
  49. * - Device Endpoint Specific Registers
  50. * - Host Mode Registers
  51. * - Host Global Registers
  52. * - Host Port CSRs
  53. * - Host Channel Specific Registers
  54. *
  55. * Only the Core Global registers can be accessed in both Device and
  56. * Host modes. When the HS OTG core is operating in one mode, either
  57. * Device or Host, the application must not access registers from the
  58. * other mode. When the core switches from one mode to another, the
  59. * registers in the new mode of operation must be reprogrammed as they
  60. * would be after a power-on reset.
  61. */
  62. /****************************************************************************/
  63. /** DWC_otg Core registers .
  64. * The dwc_otg_core_global_regs structure defines the size
  65. * and relative field offsets for the Core Global registers.
  66. */
  67. typedef struct dwc_otg_core_global_regs {
  68. /** OTG Control and Status Register. <i>Offset: 000h</i> */
  69. volatile uint32_t gotgctl;
  70. /** OTG Interrupt Register. <i>Offset: 004h</i> */
  71. volatile uint32_t gotgint;
  72. /**Core AHB Configuration Register. <i>Offset: 008h</i> */
  73. volatile uint32_t gahbcfg;
  74. #define DWC_GLBINTRMASK 0x0001
  75. #define DWC_DMAENABLE 0x0020
  76. #define DWC_NPTXEMPTYLVL_EMPTY 0x0080
  77. #define DWC_NPTXEMPTYLVL_HALFEMPTY 0x0000
  78. #define DWC_PTXEMPTYLVL_EMPTY 0x0100
  79. #define DWC_PTXEMPTYLVL_HALFEMPTY 0x0000
  80. /**Core USB Configuration Register. <i>Offset: 00Ch</i> */
  81. volatile uint32_t gusbcfg;
  82. /**Core Reset Register. <i>Offset: 010h</i> */
  83. volatile uint32_t grstctl;
  84. /**Core Interrupt Register. <i>Offset: 014h</i> */
  85. volatile uint32_t gintsts;
  86. /**Core Interrupt Mask Register. <i>Offset: 018h</i> */
  87. volatile uint32_t gintmsk;
  88. /**Receive Status Queue Read Register (Read Only). <i>Offset: 01Ch</i> */
  89. volatile uint32_t grxstsr;
  90. /**Receive Status Queue Read & POP Register (Read Only). <i>Offset: 020h</i>*/
  91. volatile uint32_t grxstsp;
  92. /**Receive FIFO Size Register. <i>Offset: 024h</i> */
  93. volatile uint32_t grxfsiz;
  94. /**Non Periodic Transmit FIFO Size Register. <i>Offset: 028h</i> */
  95. volatile uint32_t gnptxfsiz;
  96. /**Non Periodic Transmit FIFO/Queue Status Register (Read
  97. * Only). <i>Offset: 02Ch</i> */
  98. volatile uint32_t gnptxsts;
  99. /**I2C Access Register. <i>Offset: 030h</i> */
  100. volatile uint32_t gi2cctl;
  101. /**PHY Vendor Control Register. <i>Offset: 034h</i> */
  102. volatile uint32_t gpvndctl;
  103. /**General Purpose Input/Output Register. <i>Offset: 038h</i> */
  104. volatile uint32_t ggpio;
  105. /**User ID Register. <i>Offset: 03Ch</i> */
  106. volatile uint32_t guid;
  107. /**Synopsys ID Register (Read Only). <i>Offset: 040h</i> */
  108. volatile uint32_t gsnpsid;
  109. /**User HW Config1 Register (Read Only). <i>Offset: 044h</i> */
  110. volatile uint32_t ghwcfg1;
  111. /**User HW Config2 Register (Read Only). <i>Offset: 048h</i> */
  112. volatile uint32_t ghwcfg2;
  113. #define DWC_SLAVE_ONLY_ARCH 0
  114. #define DWC_EXT_DMA_ARCH 1
  115. #define DWC_INT_DMA_ARCH 2
  116. #define DWC_MODE_HNP_SRP_CAPABLE 0
  117. #define DWC_MODE_SRP_ONLY_CAPABLE 1
  118. #define DWC_MODE_NO_HNP_SRP_CAPABLE 2
  119. #define DWC_MODE_SRP_CAPABLE_DEVICE 3
  120. #define DWC_MODE_NO_SRP_CAPABLE_DEVICE 4
  121. #define DWC_MODE_SRP_CAPABLE_HOST 5
  122. #define DWC_MODE_NO_SRP_CAPABLE_HOST 6
  123. /**User HW Config3 Register (Read Only). <i>Offset: 04Ch</i> */
  124. volatile uint32_t ghwcfg3;
  125. /**User HW Config4 Register (Read Only). <i>Offset: 050h</i>*/
  126. volatile uint32_t ghwcfg4;
  127. /** Core LPM Configuration register <i>Offset: 054h</i>*/
  128. volatile uint32_t glpmcfg;
  129. /** Global PowerDn Register <i>Offset: 058h</i> */
  130. volatile uint32_t gpwrdn;
  131. /** Global DFIFO SW Config Register <i>Offset: 05Ch</i> */
  132. volatile uint32_t gdfifocfg;
  133. /** ADP Control Register <i>Offset: 060h</i> */
  134. volatile uint32_t adpctl;
  135. /** Reserved <i>Offset: 064h-0FFh</i> */
  136. volatile uint32_t reserved39[39];
  137. /** Host Periodic Transmit FIFO Size Register. <i>Offset: 100h</i> */
  138. volatile uint32_t hptxfsiz;
  139. /** Device Periodic Transmit FIFO#n Register if dedicated fifos are disabled,
  140. otherwise Device Transmit FIFO#n Register.
  141. * <i>Offset: 104h + (FIFO_Number-1)*04h, 1 <= FIFO Number <= 15 (1<=n<=15).</i> */
  142. volatile uint32_t dtxfsiz[15];
  143. } dwc_otg_core_global_regs_t;
  144. /**
  145. * This union represents the bit fields of the Core OTG Control
  146. * and Status Register (GOTGCTL). Set the bits using the bit
  147. * fields then write the <i>d32</i> value to the register.
  148. */
  149. typedef union gotgctl_data {
  150. /** raw register data */
  151. uint32_t d32;
  152. /** register bits */
  153. struct {
  154. unsigned sesreqscs:1;
  155. unsigned sesreq:1;
  156. unsigned vbvalidoven:1;
  157. unsigned vbvalidovval:1;
  158. unsigned avalidoven:1;
  159. unsigned avalidovval:1;
  160. unsigned bvalidoven:1;
  161. unsigned bvalidovval:1;
  162. unsigned hstnegscs:1;
  163. unsigned hnpreq:1;
  164. unsigned hstsethnpen:1;
  165. unsigned devhnpen:1;
  166. unsigned reserved12_15:4;
  167. unsigned conidsts:1;
  168. unsigned dbnctime:1;
  169. unsigned asesvld:1;
  170. unsigned bsesvld:1;
  171. unsigned otgver:1;
  172. unsigned reserved1:1;
  173. unsigned multvalidbc:5;
  174. unsigned chirpen:1;
  175. unsigned reserved28_31:4;
  176. } b;
  177. } gotgctl_data_t;
  178. /**
  179. * This union represents the bit fields of the Core OTG Interrupt Register
  180. * (GOTGINT). Set/clear the bits using the bit fields then write the <i>d32</i>
  181. * value to the register.
  182. */
  183. typedef union gotgint_data {
  184. /** raw register data */
  185. uint32_t d32;
  186. /** register bits */
  187. struct {
  188. /** Current Mode */
  189. unsigned reserved0_1:2;
  190. /** Session End Detected */
  191. unsigned sesenddet:1;
  192. unsigned reserved3_7:5;
  193. /** Session Request Success Status Change */
  194. unsigned sesreqsucstschng:1;
  195. /** Host Negotiation Success Status Change */
  196. unsigned hstnegsucstschng:1;
  197. unsigned reserved10_16:7;
  198. /** Host Negotiation Detected */
  199. unsigned hstnegdet:1;
  200. /** A-Device Timeout Change */
  201. unsigned adevtoutchng:1;
  202. /** Debounce Done */
  203. unsigned debdone:1;
  204. /** Multi-Valued input changed */
  205. unsigned mvic:1;
  206. unsigned reserved31_21:11;
  207. } b;
  208. } gotgint_data_t;
  209. /**
  210. * This union represents the bit fields of the Core AHB Configuration
  211. * Register (GAHBCFG). Set/clear the bits using the bit fields then
  212. * write the <i>d32</i> value to the register.
  213. */
  214. typedef union gahbcfg_data {
  215. /** raw register data */
  216. uint32_t d32;
  217. /** register bits */
  218. struct {
  219. unsigned glblintrmsk:1;
  220. #define DWC_GAHBCFG_GLBINT_ENABLE 1
  221. unsigned hburstlen:4;
  222. #define DWC_GAHBCFG_INT_DMA_BURST_SINGLE 0
  223. #define DWC_GAHBCFG_INT_DMA_BURST_INCR 1
  224. #define DWC_GAHBCFG_INT_DMA_BURST_INCR4 3
  225. #define DWC_GAHBCFG_INT_DMA_BURST_INCR8 5
  226. #define DWC_GAHBCFG_INT_DMA_BURST_INCR16 7
  227. unsigned dmaenable:1;
  228. #define DWC_GAHBCFG_DMAENABLE 1
  229. unsigned reserved:1;
  230. unsigned nptxfemplvl_txfemplvl:1;
  231. unsigned ptxfemplvl:1;
  232. #define DWC_GAHBCFG_TXFEMPTYLVL_EMPTY 1
  233. #define DWC_GAHBCFG_TXFEMPTYLVL_HALFEMPTY 0
  234. unsigned reserved9_20:12;
  235. unsigned remmemsupp:1;
  236. unsigned notialldmawrit:1;
  237. unsigned ahbsingle:1;
  238. unsigned reserved24_31:8;
  239. } b;
  240. } gahbcfg_data_t;
  241. /**
  242. * This union represents the bit fields of the Core USB Configuration
  243. * Register (GUSBCFG). Set the bits using the bit fields then write
  244. * the <i>d32</i> value to the register.
  245. */
  246. typedef union gusbcfg_data {
  247. /** raw register data */
  248. uint32_t d32;
  249. /** register bits */
  250. struct {
  251. unsigned toutcal:3;
  252. unsigned phyif:1;
  253. unsigned ulpi_utmi_sel:1;
  254. unsigned fsintf:1;
  255. unsigned physel:1;
  256. unsigned ddrsel:1;
  257. unsigned srpcap:1;
  258. unsigned hnpcap:1;
  259. unsigned usbtrdtim:4;
  260. unsigned reserved1:1;
  261. unsigned phylpwrclksel:1;
  262. unsigned otgutmifssel:1;
  263. unsigned ulpi_fsls:1;
  264. unsigned ulpi_auto_res:1;
  265. unsigned ulpi_clk_sus_m:1;
  266. unsigned ulpi_ext_vbus_drv:1;
  267. unsigned ulpi_int_vbus_indicator:1;
  268. unsigned term_sel_dl_pulse:1;
  269. unsigned indicator_complement:1;
  270. unsigned indicator_pass_through:1;
  271. unsigned ulpi_int_prot_dis:1;
  272. unsigned ic_usb_cap:1;
  273. unsigned ic_traffic_pull_remove:1;
  274. unsigned tx_end_delay:1;
  275. unsigned force_host_mode:1;
  276. unsigned force_dev_mode:1;
  277. unsigned reserved31:1;
  278. } b;
  279. } gusbcfg_data_t;
  280. /**
  281. * This union represents the bit fields of the Core Reset Register
  282. * (GRSTCTL). Set/clear the bits using the bit fields then write the
  283. * <i>d32</i> value to the register.
  284. */
  285. typedef union grstctl_data {
  286. /** raw register data */
  287. uint32_t d32;
  288. /** register bits */
  289. struct {
  290. /** Core Soft Reset (CSftRst) (Device and Host)
  291. *
  292. * The application can flush the control logic in the
  293. * entire core using this bit. This bit resets the
  294. * pipelines in the AHB Clock domain as well as the
  295. * PHY Clock domain.
  296. *
  297. * The state machines are reset to an IDLE state, the
  298. * control bits in the CSRs are cleared, all the
  299. * transmit FIFOs and the receive FIFO are flushed.
  300. *
  301. * The status mask bits that control the generation of
  302. * the interrupt, are cleared, to clear the
  303. * interrupt. The interrupt status bits are not
  304. * cleared, so the application can get the status of
  305. * any events that occurred in the core after it has
  306. * set this bit.
  307. *
  308. * Any transactions on the AHB are terminated as soon
  309. * as possible following the protocol. Any
  310. * transactions on the USB are terminated immediately.
  311. *
  312. * The configuration settings in the CSRs are
  313. * unchanged, so the software doesn't have to
  314. * reprogram these registers (Device
  315. * Configuration/Host Configuration/Core System
  316. * Configuration/Core PHY Configuration).
  317. *
  318. * The application can write to this bit, any time it
  319. * wants to reset the core. This is a self clearing
  320. * bit and the core clears this bit after all the
  321. * necessary logic is reset in the core, which may
  322. * take several clocks, depending on the current state
  323. * of the core.
  324. */
  325. unsigned csftrst:1;
  326. /** Hclk Soft Reset
  327. *
  328. * The application uses this bit to reset the control logic in
  329. * the AHB clock domain. Only AHB clock domain pipelines are
  330. * reset.
  331. */
  332. unsigned hsftrst:1;
  333. /** Host Frame Counter Reset (Host Only)<br>
  334. *
  335. * The application can reset the (micro)frame number
  336. * counter inside the core, using this bit. When the
  337. * (micro)frame counter is reset, the subsequent SOF
  338. * sent out by the core, will have a (micro)frame
  339. * number of 0.
  340. */
  341. unsigned hstfrm:1;
  342. /** In Token Sequence Learning Queue Flush
  343. * (INTknQFlsh) (Device Only)
  344. */
  345. unsigned intknqflsh:1;
  346. /** RxFIFO Flush (RxFFlsh) (Device and Host)
  347. *
  348. * The application can flush the entire Receive FIFO
  349. * using this bit. The application must first
  350. * ensure that the core is not in the middle of a
  351. * transaction. The application should write into
  352. * this bit, only after making sure that neither the
  353. * DMA engine is reading from the RxFIFO nor the MAC
  354. * is writing the data in to the FIFO. The
  355. * application should wait until the bit is cleared
  356. * before performing any other operations. This bit
  357. * will takes 8 clocks (slowest of PHY or AHB clock)
  358. * to clear.
  359. */
  360. unsigned rxfflsh:1;
  361. /** TxFIFO Flush (TxFFlsh) (Device and Host).
  362. *
  363. * This bit is used to selectively flush a single or
  364. * all transmit FIFOs. The application must first
  365. * ensure that the core is not in the middle of a
  366. * transaction. The application should write into
  367. * this bit, only after making sure that neither the
  368. * DMA engine is writing into the TxFIFO nor the MAC
  369. * is reading the data out of the FIFO. The
  370. * application should wait until the core clears this
  371. * bit, before performing any operations. This bit
  372. * will takes 8 clocks (slowest of PHY or AHB clock)
  373. * to clear.
  374. */
  375. unsigned txfflsh:1;
  376. /** TxFIFO Number (TxFNum) (Device and Host).
  377. *
  378. * This is the FIFO number which needs to be flushed,
  379. * using the TxFIFO Flush bit. This field should not
  380. * be changed until the TxFIFO Flush bit is cleared by
  381. * the core.
  382. * - 0x0 : Non Periodic TxFIFO Flush
  383. * - 0x1 : Periodic TxFIFO #1 Flush in device mode
  384. * or Periodic TxFIFO in host mode
  385. * - 0x2 : Periodic TxFIFO #2 Flush in device mode.
  386. * - ...
  387. * - 0xF : Periodic TxFIFO #15 Flush in device mode
  388. * - 0x10: Flush all the Transmit NonPeriodic and
  389. * Transmit Periodic FIFOs in the core
  390. */
  391. unsigned txfnum:5;
  392. /** Reserved */
  393. unsigned reserved11_29:19;
  394. /** DMA Request Signal. Indicated DMA request is in
  395. * probress. Used for debug purpose. */
  396. unsigned dmareq:1;
  397. /** AHB Master Idle. Indicates the AHB Master State
  398. * Machine is in IDLE condition. */
  399. unsigned ahbidle:1;
  400. } b;
  401. } grstctl_t;
  402. /**
  403. * This union represents the bit fields of the Core Interrupt Mask
  404. * Register (GINTMSK). Set/clear the bits using the bit fields then
  405. * write the <i>d32</i> value to the register.
  406. */
  407. typedef union gintmsk_data {
  408. /** raw register data */
  409. uint32_t d32;
  410. /** register bits */
  411. struct {
  412. unsigned reserved0:1;
  413. unsigned modemismatch:1;
  414. unsigned otgintr:1;
  415. unsigned sofintr:1;
  416. unsigned rxstsqlvl:1;
  417. unsigned nptxfempty:1;
  418. unsigned ginnakeff:1;
  419. unsigned goutnakeff:1;
  420. unsigned ulpickint:1;
  421. unsigned i2cintr:1;
  422. unsigned erlysuspend:1;
  423. unsigned usbsuspend:1;
  424. unsigned usbreset:1;
  425. unsigned enumdone:1;
  426. unsigned isooutdrop:1;
  427. unsigned eopframe:1;
  428. unsigned restoredone:1;
  429. unsigned epmismatch:1;
  430. unsigned inepintr:1;
  431. unsigned outepintr:1;
  432. unsigned incomplisoin:1;
  433. unsigned incomplisoout:1;
  434. unsigned fetsusp:1;
  435. unsigned resetdet:1;
  436. unsigned portintr:1;
  437. unsigned hcintr:1;
  438. unsigned ptxfempty:1;
  439. unsigned lpmtranrcvd:1;
  440. unsigned conidstschng:1;
  441. unsigned disconnect:1;
  442. unsigned sessreqintr:1;
  443. unsigned wkupintr:1;
  444. } b;
  445. } gintmsk_data_t;
  446. /**
  447. * This union represents the bit fields of the Core Interrupt Register
  448. * (GINTSTS). Set/clear the bits using the bit fields then write the
  449. * <i>d32</i> value to the register.
  450. */
  451. typedef union gintsts_data {
  452. /** raw register data */
  453. uint32_t d32;
  454. #define DWC_SOF_INTR_MASK 0x0008
  455. /** register bits */
  456. struct {
  457. #define DWC_HOST_MODE 1
  458. unsigned curmode:1;
  459. unsigned modemismatch:1;
  460. unsigned otgintr:1;
  461. unsigned sofintr:1;
  462. unsigned rxstsqlvl:1;
  463. unsigned nptxfempty:1;
  464. unsigned ginnakeff:1;
  465. unsigned goutnakeff:1;
  466. unsigned ulpickint:1;
  467. unsigned i2cintr:1;
  468. unsigned erlysuspend:1;
  469. unsigned usbsuspend:1;
  470. unsigned usbreset:1;
  471. unsigned enumdone:1;
  472. unsigned isooutdrop:1;
  473. unsigned eopframe:1;
  474. unsigned restoredone:1;
  475. unsigned epmismatch:1;
  476. unsigned inepint:1;
  477. unsigned outepintr:1;
  478. unsigned incomplisoin:1;
  479. unsigned incomplisoout:1;
  480. unsigned fetsusp:1;
  481. unsigned resetdet:1;
  482. unsigned portintr:1;
  483. unsigned hcintr:1;
  484. unsigned ptxfempty:1;
  485. unsigned lpmtranrcvd:1;
  486. unsigned conidstschng:1;
  487. unsigned disconnect:1;
  488. unsigned sessreqintr:1;
  489. unsigned wkupintr:1;
  490. } b;
  491. } gintsts_data_t;
  492. /**
  493. * This union represents the bit fields in the Device Receive Status Read and
  494. * Pop Registers (GRXSTSR, GRXSTSP) Read the register into the <i>d32</i>
  495. * element then read out the bits using the <i>b</i>it elements.
  496. */
  497. typedef union device_grxsts_data {
  498. /** raw register data */
  499. uint32_t d32;
  500. /** register bits */
  501. struct {
  502. unsigned epnum:4;
  503. unsigned bcnt:11;
  504. unsigned dpid:2;
  505. #define DWC_STS_DATA_UPDT 0x2 // OUT Data Packet
  506. #define DWC_STS_XFER_COMP 0x3 // OUT Data Transfer Complete
  507. #define DWC_DSTS_GOUT_NAK 0x1 // Global OUT NAK
  508. #define DWC_DSTS_SETUP_COMP 0x4 // Setup Phase Complete
  509. #define DWC_DSTS_SETUP_UPDT 0x6 // SETUP Packet
  510. unsigned pktsts:4;
  511. unsigned fn:4;
  512. unsigned reserved25_31:7;
  513. } b;
  514. } device_grxsts_data_t;
  515. /**
  516. * This union represents the bit fields in the Host Receive Status Read and
  517. * Pop Registers (GRXSTSR, GRXSTSP) Read the register into the <i>d32</i>
  518. * element then read out the bits using the <i>b</i>it elements.
  519. */
  520. typedef union host_grxsts_data {
  521. /** raw register data */
  522. uint32_t d32;
  523. /** register bits */
  524. struct {
  525. unsigned chnum:4;
  526. unsigned bcnt:11;
  527. unsigned dpid:2;
  528. unsigned pktsts:4;
  529. #define DWC_GRXSTS_PKTSTS_IN 0x2
  530. #define DWC_GRXSTS_PKTSTS_IN_XFER_COMP 0x3
  531. #define DWC_GRXSTS_PKTSTS_DATA_TOGGLE_ERR 0x5
  532. #define DWC_GRXSTS_PKTSTS_CH_HALTED 0x7
  533. unsigned reserved21_31:11;
  534. } b;
  535. } host_grxsts_data_t;
  536. /**
  537. * This union represents the bit fields in the FIFO Size Registers (HPTXFSIZ,
  538. * GNPTXFSIZ, DPTXFSIZn, DIEPTXFn). Read the register into the <i>d32</i> element
  539. * then read out the bits using the <i>b</i>it elements.
  540. */
  541. typedef union fifosize_data {
  542. /** raw register data */
  543. uint32_t d32;
  544. /** register bits */
  545. struct {
  546. unsigned startaddr:16;
  547. unsigned depth:16;
  548. } b;
  549. } fifosize_data_t;
  550. /**
  551. * This union represents the bit fields in the Non-Periodic Transmit
  552. * FIFO/Queue Status Register (GNPTXSTS). Read the register into the
  553. * <i>d32</i> element then read out the bits using the <i>b</i>it
  554. * elements.
  555. */
  556. typedef union gnptxsts_data {
  557. /** raw register data */
  558. uint32_t d32;
  559. /** register bits */
  560. struct {
  561. unsigned nptxfspcavail:16;
  562. unsigned nptxqspcavail:8;
  563. /** Top of the Non-Periodic Transmit Request Queue
  564. * - bit 24 - Terminate (Last entry for the selected
  565. * channel/EP)
  566. * - bits 26:25 - Token Type
  567. * - 2'b00 - IN/OUT
  568. * - 2'b01 - Zero Length OUT
  569. * - 2'b10 - PING/Complete Split
  570. * - 2'b11 - Channel Halt
  571. * - bits 30:27 - Channel/EP Number
  572. */
  573. unsigned nptxqtop_terminate:1;
  574. unsigned nptxqtop_token:2;
  575. unsigned nptxqtop_chnep:4;
  576. unsigned reserved:1;
  577. } b;
  578. } gnptxsts_data_t;
  579. /**
  580. * This union represents the bit fields in the Transmit
  581. * FIFO Status Register (DTXFSTS). Read the register into the
  582. * <i>d32</i> element then read out the bits using the <i>b</i>it
  583. * elements.
  584. */
  585. typedef union dtxfsts_data {
  586. /** raw register data */
  587. uint32_t d32;
  588. /** register bits */
  589. struct {
  590. unsigned txfspcavail:16;
  591. unsigned reserved:16;
  592. } b;
  593. } dtxfsts_data_t;
  594. /**
  595. * This union represents the bit fields in the I2C Control Register
  596. * (I2CCTL). Read the register into the <i>d32</i> element then read out the
  597. * bits using the <i>b</i>it elements.
  598. */
  599. typedef union gi2cctl_data {
  600. /** raw register data */
  601. uint32_t d32;
  602. /** register bits */
  603. struct {
  604. unsigned rwdata:8;
  605. unsigned regaddr:8;
  606. unsigned addr:7;
  607. unsigned i2cen:1;
  608. unsigned ack:1;
  609. unsigned i2csuspctl:1;
  610. unsigned i2cdevaddr:2;
  611. unsigned i2cdatse0:1;
  612. unsigned reserved:1;
  613. unsigned rw:1;
  614. unsigned bsydne:1;
  615. } b;
  616. } gi2cctl_data_t;
  617. /**
  618. * This union represents the bit fields in the PHY Vendor Control Register
  619. * (GPVNDCTL). Read the register into the <i>d32</i> element then read out the
  620. * bits using the <i>b</i>it elements.
  621. */
  622. typedef union gpvndctl_data {
  623. /** raw register data */
  624. uint32_t d32;
  625. /** register bits */
  626. struct {
  627. unsigned regdata:8;
  628. unsigned vctrl:8;
  629. unsigned regaddr16_21:6;
  630. unsigned regwr:1;
  631. unsigned reserved23_24:2;
  632. unsigned newregreq:1;
  633. unsigned vstsbsy:1;
  634. unsigned vstsdone:1;
  635. unsigned reserved28_30:3;
  636. unsigned disulpidrvr:1;
  637. } b;
  638. } gpvndctl_data_t;
  639. /**
  640. * This union represents the bit fields in the General Purpose
  641. * Input/Output Register (GGPIO).
  642. * Read the register into the <i>d32</i> element then read out the
  643. * bits using the <i>b</i>it elements.
  644. */
  645. typedef union ggpio_data {
  646. /** raw register data */
  647. uint32_t d32;
  648. /** register bits */
  649. struct {
  650. unsigned gpi:16;
  651. unsigned gpo:16;
  652. } b;
  653. } ggpio_data_t;
  654. /**
  655. * This union represents the bit fields in the User ID Register
  656. * (GUID). Read the register into the <i>d32</i> element then read out the
  657. * bits using the <i>b</i>it elements.
  658. */
  659. typedef union guid_data {
  660. /** raw register data */
  661. uint32_t d32;
  662. /** register bits */
  663. struct {
  664. unsigned rwdata:32;
  665. } b;
  666. } guid_data_t;
  667. /**
  668. * This union represents the bit fields in the Synopsys ID Register
  669. * (GSNPSID). Read the register into the <i>d32</i> element then read out the
  670. * bits using the <i>b</i>it elements.
  671. */
  672. typedef union gsnpsid_data {
  673. /** raw register data */
  674. uint32_t d32;
  675. /** register bits */
  676. struct {
  677. unsigned rwdata:32;
  678. } b;
  679. } gsnpsid_data_t;
  680. /**
  681. * This union represents the bit fields in the User HW Config1
  682. * Register. Read the register into the <i>d32</i> element then read
  683. * out the bits using the <i>b</i>it elements.
  684. */
  685. typedef union hwcfg1_data {
  686. /** raw register data */
  687. uint32_t d32;
  688. /** register bits */
  689. struct {
  690. unsigned ep_dir0:2;
  691. unsigned ep_dir1:2;
  692. unsigned ep_dir2:2;
  693. unsigned ep_dir3:2;
  694. unsigned ep_dir4:2;
  695. unsigned ep_dir5:2;
  696. unsigned ep_dir6:2;
  697. unsigned ep_dir7:2;
  698. unsigned ep_dir8:2;
  699. unsigned ep_dir9:2;
  700. unsigned ep_dir10:2;
  701. unsigned ep_dir11:2;
  702. unsigned ep_dir12:2;
  703. unsigned ep_dir13:2;
  704. unsigned ep_dir14:2;
  705. unsigned ep_dir15:2;
  706. } b;
  707. } hwcfg1_data_t;
  708. /**
  709. * This union represents the bit fields in the User HW Config2
  710. * Register. Read the register into the <i>d32</i> element then read
  711. * out the bits using the <i>b</i>it elements.
  712. */
  713. typedef union hwcfg2_data {
  714. /** raw register data */
  715. uint32_t d32;
  716. /** register bits */
  717. struct {
  718. /* GHWCFG2 */
  719. unsigned op_mode:3;
  720. #define DWC_HWCFG2_OP_MODE_HNP_SRP_CAPABLE_OTG 0
  721. #define DWC_HWCFG2_OP_MODE_SRP_ONLY_CAPABLE_OTG 1
  722. #define DWC_HWCFG2_OP_MODE_NO_HNP_SRP_CAPABLE_OTG 2
  723. #define DWC_HWCFG2_OP_MODE_SRP_CAPABLE_DEVICE 3
  724. #define DWC_HWCFG2_OP_MODE_NO_SRP_CAPABLE_DEVICE 4
  725. #define DWC_HWCFG2_OP_MODE_SRP_CAPABLE_HOST 5
  726. #define DWC_HWCFG2_OP_MODE_NO_SRP_CAPABLE_HOST 6
  727. unsigned architecture:2;
  728. unsigned point2point:1;
  729. unsigned hs_phy_type:2;
  730. #define DWC_HWCFG2_HS_PHY_TYPE_NOT_SUPPORTED 0
  731. #define DWC_HWCFG2_HS_PHY_TYPE_UTMI 1
  732. #define DWC_HWCFG2_HS_PHY_TYPE_ULPI 2
  733. #define DWC_HWCFG2_HS_PHY_TYPE_UTMI_ULPI 3
  734. unsigned fs_phy_type:2;
  735. unsigned num_dev_ep:4;
  736. unsigned num_host_chan:4;
  737. unsigned perio_ep_supported:1;
  738. unsigned dynamic_fifo:1;
  739. unsigned multi_proc_int:1;
  740. unsigned reserved21:1;
  741. unsigned nonperio_tx_q_depth:2;
  742. unsigned host_perio_tx_q_depth:2;
  743. unsigned dev_token_q_depth:5;
  744. unsigned otg_enable_ic_usb:1;
  745. } b;
  746. } hwcfg2_data_t;
  747. /**
  748. * This union represents the bit fields in the User HW Config3
  749. * Register. Read the register into the <i>d32</i> element then read
  750. * out the bits using the <i>b</i>it elements.
  751. */
  752. typedef union hwcfg3_data {
  753. /** raw register data */
  754. uint32_t d32;
  755. /** register bits */
  756. struct {
  757. /* GHWCFG3 */
  758. unsigned xfer_size_cntr_width:4;
  759. unsigned packet_size_cntr_width:3;
  760. unsigned otg_func:1;
  761. unsigned i2c:1;
  762. unsigned vendor_ctrl_if:1;
  763. unsigned optional_features:1;
  764. unsigned synch_reset_type:1;
  765. unsigned adp_supp:1;
  766. unsigned otg_enable_hsic:1;
  767. unsigned bc_support:1;
  768. unsigned otg_lpm_en:1;
  769. unsigned dfifo_depth:16;
  770. } b;
  771. } hwcfg3_data_t;
  772. /**
  773. * This union represents the bit fields in the User HW Config4
  774. * Register. Read the register into the <i>d32</i> element then read
  775. * out the bits using the <i>b</i>it elements.
  776. */
  777. typedef union hwcfg4_data {
  778. /** raw register data */
  779. uint32_t d32;
  780. /** register bits */
  781. struct {
  782. unsigned num_dev_perio_in_ep:4;
  783. unsigned power_optimiz:1;
  784. unsigned min_ahb_freq:1;
  785. unsigned part_power_down:1;
  786. unsigned reserved:7;
  787. unsigned utmi_phy_data_width:2;
  788. unsigned num_dev_mode_ctrl_ep:4;
  789. unsigned iddig_filt_en:1;
  790. unsigned vbus_valid_filt_en:1;
  791. unsigned a_valid_filt_en:1;
  792. unsigned b_valid_filt_en:1;
  793. unsigned session_end_filt_en:1;
  794. unsigned ded_fifo_en:1;
  795. unsigned num_in_eps:4;
  796. unsigned desc_dma:1;
  797. unsigned desc_dma_dyn:1;
  798. } b;
  799. } hwcfg4_data_t;
  800. /**
  801. * This union represents the bit fields of the Core LPM Configuration
  802. * Register (GLPMCFG). Set the bits using bit fields then write
  803. * the <i>d32</i> value to the register.
  804. */
  805. typedef union glpmctl_data {
  806. /** raw register data */
  807. uint32_t d32;
  808. /** register bits */
  809. struct {
  810. /** LPM-Capable (LPMCap) (Device and Host)
  811. * The application uses this bit to control
  812. * the DWC_otg core LPM capabilities.
  813. */
  814. unsigned lpm_cap_en:1;
  815. /** LPM response programmed by application (AppL1Res) (Device)
  816. * Handshake response to LPM token pre-programmed
  817. * by device application software.
  818. */
  819. unsigned appl_resp:1;
  820. /** Host Initiated Resume Duration (HIRD) (Device and Host)
  821. * In Host mode this field indicates the value of HIRD
  822. * to be sent in an LPM transaction.
  823. * In Device mode this field is updated with the
  824. * Received LPM Token HIRD bmAttribute
  825. * when an ACK/NYET/STALL response is sent
  826. * to an LPM transaction.
  827. */
  828. unsigned hird:4;
  829. /** RemoteWakeEnable (bRemoteWake) (Device and Host)
  830. * In Host mode this bit indicates the value of remote
  831. * wake up to be sent in wIndex field of LPM transaction.
  832. * In Device mode this field is updated with the
  833. * Received LPM Token bRemoteWake bmAttribute
  834. * when an ACK/NYET/STALL response is sent
  835. * to an LPM transaction.
  836. */
  837. unsigned rem_wkup_en:1;
  838. /** Enable utmi_sleep_n (EnblSlpM) (Device and Host)
  839. * The application uses this bit to control
  840. * the utmi_sleep_n assertion to the PHY when in L1 state.
  841. */
  842. unsigned en_utmi_sleep:1;
  843. /** HIRD Threshold (HIRD_Thres) (Device and Host)
  844. */
  845. unsigned hird_thres:5;
  846. /** LPM Response (CoreL1Res) (Device and Host)
  847. * In Host mode this bit contains handsake response to
  848. * LPM transaction.
  849. * In Device mode the response of the core to
  850. * LPM transaction received is reflected in these two bits.
  851. - 0x0 : ERROR (No handshake response)
  852. - 0x1 : STALL
  853. - 0x2 : NYET
  854. - 0x3 : ACK
  855. */
  856. unsigned lpm_resp:2;
  857. /** Port Sleep Status (SlpSts) (Device and Host)
  858. * This bit is set as long as a Sleep condition
  859. * is present on the USB bus.
  860. */
  861. unsigned prt_sleep_sts:1;
  862. /** Sleep State Resume OK (L1ResumeOK) (Device and Host)
  863. * Indicates that the application or host
  864. * can start resume from Sleep state.
  865. */
  866. unsigned sleep_state_resumeok:1;
  867. /** LPM channel Index (LPM_Chnl_Indx) (Host)
  868. * The channel number on which the LPM transaction
  869. * has to be applied while sending
  870. * an LPM transaction to the local device.
  871. */
  872. unsigned lpm_chan_index:4;
  873. /** LPM Retry Count (LPM_Retry_Cnt) (Host)
  874. * Number host retries that would be performed
  875. * if the device response was not valid response.
  876. */
  877. unsigned retry_count:3;
  878. /** Send LPM Transaction (SndLPM) (Host)
  879. * When set by application software,
  880. * an LPM transaction containing two tokens
  881. * is sent.
  882. */
  883. unsigned send_lpm:1;
  884. /** LPM Retry status (LPM_RetryCnt_Sts) (Host)
  885. * Number of LPM Host Retries still remaining
  886. * to be transmitted for the current LPM sequence
  887. */
  888. unsigned retry_count_sts:3;
  889. unsigned reserved28_29:2;
  890. /** In host mode once this bit is set, the host
  891. * configures to drive the HSIC Idle state on the bus.
  892. * It then waits for the device to initiate the Connect sequence.
  893. * In device mode once this bit is set, the device waits for
  894. * the HSIC Idle line state on the bus. Upon receving the Idle
  895. * line state, it initiates the HSIC Connect sequence.
  896. */
  897. unsigned hsic_connect:1;
  898. /** This bit overrides and functionally inverts
  899. * the if_select_hsic input port signal.
  900. */
  901. unsigned inv_sel_hsic:1;
  902. } b;
  903. } glpmcfg_data_t;
  904. /**
  905. * This union represents the bit fields of the Core ADP Timer, Control and
  906. * Status Register (ADPTIMCTLSTS). Set the bits using bit fields then write
  907. * the <i>d32</i> value to the register.
  908. */
  909. typedef union adpctl_data {
  910. /** raw register data */
  911. uint32_t d32;
  912. /** register bits */
  913. struct {
  914. /** Probe Discharge (PRB_DSCHG)
  915. * These bits set the times for TADP_DSCHG.
  916. * These bits are defined as follows:
  917. * 2'b00 - 4 msec
  918. * 2'b01 - 8 msec
  919. * 2'b10 - 16 msec
  920. * 2'b11 - 32 msec
  921. */
  922. unsigned prb_dschg:2;
  923. /** Probe Delta (PRB_DELTA)
  924. * These bits set the resolution for RTIM value.
  925. * The bits are defined in units of 32 kHz clock cycles as follows:
  926. * 2'b00 - 1 cycles
  927. * 2'b01 - 2 cycles
  928. * 2'b10 - 3 cycles
  929. * 2'b11 - 4 cycles
  930. * For example if this value is chosen to 2'b01, it means that RTIM
  931. * increments for every 3(three) 32Khz clock cycles.
  932. */
  933. unsigned prb_delta:2;
  934. /** Probe Period (PRB_PER)
  935. * These bits sets the TADP_PRD as shown in Figure 4 as follows:
  936. * 2'b00 - 0.625 to 0.925 sec (typical 0.775 sec)
  937. * 2'b01 - 1.25 to 1.85 sec (typical 1.55 sec)
  938. * 2'b10 - 1.9 to 2.6 sec (typical 2.275 sec)
  939. * 2'b11 - Reserved
  940. */
  941. unsigned prb_per:2;
  942. /** These bits capture the latest time it took for VBUS to ramp from
  943. * VADP_SINK to VADP_PRB.
  944. * 0x000 - 1 cycles
  945. * 0x001 - 2 cycles
  946. * 0x002 - 3 cycles
  947. * etc
  948. * 0x7FF - 2048 cycles
  949. * A time of 1024 cycles at 32 kHz corresponds to a time of 32 msec.
  950. */
  951. unsigned rtim:11;
  952. /** Enable Probe (EnaPrb)
  953. * When programmed to 1'b1, the core performs a probe operation.
  954. * This bit is valid only if OTG_Ver = 1'b1.
  955. */
  956. unsigned enaprb:1;
  957. /** Enable Sense (EnaSns)
  958. * When programmed to 1'b1, the core performs a Sense operation.
  959. * This bit is valid only if OTG_Ver = 1'b1.
  960. */
  961. unsigned enasns:1;
  962. /** ADP Reset (ADPRes)
  963. * When set, ADP controller is reset.
  964. * This bit is valid only if OTG_Ver = 1'b1.
  965. */
  966. unsigned adpres:1;
  967. /** ADP Enable (ADPEn)
  968. * When set, the core performs either ADP probing or sensing
  969. * based on EnaPrb or EnaSns.
  970. * This bit is valid only if OTG_Ver = 1'b1.
  971. */
  972. unsigned adpen:1;
  973. /** ADP Probe Interrupt (ADP_PRB_INT)
  974. * When this bit is set, it means that the VBUS
  975. * voltage is greater than VADP_PRB or VADP_PRB is reached.
  976. * This bit is valid only if OTG_Ver = 1'b1.
  977. */
  978. unsigned adp_prb_int:1;
  979. /**
  980. * ADP Sense Interrupt (ADP_SNS_INT)
  981. * When this bit is set, it means that the VBUS voltage is greater than
  982. * VADP_SNS value or VADP_SNS is reached.
  983. * This bit is valid only if OTG_Ver = 1'b1.
  984. */
  985. unsigned adp_sns_int:1;
  986. /** ADP Tomeout Interrupt (ADP_TMOUT_INT)
  987. * This bit is relevant only for an ADP probe.
  988. * When this bit is set, it means that the ramp time has
  989. * completed ie ADPCTL.RTIM has reached its terminal value
  990. * of 0x7FF. This is a debug feature that allows software
  991. * to read the ramp time after each cycle.
  992. * This bit is valid only if OTG_Ver = 1'b1.
  993. */
  994. unsigned adp_tmout_int:1;
  995. /** ADP Probe Interrupt Mask (ADP_PRB_INT_MSK)
  996. * When this bit is set, it unmasks the interrupt due to ADP_PRB_INT.
  997. * This bit is valid only if OTG_Ver = 1'b1.
  998. */
  999. unsigned adp_prb_int_msk:1;
  1000. /** ADP Sense Interrupt Mask (ADP_SNS_INT_MSK)
  1001. * When this bit is set, it unmasks the interrupt due to ADP_SNS_INT.
  1002. * This bit is valid only if OTG_Ver = 1'b1.
  1003. */
  1004. unsigned adp_sns_int_msk:1;
  1005. /** ADP Timoeout Interrupt Mask (ADP_TMOUT_MSK)
  1006. * When this bit is set, it unmasks the interrupt due to ADP_TMOUT_INT.
  1007. * This bit is valid only if OTG_Ver = 1'b1.
  1008. */
  1009. unsigned adp_tmout_int_msk:1;
  1010. /** Access Request
  1011. * 2'b00 - Read/Write Valid (updated by the core)
  1012. * 2'b01 - Read
  1013. * 2'b00 - Write
  1014. * 2'b00 - Reserved
  1015. */
  1016. unsigned ar:2;
  1017. /** Reserved */
  1018. unsigned reserved29_31:3;
  1019. } b;
  1020. } adpctl_data_t;
  1021. ////////////////////////////////////////////
  1022. // Device Registers
  1023. /**
  1024. * Device Global Registers. <i>Offsets 800h-BFFh</i>
  1025. *
  1026. * The following structures define the size and relative field offsets
  1027. * for the Device Mode Registers.
  1028. *
  1029. * <i>These registers are visible only in Device mode and must not be
  1030. * accessed in Host mode, as the results are unknown.</i>
  1031. */
  1032. typedef struct dwc_otg_dev_global_regs {
  1033. /** Device Configuration Register. <i>Offset 800h</i> */
  1034. volatile uint32_t dcfg;
  1035. /** Device Control Register. <i>Offset: 804h</i> */
  1036. volatile uint32_t dctl;
  1037. /** Device Status Register (Read Only). <i>Offset: 808h</i> */
  1038. volatile uint32_t dsts;
  1039. /** Reserved. <i>Offset: 80Ch</i> */
  1040. uint32_t unused;
  1041. /** Device IN Endpoint Common Interrupt Mask
  1042. * Register. <i>Offset: 810h</i> */
  1043. volatile uint32_t diepmsk;
  1044. /** Device OUT Endpoint Common Interrupt Mask
  1045. * Register. <i>Offset: 814h</i> */
  1046. volatile uint32_t doepmsk;
  1047. /** Device All Endpoints Interrupt Register. <i>Offset: 818h</i> */
  1048. volatile uint32_t daint;
  1049. /** Device All Endpoints Interrupt Mask Register. <i>Offset:
  1050. * 81Ch</i> */
  1051. volatile uint32_t daintmsk;
  1052. /** Device IN Token Queue Read Register-1 (Read Only).
  1053. * <i>Offset: 820h</i> */
  1054. volatile uint32_t dtknqr1;
  1055. /** Device IN Token Queue Read Register-2 (Read Only).
  1056. * <i>Offset: 824h</i> */
  1057. volatile uint32_t dtknqr2;
  1058. /** Device VBUS discharge Register. <i>Offset: 828h</i> */
  1059. volatile uint32_t dvbusdis;
  1060. /** Device VBUS Pulse Register. <i>Offset: 82Ch</i> */
  1061. volatile uint32_t dvbuspulse;
  1062. /** Device IN Token Queue Read Register-3 (Read Only). /
  1063. * Device Thresholding control register (Read/Write)
  1064. * <i>Offset: 830h</i> */
  1065. volatile uint32_t dtknqr3_dthrctl;
  1066. /** Device IN Token Queue Read Register-4 (Read Only). /
  1067. * Device IN EPs empty Inr. Mask Register (Read/Write)
  1068. * <i>Offset: 834h</i> */
  1069. volatile uint32_t dtknqr4_fifoemptymsk;
  1070. /** Device Each Endpoint Interrupt Register (Read Only). /
  1071. * <i>Offset: 838h</i> */
  1072. volatile uint32_t deachint;
  1073. /** Device Each Endpoint Interrupt mask Register (Read/Write). /
  1074. * <i>Offset: 83Ch</i> */
  1075. volatile uint32_t deachintmsk;
  1076. /** Device Each In Endpoint Interrupt mask Register (Read/Write). /
  1077. * <i>Offset: 840h</i> */
  1078. volatile uint32_t diepeachintmsk[MAX_EPS_CHANNELS];
  1079. /** Device Each Out Endpoint Interrupt mask Register (Read/Write). /
  1080. * <i>Offset: 880h</i> */
  1081. volatile uint32_t doepeachintmsk[MAX_EPS_CHANNELS];
  1082. } dwc_otg_device_global_regs_t;
  1083. /**
  1084. * This union represents the bit fields in the Device Configuration
  1085. * Register. Read the register into the <i>d32</i> member then
  1086. * set/clear the bits using the <i>b</i>it elements. Write the
  1087. * <i>d32</i> member to the dcfg register.
  1088. */
  1089. typedef union dcfg_data {
  1090. /** raw register data */
  1091. uint32_t d32;
  1092. /** register bits */
  1093. struct {
  1094. /** Device Speed */
  1095. unsigned devspd:2;
  1096. /** Non Zero Length Status OUT Handshake */
  1097. unsigned nzstsouthshk:1;
  1098. #define DWC_DCFG_SEND_STALL 1
  1099. unsigned ena32khzs:1;
  1100. /** Device Addresses */
  1101. unsigned devaddr:7;
  1102. /** Periodic Frame Interval */
  1103. unsigned perfrint:2;
  1104. #define DWC_DCFG_FRAME_INTERVAL_80 0
  1105. #define DWC_DCFG_FRAME_INTERVAL_85 1
  1106. #define DWC_DCFG_FRAME_INTERVAL_90 2
  1107. #define DWC_DCFG_FRAME_INTERVAL_95 3
  1108. /** Enable Device OUT NAK for bulk in DDMA mode */
  1109. unsigned endevoutnak:1;
  1110. unsigned reserved14_17:4;
  1111. /** In Endpoint Mis-match count */
  1112. unsigned epmscnt:5;
  1113. /** Enable Descriptor DMA in Device mode */
  1114. unsigned descdma:1;
  1115. unsigned perschintvl:2;
  1116. unsigned resvalid:6;
  1117. } b;
  1118. } dcfg_data_t;
  1119. /**
  1120. * This union represents the bit fields in the Device Control
  1121. * Register. Read the register into the <i>d32</i> member then
  1122. * set/clear the bits using the <i>b</i>it elements.
  1123. */
  1124. typedef union dctl_data {
  1125. /** raw register data */
  1126. uint32_t d32;
  1127. /** register bits */
  1128. struct {
  1129. /** Remote Wakeup */
  1130. unsigned rmtwkupsig:1;
  1131. /** Soft Disconnect */
  1132. unsigned sftdiscon:1;
  1133. /** Global Non-Periodic IN NAK Status */
  1134. unsigned gnpinnaksts:1;
  1135. /** Global OUT NAK Status */
  1136. unsigned goutnaksts:1;
  1137. /** Test Control */
  1138. unsigned tstctl:3;
  1139. /** Set Global Non-Periodic IN NAK */
  1140. unsigned sgnpinnak:1;
  1141. /** Clear Global Non-Periodic IN NAK */
  1142. unsigned cgnpinnak:1;
  1143. /** Set Global OUT NAK */
  1144. unsigned sgoutnak:1;
  1145. /** Clear Global OUT NAK */
  1146. unsigned cgoutnak:1;
  1147. /** Power-On Programming Done */
  1148. unsigned pwronprgdone:1;
  1149. /** Reserved */
  1150. unsigned reserved:1;
  1151. /** Global Multi Count */
  1152. unsigned gmc:2;
  1153. /** Ignore Frame Number for ISOC EPs */
  1154. unsigned ifrmnum:1;
  1155. /** NAK on Babble */
  1156. unsigned nakonbble:1;
  1157. /** Enable Continue on BNA */
  1158. unsigned encontonbna:1;
  1159. unsigned reserved18_31:14;
  1160. } b;
  1161. } dctl_data_t;
  1162. /**
  1163. * This union represents the bit fields in the Device Status
  1164. * Register. Read the register into the <i>d32</i> member then
  1165. * set/clear the bits using the <i>b</i>it elements.
  1166. */
  1167. typedef union dsts_data {
  1168. /** raw register data */
  1169. uint32_t d32;
  1170. /** register bits */
  1171. struct {
  1172. /** Suspend Status */
  1173. unsigned suspsts:1;
  1174. /** Enumerated Speed */
  1175. unsigned enumspd:2;
  1176. #define DWC_DSTS_ENUMSPD_HS_PHY_30MHZ_OR_60MHZ 0
  1177. #define DWC_DSTS_ENUMSPD_FS_PHY_30MHZ_OR_60MHZ 1
  1178. #define DWC_DSTS_ENUMSPD_LS_PHY_6MHZ 2
  1179. #define DWC_DSTS_ENUMSPD_FS_PHY_48MHZ 3
  1180. /** Erratic Error */
  1181. unsigned errticerr:1;
  1182. unsigned reserved4_7:4;
  1183. /** Frame or Microframe Number of the received SOF */
  1184. unsigned soffn:14;
  1185. unsigned reserved22_31:10;
  1186. } b;
  1187. } dsts_data_t;
  1188. /**
  1189. * This union represents the bit fields in the Device IN EP Interrupt
  1190. * Register and the Device IN EP Common Mask Register.
  1191. *
  1192. * - Read the register into the <i>d32</i> member then set/clear the
  1193. * bits using the <i>b</i>it elements.
  1194. */
  1195. typedef union diepint_data {
  1196. /** raw register data */
  1197. uint32_t d32;
  1198. /** register bits */
  1199. struct {
  1200. /** Transfer complete mask */
  1201. unsigned xfercompl:1;
  1202. /** Endpoint disable mask */
  1203. unsigned epdisabled:1;
  1204. /** AHB Error mask */
  1205. unsigned ahberr:1;
  1206. /** TimeOUT Handshake mask (non-ISOC EPs) */
  1207. unsigned timeout:1;
  1208. /** IN Token received with TxF Empty mask */
  1209. unsigned intktxfemp:1;
  1210. /** IN Token Received with EP mismatch mask */
  1211. unsigned intknepmis:1;
  1212. /** IN Endpoint NAK Effective mask */
  1213. unsigned inepnakeff:1;
  1214. /** Reserved */
  1215. unsigned emptyintr:1;
  1216. unsigned txfifoundrn:1;
  1217. /** BNA Interrupt mask */
  1218. unsigned bna:1;
  1219. unsigned reserved10_12:3;
  1220. /** BNA Interrupt mask */
  1221. unsigned nak:1;
  1222. unsigned reserved14_31:18;
  1223. } b;
  1224. } diepint_data_t;
  1225. /**
  1226. * This union represents the bit fields in the Device IN EP
  1227. * Common/Dedicated Interrupt Mask Register.
  1228. */
  1229. typedef union diepint_data diepmsk_data_t;
  1230. /**
  1231. * This union represents the bit fields in the Device OUT EP Interrupt
  1232. * Registerand Device OUT EP Common Interrupt Mask Register.
  1233. *
  1234. * - Read the register into the <i>d32</i> member then set/clear the
  1235. * bits using the <i>b</i>it elements.
  1236. */
  1237. typedef union doepint_data {
  1238. /** raw register data */
  1239. uint32_t d32;
  1240. /** register bits */
  1241. struct {
  1242. /** Transfer complete */
  1243. unsigned xfercompl:1;
  1244. /** Endpoint disable */
  1245. unsigned epdisabled:1;
  1246. /** AHB Error */
  1247. unsigned ahberr:1;
  1248. /** Setup Phase Done (contorl EPs) */
  1249. unsigned setup:1;
  1250. /** OUT Token Received when Endpoint Disabled */
  1251. unsigned outtknepdis:1;
  1252. unsigned stsphsercvd:1;
  1253. /** Back-to-Back SETUP Packets Received */
  1254. unsigned back2backsetup:1;
  1255. unsigned reserved7:1;
  1256. /** OUT packet Error */
  1257. unsigned outpkterr:1;
  1258. /** BNA Interrupt */
  1259. unsigned bna:1;
  1260. unsigned reserved10:1;
  1261. /** Packet Drop Status */
  1262. unsigned pktdrpsts:1;
  1263. /** Babble Interrupt */
  1264. unsigned babble:1;
  1265. /** NAK Interrupt */
  1266. unsigned nak:1;
  1267. /** NYET Interrupt */
  1268. unsigned nyet:1;
  1269. unsigned reserved15_31:17;
  1270. } b;
  1271. } doepint_data_t;
  1272. /**
  1273. * This union represents the bit fields in the Device OUT EP
  1274. * Common/Dedicated Interrupt Mask Register.
  1275. */
  1276. typedef union doepint_data doepmsk_data_t;
  1277. /**
  1278. * This union represents the bit fields in the Device All EP Interrupt
  1279. * and Mask Registers.
  1280. * - Read the register into the <i>d32</i> member then set/clear the
  1281. * bits using the <i>b</i>it elements.
  1282. */
  1283. typedef union daint_data {
  1284. /** raw register data */
  1285. uint32_t d32;
  1286. /** register bits */
  1287. struct {
  1288. /** IN Endpoint bits */
  1289. unsigned in:16;
  1290. /** OUT Endpoint bits */
  1291. unsigned out:16;
  1292. } ep;
  1293. struct {
  1294. /** IN Endpoint bits */
  1295. unsigned inep0:1;
  1296. unsigned inep1:1;
  1297. unsigned inep2:1;
  1298. unsigned inep3:1;
  1299. unsigned inep4:1;
  1300. unsigned inep5:1;
  1301. unsigned inep6:1;
  1302. unsigned inep7:1;
  1303. unsigned inep8:1;
  1304. unsigned inep9:1;
  1305. unsigned inep10:1;
  1306. unsigned inep11:1;
  1307. unsigned inep12:1;
  1308. unsigned inep13:1;
  1309. unsigned inep14:1;
  1310. unsigned inep15:1;
  1311. /** OUT Endpoint bits */
  1312. unsigned outep0:1;
  1313. unsigned outep1:1;
  1314. unsigned outep2:1;
  1315. unsigned outep3:1;
  1316. unsigned outep4:1;
  1317. unsigned outep5:1;
  1318. unsigned outep6:1;
  1319. unsigned outep7:1;
  1320. unsigned outep8:1;
  1321. unsigned outep9:1;
  1322. unsigned outep10:1;
  1323. unsigned outep11:1;
  1324. unsigned outep12:1;
  1325. unsigned outep13:1;
  1326. unsigned outep14:1;
  1327. unsigned outep15:1;
  1328. } b;
  1329. } daint_data_t;
  1330. /**
  1331. * This union represents the bit fields in the Device IN Token Queue
  1332. * Read Registers.
  1333. * - Read the register into the <i>d32</i> member.
  1334. * - READ-ONLY Register
  1335. */
  1336. typedef union dtknq1_data {
  1337. /** raw register data */
  1338. uint32_t d32;
  1339. /** register bits */
  1340. struct {
  1341. /** In Token Queue Write Pointer */
  1342. unsigned intknwptr:5;
  1343. /** Reserved */
  1344. unsigned reserved05_06:2;
  1345. /** write pointer has wrapped. */
  1346. unsigned wrap_bit:1;
  1347. /** EP Numbers of IN Tokens 0 ... 4 */
  1348. unsigned epnums0_5:24;
  1349. } b;
  1350. } dtknq1_data_t;
  1351. /**
  1352. * This union represents Threshold control Register
  1353. * - Read and write the register into the <i>d32</i> member.
  1354. * - READ-WRITABLE Register
  1355. */
  1356. typedef union dthrctl_data {
  1357. /** raw register data */
  1358. uint32_t d32;
  1359. /** register bits */
  1360. struct {
  1361. /** non ISO Tx Thr. Enable */
  1362. unsigned non_iso_thr_en:1;
  1363. /** ISO Tx Thr. Enable */
  1364. unsigned iso_thr_en:1;
  1365. /** Tx Thr. Length */
  1366. unsigned tx_thr_len:9;
  1367. /** AHB Threshold ratio */
  1368. unsigned ahb_thr_ratio:2;
  1369. /** Reserved */
  1370. unsigned reserved13_15:3;
  1371. /** Rx Thr. Enable */
  1372. unsigned rx_thr_en:1;
  1373. /** Rx Thr. Length */
  1374. unsigned rx_thr_len:9;
  1375. unsigned reserved26:1;
  1376. /** Arbiter Parking Enable*/
  1377. unsigned arbprken:1;
  1378. /** Reserved */
  1379. unsigned reserved28_31:4;
  1380. } b;
  1381. } dthrctl_data_t;
  1382. /**
  1383. * Device Logical IN Endpoint-Specific Registers. <i>Offsets
  1384. * 900h-AFCh</i>
  1385. *
  1386. * There will be one set of endpoint registers per logical endpoint
  1387. * implemented.
  1388. *
  1389. * <i>These registers are visible only in Device mode and must not be
  1390. * accessed in Host mode, as the results are unknown.</i>
  1391. */
  1392. typedef struct dwc_otg_dev_in_ep_regs {
  1393. /** Device IN Endpoint Control Register. <i>Offset:900h +
  1394. * (ep_num * 20h) + 00h</i> */
  1395. volatile uint32_t diepctl;
  1396. /** Reserved. <i>Offset:900h + (ep_num * 20h) + 04h</i> */
  1397. uint32_t reserved04;
  1398. /** Device IN Endpoint Interrupt Register. <i>Offset:900h +
  1399. * (ep_num * 20h) + 08h</i> */
  1400. volatile uint32_t diepint;
  1401. /** Reserved. <i>Offset:900h + (ep_num * 20h) + 0Ch</i> */
  1402. uint32_t reserved0C;
  1403. /** Device IN Endpoint Transfer Size
  1404. * Register. <i>Offset:900h + (ep_num * 20h) + 10h</i> */
  1405. volatile uint32_t dieptsiz;
  1406. /** Device IN Endpoint DMA Address Register. <i>Offset:900h +
  1407. * (ep_num * 20h) + 14h</i> */
  1408. volatile uint32_t diepdma;
  1409. /** Device IN Endpoint Transmit FIFO Status Register. <i>Offset:900h +
  1410. * (ep_num * 20h) + 18h</i> */
  1411. volatile uint32_t dtxfsts;
  1412. /** Device IN Endpoint DMA Buffer Register. <i>Offset:900h +
  1413. * (ep_num * 20h) + 1Ch</i> */
  1414. volatile uint32_t diepdmab;
  1415. } dwc_otg_dev_in_ep_regs_t;
  1416. /**
  1417. * Device Logical OUT Endpoint-Specific Registers. <i>Offsets:
  1418. * B00h-CFCh</i>
  1419. *
  1420. * There will be one set of endpoint registers per logical endpoint
  1421. * implemented.
  1422. *
  1423. * <i>These registers are visible only in Device mode and must not be
  1424. * accessed in Host mode, as the results are unknown.</i>
  1425. */
  1426. typedef struct dwc_otg_dev_out_ep_regs {
  1427. /** Device OUT Endpoint Control Register. <i>Offset:B00h +
  1428. * (ep_num * 20h) + 00h</i> */
  1429. volatile uint32_t doepctl;
  1430. /** Reserved. <i>Offset:B00h + (ep_num * 20h) + 04h</i> */
  1431. uint32_t reserved04;
  1432. /** Device OUT Endpoint Interrupt Register. <i>Offset:B00h +
  1433. * (ep_num * 20h) + 08h</i> */
  1434. volatile uint32_t doepint;
  1435. /** Reserved. <i>Offset:B00h + (ep_num * 20h) + 0Ch</i> */
  1436. uint32_t reserved0C;
  1437. /** Device OUT Endpoint Transfer Size Register. <i>Offset:
  1438. * B00h + (ep_num * 20h) + 10h</i> */
  1439. volatile uint32_t doeptsiz;
  1440. /** Device OUT Endpoint DMA Address Register. <i>Offset:B00h
  1441. * + (ep_num * 20h) + 14h</i> */
  1442. volatile uint32_t doepdma;
  1443. /** Reserved. <i>Offset:B00h + * (ep_num * 20h) + 18h</i> */
  1444. uint32_t unused;
  1445. /** Device OUT Endpoint DMA Buffer Register. <i>Offset:B00h
  1446. * + (ep_num * 20h) + 1Ch</i> */
  1447. uint32_t doepdmab;
  1448. } dwc_otg_dev_out_ep_regs_t;
  1449. /**
  1450. * This union represents the bit fields in the Device EP Control
  1451. * Register. Read the register into the <i>d32</i> member then
  1452. * set/clear the bits using the <i>b</i>it elements.
  1453. */
  1454. typedef union depctl_data {
  1455. /** raw register data */
  1456. uint32_t d32;
  1457. /** register bits */
  1458. struct {
  1459. /** Maximum Packet Size
  1460. * IN/OUT EPn
  1461. * IN/OUT EP0 - 2 bits
  1462. * 2'b00: 64 Bytes
  1463. * 2'b01: 32
  1464. * 2'b10: 16
  1465. * 2'b11: 8 */
  1466. unsigned mps:11;
  1467. #define DWC_DEP0CTL_MPS_64 0
  1468. #define DWC_DEP0CTL_MPS_32 1
  1469. #define DWC_DEP0CTL_MPS_16 2
  1470. #define DWC_DEP0CTL_MPS_8 3
  1471. /** Next Endpoint
  1472. * IN EPn/IN EP0
  1473. * OUT EPn/OUT EP0 - reserved */
  1474. unsigned nextep:4;
  1475. /** USB Active Endpoint */
  1476. unsigned usbactep:1;
  1477. /** Endpoint DPID (INTR/Bulk IN and OUT endpoints)
  1478. * This field contains the PID of the packet going to
  1479. * be received or transmitted on this endpoint. The
  1480. * application should program the PID of the first
  1481. * packet going to be received or transmitted on this
  1482. * endpoint , after the endpoint is
  1483. * activated. Application use the SetD1PID and
  1484. * SetD0PID fields of this register to program either
  1485. * D0 or D1 PID.
  1486. *
  1487. * The encoding for this field is
  1488. * - 0: D0
  1489. * - 1: D1
  1490. */
  1491. unsigned dpid:1;
  1492. /** NAK Status */
  1493. unsigned naksts:1;
  1494. /** Endpoint Type
  1495. * 2'b00: Control
  1496. * 2'b01: Isochronous
  1497. * 2'b10: Bulk
  1498. * 2'b11: Interrupt */
  1499. unsigned eptype:2;
  1500. /** Snoop Mode
  1501. * OUT EPn/OUT EP0
  1502. * IN EPn/IN EP0 - reserved */
  1503. unsigned snp:1;
  1504. /** Stall Handshake */
  1505. unsigned stall:1;
  1506. /** Tx Fifo Number
  1507. * IN EPn/IN EP0
  1508. * OUT EPn/OUT EP0 - reserved */
  1509. unsigned txfnum:4;
  1510. /** Clear NAK */
  1511. unsigned cnak:1;
  1512. /** Set NAK */
  1513. unsigned snak:1;
  1514. /** Set DATA0 PID (INTR/Bulk IN and OUT endpoints)
  1515. * Writing to this field sets the Endpoint DPID (DPID)
  1516. * field in this register to DATA0. Set Even
  1517. * (micro)frame (SetEvenFr) (ISO IN and OUT Endpoints)
  1518. * Writing to this field sets the Even/Odd
  1519. * (micro)frame (EO_FrNum) field to even (micro)
  1520. * frame.
  1521. */
  1522. unsigned setd0pid:1;
  1523. /** Set DATA1 PID (INTR/Bulk IN and OUT endpoints)
  1524. * Writing to this field sets the Endpoint DPID (DPID)
  1525. * field in this register to DATA1 Set Odd
  1526. * (micro)frame (SetOddFr) (ISO IN and OUT Endpoints)
  1527. * Writing to this field sets the Even/Odd
  1528. * (micro)frame (EO_FrNum) field to odd (micro) frame.
  1529. */
  1530. unsigned setd1pid:1;
  1531. /** Endpoint Disable */
  1532. unsigned epdis:1;
  1533. /** Endpoint Enable */
  1534. unsigned epena:1;
  1535. } b;
  1536. } depctl_data_t;
  1537. /**
  1538. * This union represents the bit fields in the Device EP Transfer
  1539. * Size Register. Read the register into the <i>d32</i> member then
  1540. * set/clear the bits using the <i>b</i>it elements.
  1541. */
  1542. typedef union deptsiz_data {
  1543. /** raw register data */
  1544. uint32_t d32;
  1545. /** register bits */
  1546. struct {
  1547. /** Transfer size */
  1548. unsigned xfersize:19;
  1549. /** Max packet count for EP (pow(2,10)-1) */
  1550. #define MAX_PKT_CNT 1023
  1551. /** Packet Count */
  1552. unsigned pktcnt:10;
  1553. /** Multi Count - Periodic IN endpoints */
  1554. unsigned mc:2;
  1555. unsigned reserved:1;
  1556. } b;
  1557. } deptsiz_data_t;
  1558. /**
  1559. * This union represents the bit fields in the Device EP 0 Transfer
  1560. * Size Register. Read the register into the <i>d32</i> member then
  1561. * set/clear the bits using the <i>b</i>it elements.
  1562. */
  1563. typedef union deptsiz0_data {
  1564. /** raw register data */
  1565. uint32_t d32;
  1566. /** register bits */
  1567. struct {
  1568. /** Transfer size */
  1569. unsigned xfersize:7;
  1570. /** Reserved */
  1571. unsigned reserved7_18:12;
  1572. /** Packet Count */
  1573. unsigned pktcnt:2;
  1574. /** Reserved */
  1575. unsigned reserved21_28:8;
  1576. /**Setup Packet Count (DOEPTSIZ0 Only) */
  1577. unsigned supcnt:2;
  1578. unsigned reserved31;
  1579. } b;
  1580. } deptsiz0_data_t;
  1581. /////////////////////////////////////////////////
  1582. // DMA Descriptor Specific Structures
  1583. //
  1584. /** Buffer status definitions */
  1585. #define BS_HOST_READY 0x0
  1586. #define BS_DMA_BUSY 0x1
  1587. #define BS_DMA_DONE 0x2
  1588. #define BS_HOST_BUSY 0x3
  1589. /** Receive/Transmit status definitions */
  1590. #define RTS_SUCCESS 0x0
  1591. #define RTS_BUFFLUSH 0x1
  1592. #define RTS_RESERVED 0x2
  1593. #define RTS_BUFERR 0x3
  1594. /**
  1595. * This union represents the bit fields in the DMA Descriptor
  1596. * status quadlet. Read the quadlet into the <i>d32</i> member then
  1597. * set/clear the bits using the <i>b</i>it, <i>b_iso_out</i> and
  1598. * <i>b_iso_in</i> elements.
  1599. */
  1600. typedef union dev_dma_desc_sts {
  1601. /** raw register data */
  1602. uint32_t d32;
  1603. /** quadlet bits */
  1604. struct {
  1605. /** Received number of bytes */
  1606. unsigned bytes:16;
  1607. /** NAK bit - only for OUT EPs */
  1608. unsigned nak:1;
  1609. unsigned reserved17_22:6;
  1610. /** Multiple Transfer - only for OUT EPs */
  1611. unsigned mtrf:1;
  1612. /** Setup Packet received - only for OUT EPs */
  1613. unsigned sr:1;
  1614. /** Interrupt On Complete */
  1615. unsigned ioc:1;
  1616. /** Short Packet */
  1617. unsigned sp:1;
  1618. /** Last */
  1619. unsigned l:1;
  1620. /** Receive Status */
  1621. unsigned sts:2;
  1622. /** Buffer Status */
  1623. unsigned bs:2;
  1624. } b;
  1625. //#ifdef DWC_EN_ISOC
  1626. /** iso out quadlet bits */
  1627. struct {
  1628. /** Received number of bytes */
  1629. unsigned rxbytes:11;
  1630. unsigned reserved11:1;
  1631. /** Frame Number */
  1632. unsigned framenum:11;
  1633. /** Received ISO Data PID */
  1634. unsigned pid:2;
  1635. /** Interrupt On Complete */
  1636. unsigned ioc:1;
  1637. /** Short Packet */
  1638. unsigned sp:1;
  1639. /** Last */
  1640. unsigned l:1;
  1641. /** Receive Status */
  1642. unsigned rxsts:2;
  1643. /** Buffer Status */
  1644. unsigned bs:2;
  1645. } b_iso_out;
  1646. /** iso in quadlet bits */
  1647. struct {
  1648. /** Transmited number of bytes */
  1649. unsigned txbytes:12;
  1650. /** Frame Number */
  1651. unsigned framenum:11;
  1652. /** Transmited ISO Data PID */
  1653. unsigned pid:2;
  1654. /** Interrupt On Complete */
  1655. unsigned ioc:1;
  1656. /** Short Packet */
  1657. unsigned sp:1;
  1658. /** Last */
  1659. unsigned l:1;
  1660. /** Transmit Status */
  1661. unsigned txsts:2;
  1662. /** Buffer Status */
  1663. unsigned bs:2;
  1664. } b_iso_in;
  1665. //#endif /* DWC_EN_ISOC */
  1666. } dev_dma_desc_sts_t;
  1667. /**
  1668. * DMA Descriptor structure
  1669. *
  1670. * DMA Descriptor structure contains two quadlets:
  1671. * Status quadlet and Data buffer pointer.
  1672. */
  1673. typedef struct dwc_otg_dev_dma_desc {
  1674. /** DMA Descriptor status quadlet */
  1675. dev_dma_desc_sts_t status;
  1676. /** DMA Descriptor data buffer pointer */
  1677. uint32_t buf;
  1678. } dwc_otg_dev_dma_desc_t;
  1679. /**
  1680. * The dwc_otg_dev_if structure contains information needed to manage
  1681. * the DWC_otg controller acting in device mode. It represents the
  1682. * programming view of the device-specific aspects of the controller.
  1683. */
  1684. typedef struct dwc_otg_dev_if {
  1685. /** Pointer to device Global registers.
  1686. * Device Global Registers starting at offset 800h
  1687. */
  1688. dwc_otg_device_global_regs_t *dev_global_regs;
  1689. #define DWC_DEV_GLOBAL_REG_OFFSET 0x800
  1690. /**
  1691. * Device Logical IN Endpoint-Specific Registers 900h-AFCh
  1692. */
  1693. dwc_otg_dev_in_ep_regs_t *in_ep_regs[MAX_EPS_CHANNELS];
  1694. #define DWC_DEV_IN_EP_REG_OFFSET 0x900
  1695. #define DWC_EP_REG_OFFSET 0x20
  1696. /** Device Logical OUT Endpoint-Specific Registers B00h-CFCh */
  1697. dwc_otg_dev_out_ep_regs_t *out_ep_regs[MAX_EPS_CHANNELS];
  1698. #define DWC_DEV_OUT_EP_REG_OFFSET 0xB00
  1699. /* Device configuration information */
  1700. uint8_t speed; /**< Device Speed 0: Unknown, 1: LS, 2:FS, 3: HS */
  1701. uint8_t num_in_eps; /**< Number # of Tx EP range: 0-15 exept ep0 */
  1702. uint8_t num_out_eps; /**< Number # of Rx EP range: 0-15 exept ep 0*/
  1703. /** Size of periodic FIFOs (Bytes) */
  1704. uint16_t perio_tx_fifo_size[MAX_PERIO_FIFOS];
  1705. /** Size of Tx FIFOs (Bytes) */
  1706. uint16_t tx_fifo_size[MAX_TX_FIFOS];
  1707. /** Thresholding enable flags and length varaiables **/
  1708. uint16_t rx_thr_en;
  1709. uint16_t iso_tx_thr_en;
  1710. uint16_t non_iso_tx_thr_en;
  1711. uint16_t rx_thr_length;
  1712. uint16_t tx_thr_length;
  1713. /**
  1714. * Pointers to the DMA Descriptors for EP0 Control
  1715. * transfers (virtual and physical)
  1716. */
  1717. /** 2 descriptors for SETUP packets */
  1718. dwc_dma_t dma_setup_desc_addr[2];
  1719. dwc_otg_dev_dma_desc_t *setup_desc_addr[2];
  1720. /** Pointer to Descriptor with latest SETUP packet */
  1721. dwc_otg_dev_dma_desc_t *psetup;
  1722. /** Index of current SETUP handler descriptor */
  1723. uint32_t setup_desc_index;
  1724. /** Descriptor for Data In or Status In phases */
  1725. dwc_dma_t dma_in_desc_addr;
  1726. dwc_otg_dev_dma_desc_t *in_desc_addr;
  1727. /** Descriptor for Data Out or Status Out phases */
  1728. dwc_dma_t dma_out_desc_addr;
  1729. dwc_otg_dev_dma_desc_t *out_desc_addr;
  1730. /** Setup Packet Detected - if set clear NAK when queueing */
  1731. uint32_t spd;
  1732. /** Isoc ep pointer on which incomplete happens */
  1733. void *isoc_ep;
  1734. /** DP pull up status */
  1735. uint32_t pull_up;
  1736. /** Session Requested */
  1737. uint32_t vbus_on;
  1738. } dwc_otg_dev_if_t;
  1739. /////////////////////////////////////////////////
  1740. // Host Mode Register Structures
  1741. //
  1742. /**
  1743. * The Host Global Registers structure defines the size and relative
  1744. * field offsets for the Host Mode Global Registers. Host Global
  1745. * Registers offsets 400h-7FFh.
  1746. */
  1747. typedef struct dwc_otg_host_global_regs {
  1748. /** Host Configuration Register. <i>Offset: 400h</i> */
  1749. volatile uint32_t hcfg;
  1750. /** Host Frame Interval Register. <i>Offset: 404h</i> */
  1751. volatile uint32_t hfir;
  1752. /** Host Frame Number / Frame Remaining Register. <i>Offset: 408h</i> */
  1753. volatile uint32_t hfnum;
  1754. /** Reserved. <i>Offset: 40Ch</i> */
  1755. uint32_t reserved40C;
  1756. /** Host Periodic Transmit FIFO/ Queue Status Register. <i>Offset: 410h</i> */
  1757. volatile uint32_t hptxsts;
  1758. /** Host All Channels Interrupt Register. <i>Offset: 414h</i> */
  1759. volatile uint32_t haint;
  1760. /** Host All Channels Interrupt Mask Register. <i>Offset: 418h</i> */
  1761. volatile uint32_t haintmsk;
  1762. /** Host Frame List Base Address Register . <i>Offset: 41Ch</i> */
  1763. volatile uint32_t hflbaddr;
  1764. } dwc_otg_host_global_regs_t;
  1765. /**
  1766. * This union represents the bit fields in the Host Configuration Register.
  1767. * Read the register into the <i>d32</i> member then set/clear the bits using
  1768. * the <i>b</i>it elements. Write the <i>d32</i> member to the hcfg register.
  1769. */
  1770. typedef union hcfg_data {
  1771. /** raw register data */
  1772. uint32_t d32;
  1773. /** register bits */
  1774. struct {
  1775. /** FS/LS Phy Clock Select */
  1776. unsigned fslspclksel:2;
  1777. #define DWC_HCFG_30_60_MHZ 0
  1778. #define DWC_HCFG_48_MHZ 1
  1779. #define DWC_HCFG_6_MHZ 2
  1780. /** FS/LS Only Support */
  1781. unsigned fslssupp:1;
  1782. unsigned reserved3_6:4;
  1783. /** Enable 32-KHz Suspend Mode */
  1784. unsigned ena32khzs:1;
  1785. /** Resume Validation Periiod */
  1786. unsigned resvalid:8;
  1787. unsigned reserved16_22:7;
  1788. /** Enable Scatter/gather DMA in Host mode */
  1789. unsigned descdma:1;
  1790. /** Frame List Entries */
  1791. unsigned frlisten:2;
  1792. /** Enable Periodic Scheduling */
  1793. unsigned perschedena:1;
  1794. unsigned reserved27_30:4;
  1795. unsigned modechtimen:1;
  1796. } b;
  1797. } hcfg_data_t;
  1798. /**
  1799. * This union represents the bit fields in the Host Frame Remaing/Number
  1800. * Register.
  1801. */
  1802. typedef union hfir_data {
  1803. /** raw register data */
  1804. uint32_t d32;
  1805. /** register bits */
  1806. struct {
  1807. unsigned frint:16;
  1808. unsigned hfirrldctrl:1;
  1809. unsigned reserved:15;
  1810. } b;
  1811. } hfir_data_t;
  1812. /**
  1813. * This union represents the bit fields in the Host Frame Remaing/Number
  1814. * Register.
  1815. */
  1816. typedef union hfnum_data {
  1817. /** raw register data */
  1818. uint32_t d32;
  1819. /** register bits */
  1820. struct {
  1821. unsigned frnum:16;
  1822. #define DWC_HFNUM_MAX_FRNUM 0x3FFF
  1823. unsigned frrem:16;
  1824. } b;
  1825. } hfnum_data_t;
  1826. typedef union hptxsts_data {
  1827. /** raw register data */
  1828. uint32_t d32;
  1829. /** register bits */
  1830. struct {
  1831. unsigned ptxfspcavail:16;
  1832. unsigned ptxqspcavail:8;
  1833. /** Top of the Periodic Transmit Request Queue
  1834. * - bit 24 - Terminate (last entry for the selected channel)
  1835. * - bits 26:25 - Token Type
  1836. * - 2'b00 - Zero length
  1837. * - 2'b01 - Ping
  1838. * - 2'b10 - Disable
  1839. * - bits 30:27 - Channel Number
  1840. * - bit 31 - Odd/even microframe
  1841. */
  1842. unsigned ptxqtop_terminate:1;
  1843. unsigned ptxqtop_token:2;
  1844. unsigned ptxqtop_chnum:4;
  1845. unsigned ptxqtop_odd:1;
  1846. } b;
  1847. } hptxsts_data_t;
  1848. /**
  1849. * This union represents the bit fields in the Host Port Control and Status
  1850. * Register. Read the register into the <i>d32</i> member then set/clear the
  1851. * bits using the <i>b</i>it elements. Write the <i>d32</i> member to the
  1852. * hprt0 register.
  1853. */
  1854. typedef union hprt0_data {
  1855. /** raw register data */
  1856. uint32_t d32;
  1857. /** register bits */
  1858. struct {
  1859. unsigned prtconnsts:1;
  1860. unsigned prtconndet:1;
  1861. unsigned prtena:1;
  1862. unsigned prtenchng:1;
  1863. unsigned prtovrcurract:1;
  1864. unsigned prtovrcurrchng:1;
  1865. unsigned prtres:1;
  1866. unsigned prtsusp:1;
  1867. unsigned prtrst:1;
  1868. unsigned reserved9:1;
  1869. unsigned prtlnsts:2;
  1870. unsigned prtpwr:1;
  1871. unsigned prttstctl:4;
  1872. unsigned prtspd:2;
  1873. #define DWC_HPRT0_PRTSPD_HIGH_SPEED 0
  1874. #define DWC_HPRT0_PRTSPD_FULL_SPEED 1
  1875. #define DWC_HPRT0_PRTSPD_LOW_SPEED 2
  1876. unsigned reserved19_31:13;
  1877. } b;
  1878. } hprt0_data_t;
  1879. /**
  1880. * This union represents the bit fields in the Host All Interrupt
  1881. * Register.
  1882. */
  1883. typedef union haint_data {
  1884. /** raw register data */
  1885. uint32_t d32;
  1886. /** register bits */
  1887. struct {
  1888. unsigned ch0:1;
  1889. unsigned ch1:1;
  1890. unsigned ch2:1;
  1891. unsigned ch3:1;
  1892. unsigned ch4:1;
  1893. unsigned ch5:1;
  1894. unsigned ch6:1;
  1895. unsigned ch7:1;
  1896. unsigned ch8:1;
  1897. unsigned ch9:1;
  1898. unsigned ch10:1;
  1899. unsigned ch11:1;
  1900. unsigned ch12:1;
  1901. unsigned ch13:1;
  1902. unsigned ch14:1;
  1903. unsigned ch15:1;
  1904. unsigned reserved:16;
  1905. } b;
  1906. struct {
  1907. unsigned chint:16;
  1908. unsigned reserved:16;
  1909. } b2;
  1910. } haint_data_t;
  1911. /**
  1912. * This union represents the bit fields in the Host All Interrupt
  1913. * Register.
  1914. */
  1915. typedef union haintmsk_data {
  1916. /** raw register data */
  1917. uint32_t d32;
  1918. /** register bits */
  1919. struct {
  1920. unsigned ch0:1;
  1921. unsigned ch1:1;
  1922. unsigned ch2:1;
  1923. unsigned ch3:1;
  1924. unsigned ch4:1;
  1925. unsigned ch5:1;
  1926. unsigned ch6:1;
  1927. unsigned ch7:1;
  1928. unsigned ch8:1;
  1929. unsigned ch9:1;
  1930. unsigned ch10:1;
  1931. unsigned ch11:1;
  1932. unsigned ch12:1;
  1933. unsigned ch13:1;
  1934. unsigned ch14:1;
  1935. unsigned ch15:1;
  1936. unsigned reserved:16;
  1937. } b;
  1938. struct {
  1939. unsigned chint:16;
  1940. unsigned reserved:16;
  1941. } b2;
  1942. } haintmsk_data_t;
  1943. /**
  1944. * Host Channel Specific Registers. <i>500h-5FCh</i>
  1945. */
  1946. typedef struct dwc_otg_hc_regs {
  1947. /** Host Channel 0 Characteristic Register. <i>Offset: 500h + (chan_num * 20h) + 00h</i> */
  1948. volatile uint32_t hcchar;
  1949. /** Host Channel 0 Split Control Register. <i>Offset: 500h + (chan_num * 20h) + 04h</i> */
  1950. volatile uint32_t hcsplt;
  1951. /** Host Channel 0 Interrupt Register. <i>Offset: 500h + (chan_num * 20h) + 08h</i> */
  1952. volatile uint32_t hcint;
  1953. /** Host Channel 0 Interrupt Mask Register. <i>Offset: 500h + (chan_num * 20h) + 0Ch</i> */
  1954. volatile uint32_t hcintmsk;
  1955. /** Host Channel 0 Transfer Size Register. <i>Offset: 500h + (chan_num * 20h) + 10h</i> */
  1956. volatile uint32_t hctsiz;
  1957. /** Host Channel 0 DMA Address Register. <i>Offset: 500h + (chan_num * 20h) + 14h</i> */
  1958. volatile uint32_t hcdma;
  1959. volatile uint32_t reserved;
  1960. /** Host Channel 0 DMA Buffer Address Register. <i>Offset: 500h + (chan_num * 20h) + 1Ch</i> */
  1961. volatile uint32_t hcdmab;
  1962. } dwc_otg_hc_regs_t;
  1963. /**
  1964. * This union represents the bit fields in the Host Channel Characteristics
  1965. * Register. Read the register into the <i>d32</i> member then set/clear the
  1966. * bits using the <i>b</i>it elements. Write the <i>d32</i> member to the
  1967. * hcchar register.
  1968. */
  1969. typedef union hcchar_data {
  1970. /** raw register data */
  1971. uint32_t d32;
  1972. /** register bits */
  1973. struct {
  1974. /** Maximum packet size in bytes */
  1975. unsigned mps:11;
  1976. /** Endpoint number */
  1977. unsigned epnum:4;
  1978. /** 0: OUT, 1: IN */
  1979. unsigned epdir:1;
  1980. unsigned reserved:1;
  1981. /** 0: Full/high speed device, 1: Low speed device */
  1982. unsigned lspddev:1;
  1983. /** 0: Control, 1: Isoc, 2: Bulk, 3: Intr */
  1984. unsigned eptype:2;
  1985. /** Packets per frame for periodic transfers. 0 is reserved. */
  1986. unsigned multicnt:2;
  1987. /** Device address */
  1988. unsigned devaddr:7;
  1989. /**
  1990. * Frame to transmit periodic transaction.
  1991. * 0: even, 1: odd
  1992. */
  1993. unsigned oddfrm:1;
  1994. /** Channel disable */
  1995. unsigned chdis:1;
  1996. /** Channel enable */
  1997. unsigned chen:1;
  1998. } b;
  1999. } hcchar_data_t;
  2000. typedef union hcsplt_data {
  2001. /** raw register data */
  2002. uint32_t d32;
  2003. /** register bits */
  2004. struct {
  2005. /** Port Address */
  2006. unsigned prtaddr:7;
  2007. /** Hub Address */
  2008. unsigned hubaddr:7;
  2009. /** Transaction Position */
  2010. unsigned xactpos:2;
  2011. #define DWC_HCSPLIT_XACTPOS_MID 0
  2012. #define DWC_HCSPLIT_XACTPOS_END 1
  2013. #define DWC_HCSPLIT_XACTPOS_BEGIN 2
  2014. #define DWC_HCSPLIT_XACTPOS_ALL 3
  2015. /** Do Complete Split */
  2016. unsigned compsplt:1;
  2017. /** Reserved */
  2018. unsigned reserved:14;
  2019. /** Split Enble */
  2020. unsigned spltena:1;
  2021. } b;
  2022. } hcsplt_data_t;
  2023. /**
  2024. * This union represents the bit fields in the Host All Interrupt
  2025. * Register.
  2026. */
  2027. typedef union hcint_data {
  2028. /** raw register data */
  2029. uint32_t d32;
  2030. /** register bits */
  2031. struct {
  2032. /** Transfer Complete */
  2033. unsigned xfercomp:1;
  2034. /** Channel Halted */
  2035. unsigned chhltd:1;
  2036. /** AHB Error */
  2037. unsigned ahberr:1;
  2038. /** STALL Response Received */
  2039. unsigned stall:1;
  2040. /** NAK Response Received */
  2041. unsigned nak:1;
  2042. /** ACK Response Received */
  2043. unsigned ack:1;
  2044. /** NYET Response Received */
  2045. unsigned nyet:1;
  2046. /** Transaction Err */
  2047. unsigned xacterr:1;
  2048. /** Babble Error */
  2049. unsigned bblerr:1;
  2050. /** Frame Overrun */
  2051. unsigned frmovrun:1;
  2052. /** Data Toggle Error */
  2053. unsigned datatglerr:1;
  2054. /** Buffer Not Available (only for DDMA mode) */
  2055. unsigned bna:1;
  2056. /** Exessive transaction error (only for DDMA mode) */
  2057. unsigned xcs_xact:1;
  2058. /** Frame List Rollover interrupt */
  2059. unsigned frm_list_roll:1;
  2060. /** Reserved */
  2061. unsigned reserved14_31:18;
  2062. } b;
  2063. } hcint_data_t;
  2064. /**
  2065. * This union represents the bit fields in the Host Channel Interrupt Mask
  2066. * Register. Read the register into the <i>d32</i> member then set/clear the
  2067. * bits using the <i>b</i>it elements. Write the <i>d32</i> member to the
  2068. * hcintmsk register.
  2069. */
  2070. typedef union hcintmsk_data {
  2071. /** raw register data */
  2072. uint32_t d32;
  2073. /** register bits */
  2074. struct {
  2075. unsigned xfercompl:1;
  2076. unsigned chhltd:1;
  2077. unsigned ahberr:1;
  2078. unsigned stall:1;
  2079. unsigned nak:1;
  2080. unsigned ack:1;
  2081. unsigned nyet:1;
  2082. unsigned xacterr:1;
  2083. unsigned bblerr:1;
  2084. unsigned frmovrun:1;
  2085. unsigned datatglerr:1;
  2086. unsigned bna:1;
  2087. unsigned xcs_xact:1;
  2088. unsigned frm_list_roll:1;
  2089. unsigned reserved14_31:18;
  2090. } b;
  2091. } hcintmsk_data_t;
  2092. /**
  2093. * This union represents the bit fields in the Host Channel Transfer Size
  2094. * Register. Read the register into the <i>d32</i> member then set/clear the
  2095. * bits using the <i>b</i>it elements. Write the <i>d32</i> member to the
  2096. * hcchar register.
  2097. */
  2098. typedef union hctsiz_data {
  2099. /** raw register data */
  2100. uint32_t d32;
  2101. /** register bits */
  2102. struct {
  2103. /** Total transfer size in bytes */
  2104. unsigned xfersize:19;
  2105. /** Data packets to transfer */
  2106. unsigned pktcnt:10;
  2107. /**
  2108. * Packet ID for next data packet
  2109. * 0: DATA0
  2110. * 1: DATA2
  2111. * 2: DATA1
  2112. * 3: MDATA (non-Control), SETUP (Control)
  2113. */
  2114. unsigned pid:2;
  2115. #define DWC_HCTSIZ_DATA0 0
  2116. #define DWC_HCTSIZ_DATA1 2
  2117. #define DWC_HCTSIZ_DATA2 1
  2118. #define DWC_HCTSIZ_MDATA 3
  2119. #define DWC_HCTSIZ_SETUP 3
  2120. /** Do PING protocol when 1 */
  2121. unsigned dopng:1;
  2122. } b;
  2123. /** register bits */
  2124. struct {
  2125. /** Scheduling information */
  2126. unsigned schinfo:8;
  2127. /** Number of transfer descriptors.
  2128. * Max value:
  2129. * 64 in general,
  2130. * 256 only for HS isochronous endpoint.
  2131. */
  2132. unsigned ntd:8;
  2133. /** Data packets to transfer */
  2134. unsigned reserved16_28:13;
  2135. /**
  2136. * Packet ID for next data packet
  2137. * 0: DATA0
  2138. * 1: DATA2
  2139. * 2: DATA1
  2140. * 3: MDATA (non-Control)
  2141. */
  2142. unsigned pid:2;
  2143. /** Do PING protocol when 1 */
  2144. unsigned dopng:1;
  2145. } b_ddma;
  2146. } hctsiz_data_t;
  2147. /**
  2148. * This union represents the bit fields in the Host DMA Address
  2149. * Register used in Descriptor DMA mode.
  2150. */
  2151. typedef union hcdma_data {
  2152. /** raw register data */
  2153. uint32_t d32;
  2154. /** register bits */
  2155. struct {
  2156. unsigned reserved0_2:3;
  2157. /** Current Transfer Descriptor. Not used for ISOC */
  2158. unsigned ctd:8;
  2159. /** Start Address of Descriptor List */
  2160. unsigned dma_addr:21;
  2161. } b;
  2162. } hcdma_data_t;
  2163. /**
  2164. * This union represents the bit fields in the DMA Descriptor
  2165. * status quadlet for host mode. Read the quadlet into the <i>d32</i> member then
  2166. * set/clear the bits using the <i>b</i>it elements.
  2167. */
  2168. typedef union host_dma_desc_sts {
  2169. /** raw register data */
  2170. uint32_t d32;
  2171. /** quadlet bits */
  2172. /* for non-isochronous */
  2173. struct {
  2174. /** Number of bytes */
  2175. unsigned n_bytes:17;
  2176. /** QTD offset to jump when Short Packet received - only for IN EPs */
  2177. unsigned qtd_offset:6;
  2178. /**
  2179. * Set to request the core to jump to alternate QTD if
  2180. * Short Packet received - only for IN EPs
  2181. */
  2182. unsigned a_qtd:1;
  2183. /**
  2184. * Setup Packet bit. When set indicates that buffer contains
  2185. * setup packet.
  2186. */
  2187. unsigned sup:1;
  2188. /** Interrupt On Complete */
  2189. unsigned ioc:1;
  2190. /** End of List */
  2191. unsigned eol:1;
  2192. unsigned reserved27:1;
  2193. /** Rx/Tx Status */
  2194. unsigned sts:2;
  2195. #define DMA_DESC_STS_PKTERR 1
  2196. unsigned reserved30:1;
  2197. /** Active Bit */
  2198. unsigned a:1;
  2199. } b;
  2200. /* for isochronous */
  2201. struct {
  2202. /** Number of bytes */
  2203. unsigned n_bytes:12;
  2204. unsigned reserved12_24:13;
  2205. /** Interrupt On Complete */
  2206. unsigned ioc:1;
  2207. unsigned reserved26_27:2;
  2208. /** Rx/Tx Status */
  2209. unsigned sts:2;
  2210. unsigned reserved30:1;
  2211. /** Active Bit */
  2212. unsigned a:1;
  2213. } b_isoc;
  2214. } host_dma_desc_sts_t;
  2215. #define MAX_DMA_DESC_SIZE 131071
  2216. #define MAX_DMA_DESC_NUM_GENERIC 64
  2217. #define MAX_DMA_DESC_NUM_HS_ISOC 256
  2218. #define MAX_FRLIST_EN_NUM 64
  2219. /**
  2220. * Host-mode DMA Descriptor structure
  2221. *
  2222. * DMA Descriptor structure contains two quadlets:
  2223. * Status quadlet and Data buffer pointer.
  2224. */
  2225. typedef struct dwc_otg_host_dma_desc {
  2226. /** DMA Descriptor status quadlet */
  2227. host_dma_desc_sts_t status;
  2228. /** DMA Descriptor data buffer pointer */
  2229. uint32_t buf;
  2230. } dwc_otg_host_dma_desc_t;
  2231. /** OTG Host Interface Structure.
  2232. *
  2233. * The OTG Host Interface Structure structure contains information
  2234. * needed to manage the DWC_otg controller acting in host mode. It
  2235. * represents the programming view of the host-specific aspects of the
  2236. * controller.
  2237. */
  2238. typedef struct dwc_otg_host_if {
  2239. /** Host Global Registers starting at offset 400h.*/
  2240. dwc_otg_host_global_regs_t *host_global_regs;
  2241. #define DWC_OTG_HOST_GLOBAL_REG_OFFSET 0x400
  2242. /** Host Port 0 Control and Status Register */
  2243. volatile uint32_t *hprt0;
  2244. #define DWC_OTG_HOST_PORT_REGS_OFFSET 0x440
  2245. /** Host Channel Specific Registers at offsets 500h-5FCh. */
  2246. dwc_otg_hc_regs_t *hc_regs[MAX_EPS_CHANNELS];
  2247. #define DWC_OTG_HOST_CHAN_REGS_OFFSET 0x500
  2248. #define DWC_OTG_CHAN_REGS_OFFSET 0x20
  2249. /* Host configuration information */
  2250. /** Number of Host Channels (range: 1-16) */
  2251. uint8_t num_host_channels;
  2252. /** Periodic EPs supported (0: no, 1: yes) */
  2253. uint8_t perio_eps_supported;
  2254. /** Periodic Tx FIFO Size (Only 1 host periodic Tx FIFO) */
  2255. uint16_t perio_tx_fifo_size;
  2256. } dwc_otg_host_if_t;
  2257. /**
  2258. * This union represents the bit fields in the Power and Clock Gating Control
  2259. * Register. Read the register into the <i>d32</i> member then set/clear the
  2260. * bits using the <i>b</i>it elements.
  2261. */
  2262. typedef union pcgcctl_data {
  2263. /** raw register data */
  2264. uint32_t d32;
  2265. /** register bits */
  2266. struct {
  2267. /** Stop Pclk */
  2268. unsigned stoppclk:1;
  2269. /** Gate Hclk */
  2270. unsigned gatehclk:1;
  2271. /** Power Clamp */
  2272. unsigned pwrclmp:1;
  2273. /** Reset Power Down Modules */
  2274. unsigned rstpdwnmodule:1;
  2275. /** Reserved */
  2276. unsigned reserved:1;
  2277. /** Enable Sleep Clock Gating (Enbl_L1Gating) */
  2278. unsigned enbl_sleep_gating:1;
  2279. /** PHY In Sleep (PhySleep) */
  2280. unsigned phy_in_sleep:1;
  2281. /** Deep Sleep*/
  2282. unsigned deep_sleep:1;
  2283. unsigned resetaftsusp:1;
  2284. unsigned restoremode:1;
  2285. unsigned reserved10_12:3;
  2286. unsigned ess_reg_restored:1;
  2287. unsigned prt_clk_sel:2;
  2288. unsigned port_power:1;
  2289. unsigned max_xcvrselect:2;
  2290. unsigned max_termsel:1;
  2291. unsigned mac_dev_addr:7;
  2292. unsigned p2hd_dev_enum_spd:2;
  2293. unsigned p2hd_prt_spd:2;
  2294. unsigned if_dev_mode:1;
  2295. } b;
  2296. } pcgcctl_data_t;
  2297. /**
  2298. * This union represents the bit fields in the Global Data FIFO Software
  2299. * Configuration Register. Read the register into the <i>d32</i> member then
  2300. * set/clear the bits using the <i>b</i>it elements.
  2301. */
  2302. typedef union gdfifocfg_data {
  2303. /* raw register data */
  2304. uint32_t d32;
  2305. /** register bits */
  2306. struct {
  2307. /** OTG Data FIFO depth */
  2308. unsigned gdfifocfg:16;
  2309. /** Start address of EP info controller */
  2310. unsigned epinfobase:16;
  2311. } b;
  2312. } gdfifocfg_data_t;
  2313. /**
  2314. * This union represents the bit fields in the Global Power Down Register
  2315. * Register. Read the register into the <i>d32</i> member then set/clear the
  2316. * bits using the <i>b</i>it elements.
  2317. */
  2318. typedef union gpwrdn_data {
  2319. /* raw register data */
  2320. uint32_t d32;
  2321. /** register bits */
  2322. struct {
  2323. /** PMU Interrupt Select */
  2324. unsigned pmuintsel:1;
  2325. /** PMU Active */
  2326. unsigned pmuactv:1;
  2327. /** Restore */
  2328. unsigned restore:1;
  2329. /** Power Down Clamp */
  2330. unsigned pwrdnclmp:1;
  2331. /** Power Down Reset */
  2332. unsigned pwrdnrstn:1;
  2333. /** Power Down Switch */
  2334. unsigned pwrdnswtch:1;
  2335. /** Disable VBUS */
  2336. unsigned dis_vbus:1;
  2337. /** Line State Change */
  2338. unsigned lnstschng:1;
  2339. /** Line state change mask */
  2340. unsigned lnstchng_msk:1;
  2341. /** Reset Detected */
  2342. unsigned rst_det:1;
  2343. /** Reset Detect mask */
  2344. unsigned rst_det_msk:1;
  2345. /** Disconnect Detected */
  2346. unsigned disconn_det:1;
  2347. /** Disconnect Detect mask */
  2348. unsigned disconn_det_msk:1;
  2349. /** Connect Detected*/
  2350. unsigned connect_det:1;
  2351. /** Connect Detected Mask*/
  2352. unsigned connect_det_msk:1;
  2353. /** SRP Detected */
  2354. unsigned srp_det:1;
  2355. /** SRP Detect mask */
  2356. unsigned srp_det_msk:1;
  2357. /** Status Change Interrupt */
  2358. unsigned sts_chngint:1;
  2359. /** Status Change Interrupt Mask */
  2360. unsigned sts_chngint_msk:1;
  2361. /** Line State */
  2362. unsigned linestate:2;
  2363. /** Indicates current mode(status of IDDIG signal) */
  2364. unsigned idsts:1;
  2365. /** B Session Valid signal status*/
  2366. unsigned bsessvld:1;
  2367. /** ADP Event Detected */
  2368. unsigned adp_int:1;
  2369. /** Multi Valued ID pin */
  2370. unsigned mult_val_id_bc:5;
  2371. /** Reserved 24_31 */
  2372. unsigned reserved29_31:3;
  2373. } b;
  2374. } gpwrdn_data_t;
  2375. #endif