/** * usb_hcd_ep93xx_remove - shutdown processing for EP93XX HCD * @dev: USB Host Controller being removed * Context: !in_interrupt() * * Reverses the effect of usb_hcd_ep93xx_probe(), first invoking * the HCD's stop() method. It is always called from a thread * context, normally "rmmod", "apmd", or something similar. * */ void usb_hcd_ep93xx_remove (struct usb_hcd *hcd, struct platform_device *pdev) { usb_remove_hcd(hcd); ep93xx_stop_hc(pdev); iounmap(hcd->regs); release_mem_region(hcd->rsrc_start, hcd->rsrc_len); usb_put_hcd(hcd); }
static int usb_hcd_ep93xx_probe(const struct hc_driver *driver, struct platform_device *pdev) { int retval; struct usb_hcd *hcd; if (pdev->resource[1].flags != IORESOURCE_IRQ) { dbg("resource[1] is not IORESOURCE_IRQ"); return -ENOMEM; } hcd = usb_create_hcd(driver, &pdev->dev, "ep93xx"); if (hcd == NULL) return -ENOMEM; hcd->rsrc_start = pdev->resource[0].start; hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1; if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { usb_put_hcd(hcd); retval = -EBUSY; goto err1; } hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); if (hcd->regs == NULL) { dbg("ioremap failed"); retval = -ENOMEM; goto err2; } usb_host_clock = clk_get(&pdev->dev, NULL); if (IS_ERR(usb_host_clock)) { dbg("clk_get failed"); retval = PTR_ERR(usb_host_clock); goto err3; } ep93xx_start_hc(&pdev->dev); ohci_hcd_init(hcd_to_ohci(hcd)); retval = usb_add_hcd(hcd, pdev->resource[1].start, IRQF_DISABLED); if (retval == 0) return retval; ep93xx_stop_hc(&pdev->dev); err3: iounmap(hcd->regs); err2: release_mem_region(hcd->rsrc_start, hcd->rsrc_len); err1: usb_put_hcd(hcd); return retval; }
static int ohci_hcd_ep93xx_drv_suspend(struct platform_device *pdev, pm_message_t state) { struct usb_hcd *hcd = platform_get_drvdata(pdev); struct ohci_hcd *ohci = hcd_to_ohci(hcd); if (time_before(jiffies, ohci->next_statechange)) msleep(5); ohci->next_statechange = jiffies; ep93xx_stop_hc(&pdev->dev); return 0; }
static int ohci_hcd_ep93xx_drv_suspend(struct platform_device *pdev, pm_message_t state) { struct usb_hcd *hcd = platform_get_drvdata(pdev); struct ochi_hcd *ohci = hcd_to_ohci(hcd); if (time_before(jiffies, ohci->next_statechange)) msleep(5); ohci->next_statechange = jiffies; ep93xx_stop_hc(&pdev->dev); hcd->state = HC_STATE_SUSPENDED; pdev->dev.power.power_state = PMSG_SUSPEND; return 0; }
/** * usb_hcd_ep93xx_probe - initialize EP93XX HCD * 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_ep93xx_probe (const struct hc_driver *driver, /*struct usb_hcd **hcd_out,*/ struct platform_device *pdev) { int retval; struct usb_hcd *hcd = 0; if (pdev->num_resources != 2) { pr_debug("hcd probe: invalid num_resources %x\n",pdev->num_resources); return -ENODEV; } if ((pdev->resource[0].flags != IORESOURCE_MEM) || (pdev->resource[1].flags != IORESOURCE_IRQ)) { pr_debug("hcd probe: invalid resource type\n"); return -ENODEV; } hcd = usb_create_hcd(driver, &pdev->dev, "ep93xx"); if (!hcd){ pr_debug("usb_create_hcd fail\n"); return -ENOMEM; } hcd->rsrc_start = pdev->resource[0].start; hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1; if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { pr_debug("request_mem_region failed\n"); retval = -EBUSY; goto err1; } hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); if (!hcd->regs) { pr_debug("ioremap failed\n"); retval = -EIO; goto err2; } ep93xx_start_hc(pdev); ohci_hcd_init(hcd_to_ohci(hcd)); retval = usb_add_hcd(hcd, pdev->resource[1].start, SA_INTERRUPT); if (retval == 0){ pr_debug("usb add hcd failed\n"); return retval; } /* Error handling */ ep93xx_stop_hc(pdev); iounmap(hcd->regs); err2: release_mem_region(hcd->rsrc_start, hcd->rsrc_len); err1: usb_put_hcd(hcd); return retval; }