Main Page | Data Structures | File List | Data Fields | Globals | Related Pages

dwc_otg_pcd.c File Reference

This file implements PCD Core. More...

#include "dwc_otg_pcd.h"

Go to the source code of this file.

Functions

dwc_otg_pcd_ep_tget_ep_from_handle (dwc_otg_pcd_t *pcd, void *handle)
 Choose endpoint from ep arrays using usb_ep structure.
void dwc_otg_request_done (dwc_otg_pcd_ep_t *ep, dwc_otg_pcd_request_t *req, int32_t status)
 This function completes a request.
void dwc_otg_request_nuke (dwc_otg_pcd_ep_t *ep)
 This function terminates all the requsts in the EP request queue.
void dwc_otg_pcd_start (dwc_otg_pcd_t *pcd, const struct dwc_otg_pcd_function_ops *fops)
 Call this to bind the function driver to the PCD Core.
int32_t dwc_otg_pcd_start_cb (void *p)
 PCD Callback function for initializing the PCD when switching to device mode.
uint8_t * cfiw_ep_alloc_buffer (dwc_otg_pcd_t *pcd, void *pep, dwc_dma_t *addr, size_t buflen, int flags)
 CFI-specific buffer allocation function for EP.
int32_t dwc_otg_pcd_resume_cb (void *p)
 PCD Callback function for notifying the PCD when resuming from suspend.
int32_t dwc_otg_pcd_suspend_cb (void *p)
 PCD Callback function for notifying the PCD device is suspended.
int32_t dwc_otg_pcd_stop_cb (void *p)
 PCD Callback function for stopping the PCD when switching to Host mode.
dwc_otg_dev_dma_desc_tdwc_otg_ep_alloc_desc_chain (dwc_dma_t *dma_desc_addr, uint32_t count)
 This function allocates a DMA Descriptor chain for the Endpoint buffer to be used for a transfer to/from the specified endpoint.
void dwc_otg_ep_free_desc_chain (dwc_otg_dev_dma_desc_t *desc_addr, uint32_t dma_desc_addr, uint32_t count)
 This function frees a DMA Descriptor chain that was allocated by ep_alloc_desc.
void dwc_otg_iso_ep_start_ddma_transfer (dwc_otg_core_if_t *core_if, dwc_ep_t *dwc_ep)
 This function initializes a descriptor chain for Isochronous transfer.
void dwc_otg_iso_ep_start_buf_transfer (dwc_otg_core_if_t *core_if, dwc_ep_t *ep)
 This function initializes a descriptor chain for Isochronous transfer.
void dwc_otg_iso_ep_start_transfer (dwc_otg_core_if_t *core_if, dwc_ep_t *ep)
 This function does the setup for a data transfer for an EP and starts the transfer.
void dwc_otg_iso_ep_stop_transfer (dwc_otg_core_if_t *core_if, dwc_ep_t *ep)
 This function stops transfer for an EP and resets the ep's variables.
int dwc_otg_pcd_iso_ep_start (dwc_otg_pcd_t *pcd, void *ep_handle, uint8_t *buf0, uint8_t *buf1, dwc_dma_t dma0, dwc_dma_t dma1, int sync_frame, int dp_frame, int data_per_frame, int start_frame, int buf_proc_intrvl, void *req_handle, int atomic_alloc)
 Start isochronous transfers on the endpoint referenced by ep_handle.
int dwc_otg_pcd_iso_ep_stop (dwc_otg_pcd_t *pcd, void *ep_handle, void *req_handle)
 Stop ISOC transfers on endpoint referenced by ep_handle.
void dwc_otg_iso_buffer_done (dwc_otg_pcd_t *pcd, dwc_otg_pcd_ep_t *ep, void *req_handle)
 This function is used for perodical data exchnage between PCD and gadget drivers.
int dwc_otg_pcd_get_iso_packet_count (dwc_otg_pcd_t *pcd, void *ep_handle, void *iso_req_handle)
 Get ISOC packet count.
void dwc_otg_pcd_get_iso_packet_params (dwc_otg_pcd_t *pcd, void *ep_handle, void *iso_req_handle, int packet, int *status, int *actual, int *offset)
 Get ISOC packet status.
void dwc_otg_pcd_init_ep (dwc_otg_pcd_t *pcd, dwc_otg_pcd_ep_t *pcd_ep, uint32_t is_in, uint32_t ep_num)
void dwc_otg_pcd_reinit (dwc_otg_pcd_t *pcd)
 Initialize ep's.
void srp_timeout (void *ptr)
 This function is called when the SRP timer expires.
void start_next_request (dwc_otg_pcd_ep_t *ep)
 Tasklet.
void start_xfer_tasklet_func (void *data)
dwc_otg_pcd_tdwc_otg_pcd_init (dwc_otg_core_if_t *core_if)
 Call this function to get pointer on dwc_otg_pcd_t, this pointer will be used for all PCD API functions.
void dwc_otg_pcd_remove (dwc_otg_pcd_t *pcd)
 Frees PCD allocated by dwc_otg_pcd_init.
uint32_t dwc_otg_pcd_is_dualspeed (dwc_otg_pcd_t *pcd)
 This function returns whether device is dualspeed.
uint32_t dwc_otg_pcd_is_otg (dwc_otg_pcd_t *pcd)
 This function returns whether device is otg.
uint32_t assign_tx_fifo (dwc_otg_core_if_t *core_if)
 This function assigns periodic Tx FIFO to an periodic EP in shared Tx FIFO mode.
uint32_t assign_perio_tx_fifo (dwc_otg_core_if_t *core_if)
 This function assigns periodic Tx FIFO to an periodic EP in shared Tx FIFO mode.
void release_perio_tx_fifo (dwc_otg_core_if_t *core_if, uint32_t fifo_num)
 This function releases periodic Tx FIFO in shared Tx FIFO mode.
void release_tx_fifo (dwc_otg_core_if_t *core_if, uint32_t fifo_num)
 This function releases periodic Tx FIFO in shared Tx FIFO mode.
int dwc_otg_pcd_ep_enable (dwc_otg_pcd_t *pcd, const uint8_t *ep_desc, void *usb_ep)
 Enables an endpoint for use.
int dwc_otg_pcd_ep_disable (dwc_otg_pcd_t *pcd, void *ep_handle)
 Disable the endpoint referenced by ep_handle.
int dwc_otg_pcd_ep_queue (dwc_otg_pcd_t *pcd, void *ep_handle, uint8_t *buf, dwc_dma_t dma_buf, uint32_t buflen, int zero, void *req_handle, int atomic_alloc)
 Queue a data transfer request on the endpoint referenced by ep_handle.
int dwc_otg_pcd_ep_dequeue (dwc_otg_pcd_t *pcd, void *ep_handle, void *req_handle)
 De-queue the specified data transfer that has not yet completed.
int dwc_otg_pcd_ep_halt (dwc_otg_pcd_t *pcd, void *ep_handle, int value)
 Halt (STALL) an endpoint or clear it.
void dwc_otg_pcd_rem_wkup_from_suspend (dwc_otg_pcd_t *pcd, int set)
 This function initiates remote wakeup of the host from suspend state.
void dwc_otg_pcd_remote_wakeup (dwc_otg_pcd_t *pcd, int set)
 Starts remote wakeup signaling.
void dwc_otg_pcd_disconnect_us (dwc_otg_pcd_t *pcd, int no_of_usecs)
 Starts micorsecond soft disconnect.
int dwc_otg_pcd_wakeup (dwc_otg_pcd_t *pcd)
 This function starts the SRP Protocol if no session is in progress.
void dwc_otg_pcd_initiate_srp (dwc_otg_pcd_t *pcd)
 Initiate SRP.
int dwc_otg_pcd_get_frame_number (dwc_otg_pcd_t *pcd)
 This function returns current frame number.
int dwc_otg_pcd_is_lpm_enabled (dwc_otg_pcd_t *pcd)
 This function returns 1 if LPM support is enabled, and 0 otherwise.
uint32_t get_b_hnp_enable (dwc_otg_pcd_t *pcd)
 These functions allow to get hnp parameters.
uint32_t get_a_hnp_support (dwc_otg_pcd_t *pcd)
uint32_t get_a_alt_hnp_support (dwc_otg_pcd_t *pcd)
int dwc_otg_pcd_get_rmwkup_enable (dwc_otg_pcd_t *pcd)
 This function returns 1 if remote wakeup is allowed and 0, otherwise.

Variables

dwc_otg_cil_callbacks_t pcd_callbacks
 PCD Callback structure for handling mode switching.


Detailed Description

This file implements PCD Core.

All code in this file is portable and doesn't use any OS specific functions. PCD Core provides Interface, defined in <dwc_otg_pcd_if.h> header file, which can be used to implement OS specific PCD interface.

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

Todo:
Add Device Mode test modes (Test J mode, Test K mode, etc).

Does it work when the request size is greater than DEPTSIZ transfer size

Definition in file dwc_otg_pcd.c.


Function Documentation

void dwc_otg_request_done dwc_otg_pcd_ep_t ep,
dwc_otg_pcd_request_t req,
int32_t  status
 

This function completes a request.

It call's the request call back.

Definition at line 81 of file dwc_otg_pcd.c.

void dwc_otg_pcd_start dwc_otg_pcd_t pcd,
const struct dwc_otg_pcd_function_ops fops
 

Call this to bind the function driver to the PCD Core.

Parameters:
pcd Pointer on dwc_otg_pcd_t returned by dwc_otg_pcd_init function.
fops The Function Driver Ops data structure containing pointers to all callbacks.

Definition at line 119 of file dwc_otg_pcd.c.

int32_t dwc_otg_pcd_start_cb void *  p  )  [static]
 

PCD Callback function for initializing the PCD when switching to device mode.

Parameters:
p void pointer to the dwc_otg_pcd_t

Definition at line 131 of file dwc_otg_pcd.c.

int32_t dwc_otg_pcd_resume_cb void *  p  )  [static]
 

PCD Callback function for notifying the PCD when resuming from suspend.

Parameters:
p void pointer to the dwc_otg_pcd_t

Definition at line 173 of file dwc_otg_pcd.c.

int32_t dwc_otg_pcd_suspend_cb void *  p  )  [static]
 

PCD Callback function for notifying the PCD device is suspended.

Parameters:
p void pointer to the dwc_otg_pcd_t

Definition at line 197 of file dwc_otg_pcd.c.

int32_t dwc_otg_pcd_stop_cb void *  p  )  [static]
 

PCD Callback function for stopping the PCD when switching to Host mode.

Parameters:
p void pointer to the dwc_otg_pcd_t

Definition at line 216 of file dwc_otg_pcd.c.

void dwc_otg_iso_ep_start_ddma_transfer dwc_otg_core_if_t core_if,
dwc_ep_t dwc_ep
 

This function initializes a descriptor chain for Isochronous transfer.

Parameters:
core_if Programming view of DWC_otg controller.
dwc_ep The EP to start the transfer on.

Allocate descriptors for double buffering

ISO OUT EP

Buffer 0 descriptors setup

Buffer 1 descriptors setup

Write dma_ad into DOEPDMA register

ISO IN EP

Buffer 0 descriptors setup

Buffer 1 descriptors setup

Write dma_ad into diepdma register

Enable endpoint, clear nak

Definition at line 266 of file dwc_otg_pcd.c.

void dwc_otg_iso_ep_start_buf_transfer dwc_otg_core_if_t core_if,
dwc_ep_t ep
 

This function initializes a descriptor chain for Isochronous transfer.

Parameters:
core_if Programming view of DWC_otg controller.
ep The EP to start the transfer on.

Enable endpoint, clear nak

Definition at line 540 of file dwc_otg_pcd.c.

void dwc_otg_iso_ep_start_transfer dwc_otg_core_if_t core_if,
dwc_ep_t ep
[static]
 

This function does the setup for a data transfer for an EP and starts the transfer.

For an IN transfer, the packets will be loaded into the appropriate Tx FIFO in the ISR. For OUT transfers, the packets are unloaded from the Rx FIFO in the ISR.

Parameters:
core_if Programming view of DWC_otg controller.
ep The EP to start the transfer on.

Definition at line 623 of file dwc_otg_pcd.c.

void dwc_otg_iso_ep_stop_transfer dwc_otg_core_if_t core_if,
dwc_ep_t ep
 

This function stops transfer for an EP and resets the ep's variables.

Parameters:
core_if Programming view of DWC_otg controller.
ep The EP to start the transfer on.

Definition at line 664 of file dwc_otg_pcd.c.

int dwc_otg_pcd_iso_ep_start dwc_otg_pcd_t pcd,
void *  ep_handle,
uint8_t *  buf0,
uint8_t *  buf1,
dwc_dma_t  dma0,
dwc_dma_t  dma1,
int  sync_frame,
int  dp_frame,
int  data_per_frame,
int  start_frame,
int  buf_proc_intrvl,
void *  req_handle,
int  atomic_alloc
 

Start isochronous transfers on the endpoint referenced by ep_handle.

Todo:
  • pattern data support is to be implemented in the future

Definition at line 708 of file dwc_otg_pcd.c.

int dwc_otg_pcd_iso_ep_stop dwc_otg_pcd_t pcd,
void *  ep_handle,
void *  req_handle
 

Stop ISOC transfers on endpoint referenced by ep_handle.

Parameters:
pcd The PCD
ep_handle The handle of the endpoint
req_handle Handle of ISOC request
Returns -DWC_E_INVALID if incorrect arguments are passed to the function Returns 0 on success

Definition at line 817 of file dwc_otg_pcd.c.

void dwc_otg_iso_buffer_done dwc_otg_pcd_t pcd,
dwc_otg_pcd_ep_t ep,
void *  req_handle
 

This function is used for perodical data exchnage between PCD and gadget drivers.

for Isochronous EPs

  • Every time a sync period completes this function is called to perform data exchange between PCD and gadget

Definition at line 853 of file dwc_otg_pcd.c.

int dwc_otg_pcd_get_iso_packet_count dwc_otg_pcd_t pcd,
void *  ep_handle,
void *  iso_req_handle
 

Get ISOC packet count.

Parameters:
pcd The PCD
ep_handle The handle of the endpoint
iso_req_handle 

Definition at line 873 of file dwc_otg_pcd.c.

void dwc_otg_pcd_get_iso_packet_params dwc_otg_pcd_t pcd,
void *  ep_handle,
void *  iso_req_handle,
int  packet,
int *  status,
int *  actual,
int *  offset
 

Get ISOC packet status.

Parameters:
pcd The PCD
ep_handle The handle of the endpoint
iso_req_handle Isochronoush request handle
packet Number of packet
status Out parameter for returning status
actual Out parameter for returning actual length
offset Out parameter for returning offset

Definition at line 889 of file dwc_otg_pcd.c.

void dwc_otg_pcd_reinit dwc_otg_pcd_t pcd  )  [static]
 

Initialize ep's.

Initialize the EP0 structure.

Todo:
NGS: Add direction to EP, based on contents of HWCFG1. Need a copy of HWCFG1 in pcd structure? sprintf(";r

NGS: Add direction to EP, based on contents of HWCFG1. Need a copy of HWCFG1 in pcd structure? sprintf(";r

Definition at line 941 of file dwc_otg_pcd.c.

void srp_timeout void *  ptr  )  [static]
 

This function is called when the SRP timer expires.

The SRP should complete within 6 seconds.

Definition at line 1000 of file dwc_otg_pcd.c.

dwc_otg_pcd_t* dwc_otg_pcd_init dwc_otg_core_if_t core_if  ) 
 

Call this function to get pointer on dwc_otg_pcd_t, this pointer will be used for all PCD API functions.

Initialize xfer timeout timer. Implemented for 2.93a feature "Device DDMA OUT NAK Enhancement"

Definition at line 1110 of file dwc_otg_pcd.c.

void dwc_otg_pcd_remove dwc_otg_pcd_t pcd  ) 
 

Frees PCD allocated by dwc_otg_pcd_init.

Parameters:
pcd The PCD

Definition at line 1309 of file dwc_otg_pcd.c.

int dwc_otg_pcd_ep_enable dwc_otg_pcd_t pcd,
const uint8_t *  ep_desc,
void *  usb_ep
 

Enables an endpoint for use.

This function enables an endpoint in the PCD. The endpoint is described by the ep_desc which has the same format as a USB ep descriptor. The ep_handle parameter is used to refer to the endpoint from other API functions and in callbacks. Normally this should be called after a SET_CONFIGURATION/SET_INTERFACE to configure the core for that interface.

Returns -DWC_E_INVALID if invalid parameters were passed. Returns -DWC_E_SHUTDOWN if any other error ocurred. Returns 0 on success.

Parameters:
pcd The PCD
ep_desc Endpoint descriptor
usb_ep Handle on endpoint, that will be used to identify endpoint.

Definition at line 1461 of file dwc_otg_pcd.c.

int dwc_otg_pcd_ep_disable dwc_otg_pcd_t pcd,
void *  ep_handle
 

Disable the endpoint referenced by ep_handle.

Returns -DWC_E_INVALID if invalid parameters were passed. Returns -DWC_E_SHUTDOWN if any other error occurred. Returns 0 on success.

Definition at line 1622 of file dwc_otg_pcd.c.

int dwc_otg_pcd_ep_queue dwc_otg_pcd_t pcd,
void *  ep_handle,
uint8_t *  buf,
dwc_dma_t  dma_buf,
uint32_t  buflen,
int  zero,
void *  req_handle,
int  atomic_alloc
 

Queue a data transfer request on the endpoint referenced by ep_handle.

Todo:
NGS Create a function for this.

Definition at line 2079 of file dwc_otg_pcd.c.

int dwc_otg_pcd_ep_dequeue dwc_otg_pcd_t pcd,
void *  ep_handle,
void *  req_handle
 

De-queue the specified data transfer that has not yet completed.

Returns -DWC_E_INVALID if invalid parameters were passed. Returns -DWC_E_SHUTDOWN if any other error ocurred. Returns 0 on success.

Definition at line 2306 of file dwc_otg_pcd.c.

int dwc_otg_pcd_ep_halt dwc_otg_pcd_t pcd,
void *  ep_handle,
int  value
 

Halt (STALL) an endpoint or clear it.

Returns -DWC_E_INVALID if invalid parameters were passed. Returns -DWC_E_SHUTDOWN if any other error ocurred. Returns -DWC_E_AGAIN if the STALL cannot be sent and must be tried again later Returns 0 on success.

Definition at line 2345 of file dwc_otg_pcd.c.

int dwc_otg_pcd_wakeup dwc_otg_pcd_t pcd  ) 
 

This function starts the SRP Protocol if no session is in progress.

If a session is already in progress, but the device is suspended, remote wakeup signaling is started.

Definition at line 2559 of file dwc_otg_pcd.c.

void dwc_otg_pcd_initiate_srp dwc_otg_pcd_t pcd  ) 
 

Initiate SRP.

Parameters:
pcd the pcd structure.

Definition at line 2596 of file dwc_otg_pcd.c.


Variable Documentation

dwc_otg_cil_callbacks_t pcd_callbacks [static]
 

Initial value:

 {
        .start = dwc_otg_pcd_start_cb,
        .stop = dwc_otg_pcd_stop_cb,
        .suspend = dwc_otg_pcd_suspend_cb,
        .resume_wakeup = dwc_otg_pcd_resume_cb,
        .p = 0,                 
}
PCD Callback structure for handling mode switching.

Definition at line 228 of file dwc_otg_pcd.c.


Generated on Thu Oct 27 03:56:38 2011 for DesignWare USB 2.0 OTG Controller (DWC_otg) Device Driver by  doxygen 1.3.9.1