static int ohci_hcd_s5pv210_drv_probe(struct platform_device *pdev) { struct usb_hcd *hcd = NULL; int retval = 0; if (usb_disabled()) return -ENODEV; if (pdev->resource[1].flags != IORESOURCE_IRQ) { dev_err(&pdev->dev, "resource[1] is not IORESOURCE_IRQ.\n"); return -ENODEV; } hcd = usb_create_hcd(&ohci_s5pv210_hc_driver, &pdev->dev, "s5pv210"); if (!hcd) { dev_err(&pdev->dev, "usb_create_hcd failed!\n"); return -ENODEV; } 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)) { dev_err(&pdev->dev, "request_mem_region failed!\n"); retval = -EBUSY; goto err1; } usb_clk = clk_get(&pdev->dev, "usb-host"); if (IS_ERR(usb_clk)) { dev_err(&pdev->dev, "cannot get usb-host clock\n"); retval = -ENODEV; goto err2; } s5pv210_start_ohc(); hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); if (!hcd->regs) { dev_err(&pdev->dev, "ioremap failed!\n"); retval = -ENOMEM; goto err2; } ohci_hcd_init(hcd_to_ohci(hcd)); retval = usb_add_hcd(hcd, pdev->resource[1].start, IRQF_DISABLED | IRQF_SHARED); if (retval == 0) { platform_set_drvdata(pdev, hcd); return retval; } s5pv210_stop_ohc(); iounmap(hcd->regs); err2: release_mem_region(hcd->rsrc_start, hcd->rsrc_len); err1: clk_put(usb_clk); usb_put_hcd(hcd); return retval; }
/** * 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) { int retval, irq; struct usb_hcd *hcd; struct pxaohci_platform_data *inf; struct pxa27x_ohci *ohci; struct resource *r; struct clk *usb_clk; retval = ohci_pxa_of_init(pdev); if (retval) return retval; inf = pdev->dev.platform_data; if (!inf) return -ENODEV; irq = platform_get_irq(pdev, 0); if (irq < 0) { pr_err("no resource of IORESOURCE_IRQ"); return -ENXIO; } usb_clk = clk_get(&pdev->dev, NULL); if (IS_ERR(usb_clk)) return PTR_ERR(usb_clk); hcd = usb_create_hcd (driver, &pdev->dev, "pxa27x"); if (!hcd) { retval = -ENOMEM; goto err0; } r = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!r) { pr_err("no resource of IORESOURCE_MEM"); retval = -ENXIO; goto err1; } hcd->rsrc_start = r->start; hcd->rsrc_len = resource_size(r); if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { pr_debug("request_mem_region failed"); retval = -EBUSY; goto err1; } hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); if (!hcd->regs) { pr_debug("ioremap failed"); retval = -ENOMEM; goto err2; } /* initialize "struct pxa27x_ohci" */ ohci = (struct pxa27x_ohci *)hcd_to_ohci(hcd); ohci->dev = &pdev->dev; ohci->clk = usb_clk; ohci->mmio_base = (void __iomem *)hcd->regs; if ((retval = pxa27x_start_hc(ohci, &pdev->dev)) < 0) { pr_debug("pxa27x_start_hc failed"); goto err3; } /* Select Power Management Mode */ pxa27x_ohci_select_pmm(ohci, inf->port_mode); if (inf->power_budget) hcd->power_budget = inf->power_budget; ohci_hcd_init(hcd_to_ohci(hcd)); retval = usb_add_hcd(hcd, irq, 0); if (retval == 0) return retval; pxa27x_stop_hc(ohci, &pdev->dev); err3: iounmap(hcd->regs); err2: release_mem_region(hcd->rsrc_start, hcd->rsrc_len); err1: usb_put_hcd(hcd); err0: clk_put(usb_clk); return retval; }