[PATCH] USB: Rename hcd->hub_suspend to hcd->bus_suspend
[linux-2.6.git] / drivers / usb / host / ohci-lh7a404.c
1 /*
2  * OHCI HCD (Host Controller Driver) for USB.
3  *
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  *
8  * Bus Glue for Sharp LH7A404
9  *
10  * Written by Christopher Hoover <ch@hpl.hp.com>
11  * Based on fragments of previous driver by Rusell King et al.
12  *
13  * Modified for LH7A404 from ohci-sa1111.c
14  *  by Durgesh Pattamatta <pattamattad@sharpsec.com>
15  *
16  * This file is licenced under the GPL.
17  */
18
19 #include <asm/hardware.h>
20
21
22 extern int usb_disabled(void);
23
24 /*-------------------------------------------------------------------------*/
25
26 static void lh7a404_start_hc(struct platform_device *dev)
27 {
28         printk(KERN_DEBUG __FILE__
29                ": starting LH7A404 OHCI USB Controller\n");
30
31         /*
32          * Now, carefully enable the USB clock, and take
33          * the USB host controller out of reset.
34          */
35         CSC_PWRCNT |= CSC_PWRCNT_USBH_EN; /* Enable clock */
36         udelay(1000);
37         USBH_CMDSTATUS = OHCI_HCR;
38         
39         printk(KERN_DEBUG __FILE__
40                    ": Clock to USB host has been enabled \n");
41 }
42
43 static void lh7a404_stop_hc(struct platform_device *dev)
44 {
45         printk(KERN_DEBUG __FILE__
46                ": stopping LH7A404 OHCI USB Controller\n");
47
48         CSC_PWRCNT &= ~CSC_PWRCNT_USBH_EN; /* Disable clock */
49 }
50
51
52 /*-------------------------------------------------------------------------*/
53
54 /* configure so an HC device and id are always provided */
55 /* always called with process context; sleeping is OK */
56
57
58 /**
59  * usb_hcd_lh7a404_probe - initialize LH7A404-based HCDs
60  * Context: !in_interrupt()
61  *
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.
65  *
66  */
67 int usb_hcd_lh7a404_probe (const struct hc_driver *driver,
68                           struct platform_device *dev)
69 {
70         int retval;
71         struct usb_hcd *hcd;
72
73         if (dev->resource[1].flags != IORESOURCE_IRQ) {
74                 pr_debug("resource[1] is not IORESOURCE_IRQ");
75                 return -ENOMEM;
76         }
77
78         hcd = usb_create_hcd(driver, &dev->dev, "lh7a404");
79         if (!hcd)
80                 return -ENOMEM;
81         hcd->rsrc_start = dev->resource[0].start;
82         hcd->rsrc_len = dev->resource[0].end - dev->resource[0].start + 1;
83
84         if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
85                 pr_debug("request_mem_region failed");
86                 retval = -EBUSY;
87                 goto err1;
88         }
89         
90         hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
91         if (!hcd->regs) {
92                 pr_debug("ioremap failed");
93                 retval = -ENOMEM;
94                 goto err2;
95         }
96
97         lh7a404_start_hc(dev);
98         ohci_hcd_init(hcd_to_ohci(hcd));
99
100         retval = usb_add_hcd(hcd, dev->resource[1].start, SA_INTERRUPT);
101         if (retval == 0)
102                 return retval;
103
104         lh7a404_stop_hc(dev);
105         iounmap(hcd->regs);
106  err2:
107         release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
108  err1:
109         usb_put_hcd(hcd);
110         return retval;
111 }
112
113
114 /* may be called without controller electrically present */
115 /* may be called with controller, bus, and devices active */
116
117 /**
118  * usb_hcd_lh7a404_remove - shutdown processing for LH7A404-based HCDs
119  * @dev: USB Host Controller being removed
120  * Context: !in_interrupt()
121  *
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.
125  *
126  */
127 void usb_hcd_lh7a404_remove (struct usb_hcd *hcd, struct platform_device *dev)
128 {
129         usb_remove_hcd(hcd);
130         lh7a404_stop_hc(dev);
131         iounmap(hcd->regs);
132         release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
133         usb_put_hcd(hcd);
134 }
135
136 /*-------------------------------------------------------------------------*/
137
138 static int __devinit
139 ohci_lh7a404_start (struct usb_hcd *hcd)
140 {
141         struct ohci_hcd *ohci = hcd_to_ohci (hcd);
142         int             ret;
143
144         ohci_dbg (ohci, "ohci_lh7a404_start, ohci:%p", ohci);
145         if ((ret = ohci_init(ohci)) < 0)
146                 return ret;
147
148         if ((ret = ohci_run (ohci)) < 0) {
149                 err ("can't start %s", hcd->self.bus_name);
150                 ohci_stop (hcd);
151                 return ret;
152         }
153         return 0;
154 }
155
156 /*-------------------------------------------------------------------------*/
157
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),
162
163         /*
164          * generic hardware linkage
165          */
166         .irq =                  ohci_irq,
167         .flags =                HCD_USB11 | HCD_MEMORY,
168
169         /*
170          * basic lifecycle operations
171          */
172         .start =                ohci_lh7a404_start,
173 #ifdef  CONFIG_PM
174         /* suspend:             ohci_lh7a404_suspend,  -- tbd */
175         /* resume:              ohci_lh7a404_resume,   -- tbd */
176 #endif /*CONFIG_PM*/
177         .stop =                 ohci_stop,
178
179         /*
180          * managing i/o requests and associated device resources
181          */
182         .urb_enqueue =          ohci_urb_enqueue,
183         .urb_dequeue =          ohci_urb_dequeue,
184         .endpoint_disable =     ohci_endpoint_disable,
185
186         /*
187          * scheduling support
188          */
189         .get_frame_number =     ohci_get_frame,
190
191         /*
192          * root hub support
193          */
194         .hub_status_data =      ohci_hub_status_data,
195         .hub_control =          ohci_hub_control,
196 #ifdef  CONFIG_PM
197         .bus_suspend =          ohci_bus_suspend,
198         .bus_resume =           ohci_bus_resume,
199 #endif
200         .start_port_reset =     ohci_start_port_reset,
201 };
202
203 /*-------------------------------------------------------------------------*/
204
205 static int ohci_hcd_lh7a404_drv_probe(struct device *dev)
206 {
207         struct platform_device *pdev = to_platform_device(dev);
208         int ret;
209
210         pr_debug ("In ohci_hcd_lh7a404_drv_probe");
211
212         if (usb_disabled())
213                 return -ENODEV;
214
215         ret = usb_hcd_lh7a404_probe(&ohci_lh7a404_hc_driver, pdev);
216         return ret;
217 }
218
219 static int ohci_hcd_lh7a404_drv_remove(struct device *dev)
220 {
221         struct platform_device *pdev = to_platform_device(dev);
222         struct usb_hcd *hcd = dev_get_drvdata(dev);
223
224         usb_hcd_lh7a404_remove(hcd, pdev);
225         return 0;
226 }
227         /*TBD*/
228 /*static int ohci_hcd_lh7a404_drv_suspend(struct device *dev)
229 {
230         struct platform_device *pdev = to_platform_device(dev);
231         struct usb_hcd *hcd = dev_get_drvdata(dev);
232
233         return 0;
234 }
235 static int ohci_hcd_lh7a404_drv_resume(struct device *dev)
236 {
237         struct platform_device *pdev = to_platform_device(dev);
238         struct usb_hcd *hcd = dev_get_drvdata(dev);
239
240
241         return 0;
242 }
243 */
244
245 static struct device_driver ohci_hcd_lh7a404_driver = {
246         .name           = "lh7a404-ohci",
247         .bus            = &platform_bus_type,
248         .probe          = ohci_hcd_lh7a404_drv_probe,
249         .remove         = ohci_hcd_lh7a404_drv_remove,
250         /*.suspend      = ohci_hcd_lh7a404_drv_suspend, */
251         /*.resume       = ohci_hcd_lh7a404_drv_resume, */
252 };
253
254 static int __init ohci_hcd_lh7a404_init (void)
255 {
256         pr_debug (DRIVER_INFO " (LH7A404)");
257         pr_debug ("block sizes: ed %d td %d\n",
258                 sizeof (struct ed), sizeof (struct td));
259
260         return driver_register(&ohci_hcd_lh7a404_driver);
261 }
262
263 static void __exit ohci_hcd_lh7a404_cleanup (void)
264 {
265         driver_unregister(&ohci_hcd_lh7a404_driver);
266 }
267
268 module_init (ohci_hcd_lh7a404_init);
269 module_exit (ohci_hcd_lh7a404_cleanup);