2 * OHCI HCD (Host Controller Driver) for USB.
4 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
5 * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net>
6 * (C) Copyright 2002 Hewlett-Packard Company
7 * (C) Copyright 2003-2005 MontaVista Software Inc.
9 * Bus Glue for PPC On-Chip OHCI driver
10 * Tested on Freescale MPC5200 and IBM STB04xxx
12 * Modified by Dale Farnsworth <dale@farnsworth.org> from ohci-sa1111.c
14 * This file is licenced under the GPL.
17 #include <linux/platform_device.h>
18 #include <linux/signal.h>
20 /* configure so an HC device and id are always provided */
21 /* always called with process context; sleeping is OK */
24 * usb_hcd_ppc_soc_probe - initialize On-Chip HCDs
25 * Context: !in_interrupt()
27 * Allocates basic resources for this USB host controller.
29 * Store this function in the HCD's struct pci_driver as probe().
31 static int usb_hcd_ppc_soc_probe(const struct hc_driver *driver,
32 struct platform_device *pdev)
36 struct ohci_hcd *ohci;
40 pr_debug("initializing PPC-SOC USB Controller\n");
42 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
44 pr_debug(__FILE__ ": no irq\n");
49 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
51 pr_debug(__FILE__ ": no reg addr\n");
55 hcd = usb_create_hcd(driver, &pdev->dev, "PPC-SOC USB");
58 hcd->rsrc_start = res->start;
59 hcd->rsrc_len = res->end - res->start + 1;
61 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
62 pr_debug(__FILE__ ": request_mem_region failed\n");
67 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
69 pr_debug(__FILE__ ": ioremap failed\n");
74 ohci = hcd_to_ohci(hcd);
75 ohci->flags |= OHCI_BIG_ENDIAN;
78 retval = usb_add_hcd(hcd, irq, IRQF_DISABLED);
82 pr_debug("Removing PPC-SOC USB Controller\n");
86 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
93 /* may be called without controller electrically present */
94 /* may be called with controller, bus, and devices active */
97 * usb_hcd_ppc_soc_remove - shutdown processing for On-Chip HCDs
98 * @pdev: USB Host Controller being removed
99 * Context: !in_interrupt()
101 * Reverses the effect of usb_hcd_ppc_soc_probe().
102 * It is always called from a thread
103 * context, normally "rmmod", "apmd", or something similar.
106 static void usb_hcd_ppc_soc_remove(struct usb_hcd *hcd,
107 struct platform_device *pdev)
111 pr_debug("stopping PPC-SOC USB Controller\n");
114 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
119 ohci_ppc_soc_start(struct usb_hcd *hcd)
121 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
124 if ((ret = ohci_init(ohci)) < 0)
127 if ((ret = ohci_run(ohci)) < 0) {
128 err("can't start %s", ohci_to_hcd(ohci)->self.bus_name);
136 static const struct hc_driver ohci_ppc_soc_hc_driver = {
137 .description = hcd_name,
138 .hcd_priv_size = sizeof(struct ohci_hcd),
141 * generic hardware linkage
144 .flags = HCD_USB11 | HCD_MEMORY,
147 * basic lifecycle operations
149 .start = ohci_ppc_soc_start,
151 .shutdown = ohci_shutdown,
154 * managing i/o requests and associated device resources
156 .urb_enqueue = ohci_urb_enqueue,
157 .urb_dequeue = ohci_urb_dequeue,
158 .endpoint_disable = ohci_endpoint_disable,
163 .get_frame_number = ohci_get_frame,
168 .hub_status_data = ohci_hub_status_data,
169 .hub_control = ohci_hub_control,
170 .hub_irq_enable = ohci_rhsc_enable,
172 .bus_suspend = ohci_bus_suspend,
173 .bus_resume = ohci_bus_resume,
175 .start_port_reset = ohci_start_port_reset,
178 static int ohci_hcd_ppc_soc_drv_probe(struct platform_device *pdev)
185 ret = usb_hcd_ppc_soc_probe(&ohci_ppc_soc_hc_driver, pdev);
189 static int ohci_hcd_ppc_soc_drv_remove(struct platform_device *pdev)
191 struct usb_hcd *hcd = platform_get_drvdata(pdev);
193 usb_hcd_ppc_soc_remove(hcd, pdev);
197 static struct platform_driver ohci_hcd_ppc_soc_driver = {
198 .probe = ohci_hcd_ppc_soc_drv_probe,
199 .remove = ohci_hcd_ppc_soc_drv_remove,
200 .shutdown = usb_hcd_platform_shutdown,
202 /*.suspend = ohci_hcd_ppc_soc_drv_suspend,*/
203 /*.resume = ohci_hcd_ppc_soc_drv_resume,*/
206 .name = "ppc-soc-ohci",
207 .owner = THIS_MODULE,
211 static int __init ohci_hcd_ppc_soc_init(void)
213 pr_debug(DRIVER_INFO " (PPC SOC)\n");
214 pr_debug("block sizes: ed %d td %d\n", sizeof(struct ed),
217 return platform_driver_register(&ohci_hcd_ppc_soc_driver);
220 static void __exit ohci_hcd_ppc_soc_cleanup(void)
222 platform_driver_unregister(&ohci_hcd_ppc_soc_driver);
225 module_init(ohci_hcd_ppc_soc_init);
226 module_exit(ohci_hcd_ppc_soc_cleanup);