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
,
197 .bus_suspend
= ohci_bus_suspend
,
198 .bus_resume
= ohci_bus_resume
,
200 .start_port_reset
= ohci_start_port_reset
,
203 /*-------------------------------------------------------------------------*/
205 static int ohci_hcd_lh7a404_drv_probe(struct device
*dev
)
207 struct platform_device
*pdev
= to_platform_device(dev
);
210 pr_debug ("In ohci_hcd_lh7a404_drv_probe");
215 ret
= usb_hcd_lh7a404_probe(&ohci_lh7a404_hc_driver
, pdev
);
219 static int ohci_hcd_lh7a404_drv_remove(struct device
*dev
)
221 struct platform_device
*pdev
= to_platform_device(dev
);
222 struct usb_hcd
*hcd
= dev_get_drvdata(dev
);
224 usb_hcd_lh7a404_remove(hcd
, pdev
);
228 /*static int ohci_hcd_lh7a404_drv_suspend(struct device *dev)
230 struct platform_device *pdev = to_platform_device(dev);
231 struct usb_hcd *hcd = dev_get_drvdata(dev);
235 static int ohci_hcd_lh7a404_drv_resume(struct device *dev)
237 struct platform_device *pdev = to_platform_device(dev);
238 struct usb_hcd *hcd = dev_get_drvdata(dev);
245 static struct device_driver ohci_hcd_lh7a404_driver
= {
246 .name
= "lh7a404-ohci",
247 .owner
= THIS_MODULE
,
248 .bus
= &platform_bus_type
,
249 .probe
= ohci_hcd_lh7a404_drv_probe
,
250 .remove
= ohci_hcd_lh7a404_drv_remove
,
251 /*.suspend = ohci_hcd_lh7a404_drv_suspend, */
252 /*.resume = ohci_hcd_lh7a404_drv_resume, */
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 driver_register(&ohci_hcd_lh7a404_driver
);
264 static void __exit
ohci_hcd_lh7a404_cleanup (void)
266 driver_unregister(&ohci_hcd_lh7a404_driver
);
269 module_init (ohci_hcd_lh7a404_init
);
270 module_exit (ohci_hcd_lh7a404_cleanup
);