AM261x MCU+ SDK  26.00.00
pcd.c File Reference

Introduction

This file implements the Peripheral Controller Driver.

The Peripheral Controller Driver (PCD) is responsible for translating requests from the Function Driver into the appropriate actions on the DWC_usb3 controller. It isolates the Function Driver from the specifics of the controller by providing an API to the Function Driver.

The Peripheral Controller Driver for Linux will implement the Gadget API, so that the existing Gadget drivers can be used. (Gadget Driver is the Linux terminology for a Function Driver.)

The Linux Gadget API is defined in the header file <linux/usb/gadget.h>. The USB EP operations API is defined in the structure usb_ep_ops and the USB Controller API is defined in the structure usb_gadget_ops.

An important function of the PCD is managing interrupts generated by the DWC_usb3 controller. The implementation of the DWC_usb3 device mode interrupt service routines is in pcd_intr.c.

Functions

static void dwc_usb3_stop_xfer (dwc_usb3_pcd_t *pcd, dwc_usb3_pcd_ep_t *ep)
 This function Stops any active xfer on a non-EP0 endpoint. More...
 
static int dwc_usb3_ep_complete_request (dwc_usb3_pcd_t *pcd, dwc_usb3_pcd_ep_t *ep, dwc_usb3_pcd_req_t *req, u32 event)
 This routine completes the request for the EP. If there are additional requests for the EP in the queue they will be started. More...
 
static void ep_deactivate (dwc_usb3_pcd_t *pcd, dwc_usb3_pcd_ep_t *ep)
 This routine deactivates an EP. More...
 
static void pcd_epinit (dwc_usb3_pcd_t *pcd)
 Initialize the PCD EP structures to their default state. More...
 
dwc_usb3_dma_desc_tdwc_usb3_pcd_trb_alloc (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 (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 (dwc_usb3_pcd_t *pcd, 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_ep0_activate (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_ep_activate (dwc_usb3_pcd_t *pcd, 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...
 
void dwc_usb3_pcd_ep0_out_start (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 (dwc_usb3_pcd_t *pcd, 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_ep_start_transfer (dwc_usb3_pcd_t *pcd, dwc_usb3_pcd_ep_t *ep, 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...
 
int dwc_usb3_pcd_isoc_ep_hiber_restart (dwc_usb3_pcd_t *pcd, 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_stop_all_xfers (dwc_usb3_pcd_t *pcd)
 Stop any active xfers on the non-EP0 endpoints. More...
 
void dwc_usb3_complete_request (dwc_usb3_pcd_t *pcd, dwc_usb3_pcd_ep_t *ep, u32 event)
 This routine handles non-EP0 transfers. More...
 
void dwc_usb3_pcd_ep_set_stall (dwc_usb3_pcd_t *pcd, dwc_usb3_pcd_ep_t *ep)
 Set the EP to STALL. More...
 
void dwc_usb3_pcd_ep_clear_stall (dwc_usb3_pcd_t *pcd, dwc_usb3_pcd_ep_t *ep)
 Clear the EP STALL. More...
 
dwc_usb3_pcd_ep_tdwc_usb3_get_out_ep (dwc_usb3_pcd_t *pcd, u32 ep_num)
 This routine returns a pointer to Out EP struct with number ep_num. More...
 
dwc_usb3_pcd_ep_tdwc_usb3_get_in_ep (dwc_usb3_pcd_t *pcd, u32 ep_num)
 This routine returns a pointer to In EP struct with number ep_num. More...
 
dwc_usb3_pcd_ep_tdwc_usb3_pcd_get_ep_by_addr (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_ep_enable (dwc_usb3_pcd_t *pcd, 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 (dwc_usb3_pcd_t *pcd, 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 (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 (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_ep_set_halt (dwc_usb3_pcd_t *pcd, dwc_usb3_pcd_ep_t *ep, int value)
 This function sets or clears a stall condition on an endpoint. More...
 
void dwc_usb3_pcd_request_done (dwc_usb3_pcd_t *pcd, dwc_usb3_pcd_ep_t *ep, dwc_usb3_pcd_req_t *req, int status)
 This routine completes a request. It calls the request callback. More...
 
void dwc_usb3_pcd_stop (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_pcd_get_frame_number (dwc_usb3_pcd_t *pcd)
 Gets the current USB frame number. More...
 
int dwc_usb3_pcd_init (dwc_usb3_device_t *dev)
 Initialize the PCD portion of the driver. More...
 
void dwc_usb3_pcd_remove (dwc_usb3_device_t *dev)
 Deinitialize the PCD portion of the driver. More...
 

Function Documentation

◆ dwc_usb3_stop_xfer()

static void dwc_usb3_stop_xfer ( dwc_usb3_pcd_t pcd,
dwc_usb3_pcd_ep_t ep 
)
static

This function Stops any active xfer on a non-EP0 endpoint.

Parameters
pcdProgramming view of DWC_usb3 peripheral controller.
epThe EP to stop the transfer on.

◆ dwc_usb3_ep_complete_request()

static int dwc_usb3_ep_complete_request ( dwc_usb3_pcd_t pcd,
dwc_usb3_pcd_ep_t ep,
dwc_usb3_pcd_req_t req,
u32  event 
)
static

This routine completes the request for the EP. If there are additional requests for the EP in the queue they will be started.

Parameters
pcdProgramming view of DWC_usb3 peripheral controller.
epThe EP to complete the request on.
reqThe request to complete.
eventThe event that caused the completion.
Returns
0 on success, -1 on error.

◆ ep_deactivate()

static void ep_deactivate ( dwc_usb3_pcd_t pcd,
dwc_usb3_pcd_ep_t ep 
)
static

This routine deactivates an EP.

Parameters
pcdProgramming view of DWC_usb3 peripheral controller.
epThe EP to deactivate.

◆ pcd_epinit()

static void pcd_epinit ( dwc_usb3_pcd_t pcd)
static

Initialize the PCD EP structures to their default state.

Parameters
pcdThe PCD structure.

◆ dwc_usb3_pcd_init()

int dwc_usb3_pcd_init ( dwc_usb3_device_t dev)

Initialize the PCD portion of the driver.

This routine should be called after dwc_usb3_pcd_common_init() and any platform-specific initialization routines have been called.

This routine must be called in a context that allows dwc_msleep() to be used, because that function is called while waiting for the core to come out of reset.

Parameters
devProgramming view of DWC_usb3 controller.
Returns
0 on success, negative error code on failure.

◆ dwc_usb3_pcd_remove()

void dwc_usb3_pcd_remove ( dwc_usb3_device_t dev)

Deinitialize the PCD portion of the driver.

This routine should be called before any platform-specific deinitialization routines and dwc_usb3_pcd_common_remove() are called.

Parameters
devProgramming view of DWC_usb3 controller.