This file contains the structures, constants, and interfaces for the Perpherial Contoller Driver (PCD).
The Peripheral Controller Driver (PCD) for Linux will implement the Gadget API, so that the existing Gadget drivers can be used. For the Mass Storage function, the File-backed USB Storage Gadget (FBS) driver will be used. The FBS driver supports the Control-Bulk (CB), Control-Bulk-Interrupt (CBI), and Bulk-Only transports.
Go to the source code of this file.
Data Structures | |
| struct | dwc_req_t |
| Structure representing a USB transfer request. More... | |
| struct | dwc_usb3_pcd_req_t |
| DWC_usb3 request structure. More... | |
| struct | dwc_ep_t |
The dwc_ep structure represents the state of a single EP when acting in device mode. It contains the data items needed for an EP to be activated and transfer packets. More... | |
| union | dwc_setup_pkt_t |
| Buffer used to store the SETUP packet for EP0. More... | |
| struct | dwc_usb3_pcd_ep_t |
| PCD Endpoint structure. This structure represents an endpoint (EP) in the Peripheral Controller Driver (PCD). More... | |
| struct | dwc_hiber_scratchpad_array |
| Structure representing an array of hibernation scratchpad DMA addresses. More... | |
| struct | dwc_usb3_pcd_t |
| DWC_usb3 PCD Structure. This structure encapsulates the data for the dwc_usb3 PCD. More... | |
Macros | |
| #define | DWC_MAX_TX_FIFOS 16 |
| Maximum number of Tx FIFOs. Depends on the RTL configuration. No way to probe the value at runtime. More... | |
| #define | DWC_MAX_PHYS_EP 32 |
| Maximum number of physical EPs. Depends on the RTL configuration. No way to probe the value at runtime. More... | |
| #define | DWC_MAX_DATA_BUFS 13 |
| Maximum number of data buffers per TRB. OS/application specific. More... | |
| #define | DWC_MAX_EPS 5U |
| Maximum number of EPs, defined by USB spec. More... | |
| #define | DWC_MAX_EP0_SIZE 512 |
| Maxpacket size for EP0, defined by USB3 spec. More... | |
| #define | DWC_MAX_PACKET_SIZE 1024 |
| Maxpacket size for any EP, defined by USB3 spec. More... | |
| #define | DWC_PCD_REQ_ZERO 0x001U |
| #define | DWC_PCD_REQ_STARTED 0x002U |
| #define | DWC_PCD_REQ_MAP_DMA 0x100 |
| #define | DWC_PCD_REQ_IN 0x200 |
| #define | dwc_usb3_pcd_ep_to_pcd(pcd_ep) ((pcd_ep)->dwc_ep.pcd) |
| Macro to retrieve the PCD structure from a PCD endpoint. More... | |
| #define | dwc_usb3_pcd_ep_num(pcd_ep) ((pcd_ep)->dwc_ep.num) |
| Macro to retrieve the endpoint number from a PCD endpoint. More... | |
| #define | dwc_usb3_pcd_ep_type(pcd_ep) ((pcd_ep)->dwc_ep.type) |
| Macro to retrieve the endpoint type from a PCD endpoint. More... | |
| #define | dwc_usb3_pcd_ep_is_in(pcd_ep) ((pcd_ep)->dwc_ep.is_in) |
| Macro to check if the endpoint direction is IN. More... | |
| #define | DWC_STATUS_BUF_SIZE 512U |
| #define | dwc_usb3_ep0_setup_desc(pcd) (pcd)->ep0_setup_desc |
| Macro to retrieve the descriptor for SETUP packets for EP0. More... | |
| #define | dwc_usb3_ep0_setup_desc_dma(pcd) (pcd)->ep0_setup_desc_dma |
| Macro to retrieve the DMA address of the SETUP packet descriptor for EP0. More... | |
| #define | dwc_usb3_ep0_out_desc(pcd) (pcd)->ep0_out_desc |
| Macro to retrieve the descriptor for Data Out or Status Out phases for EP0. More... | |
| #define | dwc_usb3_ep0_out_desc_dma(pcd) (pcd)->ep0_out_desc_dma |
| Macro to retrieve the DMA address of the Data Out or Status Out descriptor for EP0. More... | |
| #define | dwc_usb3_ep0_in_desc(pcd) (pcd)->ep0_in_desc |
| Macro to retrieve the descriptor for Data In or Status In phases for EP0. More... | |
| #define | dwc_usb3_ep0_in_desc_dma(pcd) (pcd)->ep0_in_desc_dma |
| Macro to retrieve the DMA address of the Data In or Status In descriptor for EP0. More... | |
| #define | dwc_usb3_ep0_setup_pkt(pcd) (pcd)->ep0_setup_pkt |
| Macro to retrieve the SETUP packet buffer for EP0. More... | |
| #define | dwc_usb3_ep0_setup_pkt_dma(pcd) (pcd)->ep0_setup_pkt_dma |
| Macro to retrieve the DMA address of the SETUP packet buffer for EP0. More... | |
Enumerations | |
| enum | ep0state_e { EP0_IDLE, EP0_IN_DATA_PHASE, EP0_OUT_DATA_PHASE, EP0_IN_WAIT_GADGET, EP0_OUT_WAIT_GADGET, EP0_IN_WAIT_NRDY, EP0_OUT_WAIT_NRDY, EP0_IN_STATUS_PHASE, EP0_OUT_STATUS_PHASE, EP0_STALL } |
| Enumeration representing the various states of Endpoint 0 (EP0). More... | |
| enum | pcdstate_e { DWC_STATE_UNCONNECTED, DWC_STATE_DEFAULT, DWC_STATE_ADDRESSED, DWC_STATE_CONFIGURED } |
| Enumeration representing the various states of the PCD. More... | |
Functions | |
| void | dwc_usb3_stop_all_xfers (volatile dwc_usb3_pcd_t *pcd) |
| Stop any active xfers on the non-EP0 endpoints. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| int | dwc_usb3_handle_dev_intr (volatile dwc_usb3_pcd_t *pcd, u32 event) |
| PCD interrupt handler. More... | |
| 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 device speed in the data structure. Set up EP0 to receive SETUP packets. More... | |
| 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. More... | |
| 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. More... | |
| int | dwc_exit_hibernation (volatile dwc_usb3_pcd_t *pcd, int restore_state) |
| This routine wakes the core from hibernation. More... | |
| int | dwc_usb3_handle_pme_intr (volatile struct dwc_usb3_device *dev) |
| void | dwc_usb3_power_ctl (volatile struct dwc_usb3_device *dev, int on) |
| int | dwc_usb3_pcd_init (volatile struct dwc_usb3_device *dev) |
| void | dwc_usb3_pcd_remove (volatile struct dwc_usb3_device *dev) |
| 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. More... | |
| 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(). More... | |
| 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. More... | |
| 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 the EP structure. More... | |
| 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 current configuration (SET_CONFIGURATION). More... | |
| 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 configuration. Any pending requests will terminate with a status of -ESHUTDOWN. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| void | dwc_usb3_pcd_ep_clear_stall (volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep) |
| Clear the EP STALL. More... | |
| 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. More... | |
| 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 packets. More... | |
| 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. More... | |
| 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. If pcd->ep0->dwc_ep.is_in is 0 it will be an OUT transfer, otherwise it will be an IN transfer. More... | |
| 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_DATA_PHASE or EP0_IN_DATA_PHASE, and pcd->ep0->dwc_ep.is_in must be set to 0 or 1 before calling this routine. For IN, the data to be sent must be placed in pcd->ep0_status_buf before the call. More... | |
| void | dwc_usb3_handle_ep0_xfer (volatile dwc_usb3_pcd_t *pcd, u32 event) |
| This routine handles EP0 transfers. More... | |
| 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. More... | |
| int | dwc_usb3_pcd_get_frame_number (volatile dwc_usb3_pcd_t *pcd) |
| Gets the current USB frame number. More... | |
| 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 hibernation. The address is stored in the hiber_desc_idx field of the dwc_ep structure during the wakeup process. More... | |
| 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 Function Driver of the disconnect. More... | |
| int | dwc_usb3_gadget_connect (volatile dwc_usb3_pcd_t *pcd, int speed) |
| This routine receives Connect notifications from the PCD. More... | |
| int | dwc_usb3_gadget_disconnect (volatile dwc_usb3_pcd_t *pcd) |
| This routine receives Disconnect notifications from the PCD. More... | |
| int | dwc_usb3_gadget_suspend (volatile dwc_usb3_pcd_t *pcd) |
| This routine receives Suspend notifications from the PCD. More... | |
| int | dwc_usb3_gadget_resume (volatile dwc_usb3_pcd_t *pcd) |
| This routine receives Resume notifications from the PCD. More... | |
| 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. More... | |
| 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. More... | |
| 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. The block of memory returned must have a start address aligned to a 16-byte boundary. More... | |
| 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(). More... | |
| 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. The current transfer request is the first request submitted that has not been completed yet. More... | |
| 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 been started yet. If so then that transfer is started. More... | |
| 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 event. More... | |
| 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. More... | |
| 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. More... | |
| void | dwc_usb3_task_schedule (volatile struct tasklet_struct *tasklet) |
| OS-specific routines called from core code. More... | |
| #define DWC_PCD_REQ_ZERO 0x001U |
Flag indicating zero-length packet.
| #define DWC_PCD_REQ_STARTED 0x002U |
Flag indicating the request has started.
| #define DWC_PCD_REQ_MAP_DMA 0x100 |
Flag indicating DMA mapping is required.
| #define DWC_PCD_REQ_IN 0x200 |
Flag indicating an IN transfer.
| #define DWC_STATUS_BUF_SIZE 512U |