顯示具有 linux_driver 標籤的文章。 顯示所有文章
顯示具有 linux_driver 標籤的文章。 顯示所有文章

2011年1月5日 星期三

Linux device and driver : USB example

arch\arm\mach-pxa\devices.c
struct platform_device pxa27x_device_ohci = {
    .name        = "pxa27x-ohci",
    .id        = -1,
    .dev        = {
        .dma_mask = &pxa27x_ohci_dma_mask,
        .coherent_dma_mask = DMA_BIT_MASK(32),
    },
    .num_resources  = ARRAY_SIZE(pxa27x_resource_ohci),
    .resource       = pxa27x_resource_ohci,
};
static struct platform_driver ohci_hcd_pxa27x_driver = {
    .probe        = ohci_hcd_pxa27x_drv_probe,
    .remove        = ohci_hcd_pxa27x_drv_remove,
    .shutdown    = usb_hcd_platform_shutdown,
    .driver        = {
        .name    = "pxa27x-ohci",
        .owner    = THIS_MODULE,
#ifdef CONFIG_PM
        .pm    = &ohci_hcd_pxa27x_pm_ops,
#endif
    },
};


static const struct hc_driver ohci_pxa27x_hc_driver = {
    .description =        hcd_name,
    .product_desc =        "PXA27x OHCI",
    .hcd_priv_size =    sizeof(struct pxa27x_ohci),

    /*
     * generic hardware linkage
     */
    .irq =            ohci_irq,
    .flags =        HCD_USB11 | HCD_MEMORY,

    /*
     * basic lifecycle operations
     */
    .start =        ohci_pxa27x_start,
    .stop =            ohci_stop,
    .shutdown =        ohci_shutdown,

    /*
     * managing i/o requests and associated device resources
     */
    .urb_enqueue =        ohci_urb_enqueue,
    .urb_dequeue =        ohci_urb_dequeue,
    .endpoint_disable =    ohci_endpoint_disable,

    /*
     * scheduling support
     */
    .get_frame_number =    ohci_get_frame,

    /*
     * root hub support
     */
    .hub_status_data =    ohci_hub_status_data,
    .hub_control =        ohci_hub_control,
#ifdef  CONFIG_PM
    .bus_suspend =        ohci_bus_suspend,
    .bus_resume =        ohci_bus_resume,
#endif
    .start_port_reset =    ohci_start_port_reset,
};

drivers\usb\host\ohci-pxa27x.c
static int ohci_hcd_pxa27x_drv_probe(struct platform_device *pdev);
/**
 * usb_hcd_pxa27x_probe - initialize pxa27x-based HCDs
 * Context: !in_interrupt()
 *
 * Allocates basic resources for this USB host controller, and
 * then invokes the start() method for the HCD associated with it
 * through the hotplug entry's driver_data.
 *
 */
int usb_hcd_pxa27x_probe (const struct hc_driver *driver, struct platform_device *pdev);
drivers\usb\core\hcd.c
usb_add_hcd