dwc_otg_driver.c File Reference

The dwc_otg_driver module provides the initialization and cleanup entry points for the DWC_otg driver. More...

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/device.h>
#include <linux/errno.h>
#include <linux/types.h>
#include <linux/stat.h>
#include <linux/version.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <asm/io.h>
#include "dwc_os.h"
#include "dwc_otg_dbg.h"
#include "dwc_otg_driver.h"
#include "dwc_otg_attr.h"
#include "dwc_otg_core_if.h"
#include "dwc_otg_pcd_if.h"
#include "dwc_otg_hcd_if.h"

Go to the source code of this file.

Data Structures

struct  dwc_otg_driver_module_params

Defines

#define DWC_DRIVER_VERSION   "2.90a 23-APR-2009"
#define DWC_DRIVER_DESC   "HS OTG USB Controller driver"

Functions

int pcd_init ()
 This function initialized the PCD portion of the driver.
int hcd_init ()
 Initializes the HCD.
int pcd_remove ()
 Cleanup the PCD.
void hcd_remove ()
 Removes the HCD.
static ssize_t version_show (struct device_driver *dev, char *buf)
 This function shows the Driver Version.
static DRIVER_ATTR (version, S_IRUGO, version_show, NULL)
static ssize_t dbg_level_show (struct device_driver *drv, char *buf)
 This function shows the driver Debug Level.
static ssize_t dbg_level_store (struct device_driver *drv, const char *buf, size_t count)
 This function stores the driver Debug Level.
static DRIVER_ATTR (debuglevel, S_IRUGO|S_IWUSR, dbg_level_show, dbg_level_store)
static int set_parameters (dwc_otg_core_if_t *core_if)
 This function is called during module intialization to pass module parameters to the DWC_OTG CORE.
static irqreturn_t dwc_otg_common_irq (int irq, void *dev)
 This function is the top level interrupt handler for the Common (Device and host modes) interrupts.
static void dwc_otg_driver_remove ()
 This function is called when a lm_device is unregistered with the dwc_otg_driver.
static int dwc_otg_driver_probe ()
 This function is called when an lm_device is bound to a dwc_otg_driver.
static int __init dwc_otg_driver_init (void)
 This function is called when the dwc_otg_driver is installed with the insmod command.
 module_init (dwc_otg_driver_init)
static void __exit dwc_otg_driver_cleanup (void)
 This function is called when the driver is removed from the kernel with the rmmod command.
 module_exit (dwc_otg_driver_cleanup)
 MODULE_DESCRIPTION (DWC_DRIVER_DESC)
 MODULE_AUTHOR ("Synopsys Inc.")
 MODULE_LICENSE ("GPL")
 module_param_named (otg_cap, dwc_otg_module_params.otg_cap, int, 0444)
 MODULE_PARM_DESC (otg_cap,"OTG Capabilities 0=HNP&SRP 1=SRP Only 2=None")
 module_param_named (opt, dwc_otg_module_params.opt, int, 0444)
 MODULE_PARM_DESC (opt,"OPT Mode")
 module_param_named (dma_enable, dwc_otg_module_params.dma_enable, int, 0444)
 MODULE_PARM_DESC (dma_enable,"DMA Mode 0=Slave 1=DMA enabled")
 module_param_named (dma_desc_enable, dwc_otg_module_params.dma_desc_enable, int, 0444)
 MODULE_PARM_DESC (dma_desc_enable,"DMA Desc Mode 0=Address DMA 1=DMA Descriptor enabled")
 module_param_named (dma_burst_size, dwc_otg_module_params.dma_burst_size, int, 0444)
 MODULE_PARM_DESC (dma_burst_size,"DMA Burst Size 1, 4, 8, 16, 32, 64, 128, 256")
 module_param_named (speed, dwc_otg_module_params.speed, int, 0444)
 MODULE_PARM_DESC (speed,"Speed 0=High Speed 1=Full Speed")
 module_param_named (host_support_fs_ls_low_power, dwc_otg_module_params.host_support_fs_ls_low_power, int, 0444)
 MODULE_PARM_DESC (host_support_fs_ls_low_power,"Support Low Power w/FS or LS 0=Support 1=Don't Support")
 module_param_named (host_ls_low_power_phy_clk, dwc_otg_module_params.host_ls_low_power_phy_clk, int, 0444)
 MODULE_PARM_DESC (host_ls_low_power_phy_clk,"Low Speed Low Power Clock 0=48Mhz 1=6Mhz")
 module_param_named (enable_dynamic_fifo, dwc_otg_module_params.enable_dynamic_fifo, int, 0444)
 MODULE_PARM_DESC (enable_dynamic_fifo,"0=cC Setting 1=Allow Dynamic Sizing")
 module_param_named (data_fifo_size, dwc_otg_module_params.data_fifo_size, int, 0444)
 MODULE_PARM_DESC (data_fifo_size,"Total number of words in the data FIFO memory 32-32768")
 module_param_named (dev_rx_fifo_size, dwc_otg_module_params.dev_rx_fifo_size, int, 0444)
 MODULE_PARM_DESC (dev_rx_fifo_size,"Number of words in the Rx FIFO 16-32768")
 module_param_named (dev_nperio_tx_fifo_size, dwc_otg_module_params.dev_nperio_tx_fifo_size, int, 0444)
 MODULE_PARM_DESC (dev_nperio_tx_fifo_size,"Number of words in the non-periodic Tx FIFO 16-32768")
 module_param_named (dev_perio_tx_fifo_size_1, dwc_otg_module_params.dev_perio_tx_fifo_size[0], int, 0444)
 MODULE_PARM_DESC (dev_perio_tx_fifo_size_1,"Number of words in the periodic Tx FIFO 4-768")
 module_param_named (dev_perio_tx_fifo_size_2, dwc_otg_module_params.dev_perio_tx_fifo_size[1], int, 0444)
 MODULE_PARM_DESC (dev_perio_tx_fifo_size_2,"Number of words in the periodic Tx FIFO 4-768")
 module_param_named (dev_perio_tx_fifo_size_3, dwc_otg_module_params.dev_perio_tx_fifo_size[2], int, 0444)
 MODULE_PARM_DESC (dev_perio_tx_fifo_size_3,"Number of words in the periodic Tx FIFO 4-768")
 module_param_named (dev_perio_tx_fifo_size_4, dwc_otg_module_params.dev_perio_tx_fifo_size[3], int, 0444)
 MODULE_PARM_DESC (dev_perio_tx_fifo_size_4,"Number of words in the periodic Tx FIFO 4-768")
 module_param_named (dev_perio_tx_fifo_size_5, dwc_otg_module_params.dev_perio_tx_fifo_size[4], int, 0444)
 MODULE_PARM_DESC (dev_perio_tx_fifo_size_5,"Number of words in the periodic Tx FIFO 4-768")
 module_param_named (dev_perio_tx_fifo_size_6, dwc_otg_module_params.dev_perio_tx_fifo_size[5], int, 0444)
 MODULE_PARM_DESC (dev_perio_tx_fifo_size_6,"Number of words in the periodic Tx FIFO 4-768")
 module_param_named (dev_perio_tx_fifo_size_7, dwc_otg_module_params.dev_perio_tx_fifo_size[6], int, 0444)
 MODULE_PARM_DESC (dev_perio_tx_fifo_size_7,"Number of words in the periodic Tx FIFO 4-768")
 module_param_named (dev_perio_tx_fifo_size_8, dwc_otg_module_params.dev_perio_tx_fifo_size[7], int, 0444)
 MODULE_PARM_DESC (dev_perio_tx_fifo_size_8,"Number of words in the periodic Tx FIFO 4-768")
 module_param_named (dev_perio_tx_fifo_size_9, dwc_otg_module_params.dev_perio_tx_fifo_size[8], int, 0444)
 MODULE_PARM_DESC (dev_perio_tx_fifo_size_9,"Number of words in the periodic Tx FIFO 4-768")
 module_param_named (dev_perio_tx_fifo_size_10, dwc_otg_module_params.dev_perio_tx_fifo_size[9], int, 0444)
 MODULE_PARM_DESC (dev_perio_tx_fifo_size_10,"Number of words in the periodic Tx FIFO 4-768")
 module_param_named (dev_perio_tx_fifo_size_11, dwc_otg_module_params.dev_perio_tx_fifo_size[10], int, 0444)
 MODULE_PARM_DESC (dev_perio_tx_fifo_size_11,"Number of words in the periodic Tx FIFO 4-768")
 module_param_named (dev_perio_tx_fifo_size_12, dwc_otg_module_params.dev_perio_tx_fifo_size[11], int, 0444)
 MODULE_PARM_DESC (dev_perio_tx_fifo_size_12,"Number of words in the periodic Tx FIFO 4-768")
 module_param_named (dev_perio_tx_fifo_size_13, dwc_otg_module_params.dev_perio_tx_fifo_size[12], int, 0444)
 MODULE_PARM_DESC (dev_perio_tx_fifo_size_13,"Number of words in the periodic Tx FIFO 4-768")
 module_param_named (dev_perio_tx_fifo_size_14, dwc_otg_module_params.dev_perio_tx_fifo_size[13], int, 0444)
 MODULE_PARM_DESC (dev_perio_tx_fifo_size_14,"Number of words in the periodic Tx FIFO 4-768")
 module_param_named (dev_perio_tx_fifo_size_15, dwc_otg_module_params.dev_perio_tx_fifo_size[14], int, 0444)
 MODULE_PARM_DESC (dev_perio_tx_fifo_size_15,"Number of words in the periodic Tx FIFO 4-768")
 module_param_named (host_rx_fifo_size, dwc_otg_module_params.host_rx_fifo_size, int, 0444)
 MODULE_PARM_DESC (host_rx_fifo_size,"Number of words in the Rx FIFO 16-32768")
 module_param_named (host_nperio_tx_fifo_size, dwc_otg_module_params.host_nperio_tx_fifo_size, int, 0444)
 MODULE_PARM_DESC (host_nperio_tx_fifo_size,"Number of words in the non-periodic Tx FIFO 16-32768")
 module_param_named (host_perio_tx_fifo_size, dwc_otg_module_params.host_perio_tx_fifo_size, int, 0444)
 MODULE_PARM_DESC (host_perio_tx_fifo_size,"Number of words in the host periodic Tx FIFO 16-32768")
 module_param_named (max_transfer_size, dwc_otg_module_params.max_transfer_size, int, 0444)
 MODULE_PARM_DESC (max_transfer_size,"The maximum transfer size supported in bytes 2047-65535")
 module_param_named (max_packet_count, dwc_otg_module_params.max_packet_count, int, 0444)
 MODULE_PARM_DESC (max_packet_count,"The maximum number of packets in a transfer 15-511")
 module_param_named (host_channels, dwc_otg_module_params.host_channels, int, 0444)
 MODULE_PARM_DESC (host_channels,"The number of host channel registers to use 1-16")
 module_param_named (dev_endpoints, dwc_otg_module_params.dev_endpoints, int, 0444)
 MODULE_PARM_DESC (dev_endpoints,"The number of endpoints in addition to EP0 available for device mode 1-15")
 module_param_named (phy_type, dwc_otg_module_params.phy_type, int, 0444)
 MODULE_PARM_DESC (phy_type,"0=Reserved 1=UTMI+ 2=ULPI")
 module_param_named (phy_utmi_width, dwc_otg_module_params.phy_utmi_width, int, 0444)
 MODULE_PARM_DESC (phy_utmi_width,"Specifies the UTMI+ Data Width 8 or 16 bits")
 module_param_named (phy_ulpi_ddr, dwc_otg_module_params.phy_ulpi_ddr, int, 0444)
 MODULE_PARM_DESC (phy_ulpi_ddr,"ULPI at double or single data rate 0=Single 1=Double")
 module_param_named (phy_ulpi_ext_vbus, dwc_otg_module_params.phy_ulpi_ext_vbus, int, 0444)
 MODULE_PARM_DESC (phy_ulpi_ext_vbus,"ULPI PHY using internal or external vbus 0=Internal")
 module_param_named (i2c_enable, dwc_otg_module_params.i2c_enable, int, 0444)
 MODULE_PARM_DESC (i2c_enable,"FS PHY Interface")
 module_param_named (ulpi_fs_ls, dwc_otg_module_params.ulpi_fs_ls, int, 0444)
 MODULE_PARM_DESC (ulpi_fs_ls,"ULPI PHY FS/LS mode only")
 module_param_named (ts_dline, dwc_otg_module_params.ts_dline, int, 0444)
 MODULE_PARM_DESC (ts_dline,"Term select Dline pulsing for all PHYs")
 module_param_named (debug, g_dbg_lvl, int, 0444)
 MODULE_PARM_DESC (debug,"")
 module_param_named (en_multiple_tx_fifo, dwc_otg_module_params.en_multiple_tx_fifo, int, 0444)
 MODULE_PARM_DESC (en_multiple_tx_fifo,"Dedicated Non Periodic Tx FIFOs 0=disabled 1=enabled")
 module_param_named (dev_tx_fifo_size_1, dwc_otg_module_params.dev_tx_fifo_size[0], int, 0444)
 MODULE_PARM_DESC (dev_tx_fifo_size_1,"Number of words in the Tx FIFO 4-768")
 module_param_named (dev_tx_fifo_size_2, dwc_otg_module_params.dev_tx_fifo_size[1], int, 0444)
 MODULE_PARM_DESC (dev_tx_fifo_size_2,"Number of words in the Tx FIFO 4-768")
 module_param_named (dev_tx_fifo_size_3, dwc_otg_module_params.dev_tx_fifo_size[2], int, 0444)
 MODULE_PARM_DESC (dev_tx_fifo_size_3,"Number of words in the Tx FIFO 4-768")
 module_param_named (dev_tx_fifo_size_4, dwc_otg_module_params.dev_tx_fifo_size[3], int, 0444)
 MODULE_PARM_DESC (dev_tx_fifo_size_4,"Number of words in the Tx FIFO 4-768")
 module_param_named (dev_tx_fifo_size_5, dwc_otg_module_params.dev_tx_fifo_size[4], int, 0444)
 MODULE_PARM_DESC (dev_tx_fifo_size_5,"Number of words in the Tx FIFO 4-768")
 module_param_named (dev_tx_fifo_size_6, dwc_otg_module_params.dev_tx_fifo_size[5], int, 0444)
 MODULE_PARM_DESC (dev_tx_fifo_size_6,"Number of words in the Tx FIFO 4-768")
 module_param_named (dev_tx_fifo_size_7, dwc_otg_module_params.dev_tx_fifo_size[6], int, 0444)
 MODULE_PARM_DESC (dev_tx_fifo_size_7,"Number of words in the Tx FIFO 4-768")
 module_param_named (dev_tx_fifo_size_8, dwc_otg_module_params.dev_tx_fifo_size[7], int, 0444)
 MODULE_PARM_DESC (dev_tx_fifo_size_8,"Number of words in the Tx FIFO 4-768")
 module_param_named (dev_tx_fifo_size_9, dwc_otg_module_params.dev_tx_fifo_size[8], int, 0444)
 MODULE_PARM_DESC (dev_tx_fifo_size_9,"Number of words in the Tx FIFO 4-768")
 module_param_named (dev_tx_fifo_size_10, dwc_otg_module_params.dev_tx_fifo_size[9], int, 0444)
 MODULE_PARM_DESC (dev_tx_fifo_size_10,"Number of words in the Tx FIFO 4-768")
 module_param_named (dev_tx_fifo_size_11, dwc_otg_module_params.dev_tx_fifo_size[10], int, 0444)
 MODULE_PARM_DESC (dev_tx_fifo_size_11,"Number of words in the Tx FIFO 4-768")
 module_param_named (dev_tx_fifo_size_12, dwc_otg_module_params.dev_tx_fifo_size[11], int, 0444)
 MODULE_PARM_DESC (dev_tx_fifo_size_12,"Number of words in the Tx FIFO 4-768")
 module_param_named (dev_tx_fifo_size_13, dwc_otg_module_params.dev_tx_fifo_size[12], int, 0444)
 MODULE_PARM_DESC (dev_tx_fifo_size_13,"Number of words in the Tx FIFO 4-768")
 module_param_named (dev_tx_fifo_size_14, dwc_otg_module_params.dev_tx_fifo_size[13], int, 0444)
 MODULE_PARM_DESC (dev_tx_fifo_size_14,"Number of words in the Tx FIFO 4-768")
 module_param_named (dev_tx_fifo_size_15, dwc_otg_module_params.dev_tx_fifo_size[14], int, 0444)
 MODULE_PARM_DESC (dev_tx_fifo_size_15,"Number of words in the Tx FIFO 4-768")
 module_param_named (thr_ctl, dwc_otg_module_params.thr_ctl, int, 0444)
 MODULE_PARM_DESC (thr_ctl,"Thresholding enable flag bit 0 - non ISO Tx thr., 1 - ISO Tx thr., 2 - Rx thr.- bit 0=disabled 1=enabled")
 module_param_named (tx_thr_length, dwc_otg_module_params.tx_thr_length, int, 0444)
 MODULE_PARM_DESC (tx_thr_length,"Tx Threshold length in 32 bit DWORDs")
 module_param_named (rx_thr_length, dwc_otg_module_params.rx_thr_length, int, 0444)
 MODULE_PARM_DESC (rx_thr_length,"Rx Threshold length in 32 bit DWORDs")
 module_param_named (pti_enable, dwc_otg_module_params.pti_enable, int, 0444)
 module_param_named (mpi_enable, dwc_otg_module_params.mpi_enable, int, 0444)
 module_param_named (lpm_enable, dwc_otg_module_params.lpm_enable, int, 0444)
 MODULE_PARM_DESC (lpm_enable,"LPM Enable 0=LPM Disabled 1=LPM Enabled")
 module_param_named (ic_usb_cap, dwc_otg_module_params.ic_usb_cap, int, 0444)
 MODULE_PARM_DESC (ic_usb_cap,"IC_USB Capability 0=IC_USB Disabled 1=IC_USB Enabled")
 module_param_named (ahb_thr_ratio, dwc_otg_module_params.ahb_thr_ratio, int, 0444)
 MODULE_PARM_DESC (ahb_thr_ratio,"AHB Threshold Ratio")

Variables

static const char dwc_driver_name [] = "dwc_otg"
static struct dwc_otg_driver_module_params dwc_otg_module_params
uint32_t g_dbg_lvl = 0
 The Debug Level bit-mask variable.


Detailed Description

The dwc_otg_driver module provides the initialization and cleanup entry points for the DWC_otg driver.

This module will be dynamically installed after Linux is booted using the insmod command. When the module is installed, the dwc_otg_driver_init function is called. When the module is removed (using rmmod), the dwc_otg_driver_cleanup function is called.

This module also defines a data structure for the dwc_otg_driver, which is used in conjunction with the standard ARM lm_device structure. These structures allow the OTG driver to comply with the standard Linux driver model in which devices and drivers are registered with a bus driver. This has the benefit that Linux can expose attributes of the driver and device in its special sysfs file system. Users can then read or write files in this file system to perform diagnostics on the driver components or the device.

Definition in file dwc_otg_driver.c.


Function Documentation

int hcd_init (  ) 

Initializes the HCD.

This function allocates memory for and initializes the static parts of the usb_hcd and dwc_otg_hcd structures. It also registers the USB bus with the core and calls the hc_driver->start() function. It returns a negative error on failure.

Definition at line 327 of file dwc_otg_hcd_linux.c.

void hcd_remove (  ) 

Removes the HCD.

Frees memory and resources associated with the HCD and deregisters the bus.

Definition at line 417 of file dwc_otg_hcd_linux.c.

static void dwc_otg_driver_remove (  )  [static]

This function is called when a lm_device is unregistered with the dwc_otg_driver.

This happens, for example, when the rmmod command is executed. The device may or may not be electrically present. If it is present, the driver stops device processing. Any resources used on behalf of this device are freed.

Parameters:
_dev 

Definition at line 525 of file dwc_otg_driver.c.

static int dwc_otg_driver_probe (  )  [static]

This function is called when an lm_device is bound to a dwc_otg_driver.

It creates the driver components required to control the device (CIL, HCD, and PCD) and it initializes the device. The driver components are stored in a dwc_otg_device structure. A reference to the dwc_otg_device is saved in the lm_device. This allows the driver to access the dwc_otg_device structure on subsequent calls to driver methods for this device.

Parameters:
_dev Bus device

Definition at line 608 of file dwc_otg_driver.c.

static int __init dwc_otg_driver_init ( void   )  [static]

This function is called when the dwc_otg_driver is installed with the insmod command.

It registers the dwc_otg_driver structure with the appropriate bus driver. This will cause the dwc_otg_driver_probe function to be called. In addition, the bus driver will automatically expose attributes defined for the device and driver in the special sysfs file system.

Returns:

Definition at line 866 of file dwc_otg_driver.c.

static void __exit dwc_otg_driver_cleanup ( void   )  [static]

This function is called when the driver is removed from the kernel with the rmmod command.

The driver unregisters itself with its bus driver.

Definition at line 899 of file dwc_otg_driver.c.

MODULE_PARM_DESC ( max_transfer_size  ,
"The maximum transfer size supported in bytes 2047-65535"   
)

Todo:
Set the max to 512K, modify checks


Generated on Tue May 5 02:22:49 2009 for DesignWare USB 2.0 OTG Controller (DWC_otg) Device Driver by  doxygen 1.4.7