blob: 5f1c0e57eb2f331449d0263695728feb7593f575 [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001/* ==========================================================================
2 * $File: //dwh/usb_iip/dev/software/otg/linux/drivers/dwc_otg_regs.h $
3 * $Revision: #98 $
4 * $Date: 2012/08/10 $
5 * $Change: 2047372 $
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#include "dwc_otg_core_if.h"
37
38/**
39 * @file
40 *
41 * This file contains the data structures for accessing the DWC_otg core registers.
42 *
43 * The application interfaces with the HS OTG core by reading from and
44 * writing to the Control and Status Register (CSR) space through the
45 * AHB Slave interface. These registers are 32 bits wide, and the
46 * addresses are 32-bit-block aligned.
47 * CSRs are classified as follows:
48 * - Core Global Registers
49 * - Device Mode Registers
50 * - Device Global Registers
51 * - Device Endpoint Specific Registers
52 * - Host Mode Registers
53 * - Host Global Registers
54 * - Host Port CSRs
55 * - Host Channel Specific Registers
56 *
57 * Only the Core Global registers can be accessed in both Device and
58 * Host modes. When the HS OTG core is operating in one mode, either
59 * Device or Host, the application must not access registers from the
60 * other mode. When the core switches from one mode to another, the
61 * registers in the new mode of operation must be reprogrammed as they
62 * would be after a power-on reset.
63 */
64
65/****************************************************************************/
66/** DWC_otg Core registers .
67 * The dwc_otg_core_global_regs structure defines the size
68 * and relative field offsets for the Core Global registers.
69 */
70typedef struct dwc_otg_core_global_regs
71{
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 /**Core USB Configuration Register. <i>Offset: 00Ch</i> */
79 volatile uint32_t gusbcfg;
80 /**Core Reset Register. <i>Offset: 010h</i> */
81 volatile uint32_t grstctl;
82 /**Core Interrupt Register. <i>Offset: 014h</i> */
83 volatile uint32_t gintsts;
84 /**Core Interrupt Mask Register. <i>Offset: 018h</i> */
85 volatile uint32_t gintmsk;
86 /**Receive Status Queue Read Register (Read Only). <i>Offset: 01Ch</i> */
87 volatile uint32_t grxstsr;
88 /**Receive Status Queue Read & POP Register (Read Only). <i>Offset: 020h</i>*/
89 volatile uint32_t grxstsp;
90 /**Receive FIFO Size Register. <i>Offset: 024h</i> */
91 volatile uint32_t grxfsiz;
92 /**Non Periodic Transmit FIFO Size Register. <i>Offset: 028h</i> */
93 volatile uint32_t gnptxfsiz;
94 /**Non Periodic Transmit FIFO/Queue Status Register (Read
95 * Only). <i>Offset: 02Ch</i> */
96 volatile uint32_t gnptxsts;
97 /**I2C Access Register. <i>Offset: 030h</i> */
98 volatile uint32_t gi2cctl;
99 /**PHY Vendor Control Register. <i>Offset: 034h</i> */
100 volatile uint32_t gpvndctl;
101 /**General Purpose Input/Output Register. <i>Offset: 038h</i> */
102 volatile uint32_t ggpio;
103 /**User ID Register. <i>Offset: 03Ch</i> */
104 volatile uint32_t guid;
105 /**Synopsys ID Register (Read Only). <i>Offset: 040h</i> */
106 volatile uint32_t gsnpsid;
107 /**User HW Config1 Register (Read Only). <i>Offset: 044h</i> */
108 volatile uint32_t ghwcfg1;
109 /**User HW Config2 Register (Read Only). <i>Offset: 048h</i> */
110 volatile uint32_t ghwcfg2;
111 /**User HW Config3 Register (Read Only). <i>Offset: 04Ch</i> */
112 volatile uint32_t ghwcfg3;
113 /**User HW Config4 Register (Read Only). <i>Offset: 050h</i>*/
114 volatile uint32_t ghwcfg4;
115 /** Core LPM Configuration register <i>Offset: 054h</i>*/
116 volatile uint32_t glpmcfg;
117 /** Global PowerDn Register <i>Offset: 058h</i> */
118 volatile uint32_t gpwrdn;
119 /** Global DFIFO SW Config Register <i>Offset: 05Ch</i> */
120 volatile uint32_t gdfifocfg;
121 /** ADP Control Register <i>Offset: 060h</i> */
122 volatile uint32_t adpctl;
123} dwc_otg_core_global_regs_t;
124
125/**
126 * This union represents the bit fields of the Core OTG Control
127 * and Status Register (GOTGCTL). Set the bits using the bit
128 * fields then write the <i>d32</i> value to the register.
129 */
130typedef union gotgctl_data
131{
132 /** raw register data */
133 uint32_t d32;
134 /** register bits */
135 struct
136 {
137 unsigned sesreqscs:1;
138 unsigned sesreq:1;
139 unsigned vbvalidoven:1;
140 unsigned vbvalidovval:1;
141 unsigned avalidoven:1;
142 unsigned avalidovval:1;
143 unsigned bvalidoven:1;
144 unsigned bvalidovval:1;
145 unsigned hstnegscs:1;
146 unsigned hnpreq:1;
147 unsigned hstsethnpen:1;
148 unsigned devhnpen:1;
149 unsigned reserved12_15:4;
150 unsigned conidsts:1;
151 unsigned dbnctime:1;
152 unsigned asesvld:1;
153 unsigned bsesvld:1;
154 unsigned otgver:1;
155 unsigned reserved1:1;
156 unsigned multvalidbc:5;
157 unsigned chirpen:1;
158 unsigned reserved28_31:4;
159 } b;
160} gotgctl_data_t;
161/**
162 * This union represents the bit fields of the Core AHB Configuration
163 * Register (GAHBCFG). Set/clear the bits using the bit fields then
164 * write the <i>d32</i> value to the register.
165 */
166#define DWC_GAHBCFG_TXFEMPTYLVL_EMPTY 1
167#define DWC_GAHBCFG_TXFEMPTYLVL_HALFEMPTY 0
168typedef union gahbcfg_data
169{
170 /** raw register data */
171 uint32_t d32;
172 /** register bits */
173 struct
174 {
175 unsigned glblintrmsk:1;
176 unsigned hburstlen:4;
177 unsigned dmaenable:1;
178 unsigned reserved:1;
179 unsigned nptxfemplvl_txfemplvl:1;
180 unsigned ptxfemplvl:1;
181 unsigned reserved9_20:12;
182 unsigned remmemsupp:1;
183 unsigned notialldmawrit:1;
184 unsigned ahbsingle:1;
185 unsigned reserved24_31:8;
186 } b;
187} gahbcfg_data_t;
188
189/**
190 * This union represents the bit fields of the Core USB Configuration
191 * Register (GUSBCFG). Set the bits using the bit fields then write
192 * the <i>d32</i> value to the register.
193 */
194typedef union gusbcfg_data
195{
196 /** raw register data */
197 uint32_t d32;
198 /** register bits */
199 struct
200 {
201 unsigned toutcal:3;
202 unsigned phyif:1;
203 unsigned ulpi_utmi_sel:1;
204 unsigned fsintf:1;
205 unsigned physel:1;
206 unsigned ddrsel:1;
207 unsigned srpcap:1;
208 unsigned hnpcap:1;
209 unsigned usbtrdtim:4;
210 unsigned reserved1:1;
211 unsigned phylpwrclksel:1;
212 unsigned otgutmifssel:1;
213 unsigned ulpi_fsls:1;
214 unsigned ulpi_auto_res:1;
215 unsigned ulpi_clk_sus_m:1;
216 unsigned ulpi_ext_vbus_drv:1;
217 unsigned ulpi_int_vbus_indicator:1;
218 unsigned term_sel_dl_pulse:1;
219 unsigned indicator_complement:1;
220 unsigned indicator_pass_through:1;
221 unsigned ulpi_int_prot_dis:1;
222 unsigned ic_usb_cap:1;
223 unsigned ic_traffic_pull_remove:1;
224 unsigned tx_end_delay:1;
225 unsigned force_host_mode:1;
226 unsigned force_dev_mode:1;
227 unsigned reserved31:1;
228 } b;
229} gusbcfg_data_t;
230
231/**
232 * This union represents the bit fields of the Core Reset Register
233 * (GRSTCTL). Set/clear the bits using the bit fields then write the
234 * <i>d32</i> value to the register.
235 */
236typedef union grstctl_data
237{
238 /** raw register data */
239 uint32_t d32;
240 /** register bits */
241 struct
242 {
243 /** Core Soft Reset (CSftRst) (Device and Host)
244 *
245 * The application can flush the control logic in the
246 * entire core using this bit. This bit resets the
247 * pipelines in the AHB Clock domain as well as the
248 * PHY Clock domain.
249 *
250 * The state machines are reset to an IDLE state, the
251 * control bits in the CSRs are cleared, all the
252 * transmit FIFOs and the receive FIFO are flushed.
253 *
254 * The status mask bits that control the generation of
255 * the interrupt, are cleared, to clear the
256 * interrupt. The interrupt status bits are not
257 * cleared, so the application can get the status of
258 * any events that occurred in the core after it has
259 * set this bit.
260 *
261 * Any transactions on the AHB are terminated as soon
262 * as possible following the protocol. Any
263 * transactions on the USB are terminated immediately.
264 *
265 * The configuration settings in the CSRs are
266 * unchanged, so the software doesn't have to
267 * reprogram these registers (Device
268 * Configuration/Host Configuration/Core System
269 * Configuration/Core PHY Configuration).
270 *
271 * The application can write to this bit, any time it
272 * wants to reset the core. This is a self clearing
273 * bit and the core clears this bit after all the
274 * necessary logic is reset in the core, which may
275 * take several clocks, depending on the current state
276 * of the core.
277 */
278 unsigned csftrst:1;
279 /** Hclk Soft Reset
280 *
281 * The application uses this bit to reset the control logic in
282 * the AHB clock domain. Only AHB clock domain pipelines are
283 * reset.
284 */
285 unsigned hsftrst:1;
286 /** Host Frame Counter Reset (Host Only)<br>
287 *
288 * The application can reset the (micro)frame number
289 * counter inside the core, using this bit. When the
290 * (micro)frame counter is reset, the subsequent SOF
291 * sent out by the core, will have a (micro)frame
292 * number of 0.
293 */
294 unsigned hstfrm:1;
295 /** In Token Sequence Learning Queue Flush
296 * (INTknQFlsh) (Device Only)
297 */
298 unsigned intknqflsh:1;
299 /** RxFIFO Flush (RxFFlsh) (Device and Host)
300 *
301 * The application can flush the entire Receive FIFO
302 * using this bit. The application must first
303 * ensure that the core is not in the middle of a
304 * transaction. The application should write into
305 * this bit, only after making sure that neither the
306 * DMA engine is reading from the RxFIFO nor the MAC
307 * is writing the data in to the FIFO. The
308 * application should wait until the bit is cleared
309 * before performing any other operations. This bit
310 * will takes 8 clocks (slowest of PHY or AHB clock)
311 * to clear.
312 */
313 unsigned rxfflsh:1;
314 /** TxFIFO Flush (TxFFlsh) (Device and Host).
315 *
316 * This bit is used to selectively flush a single or
317 * all transmit FIFOs. The application must first
318 * ensure that the core is not in the middle of a
319 * transaction. The application should write into
320 * this bit, only after making sure that neither the
321 * DMA engine is writing into the TxFIFO nor the MAC
322 * is reading the data out of the FIFO. The
323 * application should wait until the core clears this
324 * bit, before performing any operations. This bit
325 * will takes 8 clocks (slowest of PHY or AHB clock)
326 * to clear.
327 */
328 unsigned txfflsh:1;
329
330 /** TxFIFO Number (TxFNum) (Device and Host).
331 *
332 * This is the FIFO number which needs to be flushed,
333 * using the TxFIFO Flush bit. This field should not
334 * be changed until the TxFIFO Flush bit is cleared by
335 * the core.
336 * - 0x0 : Non Periodic TxFIFO Flush
337 * - 0x1 : Periodic TxFIFO #1 Flush in device mode
338 * or Periodic TxFIFO in host mode
339 * - 0x2 : Periodic TxFIFO #2 Flush in device mode.
340 * - ...
341 * - 0xF : Periodic TxFIFO #15 Flush in device mode
342 * - 0x10: Flush all the Transmit NonPeriodic and
343 * Transmit Periodic FIFOs in the core
344 */
345 unsigned txfnum:5;
346 /** Reserved */
347 unsigned reserved11_29:19;
348 /** DMA Request Signal. Indicated DMA request is in
349 * probress. Used for debug purpose. */
350 unsigned dmareq:1;
351 /** AHB Master Idle. Indicates the AHB Master State
352 * Machine is in IDLE condition. */
353 unsigned ahbidle:1;
354 } b;
355} grstctl_t;
356
357/**
358 * This union represents the bit fields of the Core Interrupt Mask
359 * Register (GINTMSK). Set/clear the bits using the bit fields then
360 * write the <i>d32</i> value to the register.
361 */
362typedef union gintmsk_data
363{
364 /** raw register data */
365 uint32_t d32;
366 /** register bits */
367 struct
368 {
369 unsigned reserved0:1;
370 unsigned modemismatch:1;
371 unsigned otgintr:1;
372 unsigned sofintr:1;
373 unsigned rxstsqlvl:1;
374 unsigned nptxfempty:1;
375 unsigned ginnakeff:1;
376 unsigned goutnakeff:1;
377 unsigned ulpickint:1;
378 unsigned i2cintr:1;
379 unsigned erlysuspend:1;
380 unsigned usbsuspend:1;
381 unsigned usbreset:1;
382 unsigned enumdone:1;
383 unsigned isooutdrop:1;
384 unsigned eopframe:1;
385 unsigned restoredone:1;
386 unsigned epmismatch:1;
387 unsigned inepintr:1;
388 unsigned outepintr:1;
389 unsigned incomplisoin:1;
390 unsigned incomplisoout:1;
391 unsigned fetsusp:1;
392 unsigned resetdet:1;
393 unsigned portintr:1;
394 unsigned hcintr:1;
395 unsigned ptxfempty:1;
396 unsigned lpmtranrcvd:1;
397 unsigned conidstschng:1;
398 unsigned disconnect:1;
399 unsigned sessreqintr:1;
400 unsigned wkupintr:1;
401 } b;
402} gintmsk_data_t;
403/**
404 * This union represents the bit fields of the Core Interrupt Register
405 * (GINTSTS). Set/clear the bits using the bit fields then write the
406 * <i>d32</i> value to the register.
407 */
408#define DWC_SOF_INTR_MASK 0x0008
409#define DWC_HOST_MODE 1
410
411typedef union gintsts_data
412{
413 /** raw register data */
414 uint32_t d32;
415 /** register bits */
416 struct
417 {
418 unsigned curmode:1;
419 unsigned modemismatch:1;
420 unsigned otgintr:1;
421 unsigned sofintr:1;
422 unsigned rxstsqlvl:1;
423 unsigned nptxfempty:1;
424 unsigned ginnakeff:1;
425 unsigned goutnakeff:1;
426 unsigned ulpickint:1;
427 unsigned i2cintr:1;
428 unsigned erlysuspend:1;
429 unsigned usbsuspend:1;
430 unsigned usbreset:1;
431 unsigned enumdone:1;
432 unsigned isooutdrop:1;
433 unsigned eopframe:1;
434 unsigned restoredone:1;
435 unsigned epmismatch:1;
436 unsigned inepint:1;
437 unsigned outepintr:1;
438 unsigned incomplisoin:1;
439 unsigned incomplisoout:1;
440 unsigned fetsusp:1;
441 unsigned resetdet:1;
442 unsigned portintr:1;
443 unsigned hcintr:1;
444 unsigned ptxfempty:1;
445 unsigned lpmtranrcvd:1;
446 unsigned conidstschng:1;
447 unsigned disconnect:1;
448 unsigned sessreqintr:1;
449 unsigned wkupintr:1;
450 } b;
451} gintsts_data_t;
452
453/**
454 * This union represents the bit fields in the Device Receive Status Read and
455 * Pop Registers (GRXSTSR, GRXSTSP) Read the register into the <i>d32</i>
456 * element then read out the bits using the <i>b</i>it elements.
457 */
458
459#define DWC_STS_DATA_UPDT 0x2 // OUT Data Packet
460#define DWC_STS_XFER_COMP 0x3 // OUT Data Transfer Complete
461#define DWC_DSTS_GOUT_NAK 0x1 // Global OUT NAK
462#define DWC_DSTS_SETUP_COMP 0x4 // Setup Phase Complete
463#define DWC_DSTS_SETUP_UPDT 0x6 // SETUP Packet
464
465typedef union device_grxsts_data
466{
467 /** raw register data */
468 uint32_t d32;
469 /** register bits */
470 struct
471 {
472 unsigned epnum:4;
473 unsigned bcnt:11;
474 unsigned dpid:2;
475 unsigned pktsts:4;
476 unsigned fn:4;
477 unsigned reserved25_31:7;
478 } b;
479} device_grxsts_data_t;
480/**
481 * This union represents the bit fields in the FIFO Size Registers (HPTXFSIZ,
482 * GNPTXFSIZ, DPTXFSIZn, DIEPTXFn). Read the register into the <i>d32</i> element
483 * then read out the bits using the <i>b</i>it elements.
484 */
485typedef union fifosize_data
486{
487 /** raw register data */
488 uint32_t d32;
489 /** register bits */
490 struct
491 {
492 unsigned startaddr:16;
493 unsigned depth:16;
494 } b;
495} fifosize_data_t;
496
497/**
498 * This union represents the bit fields in the Non-Periodic Transmit
499 * FIFO/Queue Status Register (GNPTXSTS). Read the register into the
500 * <i>d32</i> element then read out the bits using the <i>b</i>it
501 * elements.
502 */
503typedef union gnptxsts_data
504{
505 /** raw register data */
506 uint32_t d32;
507 /** register bits */
508 struct
509 {
510 unsigned nptxfspcavail:16;
511 unsigned nptxqspcavail:8;
512 /** Top of the Non-Periodic Transmit Request Queue
513 * - bit 24 - Terminate (Last entry for the selected
514 * channel/EP)
515 * - bits 26:25 - Token Type
516 * - 2'b00 - IN/OUT
517 * - 2'b01 - Zero Length OUT
518 * - 2'b10 - PING/Complete Split
519 * - 2'b11 - Channel Halt
520 * - bits 30:27 - Channel/EP Number
521 */
522 unsigned nptxqtop_terminate:1;
523 unsigned nptxqtop_token:2;
524 unsigned nptxqtop_chnep:4;
525 unsigned reserved:1;
526 } b;
527} gnptxsts_data_t;
528
529/**
530 * This union represents the bit fields in the Transmit
531 * FIFO Status Register (DTXFSTS). Read the register into the
532 * <i>d32</i> element then read out the bits using the <i>b</i>it
533 * elements.
534 */
535typedef union dtxfsts_data
536{
537 /** raw register data */
538 uint32_t d32;
539 /** register bits */
540 struct
541 {
542 unsigned txfspcavail:16;
543 unsigned reserved:16;
544 } b;
545} dtxfsts_data_t;
546/**
547 * This union represents the bit fields in the User HW Config1
548 * Register. Read the register into the <i>d32</i> element then read
549 * out the bits using the <i>b</i>it elements.
550 */
551typedef union hwcfg1_data
552{
553 /** raw register data */
554 uint32_t d32;
555 /** register bits */
556 struct
557 {
558 unsigned ep_dir0:2;
559 unsigned ep_dir1:2;
560 unsigned ep_dir2:2;
561 unsigned ep_dir3:2;
562 unsigned ep_dir4:2;
563 unsigned ep_dir5:2;
564 unsigned ep_dir6:2;
565 unsigned ep_dir7:2;
566 unsigned ep_dir8:2;
567 unsigned ep_dir9:2;
568 unsigned ep_dir10:2;
569 unsigned ep_dir11:2;
570 unsigned ep_dir12:2;
571 unsigned ep_dir13:2;
572 unsigned ep_dir14:2;
573 unsigned ep_dir15:2;
574 } b;
575} hwcfg1_data_t;
576
577/**
578 * This union represents the bit fields in the User HW Config2
579 * Register. Read the register into the <i>d32</i> element then read
580 * out the bits using the <i>b</i>it elements.
581 */
582#define DWC_HWCFG2_OP_MODE_SRP_ONLY_CAPABLE_OTG 1
583#define DWC_HWCFG2_OP_MODE_NO_HNP_SRP_CAPABLE_OTG 2
584#define DWC_HWCFG2_OP_MODE_SRP_CAPABLE_DEVICE 3
585#define DWC_HWCFG2_OP_MODE_NO_SRP_CAPABLE_DEVICE 4
586#define DWC_HWCFG2_OP_MODE_SRP_CAPABLE_HOST 5
587#define DWC_HWCFG2_OP_MODE_NO_SRP_CAPABLE_HOST 6
588#define DWC_HWCFG2_HS_PHY_TYPE_NOT_SUPPORTED 0
589#define DWC_HWCFG2_HS_PHY_TYPE_UTMI 1
590#define DWC_HWCFG2_HS_PHY_TYPE_ULPI 2
591#define DWC_HWCFG2_HS_PHY_TYPE_UTMI_ULPI 3
592
593typedef union hwcfg2_data
594{
595 /** raw register data */
596 uint32_t d32;
597 /** register bits */
598 struct
599 {
600 /* GHWCFG2 */
601 unsigned op_mode:3;
602 unsigned architecture:2; //00 salve-only;01 external dma;10 internal dma;
603 unsigned point2point:1;
604 unsigned hs_phy_type:2;
605 unsigned fs_phy_type:2;
606 unsigned num_dev_ep:4;
607 unsigned num_host_chan:4;
608 unsigned perio_ep_supported:1;
609 unsigned dynamic_fifo:1;
610 unsigned multi_proc_int:1;
611 unsigned reserved21:1;
612 unsigned nonperio_tx_q_depth:2;
613 unsigned host_perio_tx_q_depth:2;
614 unsigned dev_token_q_depth:5;
615 unsigned otg_enable_ic_usb:1;
616 } b;
617} hwcfg2_data_t;
618
619/**
620 * This union represents the bit fields in the User HW Config3
621 * Register. Read the register into the <i>d32</i> element then read
622 * out the bits using the <i>b</i>it elements.
623 */
624typedef union hwcfg3_data
625{
626 /** raw register data */
627 uint32_t d32;
628 /** register bits */
629 struct
630 {
631 /* GHWCFG3 */
632 unsigned xfer_size_cntr_width:4;
633 unsigned packet_size_cntr_width:3;
634 unsigned otg_func:1;
635 unsigned i2c:1;
636 unsigned vendor_ctrl_if:1;
637 unsigned optional_features:1;
638 unsigned synch_reset_type:1;
639 unsigned adp_supp:1;
640 unsigned otg_enable_hsic:1;
641 unsigned bc_support:1;
642 unsigned otg_lpm_en:1;
643 unsigned dfifo_depth:16;
644 } b;
645} hwcfg3_data_t;
646
647/**
648 * This union represents the bit fields in the User HW Config4
649 * Register. Read the register into the <i>d32</i> element then read
650 * out the bits using the <i>b</i>it elements.
651 */
652typedef union hwcfg4_data
653{
654 /** raw register data */
655 uint32_t d32;
656 /** register bits */
657 struct
658 {
659 unsigned num_dev_perio_in_ep:4;
660 unsigned power_optimiz:1;
661 unsigned min_ahb_freq:1;
662 unsigned hiber:1;
663 unsigned xhiber:1;
664 unsigned reserved:6;
665 unsigned utmi_phy_data_width:2;
666 unsigned num_dev_mode_ctrl_ep:4;
667 unsigned iddig_filt_en:1;
668 unsigned vbus_valid_filt_en:1;
669 unsigned a_valid_filt_en:1;
670 unsigned b_valid_filt_en:1;
671 unsigned session_end_filt_en:1;
672 unsigned ded_fifo_en:1;
673 unsigned num_in_eps:4;
674 unsigned desc_dma:1;
675 unsigned desc_dma_dyn:1;
676 } b;
677} hwcfg4_data_t;
678
679/**
680 * This union represents the bit fields of the Core LPM Configuration
681 * Register (GLPMCFG). Set the bits using bit fields then write
682 * the <i>d32</i> value to the register.
683 */
684typedef union glpmctl_data
685{
686 /** raw register data */
687 uint32_t d32;
688 /** register bits */
689 struct
690 {
691 /** LPM-Capable (LPMCap) (Device and Host)
692 * The application uses this bit to control
693 * the DWC_otg core LPM capabilities.
694 */
695 unsigned lpm_cap_en:1;
696 /** LPM response programmed by application (AppL1Res) (Device)
697 * Handshake response to LPM token pre-programmed
698 * by device application software.
699 */
700 unsigned appl_resp:1;
701 /** Host Initiated Resume Duration (HIRD) (Device and Host)
702 * In Host mode this field indicates the value of HIRD
703 * to be sent in an LPM transaction.
704 * In Device mode this field is updated with the
705 * Received LPM Token HIRD bmAttribute
706 * when an ACK/NYET/STALL response is sent
707 * to an LPM transaction.
708 */
709 unsigned hird:4;
710 /** RemoteWakeEnable (bRemoteWake) (Device and Host)
711 * In Host mode this bit indicates the value of remote
712 * wake up to be sent in wIndex field of LPM transaction.
713 * In Device mode this field is updated with the
714 * Received LPM Token bRemoteWake bmAttribute
715 * when an ACK/NYET/STALL response is sent
716 * to an LPM transaction.
717 */
718 unsigned rem_wkup_en:1;
719 /** Enable utmi_sleep_n (EnblSlpM) (Device and Host)
720 * The application uses this bit to control
721 * the utmi_sleep_n assertion to the PHY when in L1 state.
722 */
723 unsigned en_utmi_sleep:1;
724 /** HIRD Threshold (HIRD_Thres) (Device and Host)
725 */
726 unsigned hird_thres:5;
727 /** LPM Response (CoreL1Res) (Device and Host)
728 * In Host mode this bit contains handsake response to
729 * LPM transaction.
730 * In Device mode the response of the core to
731 * LPM transaction received is reflected in these two bits.
732 - 0x0 : ERROR (No handshake response)
733 - 0x1 : STALL
734 - 0x2 : NYET
735 - 0x3 : ACK
736 */
737 unsigned lpm_resp:2;
738 /** Port Sleep Status (SlpSts) (Device and Host)
739 * This bit is set as long as a Sleep condition
740 * is present on the USB bus.
741 */
742 unsigned prt_sleep_sts:1;
743 /** Sleep State Resume OK (L1ResumeOK) (Device and Host)
744 * Indicates that the application or host
745 * can start resume from Sleep state.
746 */
747 unsigned sleep_state_resumeok:1;
748 /** LPM channel Index (LPM_Chnl_Indx) (Host)
749 * The channel number on which the LPM transaction
750 * has to be applied while sending
751 * an LPM transaction to the local device.
752 */
753 unsigned lpm_chan_index:4;
754 /** LPM Retry Count (LPM_Retry_Cnt) (Host)
755 * Number host retries that would be performed
756 * if the device response was not valid response.
757 */
758 unsigned retry_count:3;
759 /** Send LPM Transaction (SndLPM) (Host)
760 * When set by application software,
761 * an LPM transaction containing two tokens
762 * is sent.
763 */
764 unsigned send_lpm:1;
765 /** LPM Retry status (LPM_RetryCnt_Sts) (Host)
766 * Number of LPM Host Retries still remaining
767 * to be transmitted for the current LPM sequence
768 */
769 unsigned retry_count_sts:3;
770 unsigned reserved28_29:2;
771 /** In host mode once this bit is set, the host
772 * configures to drive the HSIC Idle state on the bus.
773 * It then waits for the device to initiate the Connect sequence.
774 * In device mode once this bit is set, the device waits for
775 * the HSIC Idle line state on the bus. Upon receving the Idle
776 * line state, it initiates the HSIC Connect sequence.
777 */
778 unsigned hsic_connect:1;
779 /** This bit overrides and functionally inverts
780 * the if_select_hsic input port signal.
781 */
782 unsigned inv_sel_hsic:1;
783 } b;
784} glpmcfg_data_t;
785// Device Registers
786/**
787 * Device Global Registers. <i>Offsets 800h-BFFh</i>
788 *
789 * The following structures define the size and relative field offsets
790 * for the Device Mode Registers.
791 *
792 * <i>These registers are visible only in Device mode and must not be
793 * accessed in Host mode, as the results are unknown.</i>
794 */
795typedef struct dwc_otg_dev_global_regs
796{
797 /** Device Configuration Register. <i>Offset 800h</i> */
798 volatile uint32_t dcfg;
799 /** Device Control Register. <i>Offset: 804h</i> */
800 volatile uint32_t dctl;
801 /** Device Status Register (Read Only). <i>Offset: 808h</i> */
802 volatile uint32_t dsts;
803 /** Reserved. <i>Offset: 80Ch</i> */
804 uint32_t unused;
805 /** Device IN Endpoint Common Interrupt Mask
806 * Register. <i>Offset: 810h</i> */
807 volatile uint32_t diepmsk;
808 /** Device OUT Endpoint Common Interrupt Mask
809 * Register. <i>Offset: 814h</i> */
810 volatile uint32_t doepmsk;
811 /** Device All Endpoints Interrupt Register. <i>Offset: 818h</i> */
812 volatile uint32_t daint;
813 /** Device All Endpoints Interrupt Mask Register. <i>Offset:
814 * 81Ch</i> */
815 volatile uint32_t daintmsk;
816 /** Device IN Token Queue Read Register-1 (Read Only).
817 * <i>Offset: 820h</i> */
818 volatile uint32_t dtknqr1;
819 /** Device IN Token Queue Read Register-2 (Read Only).
820 * <i>Offset: 824h</i> */
821 volatile uint32_t dtknqr2;
822 /** Device VBUS discharge Register. <i>Offset: 828h</i> */
823 volatile uint32_t dvbusdis;
824 /** Device VBUS Pulse Register. <i>Offset: 82Ch</i> */
825 volatile uint32_t dvbuspulse;
826 /** Device IN Token Queue Read Register-3 (Read Only). /
827 * Device Thresholding control register (Read/Write)
828 * <i>Offset: 830h</i> */
829 volatile uint32_t dtknqr3_dthrctl;
830 /** Device IN Token Queue Read Register-4 (Read Only). /
831 * Device IN EPs empty Inr. Mask Register (Read/Write)
832 * <i>Offset: 834h</i> */
833 volatile uint32_t dtknqr4_fifoemptymsk;
834 /** Device Each Endpoint Interrupt Register (Read Only). /
835 * <i>Offset: 838h</i> */
836 volatile uint32_t deachint;
837 /** Device Each Endpoint Interrupt mask Register (Read/Write). /
838 * <i>Offset: 83Ch</i> */
839 volatile uint32_t deachintmsk;
840 /** Device Each In Endpoint Interrupt mask Register (Read/Write). /
841 * <i>Offset: 840h</i> */
842 volatile uint32_t diepeachintmsk[MAX_EPS_CHANNELS];
843 /** Device Each Out Endpoint Interrupt mask Register (Read/Write). /
844 * <i>Offset: 880h</i> */
845 volatile uint32_t doepeachintmsk[MAX_EPS_CHANNELS];
846} dwc_otg_device_global_regs_t;
847
848/**
849 * This union represents the bit fields in the Device Configuration
850 * Register. Read the register into the <i>d32</i> member then
851 * set/clear the bits using the <i>b</i>it elements. Write the
852 * <i>d32</i> member to the dcfg register.
853 */
854#define DWC_DCFG_SEND_STALL 1
855#define DWC_DCFG_FRAME_INTERVAL_80 0
856#define DWC_DCFG_FRAME_INTERVAL_85 1
857#define DWC_DCFG_FRAME_INTERVAL_90 2
858#define DWC_DCFG_FRAME_INTERVAL_95 3
859
860typedef union dcfg_data
861{
862 /** raw register data */
863 uint32_t d32;
864 /** register bits */
865 struct
866 {
867 /** Device Speed */
868 unsigned devspd:2;
869 /** Non Zero Length Status OUT Handshake */
870 unsigned nzstsouthshk:1;
871 unsigned ena32khzs:1;
872 /** Device Addresses */
873 unsigned devaddr:7;
874 /** Periodic Frame Interval */
875 unsigned perfrint:2;
876 /** Enable Device OUT NAK for bulk in DDMA mode */
877 unsigned endevoutnak:1;
878 unsigned reserved14_17:4;
879 /** In Endpoint Mis-match count */
880 unsigned epmscnt:5;
881 /** Enable Descriptor DMA in Device mode */
882 unsigned descdma:1;
883 unsigned perschintvl:2;
884 unsigned resvalid:6;
885 } b;
886} dcfg_data_t;
887
888/**
889 * This union represents the bit fields in the Device Control
890 * Register. Read the register into the <i>d32</i> member then
891 * set/clear the bits using the <i>b</i>it elements.
892 */
893typedef union dctl_data
894{
895 /** raw register data */
896 uint32_t d32;
897 /** register bits */
898 struct
899 {
900 /** Remote Wakeup */
901 unsigned rmtwkupsig:1;
902 /** Soft Disconnect */
903 unsigned sftdiscon:1;
904 /** Global Non-Periodic IN NAK Status */
905 unsigned gnpinnaksts:1;
906 /** Global OUT NAK Status */
907 unsigned goutnaksts:1;
908 /** Test Control */
909 unsigned tstctl:3;
910 /** Set Global Non-Periodic IN NAK */
911 unsigned sgnpinnak:1;
912 /** Clear Global Non-Periodic IN NAK */
913 unsigned cgnpinnak:1;
914 /** Set Global OUT NAK */
915 unsigned sgoutnak:1;
916 /** Clear Global OUT NAK */
917 unsigned cgoutnak:1;
918 /** Power-On Programming Done */
919 unsigned pwronprgdone:1;
920 /** Reserved */
921 unsigned reserved:1;
922 /** Global Multi Count */
923 unsigned gmc:2;
924 /** Ignore Frame Number for ISOC EPs */
925 unsigned ifrmnum:1;
926 /** NAK on Babble */
927 unsigned nakonbble:1;
928 /** Enable Continue on BNA */
929 unsigned encontonbna:1;
930
931 unsigned reserved18_31:14;
932 } b;
933} dctl_data_t;
934
935/**
936 * This union represents the bit fields in the Device Status
937 * Register. Read the register into the <i>d32</i> member then
938 * set/clear the bits using the <i>b</i>it elements.
939 */
940#define DWC_DSTS_ENUMSPD_HS_PHY_30MHZ_OR_60MHZ 0
941#define DWC_DSTS_ENUMSPD_FS_PHY_30MHZ_OR_60MHZ 1
942#define DWC_DSTS_ENUMSPD_LS_PHY_6MHZ 2
943#define DWC_DSTS_ENUMSPD_FS_PHY_48MHZ 3
944typedef union dsts_data
945{
946 /** raw register data */
947 uint32_t d32;
948 /** register bits */
949 struct
950 {
951 /** Suspend Status */
952 unsigned suspsts:1;
953 /** Enumerated Speed */
954 unsigned enumspd:2;
955 /** Erratic Error */
956 unsigned errticerr:1;
957 unsigned reserved4_7:4;
958 /** Frame or Microframe Number of the received SOF */
959 unsigned soffn:14;
960 unsigned reserved22_31:10;
961 } b;
962} dsts_data_t;
963
964/**
965 * This union represents the bit fields in the Device IN EP Interrupt
966 * Register and the Device IN EP Common Mask Register.
967 *
968 * - Read the register into the <i>d32</i> member then set/clear the
969 * bits using the <i>b</i>it elements.
970 */
971typedef union diepint_data
972{
973 /** raw register data */
974 uint32_t d32;
975 /** register bits */
976 struct
977 {
978 /** Transfer complete mask */
979 unsigned xfercompl:1;
980 /** Endpoint disable mask */
981 unsigned epdisabled:1;
982 /** AHB Error mask */
983 unsigned ahberr:1;
984 /** TimeOUT Handshake mask (non-ISOC EPs) */
985 unsigned timeout:1;
986 /** IN Token received with TxF Empty mask */
987 unsigned intktxfemp:1;
988 /** IN Token Received with EP mismatch mask */
989 unsigned intknepmis:1;
990 /** IN Endpoint NAK Effective mask */
991 unsigned inepnakeff:1;
992 /** Reserved */
993 unsigned emptyintr:1;
994
995 unsigned txfifoundrn:1;
996
997 /** BNA Interrupt mask */
998 unsigned bna:1;
999
1000 unsigned reserved10_12:3;
1001 /** BNA Interrupt mask */
1002 unsigned nak:1;
1003
1004 unsigned reserved14_31:18;
1005 } b;
1006} diepint_data_t;
1007
1008/**
1009 * This union represents the bit fields in the Device IN EP
1010 * Common/Dedicated Interrupt Mask Register.
1011 */
1012typedef union diepint_data diepmsk_data_t;
1013
1014/**
1015 * This union represents the bit fields in the Device OUT EP Interrupt
1016 * Registerand Device OUT EP Common Interrupt Mask Register.
1017 *
1018 * - Read the register into the <i>d32</i> member then set/clear the
1019 * bits using the <i>b</i>it elements.
1020 */
1021typedef union doepint_data
1022{
1023 /** raw register data */
1024 uint32_t d32;
1025 /** register bits */
1026 struct
1027 {
1028 /** Transfer complete */
1029 unsigned xfercompl:1;
1030 /** Endpoint disable */
1031 unsigned epdisabled:1;
1032 /** AHB Error */
1033 unsigned ahberr:1;
1034 /** Setup Phase Done (contorl EPs) */
1035 unsigned setup:1;
1036 /** OUT Token Received when Endpoint Disabled */
1037 unsigned outtknepdis:1;
1038
1039 unsigned stsphsercvd:1;
1040 /** Back-to-Back SETUP Packets Received */
1041 unsigned back2backsetup:1;
1042
1043 unsigned reserved7:1;
1044 /** OUT packet Error */
1045 unsigned outpkterr:1;
1046 /** BNA Interrupt */
1047 unsigned bna:1;
1048
1049 unsigned reserved10:1;
1050 /** Packet Drop Status */
1051 unsigned pktdrpsts:1;
1052 /** Babble Interrupt */
1053 unsigned babble:1;
1054 /** NAK Interrupt */
1055 unsigned nak:1;
1056 /** NYET Interrupt */
1057 unsigned nyet:1;
1058 /** Bit indicating setup packet received */
1059 unsigned sr:1;
1060
1061 unsigned reserved16_31:16;
1062 } b;
1063} doepint_data_t;
1064
1065/**
1066 * This union represents the bit fields in the Device OUT EP
1067 * Common/Dedicated Interrupt Mask Register.
1068 */
1069typedef union doepint_data doepmsk_data_t;
1070
1071/**
1072 * This union represents the bit fields in the Device All EP Interrupt
1073 * and Mask Registers.
1074 * - Read the register into the <i>d32</i> member then set/clear the
1075 * bits using the <i>b</i>it elements.
1076 */
1077typedef union daint_data
1078{
1079 /** raw register data */
1080 uint32_t d32;
1081 /** register bits */
1082 struct
1083 {
1084 /** IN Endpoint bits */
1085 unsigned in:16;
1086 /** OUT Endpoint bits */
1087 unsigned out:16;
1088 } ep;
1089 struct
1090 {
1091 /** IN Endpoint bits */
1092 unsigned inep0:1;
1093 unsigned inep1:1;
1094 unsigned inep2:1;
1095 unsigned inep3:1;
1096 unsigned inep4:1;
1097 unsigned inep5:1;
1098 unsigned inep6:1;
1099 unsigned inep7:1;
1100 unsigned inep8:1;
1101 unsigned inep9:1;
1102 unsigned inep10:1;
1103 unsigned inep11:1;
1104 unsigned inep12:1;
1105 unsigned inep13:1;
1106 unsigned inep14:1;
1107 unsigned inep15:1;
1108 /** OUT Endpoint bits */
1109 unsigned outep0:1;
1110 unsigned outep1:1;
1111 unsigned outep2:1;
1112 unsigned outep3:1;
1113 unsigned outep4:1;
1114 unsigned outep5:1;
1115 unsigned outep6:1;
1116 unsigned outep7:1;
1117 unsigned outep8:1;
1118 unsigned outep9:1;
1119 unsigned outep10:1;
1120 unsigned outep11:1;
1121 unsigned outep12:1;
1122 unsigned outep13:1;
1123 unsigned outep14:1;
1124 unsigned outep15:1;
1125 } b;
1126} daint_data_t;
1127
1128/**
1129 * This union represents the bit fields in the Device IN Token Queue
1130 * Read Registers.
1131 * - Read the register into the <i>d32</i> member.
1132 * - READ-ONLY Register
1133 */
1134typedef union dtknq1_data
1135{
1136 /** raw register data */
1137 uint32_t d32;
1138 /** register bits */
1139 struct
1140 {
1141 /** In Token Queue Write Pointer */
1142 unsigned intknwptr:5;
1143 /** Reserved */
1144 unsigned reserved05_06:2;
1145 /** write pointer has wrapped. */
1146 unsigned wrap_bit:1;
1147 /** EP Numbers of IN Tokens 0 ... 4 */
1148 unsigned epnums0_5:24;
1149 } b;
1150} dtknq1_data_t;
1151
1152
1153/**
1154 * Device Logical IN Endpoint-Specific Registers. <i>Offsets
1155 * 900h-AFCh</i>
1156 *
1157 * There will be one set of endpoint registers per logical endpoint
1158 * implemented.
1159 *
1160 * <i>These registers are visible only in Device mode and must not be
1161 * accessed in Host mode, as the results are unknown.</i>
1162 */
1163typedef struct dwc_otg_dev_in_ep_regs
1164{
1165 /** Device IN Endpoint Control Register. <i>Offset:900h +
1166 * (ep_num * 20h) + 00h</i> */
1167 volatile uint32_t diepctl;
1168 /** Reserved. <i>Offset:900h + (ep_num * 20h) + 04h</i> */
1169 uint32_t reserved04;
1170 /** Device IN Endpoint Interrupt Register. <i>Offset:900h +
1171 * (ep_num * 20h) + 08h</i> */
1172 volatile uint32_t diepint;
1173 /** Reserved. <i>Offset:900h + (ep_num * 20h) + 0Ch</i> */
1174 uint32_t reserved0C;
1175 /** Device IN Endpoint Transfer Size
1176 * Register. <i>Offset:900h + (ep_num * 20h) + 10h</i> */
1177 volatile uint32_t dieptsiz;
1178 /** Device IN Endpoint DMA Address Register. <i>Offset:900h +
1179 * (ep_num * 20h) + 14h</i> */
1180 volatile uint32_t diepdma;
1181 /** Device IN Endpoint Transmit FIFO Status Register. <i>Offset:900h +
1182 * (ep_num * 20h) + 18h</i> */
1183 volatile uint32_t dtxfsts;
1184 /** Device IN Endpoint DMA Buffer Register. <i>Offset:900h +
1185 * (ep_num * 20h) + 1Ch</i> */
1186 volatile uint32_t diepdmab;
1187} dwc_otg_dev_in_ep_regs_t;
1188
1189/**
1190 * Device Logical OUT Endpoint-Specific Registers. <i>Offsets:
1191 * B00h-CFCh</i>
1192 *
1193 * There will be one set of endpoint registers per logical endpoint
1194 * implemented.
1195 *
1196 * <i>These registers are visible only in Device mode and must not be
1197 * accessed in Host mode, as the results are unknown.</i>
1198 */
1199typedef struct dwc_otg_dev_out_ep_regs
1200{
1201 /** Device OUT Endpoint Control Register. <i>Offset:B00h +
1202 * (ep_num * 20h) + 00h</i> */
1203 volatile uint32_t doepctl;
1204 /** Reserved. <i>Offset:B00h + (ep_num * 20h) + 04h</i> */
1205 uint32_t reserved04;
1206 /** Device OUT Endpoint Interrupt Register. <i>Offset:B00h +
1207 * (ep_num * 20h) + 08h</i> */
1208 volatile uint32_t doepint;
1209 /** Reserved. <i>Offset:B00h + (ep_num * 20h) + 0Ch</i> */
1210 uint32_t reserved0C;
1211 /** Device OUT Endpoint Transfer Size Register. <i>Offset:
1212 * B00h + (ep_num * 20h) + 10h</i> */
1213 volatile uint32_t doeptsiz;
1214 /** Device OUT Endpoint DMA Address Register. <i>Offset:B00h
1215 * + (ep_num * 20h) + 14h</i> */
1216 volatile uint32_t doepdma;
1217 /** Reserved. <i>Offset:B00h + * (ep_num * 20h) + 18h</i> */
1218 uint32_t unused;
1219 /** Device OUT Endpoint DMA Buffer Register. <i>Offset:B00h
1220 * + (ep_num * 20h) + 1Ch</i> */
1221 uint32_t doepdmab;
1222} dwc_otg_dev_out_ep_regs_t;
1223
1224/**
1225 * This union represents the bit fields in the Device EP Control
1226 * Register. Read the register into the <i>d32</i> member then
1227 * set/clear the bits using the <i>b</i>it elements.
1228 */
1229#define DWC_DEP0CTL_MPS_64 0
1230#define DWC_DEP0CTL_MPS_32 1
1231#define DWC_DEP0CTL_MPS_16 2
1232#define DWC_DEP0CTL_MPS_8 3
1233
1234typedef union depctl_data
1235{
1236 /** raw register data */
1237 uint32_t d32;
1238 /** register bits */
1239 struct
1240 {
1241 /** Maximum Packet Size
1242 * IN/OUT EPn
1243 * IN/OUT EP0 - 2 bits
1244 * 2'b00: 64 Bytes
1245 * 2'b01: 32
1246 * 2'b10: 16
1247 * 2'b11: 8 */
1248 unsigned mps:11;
1249 /** Next Endpoint
1250 * IN EPn/IN EP0
1251 * OUT EPn/OUT EP0 - reserved */
1252 unsigned nextep:4;
1253
1254 /** USB Active Endpoint */
1255 unsigned usbactep:1;
1256
1257 /** Endpoint DPID (INTR/Bulk IN and OUT endpoints)
1258 * This field contains the PID of the packet going to
1259 * be received or transmitted on this endpoint. The
1260 * application should program the PID of the first
1261 * packet going to be received or transmitted on this
1262 * endpoint , after the endpoint is
1263 * activated. Application use the SetD1PID and
1264 * SetD0PID fields of this register to program either
1265 * D0 or D1 PID.
1266 *
1267 * The encoding for this field is
1268 * - 0: D0
1269 * - 1: D1
1270 */
1271 unsigned dpid:1;
1272
1273 /** NAK Status */
1274 unsigned naksts:1;
1275
1276 /** Endpoint Type
1277 * 2'b00: Control
1278 * 2'b01: Isochronous
1279 * 2'b10: Bulk
1280 * 2'b11: Interrupt */
1281 unsigned eptype:2;
1282
1283 /** Snoop Mode
1284 * OUT EPn/OUT EP0
1285 * IN EPn/IN EP0 - reserved */
1286 unsigned snp:1;
1287
1288 /** Stall Handshake */
1289 unsigned stall:1;
1290
1291 /** Tx Fifo Number
1292 * IN EPn/IN EP0
1293 * OUT EPn/OUT EP0 - reserved */
1294 unsigned txfnum:4;
1295
1296 /** Clear NAK */
1297 unsigned cnak:1;
1298 /** Set NAK */
1299 unsigned snak:1;
1300 /** Set DATA0 PID (INTR/Bulk IN and OUT endpoints)
1301 * Writing to this field sets the Endpoint DPID (DPID)
1302 * field in this register to DATA0. Set Even
1303 * (micro)frame (SetEvenFr) (ISO IN and OUT Endpoints)
1304 * Writing to this field sets the Even/Odd
1305 * (micro)frame (EO_FrNum) field to even (micro)
1306 * frame.
1307 */
1308 unsigned setd0pid:1;
1309 /** Set DATA1 PID (INTR/Bulk IN and OUT endpoints)
1310 * Writing to this field sets the Endpoint DPID (DPID)
1311 * field in this register to DATA1 Set Odd
1312 * (micro)frame (SetOddFr) (ISO IN and OUT Endpoints)
1313 * Writing to this field sets the Even/Odd
1314 * (micro)frame (EO_FrNum) field to odd (micro) frame.
1315 */
1316 unsigned setd1pid:1;
1317
1318 /** Endpoint Disable */
1319 unsigned epdis:1;
1320 /** Endpoint Enable */
1321 unsigned epena:1;
1322 } b;
1323} depctl_data_t;
1324
1325/**
1326 * This union represents the bit fields in the Device EP Transfer
1327 * Size Register. Read the register into the <i>d32</i> member then
1328 * set/clear the bits using the <i>b</i>it elements.
1329 */
1330
1331/** Max packet count for EP (pow(2,10)-1) */
1332#define MAX_PKT_CNT 1023
1333typedef union deptsiz_data
1334{
1335 /** raw register data */
1336 uint32_t d32;
1337 /** register bits */
1338 struct
1339 {
1340 /** Transfer size */
1341 unsigned xfersize:19;
1342 /** Packet Count */
1343 unsigned pktcnt:10;
1344 /** Multi Count - Periodic IN endpoints */
1345 unsigned mc:2;
1346 unsigned reserved:1;
1347 } b;
1348} deptsiz_data_t;
1349
1350/**
1351 * This union represents the bit fields in the Device EP 0 Transfer
1352 * Size Register. Read the register into the <i>d32</i> member then
1353 * set/clear the bits using the <i>b</i>it elements.
1354 */
1355typedef union deptsiz0_data
1356{
1357 /** raw register data */
1358 uint32_t d32;
1359 /** register bits */
1360 struct
1361 {
1362 /** Transfer size */
1363 unsigned xfersize:7;
1364 /** Reserved */
1365 unsigned reserved7_18:12;
1366 /** Packet Count */
1367 unsigned pktcnt:2;
1368 /** Reserved */
1369 unsigned reserved21_28:8;
1370 /**Setup Packet Count (DOEPTSIZ0 Only) */
1371 unsigned supcnt:2;
1372 unsigned reserved31;
1373 } b;
1374} deptsiz0_data_t;
1375
1376/////////////////////////////////////////////////
1377// DMA Descriptor Specific Structures
1378//
1379
1380/** Buffer status definitions */
1381
1382#define BS_HOST_READY 0x0
1383#define BS_DMA_BUSY 0x1
1384#define BS_DMA_DONE 0x2
1385#define BS_HOST_BUSY 0x3
1386
1387/** Receive/Transmit status definitions */
1388
1389#define RTS_SUCCESS 0x0
1390#define RTS_BUFFLUSH 0x1
1391#define RTS_RESERVED 0x2
1392#define RTS_BUFERR 0x3
1393
1394
1395/**
1396 * The dwc_otg_dev_if structure contains information needed to manage
1397 * the DWC_otg controller acting in device mode. It represents the
1398 * programming view of the device-specific aspects of the controller.
1399 */
1400#define DWC_DEV_GLOBAL_REG_OFFSET 0x800
1401#define DWC_DEV_IN_EP_REG_OFFSET 0x900
1402#define DWC_EP_REG_OFFSET 0x20
1403#define DWC_DEV_OUT_EP_REG_OFFSET 0xB00
1404
1405typedef struct dwc_otg_dev_if
1406{
1407 /** Pointer to device Global registers.
1408 * Device Global Registers starting at offset 800h
1409 */
1410 dwc_otg_device_global_regs_t *dev_global_regs;
1411 /**
1412 * Device Logical IN Endpoint-Specific Registers 900h-AFCh
1413 */
1414 dwc_otg_dev_in_ep_regs_t *in_ep_regs[MAX_EPS_CHANNELS];
1415
1416 /** Device Logical OUT Endpoint-Specific Registers B00h-CFCh */
1417 dwc_otg_dev_out_ep_regs_t *out_ep_regs[MAX_EPS_CHANNELS];
1418 /* Device configuration information */
1419 uint8_t speed; /**< Device Speed 0: Unknown, 1: LS, 2:FS, 3: HS */
1420 uint8_t num_in_eps; /**< Number # of Tx EP range: 0-15 exept ep0 */
1421 uint8_t num_out_eps; /**< Number # of Rx EP range: 0-15 exept ep 0*/
1422
1423 /** Thresholding enable flags and length varaiables **/
1424 uint16_t rx_thr_en;
1425 //uint16_t iso_tx_thr_en;
1426 uint16_t non_iso_tx_thr_en;
1427
1428 uint16_t rx_thr_length;
1429 uint16_t tx_thr_length;
1430
1431 /**
1432 * Pointers to the DMA Descriptors for EP0 Control
1433 * transfers (virtual and physical)
1434 */
1435
1436 /** Setup Packet Detected - if set clear NAK when queueing */
1437 uint32_t spd;
1438
1439} dwc_otg_dev_if_t;
1440
1441/////////////////////////////////////////////////
1442// Host Mode Register Structures
1443//
1444
1445/**
1446 * This union represents the bit fields in the Host Configuration Register.
1447 * Read the register into the <i>d32</i> member then set/clear the bits using
1448 * the <i>b</i>it elements. Write the <i>d32</i> member to the hcfg register.
1449 */
1450#define DWC_HCFG_30_60_MHZ 0
1451#define DWC_HCFG_48_MHZ 1
1452#define DWC_HCFG_6_MHZ 2
1453/**
1454 * This union represents the bit fields in the Power and Clock Gating Control
1455 * Register. Read the register into the <i>d32</i> member then set/clear the
1456 * bits using the <i>b</i>it elements.
1457 */
1458typedef union pcgcctl_data
1459{
1460 /** raw register data */
1461 uint32_t d32;
1462
1463 /** register bits */
1464 struct
1465 {
1466 /** Stop Pclk */
1467 unsigned stoppclk:1;
1468 /** Gate Hclk */
1469 unsigned gatehclk:1;
1470 /** Power Clamp */
1471 unsigned pwrclmp:1;
1472 /** Reset Power Down Modules */
1473 unsigned rstpdwnmodule:1;
1474 /** Reserved */
1475 unsigned reserved:1;
1476 /** Enable Sleep Clock Gating (Enbl_L1Gating) */
1477 unsigned enbl_sleep_gating:1;
1478 /** PHY In Sleep (PhySleep) */
1479 unsigned phy_in_sleep:1;
1480 /** Deep Sleep*/
1481 unsigned deep_sleep:1;
1482 unsigned resetaftsusp:1;
1483 unsigned restoremode:1;
1484 unsigned enbl_extnd_hiber:1;
1485 unsigned extnd_hiber_pwrclmp:1;
1486 unsigned extnd_hiber_switch:1;
1487 unsigned ess_reg_restored:1;
1488 unsigned prt_clk_sel:2;
1489 unsigned port_power:1;
1490 unsigned max_xcvrselect:2;
1491 unsigned max_termsel:1;
1492 unsigned mac_dev_addr:7;
1493 unsigned p2hd_dev_enum_spd:2;
1494 unsigned p2hd_prt_spd:2;
1495 unsigned if_dev_mode:1;
1496 } b;
1497} pcgcctl_data_t;
1498
1499/**
1500 * This union represents the bit fields in the Global Data FIFO Software
1501 * Configuration Register. Read the register into the <i>d32</i> member then
1502 * set/clear the bits using the <i>b</i>it elements.
1503 */
1504typedef union gdfifocfg_data
1505{
1506 /* raw register data */
1507 uint32_t d32;
1508 /** register bits */
1509 struct
1510 {
1511 /** OTG Data FIFO depth */
1512 unsigned gdfifocfg:16;
1513 /** Start address of EP info controller */
1514 unsigned epinfobase:16;
1515 } b;
1516} gdfifocfg_data_t;
1517
1518/**
1519 * This union represents the bit fields in the Global Power Down Register
1520 * Register. Read the register into the <i>d32</i> member then set/clear the
1521 * bits using the <i>b</i>it elements.
1522 */
1523#define disconn_det disconn_det
1524
1525#define lnstschng lnstschng
1526
1527#define rst_det rst_det
1528
1529#define srp_det srp_det
1530
1531#define sts_chngint sts_chngint
1532
1533typedef union gpwrdn_data
1534{
1535 /* raw register data */
1536 uint32_t d32;
1537 /** register bits */
1538 struct
1539 {
1540 /** PMU Interrupt Select */
1541 unsigned pmuintsel:1;
1542 /** PMU Active */
1543 unsigned pmuactv:1;
1544 /** Restore */
1545 unsigned restore:1;
1546 /** Power Down Clamp */
1547 unsigned pwrdnclmp:1;
1548 /** Power Down Reset */
1549 unsigned pwrdnrstn:1;
1550 /** Power Down Switch */
1551 unsigned pwrdnswtch:1;
1552 /** Disable VBUS */
1553 unsigned dis_vbus:1;
1554 /** Line State Change */
1555 unsigned lnstschng:1;
1556 /** Line state change mask */
1557 unsigned lnstchng_msk:1;
1558 /** Reset Detected */
1559 unsigned rst_det:1;
1560 /** Reset Detect mask */
1561 unsigned rst_det_msk:1;
1562 /** Disconnect Detected */
1563 unsigned disconn_det:1;
1564 /** Disconnect Detect mask */
1565 unsigned disconn_det_msk:1;
1566 /** Connect Detected*/
1567 unsigned connect_det:1;
1568 /** Connect Detected Mask*/
1569 unsigned connect_det_msk:1;
1570 /** SRP Detected */
1571 unsigned srp_det:1;
1572 /** SRP Detect mask */
1573 unsigned srp_det_msk:1;
1574 /** Status Change Interrupt */
1575 unsigned sts_chngint:1;
1576 /** Status Change Interrupt Mask */
1577 unsigned sts_chngint_msk:1;
1578 /** Line State */
1579 unsigned linestate:2;
1580 /** Indicates current mode(status of IDDIG signal) */
1581 unsigned idsts:1;
1582 /** B Session Valid signal status*/
1583 unsigned bsessvld:1;
1584 /** ADP Event Detected */
1585 unsigned adp_int:1;
1586 /** Multi Valued ID pin */
1587 unsigned mult_val_id_bc:5;
1588 /** Reserved 24_31 */
1589 unsigned reserved29_31:3;
1590 } b;
1591} gpwrdn_data_t;
1592
1593#endif