diff options
author | Manjunath Goudar <manjunath.goudar@linaro.org> | 2013-09-21 07:08:44 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-09-26 14:35:02 -0400 |
commit | 30330b8fedba32e6bfeda8040311a11b84053c97 (patch) | |
tree | 8b42dcd4208bc69fb33e7bd7dfffaa517d3b7d66 /drivers/usb/host/ohci-nxp.c | |
parent | f23b71f3fe63b760a665406f453fa479ff90aad5 (diff) |
USB: OHCI: make ohci-nxp a separate driver
Separate the OHCI NXP host controller driver from ohci-hcd
host code so that it can be built as a separate driver module.
This work is part of enabling multi-platform kernels on ARM.
Many place function name and struct name started with usb,
current scenario replaced usb with ohci for proper naming.
Signed-off-by: Manjunath Goudar <manjunath.goudar@linaro.org>
Signed-off-by: Deepak Saxena <dsaxena@linaro.org>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/host/ohci-nxp.c')
-rw-r--r-- | drivers/usb/host/ohci-nxp.c | 123 |
1 files changed, 48 insertions, 75 deletions
diff --git a/drivers/usb/host/ohci-nxp.c b/drivers/usb/host/ohci-nxp.c index 7d7d507d54e8..9ab7e24ba65d 100644 --- a/drivers/usb/host/ohci-nxp.c +++ b/drivers/usb/host/ohci-nxp.c | |||
@@ -19,10 +19,19 @@ | |||
19 | * or implied. | 19 | * or implied. |
20 | */ | 20 | */ |
21 | #include <linux/clk.h> | 21 | #include <linux/clk.h> |
22 | #include <linux/platform_device.h> | 22 | #include <linux/dma-mapping.h> |
23 | #include <linux/io.h> | ||
23 | #include <linux/i2c.h> | 24 | #include <linux/i2c.h> |
25 | #include <linux/kernel.h> | ||
26 | #include <linux/module.h> | ||
24 | #include <linux/of.h> | 27 | #include <linux/of.h> |
28 | #include <linux/platform_device.h> | ||
25 | #include <linux/usb/isp1301.h> | 29 | #include <linux/usb/isp1301.h> |
30 | #include <linux/usb.h> | ||
31 | #include <linux/usb/hcd.h> | ||
32 | |||
33 | #include "ohci.h" | ||
34 | |||
26 | 35 | ||
27 | #include <mach/hardware.h> | 36 | #include <mach/hardware.h> |
28 | #include <asm/mach-types.h> | 37 | #include <asm/mach-types.h> |
@@ -57,6 +66,11 @@ | |||
57 | #define start_int_umask(irq) | 66 | #define start_int_umask(irq) |
58 | #endif | 67 | #endif |
59 | 68 | ||
69 | #define DRIVER_DESC "OHCI NXP driver" | ||
70 | |||
71 | static const char hcd_name[] = "ohci-nxp"; | ||
72 | static struct hc_driver __read_mostly ohci_nxp_hc_driver; | ||
73 | |||
60 | static struct i2c_client *isp1301_i2c_client; | 74 | static struct i2c_client *isp1301_i2c_client; |
61 | 75 | ||
62 | extern int usb_disabled(void); | 76 | extern int usb_disabled(void); |
@@ -132,14 +146,14 @@ static inline void isp1301_vbus_off(void) | |||
132 | OTG1_VBUS_DRV); | 146 | OTG1_VBUS_DRV); |
133 | } | 147 | } |
134 | 148 | ||
135 | static void nxp_start_hc(void) | 149 | static void ohci_nxp_start_hc(void) |
136 | { | 150 | { |
137 | unsigned long tmp = __raw_readl(USB_OTG_STAT_CONTROL) | HOST_EN; | 151 | unsigned long tmp = __raw_readl(USB_OTG_STAT_CONTROL) | HOST_EN; |
138 | __raw_writel(tmp, USB_OTG_STAT_CONTROL); | 152 | __raw_writel(tmp, USB_OTG_STAT_CONTROL); |
139 | isp1301_vbus_on(); | 153 | isp1301_vbus_on(); |
140 | } | 154 | } |
141 | 155 | ||
142 | static void nxp_stop_hc(void) | 156 | static void ohci_nxp_stop_hc(void) |
143 | { | 157 | { |
144 | unsigned long tmp; | 158 | unsigned long tmp; |
145 | isp1301_vbus_off(); | 159 | isp1301_vbus_off(); |
@@ -147,68 +161,9 @@ static void nxp_stop_hc(void) | |||
147 | __raw_writel(tmp, USB_OTG_STAT_CONTROL); | 161 | __raw_writel(tmp, USB_OTG_STAT_CONTROL); |
148 | } | 162 | } |
149 | 163 | ||
150 | static int ohci_nxp_start(struct usb_hcd *hcd) | 164 | static int ohci_hcd_nxp_probe(struct platform_device *pdev) |
151 | { | ||
152 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | ||
153 | int ret; | ||
154 | |||
155 | if ((ret = ohci_init(ohci)) < 0) | ||
156 | return ret; | ||
157 | |||
158 | if ((ret = ohci_run(ohci)) < 0) { | ||
159 | dev_err(hcd->self.controller, "can't start\n"); | ||
160 | ohci_stop(hcd); | ||
161 | return ret; | ||
162 | } | ||
163 | return 0; | ||
164 | } | ||
165 | |||
166 | static const struct hc_driver ohci_nxp_hc_driver = { | ||
167 | .description = hcd_name, | ||
168 | .product_desc = "nxp OHCI", | ||
169 | |||
170 | /* | ||
171 | * generic hardware linkage | ||
172 | */ | ||
173 | .irq = ohci_irq, | ||
174 | .flags = HCD_USB11 | HCD_MEMORY, | ||
175 | |||
176 | .hcd_priv_size = sizeof(struct ohci_hcd), | ||
177 | /* | ||
178 | * basic lifecycle operations | ||
179 | */ | ||
180 | .start = ohci_nxp_start, | ||
181 | .stop = ohci_stop, | ||
182 | .shutdown = ohci_shutdown, | ||
183 | |||
184 | /* | ||
185 | * managing i/o requests and associated device resources | ||
186 | */ | ||
187 | .urb_enqueue = ohci_urb_enqueue, | ||
188 | .urb_dequeue = ohci_urb_dequeue, | ||
189 | .endpoint_disable = ohci_endpoint_disable, | ||
190 | |||
191 | /* | ||
192 | * scheduling support | ||
193 | */ | ||
194 | .get_frame_number = ohci_get_frame, | ||
195 | |||
196 | /* | ||
197 | * root hub support | ||
198 | */ | ||
199 | .hub_status_data = ohci_hub_status_data, | ||
200 | .hub_control = ohci_hub_control, | ||
201 | #ifdef CONFIG_PM | ||
202 | .bus_suspend = ohci_bus_suspend, | ||
203 | .bus_resume = ohci_bus_resume, | ||
204 | #endif | ||
205 | .start_port_reset = ohci_start_port_reset, | ||
206 | }; | ||
207 | |||
208 | static int usb_hcd_nxp_probe(struct platform_device *pdev) | ||
209 | { | 165 | { |
210 | struct usb_hcd *hcd = 0; | 166 | struct usb_hcd *hcd = 0; |
211 | struct ohci_hcd *ohci; | ||
212 | const struct hc_driver *driver = &ohci_nxp_hc_driver; | 167 | const struct hc_driver *driver = &ohci_nxp_hc_driver; |
213 | struct resource *res; | 168 | struct resource *res; |
214 | int ret = 0, irq; | 169 | int ret = 0, irq; |
@@ -313,17 +268,15 @@ static int usb_hcd_nxp_probe(struct platform_device *pdev) | |||
313 | goto fail_resource; | 268 | goto fail_resource; |
314 | } | 269 | } |
315 | 270 | ||
316 | nxp_start_hc(); | 271 | ohci_nxp_start_hc(); |
317 | platform_set_drvdata(pdev, hcd); | 272 | platform_set_drvdata(pdev, hcd); |
318 | ohci = hcd_to_ohci(hcd); | ||
319 | ohci_hcd_init(ohci); | ||
320 | 273 | ||
321 | dev_info(&pdev->dev, "at 0x%p, irq %d\n", hcd->regs, hcd->irq); | 274 | dev_info(&pdev->dev, "at 0x%p, irq %d\n", hcd->regs, hcd->irq); |
322 | ret = usb_add_hcd(hcd, irq, 0); | 275 | ret = usb_add_hcd(hcd, irq, 0); |
323 | if (ret == 0) | 276 | if (ret == 0) |
324 | return ret; | 277 | return ret; |
325 | 278 | ||
326 | nxp_stop_hc(); | 279 | ohci_nxp_stop_hc(); |
327 | fail_resource: | 280 | fail_resource: |
328 | usb_put_hcd(hcd); | 281 | usb_put_hcd(hcd); |
329 | fail_hcd: | 282 | fail_hcd: |
@@ -345,12 +298,12 @@ fail_disable: | |||
345 | return ret; | 298 | return ret; |
346 | } | 299 | } |
347 | 300 | ||
348 | static int usb_hcd_nxp_remove(struct platform_device *pdev) | 301 | static int ohci_hcd_nxp_remove(struct platform_device *pdev) |
349 | { | 302 | { |
350 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | 303 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
351 | 304 | ||
352 | usb_remove_hcd(hcd); | 305 | usb_remove_hcd(hcd); |
353 | nxp_stop_hc(); | 306 | ohci_nxp_stop_hc(); |
354 | usb_put_hcd(hcd); | 307 | usb_put_hcd(hcd); |
355 | clk_disable(usb_pll_clk); | 308 | clk_disable(usb_pll_clk); |
356 | clk_put(usb_pll_clk); | 309 | clk_put(usb_pll_clk); |
@@ -366,20 +319,40 @@ static int usb_hcd_nxp_remove(struct platform_device *pdev) | |||
366 | MODULE_ALIAS("platform:usb-ohci"); | 319 | MODULE_ALIAS("platform:usb-ohci"); |
367 | 320 | ||
368 | #ifdef CONFIG_OF | 321 | #ifdef CONFIG_OF |
369 | static const struct of_device_id usb_hcd_nxp_match[] = { | 322 | static const struct of_device_id ohci_hcd_nxp_match[] = { |
370 | { .compatible = "nxp,ohci-nxp" }, | 323 | { .compatible = "nxp,ohci-nxp" }, |
371 | {}, | 324 | {}, |
372 | }; | 325 | }; |
373 | MODULE_DEVICE_TABLE(of, usb_hcd_nxp_match); | 326 | MODULE_DEVICE_TABLE(of, ohci_hcd_nxp_match); |
374 | #endif | 327 | #endif |
375 | 328 | ||
376 | static struct platform_driver usb_hcd_nxp_driver = { | 329 | static struct platform_driver ohci_hcd_nxp_driver = { |
377 | .driver = { | 330 | .driver = { |
378 | .name = "usb-ohci", | 331 | .name = "usb-ohci", |
379 | .owner = THIS_MODULE, | 332 | .owner = THIS_MODULE, |
380 | .of_match_table = of_match_ptr(usb_hcd_nxp_match), | 333 | .of_match_table = of_match_ptr(ohci_hcd_nxp_match), |
381 | }, | 334 | }, |
382 | .probe = usb_hcd_nxp_probe, | 335 | .probe = ohci_hcd_nxp_probe, |
383 | .remove = usb_hcd_nxp_remove, | 336 | .remove = ohci_hcd_nxp_remove, |
384 | }; | 337 | }; |
385 | 338 | ||
339 | static int __init ohci_nxp_init(void) | ||
340 | { | ||
341 | if (usb_disabled()) | ||
342 | return -ENODEV; | ||
343 | |||
344 | pr_info("%s: " DRIVER_DESC "\n", hcd_name); | ||
345 | |||
346 | ohci_init_driver(&ohci_nxp_hc_driver, NULL); | ||
347 | return platform_driver_register(&ohci_hcd_nxp_driver); | ||
348 | } | ||
349 | module_init(ohci_nxp_init); | ||
350 | |||
351 | static void __exit ohci_nxp_cleanup(void) | ||
352 | { | ||
353 | platform_driver_unregister(&ohci_hcd_nxp_driver); | ||
354 | } | ||
355 | module_exit(ohci_nxp_cleanup); | ||
356 | |||
357 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
358 | MODULE_LICENSE("GPL v2"); | ||