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 <asm/hardware.h>
22 extern int usb_disabled(void);
24 /*-------------------------------------------------------------------------*/
26 static void lh7a404_start_hc(struct platform_device *dev)
28 printk(KERN_DEBUG __FILE__
29 ": starting LH7A404 OHCI USB Controller\n");
32 * Now, carefully enable the USB clock, and take
33 * the USB host controller out of reset.
35 CSC_PWRCNT |= CSC_PWRCNT_USBH_EN; /* Enable clock */
37 USBH_CMDSTATUS = OHCI_HCR;
39 printk(KERN_DEBUG __FILE__
40 ": Clock to USB host has been enabled \n");
43 static void lh7a404_stop_hc(struct platform_device *dev)
45 printk(KERN_DEBUG __FILE__
46 ": stopping LH7A404 OHCI USB Controller\n");
48 CSC_PWRCNT &= ~CSC_PWRCNT_USBH_EN; /* Disable clock */
52 /*-------------------------------------------------------------------------*/
54 /* configure so an HC device and id are always provided */
55 /* always called with process context; sleeping is OK */
59 * usb_hcd_lh7a404_probe - initialize LH7A404-based HCDs
60 * Context: !in_interrupt()
62 * Allocates basic resources for this USB host controller, and
63 * then invokes the start() method for the HCD associated with it
64 * through the hotplug entry's driver_data.
67 int usb_hcd_lh7a404_probe (const struct hc_driver *driver,
68 struct platform_device *dev)
73 if (dev->resource[1].flags != IORESOURCE_IRQ) {
74 pr_debug("resource[1] is not IORESOURCE_IRQ");
78 hcd = usb_create_hcd(driver, &dev->dev, "lh7a404");
81 hcd->rsrc_start = dev->resource[0].start;
82 hcd->rsrc_len = dev->resource[0].end - dev->resource[0].start + 1;
84 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
85 pr_debug("request_mem_region failed");
90 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
92 pr_debug("ioremap failed");
97 lh7a404_start_hc(dev);
98 ohci_hcd_init(hcd_to_ohci(hcd));
100 retval = usb_add_hcd(hcd, dev->resource[1].start, SA_INTERRUPT);
104 lh7a404_stop_hc(dev);
107 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
114 /* may be called without controller electrically present */
115 /* may be called with controller, bus, and devices active */
118 * usb_hcd_lh7a404_remove - shutdown processing for LH7A404-based HCDs
119 * @dev: USB Host Controller being removed
120 * Context: !in_interrupt()
122 * Reverses the effect of usb_hcd_lh7a404_probe(), first invoking
123 * the HCD's stop() method. It is always called from a thread
124 * context, normally "rmmod", "apmd", or something similar.
127 void usb_hcd_lh7a404_remove (struct usb_hcd *hcd, struct platform_device *dev)
130 lh7a404_stop_hc(dev);
132 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
136 /*-------------------------------------------------------------------------*/
139 ohci_lh7a404_start (struct usb_hcd *hcd)
141 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
144 ohci_dbg (ohci, "ohci_lh7a404_start, ohci:%p", ohci);
145 if ((ret = ohci_init(ohci)) < 0)
148 if ((ret = ohci_run (ohci)) < 0) {
149 err ("can't start %s", hcd->self.bus_name);
156 /*-------------------------------------------------------------------------*/
158 static const struct hc_driver ohci_lh7a404_hc_driver = {
159 .description = hcd_name,
160 .product_desc = "LH7A404 OHCI",
161 .hcd_priv_size = sizeof(struct ohci_hcd),
164 * generic hardware linkage
167 .flags = HCD_USB11 | HCD_MEMORY,
170 * basic lifecycle operations
172 .start = ohci_lh7a404_start,
174 /* suspend: ohci_lh7a404_suspend, -- tbd */
175 /* resume: ohci_lh7a404_resume, -- tbd */
180 * managing i/o requests and associated device resources
182 .urb_enqueue = ohci_urb_enqueue,
183 .urb_dequeue = ohci_urb_dequeue,
184 .endpoint_disable = ohci_endpoint_disable,
189 .get_frame_number = ohci_get_frame,
194 .hub_status_data = ohci_hub_status_data,
195 .hub_control = ohci_hub_control,
198 /*-------------------------------------------------------------------------*/
200 static int ohci_hcd_lh7a404_drv_probe(struct device *dev)
202 struct platform_device *pdev = to_platform_device(dev);
205 pr_debug ("In ohci_hcd_lh7a404_drv_probe");
210 ret = usb_hcd_lh7a404_probe(&ohci_lh7a404_hc_driver, pdev);
214 static int ohci_hcd_lh7a404_drv_remove(struct device *dev)
216 struct platform_device *pdev = to_platform_device(dev);
217 struct usb_hcd *hcd = dev_get_drvdata(dev);
219 usb_hcd_lh7a404_remove(hcd, pdev);
223 /*static int ohci_hcd_lh7a404_drv_suspend(struct device *dev)
225 struct platform_device *pdev = to_platform_device(dev);
226 struct usb_hcd *hcd = dev_get_drvdata(dev);
230 static int ohci_hcd_lh7a404_drv_resume(struct device *dev)
232 struct platform_device *pdev = to_platform_device(dev);
233 struct usb_hcd *hcd = dev_get_drvdata(dev);
240 static struct device_driver ohci_hcd_lh7a404_driver = {
241 .name = "lh7a404-ohci",
242 .bus = &platform_bus_type,
243 .probe = ohci_hcd_lh7a404_drv_probe,
244 .remove = ohci_hcd_lh7a404_drv_remove,
245 /*.suspend = ohci_hcd_lh7a404_drv_suspend, */
246 /*.resume = ohci_hcd_lh7a404_drv_resume, */
249 static int __init ohci_hcd_lh7a404_init (void)
251 pr_debug (DRIVER_INFO " (LH7A404)");
252 pr_debug ("block sizes: ed %d td %d\n",
253 sizeof (struct ed), sizeof (struct td));
255 return driver_register(&ohci_hcd_lh7a404_driver);
258 static void __exit ohci_hcd_lh7a404_cleanup (void)
260 driver_unregister(&ohci_hcd_lh7a404_driver);
263 module_init (ohci_hcd_lh7a404_init);
264 module_exit (ohci_hcd_lh7a404_cleanup);