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
8 * Bus Glue for Sharp LH7A404
10 * Written by Christopher Hoover <ch@hpl.hp.com>
11 * Based on fragments of previous driver by Rusell King et al.
13 * Modified for LH7A404 from ohci-sa1111.c
14 * by Durgesh Pattamatta <pattamattad@sharpsec.com>
16 * This file is licenced under the GPL.
19 #include <linux/platform_device.h>
20 #include <linux/signal.h>
22 #include <asm/hardware.h>
25 extern int usb_disabled(void);
27 /*-------------------------------------------------------------------------*/
29 static void lh7a404_start_hc(struct platform_device *dev)
31 printk(KERN_DEBUG __FILE__
32 ": starting LH7A404 OHCI USB Controller\n");
35 * Now, carefully enable the USB clock, and take
36 * the USB host controller out of reset.
38 CSC_PWRCNT |= CSC_PWRCNT_USBH_EN; /* Enable clock */
40 USBH_CMDSTATUS = OHCI_HCR;
42 printk(KERN_DEBUG __FILE__
43 ": Clock to USB host has been enabled \n");
46 static void lh7a404_stop_hc(struct platform_device *dev)
48 printk(KERN_DEBUG __FILE__
49 ": stopping LH7A404 OHCI USB Controller\n");
51 CSC_PWRCNT &= ~CSC_PWRCNT_USBH_EN; /* Disable clock */
55 /*-------------------------------------------------------------------------*/
57 /* configure so an HC device and id are always provided */
58 /* always called with process context; sleeping is OK */
62 * usb_hcd_lh7a404_probe - initialize LH7A404-based HCDs
63 * Context: !in_interrupt()
65 * Allocates basic resources for this USB host controller, and
66 * then invokes the start() method for the HCD associated with it
67 * through the hotplug entry's driver_data.
70 int usb_hcd_lh7a404_probe (const struct hc_driver *driver,
71 struct platform_device *dev)
76 if (dev->resource[1].flags != IORESOURCE_IRQ) {
77 pr_debug("resource[1] is not IORESOURCE_IRQ");
81 hcd = usb_create_hcd(driver, &dev->dev, "lh7a404");
84 hcd->rsrc_start = dev->resource[0].start;
85 hcd->rsrc_len = dev->resource[0].end - dev->resource[0].start + 1;
87 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
88 pr_debug("request_mem_region failed");
93 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
95 pr_debug("ioremap failed");
100 lh7a404_start_hc(dev);
101 ohci_hcd_init(hcd_to_ohci(hcd));
103 retval = usb_add_hcd(hcd, dev->resource[1].start, IRQF_DISABLED);
107 lh7a404_stop_hc(dev);
110 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
117 /* may be called without controller electrically present */
118 /* may be called with controller, bus, and devices active */
121 * usb_hcd_lh7a404_remove - shutdown processing for LH7A404-based HCDs
122 * @dev: USB Host Controller being removed
123 * Context: !in_interrupt()
125 * Reverses the effect of usb_hcd_lh7a404_probe(), first invoking
126 * the HCD's stop() method. It is always called from a thread
127 * context, normally "rmmod", "apmd", or something similar.
130 void usb_hcd_lh7a404_remove (struct usb_hcd *hcd, struct platform_device *dev)
133 lh7a404_stop_hc(dev);
135 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
139 /*-------------------------------------------------------------------------*/
142 ohci_lh7a404_start (struct usb_hcd *hcd)
144 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
147 ohci_dbg (ohci, "ohci_lh7a404_start, ohci:%p", ohci);
148 if ((ret = ohci_init(ohci)) < 0)
151 if ((ret = ohci_run (ohci)) < 0) {
152 err ("can't start %s", hcd->self.bus_name);
159 /*-------------------------------------------------------------------------*/
161 static const struct hc_driver ohci_lh7a404_hc_driver = {
162 .description = hcd_name,
163 .product_desc = "LH7A404 OHCI",
164 .hcd_priv_size = sizeof(struct ohci_hcd),
167 * generic hardware linkage
170 .flags = HCD_USB11 | HCD_MEMORY,
173 * basic lifecycle operations
175 .start = ohci_lh7a404_start,
177 /* suspend: ohci_lh7a404_suspend, -- tbd */
178 /* resume: ohci_lh7a404_resume, -- tbd */
183 * managing i/o requests and associated device resources
185 .urb_enqueue = ohci_urb_enqueue,
186 .urb_dequeue = ohci_urb_dequeue,
187 .endpoint_disable = ohci_endpoint_disable,
192 .get_frame_number = ohci_get_frame,
197 .hub_status_data = ohci_hub_status_data,
198 .hub_control = ohci_hub_control,
200 .bus_suspend = ohci_bus_suspend,
201 .bus_resume = ohci_bus_resume,
203 .start_port_reset = ohci_start_port_reset,
206 /*-------------------------------------------------------------------------*/
208 static int ohci_hcd_lh7a404_drv_probe(struct platform_device *pdev)
212 pr_debug ("In ohci_hcd_lh7a404_drv_probe");
217 ret = usb_hcd_lh7a404_probe(&ohci_lh7a404_hc_driver, pdev);
221 static int ohci_hcd_lh7a404_drv_remove(struct platform_device *pdev)
223 struct usb_hcd *hcd = platform_get_drvdata(pdev);
225 usb_hcd_lh7a404_remove(hcd, pdev);
229 /*static int ohci_hcd_lh7a404_drv_suspend(struct platform_device *dev)
231 struct usb_hcd *hcd = platform_get_drvdata(dev);
235 static int ohci_hcd_lh7a404_drv_resume(struct platform_device *dev)
237 struct usb_hcd *hcd = platform_get_drvdata(dev);
244 static struct platform_driver ohci_hcd_lh7a404_driver = {
245 .probe = ohci_hcd_lh7a404_drv_probe,
246 .remove = ohci_hcd_lh7a404_drv_remove,
247 /*.suspend = ohci_hcd_lh7a404_drv_suspend, */
248 /*.resume = ohci_hcd_lh7a404_drv_resume, */
250 .name = "lh7a404-ohci",
251 .owner = THIS_MODULE,
255 static int __init ohci_hcd_lh7a404_init (void)
257 pr_debug (DRIVER_INFO " (LH7A404)");
258 pr_debug ("block sizes: ed %d td %d\n",
259 sizeof (struct ed), sizeof (struct td));
261 return platform_driver_register(&ohci_hcd_lh7a404_driver);
264 static void __exit ohci_hcd_lh7a404_cleanup (void)
266 platform_driver_unregister(&ohci_hcd_lh7a404_driver);
269 module_init (ohci_hcd_lh7a404_init);
270 module_exit (ohci_hcd_lh7a404_cleanup);