diff options
author | Li Yang <leoli@freescale.com> | 2007-02-07 00:49:24 -0500 |
---|---|---|
committer | Kumar Gala <galak@kernel.crashing.org> | 2007-02-08 01:41:05 -0500 |
commit | 97c5a20ae68774b4c9246c4657be0d88317f103f (patch) | |
tree | 2cf9933f1753532db609dc4a27477a83bbe72366 /arch | |
parent | c161698287f501e7ea229672383af7aefe8a2056 (diff) |
[POWERPC] 83xx: Add platform_device for USB DR peripheral driver
Add platform_device setup code for OTG/peripheral mode of 834x DR module.
It is needed for USB client driver to work.
Signed-off-by: Li Yang <leoli@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/sysdev/fsl_soc.c | 78 |
1 files changed, 59 insertions, 19 deletions
diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c index 9f2a9a444bfb..34161bc5a02f 100644 --- a/arch/powerpc/sysdev/fsl_soc.c +++ b/arch/powerpc/sysdev/fsl_soc.c | |||
@@ -441,7 +441,8 @@ static int __init fsl_usb_of_init(void) | |||
441 | { | 441 | { |
442 | struct device_node *np; | 442 | struct device_node *np; |
443 | unsigned int i; | 443 | unsigned int i; |
444 | struct platform_device *usb_dev_mph = NULL, *usb_dev_dr = NULL; | 444 | struct platform_device *usb_dev_mph = NULL, *usb_dev_dr_host = NULL, |
445 | *usb_dev_dr_client = NULL; | ||
445 | int ret; | 446 | int ret; |
446 | 447 | ||
447 | for (np = NULL, i = 0; | 448 | for (np = NULL, i = 0; |
@@ -507,33 +508,72 @@ static int __init fsl_usb_of_init(void) | |||
507 | 508 | ||
508 | of_irq_to_resource(np, 0, &r[1]); | 509 | of_irq_to_resource(np, 0, &r[1]); |
509 | 510 | ||
510 | usb_dev_dr = | 511 | prop = get_property(np, "dr_mode", NULL); |
511 | platform_device_register_simple("fsl-ehci", i, r, 2); | 512 | |
512 | if (IS_ERR(usb_dev_dr)) { | 513 | if (!prop || !strcmp(prop, "host")) { |
513 | ret = PTR_ERR(usb_dev_dr); | 514 | usb_data.operating_mode = FSL_USB2_DR_HOST; |
515 | usb_dev_dr_host = platform_device_register_simple( | ||
516 | "fsl-ehci", i, r, 2); | ||
517 | if (IS_ERR(usb_dev_dr_host)) { | ||
518 | ret = PTR_ERR(usb_dev_dr_host); | ||
519 | goto err; | ||
520 | } | ||
521 | } else if (prop && !strcmp(prop, "peripheral")) { | ||
522 | usb_data.operating_mode = FSL_USB2_DR_DEVICE; | ||
523 | usb_dev_dr_client = platform_device_register_simple( | ||
524 | "fsl-usb2-udc", i, r, 2); | ||
525 | if (IS_ERR(usb_dev_dr_client)) { | ||
526 | ret = PTR_ERR(usb_dev_dr_client); | ||
527 | goto err; | ||
528 | } | ||
529 | } else if (prop && !strcmp(prop, "otg")) { | ||
530 | usb_data.operating_mode = FSL_USB2_DR_OTG; | ||
531 | usb_dev_dr_host = platform_device_register_simple( | ||
532 | "fsl-ehci", i, r, 2); | ||
533 | if (IS_ERR(usb_dev_dr_host)) { | ||
534 | ret = PTR_ERR(usb_dev_dr_host); | ||
535 | goto err; | ||
536 | } | ||
537 | usb_dev_dr_client = platform_device_register_simple( | ||
538 | "fsl-usb2-udc", i, r, 2); | ||
539 | if (IS_ERR(usb_dev_dr_client)) { | ||
540 | ret = PTR_ERR(usb_dev_dr_client); | ||
541 | goto err; | ||
542 | } | ||
543 | } else { | ||
544 | ret = -EINVAL; | ||
514 | goto err; | 545 | goto err; |
515 | } | 546 | } |
516 | 547 | ||
517 | usb_dev_dr->dev.coherent_dma_mask = 0xffffffffUL; | ||
518 | usb_dev_dr->dev.dma_mask = &usb_dev_dr->dev.coherent_dma_mask; | ||
519 | |||
520 | usb_data.operating_mode = FSL_USB2_DR_HOST; | ||
521 | |||
522 | prop = get_property(np, "phy_type", NULL); | 548 | prop = get_property(np, "phy_type", NULL); |
523 | usb_data.phy_mode = determine_usb_phy(prop); | 549 | usb_data.phy_mode = determine_usb_phy(prop); |
524 | 550 | ||
525 | ret = | 551 | if (usb_dev_dr_host) { |
526 | platform_device_add_data(usb_dev_dr, &usb_data, | 552 | usb_dev_dr_host->dev.coherent_dma_mask = 0xffffffffUL; |
527 | sizeof(struct | 553 | usb_dev_dr_host->dev.dma_mask = &usb_dev_dr_host-> |
528 | fsl_usb2_platform_data)); | 554 | dev.coherent_dma_mask; |
529 | if (ret) | 555 | if ((ret = platform_device_add_data(usb_dev_dr_host, |
530 | goto unreg_dr; | 556 | &usb_data, sizeof(struct |
557 | fsl_usb2_platform_data)))) | ||
558 | goto unreg_dr; | ||
559 | } | ||
560 | if (usb_dev_dr_client) { | ||
561 | usb_dev_dr_client->dev.coherent_dma_mask = 0xffffffffUL; | ||
562 | usb_dev_dr_client->dev.dma_mask = &usb_dev_dr_client-> | ||
563 | dev.coherent_dma_mask; | ||
564 | if ((ret = platform_device_add_data(usb_dev_dr_client, | ||
565 | &usb_data, sizeof(struct | ||
566 | fsl_usb2_platform_data)))) | ||
567 | goto unreg_dr; | ||
568 | } | ||
531 | } | 569 | } |
532 | return 0; | 570 | return 0; |
533 | 571 | ||
534 | unreg_dr: | 572 | unreg_dr: |
535 | if (usb_dev_dr) | 573 | if (usb_dev_dr_host) |
536 | platform_device_unregister(usb_dev_dr); | 574 | platform_device_unregister(usb_dev_dr_host); |
575 | if (usb_dev_dr_client) | ||
576 | platform_device_unregister(usb_dev_dr_client); | ||
537 | unreg_mph: | 577 | unreg_mph: |
538 | if (usb_dev_mph) | 578 | if (usb_dev_mph) |
539 | platform_device_unregister(usb_dev_mph); | 579 | platform_device_unregister(usb_dev_mph); |
@@ -699,7 +739,7 @@ static int __init fs_enet_of_init(void) | |||
699 | if (ret) | 739 | if (ret) |
700 | goto unreg; | 740 | goto unreg; |
701 | } | 741 | } |
702 | 742 | ||
703 | of_node_put(phy); | 743 | of_node_put(phy); |
704 | of_node_put(mdio); | 744 | of_node_put(mdio); |
705 | 745 | ||