diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/usb/host/ohci-lh7a404.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'drivers/usb/host/ohci-lh7a404.c')
-rw-r--r-- | drivers/usb/host/ohci-lh7a404.c | 266 |
1 files changed, 266 insertions, 0 deletions
diff --git a/drivers/usb/host/ohci-lh7a404.c b/drivers/usb/host/ohci-lh7a404.c new file mode 100644 index 000000000000..817620d73841 --- /dev/null +++ b/drivers/usb/host/ohci-lh7a404.c | |||
@@ -0,0 +1,266 @@ | |||
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 | #include <asm/mach-types.h> | ||
21 | #include <asm/arch/hardware.h> | ||
22 | |||
23 | |||
24 | extern int usb_disabled(void); | ||
25 | |||
26 | /*-------------------------------------------------------------------------*/ | ||
27 | |||
28 | static void lh7a404_start_hc(struct platform_device *dev) | ||
29 | { | ||
30 | printk(KERN_DEBUG __FILE__ | ||
31 | ": starting LH7A404 OHCI USB Controller\n"); | ||
32 | |||
33 | /* | ||
34 | * Now, carefully enable the USB clock, and take | ||
35 | * the USB host controller out of reset. | ||
36 | */ | ||
37 | CSC_PWRCNT |= CSC_PWRCNT_USBH_EN; /* Enable clock */ | ||
38 | udelay(1000); | ||
39 | USBH_CMDSTATUS = OHCI_HCR; | ||
40 | |||
41 | printk(KERN_DEBUG __FILE__ | ||
42 | ": Clock to USB host has been enabled \n"); | ||
43 | } | ||
44 | |||
45 | static void lh7a404_stop_hc(struct platform_device *dev) | ||
46 | { | ||
47 | printk(KERN_DEBUG __FILE__ | ||
48 | ": stopping LH7A404 OHCI USB Controller\n"); | ||
49 | |||
50 | CSC_PWRCNT &= ~CSC_PWRCNT_USBH_EN; /* Disable clock */ | ||
51 | } | ||
52 | |||
53 | |||
54 | /*-------------------------------------------------------------------------*/ | ||
55 | |||
56 | /* configure so an HC device and id are always provided */ | ||
57 | /* always called with process context; sleeping is OK */ | ||
58 | |||
59 | |||
60 | /** | ||
61 | * usb_hcd_lh7a404_probe - initialize LH7A404-based HCDs | ||
62 | * Context: !in_interrupt() | ||
63 | * | ||
64 | * Allocates basic resources for this USB host controller, and | ||
65 | * then invokes the start() method for the HCD associated with it | ||
66 | * through the hotplug entry's driver_data. | ||
67 | * | ||
68 | */ | ||
69 | int usb_hcd_lh7a404_probe (const struct hc_driver *driver, | ||
70 | struct platform_device *dev) | ||
71 | { | ||
72 | int retval; | ||
73 | struct usb_hcd *hcd; | ||
74 | |||
75 | if (dev->resource[1].flags != IORESOURCE_IRQ) { | ||
76 | pr_debug("resource[1] is not IORESOURCE_IRQ"); | ||
77 | return -ENOMEM; | ||
78 | } | ||
79 | |||
80 | hcd = usb_create_hcd(driver, &dev->dev, "lh7a404"); | ||
81 | if (!hcd) | ||
82 | return -ENOMEM; | ||
83 | hcd->rsrc_start = dev->resource[0].start; | ||
84 | hcd->rsrc_len = dev->resource[0].end - dev->resource[0].start + 1; | ||
85 | |||
86 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | ||
87 | pr_debug("request_mem_region failed"); | ||
88 | retval = -EBUSY; | ||
89 | goto err1; | ||
90 | } | ||
91 | |||
92 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | ||
93 | if (!hcd->regs) { | ||
94 | pr_debug("ioremap failed"); | ||
95 | retval = -ENOMEM; | ||
96 | goto err2; | ||
97 | } | ||
98 | |||
99 | lh7a404_start_hc(dev); | ||
100 | ohci_hcd_init(hcd_to_ohci(hcd)); | ||
101 | |||
102 | retval = usb_add_hcd(hcd, dev->resource[1].start, SA_INTERRUPT); | ||
103 | if (retval == 0) | ||
104 | return retval; | ||
105 | |||
106 | lh7a404_stop_hc(dev); | ||
107 | iounmap(hcd->regs); | ||
108 | err2: | ||
109 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
110 | err1: | ||
111 | usb_put_hcd(hcd); | ||
112 | return retval; | ||
113 | } | ||
114 | |||
115 | |||
116 | /* may be called without controller electrically present */ | ||
117 | /* may be called with controller, bus, and devices active */ | ||
118 | |||
119 | /** | ||
120 | * usb_hcd_lh7a404_remove - shutdown processing for LH7A404-based HCDs | ||
121 | * @dev: USB Host Controller being removed | ||
122 | * Context: !in_interrupt() | ||
123 | * | ||
124 | * Reverses the effect of usb_hcd_lh7a404_probe(), first invoking | ||
125 | * the HCD's stop() method. It is always called from a thread | ||
126 | * context, normally "rmmod", "apmd", or something similar. | ||
127 | * | ||
128 | */ | ||
129 | void usb_hcd_lh7a404_remove (struct usb_hcd *hcd, struct platform_device *dev) | ||
130 | { | ||
131 | usb_remove_hcd(hcd); | ||
132 | lh7a404_stop_hc(dev); | ||
133 | iounmap(hcd->regs); | ||
134 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
135 | usb_put_hcd(hcd); | ||
136 | } | ||
137 | |||
138 | /*-------------------------------------------------------------------------*/ | ||
139 | |||
140 | static int __devinit | ||
141 | ohci_lh7a404_start (struct usb_hcd *hcd) | ||
142 | { | ||
143 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); | ||
144 | int ret; | ||
145 | |||
146 | ohci_dbg (ohci, "ohci_lh7a404_start, ohci:%p", ohci); | ||
147 | if ((ret = ohci_init(ohci)) < 0) | ||
148 | return ret; | ||
149 | |||
150 | if ((ret = ohci_run (ohci)) < 0) { | ||
151 | err ("can't start %s", hcd->self.bus_name); | ||
152 | ohci_stop (hcd); | ||
153 | return ret; | ||
154 | } | ||
155 | return 0; | ||
156 | } | ||
157 | |||
158 | /*-------------------------------------------------------------------------*/ | ||
159 | |||
160 | static const struct hc_driver ohci_lh7a404_hc_driver = { | ||
161 | .description = hcd_name, | ||
162 | .product_desc = "LH7A404 OHCI", | ||
163 | .hcd_priv_size = sizeof(struct ohci_hcd), | ||
164 | |||
165 | /* | ||
166 | * generic hardware linkage | ||
167 | */ | ||
168 | .irq = ohci_irq, | ||
169 | .flags = HCD_USB11 | HCD_MEMORY, | ||
170 | |||
171 | /* | ||
172 | * basic lifecycle operations | ||
173 | */ | ||
174 | .start = ohci_lh7a404_start, | ||
175 | #ifdef CONFIG_PM | ||
176 | /* suspend: ohci_lh7a404_suspend, -- tbd */ | ||
177 | /* resume: ohci_lh7a404_resume, -- tbd */ | ||
178 | #endif /*CONFIG_PM*/ | ||
179 | .stop = ohci_stop, | ||
180 | |||
181 | /* | ||
182 | * managing i/o requests and associated device resources | ||
183 | */ | ||
184 | .urb_enqueue = ohci_urb_enqueue, | ||
185 | .urb_dequeue = ohci_urb_dequeue, | ||
186 | .endpoint_disable = ohci_endpoint_disable, | ||
187 | |||
188 | /* | ||
189 | * scheduling support | ||
190 | */ | ||
191 | .get_frame_number = ohci_get_frame, | ||
192 | |||
193 | /* | ||
194 | * root hub support | ||
195 | */ | ||
196 | .hub_status_data = ohci_hub_status_data, | ||
197 | .hub_control = ohci_hub_control, | ||
198 | }; | ||
199 | |||
200 | /*-------------------------------------------------------------------------*/ | ||
201 | |||
202 | static int ohci_hcd_lh7a404_drv_probe(struct device *dev) | ||
203 | { | ||
204 | struct platform_device *pdev = to_platform_device(dev); | ||
205 | int ret; | ||
206 | |||
207 | pr_debug ("In ohci_hcd_lh7a404_drv_probe"); | ||
208 | |||
209 | if (usb_disabled()) | ||
210 | return -ENODEV; | ||
211 | |||
212 | ret = usb_hcd_lh7a404_probe(&ohci_lh7a404_hc_driver, pdev); | ||
213 | return ret; | ||
214 | } | ||
215 | |||
216 | static int ohci_hcd_lh7a404_drv_remove(struct device *dev) | ||
217 | { | ||
218 | struct platform_device *pdev = to_platform_device(dev); | ||
219 | struct usb_hcd *hcd = dev_get_drvdata(dev); | ||
220 | |||
221 | usb_hcd_lh7a404_remove(hcd, pdev); | ||
222 | return 0; | ||
223 | } | ||
224 | /*TBD*/ | ||
225 | /*static int ohci_hcd_lh7a404_drv_suspend(struct device *dev) | ||
226 | { | ||
227 | struct platform_device *pdev = to_platform_device(dev); | ||
228 | struct usb_hcd *hcd = dev_get_drvdata(dev); | ||
229 | |||
230 | return 0; | ||
231 | } | ||
232 | static int ohci_hcd_lh7a404_drv_resume(struct device *dev) | ||
233 | { | ||
234 | struct platform_device *pdev = to_platform_device(dev); | ||
235 | struct usb_hcd *hcd = dev_get_drvdata(dev); | ||
236 | |||
237 | |||
238 | return 0; | ||
239 | } | ||
240 | */ | ||
241 | |||
242 | static struct device_driver ohci_hcd_lh7a404_driver = { | ||
243 | .name = "lh7a404-ohci", | ||
244 | .bus = &platform_bus_type, | ||
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, */ | ||
249 | }; | ||
250 | |||
251 | static int __init ohci_hcd_lh7a404_init (void) | ||
252 | { | ||
253 | pr_debug (DRIVER_INFO " (LH7A404)"); | ||
254 | pr_debug ("block sizes: ed %d td %d\n", | ||
255 | sizeof (struct ed), sizeof (struct td)); | ||
256 | |||
257 | return driver_register(&ohci_hcd_lh7a404_driver); | ||
258 | } | ||
259 | |||
260 | static void __exit ohci_hcd_lh7a404_cleanup (void) | ||
261 | { | ||
262 | driver_unregister(&ohci_hcd_lh7a404_driver); | ||
263 | } | ||
264 | |||
265 | module_init (ohci_hcd_lh7a404_init); | ||
266 | module_exit (ohci_hcd_lh7a404_cleanup); | ||