diff options
| author | Manjunath Goudar <manjunath.goudar@linaro.org> | 2013-09-21 07:08:39 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-09-26 12:53:46 -0400 |
| commit | de57a1547a4865d31094de95a029fed69edf760d (patch) | |
| tree | c402770ddb7a0776a633daeae6701877561a0bae /drivers/usb/host | |
| parent | 50a97e059bc9ffe05270a1e2dd963cff1b7396bd (diff) | |
USB: OHCI: make ohci-omap a separate driver
Separate the TI OHCI OMAP1/2 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.
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: Felipe Balbi <balbi@ti.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/host')
| -rw-r--r-- | drivers/usb/host/Kconfig | 2 | ||||
| -rw-r--r-- | drivers/usb/host/Makefile | 1 | ||||
| -rw-r--r-- | drivers/usb/host/ohci-hcd.c | 18 | ||||
| -rw-r--r-- | drivers/usb/host/ohci-omap.c | 156 |
4 files changed, 55 insertions, 122 deletions
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index d8d39c7846c7..2b11084c3be9 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig | |||
| @@ -367,7 +367,7 @@ config USB_OHCI_HCD | |||
| 367 | if USB_OHCI_HCD | 367 | if USB_OHCI_HCD |
| 368 | 368 | ||
| 369 | config USB_OHCI_HCD_OMAP1 | 369 | config USB_OHCI_HCD_OMAP1 |
| 370 | bool "OHCI support for OMAP1/2 chips" | 370 | tristate "OHCI support for OMAP1/2 chips" |
| 371 | depends on ARCH_OMAP1 | 371 | depends on ARCH_OMAP1 |
| 372 | default y | 372 | default y |
| 373 | ---help--- | 373 | ---help--- |
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index 78ace5517896..b1640efad539 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile | |||
| @@ -48,6 +48,7 @@ obj-$(CONFIG_USB_OHCI_HCD) += ohci-hcd.o | |||
| 48 | obj-$(CONFIG_USB_OHCI_HCD_PCI) += ohci-pci.o | 48 | obj-$(CONFIG_USB_OHCI_HCD_PCI) += ohci-pci.o |
| 49 | obj-$(CONFIG_USB_OHCI_HCD_PLATFORM) += ohci-platform.o | 49 | obj-$(CONFIG_USB_OHCI_HCD_PLATFORM) += ohci-platform.o |
| 50 | obj-$(CONFIG_USB_OHCI_EXYNOS) += ohci-exynos.o | 50 | obj-$(CONFIG_USB_OHCI_EXYNOS) += ohci-exynos.o |
| 51 | obj-$(CONFIG_USB_OHCI_HCD_OMAP1) += ohci-omap.o | ||
| 51 | 52 | ||
| 52 | obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o | 53 | obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o |
| 53 | obj-$(CONFIG_USB_FHCI_HCD) += fhci.o | 54 | obj-$(CONFIG_USB_FHCI_HCD) += fhci.o |
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 1fc7d3bb78b2..fcef838f3c33 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c | |||
| @@ -1182,11 +1182,6 @@ MODULE_LICENSE ("GPL"); | |||
| 1182 | #define S3C2410_PLATFORM_DRIVER ohci_hcd_s3c2410_driver | 1182 | #define S3C2410_PLATFORM_DRIVER ohci_hcd_s3c2410_driver |
| 1183 | #endif | 1183 | #endif |
| 1184 | 1184 | ||
| 1185 | #ifdef CONFIG_USB_OHCI_HCD_OMAP1 | ||
| 1186 | #include "ohci-omap.c" | ||
| 1187 | #define OMAP1_PLATFORM_DRIVER ohci_hcd_omap_driver | ||
| 1188 | #endif | ||
| 1189 | |||
| 1190 | #ifdef CONFIG_USB_OHCI_HCD_OMAP3 | 1185 | #ifdef CONFIG_USB_OHCI_HCD_OMAP3 |
| 1191 | #include "ohci-omap3.c" | 1186 | #include "ohci-omap3.c" |
| 1192 | #define OMAP3_PLATFORM_DRIVER ohci_hcd_omap3_driver | 1187 | #define OMAP3_PLATFORM_DRIVER ohci_hcd_omap3_driver |
| @@ -1289,12 +1284,6 @@ static int __init ohci_hcd_mod_init(void) | |||
| 1289 | goto error_platform; | 1284 | goto error_platform; |
| 1290 | #endif | 1285 | #endif |
| 1291 | 1286 | ||
| 1292 | #ifdef OMAP1_PLATFORM_DRIVER | ||
| 1293 | retval = platform_driver_register(&OMAP1_PLATFORM_DRIVER); | ||
| 1294 | if (retval < 0) | ||
| 1295 | goto error_omap1_platform; | ||
| 1296 | #endif | ||
| 1297 | |||
| 1298 | #ifdef OMAP3_PLATFORM_DRIVER | 1287 | #ifdef OMAP3_PLATFORM_DRIVER |
| 1299 | retval = platform_driver_register(&OMAP3_PLATFORM_DRIVER); | 1288 | retval = platform_driver_register(&OMAP3_PLATFORM_DRIVER); |
| 1300 | if (retval < 0) | 1289 | if (retval < 0) |
| @@ -1408,10 +1397,6 @@ static int __init ohci_hcd_mod_init(void) | |||
| 1408 | platform_driver_unregister(&OMAP3_PLATFORM_DRIVER); | 1397 | platform_driver_unregister(&OMAP3_PLATFORM_DRIVER); |
| 1409 | error_omap3_platform: | 1398 | error_omap3_platform: |
| 1410 | #endif | 1399 | #endif |
| 1411 | #ifdef OMAP1_PLATFORM_DRIVER | ||
| 1412 | platform_driver_unregister(&OMAP1_PLATFORM_DRIVER); | ||
| 1413 | error_omap1_platform: | ||
| 1414 | #endif | ||
| 1415 | #ifdef PLATFORM_DRIVER | 1400 | #ifdef PLATFORM_DRIVER |
| 1416 | platform_driver_unregister(&PLATFORM_DRIVER); | 1401 | platform_driver_unregister(&PLATFORM_DRIVER); |
| 1417 | error_platform: | 1402 | error_platform: |
| @@ -1466,9 +1451,6 @@ static void __exit ohci_hcd_mod_exit(void) | |||
| 1466 | #ifdef OMAP3_PLATFORM_DRIVER | 1451 | #ifdef OMAP3_PLATFORM_DRIVER |
| 1467 | platform_driver_unregister(&OMAP3_PLATFORM_DRIVER); | 1452 | platform_driver_unregister(&OMAP3_PLATFORM_DRIVER); |
| 1468 | #endif | 1453 | #endif |
| 1469 | #ifdef OMAP1_PLATFORM_DRIVER | ||
| 1470 | platform_driver_unregister(&OMAP1_PLATFORM_DRIVER); | ||
| 1471 | #endif | ||
| 1472 | #ifdef PLATFORM_DRIVER | 1454 | #ifdef PLATFORM_DRIVER |
| 1473 | platform_driver_unregister(&PLATFORM_DRIVER); | 1455 | platform_driver_unregister(&PLATFORM_DRIVER); |
| 1474 | #endif | 1456 | #endif |
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c index 31d3a12eb486..18b27a27e7dc 100644 --- a/drivers/usb/host/ohci-omap.c +++ b/drivers/usb/host/ohci-omap.c | |||
| @@ -14,12 +14,21 @@ | |||
| 14 | * This file is licenced under the GPL. | 14 | * This file is licenced under the GPL. |
| 15 | */ | 15 | */ |
| 16 | 16 | ||
| 17 | #include <linux/signal.h> | ||
| 18 | #include <linux/jiffies.h> | ||
| 19 | #include <linux/platform_device.h> | ||
| 20 | #include <linux/clk.h> | 17 | #include <linux/clk.h> |
| 18 | #include <linux/dma-mapping.h> | ||
| 21 | #include <linux/err.h> | 19 | #include <linux/err.h> |
| 22 | #include <linux/gpio.h> | 20 | #include <linux/gpio.h> |
| 21 | #include <linux/io.h> | ||
| 22 | #include <linux/jiffies.h> | ||
| 23 | #include <linux/kernel.h> | ||
| 24 | #include <linux/module.h> | ||
| 25 | #include <linux/usb/otg.h> | ||
| 26 | #include <linux/platform_device.h> | ||
| 27 | #include <linux/signal.h> | ||
| 28 | #include <linux/usb.h> | ||
| 29 | #include <linux/usb/hcd.h> | ||
| 30 | |||
| 31 | #include "ohci.h" | ||
| 23 | 32 | ||
| 24 | #include <asm/io.h> | 33 | #include <asm/io.h> |
| 25 | #include <asm/mach-types.h> | 34 | #include <asm/mach-types.h> |
| @@ -42,10 +51,7 @@ | |||
| 42 | #define OMAP1510_LB_MMU_RAM_H 0xfffec234 | 51 | #define OMAP1510_LB_MMU_RAM_H 0xfffec234 |
| 43 | #define OMAP1510_LB_MMU_RAM_L 0xfffec238 | 52 | #define OMAP1510_LB_MMU_RAM_L 0xfffec238 |
| 44 | 53 | ||
| 45 | 54 | #define DRIVER_DESC "OHCI OMAP driver" | |
| 46 | #ifndef CONFIG_ARCH_OMAP | ||
| 47 | #error "This file is OMAP bus glue. CONFIG_OMAP must be defined." | ||
| 48 | #endif | ||
| 49 | 55 | ||
| 50 | #ifdef CONFIG_TPS65010 | 56 | #ifdef CONFIG_TPS65010 |
| 51 | #include <linux/i2c/tps65010.h> | 57 | #include <linux/i2c/tps65010.h> |
| @@ -68,8 +74,9 @@ extern int ocpi_enable(void); | |||
| 68 | 74 | ||
| 69 | static struct clk *usb_host_ck; | 75 | static struct clk *usb_host_ck; |
| 70 | static struct clk *usb_dc_ck; | 76 | static struct clk *usb_dc_ck; |
| 71 | static int host_enabled; | 77 | |
| 72 | static int host_initialized; | 78 | static const char hcd_name[] = "ohci-omap"; |
| 79 | static struct hc_driver __read_mostly ohci_omap_hc_driver; | ||
| 73 | 80 | ||
| 74 | static void omap_ohci_clock_power(int on) | 81 | static void omap_ohci_clock_power(int on) |
| 75 | { | 82 | { |
| @@ -188,7 +195,7 @@ static void start_hnp(struct ohci_hcd *ohci) | |||
| 188 | 195 | ||
| 189 | /*-------------------------------------------------------------------------*/ | 196 | /*-------------------------------------------------------------------------*/ |
| 190 | 197 | ||
| 191 | static int ohci_omap_init(struct usb_hcd *hcd) | 198 | static int ohci_omap_reset(struct usb_hcd *hcd) |
| 192 | { | 199 | { |
| 193 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | 200 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); |
| 194 | struct omap_usb_config *config = dev_get_platdata(hcd->self.controller); | 201 | struct omap_usb_config *config = dev_get_platdata(hcd->self.controller); |
| @@ -198,9 +205,9 @@ static int ohci_omap_init(struct usb_hcd *hcd) | |||
| 198 | dev_dbg(hcd->self.controller, "starting USB Controller\n"); | 205 | dev_dbg(hcd->self.controller, "starting USB Controller\n"); |
| 199 | 206 | ||
| 200 | if (config->otg) { | 207 | if (config->otg) { |
| 201 | ohci_to_hcd(ohci)->self.otg_port = config->otg; | 208 | hcd->self.otg_port = config->otg; |
| 202 | /* default/minimum OTG power budget: 8 mA */ | 209 | /* default/minimum OTG power budget: 8 mA */ |
| 203 | ohci_to_hcd(ohci)->power_budget = 8; | 210 | hcd->power_budget = 8; |
| 204 | } | 211 | } |
| 205 | 212 | ||
| 206 | /* boards can use OTG transceivers in non-OTG modes */ | 213 | /* boards can use OTG transceivers in non-OTG modes */ |
| @@ -238,9 +245,15 @@ static int ohci_omap_init(struct usb_hcd *hcd) | |||
| 238 | omap_1510_local_bus_init(); | 245 | omap_1510_local_bus_init(); |
| 239 | } | 246 | } |
| 240 | 247 | ||
| 241 | if ((ret = ohci_init(ohci)) < 0) | 248 | ret = ohci_setup(hcd); |
| 249 | if (ret < 0) | ||
| 242 | return ret; | 250 | return ret; |
| 243 | 251 | ||
| 252 | if (config->otg || config->rwc) { | ||
| 253 | ohci->hc_control = OHCI_CTRL_RWC; | ||
| 254 | writel(OHCI_CTRL_RWC, &ohci->regs->control); | ||
| 255 | } | ||
| 256 | |||
| 244 | /* board-specific power switching and overcurrent support */ | 257 | /* board-specific power switching and overcurrent support */ |
| 245 | if (machine_is_omap_osk() || machine_is_omap_innovator()) { | 258 | if (machine_is_omap_osk() || machine_is_omap_innovator()) { |
| 246 | u32 rh = roothub_a (ohci); | 259 | u32 rh = roothub_a (ohci); |
| @@ -281,14 +294,6 @@ static int ohci_omap_init(struct usb_hcd *hcd) | |||
| 281 | return 0; | 294 | return 0; |
| 282 | } | 295 | } |
| 283 | 296 | ||
| 284 | static void ohci_omap_stop(struct usb_hcd *hcd) | ||
| 285 | { | ||
| 286 | dev_dbg(hcd->self.controller, "stopping USB Controller\n"); | ||
| 287 | ohci_stop(hcd); | ||
| 288 | omap_ohci_clock_power(0); | ||
| 289 | } | ||
| 290 | |||
| 291 | |||
| 292 | /*-------------------------------------------------------------------------*/ | 297 | /*-------------------------------------------------------------------------*/ |
| 293 | 298 | ||
| 294 | /** | 299 | /** |
| @@ -304,7 +309,6 @@ static int usb_hcd_omap_probe (const struct hc_driver *driver, | |||
| 304 | { | 309 | { |
| 305 | int retval, irq; | 310 | int retval, irq; |
| 306 | struct usb_hcd *hcd = 0; | 311 | struct usb_hcd *hcd = 0; |
| 307 | struct ohci_hcd *ohci; | ||
| 308 | 312 | ||
| 309 | if (pdev->num_resources != 2) { | 313 | if (pdev->num_resources != 2) { |
| 310 | printk(KERN_ERR "hcd probe: invalid num_resources: %i\n", | 314 | printk(KERN_ERR "hcd probe: invalid num_resources: %i\n", |
| @@ -354,12 +358,6 @@ static int usb_hcd_omap_probe (const struct hc_driver *driver, | |||
| 354 | goto err2; | 358 | goto err2; |
| 355 | } | 359 | } |
| 356 | 360 | ||
| 357 | ohci = hcd_to_ohci(hcd); | ||
| 358 | ohci_hcd_init(ohci); | ||
| 359 | |||
| 360 | host_initialized = 0; | ||
| 361 | host_enabled = 1; | ||
| 362 | |||
| 363 | irq = platform_get_irq(pdev, 0); | 361 | irq = platform_get_irq(pdev, 0); |
| 364 | if (irq < 0) { | 362 | if (irq < 0) { |
| 365 | retval = -ENXIO; | 363 | retval = -ENXIO; |
| @@ -369,11 +367,6 @@ static int usb_hcd_omap_probe (const struct hc_driver *driver, | |||
| 369 | if (retval) | 367 | if (retval) |
| 370 | goto err3; | 368 | goto err3; |
| 371 | 369 | ||
| 372 | host_initialized = 1; | ||
| 373 | |||
| 374 | if (!host_enabled) | ||
| 375 | omap_ohci_clock_power(0); | ||
| 376 | |||
| 377 | return 0; | 370 | return 0; |
| 378 | err3: | 371 | err3: |
| 379 | iounmap(hcd->regs); | 372 | iounmap(hcd->regs); |
| @@ -402,7 +395,9 @@ err0: | |||
| 402 | static inline void | 395 | static inline void |
| 403 | usb_hcd_omap_remove (struct usb_hcd *hcd, struct platform_device *pdev) | 396 | usb_hcd_omap_remove (struct usb_hcd *hcd, struct platform_device *pdev) |
| 404 | { | 397 | { |
| 398 | dev_dbg(hcd->self.controller, "stopping USB Controller\n"); | ||
| 405 | usb_remove_hcd(hcd); | 399 | usb_remove_hcd(hcd); |
| 400 | omap_ohci_clock_power(0); | ||
| 406 | if (!IS_ERR_OR_NULL(hcd->phy)) { | 401 | if (!IS_ERR_OR_NULL(hcd->phy)) { |
| 407 | (void) otg_set_host(hcd->phy->otg, 0); | 402 | (void) otg_set_host(hcd->phy->otg, 0); |
| 408 | usb_put_phy(hcd->phy); | 403 | usb_put_phy(hcd->phy); |
| @@ -418,76 +413,6 @@ usb_hcd_omap_remove (struct usb_hcd *hcd, struct platform_device *pdev) | |||
| 418 | 413 | ||
| 419 | /*-------------------------------------------------------------------------*/ | 414 | /*-------------------------------------------------------------------------*/ |
| 420 | 415 | ||
| 421 | static int | ||
| 422 | ohci_omap_start (struct usb_hcd *hcd) | ||
| 423 | { | ||
| 424 | struct omap_usb_config *config; | ||
| 425 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); | ||
| 426 | int ret; | ||
| 427 | |||
| 428 | if (!host_enabled) | ||
| 429 | return 0; | ||
| 430 | config = dev_get_platdata(hcd->self.controller); | ||
| 431 | if (config->otg || config->rwc) { | ||
| 432 | ohci->hc_control = OHCI_CTRL_RWC; | ||
| 433 | writel(OHCI_CTRL_RWC, &ohci->regs->control); | ||
| 434 | } | ||
| 435 | |||
| 436 | if ((ret = ohci_run (ohci)) < 0) { | ||
| 437 | dev_err(hcd->self.controller, "can't start\n"); | ||
| 438 | ohci_stop (hcd); | ||
| 439 | return ret; | ||
| 440 | } | ||
| 441 | return 0; | ||
| 442 | } | ||
| 443 | |||
| 444 | /*-------------------------------------------------------------------------*/ | ||
| 445 | |||
| 446 | static const struct hc_driver ohci_omap_hc_driver = { | ||
| 447 | .description = hcd_name, | ||
| 448 | .product_desc = "OMAP OHCI", | ||
| 449 | .hcd_priv_size = sizeof(struct ohci_hcd), | ||
| 450 | |||
| 451 | /* | ||
| 452 | * generic hardware linkage | ||
| 453 | */ | ||
| 454 | .irq = ohci_irq, | ||
| 455 | .flags = HCD_USB11 | HCD_MEMORY, | ||
| 456 | |||
| 457 | /* | ||
| 458 | * basic lifecycle operations | ||
| 459 | */ | ||
| 460 | .reset = ohci_omap_init, | ||
| 461 | .start = ohci_omap_start, | ||
| 462 | .stop = ohci_omap_stop, | ||
| 463 | .shutdown = ohci_shutdown, | ||
| 464 | |||
| 465 | /* | ||
| 466 | * managing i/o requests and associated device resources | ||
| 467 | */ | ||
| 468 | .urb_enqueue = ohci_urb_enqueue, | ||
| 469 | .urb_dequeue = ohci_urb_dequeue, | ||
| 470 | .endpoint_disable = ohci_endpoint_disable, | ||
| 471 | |||
| 472 | /* | ||
| 473 | * scheduling support | ||
| 474 | */ | ||
| 475 | .get_frame_number = ohci_get_frame, | ||
| 476 | |||
| 477 | /* | ||
| 478 | * root hub support | ||
| 479 | */ | ||
| 480 | .hub_status_data = ohci_hub_status_data, | ||
| 481 | .hub_control = ohci_hub_control, | ||
| 482 | #ifdef CONFIG_PM | ||
| 483 | .bus_suspend = ohci_bus_suspend, | ||
| 484 | .bus_resume = ohci_bus_resume, | ||
| 485 | #endif | ||
| 486 | .start_port_reset = ohci_start_port_reset, | ||
| 487 | }; | ||
| 488 | |||
| 489 | /*-------------------------------------------------------------------------*/ | ||
| 490 | |||
| 491 | static int ohci_hcd_omap_drv_probe(struct platform_device *dev) | 416 | static int ohci_hcd_omap_drv_probe(struct platform_device *dev) |
| 492 | { | 417 | { |
| 493 | return usb_hcd_omap_probe(&ohci_omap_hc_driver, dev); | 418 | return usb_hcd_omap_probe(&ohci_omap_hc_driver, dev); |
| @@ -553,4 +478,29 @@ static struct platform_driver ohci_hcd_omap_driver = { | |||
| 553 | }, | 478 | }, |
| 554 | }; | 479 | }; |
| 555 | 480 | ||
| 481 | static const struct ohci_driver_overrides omap_overrides __initconst = { | ||
| 482 | .product_desc = "OMAP OHCI", | ||
| 483 | .reset = ohci_omap_reset | ||
| 484 | }; | ||
| 485 | |||
| 486 | static int __init ohci_omap_init(void) | ||
| 487 | { | ||
| 488 | if (usb_disabled()) | ||
| 489 | return -ENODEV; | ||
| 490 | |||
| 491 | pr_info("%s: " DRIVER_DESC "\n", hcd_name); | ||
| 492 | |||
| 493 | ohci_init_driver(&ohci_omap_hc_driver, &omap_overrides); | ||
| 494 | return platform_driver_register(&ohci_hcd_omap_driver); | ||
| 495 | } | ||
| 496 | module_init(ohci_omap_init); | ||
| 497 | |||
| 498 | static void __exit ohci_omap_cleanup(void) | ||
| 499 | { | ||
| 500 | platform_driver_unregister(&ohci_hcd_omap_driver); | ||
| 501 | } | ||
| 502 | module_exit(ohci_omap_cleanup); | ||
| 503 | |||
| 504 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
| 556 | MODULE_ALIAS("platform:ohci"); | 505 | MODULE_ALIAS("platform:ohci"); |
| 506 | MODULE_LICENSE("GPL"); | ||
