aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKumar Gala <galak@kernel.crashing.org>2006-04-11 11:07:16 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2006-06-21 18:04:09 -0400
commit01cced250722d22d99c2342979490f93ca886521 (patch)
treeb29b395305836a0f3690a69173e1df2a2f0ecf4f
parentdf47e5330b0f5decb0a5736e9a81fff49d46d151 (diff)
[PATCH] USB: allow multiple types of EHCI controllers to be built as modules
In some systems we may have both a platform EHCI controller and PCI EHCI controller. Previously we couldn't build the EHCI support as a module due to conflicting module_init() calls in the code. Signed-off-by: Kumar Gala <galak@kernel.crashing.org> Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--arch/powerpc/sysdev/fsl_soc.c66
-rw-r--r--arch/ppc/syslib/mpc83xx_devices.c6
-rw-r--r--drivers/usb/host/ehci-au1xxx.c17
-rw-r--r--drivers/usb/host/ehci-fsl.c37
-rw-r--r--drivers/usb/host/ehci-hcd.c48
-rw-r--r--drivers/usb/host/ehci-pci.c20
6 files changed, 78 insertions, 116 deletions
diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index ceb584682fa3..71a3275935ec 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -372,7 +372,7 @@ static int __init fsl_usb_of_init(void)
372{ 372{
373 struct device_node *np; 373 struct device_node *np;
374 unsigned int i; 374 unsigned int i;
375 struct platform_device *usb_dev; 375 struct platform_device *usb_dev_mph = NULL, *usb_dev_dr = NULL;
376 int ret; 376 int ret;
377 377
378 for (np = NULL, i = 0; 378 for (np = NULL, i = 0;
@@ -393,15 +393,15 @@ static int __init fsl_usb_of_init(void)
393 r[1].end = np->intrs[0].line; 393 r[1].end = np->intrs[0].line;
394 r[1].flags = IORESOURCE_IRQ; 394 r[1].flags = IORESOURCE_IRQ;
395 395
396 usb_dev = 396 usb_dev_mph =
397 platform_device_register_simple("fsl-usb2-mph", i, r, 2); 397 platform_device_register_simple("fsl-ehci", i, r, 2);
398 if (IS_ERR(usb_dev)) { 398 if (IS_ERR(usb_dev_mph)) {
399 ret = PTR_ERR(usb_dev); 399 ret = PTR_ERR(usb_dev_mph);
400 goto err; 400 goto err;
401 } 401 }
402 402
403 usb_dev->dev.coherent_dma_mask = 0xffffffffUL; 403 usb_dev_mph->dev.coherent_dma_mask = 0xffffffffUL;
404 usb_dev->dev.dma_mask = &usb_dev->dev.coherent_dma_mask; 404 usb_dev_mph->dev.dma_mask = &usb_dev_mph->dev.coherent_dma_mask;
405 405
406 usb_data.operating_mode = FSL_USB2_MPH_HOST; 406 usb_data.operating_mode = FSL_USB2_MPH_HOST;
407 407
@@ -417,31 +417,14 @@ static int __init fsl_usb_of_init(void)
417 usb_data.phy_mode = determine_usb_phy(prop); 417 usb_data.phy_mode = determine_usb_phy(prop);
418 418
419 ret = 419 ret =
420 platform_device_add_data(usb_dev, &usb_data, 420 platform_device_add_data(usb_dev_mph, &usb_data,
421 sizeof(struct 421 sizeof(struct
422 fsl_usb2_platform_data)); 422 fsl_usb2_platform_data));
423 if (ret) 423 if (ret)
424 goto unreg; 424 goto unreg_mph;
425 } 425 }
426 426
427 return 0; 427 for (np = NULL;
428
429unreg:
430 platform_device_unregister(usb_dev);
431err:
432 return ret;
433}
434
435arch_initcall(fsl_usb_of_init);
436
437static int __init fsl_usb_dr_of_init(void)
438{
439 struct device_node *np;
440 unsigned int i;
441 struct platform_device *usb_dev;
442 int ret;
443
444 for (np = NULL, i = 0;
445 (np = of_find_compatible_node(np, "usb", "fsl-usb2-dr")) != NULL; 428 (np = of_find_compatible_node(np, "usb", "fsl-usb2-dr")) != NULL;
446 i++) { 429 i++) {
447 struct resource r[2]; 430 struct resource r[2];
@@ -453,21 +436,21 @@ static int __init fsl_usb_dr_of_init(void)
453 436
454 ret = of_address_to_resource(np, 0, &r[0]); 437 ret = of_address_to_resource(np, 0, &r[0]);
455 if (ret) 438 if (ret)
456 goto err; 439 goto unreg_mph;
457 440
458 r[1].start = np->intrs[0].line; 441 r[1].start = np->intrs[0].line;
459 r[1].end = np->intrs[0].line; 442 r[1].end = np->intrs[0].line;
460 r[1].flags = IORESOURCE_IRQ; 443 r[1].flags = IORESOURCE_IRQ;
461 444
462 usb_dev = 445 usb_dev_dr =
463 platform_device_register_simple("fsl-usb2-dr", i, r, 2); 446 platform_device_register_simple("fsl-ehci", i, r, 2);
464 if (IS_ERR(usb_dev)) { 447 if (IS_ERR(usb_dev_dr)) {
465 ret = PTR_ERR(usb_dev); 448 ret = PTR_ERR(usb_dev_dr);
466 goto err; 449 goto err;
467 } 450 }
468 451
469 usb_dev->dev.coherent_dma_mask = 0xffffffffUL; 452 usb_dev_dr->dev.coherent_dma_mask = 0xffffffffUL;
470 usb_dev->dev.dma_mask = &usb_dev->dev.coherent_dma_mask; 453 usb_dev_dr->dev.dma_mask = &usb_dev_dr->dev.coherent_dma_mask;
471 454
472 usb_data.operating_mode = FSL_USB2_DR_HOST; 455 usb_data.operating_mode = FSL_USB2_DR_HOST;
473 456
@@ -475,19 +458,22 @@ static int __init fsl_usb_dr_of_init(void)
475 usb_data.phy_mode = determine_usb_phy(prop); 458 usb_data.phy_mode = determine_usb_phy(prop);
476 459
477 ret = 460 ret =
478 platform_device_add_data(usb_dev, &usb_data, 461 platform_device_add_data(usb_dev_dr, &usb_data,
479 sizeof(struct 462 sizeof(struct
480 fsl_usb2_platform_data)); 463 fsl_usb2_platform_data));
481 if (ret) 464 if (ret)
482 goto unreg; 465 goto unreg_dr;
483 } 466 }
484
485 return 0; 467 return 0;
486 468
487unreg: 469unreg_dr:
488 platform_device_unregister(usb_dev); 470 if (usb_dev_dr)
471 platform_device_unregister(usb_dev_dr);
472unreg_mph:
473 if (usb_dev_mph)
474 platform_device_unregister(usb_dev_mph);
489err: 475err:
490 return ret; 476 return ret;
491} 477}
492 478
493arch_initcall(fsl_usb_dr_of_init); 479arch_initcall(fsl_usb_of_init);
diff --git a/arch/ppc/syslib/mpc83xx_devices.c b/arch/ppc/syslib/mpc83xx_devices.c
index 1af2c000fcfa..5c4932ca8e9b 100644
--- a/arch/ppc/syslib/mpc83xx_devices.c
+++ b/arch/ppc/syslib/mpc83xx_devices.c
@@ -186,7 +186,7 @@ struct platform_device ppc_sys_platform_devices[] = {
186 }, 186 },
187 }, 187 },
188 [MPC83xx_USB2_DR] = { 188 [MPC83xx_USB2_DR] = {
189 .name = "fsl-usb2-dr", 189 .name = "fsl-ehci",
190 .id = 1, 190 .id = 1,
191 .num_resources = 2, 191 .num_resources = 2,
192 .resource = (struct resource[]) { 192 .resource = (struct resource[]) {
@@ -203,8 +203,8 @@ struct platform_device ppc_sys_platform_devices[] = {
203 }, 203 },
204 }, 204 },
205 [MPC83xx_USB2_MPH] = { 205 [MPC83xx_USB2_MPH] = {
206 .name = "fsl-usb2-mph", 206 .name = "fsl-ehci",
207 .id = 1, 207 .id = 2,
208 .num_resources = 2, 208 .num_resources = 2,
209 .resource = (struct resource[]) { 209 .resource = (struct resource[]) {
210 { 210 {
diff --git a/drivers/usb/host/ehci-au1xxx.c b/drivers/usb/host/ehci-au1xxx.c
index 63eadeec1324..0e444ab1930d 100644
--- a/drivers/usb/host/ehci-au1xxx.c
+++ b/drivers/usb/host/ehci-au1xxx.c
@@ -272,6 +272,8 @@ static int ehci_hcd_au1xxx_drv_resume(struct device *dev)
272 return 0; 272 return 0;
273} 273}
274*/ 274*/
275MODULE_ALIAS("au1xxx-ehci");
276/* FIXME use "struct platform_driver" */
275static struct device_driver ehci_hcd_au1xxx_driver = { 277static struct device_driver ehci_hcd_au1xxx_driver = {
276 .name = "au1xxx-ehci", 278 .name = "au1xxx-ehci",
277 .bus = &platform_bus_type, 279 .bus = &platform_bus_type,
@@ -280,18 +282,3 @@ static struct device_driver ehci_hcd_au1xxx_driver = {
280 /*.suspend = ehci_hcd_au1xxx_drv_suspend, */ 282 /*.suspend = ehci_hcd_au1xxx_drv_suspend, */
281 /*.resume = ehci_hcd_au1xxx_drv_resume, */ 283 /*.resume = ehci_hcd_au1xxx_drv_resume, */
282}; 284};
283
284static int __init ehci_hcd_au1xxx_init(void)
285{
286 pr_debug(DRIVER_INFO " (Au1xxx)\n");
287
288 return driver_register(&ehci_hcd_au1xxx_driver);
289}
290
291static void __exit ehci_hcd_au1xxx_cleanup(void)
292{
293 driver_unregister(&ehci_hcd_au1xxx_driver);
294}
295
296module_init(ehci_hcd_au1xxx_init);
297module_exit(ehci_hcd_au1xxx_cleanup);
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index f985f121a245..a49a689bf423 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -324,43 +324,12 @@ static int ehci_fsl_drv_remove(struct platform_device *pdev)
324 return 0; 324 return 0;
325} 325}
326 326
327static struct platform_driver ehci_fsl_dr_driver = { 327MODULE_ALIAS("fsl-ehci");
328 .probe = ehci_fsl_drv_probe,
329 .remove = ehci_fsl_drv_remove,
330 .driver = {
331 .name = "fsl-usb2-dr",
332 },
333};
334 328
335static struct platform_driver ehci_fsl_mph_driver = { 329static struct platform_driver ehci_fsl_driver = {
336 .probe = ehci_fsl_drv_probe, 330 .probe = ehci_fsl_drv_probe,
337 .remove = ehci_fsl_drv_remove, 331 .remove = ehci_fsl_drv_remove,
338 .driver = { 332 .driver = {
339 .name = "fsl-usb2-mph", 333 .name = "fsl-ehci",
340 }, 334 },
341}; 335};
342
343static int __init ehci_fsl_init(void)
344{
345 int retval;
346
347 pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n",
348 hcd_name,
349 sizeof(struct ehci_qh), sizeof(struct ehci_qtd),
350 sizeof(struct ehci_itd), sizeof(struct ehci_sitd));
351
352 retval = platform_driver_register(&ehci_fsl_dr_driver);
353 if (retval)
354 return retval;
355
356 return platform_driver_register(&ehci_fsl_mph_driver);
357}
358
359static void __exit ehci_fsl_cleanup(void)
360{
361 platform_driver_unregister(&ehci_fsl_mph_driver);
362 platform_driver_unregister(&ehci_fsl_dr_driver);
363}
364
365module_init(ehci_fsl_init);
366module_exit(ehci_fsl_cleanup);
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 79f2d8b9bfb6..7d7c97cf9b2f 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -889,19 +889,59 @@ MODULE_LICENSE ("GPL");
889 889
890#ifdef CONFIG_PCI 890#ifdef CONFIG_PCI
891#include "ehci-pci.c" 891#include "ehci-pci.c"
892#define EHCI_BUS_GLUED 892#define PCI_DRIVER ehci_pci_driver
893#endif 893#endif
894 894
895#ifdef CONFIG_PPC_83xx 895#ifdef CONFIG_PPC_83xx
896#include "ehci-fsl.c" 896#include "ehci-fsl.c"
897#define EHCI_BUS_GLUED 897#define PLATFORM_DRIVER ehci_fsl_driver
898#endif 898#endif
899 899
900#ifdef CONFIG_SOC_AU1X00 900#ifdef CONFIG_SOC_AU1X00
901#include "ehci-au1xxx.c" 901#include "ehci-au1xxx.c"
902#define EHCI_BUS_GLUED 902#define PLATFORM_DRIVER ehci_hcd_au1xxx_driver
903#endif 903#endif
904 904
905#ifndef EHCI_BUS_GLUED 905#if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER)
906#error "missing bus glue for ehci-hcd" 906#error "missing bus glue for ehci-hcd"
907#endif 907#endif
908
909static int __init ehci_hcd_init(void)
910{
911 int retval = 0;
912
913 pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n",
914 hcd_name,
915 sizeof(struct ehci_qh), sizeof(struct ehci_qtd),
916 sizeof(struct ehci_itd), sizeof(struct ehci_sitd));
917
918#ifdef PLATFORM_DRIVER
919 retval = platform_driver_register(&PLATFORM_DRIVER);
920 if (retval < 0)
921 return retval;
922#endif
923
924#ifdef PCI_DRIVER
925 retval = pci_register_driver(&PCI_DRIVER);
926 if (retval < 0) {
927#ifdef PLATFORM_DRIVER
928 platform_driver_unregister(&PLATFORM_DRIVER);
929#endif
930 }
931#endif
932
933 return retval;
934}
935module_init(ehci_hcd_init);
936
937static void __exit ehci_hcd_cleanup(void)
938{
939#ifdef PLATFORM_DRIVER
940 platform_driver_unregister(&PLATFORM_DRIVER);
941#endif
942#ifdef PCI_DRIVER
943 pci_unregister_driver(&PCI_DRIVER);
944#endif
945}
946module_exit(ehci_hcd_cleanup);
947
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 648ddb52d579..cadffacd945b 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -379,23 +379,3 @@ static struct pci_driver ehci_pci_driver = {
379 .resume = usb_hcd_pci_resume, 379 .resume = usb_hcd_pci_resume,
380#endif 380#endif
381}; 381};
382
383static int __init ehci_hcd_pci_init(void)
384{
385 if (usb_disabled())
386 return -ENODEV;
387
388 pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n",
389 hcd_name,
390 sizeof(struct ehci_qh), sizeof(struct ehci_qtd),
391 sizeof(struct ehci_itd), sizeof(struct ehci_sitd));
392
393 return pci_register_driver(&ehci_pci_driver);
394}
395module_init(ehci_hcd_pci_init);
396
397static void __exit ehci_hcd_pci_cleanup(void)
398{
399 pci_unregister_driver(&ehci_pci_driver);
400}
401module_exit(ehci_hcd_pci_cleanup);