The Core Interface Layer provides basic services for accessing and managing the DWC_usb3 hardware. These services are used by both the Peripheral Controller Driver and the On The Go Driver.
The CIL manages the memory map for the core so that the PCD and OTG drivers don't have to do this separately. The CIL also performs basic services that are not specific to either the Device or OTG modes of operation. These services include all functionality that requires specific knowledge of the CSR layout or the DMA descriptor (TRB) layout. Also included are services for invoking each of the commands provided by the DGCMD and DEPCMD registers (see the "Control and Status Registers" chapter of the USB3 controller databook for details).
The Core Interface Layer has the following requirements:
Functions | |
| static int | _handshake (dwc_usb3_device_t *dev, volatile u32 __iomem *ptr, u32 mask, u32 done) |
| static int | calc_num_in_eps (dwc_usb3_device_t *dev) |
| static int | calc_num_out_eps (dwc_usb3_device_t *dev) |
| void | dwc_usb3_fill_desc (dwc_usb3_dma_desc_t *desc, dwc_dma_t dma_addr, u32 dma_len, u32 stream, u32 type, u32 ctrlbits, int own) |
| void | dwc_usb3_start_desc_chain (dwc_usb3_dma_desc_t *desc) |
| void | dwc_usb3_end_desc_chain (dwc_usb3_dma_desc_t *desc) |
| void | dwc_usb3_enable_desc (dwc_usb3_dma_desc_t *desc) |
| void | dwc_usb3_disable_desc (dwc_usb3_dma_desc_t *desc) |
| int | dwc_usb3_xmit_fn_remote_wake (dwc_usb3_pcd_t *pcd, u32 intf) |
| int | dwc_usb3_xmit_ltm (dwc_usb3_pcd_t *pcd, u32 value) |
| int | dwc_usb3_set_scratchpad_buf_array (dwc_usb3_pcd_t *pcd, dwc_dma_t dma_addr) |
| int | dwc_usb3_flush_fifo (dwc_usb3_pcd_t *pcd, u32 fifo_sel) |
| int | dwc_usb3_dep_cfg (dwc_usb3_pcd_t *pcd, dwc_usb3_dev_ep_regs_t __iomem *ep_reg, u32 depcfg0, u32 depcfg1, u32 depcfg2) |
| int | dwc_usb3_dep_xfercfg (dwc_usb3_pcd_t *pcd, dwc_usb3_dev_ep_regs_t __iomem *ep_reg, u32 depstrmcfg) |
| u32 | dwc_usb3_dep_getepstate (dwc_usb3_pcd_t *pcd, dwc_usb3_dev_ep_regs_t __iomem *ep_reg) |
| int | dwc_usb3_dep_sstall (dwc_usb3_pcd_t *pcd, dwc_usb3_dev_ep_regs_t __iomem *ep_reg) |
| int | dwc_usb3_dep_cstall (dwc_usb3_pcd_t *pcd, dwc_usb3_dev_ep_regs_t __iomem *ep_reg, int clr_pend) |
| int | dwc_usb3_dep_startxfer (dwc_usb3_pcd_t *pcd, dwc_usb3_dev_ep_regs_t __iomem *ep_reg, dwc_dma_t dma_addr, u32 stream_or_uf) |
| int | dwc_usb3_dep_updatexfer (dwc_usb3_pcd_t *pcd, dwc_usb3_dev_ep_regs_t __iomem *ep_reg, u32 tri) |
| int | dwc_usb3_dep_endxfer (dwc_usb3_pcd_t *pcd, dwc_usb3_dev_ep_regs_t __iomem *ep_reg, u32 tri, u32 flags, void *condition) |
| int | dwc_usb3_dep_startnewcfg (dwc_usb3_pcd_t *pcd, dwc_usb3_dev_ep_regs_t __iomem *ep_reg, u32 rsrcidx) |
| int | dwc_usb3_enable_ep (dwc_usb3_pcd_t *pcd, dwc_usb3_pcd_ep_t *ep) |
| int | dwc_usb3_disable_ep (dwc_usb3_pcd_t *pcd, dwc_usb3_pcd_ep_t *ep) |
| int | dwc_usb3_get_device_speed (dwc_usb3_pcd_t *pcd) |
| int | dwc_usb3_get_frame (dwc_usb3_pcd_t *pcd) |
| u32 | dwc_usb3_pcd_get_link_state (dwc_usb3_pcd_t *pcd) |
| This function retrieves the current link state. More... | |
| void | dwc_usb3_pcd_set_link_state (dwc_usb3_pcd_t *pcd, u32 state) |
| This function sets state of USB link. More... | |
| void | dwc_usb3_pcd_remote_wake (dwc_usb3_pcd_t *pcd, int function) |
| This function sends a Remote Wakeup to the host. More... | |
| void | dwc_usb3_set_address (dwc_usb3_pcd_t *pcd, int addr) |
| This function sets the Device Address. More... | |
| void | dwc_usb3_ena_usb2_phy_suspend (dwc_usb3_pcd_t *pcd) |
| This function enables USB2 Phy suspend. More... | |
| void | dwc_usb3_dis_usb2_phy_suspend (dwc_usb3_pcd_t *pcd) |
| void | dwc_usb3_ena_usb3_phy_suspend (dwc_usb3_pcd_t *pcd) |
| void | dwc_usb3_dis_usb3_phy_suspend (dwc_usb3_pcd_t *pcd) |
| void | dwc_usb3_accept_u1 (dwc_usb3_pcd_t *pcd) |
| void | dwc_usb3_accept_u2 (dwc_usb3_pcd_t *pcd) |
| void | dwc_usb3_enable_u1 (dwc_usb3_pcd_t *pcd) |
| void | dwc_usb3_enable_u2 (dwc_usb3_pcd_t *pcd) |
| void | dwc_usb3_disable_u1 (dwc_usb3_pcd_t *pcd) |
| void | dwc_usb3_disable_u2 (dwc_usb3_pcd_t *pcd) |
| int | dwc_usb3_u1_enabled (dwc_usb3_pcd_t *pcd) |
| int | dwc_usb3_u2_enabled (dwc_usb3_pcd_t *pcd) |
| void | dwc_usb3_clr_eps_enabled (dwc_usb3_pcd_t *pcd) |
| void | dwc_usb3_pcd_do_test_mode (unsigned long data) |
| This routine is called when the SET_FEATURE TEST_MODE Setup packet is sent from the host. The Device Control register is written with the Test Mode bits set to the specified Test Mode. This is done as a tasklet so that the "Status" phase of the control transfer completes before transmitting the TEST packets. More... | |
| int | dwc_usb3_pcd_common_init (dwc_usb3_device_t *dev, volatile u8 __iomem *base, const dwc_usb3_core_params_t *core_params) |
| This routine is called to initialize the DWC_usb3 CSR data structures. The register addresses in the device structures are initialized from the base address supplied by the caller. The calling routine must make the OS calls to get the base address of the DWC_usb3 controller registers. The core_params argument holds the parameters that specify how the core should be configured. More... | |
| void | dwc_usb3_pcd_common_remove (dwc_usb3_device_t *dev) |
| int | dwc_usb3_pcd_check_snpsid (dwc_usb3_device_t *dev, u32 addr_ofs) |
| This routine ensures the device is really a DWC_usb3 controller, by reading and verifying the SNPSID register contents. The value should be 0x5533XXXX, which corresponds to "U3", as in "USB3 version X.XXX". More... | |
| void | dwc_usb3_dump_dbgregs (dwc_usb3_device_t *dev) |
| void | dwc_usb3_dump_global_registers (dwc_usb3_device_t *dev) |
| void | dwc_usb3_dump_dev_registers (dwc_usb3_pcd_t *pcd) |
| void | dwc_usb3_set_tx_fifo_size (dwc_usb3_device_t *dev, int *sz) |
| void | dwc_usb3_set_rx_fifo_size (dwc_usb3_device_t *dev, u32 size) |
| void | dwc_usb3_pcd_device_init (dwc_usb3_device_t *dev, int soft_reset, int restore) |
| This routine initializes the DWC_usb3 controller registers. More... | |
| void | dwc_usb3_pcd_device_remove (dwc_usb3_device_t *dev) |
| This routine deinitializes the DWC_usb3 controller registers. More... | |
|
static |
Spin on register bit until handshake completes or times out.
| dev | Programming view of DWC_usb3 controller. |
| ptr | Address of register to read. |
| mask | Bit to look at in result of read. |
| done | Value of the bit when handshake succeeds. |
|
static |
This routine calculates the number of IN EPs (excluding EP0) using GHWPARAMS3 register values
| dev | Programming view of DWC_usb3 controller. |
|
static |
This routine calculates the number of OUT EPs (excluding EP0) using GHWPARAMS3 register values
| dev | Programming view of DWC_usb3 controller. |
| void dwc_usb3_fill_desc | ( | dwc_usb3_dma_desc_t * | desc, |
| dwc_dma_t | dma_addr, | ||
| u32 | dma_len, | ||
| u32 | stream, | ||
| u32 | type, | ||
| u32 | ctrlbits, | ||
| int | own | ||
| ) |
Fill in the four dwords of a DMA descriptor (aka a TRB).
| void dwc_usb3_start_desc_chain | ( | dwc_usb3_dma_desc_t * | desc | ) |
Make a DMA descriptor the start of a chain by setting its CHN bit and clearing its IOC bit.
| desc | The DMA descriptor (TRB) to operate on. |
| void dwc_usb3_end_desc_chain | ( | dwc_usb3_dma_desc_t * | desc | ) |
Make a DMA descriptor the end of a chain by clearing its CHN bit and setting its IOC bit.
| desc | The DMA descriptor (TRB) to operate on. |
| void dwc_usb3_enable_desc | ( | dwc_usb3_dma_desc_t * | desc | ) |
Enable a DMA descriptor by setting its HWO bit.
| desc | The DMA descriptor (TRB) to operate on. |
| void dwc_usb3_disable_desc | ( | dwc_usb3_dma_desc_t * | desc | ) |
Disable a DMA descriptor by clearing its HWO bit.
NOTE: This must only be called if it is known that the hardware has finished with the DMA descriptor, but for some reason the hardware has not cleared the HWO bit.
| desc | The DMA descriptor (TRB) to operate on. |
| int dwc_usb3_xmit_fn_remote_wake | ( | dwc_usb3_pcd_t * | pcd, |
| u32 | intf | ||
| ) |
Send TRANSMIT FUNCTION WAKE DEVICE NOTIFICATION command to Device
| int dwc_usb3_xmit_ltm | ( | dwc_usb3_pcd_t * | pcd, |
| u32 | value | ||
| ) |
Send LATENCY TOLERANCE MESSAGE DEVICE NOTIFICATION command to Device
| int dwc_usb3_set_scratchpad_buf_array | ( | dwc_usb3_pcd_t * | pcd, |
| dwc_dma_t | dma_addr | ||
| ) |
Send SET SCRATCHPAD BUFFER ARRAY command to Device
| int dwc_usb3_flush_fifo | ( | dwc_usb3_pcd_t * | pcd, |
| u32 | fifo_sel | ||
| ) |
Send SELECTED FIFO FLUSH command to Device
| int dwc_usb3_dep_cfg | ( | dwc_usb3_pcd_t * | pcd, |
| dwc_usb3_dev_ep_regs_t __iomem * | ep_reg, | ||
| u32 | depcfg0, | ||
| u32 | depcfg1, | ||
| u32 | depcfg2 | ||
| ) |
Send DEPCFG command to EP
| int dwc_usb3_dep_xfercfg | ( | dwc_usb3_pcd_t * | pcd, |
| dwc_usb3_dev_ep_regs_t __iomem * | ep_reg, | ||
| u32 | depstrmcfg | ||
| ) |
Send DEPXFERCFG command to EP
| u32 dwc_usb3_dep_getepstate | ( | dwc_usb3_pcd_t * | pcd, |
| dwc_usb3_dev_ep_regs_t __iomem * | ep_reg | ||
| ) |
Send DEPGETEPSTATE command to EP
| int dwc_usb3_dep_sstall | ( | dwc_usb3_pcd_t * | pcd, |
| dwc_usb3_dev_ep_regs_t __iomem * | ep_reg | ||
| ) |
Send DEPSSTALL command to EP
| int dwc_usb3_dep_cstall | ( | dwc_usb3_pcd_t * | pcd, |
| dwc_usb3_dev_ep_regs_t __iomem * | ep_reg, | ||
| int | clr_pend | ||
| ) |
Send DEPCSTALL command to EP
| int dwc_usb3_dep_startxfer | ( | dwc_usb3_pcd_t * | pcd, |
| dwc_usb3_dev_ep_regs_t __iomem * | ep_reg, | ||
| dwc_dma_t | dma_addr, | ||
| u32 | stream_or_uf | ||
| ) |
Send DEPSTRTXFER command to EP
| int dwc_usb3_dep_updatexfer | ( | dwc_usb3_pcd_t * | pcd, |
| dwc_usb3_dev_ep_regs_t __iomem * | ep_reg, | ||
| u32 | tri | ||
| ) |
Send DEPUPDTXFER command to EP
| int dwc_usb3_dep_endxfer | ( | dwc_usb3_pcd_t * | pcd, |
| dwc_usb3_dev_ep_regs_t __iomem * | ep_reg, | ||
| u32 | tri, | ||
| u32 | flags, | ||
| void * | condition | ||
| ) |
Send DEPENDXFER command to EP
| int dwc_usb3_dep_startnewcfg | ( | dwc_usb3_pcd_t * | pcd, |
| dwc_usb3_dev_ep_regs_t __iomem * | ep_reg, | ||
| u32 | rsrcidx | ||
| ) |
Send DEPSTRTNEWCFG command to EP
| int dwc_usb3_enable_ep | ( | dwc_usb3_pcd_t * | pcd, |
| dwc_usb3_pcd_ep_t * | ep | ||
| ) |
Enable an EP in the DALEPENA register.
| pcd | Programming view of DWC_usb3 peripheral controller. |
| ep | The EP to enable. |
| int dwc_usb3_disable_ep | ( | dwc_usb3_pcd_t * | pcd, |
| dwc_usb3_pcd_ep_t * | ep | ||
| ) |
Disable an EP in the DALEPENA register.
| pcd | Programming view of DWC_usb3 peripheral controller. |
| ep | The EP to disable. |
| int dwc_usb3_get_device_speed | ( | dwc_usb3_pcd_t * | pcd | ) |
Get the device speed from the device status register and convert it to USB speed constant.
| pcd | Programming view of DWC_usb3 peripheral controller. |
| int dwc_usb3_get_frame | ( | dwc_usb3_pcd_t * | pcd | ) |
Get the current microframe number.
| pcd | Programming view of DWC_usb3 peripheral controller. |
| void dwc_usb3_set_address | ( | dwc_usb3_pcd_t * | pcd, |
| int | addr | ||
| ) |
This function sets the Device Address.
| pcd | Programming view of DWC_usb3 peripheral controller. |
| addr | The address to set. |
| void dwc_usb3_ena_usb2_phy_suspend | ( | dwc_usb3_pcd_t * | pcd | ) |
This function enables USB2 Phy suspend.
| pcd | Programming view of DWC_usb3 peripheral controller. |
| void dwc_usb3_dis_usb2_phy_suspend | ( | dwc_usb3_pcd_t * | pcd | ) |
Disable USB2 Phy suspend.
| pcd | Programming view of DWC_usb3 peripheral controller. |
| void dwc_usb3_ena_usb3_phy_suspend | ( | dwc_usb3_pcd_t * | pcd | ) |
Enable USB3 Phy suspend.
| pcd | Programming view of DWC_usb3 peripheral controller. |
| void dwc_usb3_dis_usb3_phy_suspend | ( | dwc_usb3_pcd_t * | pcd | ) |
Disable USB3 Phy suspend.
| pcd | Programming view of DWC_usb3 peripheral controller. |
| void dwc_usb3_accept_u1 | ( | dwc_usb3_pcd_t * | pcd | ) |
Enable the Device to accept U1 control commands from the Host.
| pcd | Programming view of DWC_usb3 peripheral controller. |
| void dwc_usb3_accept_u2 | ( | dwc_usb3_pcd_t * | pcd | ) |
Enable the Device to accept U2 control commands from the Host.
| pcd | Programming view of DWC_usb3 peripheral controller. |
| void dwc_usb3_enable_u1 | ( | dwc_usb3_pcd_t * | pcd | ) |
Enable U1 sleep.
| pcd | Programming view of DWC_usb3 peripheral controller. |
| void dwc_usb3_enable_u2 | ( | dwc_usb3_pcd_t * | pcd | ) |
Enable U2 sleep.
| pcd | Programming view of DWC_usb3 peripheral controller. |
| void dwc_usb3_disable_u1 | ( | dwc_usb3_pcd_t * | pcd | ) |
Disable U1 sleep.
| pcd | Programming view of DWC_usb3 peripheral controller. |
| void dwc_usb3_disable_u2 | ( | dwc_usb3_pcd_t * | pcd | ) |
Disable U2 sleep.
| pcd | Programming view of DWC_usb3 peripheral controller. |
| int dwc_usb3_u1_enabled | ( | dwc_usb3_pcd_t * | pcd | ) |
Test whether U1 sleep is enabled.
| pcd | Programming view of DWC_usb3 peripheral controller. |
| int dwc_usb3_u2_enabled | ( | dwc_usb3_pcd_t * | pcd | ) |
Test whether U2 sleep is enabled.
| pcd | Programming view of DWC_usb3 peripheral controller. |
| void dwc_usb3_clr_eps_enabled | ( | dwc_usb3_pcd_t * | pcd | ) |
Clear 'eps_enabled' flag and 'ena_once' flags for all EPs, so EPs will get completely reconfigured by SetConfig and SetInterface.
| void dwc_usb3_dump_dbgregs | ( | dwc_usb3_device_t * | dev | ) |
This routine dumps the core's internal debug registers
| dev | Programming view of DWC_usb3 controller. |
| void dwc_usb3_dump_global_registers | ( | dwc_usb3_device_t * | dev | ) |
This routine reads the core global registers and prints them
| dev | Programming view of DWC_usb3 controller. |
| void dwc_usb3_dump_dev_registers | ( | dwc_usb3_pcd_t * | pcd | ) |
This routine reads the device registers and prints them
| pcd | Programming view of DWC_usb3 peripheral controller. |
| void dwc_usb3_set_tx_fifo_size | ( | dwc_usb3_device_t * | dev, |
| int * | sz | ||
| ) |
Set the size of the Tx FIFOs
NOTE: The following code for setting the FIFO sizes only works for cores configured with the 3 RAM option. Setting FIFO sizes for the 2 RAM option is not implemented.
| dev | Programming view of DWC_usb3 controller. |
| sz | New sizes for the FIFOs. |
| void dwc_usb3_set_rx_fifo_size | ( | dwc_usb3_device_t * | dev, |
| u32 | size | ||
| ) |
Set the size of the Rx FIFO
NOTE: The following code for setting the FIFO sizes only works for cores configured with the 3 RAM option. Setting FIFO sizes for the 2 RAM option is not implemented.
| dev | Programming view of DWC_usb3 controller. |
| size | New size for the FIFO. |