/** * 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 *dev) { int retval; struct usb_hcd *hcd; if (dev->resource[1].flags != IORESOURCE_IRQ) { pr_debug ("resource[1] is not IORESOURCE_IRQ"); return -ENOMEM; } hcd = usb_create_hcd (driver, &dev->dev, "pxa27x"); if (!hcd) return -ENOMEM; hcd->rsrc_start = dev->resource[0].start; hcd->rsrc_len = dev->resource[0].end - dev->resource[0].start + 1; 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; } pxa27x_start_hc(dev); /* Select Power Management Mode */ pxa27x_ohci_select_pmm( PMM_PERPORT_MODE ); /* If choosing PMM_PERPORT_MODE, we should set the port power before we use it. */ if (pxa27x_ohci_set_port_power(1) < 0) printk(KERN_ERR "Setting port 1 power failed.\n"); if (pxa27x_ohci_clear_port_power(2) < 0) printk(KERN_ERR "Setting port 2 power failed.\n"); if (pxa27x_ohci_clear_port_power(3) < 0) printk(KERN_ERR "Setting port 3 power failed.\n"); ohci_hcd_init(hcd_to_ohci(hcd)); retval = usb_add_hcd(hcd, dev->resource[1].start, SA_INTERRUPT); if (retval == 0) return retval; pxa27x_stop_hc(dev); iounmap(hcd->regs); err2: release_mem_region(hcd->rsrc_start, hcd->rsrc_len); err1: 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 usb_hcd **hcd_out, struct platform_device *dev) { int retval; struct usb_hcd *hcd = 0; unsigned int *addr = NULL; if (!request_mem_region(dev->resource[0].start, dev->resource[0].end - dev->resource[0].start + 1, hcd_name)) { pr_debug("request_mem_region failed"); return -EBUSY; } pxa27x_start_hc(dev); /* Select Power Management Mode */ pxa27x_ohci_select_pmm( PMM_PERPORT_MODE ); /* If choosing PMM_PERPORT_MODE, we should set the port power before we use it. */ if (pxa27x_ohci_set_port_power(1) < 0) printk(KERN_ERR "Setting port 1 power failed.\n"); if (pxa27x_ohci_clear_port_power(2) < 0) printk(KERN_ERR "Setting port 2 power failed.\n"); if (pxa27x_ohci_clear_port_power(3) < 0) printk(KERN_ERR "Setting port 3 power failed.\n"); addr = ioremap(dev->resource[0].start, dev->resource[0].end - dev->resource[0].start + 1); if (!addr) { pr_debug("ioremap failed"); retval = -ENOMEM; goto err1; } hcd = driver->hcd_alloc (); if (hcd == NULL){ pr_debug ("hcd_alloc failed"); retval = -ENOMEM; goto err1; } if(dev->resource[1].flags != IORESOURCE_IRQ){ pr_debug ("resource[1] is not IORESOURCE_IRQ"); retval = -ENOMEM; goto err1; } hcd->driver = (struct hc_driver *) driver; hcd->description = driver->description; hcd->irq = dev->resource[1].start; hcd->regs = addr; hcd->self.controller = &dev->dev; retval = hcd_buffer_create (hcd); if (retval != 0) { pr_debug ("pool alloc fail"); goto err1; } retval = request_irq (hcd->irq, usb_hcd_irq, SA_INTERRUPT, hcd->description, hcd); if (retval != 0) { pr_debug("request_irq(%d) failed with retval %d\n",hcd->irq,retval); retval = -EBUSY; goto err2; } pr_debug ("%s (pxa27x) at 0x%p, irq %d", hcd->description, hcd->regs, hcd->irq); usb_bus_init (&hcd->self); hcd->self.op = &usb_hcd_operations; hcd->self.hcpriv = (void *) hcd; hcd->self.bus_name = "pxa27x"; hcd->product_desc = "PXA27x OHCI"; INIT_LIST_HEAD (&hcd->dev_list); usb_register_bus (&hcd->self); if ((retval = driver->start (hcd)) < 0) { usb_hcd_pxa27x_remove(hcd, dev); return retval; } *hcd_out = hcd; return 0; err2: hcd_buffer_destroy (hcd); if (hcd) driver->hcd_free(hcd); err1: pxa27x_stop_hc(dev); release_mem_region(dev->resource[0].start, dev->resource[0].end - dev->resource[0].start + 1); return retval; }