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

dwc_otg_pcd_linux.c File Reference

This file implements the Peripheral Controller Driver. More...

#include "dwc_otg_os_dep.h"
#include "dwc_otg_pcd_if.h"
#include "dwc_otg_pcd.h"
#include "dwc_otg_driver.h"
#include "dwc_otg_dbg.h"

Go to the source code of this file.

Data Structures

struct  gadget_wrapper

Functions

void dump_msg (const u8 *buf, unsigned int length)
dwc_otg_pcd_epep_from_handle (dwc_otg_pcd_t *pcd, void *handle)
 Get the dwc_otg_pcd_ep_t* from usb_ep* pointer - NULL in case if the endpoint is not found.
int ep_enable (struct usb_ep *usb_ep, const struct usb_endpoint_descriptor *ep_desc)
 This function is called by the Gadget Driver for each EP to be configured for the current configuration (SET_CONFIGURATION).
int ep_disable (struct usb_ep *usb_ep)
 This function is called when an EP is disabled due to disconnect or change in configuration.
usb_request * dwc_otg_pcd_alloc_request (struct usb_ep *ep, gfp_t gfp_flags)
 This function allocates a request object to use with the specified endpoint.
void dwc_otg_pcd_free_request (struct usb_ep *ep, struct usb_request *req)
 This function frees a request object.
int ep_queue (struct usb_ep *usb_ep, struct usb_request *usb_req, gfp_t gfp_flags)
 This function is used to submit an I/O Request to an EP.
int ep_dequeue (struct usb_ep *usb_ep, struct usb_request *usb_req)
 This function cancels an I/O request from an EP.
int ep_halt (struct usb_ep *usb_ep, int value)
 usb_ep_set_halt stalls an endpoint.
int iso_ep_start (struct usb_ep *usb_ep, struct usb_iso_request *req, gfp_t gfp_flags)
 This function is used to submit an ISOC Transfer Request to an EP.
int iso_ep_stop (struct usb_ep *usb_ep, struct usb_iso_request *req)
 This function stops ISO EP Periodic Data Transfer.
usb_iso_request * alloc_iso_request (struct usb_ep *ep, int packets, gfp_t gfp_flags)
void free_iso_request (struct usb_ep *ep, struct usb_iso_request *req)
int get_frame_number (struct usb_gadget *gadget)
 Gets the USB Frame number of the last SOF.
int wakeup (struct usb_gadget *gadget)
 Initiates Session Request Protocol (SRP) to wakeup the host if no session is in progress.
int _setup (dwc_otg_pcd_t *pcd, uint8_t *bytes)
int _isoc_complete (dwc_otg_pcd_t *pcd, void *ep_handle, void *req_handle, int proc_buf_num)
int _complete (dwc_otg_pcd_t *pcd, void *ep_handle, void *req_handle, int32_t status, uint32_t actual)
int _connect (dwc_otg_pcd_t *pcd, int speed)
int _disconnect (dwc_otg_pcd_t *pcd)
int _resume (dwc_otg_pcd_t *pcd)
int _suspend (dwc_otg_pcd_t *pcd)
int _hnp_changed (dwc_otg_pcd_t *pcd)
 This function updates the otg values in the gadget structure.
int _reset (dwc_otg_pcd_t *pcd)
irqreturn_t dwc_otg_pcd_irq (int irq, void *dev)
 This function is the top level PCD interrupt handler.
void gadget_add_eps (struct gadget_wrapper *d)
 This function initialized the usb_ep structures to there default state.
void dwc_otg_pcd_gadget_release (struct device *dev)
 This function releases the Gadget device.
gadget_wrapper * alloc_wrapper ()
void free_wrapper (struct gadget_wrapper *d)
int pcd_init ()
 This function initialized the PCD portion of the driver.
void pcd_remove ()
 Cleanup the PCD.
int usb_gadget_probe_driver (struct usb_gadget_driver *driver, int(*bind)(struct usb_gadget *))
 This function registers a gadget driver with the PCD.
 EXPORT_SYMBOL (usb_gadget_probe_driver)
int usb_gadget_unregister_driver (struct usb_gadget_driver *driver)
 This function unregisters a gadget driver.
 EXPORT_SYMBOL (usb_gadget_unregister_driver)

Variables

gadget_wrapper * gadget_wrapper
usb_isoc_ep_ops dwc_otg_pcd_ep_ops
const struct usb_gadget_ops dwc_otg_pcd_ops
const struct dwc_otg_pcd_function_ops fops


Detailed Description

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_otg 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.

Definition in file dwc_otg_pcd_linux.c.


Function Documentation

int ep_enable struct usb_ep *  usb_ep,
const struct usb_endpoint_descriptor *  ep_desc
[static]
 

This function is called by the Gadget Driver for each EP to be configured for the current configuration (SET_CONFIGURATION).

This function initializes the dwc_otg_ep_t data structure, and then calls dwc_otg_ep_activate.

Definition at line 121 of file dwc_otg_pcd_linux.c.

int ep_disable struct usb_ep *  usb_ep  )  [static]
 

This function is called when an EP is disabled due to disconnect or change in configuration.

Any pending requests will terminate with a status of -ESHUTDOWN.

This function modifies the dwc_otg_ep_t data structure for this EP, and then calls dwc_otg_ep_deactivate.

Definition at line 177 of file dwc_otg_pcd_linux.c.

struct usb_request* dwc_otg_pcd_alloc_request struct usb_ep *  ep,
gfp_t  gfp_flags
[static]
 

This function allocates a request object to use with the specified endpoint.

Parameters:
ep The endpoint to be used with with the request
gfp_flags the GFP_* flags to use.

Definition at line 203 of file dwc_otg_pcd_linux.c.

void dwc_otg_pcd_free_request struct usb_ep *  ep,
struct usb_request *  req
[static]
 

This function frees a request object.

Parameters:
ep The endpoint associated with the request
req The request being freed

Definition at line 230 of file dwc_otg_pcd_linux.c.

int ep_queue struct usb_ep *  usb_ep,
struct usb_request *  usb_req,
gfp_t  gfp_flags
[static]
 

This function is used to submit an I/O Request to an EP.

  • When the request completes the request's completion callback is called to return the request to the driver.
  • An EP, except control EPs, may have multiple requests pending.
  • Once submitted the request cannot be examined or modified.
  • Each request is turned into one or more packets.
  • A BULK EP can queue any amount of data; the transfer is packetized.
  • Zero length Packets are specified with the request 'zero' flag.

Definition at line 317 of file dwc_otg_pcd_linux.c.

int ep_halt struct usb_ep *  usb_ep,
int  value
[static]
 

usb_ep_set_halt stalls an endpoint.

usb_ep_clear_halt clears an endpoint halt and resets its data toggle.

Both of these functions are implemented with the same underlying function. The behavior depends on the value argument.

Parameters:
[in] usb_ep the Endpoint to halt or clear halt.
[in] value 
  • 0 means clear_halt.
  • 1 means set_halt,
  • 2 means clear stall lock flag.
  • 3 means set stall lock flag.

Definition at line 430 of file dwc_otg_pcd_linux.c.

int iso_ep_start struct usb_ep *  usb_ep,
struct usb_iso_request *  req,
gfp_t  gfp_flags
[static]
 

This function is used to submit an ISOC Transfer Request to an EP.

  • Every time a sync period completes the request's completion callback is called to provide data to the gadget driver.
  • Once submitted the request cannot be modified.
  • Each request is turned into periodic data packets untill ISO Transfer is stopped..

Definition at line 461 of file dwc_otg_pcd_linux.c.

int wakeup struct usb_gadget *  gadget  )  [static]
 

Initiates Session Request Protocol (SRP) to wakeup the host 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 646 of file dwc_otg_pcd_linux.c.

void gadget_add_eps struct gadget_wrapper *  d  ) 
 

This function initialized the usb_ep structures to there default state.

Parameters:
d Pointer on gadget_wrapper.

Initialize the EP0 structure.

Todo:
NGS: What should the max packet size be set to here? Before EP type is set?

NGS: What should the max packet size be set to here? Before EP type is set?

NGS: What should the max packet size be set to here? Before EP type is set?

Initialize the EP structures.

Definition at line 950 of file dwc_otg_pcd_linux.c.

void dwc_otg_pcd_gadget_release struct device *  dev  )  [static]
 

This function releases the Gadget device.

required by device_unregister().

Todo:
Should this do something? Should it free the PCD?

Definition at line 1067 of file dwc_otg_pcd_linux.c.

int usb_gadget_probe_driver struct usb_gadget_driver *  driver,
int(*)(struct usb_gadget *)  bind
 

This function registers a gadget driver with the PCD.

When a driver is successfully registered, it will receive control requests including set_configuration(), which enables non-control requests. then usb traffic follows until a disconnect is reported. then a host may connect again, or the driver might get unbound.

Parameters:
driver The driver being registered
bind The bind function of gadget driver

Definition at line 1234 of file dwc_otg_pcd_linux.c.

int usb_gadget_unregister_driver struct usb_gadget_driver *  driver  ) 
 

This function unregisters a gadget driver.

Parameters:
driver The driver being unregistered

Definition at line 1294 of file dwc_otg_pcd_linux.c.


Variable Documentation

struct usb_isoc_ep_ops dwc_otg_pcd_ep_ops [static]
 

Initial value:

 {
        .ep_ops = {
                   .enable = ep_enable,
                   .disable = ep_disable,

                   .alloc_request = dwc_otg_pcd_alloc_request,
                   .free_request = dwc_otg_pcd_free_request,






                   .queue = ep_queue,
                   .dequeue = ep_dequeue,

                   .set_halt = ep_halt,
                   .fifo_status = 0,
                   .fifo_flush = 0,
                   },
        .iso_ep_start = iso_ep_start,
        .iso_ep_stop = iso_ep_stop,
        .alloc_iso_request = alloc_iso_request,
        .free_iso_request = free_iso_request,
}

Definition at line 546 of file dwc_otg_pcd_linux.c.

const struct usb_gadget_ops dwc_otg_pcd_ops [static]
 

Initial value:

 {
        .get_frame = get_frame_number,
        .wakeup = wakeup,



        
}

Definition at line 661 of file dwc_otg_pcd_linux.c.

const struct dwc_otg_pcd_function_ops fops [static]
 

Initial value:

 {
        .complete = _complete,

        .isoc_complete = _isoc_complete,

        .setup = _setup,
        .disconnect = _disconnect,
        .connect = _connect,
        .resume = _resume,
        .suspend = _suspend,
        .hnp_changed = _hnp_changed,
        .reset = _reset,






}

Definition at line 909 of file dwc_otg_pcd_linux.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