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