ohci-omap.c
来自「Linux Kernel 2.6.9 for OMAP1710」· C语言 代码 · 共 640 行 · 第 1/2 页
C
640 行
hcd->self.controller = &pdev->dev; retval = omap_start_hc(ohci, pdev); if (retval < 0) goto err2; retval = hcd_buffer_create (hcd); if (retval != 0) { dev_dbg(&pdev->dev, "pool alloc fail\n"); goto err1; } retval = request_irq (hcd->irq, usb_hcd_irq, SA_INTERRUPT, hcd->description, hcd); if (retval != 0) { dev_dbg(&pdev->dev, "request_irq failed\n"); retval = -EBUSY; goto err2; } dev_info(&pdev->dev, "at 0x%p, irq %d\n", hcd->regs, hcd->irq); usb_bus_init (&hcd->self); hcd->self.op = &usb_hcd_operations; hcd->self.hcpriv = (void *) hcd; hcd->self.bus_name = pdev->dev.bus_id; hcd->product_desc = "OMAP OHCI"; INIT_LIST_HEAD (&hcd->dev_list); usb_register_bus (&hcd->self); if ((retval = driver->start (hcd)) < 0) { usb_hcd_omap_remove(hcd, pdev); return retval; } return 0; err2: hcd_buffer_destroy (hcd); if (hcd) driver->hcd_free(hcd); err1: omap_stop_hc(pdev); release_mem_region(pdev->resource[0].start, pdev->resource[0].end - pdev->resource[0].start + 1); dev_set_drvdata(&pdev->dev, 0); return retval;}/* may be called without controller electrically present *//* may be called with controller, bus, and devices active *//** * usb_hcd_omap_remove - shutdown processing for OMAP-based HCDs * @dev: USB Host Controller being removed * Context: !in_interrupt() * * Reverses the effect of usb_hcd_omap_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_omap_remove (struct usb_hcd *hcd, struct platform_device *pdev){ void *base; dev_info(&pdev->dev, "remove: state %x\n", hcd->state); if (in_interrupt ()) BUG (); hcd->state = USB_STATE_QUIESCING; dev_dbg(&pdev->dev, "roothub graceful disconnect\n"); usb_disconnect (&hcd->self.root_hub); hcd->driver->stop (hcd); hcd_buffer_destroy (hcd); hcd->state = USB_STATE_HALT; if (machine_is_omap_osk()) omap_free_gpio(9); free_irq (hcd->irq, hcd); usb_deregister_bus (&hcd->self); base = hcd->regs; hcd->driver->hcd_free (hcd); omap_stop_hc(pdev); release_mem_region(pdev->resource[0].start, pdev->resource[0].end - pdev->resource[0].start + 1);}/*-------------------------------------------------------------------------*/static int __devinitohci_omap_start (struct usb_hcd *hcd){ struct omap_usb_config *config; struct ohci_hcd *ohci = hcd_to_ohci (hcd); int ret; config = hcd->self.controller->platform_data; ohci->hcca = dma_alloc_coherent (hcd->self.controller, sizeof *ohci->hcca, &ohci->hcca_dma, 0); if (!ohci->hcca) return -ENOMEM; memset (ohci->hcca, 0, sizeof (struct ohci_hcca)); if ((ret = ohci_mem_init (ohci)) < 0) { ohci_stop (hcd); return ret; } ohci->regs = hcd->regs; if (config->otg || config->rwc) writel(OHCI_CTRL_RWC, &ohci->regs->control); if (hc_reset (ohci) < 0) { ohci_stop (hcd); return -ENODEV; } if (hc_start (ohci) < 0) { err ("can't start %s", ohci->hcd.self.bus_name); ohci_stop (hcd); return -EBUSY; } if (ohci->power_budget) hub_set_power_budget(ohci->hcd.self.root_hub, ohci->power_budget); create_debug_files (ohci);#ifdef DEBUG ohci_dump (ohci, 1);#endif return 0;}/*-------------------------------------------------------------------------*/static const struct hc_driver ohci_omap_hc_driver = { .description = hcd_name, /* * generic hardware linkage */ .irq = ohci_irq, .flags = HCD_USB11, /* * basic lifecycle operations */ .start = ohci_omap_start, .stop = ohci_stop, /* * memory lifecycle (except per-request) */ .hcd_alloc = ohci_hcd_alloc, .hcd_free = ohci_hcd_free, /* * 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_USB_SUSPEND .hub_suspend = ohci_hub_suspend, .hub_resume = ohci_hub_resume,#endif .start_port_reset = ohci_start_port_reset,};/*-------------------------------------------------------------------------*/static int ohci_hcd_omap_drv_probe(struct device *dev){ return usb_hcd_omap_probe(&ohci_omap_hc_driver, to_platform_device(dev));}static int ohci_hcd_omap_drv_remove(struct device *dev){ struct platform_device *pdev = to_platform_device(dev); struct usb_hcd *hcd = dev_get_drvdata(dev); struct ohci_hcd *ohci = hcd_to_ohci (hcd); usb_hcd_omap_remove(hcd, pdev); if (ohci->transceiver) { (void) otg_set_host(ohci->transceiver, 0); put_device(ohci->transceiver->dev); } dev_set_drvdata(dev, NULL); return 0;}/*-------------------------------------------------------------------------*/#if defined(CONFIG_USB_SUSPEND) || defined(CONFIG_PM)/* states match PCI usage, always suspending the root hub except that * 4 ~= D3cold (ACPI D3) with clock off (resume sees reset). */static int ohci_omap_suspend(struct device *dev, u32 state, u32 level){ struct ohci_hcd *ohci = hcd_to_ohci(dev_get_drvdata(dev)); int status = -EINVAL; if (state <= dev->power.power_state) return 0; dev_dbg(dev, "suspend to %d\n", state); down(&ohci->hcd.self.root_hub->serialize); status = ohci_hub_suspend(&ohci->hcd); if (status == 0) { if (state >= 4) { /* power off + reset */ OTG_SYSCON_2_REG &= ~UHOST_EN; ohci->hcd.self.root_hub->state = USB_STATE_SUSPENDED; state = 4; } ohci->hcd.state = HCD_STATE_SUSPENDED; dev->power.power_state = state; } up(&ohci->hcd.self.root_hub->serialize); return status;}static int ohci_omap_resume(struct device *dev, u32 level){ struct ohci_hcd *ohci = hcd_to_ohci(dev_get_drvdata(dev)); int status = 0; switch (dev->power.power_state) { case 0: break; case 4: if (time_before(jiffies, ohci->next_statechange)) msleep(5); ohci->next_statechange = jiffies; OTG_SYSCON_2_REG |= UHOST_EN; /* FALLTHROUGH */ default: dev_dbg(dev, "resume from %d\n", dev->power.power_state);#ifdef CONFIG_USB_SUSPEND /* get extra cleanup even if remote wakeup isn't in use */ status = usb_resume_device(ohci->hcd.self.root_hub);#else down(&ohci->hcd.self.root_hub->serialize); status = ohci_hub_resume(&ohci->hcd); up(&ohci->hcd.self.root_hub->serialize);#endif if (status == 0) dev->power.power_state = 0; break; } return status;}#endif/*-------------------------------------------------------------------------*//* * Driver definition to register with the OMAP bus */static struct device_driver ohci_hcd_omap_driver = { .name = "ohci", .bus = &platform_bus_type, .probe = ohci_hcd_omap_drv_probe, .remove = ohci_hcd_omap_drv_remove,#if defined(CONFIG_USB_SUSPEND) || defined(CONFIG_PM) .suspend = ohci_omap_suspend, .resume = ohci_omap_resume,#endif};static int __init ohci_hcd_omap_init (void){ printk (KERN_DEBUG "%s: " DRIVER_INFO " (OMAP)\n", hcd_name); if (usb_disabled()) return -ENODEV; pr_debug("%s: block sizes: ed %Zd td %Zd\n", hcd_name, sizeof (struct ed), sizeof (struct td)); return driver_register(&ohci_hcd_omap_driver);}static void __exit ohci_hcd_omap_cleanup (void){ driver_unregister(&ohci_hcd_omap_driver);}module_init (ohci_hcd_omap_init);module_exit (ohci_hcd_omap_cleanup);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?