 |
AM261x MCU+ SDK
11.00.00
|
|
Go to the documentation of this file.
66 #define DWC_MAX_TX_FIFOS 16
72 #define DWC_MAX_PHYS_EP 32
77 #define DWC_MAX_DATA_BUFS 13
83 #define DWC_MAX_EPS 5U
88 #define DWC_MAX_EP0_SIZE 512
93 #define DWC_MAX_PACKET_SIZE 1024
98 typedef enum ep0_state {
114 typedef enum pcd_state {
121 struct dwc_usb3_device;
131 typedef struct dwc_reqt {
139 #define DWC_PCD_REQ_ZERO 0x001U
140 #define DWC_PCD_REQ_STARTED 0x002U
141 #define DWC_PCD_REQ_MAP_DMA 0x100
142 #define DWC_PCD_REQ_IN 0x200
145 char *buf[DWC_MAX_DATA_BUFS];
146 dwc_dma_t bufdma[DWC_MAX_DATA_BUFS];
147 u32 buflen[DWC_MAX_DATA_BUFS];
157 typedef struct dwc_usb3_pcd_req {
164 #if defined(__linux__) || defined(SELA_PLATFORM)
165 struct list_head entry;
167 DWC_CIRCLEQ_ENTRY(dwc_usb3_pcd_req) entry;
171 struct usb_request usb_req;
175 typedef struct dwc_usb3_event_req{
177 DWC_SIMPLEQ_ENTRY(dwc_usb3_event_req) entry;
178 } dwc_usb3_event_req_t ;
186 typedef struct dwc_ept {
307 #if defined(__linux__) || defined(SELA_PLATFORM)
308 struct list_head queue;
315 typedef union dwc_setup_pkt {
324 typedef struct dwc_usb3_pcd_ep {
331 struct usb_ept usb_ep;
341 #define dwc_usb3_pcd_ep_to_pcd(pcd_ep) ((pcd_ep)->dwc_ep.pcd)
348 #define dwc_usb3_pcd_ep_num(pcd_ep) ((pcd_ep)->dwc_ep.num)
355 #define dwc_usb3_pcd_ep_type(pcd_ep) ((pcd_ep)->dwc_ep.type)
362 #define dwc_usb3_pcd_ep_is_in(pcd_ep) ((pcd_ep)->dwc_ep.is_in)
375 typedef struct dwc_usb3_pcd {
412 #ifdef DWC_STAR_9000463548_WORKAROUND
413 unsigned int configuring : 1;
416 #ifdef CONFIG_USB_OTG_DWC
418 unsigned int wants_host : 1;
421 unsigned int b_hnp_enable : 1;
445 void *hiber_scratchpad[15];
470 unsigned def_rxf_size;
494 unsigned request_pending;
499 int max_in_eps, max_out_eps;
502 int *dev_event, *ep_event;
504 #if defined(__linux__) || defined(LINUXTEST)
510 struct usb_gadget *gadget;
550 #define DWC_STATUS_BUF_SIZE 512U
571 #define dwc_usb3_ep0_setup_desc(pcd) (pcd)->ep0_setup_desc
578 #define dwc_usb3_ep0_setup_desc_dma(pcd) (pcd)->ep0_setup_desc_dma
585 #define dwc_usb3_ep0_out_desc(pcd) (pcd)->ep0_out_desc
592 #define dwc_usb3_ep0_out_desc_dma(pcd) (pcd)->ep0_out_desc_dma
599 #define dwc_usb3_ep0_in_desc(pcd) (pcd)->ep0_in_desc
606 #define dwc_usb3_ep0_in_desc_dma(pcd) (pcd)->ep0_in_desc_dma
613 #define dwc_usb3_ep0_setup_pkt(pcd) (pcd)->ep0_setup_pkt
620 #define dwc_usb3_ep0_setup_pkt_dma(pcd) (pcd)->ep0_setup_pkt_dma
629 extern void dwc_usb3_print_ep0_state(
volatile dwc_usb3_pcd_t *pcd);
652 int num_trbs,
uByte trb_type,
int iso_intvl,
int link,
731 usb_device_request_t *ctrl);
764 #ifdef CONFIG_USB_OTG_DWC
int dwc_usb3_pcd_ep_submit_req(volatile dwc_usb3_pcd_t *pcd, dwc_usb3_pcd_ep_t *ep, dwc_usb3_pcd_req_t *req, u32 req_flags)
This routine submits an I/O Request to an EP.
Definition: pcd.c:1719
DWC_usb3 request structure.
Definition: pcd.h:157
int desc_size
Definition: pcd.h:288
void dwc_usb3_stop_all_xfers(volatile dwc_usb3_pcd_t *pcd)
Stop any active xfers on the non-EP0 endpoints.
Definition: pcd.c:1087
u32 length
Definition: pcd.h:134
struct dwc_usb3_device * usb3_dev
Definition: pcd.h:377
dwc_usb3_dma_desc_t * ep0_setup_desc
Definition: pcd.h:524
u32 condition
Definition: pcd.h:304
u16 rx_thr_en
Definition: pcd.h:478
dwc_usb3_dma_desc_t * ep0_in_desc
Definition: pcd.h:538
unsigned int three_stage
Definition: pcd.h:244
unsigned int u32
Definition: os_defs.h:41
void dwc_usb3_ep_activate(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep, int restore)
This routine activates an EP. The Device EP control registers for the EP are configured as defined in...
Definition: pcd.c:396
unsigned int xfer_started
Definition: pcd.h:247
struct dwc_usb3_pcd * pcd
Definition: pcd.h:188
unsigned int remote_wakeup_enable
Definition: pcd.h:395
u8 test_mode
Definition: pcd.h:491
dwc_usb3_dev_ep_regs_t __iomem * in_ep_regs
Definition: pcd.h:441
u32 param0in
Definition: pcd.h:274
unsigned short u16
Definition: os_defs.h:43
u16 iso_tx_thr_en
Definition: pcd.h:479
dwc_dma_t ep0_out_desc_dma
Definition: pcd.h:533
dwc_dma_t ep0_status_buf_dma
Definition: pcd.h:549
int dwc_usb3_handle_dev_intr(volatile dwc_usb3_pcd_t *pcd, u32 event)
PCD interrupt handler.
Definition: pcd_intr.c:652
void dwc_usb3_pcd_request_done(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep, volatile dwc_usb3_pcd_req_t *req, int status)
This routine completes a request. It calls the request callback.
Definition: pcd.c:1898
@ DWC_STATE_ADDRESSED
Definition: pcd.h:117
void dwc_usb3_pcd_ep_cancel_req(volatile dwc_usb3_pcd_t *pcd, dwc_usb3_pcd_ep_t *ep, dwc_usb3_pcd_req_t *req, u32 stream)
This routine cancels an I/O request from an EP.
Definition: pcd.c:1821
volatile dwc_usb3_pcd_req_t * ep0_req
Definition: pcd.h:457
u8 num
Definition: pcd.h:200
dwc_usb3_dma_desc_t * ep0_out_desc
Definition: pcd.h:531
int dwc_usb3_gadget_suspend(volatile dwc_usb3_pcd_t *pcd)
This routine receives Suspend notifications from the PCD.
Definition: no_os_gadget.c:128
@ EP0_OUT_WAIT_NRDY
Definition: pcd.h:105
dwc_dma_t ep0_setup_pkt_dma
Definition: pcd.h:557
void dwc_usb3_pcd_remove(volatile struct dwc_usb3_device *dev)
void * dwc_usb3_gadget_alloc_dma(volatile dwc_usb3_pcd_ep_t *ep, int size, dwc_dma_t *mem_dma_ret)
This routine allocates coherent DMA memory. It is used by the PCD to allocate memory for TRBs....
Definition: no_os_gadget.c:259
#define __iomem
Definition: os_defs.h:74
int dwc_usb3_gadget_disconnect(volatile dwc_usb3_pcd_t *pcd)
This routine receives Disconnect notifications from the PCD.
Definition: no_os_gadget.c:107
u8 * ep0_status_buf
Definition: pcd.h:547
dwc_usb3_dma_desc_t * dma_desc
Definition: pcd.h:286
@ EP0_OUT_DATA_PHASE
Definition: pcd.h:101
void dwc_usb3_pcd_ep_set_stall(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep)
Set the EP to STALL.
Definition: pcd.c:1420
u8 tri_in
Definition: pcd.h:226
void dwc_usb3_gadget_free_dma(volatile dwc_usb3_pcd_ep_t *ep, int size, void *mem, dwc_dma_t mem_dma)
This routine frees DMA memory allocated by dwc_usb3_gadget_alloc_dma().
Definition: no_os_gadget.c:298
int dwc_usb3_handle_pme_intr(volatile struct dwc_usb3_device *dev)
struct dwc_hiber_scratchpad_array * hiber_scratchpad_array
Definition: pcd.h:446
void dwc_usb3_gadget_isoc_ep_start(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep, u32 event)
This routine starts an Isoc EP running at the proper interval, after receiving the initial XferNrdy e...
Definition: no_os_gadget.c:376
u32 flags
Definition: pcd.h:138
unsigned int wkup_rdy
Definition: pcd.h:404
unsigned long dwc_dma_t
Definition: os_defs.h:62
@ EP0_OUT_WAIT_GADGET
Definition: pcd.h:103
DWC_usb3 PCD Structure. This structure encapsulates the data for the dwc_usb3 PCD.
Definition: pcd.h:375
ep0state_e
Enumeration representing the various states of Endpoint 0 (EP0).
Definition: pcd.h:98
@ DWC_STATE_UNCONNECTED
Definition: pcd.h:115
void dwc_usb3_pcd_fill_trbs(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep, dwc_usb3_pcd_req_t *req)
This routine assigns and fills in the TRBs for a request.
Definition: pcd.c:208
u8 phys
Definition: pcd.h:197
dwc_queue_t event_q
Definition: pcd.h:561
u8 mult
Definition: pcd.h:212
void dwc_usb3_gadget_set_ep_not_started(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep)
This routine marks all pending requests for an EP as not started.
Definition: no_os_gadget.c:470
usb_device_request_t req
Definition: pcd.h:316
void dwc_usb3_power_ctl(volatile struct dwc_usb3_device *dev, int on)
void dwc_usb3_pcd_ep_start_transfer(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep, volatile dwc_usb3_pcd_req_t *req, u32 event)
This routine does the setup for a data transfer for an EP and starts the transfer.
Definition: pcd.c:809
const usb_endpoint_descriptor_t * usb_ep_desc
Definition: pcd.h:282
u8 type
Definition: pcd.h:203
int hiber_desc_idx
Definition: pcd.h:299
int dwc_usb3_pcd_get_frame_number(volatile dwc_usb3_pcd_t *pcd)
Gets the current USB frame number.
Definition: pcd.c:1975
dwc_usb3_dev_global_regs_t __iomem * dev_global_regs
Definition: pcd.h:435
dwc_setup_pkt_t * ep0_setup_pkt
Definition: pcd.h:555
@ EP0_IN_DATA_PHASE
Definition: pcd.h:100
u8 speed
Definition: pcd.h:486
u8 intvl
Definition: pcd.h:206
void dwc_usb3_handle_connect_done_intr(volatile dwc_usb3_pcd_t *pcd)
This interrupt occurs when a Connect Done is detected. Read the device status register and set the de...
Definition: pcd_intr.c:215
u32 actual
Definition: pcd.h:135
u8 maxburst
Definition: pcd.h:215
DWC_CIRCLEQ_HEAD(circleq, dwc_usb3_pcd_req) queue
void dwc_exit_hibernation_after_connect(volatile dwc_usb3_pcd_t *pcd, int connected)
This routine finishes exiting from hibernation once the device is connected.
Definition: pcd_hiber.c:399
unsigned int request_config
Definition: pcd.h:392
void dwc_usb3_handle_ep0_xfer(volatile dwc_usb3_pcd_t *pcd, u32 event)
This routine handles EP0 transfers.
Definition: ep0.c:1421
int dwc_usb3_pcd_ep_disable(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep)
This routine is called when an EP (except EP0) is disabled due to disconnect or change in configurati...
Definition: pcd.c:1684
@ EP0_IN_WAIT_NRDY
Definition: pcd.h:104
unsigned long long u64
Definition: os_defs.h:39
void dwc_usb3_pcd_ep0_out_start(volatile dwc_usb3_pcd_t *pcd)
This routine sets up a SETUP stage transfer for EP0 and starts the transfer.
Definition: pcd.c:645
int desc_idx
Definition: pcd.h:296
void dwc_usb3_gadget_request_nuke(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep)
This routine terminates all requests which are pending on an endpoint.
Definition: no_os_gadget.c:447
dwc_dma_t hiber_scratchpad_array_dma
Definition: pcd.h:447
int num_desc
Definition: pcd.h:289
@ EP0_IN_WAIT_GADGET
Definition: pcd.h:102
#define DWC_MAX_EPS
Maximum number of EPs, defined by USB spec.
Definition: pcd.h:83
int dwc_usb3_pcd_ep_enable(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep, const usb_endpoint_descriptor_t *ep_desc, const ss_endpoint_companion_descriptor_t *ep_comp)
This routine is called by the Function Driver for each EP (except EP0) to be configured for the curre...
Definition: pcd.c:1558
Definition: os_defs.h:120
#define DWC_MAX_PHYS_EP
Maximum number of physical EPs. Depends on the RTL configuration. No way to probe the value at runtim...
Definition: pcd.h:72
@ EP0_STALL
Definition: pcd.h:108
void dwc_usb3_complete_request(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep, u32 event)
This routine handles non-EP0 transfers.
Definition: pcd.c:1369
unsigned int stall_clear_flag
Definition: pcd.h:241
dwc_dma_t ep0_in_desc_dma
Definition: pcd.h:540
Structure representing an array of hibernation scratchpad DMA addresses.
Definition: pcd.h:368
unsigned int ena_once
Definition: pcd.h:263
volatile dwc_usb3_pcd_ep_t * dwc_usb3_get_in_ep(volatile dwc_usb3_pcd_t *pcd, u32 ep_num)
This routine returns a pointer to In EP struct with number ep_num.
Definition: pcd.c:1494
u32 ep0_in_save_state
Definition: pcd.h:453
int dwc_usb3_gadget_setup(volatile dwc_usb3_pcd_t *pcd, usb_device_request_t *ctrl)
This routine receives Setup request notifications from the PCD.
Definition: no_os_gadget.c:169
unsigned int desc_link
Definition: pcd.h:257
unsigned int queue_sof
Definition: pcd.h:233
u32 param1out
Definition: pcd.h:273
pcdstate_e state
Definition: pcd.h:383
u16 non_iso_tx_thr_en
Definition: pcd.h:480
dwc_dma_t dma_desc_dma
Definition: pcd.h:287
DMA Descriptor structure.
Definition: hw.h:1840
unsigned int ltm_enable
Definition: pcd.h:398
void dwc_usb3_handle_ep_intr(volatile dwc_usb3_pcd_t *pcd, u32 physep, u32 event)
This interrupt indicates that an EP has a pending interrupt.
Definition: pcd_intr.c:477
int dwc_usb3_gadget_resume(volatile dwc_usb3_pcd_t *pcd)
This routine receives Resume notifications from the PCD.
Definition: no_os_gadget.c:148
#define DWC_MAX_TX_FIFOS
Maximum number of Tx FIFOs. Depends on the RTL configuration. No way to probe the value at runtime.
Definition: pcd.h:66
u8 tx_fifo_num
Definition: pcd.h:221
u16 maxpacket
Definition: pcd.h:209
void dwc_usb3_pcd_stop(volatile dwc_usb3_pcd_t *pcd)
This routine is called when the Device is disconnected. It stops any active requests and informs the ...
Definition: pcd.c:1930
dwc_req_t dwc_req
DWC_usb3 request data.
Definition: pcd.h:159
dwc_usb3_dma_desc_t * dwc_usb3_pcd_trb_alloc(volatile dwc_usb3_pcd_ep_t *ep, int num_trbs, uByte trb_type, int iso_intvl, int link, dwc_dma_t *trbs_dma_ret)
This routine allocates the TRBs for an EP.
Definition: pcd.c:91
void dwc_usb3_pcd_ep0_start_transfer(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_req_t *req)
This routine sets up a data/status stage transfer for EP0 and starts the transfer....
Definition: pcd.c:689
unsigned int stopped
Definition: pcd.h:231
ep0state_e ep0state
Definition: pcd.h:386
void dwc_usb3_task_schedule(volatile struct tasklet_struct *tasklet)
OS-specific routines called from core code.
unsigned int ep0_status_pending
Definition: pcd.h:389
u8 num_in_eps
Definition: pcd.h:488
int dwc_usb3_gadget_connect(volatile dwc_usb3_pcd_t *pcd, int speed)
This routine receives Connect notifications from the PCD.
Definition: no_os_gadget.c:65
int dwc_usb3_pcd_isoc_ep_hiber_restart(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep)
After hibernation, this function restarts the transfer using the TRB address that was active before h...
Definition: pcd.c:1005
unsigned int active
Definition: pcd.h:254
int dwc_usb3_gadget_complete(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep, volatile dwc_usb3_pcd_req_t *pcd_req, int status)
This routine receives Transfer Complete notifications from the PCD.
Definition: no_os_gadget.c:204
This structure describes a USB endpoint.
Definition: usb.h:317
dwc_usb3_dev_ep_regs_t __iomem * out_ep_reg
Definition: pcd.h:191
void dwc_usb3_pcd_ep0_data_stage(volatile dwc_usb3_pcd_t *pcd, int length)
This routine starts the data stage of a 3-stage control command. pcd->ep0state must be set to EP0_OUT...
Definition: ep0.c:114
dwc_usb3_dev_ep_regs_t __iomem * in_ep_reg
Definition: pcd.h:194
unsigned int disabling
Definition: pcd.h:232
u32 stream
Definition: pcd.h:136
dwc_dma_t ep0_setup_desc_dma
Definition: pcd.h:526
u32 param0out
Definition: pcd.h:272
unsigned int is_in
Definition: pcd.h:251
u8 uByte
Definition: usb.h:58
@ EP0_IN_STATUS_PHASE
Definition: pcd.h:106
dwc_dma_t trbdma
Definition: pcd.h:133
u16 tx_thr_length
Definition: pcd.h:482
volatile dwc_usb3_pcd_ep_t * dwc_usb3_get_out_ep(volatile dwc_usb3_pcd_t *pcd, u32 ep_num)
This routine returns a pointer to Out EP struct with number ep_num.
Definition: pcd.c:1474
Structure representing a USB transfer request.
Definition: pcd.h:131
int desc_avail
Definition: pcd.h:293
@ DWC_STATE_CONFIGURED
Definition: pcd.h:118
unsigned int data_pid_start
Definition: pcd.h:260
dwc_usb3_pcd_req_t * dwc_usb3_gadget_get_request(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep)
This routine returns the PCD request corresponding to the current transfer request for an endpoint....
Definition: no_os_gadget.c:316
void dwc_usb3_pcd_ep_clear_stall(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep)
Clear the EP STALL.
Definition: pcd.c:1446
dwc_usb3_dma_desc_t * trb
Definition: pcd.h:132
void dwc_usb3_gadget_start_next_request(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep)
This routine checks to see if there is another transfer request waiting on an endpoint that has not b...
Definition: no_os_gadget.c:340
void dwc_enter_hibernation(volatile dwc_usb3_pcd_t *pcd, int save_state)
This routine sends the core into hibernation, saving the core's runtime state if requested.
Definition: pcd_hiber.c:58
volatile dwc_usb3_pcd_ep_t * dwc_usb3_pcd_get_ep_by_addr(volatile dwc_usb3_pcd_t *pcd, u16 idx)
This routine gets a pointer to an EP from the wIndex address value of the control request.
Definition: pcd.c:1515
Buffer used to store the SETUP packet for EP0.
Definition: pcd.h:315
u8 tri_out
Definition: pcd.h:225
u16 rx_thr_length
Definition: pcd.h:481
unsigned char u8
Definition: os_defs.h:45
A structure representing a queue for managing data.
Definition: dwc_queue.h:57
unsigned int ute_change
Definition: pcd.h:410
unsigned int stalled_save
Definition: pcd.h:266
@ DWC_STATE_DEFAULT
Definition: pcd.h:116
pcdstate_e
Enumeration representing the various states of the PCD.
Definition: pcd.h:114
dwc_usb3_dev_ep_regs_t __iomem * out_ep_regs
Definition: pcd.h:438
void dwc_usb3_pcd_trb_free(volatile dwc_usb3_pcd_ep_t *ep)
This routine frees the TRBs allocated by dwc_usb3_pcd_trb_alloc().
Definition: pcd.c:184
void dwc_usb3_pcd_ep_set_halt(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep, int value)
This function sets or clears a stall condition on an endpoint.
Definition: pcd.c:1849
u8 num_streams
Definition: pcd.h:218
unsigned int send_zlp
Definition: pcd.h:238
DWC queue implementation.
PCD Endpoint structure. This structure represents an endpoint (EP) in the Peripheral Controller Drive...
Definition: pcd.h:324
unsigned int send_lpm
Definition: pcd.h:401
u32 param1in
Definition: pcd.h:275
@ EP0_OUT_STATUS_PHASE
Definition: pcd.h:107
void dwc_usb3_ep0_activate(volatile dwc_usb3_pcd_t *pcd, int restore)
This routine configures EP0 OUT to receive SETUP packets and configures EP0 IN for transmitting packe...
Definition: pcd.c:312
int dwc_usb3_pcd_init(volatile struct dwc_usb3_device *dev)
u32 ep0_out_save_state
Definition: pcd.h:452
u8 num_out_eps
Definition: pcd.h:487
u32 save_state
Definition: pcd.h:279
unsigned int eps_enabled
Definition: pcd.h:407
@ EP0_IDLE
Definition: pcd.h:99
int link_state
Definition: pcd.h:380
int dwc_exit_hibernation(volatile dwc_usb3_pcd_t *pcd, int restore_state)
This routine wakes the core from hibernation.
Definition: pcd_hiber.c:525
volatile dwc_usb3_pcd_ep_t * ep0
Definition: pcd.h:424
The dwc_ep structure represents the state of a single EP when acting in device mode....
Definition: pcd.h:186