[PATCH] DRIVER MODEL: Get rid of the obsolete tri-level suspend/resume callbacks
[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 };
197
198 /*-------------------------------------------------------------------------*/
199
200 static int ohci_hcd_lh7a404_drv_probe(struct device *dev)
201 {
202         struct platform_device *pdev = to_platform_device(dev);
203         int ret;
204
205         pr_debug ("In ohci_hcd_lh7a404_drv_probe");
206
207         if (usb_disabled())
208                 return -ENODEV;
209
210         ret = usb_hcd_lh7a404_probe(&ohci_lh7a404_hc_driver, pdev);
211         return ret;
212 }
213
214 static int ohci_hcd_lh7a404_drv_remove(struct device *dev)
215 {
216         struct platform_device *pdev = to_platform_device(dev);
217         struct usb_hcd *hcd = dev_get_drvdata(dev);
218
219         usb_hcd_lh7a404_remove(hcd, pdev);
220         return 0;
221 }
222         /*TBD*/
223 /*static int ohci_hcd_lh7a404_drv_suspend(struct device *dev)
224 {
225         struct platform_device *pdev = to_platform_device(dev);
226         struct usb_hcd *hcd = dev_get_drvdata(dev);
227
228         return 0;
229 }
230 static int ohci_hcd_lh7a404_drv_resume(struct device *dev)
231 {
232         struct platform_device *pdev = to_platform_device(dev);
233         struct usb_hcd *hcd = dev_get_drvdata(dev);
234
235
236         return 0;
237 }
238 */
239
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, */
247 };
248
249 static int __init ohci_hcd_lh7a404_init (void)
250 {
251         pr_debug (DRIVER_INFO " (LH7A404)");
252         pr_debug ("block sizes: ed %d td %d\n",
253                 sizeof (struct ed), sizeof (struct td));
254
255         return driver_register(&ohci_hcd_lh7a404_driver);
256 }
257
258 static void __exit ohci_hcd_lh7a404_cleanup (void)
259 {
260         driver_unregister(&ohci_hcd_lh7a404_driver);
261 }
262
263 module_init (ohci_hcd_lh7a404_init);
264 module_exit (ohci_hcd_lh7a404_cleanup);