diff options
author | Manjunath Goudar <manjunath.goudar@linaro.org> | 2013-05-28 09:04:51 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-05-30 08:36:03 -0400 |
commit | c1117afb85890adf4073c7ff18ebcb4d0495e6af (patch) | |
tree | 23a60868cdf7ccde10b1df37eee73fd71fc986a5 | |
parent | 2621d0119e574f12496c4ab731265d5777cb6a18 (diff) |
USB: OHCI: make ohci-pci a separate driver
This patch splits the PCI portion of ohci-hcd out into its
own separate driver module, called ohci-pci.
The major point of difficulty lies in ohci-pci's many vendor- and
device-specific workarounds. Some of them have to be applied before
calling ohci_start() some after, which necessitates a fair amount of
code motion. The other platform drivers require much smaller changes.
The complete sb800_prefetch() function moved to ohci-q.c,because its
only related to ohci-pci driver.
USB_OHCI_HCD_PCI symbol no longer dependence on STB03xxx, PPC_MPC52xx and
USB_OHCI_HCD_PPC_OF that's what removed.
V2:
- few specific content of pci related code in ohci_pci_start function has been moved to ohci_pci_reset
and rest of the generic code is written in ohci_start of ohci-hcd.c file.
V3:
- ohci_restart() has been called in ohci_pci_reset() function for to reset the ohci pci.
V4:
-sb800_prefetch() moved to ohci-q.c,because its only related to ohci-pci.
-no longer _creating_ CONFIG_USB_OHCI_PCI,creating CONFIG_USB_OHCI_HCD_PCI.
-overrides renamed with pci_override,its giving proper meaning.
V5:
-sb800_prefetch() moved to pci-quirks.c,because its only related to pci.
V6:
-sb800_prefetch() function has been moved to pci-quirks.c made as separate patch in 2/3.
-Most of the generic ohci pci changes moved in 2/3 patch,now this is complete ohci-pci separation patch.
V7:
-Unrelated include file has been removed from ohci.h file.
V8:
-USB_OHCI_HCD_PCI symbol does not dependence on STB03xxx, PPC_MPC52xx and USB_OHCI_HCD_PPC_OF.
Signed-off-by: Manjunath Goudar <manjunath.goudar@linaro.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/usb/host/Kconfig | 6 | ||||
-rw-r--r-- | drivers/usb/host/Makefile | 3 | ||||
-rw-r--r-- | drivers/usb/host/ohci-hcd.c | 20 | ||||
-rw-r--r-- | drivers/usb/host/ohci-pci.c | 131 |
4 files changed, 52 insertions, 108 deletions
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 77aeb0de98e1..972ddd39c1de 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig | |||
@@ -357,7 +357,7 @@ config USB_FUSBH200_HCD | |||
357 | module will be called fusbh200-hcd. | 357 | module will be called fusbh200-hcd. |
358 | 358 | ||
359 | config USB_OHCI_HCD | 359 | config USB_OHCI_HCD |
360 | tristate "OHCI HCD support" | 360 | tristate "OHCI HCD (USB 1.1) support" |
361 | depends on USB_ARCH_HAS_OHCI | 361 | depends on USB_ARCH_HAS_OHCI |
362 | select ISP1301_OMAP if MACH_OMAP_H2 || MACH_OMAP_H3 | 362 | select ISP1301_OMAP if MACH_OMAP_H2 || MACH_OMAP_H3 |
363 | depends on USB_ISP1301 || !ARCH_LPC32XX | 363 | depends on USB_ISP1301 || !ARCH_LPC32XX |
@@ -426,8 +426,8 @@ config USB_OHCI_HCD_PPC_OF | |||
426 | default USB_OHCI_HCD_PPC_OF_BE || USB_OHCI_HCD_PPC_OF_LE | 426 | default USB_OHCI_HCD_PPC_OF_BE || USB_OHCI_HCD_PPC_OF_LE |
427 | 427 | ||
428 | config USB_OHCI_HCD_PCI | 428 | config USB_OHCI_HCD_PCI |
429 | bool "OHCI support for PCI-bus USB controllers" | 429 | tristate "OHCI support for PCI-bus USB controllers" |
430 | depends on PCI && (STB03xxx || PPC_MPC52xx || USB_OHCI_HCD_PPC_OF) | 430 | depends on PCI |
431 | default y | 431 | default y |
432 | select USB_OHCI_LITTLE_ENDIAN | 432 | select USB_OHCI_LITTLE_ENDIAN |
433 | ---help--- | 433 | ---help--- |
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index 58b7ae87efae..dbc785d6b4a1 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile | |||
@@ -37,7 +37,10 @@ obj-$(CONFIG_USB_EHCI_MSM) += ehci-msm.o | |||
37 | obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o | 37 | obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o |
38 | obj-$(CONFIG_USB_ISP116X_HCD) += isp116x-hcd.o | 38 | obj-$(CONFIG_USB_ISP116X_HCD) += isp116x-hcd.o |
39 | obj-$(CONFIG_USB_ISP1362_HCD) += isp1362-hcd.o | 39 | obj-$(CONFIG_USB_ISP1362_HCD) += isp1362-hcd.o |
40 | |||
40 | obj-$(CONFIG_USB_OHCI_HCD) += ohci-hcd.o | 41 | obj-$(CONFIG_USB_OHCI_HCD) += ohci-hcd.o |
42 | obj-$(CONFIG_USB_OHCI_HCD_PCI) += ohci-pci.o | ||
43 | |||
41 | obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o | 44 | obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o |
42 | obj-$(CONFIG_USB_FHCI_HCD) += fhci.o | 45 | obj-$(CONFIG_USB_FHCI_HCD) += fhci.o |
43 | obj-$(CONFIG_USB_XHCI_HCD) += xhci-hcd.o | 46 | obj-$(CONFIG_USB_XHCI_HCD) += xhci-hcd.o |
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 93d2f3edd19d..52959a1f0708 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c | |||
@@ -1172,11 +1172,6 @@ MODULE_AUTHOR (DRIVER_AUTHOR); | |||
1172 | MODULE_DESCRIPTION(DRIVER_DESC); | 1172 | MODULE_DESCRIPTION(DRIVER_DESC); |
1173 | MODULE_LICENSE ("GPL"); | 1173 | MODULE_LICENSE ("GPL"); |
1174 | 1174 | ||
1175 | #ifdef CONFIG_PCI | ||
1176 | #include "ohci-pci.c" | ||
1177 | #define PCI_DRIVER ohci_pci_driver | ||
1178 | #endif | ||
1179 | |||
1180 | #if defined(CONFIG_ARCH_SA1100) && defined(CONFIG_SA1111) | 1175 | #if defined(CONFIG_ARCH_SA1100) && defined(CONFIG_SA1111) |
1181 | #include "ohci-sa1111.c" | 1176 | #include "ohci-sa1111.c" |
1182 | #define SA1111_DRIVER ohci_hcd_sa1111_driver | 1177 | #define SA1111_DRIVER ohci_hcd_sa1111_driver |
@@ -1272,7 +1267,7 @@ MODULE_LICENSE ("GPL"); | |||
1272 | #define PLATFORM_DRIVER ohci_platform_driver | 1267 | #define PLATFORM_DRIVER ohci_platform_driver |
1273 | #endif | 1268 | #endif |
1274 | 1269 | ||
1275 | #if !defined(PCI_DRIVER) && \ | 1270 | #if !IS_ENABLED(CONFIG_USB_OHCI_HCD_PCI) && \ |
1276 | !defined(PLATFORM_DRIVER) && \ | 1271 | !defined(PLATFORM_DRIVER) && \ |
1277 | !defined(OMAP1_PLATFORM_DRIVER) && \ | 1272 | !defined(OMAP1_PLATFORM_DRIVER) && \ |
1278 | !defined(OMAP3_PLATFORM_DRIVER) && \ | 1273 | !defined(OMAP3_PLATFORM_DRIVER) && \ |
@@ -1347,12 +1342,6 @@ static int __init ohci_hcd_mod_init(void) | |||
1347 | goto error_sa1111; | 1342 | goto error_sa1111; |
1348 | #endif | 1343 | #endif |
1349 | 1344 | ||
1350 | #ifdef PCI_DRIVER | ||
1351 | retval = pci_register_driver(&PCI_DRIVER); | ||
1352 | if (retval < 0) | ||
1353 | goto error_pci; | ||
1354 | #endif | ||
1355 | |||
1356 | #ifdef SM501_OHCI_DRIVER | 1345 | #ifdef SM501_OHCI_DRIVER |
1357 | retval = platform_driver_register(&SM501_OHCI_DRIVER); | 1346 | retval = platform_driver_register(&SM501_OHCI_DRIVER); |
1358 | if (retval < 0) | 1347 | if (retval < 0) |
@@ -1446,10 +1435,6 @@ static int __init ohci_hcd_mod_init(void) | |||
1446 | platform_driver_unregister(&SM501_OHCI_DRIVER); | 1435 | platform_driver_unregister(&SM501_OHCI_DRIVER); |
1447 | error_sm501: | 1436 | error_sm501: |
1448 | #endif | 1437 | #endif |
1449 | #ifdef PCI_DRIVER | ||
1450 | pci_unregister_driver(&PCI_DRIVER); | ||
1451 | error_pci: | ||
1452 | #endif | ||
1453 | #ifdef SA1111_DRIVER | 1438 | #ifdef SA1111_DRIVER |
1454 | sa1111_driver_unregister(&SA1111_DRIVER); | 1439 | sa1111_driver_unregister(&SA1111_DRIVER); |
1455 | error_sa1111: | 1440 | error_sa1111: |
@@ -1514,9 +1499,6 @@ static void __exit ohci_hcd_mod_exit(void) | |||
1514 | #ifdef SM501_OHCI_DRIVER | 1499 | #ifdef SM501_OHCI_DRIVER |
1515 | platform_driver_unregister(&SM501_OHCI_DRIVER); | 1500 | platform_driver_unregister(&SM501_OHCI_DRIVER); |
1516 | #endif | 1501 | #endif |
1517 | #ifdef PCI_DRIVER | ||
1518 | pci_unregister_driver(&PCI_DRIVER); | ||
1519 | #endif | ||
1520 | #ifdef SA1111_DRIVER | 1502 | #ifdef SA1111_DRIVER |
1521 | sa1111_driver_unregister(&SA1111_DRIVER); | 1503 | sa1111_driver_unregister(&SA1111_DRIVER); |
1522 | #endif | 1504 | #endif |
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c index c3fa93638ea6..08613e241894 100644 --- a/drivers/usb/host/ohci-pci.c +++ b/drivers/usb/host/ohci-pci.c | |||
@@ -14,12 +14,19 @@ | |||
14 | * This file is licenced under the GPL. | 14 | * This file is licenced under the GPL. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #ifndef CONFIG_PCI | ||
18 | #error "This file is PCI bus glue. CONFIG_PCI must be defined." | ||
19 | #endif | ||
20 | |||
21 | #include <linux/pci.h> | ||
22 | #include <linux/io.h> | 17 | #include <linux/io.h> |
18 | #include <linux/kernel.h> | ||
19 | #include <linux/module.h> | ||
20 | #include <linux/pci.h> | ||
21 | #include <linux/usb.h> | ||
22 | #include <linux/usb/hcd.h> | ||
23 | |||
24 | #include "ohci.h" | ||
25 | #include "pci-quirks.h" | ||
26 | |||
27 | #define DRIVER_DESC "OHCI PCI platform driver" | ||
28 | |||
29 | static const char hcd_name[] = "ohci-pci"; | ||
23 | 30 | ||
24 | 31 | ||
25 | /*-------------------------------------------------------------------------*/ | 32 | /*-------------------------------------------------------------------------*/ |
@@ -229,10 +236,10 @@ static const struct pci_device_id ohci_pci_quirks[] = { | |||
229 | static int ohci_pci_reset (struct usb_hcd *hcd) | 236 | static int ohci_pci_reset (struct usb_hcd *hcd) |
230 | { | 237 | { |
231 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); | 238 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); |
239 | struct pci_dev *pdev = to_pci_dev(hcd->self.controller); | ||
232 | int ret = 0; | 240 | int ret = 0; |
233 | 241 | ||
234 | if (hcd->self.controller) { | 242 | if (hcd->self.controller) { |
235 | struct pci_dev *pdev = to_pci_dev(hcd->self.controller); | ||
236 | const struct pci_device_id *quirk_id; | 243 | const struct pci_device_id *quirk_id; |
237 | 244 | ||
238 | quirk_id = pci_match_id(ohci_pci_quirks, pdev); | 245 | quirk_id = pci_match_id(ohci_pci_quirks, pdev); |
@@ -242,94 +249,25 @@ static int ohci_pci_reset (struct usb_hcd *hcd) | |||
242 | ret = quirk(hcd); | 249 | ret = quirk(hcd); |
243 | } | 250 | } |
244 | } | 251 | } |
245 | if (ret == 0) { | ||
246 | ohci_hcd_init (ohci); | ||
247 | return ohci_init (ohci); | ||
248 | } | ||
249 | return ret; | ||
250 | } | ||
251 | |||
252 | |||
253 | static int ohci_pci_start (struct usb_hcd *hcd) | ||
254 | { | ||
255 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); | ||
256 | int ret; | ||
257 | |||
258 | #ifdef CONFIG_PM /* avoid warnings about unused pdev */ | ||
259 | if (hcd->self.controller) { | ||
260 | struct pci_dev *pdev = to_pci_dev(hcd->self.controller); | ||
261 | |||
262 | /* RWC may not be set for add-in PCI cards, since boot | ||
263 | * firmware probably ignored them. This transfers PCI | ||
264 | * PM wakeup capabilities. | ||
265 | */ | ||
266 | if (device_can_wakeup(&pdev->dev)) | ||
267 | ohci->hc_control |= OHCI_CTRL_RWC; | ||
268 | } | ||
269 | #endif /* CONFIG_PM */ | ||
270 | 252 | ||
271 | ret = ohci_run (ohci); | 253 | if (ret == 0) |
272 | if (ret < 0) { | 254 | ret = ohci_setup(hcd); |
273 | ohci_err (ohci, "can't start\n"); | 255 | /* |
274 | ohci_stop (hcd); | 256 | * After ohci setup RWC may not be set for add-in PCI cards. |
275 | } | 257 | * This transfers PCI PM wakeup capabilities. |
258 | */ | ||
259 | if (device_can_wakeup(&pdev->dev)) | ||
260 | ohci->hc_control |= OHCI_CTRL_RWC; | ||
276 | return ret; | 261 | return ret; |
277 | } | 262 | } |
278 | 263 | ||
264 | static struct hc_driver __read_mostly ohci_pci_hc_driver; | ||
279 | 265 | ||
280 | /*-------------------------------------------------------------------------*/ | 266 | static const struct ohci_driver_overrides pci_overrides __initconst = { |
281 | 267 | .product_desc = "OHCI PCI host controller", | |
282 | static const struct hc_driver ohci_pci_hc_driver = { | ||
283 | .description = hcd_name, | ||
284 | .product_desc = "OHCI Host Controller", | ||
285 | .hcd_priv_size = sizeof(struct ohci_hcd), | ||
286 | |||
287 | /* | ||
288 | * generic hardware linkage | ||
289 | */ | ||
290 | .irq = ohci_irq, | ||
291 | .flags = HCD_MEMORY | HCD_USB11, | ||
292 | |||
293 | /* | ||
294 | * basic lifecycle operations | ||
295 | */ | ||
296 | .reset = ohci_pci_reset, | 268 | .reset = ohci_pci_reset, |
297 | .start = ohci_pci_start, | ||
298 | .stop = ohci_stop, | ||
299 | .shutdown = ohci_shutdown, | ||
300 | |||
301 | #ifdef CONFIG_PM | ||
302 | .pci_suspend = ohci_suspend, | ||
303 | .pci_resume = ohci_resume, | ||
304 | #endif | ||
305 | |||
306 | /* | ||
307 | * managing i/o requests and associated device resources | ||
308 | */ | ||
309 | .urb_enqueue = ohci_urb_enqueue, | ||
310 | .urb_dequeue = ohci_urb_dequeue, | ||
311 | .endpoint_disable = ohci_endpoint_disable, | ||
312 | |||
313 | /* | ||
314 | * scheduling support | ||
315 | */ | ||
316 | .get_frame_number = ohci_get_frame, | ||
317 | |||
318 | /* | ||
319 | * root hub support | ||
320 | */ | ||
321 | .hub_status_data = ohci_hub_status_data, | ||
322 | .hub_control = ohci_hub_control, | ||
323 | #ifdef CONFIG_PM | ||
324 | .bus_suspend = ohci_bus_suspend, | ||
325 | .bus_resume = ohci_bus_resume, | ||
326 | #endif | ||
327 | .start_port_reset = ohci_start_port_reset, | ||
328 | }; | 269 | }; |
329 | 270 | ||
330 | /*-------------------------------------------------------------------------*/ | ||
331 | |||
332 | |||
333 | static const struct pci_device_id pci_ids [] = { { | 271 | static const struct pci_device_id pci_ids [] = { { |
334 | /* handle any USB OHCI controller */ | 272 | /* handle any USB OHCI controller */ |
335 | PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_OHCI, ~0), | 273 | PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_OHCI, ~0), |
@@ -357,3 +295,24 @@ static struct pci_driver ohci_pci_driver = { | |||
357 | }, | 295 | }, |
358 | #endif | 296 | #endif |
359 | }; | 297 | }; |
298 | |||
299 | static int __init ohci_pci_init(void) | ||
300 | { | ||
301 | if (usb_disabled()) | ||
302 | return -ENODEV; | ||
303 | |||
304 | pr_info("%s: " DRIVER_DESC "\n", hcd_name); | ||
305 | |||
306 | ohci_init_driver(&ohci_pci_hc_driver, &pci_overrides); | ||
307 | return pci_register_driver(&ohci_pci_driver); | ||
308 | } | ||
309 | module_init(ohci_pci_init); | ||
310 | |||
311 | static void __exit ohci_pci_cleanup(void) | ||
312 | { | ||
313 | pci_unregister_driver(&ohci_pci_driver); | ||
314 | } | ||
315 | module_exit(ohci_pci_cleanup); | ||
316 | |||
317 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
318 | MODULE_LICENSE("GPL"); | ||