1 /* ==========================================================================
2 * $File: //dwh/usb_iip/dev/software/otg/linux/drivers/dwc_otg_regs.h $
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.
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.
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
32 * ========================================================================== */
34 #ifndef __DWC_OTG_REGS_H__
35 #define __DWC_OTG_REGS_H__
37 #include "dwc_otg_core_if.h"
42 * This file contains the data structures for accessing the DWC_otg core registers.
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
56 * - Host Channel Specific Registers
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.
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.
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;
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
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
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
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;
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.
152 typedef union gotgctl_data {
153 /** raw register data */
157 unsigned sesreqscs:1;
159 unsigned reserved2_7:6;
160 unsigned hstnegscs:1;
162 unsigned hstsethnpen:1;
164 unsigned reserved12_15:4;
166 unsigned reserved17:1;
170 unsigned reserved21_31:11;
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.
179 typedef union gotgint_data {
180 /** raw register data */
185 unsigned reserved0_1:2;
187 /** Session End Detected */
188 unsigned sesenddet:1;
190 unsigned reserved3_7:5;
192 /** Session Request Success Status Change */
193 unsigned sesreqsucstschng:1;
194 /** Host Negotiation Success Status Change */
195 unsigned hstnegsucstschng:1;
197 unsigned reserver10_16:7;
199 /** Host Negotiation Detected */
200 unsigned hstnegdet:1;
201 /** A-Device Timeout Change */
202 unsigned adevtoutchng:1;
206 unsigned reserved31_20:12;
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.
216 typedef union gahbcfg_data {
217 /** raw register data */
221 unsigned glblintrmsk:1;
222 #define DWC_GAHBCFG_GLBINT_ENABLE 1
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
231 unsigned dmaenable:1;
232 #define DWC_GAHBCFG_DMAENABLE 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;
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.
247 typedef union gusbcfg_data {
248 /** raw register data */
254 unsigned ulpi_utmi_sel: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;
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.
283 typedef union glpmctl_data {
284 /** raw register data */
288 /** LPM-Capable (LPMCap) (Device and Host)
289 * The application uses this bit to control
290 * the DWC_otg core LPM capabilities.
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.
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.
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.
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.
320 unsigned en_utmi_sleep:1;
321 /** HIRD Threshold (HIRD_Thres) (Device and Host)
323 unsigned hird_thres:5;
324 /** LPM Response (CoreL1Res) (Device and Host)
325 * In Host mode this bit contains handsake response to
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)
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.
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.
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.
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.
355 unsigned retry_count:3;
356 /** Send LPM Transaction (SndLPM) (Host)
357 * When set by application software,
358 * an LPM transaction containing two tokens
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
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.
375 unsigned hsic_connect:1;
376 /** This bit overrides and functionally inverts
377 * the if_select_hsic input port signal.
379 unsigned inv_sel_hsic:1;
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.
388 typedef union grstctl_data {
389 /** raw register data */
393 /** Core Soft Reset (CSftRst) (Device and Host)
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
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.
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
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.
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).
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
431 * The application uses this bit to reset the control logic in
432 * the AHB clock domain. Only AHB clock domain pipelines are
436 /** Host Frame Counter Reset (Host Only)<br>
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
445 /** In Token Sequence Learning Queue Flush
446 * (INTknQFlsh) (Device Only)
448 unsigned intknqflsh:1;
449 /** RxFIFO Flush (RxFFlsh) (Device and Host)
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)
464 /** TxFIFO Flush (TxFFlsh) (Device and Host).
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)
480 /** TxFIFO Number (TxFNum) (Device and Host).
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
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.
491 * - 0xF : Periodic TxFIFO #15 Flush in device mode
492 * - 0x10: Flush all the Transmit NonPeriodic and
493 * Transmit Periodic FIFOs in the core
497 unsigned reserved11_29:19;
498 /** DMA Request Signal. Indicated DMA request is in
499 * probress. Used for debug purpose. */
501 /** AHB Master Idle. Indicates the AHB Master State
502 * Machine is in IDLE condition. */
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.
512 typedef union gintmsk_data {
513 /** raw register data */
517 unsigned reserved0:1;
518 unsigned modemismatch:1;
521 unsigned rxstsqlvl:1;
522 unsigned nptxfempty:1;
523 unsigned ginnakeff:1;
524 unsigned goutnakeff:1;
525 unsigned reserved8:1;
527 unsigned erlysuspend:1;
528 unsigned usbsuspend:1;
531 unsigned isooutdrop:1;
533 unsigned reserved16:1;
534 unsigned epmismatch:1;
536 unsigned outepintr:1;
537 unsigned incomplisoin:1;
538 unsigned incomplisoout:1;
539 unsigned reserved22_23:2;
542 unsigned ptxfempty:1;
543 unsigned lpmtranrcvd:1;
544 unsigned conidstschng:1;
545 unsigned disconnect:1;
546 unsigned sessreqintr:1;
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.
555 typedef union gintsts_data {
556 /** raw register data */
558 #define DWC_SOF_INTR_MASK 0x0008
561 #define DWC_HOST_MODE 1
563 unsigned modemismatch:1;
566 unsigned rxstsqlvl:1;
567 unsigned nptxfempty:1;
568 unsigned ginnakeff:1;
569 unsigned goutnakeff:1;
570 unsigned reserved8:1;
572 unsigned erlysuspend:1;
573 unsigned usbsuspend:1;
576 unsigned isooutdrop:1;
578 unsigned intokenrx:1;
579 unsigned epmismatch:1;
581 unsigned outepintr:1;
582 unsigned incomplisoin:1;
583 unsigned incomplisoout:1;
584 unsigned reserved22_23:2;
587 unsigned ptxfempty:1;
588 unsigned lpmtranrcvd:1;
589 unsigned conidstschng:1;
590 unsigned disconnect:1;
591 unsigned sessreqintr:1;
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.
601 typedef union device_grxsts_data {
602 /** raw register data */
610 #define DWC_STS_DATA_UPDT 0x2 // OUT Data Packet
611 #define DWC_STS_XFER_COMP 0x3 // OUT Data Transfer Complete
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
620 } device_grxsts_data_t;
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.
627 typedef union host_grxsts_data {
628 /** raw register data */
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
642 unsigned reserved:11;
644 } host_grxsts_data_t;
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.
651 typedef union fifosize_data {
652 /** raw register data */
656 unsigned startaddr:16;
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
667 typedef union gnptxsts_data {
668 /** raw register data */
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
677 * - bits 26:25 - Token Type
679 * - 2'b01 - Zero Length OUT
680 * - 2'b10 - PING/Complete Split
681 * - 2'b11 - Channel Halt
682 * - bits 30:27 - Channel/EP Number
684 unsigned nptxqtop_terminate:1;
685 unsigned nptxqtop_token:2;
686 unsigned nptxqtop_chnep:4;
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
697 typedef union dtxfsts_data {
698 /** raw register data */
702 unsigned txfspcavail:16;
703 unsigned reserved:16;
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.
712 typedef union gi2cctl_data {
713 /** raw register data */
722 unsigned i2csuspctl:1;
723 unsigned i2cdevaddr:2;
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.
735 typedef union hwcfg1_data {
736 /** raw register data */
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.
764 typedef union hwcfg2_data {
765 /** raw register data */
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
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
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;
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.
806 typedef union hwcfg3_data {
807 /** raw register data */
812 unsigned xfer_size_cntr_width:4;
813 unsigned packet_size_cntr_width:3;
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;
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.
832 typedef union hwcfg4_data {
833 /** raw register data */
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;
850 unsigned desc_dma_dyn:1;
854 ////////////////////////////////////////////
857 * Device Global Registers. <i>Offsets 800h-BFFh</i>
859 * The following structures define the size and relative field offsets
860 * for the Device Mode Registers.
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>
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> */
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:
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;
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.
923 typedef union dcfg_data {
924 /** raw register data */
930 /** Non Zero Length Status OUT Handshake */
931 unsigned nzstsouthshk:1;
932 #define DWC_DCFG_SEND_STALL 1
934 unsigned reserved3:1;
935 /** Device Addresses */
937 /** Periodic Frame Interval */
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
944 unsigned reserved13_17:5;
945 /** In Endpoint Mis-match count */
947 /** Enable Descriptor DMA in Device mode */
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.
957 typedef union dctl_data {
958 /** raw register data */
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;
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 */
978 /** Clear Global OUT NAK */
981 /** Power-On Programming Done */
982 unsigned pwronprgdone:1;
983 /** Global Continue on BNA */
985 /** Global Multi Count */
987 /** Ignore Frame Number for ISOC EPs */
990 unsigned nakonbble:1;
992 unsigned reserved17_31:15;
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.
1001 typedef union dsts_data {
1002 /** raw register data */
1004 /** register bits */
1006 /** Suspend Status */
1008 /** Enumerated Speed */
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 */
1019 unsigned reserved22_31:10;
1024 * This union represents the bit fields in the Device IN EP Interrupt
1025 * Register and the Device IN EP Common Mask Register.
1027 * - Read the register into the <i>d32</i> member then set/clear the
1028 * bits using the <i>b</i>it elements.
1030 typedef union diepint_data {
1031 /** raw register data */
1033 /** register bits */
1035 /** Transfer complete mask */
1036 unsigned xfercompl:1;
1037 /** Endpoint disable mask */
1038 unsigned epdisabled:1;
1039 /** AHB Error mask */
1041 /** TimeOUT Handshake mask (non-ISOC EPs) */
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;
1052 unsigned txfifoundrn:1;
1054 /** BNA Interrupt mask */
1057 unsigned reserved10_12:3;
1058 /** BNA Interrupt mask */
1061 unsigned reserved14_31:18;
1066 * This union represents the bit fields in the Device IN EP
1067 * Common/Dedicated Interrupt Mask Register.
1069 typedef union diepint_data diepmsk_data_t;
1072 * This union represents the bit fields in the Device OUT EP Interrupt
1073 * Registerand Device OUT EP Common Interrupt Mask Register.
1075 * - Read the register into the <i>d32</i> member then set/clear the
1076 * bits using the <i>b</i>it elements.
1078 typedef union doepint_data {
1079 /** raw register data */
1081 /** register bits */
1083 /** Transfer complete */
1084 unsigned xfercompl:1;
1085 /** Endpoint disable */
1086 unsigned epdisabled:1;
1089 /** Setup Phase Done (contorl EPs) */
1091 /** OUT Token Received when Endpoint Disabled */
1092 unsigned outtknepdis:1;
1094 unsigned stsphsercvd:1;
1095 /** Back-to-Back SETUP Packets Received */
1096 unsigned back2backsetup:1;
1098 unsigned reserved7:1;
1099 /** OUT packet Error */
1100 unsigned outpkterr:1;
1101 /** BNA Interrupt */
1104 unsigned reserved10:1;
1105 /** Packet Drop Status */
1106 unsigned pktdrpsts:1;
1107 /** Babble Interrupt */
1109 /** NAK Interrupt */
1111 /** NYET Interrupt */
1114 unsigned reserved15_31:17;
1119 * This union represents the bit fields in the Device OUT EP
1120 * Common/Dedicated Interrupt Mask Register.
1122 typedef union doepint_data doepmsk_data_t;
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.
1130 typedef union daint_data {
1131 /** raw register data */
1133 /** register bits */
1135 /** IN Endpoint bits */
1137 /** OUT Endpoint bits */
1141 /** IN Endpoint bits */
1158 /** OUT Endpoint bits */
1179 * This union represents the bit fields in the Device IN Token Queue
1181 * - Read the register into the <i>d32</i> member.
1182 * - READ-ONLY Register
1184 typedef union dtknq1_data {
1185 /** raw register data */
1187 /** register bits */
1189 /** In Token Queue Write Pointer */
1190 unsigned intknwptr:5;
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;
1201 * This union represents Threshold control Register
1202 * - Read and write the register into the <i>d32</i> member.
1203 * - READ-WRITABLE Register
1205 typedef union dthrctl_data {
1206 /** raw register data */
1208 /** register bits */
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;
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;
1225 unsigned reserved26_31:6;
1230 * Device Logical IN Endpoint-Specific Registers. <i>Offsets
1233 * There will be one set of endpoint registers per logical endpoint
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>
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;
1265 * Device Logical OUT Endpoint-Specific Registers. <i>Offsets:
1268 * There will be one set of endpoint registers per logical endpoint
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>
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> */
1294 /** Device OUT Endpoint DMA Buffer Register. <i>Offset:B00h
1295 * + (ep_num * 20h) + 1Ch</i> */
1297 } dwc_otg_dev_out_ep_regs_t;
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.
1304 typedef union depctl_data {
1305 /** raw register data */
1307 /** register bits */
1309 /** Maximum Packet Size
1311 * IN/OUT EP0 - 2 bits
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
1324 * OUT EPn/OUT EP0 - reserved */
1327 /** USB Active Endpoint */
1328 unsigned usbactep:1;
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
1340 * The encoding for this field is
1351 * 2'b01: Isochronous
1353 * 2'b11: Interrupt */
1358 * IN EPn/IN EP0 - reserved */
1361 /** Stall Handshake */
1366 * OUT EPn/OUT EP0 - reserved */
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)
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.
1389 unsigned setd1pid:1;
1391 /** Endpoint Disable */
1393 /** Endpoint Enable */
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.
1403 typedef union deptsiz_data {
1404 /** raw register data */
1406 /** register bits */
1408 /** Transfer size */
1409 unsigned xfersize:19;
1412 /** Multi Count - Periodic IN endpoints */
1414 unsigned reserved:1;
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.
1423 typedef union deptsiz0_data {
1424 /** raw register data */
1426 /** register bits */
1428 /** Transfer size */
1429 unsigned xfersize:7;
1431 unsigned reserved7_18:12;
1435 unsigned reserved20_28:9;
1436 /**Setup Packet Count (DOEPTSIZ0 Only) */
1438 unsigned reserved31;
1442 /////////////////////////////////////////////////
1443 // DMA Descriptor Specific Structures
1446 /** Buffer status definitions */
1448 #define BS_HOST_READY 0x0
1449 #define BS_DMA_BUSY 0x1
1450 #define BS_DMA_DONE 0x2
1451 #define BS_HOST_BUSY 0x3
1453 /** Receive/Transmit status definitions */
1455 #define RTS_SUCCESS 0x0
1456 #define RTS_BUFFLUSH 0x1
1457 #define RTS_RESERVED 0x2
1458 #define RTS_BUFERR 0x3
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.
1466 typedef union desc_sts_data {
1467 /** raw register data */
1471 /** Received number of bytes */
1474 unsigned reserved16_22:7;
1475 /** Multiple Transfer - only for OUT EPs */
1477 /** Setup Packet received - only for OUT EPs */
1479 /** Interrupt On Complete */
1485 /** Receive Status */
1487 /** Buffer Status */
1492 /** iso out quadlet bits */
1494 /** Received number of bytes */
1495 unsigned rxbytes:11;
1497 unsigned reserved11:1;
1499 unsigned framenum:11;
1500 /** Received ISO Data PID */
1502 /** Interrupt On Complete */
1508 /** Receive Status */
1510 /** Buffer Status */
1514 /** iso in quadlet bits */
1516 /** Transmited number of bytes */
1517 unsigned txbytes:12;
1519 unsigned framenum:11;
1520 /** Transmited ISO Data PID */
1522 /** Interrupt On Complete */
1528 /** Transmit Status */
1530 /** Buffer Status */
1533 #endif /* DWC_EN_ISOC */
1537 * DMA Descriptor structure
1539 * DMA Descriptor structure contains two quadlets:
1540 * Status quadlet and Data buffer pointer.
1542 typedef struct dwc_otg_dma_desc {
1543 /** DMA Descriptor status quadlet */
1544 desc_sts_data_t status;
1545 /** DMA Descriptor data buffer pointer */
1547 } dwc_otg_dma_desc_t;
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.
1554 typedef struct dwc_otg_dev_if {
1555 /** Pointer to device Global registers.
1556 * Device Global Registers starting at offset 800h
1558 dwc_otg_device_global_regs_t *dev_global_regs;
1559 #define DWC_DEV_GLOBAL_REG_OFFSET 0x800
1562 * Device Logical IN Endpoint-Specific Registers 900h-AFCh
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
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
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*/
1577 /** Size of periodic FIFOs (Bytes) */
1578 uint16_t perio_tx_fifo_size[MAX_PERIO_FIFOS];
1580 /** Size of Tx FIFOs (Bytes) */
1581 uint16_t tx_fifo_size[MAX_TX_FIFOS];
1583 /** Thresholding enable flags and length varaiables **/
1585 uint16_t iso_tx_thr_en;
1586 uint16_t non_iso_tx_thr_en;
1588 uint16_t rx_thr_length;
1589 uint16_t tx_thr_length;
1592 * Pointers to the DMA Descriptors for EP0 Control
1593 * transfers (virtual and physical)
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];
1600 /** Pointer to Descriptor with latest SETUP packet */
1601 dwc_otg_dma_desc_t *psetup;
1603 /** Index of current SETUP handler descriptor */
1604 uint32_t setup_desc_index;
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;;
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;
1614 /** Setup Packet Detected - if set clear NAK when queueing */
1619 /////////////////////////////////////////////////
1620 // Host Mode Register Structures
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.
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;
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.
1649 typedef union hcfg_data {
1650 /** raw register data */
1653 /** register bits */
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
1661 /** FS/LS Only Support */
1662 unsigned fslssupp:1;
1667 * This union represents the bit fields in the Host Frame Remaing/Number
1670 typedef union hfir_data {
1671 /** raw register data */
1674 /** register bits */
1677 unsigned reserved:16;
1682 * This union represents the bit fields in the Host Frame Remaing/Number
1685 typedef union hfnum_data {
1686 /** raw register data */
1689 /** register bits */
1692 #define DWC_HFNUM_MAX_FRNUM 0x3FFF
1697 typedef union hptxsts_data {
1698 /** raw register data */
1701 /** register bits */
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
1711 * - bits 30:27 - Channel Number
1712 * - bit 31 - Odd/even microframe
1714 unsigned ptxqtop_terminate:1;
1715 unsigned ptxqtop_token:2;
1716 unsigned ptxqtop_chnum:4;
1717 unsigned ptxqtop_odd:1;
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
1727 typedef union hprt0_data {
1728 /** raw register data */
1730 /** register bits */
1732 unsigned prtconnsts:1;
1733 unsigned prtconndet:1;
1735 unsigned prtenchng:1;
1736 unsigned prtovrcurract:1;
1737 unsigned prtovrcurrchng:1;
1741 unsigned reserved9:1;
1742 unsigned prtlnsts:2;
1744 unsigned prttstctl:4;
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;
1754 * This union represents the bit fields in the Host All Interrupt
1757 typedef union haint_data {
1758 /** raw register data */
1760 /** register bits */
1778 unsigned reserved:16;
1783 unsigned reserved:16;
1788 * This union represents the bit fields in the Host All Interrupt
1791 typedef union haintmsk_data {
1792 /** raw register data */
1794 /** register bits */
1812 unsigned reserved:16;
1817 unsigned reserved:16;
1822 * Host Channel Specific Registers. <i>500h-5FCh</i>
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;
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
1847 typedef union hcchar_data {
1848 /** raw register data */
1851 /** register bits */
1853 /** Maximum packet size in bytes */
1856 /** Endpoint number */
1859 /** 0: OUT, 1: IN */
1862 unsigned reserved:1;
1864 /** 0: Full/high speed device, 1: Low speed device */
1867 /** 0: Control, 1: Isoc, 2: Bulk, 3: Intr */
1870 /** Packets per frame for periodic transfers. 0 is reserved. */
1871 unsigned multicnt:2;
1873 /** Device address */
1877 * Frame to transmit periodic transaction.
1882 /** Channel disable */
1885 /** Channel enable */
1890 typedef union hcsplt_data {
1891 /** raw register data */
1894 /** register bits */
1902 /** Transaction Position */
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
1909 /** Do Complete Split */
1910 unsigned compsplt:1;
1913 unsigned reserved:14;
1921 * This union represents the bit fields in the Host All Interrupt
1924 typedef union hcint_data {
1925 /** raw register data */
1927 /** register bits */
1929 /** Transfer Complete */
1930 unsigned xfercomp:1;
1931 /** Channel Halted */
1935 /** STALL Response Received */
1937 /** NAK Response Received */
1939 /** ACK Response Received */
1941 /** NYET Response Received */
1943 /** Transaction Err */
1947 /** Frame Overrun */
1948 unsigned frmovrun:1;
1949 /** Data Toggle Error */
1950 unsigned datatglerr:1;
1952 unsigned reserved:21;
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
1962 typedef union hctsiz_data {
1963 /** raw register data */
1966 /** register bits */
1968 /** Total transfer size in bytes */
1969 unsigned xfersize:19;
1971 /** Data packets to transfer */
1975 * Packet ID for next data packet
1979 * 3: MDATA (non-Control), SETUP (Control)
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
1988 /** Do PING protocol when 1 */
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.
1999 typedef union hcintmsk_data {
2000 /** raw register data */
2003 /** register bits */
2005 unsigned xfercompl:1;
2014 unsigned frmovrun:1;
2015 unsigned datatglerr:1;
2016 unsigned reserved:21;
2020 /** OTG Host Interface Structure.
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
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
2032 /** Host Port 0 Control and Status Register */
2033 volatile uint32_t *hprt0;
2034 #define DWC_OTG_HOST_PORT_REGS_OFFSET 0x440
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
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;
2049 } dwc_otg_host_if_t;
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.
2056 typedef union pcgcctl_data {
2057 /** raw register data */
2060 /** register bits */
2063 unsigned stoppclk:1;
2065 unsigned gatehclk: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;
2077 unsigned deep_sleep:1;
2079 unsigned reserved31_8:24;