aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb
diff options
context:
space:
mode:
authorB, Ravi <ravibabu@ti.com>2012-08-31 07:09:49 -0400
committerFelipe Balbi <balbi@ti.com>2012-09-11 10:34:41 -0400
commit65b3d52d02a558fbfe08e43688e15390c5ab3067 (patch)
tree0082a0e45c26ff015a7b0976e917c83d87db8e70 /drivers/usb/musb
parent00a0b1d58af873d842580dcac55f3b156c3a4077 (diff)
usb: musb: add musb_ida for multi instance support
Added musb_ida in musb_core.c to manage the multi core ids. Signed-off-by: Ravi Babu <ravibabu@ti.com> Signed-off-by: Ajay Kumar Gupta <ajay.gupta@ti.com> Signed-off-by: Santhapuri, Damodar <damodar.santhapuri@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/musb')
-rw-r--r--drivers/usb/musb/am35x.c42
-rw-r--r--drivers/usb/musb/blackfin.c26
-rw-r--r--drivers/usb/musb/da8xx.c34
-rw-r--r--drivers/usb/musb/davinci.c34
-rw-r--r--drivers/usb/musb/musb_core.c31
-rw-r--r--drivers/usb/musb/musb_core.h2
-rw-r--r--drivers/usb/musb/musb_dsps.c25
-rw-r--r--drivers/usb/musb/omap2430.c26
-rw-r--r--drivers/usb/musb/tusb6010.c26
-rw-r--r--drivers/usb/musb/ux500.c33
10 files changed, 210 insertions, 69 deletions
diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
index 9fbe73688037..de717b5a92b0 100644
--- a/drivers/usb/musb/am35x.c
+++ b/drivers/usb/musb/am35x.c
@@ -458,6 +458,7 @@ static int __devinit am35x_probe(struct platform_device *pdev)
458 struct clk *clk; 458 struct clk *clk;
459 459
460 int ret = -ENOMEM; 460 int ret = -ENOMEM;
461 int musbid;
461 462
462 glue = kzalloc(sizeof(*glue), GFP_KERNEL); 463 glue = kzalloc(sizeof(*glue), GFP_KERNEL);
463 if (!glue) { 464 if (!glue) {
@@ -465,38 +466,47 @@ static int __devinit am35x_probe(struct platform_device *pdev)
465 goto err0; 466 goto err0;
466 } 467 }
467 468
468 musb = platform_device_alloc("musb-hdrc", -1); 469 /* get the musb id */
470 musbid = musb_get_id(&pdev->dev, GFP_KERNEL);
471 if (musbid < 0) {
472 dev_err(&pdev->dev, "failed to allocate musb id\n");
473 ret = -ENOMEM;
474 goto err1;
475 }
476
477 musb = platform_device_alloc("musb-hdrc", musbid);
469 if (!musb) { 478 if (!musb) {
470 dev_err(&pdev->dev, "failed to allocate musb device\n"); 479 dev_err(&pdev->dev, "failed to allocate musb device\n");
471 goto err1; 480 goto err2;
472 } 481 }
473 482
474 phy_clk = clk_get(&pdev->dev, "fck"); 483 phy_clk = clk_get(&pdev->dev, "fck");
475 if (IS_ERR(phy_clk)) { 484 if (IS_ERR(phy_clk)) {
476 dev_err(&pdev->dev, "failed to get PHY clock\n"); 485 dev_err(&pdev->dev, "failed to get PHY clock\n");
477 ret = PTR_ERR(phy_clk); 486 ret = PTR_ERR(phy_clk);
478 goto err2; 487 goto err3;
479 } 488 }
480 489
481 clk = clk_get(&pdev->dev, "ick"); 490 clk = clk_get(&pdev->dev, "ick");
482 if (IS_ERR(clk)) { 491 if (IS_ERR(clk)) {
483 dev_err(&pdev->dev, "failed to get clock\n"); 492 dev_err(&pdev->dev, "failed to get clock\n");
484 ret = PTR_ERR(clk); 493 ret = PTR_ERR(clk);
485 goto err3; 494 goto err4;
486 } 495 }
487 496
488 ret = clk_enable(phy_clk); 497 ret = clk_enable(phy_clk);
489 if (ret) { 498 if (ret) {
490 dev_err(&pdev->dev, "failed to enable PHY clock\n"); 499 dev_err(&pdev->dev, "failed to enable PHY clock\n");
491 goto err4; 500 goto err5;
492 } 501 }
493 502
494 ret = clk_enable(clk); 503 ret = clk_enable(clk);
495 if (ret) { 504 if (ret) {
496 dev_err(&pdev->dev, "failed to enable clock\n"); 505 dev_err(&pdev->dev, "failed to enable clock\n");
497 goto err5; 506 goto err6;
498 } 507 }
499 508
509 musb->id = musbid;
500 musb->dev.parent = &pdev->dev; 510 musb->dev.parent = &pdev->dev;
501 musb->dev.dma_mask = &am35x_dmamask; 511 musb->dev.dma_mask = &am35x_dmamask;
502 musb->dev.coherent_dma_mask = am35x_dmamask; 512 musb->dev.coherent_dma_mask = am35x_dmamask;
@@ -514,38 +524,41 @@ static int __devinit am35x_probe(struct platform_device *pdev)
514 pdev->num_resources); 524 pdev->num_resources);
515 if (ret) { 525 if (ret) {
516 dev_err(&pdev->dev, "failed to add resources\n"); 526 dev_err(&pdev->dev, "failed to add resources\n");
517 goto err6; 527 goto err7;
518 } 528 }
519 529
520 ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); 530 ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
521 if (ret) { 531 if (ret) {
522 dev_err(&pdev->dev, "failed to add platform_data\n"); 532 dev_err(&pdev->dev, "failed to add platform_data\n");
523 goto err6; 533 goto err7;
524 } 534 }
525 535
526 ret = platform_device_add(musb); 536 ret = platform_device_add(musb);
527 if (ret) { 537 if (ret) {
528 dev_err(&pdev->dev, "failed to register musb device\n"); 538 dev_err(&pdev->dev, "failed to register musb device\n");
529 goto err6; 539 goto err7;
530 } 540 }
531 541
532 return 0; 542 return 0;
533 543
534err6: 544err7:
535 clk_disable(clk); 545 clk_disable(clk);
536 546
537err5: 547err6:
538 clk_disable(phy_clk); 548 clk_disable(phy_clk);
539 549
540err4: 550err5:
541 clk_put(clk); 551 clk_put(clk);
542 552
543err3: 553err4:
544 clk_put(phy_clk); 554 clk_put(phy_clk);
545 555
546err2: 556err3:
547 platform_device_put(musb); 557 platform_device_put(musb);
548 558
559err2:
560 musb_put_id(&pdev->dev, musbid);
561
549err1: 562err1:
550 kfree(glue); 563 kfree(glue);
551 564
@@ -557,6 +570,7 @@ static int __devexit am35x_remove(struct platform_device *pdev)
557{ 570{
558 struct am35x_glue *glue = platform_get_drvdata(pdev); 571 struct am35x_glue *glue = platform_get_drvdata(pdev);
559 572
573 musb_put_id(&pdev->dev, glue->musb->id);
560 platform_device_del(glue->musb); 574 platform_device_del(glue->musb);
561 platform_device_put(glue->musb); 575 platform_device_put(glue->musb);
562 clk_disable(glue->clk); 576 clk_disable(glue->clk);
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
index 54f1b98b74de..26cc8b7823b7 100644
--- a/drivers/usb/musb/blackfin.c
+++ b/drivers/usb/musb/blackfin.c
@@ -454,6 +454,7 @@ static int __devinit bfin_probe(struct platform_device *pdev)
454 struct bfin_glue *glue; 454 struct bfin_glue *glue;
455 455
456 int ret = -ENOMEM; 456 int ret = -ENOMEM;
457 int musbid;
457 458
458 glue = kzalloc(sizeof(*glue), GFP_KERNEL); 459 glue = kzalloc(sizeof(*glue), GFP_KERNEL);
459 if (!glue) { 460 if (!glue) {
@@ -461,12 +462,21 @@ static int __devinit bfin_probe(struct platform_device *pdev)
461 goto err0; 462 goto err0;
462 } 463 }
463 464
464 musb = platform_device_alloc("musb-hdrc", -1); 465 /* get the musb id */
466 musbid = musb_get_id(&pdev->dev, GFP_KERNEL);
467 if (musbid < 0) {
468 dev_err(&pdev->dev, "failed to allocate musb id\n");
469 ret = -ENOMEM;
470 goto err1;
471 }
472
473 musb = platform_device_alloc("musb-hdrc", musbid);
465 if (!musb) { 474 if (!musb) {
466 dev_err(&pdev->dev, "failed to allocate musb device\n"); 475 dev_err(&pdev->dev, "failed to allocate musb device\n");
467 goto err1; 476 goto err2;
468 } 477 }
469 478
479 musb->id = musbid;
470 musb->dev.parent = &pdev->dev; 480 musb->dev.parent = &pdev->dev;
471 musb->dev.dma_mask = &bfin_dmamask; 481 musb->dev.dma_mask = &bfin_dmamask;
472 musb->dev.coherent_dma_mask = bfin_dmamask; 482 musb->dev.coherent_dma_mask = bfin_dmamask;
@@ -482,26 +492,29 @@ static int __devinit bfin_probe(struct platform_device *pdev)
482 pdev->num_resources); 492 pdev->num_resources);
483 if (ret) { 493 if (ret) {
484 dev_err(&pdev->dev, "failed to add resources\n"); 494 dev_err(&pdev->dev, "failed to add resources\n");
485 goto err2; 495 goto err3;
486 } 496 }
487 497
488 ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); 498 ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
489 if (ret) { 499 if (ret) {
490 dev_err(&pdev->dev, "failed to add platform_data\n"); 500 dev_err(&pdev->dev, "failed to add platform_data\n");
491 goto err2; 501 goto err3;
492 } 502 }
493 503
494 ret = platform_device_add(musb); 504 ret = platform_device_add(musb);
495 if (ret) { 505 if (ret) {
496 dev_err(&pdev->dev, "failed to register musb device\n"); 506 dev_err(&pdev->dev, "failed to register musb device\n");
497 goto err2; 507 goto err3;
498 } 508 }
499 509
500 return 0; 510 return 0;
501 511
502err2: 512err3:
503 platform_device_put(musb); 513 platform_device_put(musb);
504 514
515err2:
516 musb_put_id(&pdev->dev, musbid);
517
505err1: 518err1:
506 kfree(glue); 519 kfree(glue);
507 520
@@ -513,6 +526,7 @@ static int __devexit bfin_remove(struct platform_device *pdev)
513{ 526{
514 struct bfin_glue *glue = platform_get_drvdata(pdev); 527 struct bfin_glue *glue = platform_get_drvdata(pdev);
515 528
529 musb_put_id(&pdev->dev, glue->musb->id);
516 platform_device_del(glue->musb); 530 platform_device_del(glue->musb);
517 platform_device_put(glue->musb); 531 platform_device_put(glue->musb);
518 kfree(glue); 532 kfree(glue);
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index 4e4df9d2eee2..ddb9c9c7b775 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -479,6 +479,7 @@ static int __devinit da8xx_probe(struct platform_device *pdev)
479 struct clk *clk; 479 struct clk *clk;
480 480
481 int ret = -ENOMEM; 481 int ret = -ENOMEM;
482 int musbid;
482 483
483 glue = kzalloc(sizeof(*glue), GFP_KERNEL); 484 glue = kzalloc(sizeof(*glue), GFP_KERNEL);
484 if (!glue) { 485 if (!glue) {
@@ -486,25 +487,34 @@ static int __devinit da8xx_probe(struct platform_device *pdev)
486 goto err0; 487 goto err0;
487 } 488 }
488 489
489 musb = platform_device_alloc("musb-hdrc", -1); 490 /* get the musb id */
491 musbid = musb_get_id(&pdev->dev, GFP_KERNEL);
492 if (musbid < 0) {
493 dev_err(&pdev->dev, "failed to allocate musb id\n");
494 ret = -ENOMEM;
495 goto err1;
496 }
497
498 musb = platform_device_alloc("musb-hdrc", musbid);
490 if (!musb) { 499 if (!musb) {
491 dev_err(&pdev->dev, "failed to allocate musb device\n"); 500 dev_err(&pdev->dev, "failed to allocate musb device\n");
492 goto err1; 501 goto err2;
493 } 502 }
494 503
495 clk = clk_get(&pdev->dev, "usb20"); 504 clk = clk_get(&pdev->dev, "usb20");
496 if (IS_ERR(clk)) { 505 if (IS_ERR(clk)) {
497 dev_err(&pdev->dev, "failed to get clock\n"); 506 dev_err(&pdev->dev, "failed to get clock\n");
498 ret = PTR_ERR(clk); 507 ret = PTR_ERR(clk);
499 goto err2; 508 goto err3;
500 } 509 }
501 510
502 ret = clk_enable(clk); 511 ret = clk_enable(clk);
503 if (ret) { 512 if (ret) {
504 dev_err(&pdev->dev, "failed to enable clock\n"); 513 dev_err(&pdev->dev, "failed to enable clock\n");
505 goto err3; 514 goto err4;
506 } 515 }
507 516
517 musb->id = musbid;
508 musb->dev.parent = &pdev->dev; 518 musb->dev.parent = &pdev->dev;
509 musb->dev.dma_mask = &da8xx_dmamask; 519 musb->dev.dma_mask = &da8xx_dmamask;
510 musb->dev.coherent_dma_mask = da8xx_dmamask; 520 musb->dev.coherent_dma_mask = da8xx_dmamask;
@@ -521,32 +531,35 @@ static int __devinit da8xx_probe(struct platform_device *pdev)
521 pdev->num_resources); 531 pdev->num_resources);
522 if (ret) { 532 if (ret) {
523 dev_err(&pdev->dev, "failed to add resources\n"); 533 dev_err(&pdev->dev, "failed to add resources\n");
524 goto err4; 534 goto err5;
525 } 535 }
526 536
527 ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); 537 ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
528 if (ret) { 538 if (ret) {
529 dev_err(&pdev->dev, "failed to add platform_data\n"); 539 dev_err(&pdev->dev, "failed to add platform_data\n");
530 goto err4; 540 goto err5;
531 } 541 }
532 542
533 ret = platform_device_add(musb); 543 ret = platform_device_add(musb);
534 if (ret) { 544 if (ret) {
535 dev_err(&pdev->dev, "failed to register musb device\n"); 545 dev_err(&pdev->dev, "failed to register musb device\n");
536 goto err4; 546 goto err5;
537 } 547 }
538 548
539 return 0; 549 return 0;
540 550
541err4: 551err5:
542 clk_disable(clk); 552 clk_disable(clk);
543 553
544err3: 554err4:
545 clk_put(clk); 555 clk_put(clk);
546 556
547err2: 557err3:
548 platform_device_put(musb); 558 platform_device_put(musb);
549 559
560err2:
561 musb_put_id(&pdev->dev, musbid);
562
550err1: 563err1:
551 kfree(glue); 564 kfree(glue);
552 565
@@ -558,6 +571,7 @@ static int __devexit da8xx_remove(struct platform_device *pdev)
558{ 571{
559 struct da8xx_glue *glue = platform_get_drvdata(pdev); 572 struct da8xx_glue *glue = platform_get_drvdata(pdev);
560 573
574 musb_put_id(&pdev->dev, glue->musb->id);
561 platform_device_del(glue->musb); 575 platform_device_del(glue->musb);
562 platform_device_put(glue->musb); 576 platform_device_put(glue->musb);
563 clk_disable(glue->clk); 577 clk_disable(glue->clk);
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c
index 8805f809175c..c269e61822c9 100644
--- a/drivers/usb/musb/davinci.c
+++ b/drivers/usb/musb/davinci.c
@@ -511,6 +511,7 @@ static int __devinit davinci_probe(struct platform_device *pdev)
511 struct clk *clk; 511 struct clk *clk;
512 512
513 int ret = -ENOMEM; 513 int ret = -ENOMEM;
514 int musbid;
514 515
515 glue = kzalloc(sizeof(*glue), GFP_KERNEL); 516 glue = kzalloc(sizeof(*glue), GFP_KERNEL);
516 if (!glue) { 517 if (!glue) {
@@ -518,25 +519,34 @@ static int __devinit davinci_probe(struct platform_device *pdev)
518 goto err0; 519 goto err0;
519 } 520 }
520 521
521 musb = platform_device_alloc("musb-hdrc", -1); 522 /* get the musb id */
523 musbid = musb_get_id(&pdev->dev, GFP_KERNEL);
524 if (musbid < 0) {
525 dev_err(&pdev->dev, "failed to allocate musb id\n");
526 ret = -ENOMEM;
527 goto err1;
528 }
529
530 musb = platform_device_alloc("musb-hdrc", musbid);
522 if (!musb) { 531 if (!musb) {
523 dev_err(&pdev->dev, "failed to allocate musb device\n"); 532 dev_err(&pdev->dev, "failed to allocate musb device\n");
524 goto err1; 533 goto err2;
525 } 534 }
526 535
527 clk = clk_get(&pdev->dev, "usb"); 536 clk = clk_get(&pdev->dev, "usb");
528 if (IS_ERR(clk)) { 537 if (IS_ERR(clk)) {
529 dev_err(&pdev->dev, "failed to get clock\n"); 538 dev_err(&pdev->dev, "failed to get clock\n");
530 ret = PTR_ERR(clk); 539 ret = PTR_ERR(clk);
531 goto err2; 540 goto err3;
532 } 541 }
533 542
534 ret = clk_enable(clk); 543 ret = clk_enable(clk);
535 if (ret) { 544 if (ret) {
536 dev_err(&pdev->dev, "failed to enable clock\n"); 545 dev_err(&pdev->dev, "failed to enable clock\n");
537 goto err3; 546 goto err4;
538 } 547 }
539 548
549 musb->id = musbid;
540 musb->dev.parent = &pdev->dev; 550 musb->dev.parent = &pdev->dev;
541 musb->dev.dma_mask = &davinci_dmamask; 551 musb->dev.dma_mask = &davinci_dmamask;
542 musb->dev.coherent_dma_mask = davinci_dmamask; 552 musb->dev.coherent_dma_mask = davinci_dmamask;
@@ -553,32 +563,35 @@ static int __devinit davinci_probe(struct platform_device *pdev)
553 pdev->num_resources); 563 pdev->num_resources);
554 if (ret) { 564 if (ret) {
555 dev_err(&pdev->dev, "failed to add resources\n"); 565 dev_err(&pdev->dev, "failed to add resources\n");
556 goto err4; 566 goto err5;
557 } 567 }
558 568
559 ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); 569 ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
560 if (ret) { 570 if (ret) {
561 dev_err(&pdev->dev, "failed to add platform_data\n"); 571 dev_err(&pdev->dev, "failed to add platform_data\n");
562 goto err4; 572 goto err5;
563 } 573 }
564 574
565 ret = platform_device_add(musb); 575 ret = platform_device_add(musb);
566 if (ret) { 576 if (ret) {
567 dev_err(&pdev->dev, "failed to register musb device\n"); 577 dev_err(&pdev->dev, "failed to register musb device\n");
568 goto err4; 578 goto err5;
569 } 579 }
570 580
571 return 0; 581 return 0;
572 582
573err4: 583err5:
574 clk_disable(clk); 584 clk_disable(clk);
575 585
576err3: 586err4:
577 clk_put(clk); 587 clk_put(clk);
578 588
579err2: 589err3:
580 platform_device_put(musb); 590 platform_device_put(musb);
581 591
592err2:
593 musb_put_id(&pdev->dev, musbid);
594
582err1: 595err1:
583 kfree(glue); 596 kfree(glue);
584 597
@@ -590,6 +603,7 @@ static int __devexit davinci_remove(struct platform_device *pdev)
590{ 603{
591 struct davinci_glue *glue = platform_get_drvdata(pdev); 604 struct davinci_glue *glue = platform_get_drvdata(pdev);
592 605
606 musb_put_id(&pdev->dev, glue->musb->id);
593 platform_device_del(glue->musb); 607 platform_device_del(glue->musb);
594 platform_device_put(glue->musb); 608 platform_device_put(glue->musb);
595 clk_disable(glue->clk); 609 clk_disable(glue->clk);
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 5cacccbc39b5..61b64fced256 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -99,6 +99,7 @@
99#include <linux/prefetch.h> 99#include <linux/prefetch.h>
100#include <linux/platform_device.h> 100#include <linux/platform_device.h>
101#include <linux/io.h> 101#include <linux/io.h>
102#include <linux/idr.h>
102 103
103#include "musb_core.h" 104#include "musb_core.h"
104 105
@@ -114,6 +115,7 @@
114 115
115#define MUSB_DRIVER_NAME "musb-hdrc" 116#define MUSB_DRIVER_NAME "musb-hdrc"
116const char musb_driver_name[] = MUSB_DRIVER_NAME; 117const char musb_driver_name[] = MUSB_DRIVER_NAME;
118static DEFINE_IDA(musb_ida);
117 119
118MODULE_DESCRIPTION(DRIVER_INFO); 120MODULE_DESCRIPTION(DRIVER_INFO);
119MODULE_AUTHOR(DRIVER_AUTHOR); 121MODULE_AUTHOR(DRIVER_AUTHOR);
@@ -130,6 +132,35 @@ static inline struct musb *dev_to_musb(struct device *dev)
130 132
131/*-------------------------------------------------------------------------*/ 133/*-------------------------------------------------------------------------*/
132 134
135int musb_get_id(struct device *dev, gfp_t gfp_mask)
136{
137 int ret;
138 int id;
139
140 ret = ida_pre_get(&musb_ida, gfp_mask);
141 if (!ret) {
142 dev_err(dev, "failed to reserve resource for id\n");
143 return -ENOMEM;
144 }
145
146 ret = ida_get_new(&musb_ida, &id);
147 if (ret < 0) {
148 dev_err(dev, "failed to allocate a new id\n");
149 return ret;
150 }
151
152 return id;
153}
154EXPORT_SYMBOL_GPL(musb_get_id);
155
156void musb_put_id(struct device *dev, int id)
157{
158
159 dev_dbg(dev, "removing id %d\n", id);
160 ida_remove(&musb_ida, id);
161}
162EXPORT_SYMBOL_GPL(musb_put_id);
163
133#ifndef CONFIG_BLACKFIN 164#ifndef CONFIG_BLACKFIN
134static int musb_ulpi_read(struct usb_phy *phy, u32 offset) 165static int musb_ulpi_read(struct usb_phy *phy, u32 offset)
135{ 166{
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index a1a32c6601c7..a69ffd68a9e0 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -517,6 +517,8 @@ extern const char musb_driver_name[];
517 517
518extern void musb_start(struct musb *musb); 518extern void musb_start(struct musb *musb);
519extern void musb_stop(struct musb *musb); 519extern void musb_stop(struct musb *musb);
520extern int musb_get_id(struct device *dev, gfp_t gfp_mask);
521extern void musb_put_id(struct device *dev, int id);
520 522
521extern void musb_write_fifo(struct musb_hw_ep *ep, u16 len, const u8 *src); 523extern void musb_write_fifo(struct musb_hw_ep *ep, u16 len, const u8 *src);
522extern void musb_read_fifo(struct musb_hw_ep *ep, u16 len, u8 *dst); 524extern void musb_read_fifo(struct musb_hw_ep *ep, u16 len, u8 *dst);
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index 51ff1bbff381..5351e960d650 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -448,7 +448,7 @@ static int __devinit dsps_create_musb_pdev(struct dsps_glue *glue, u8 id)
448 struct resource *res; 448 struct resource *res;
449 struct resource resources[2]; 449 struct resource resources[2];
450 char res_name[10]; 450 char res_name[10];
451 int ret; 451 int ret, musbid;
452 452
453 /* get memory resource */ 453 /* get memory resource */
454 sprintf(res_name, "musb%d", id); 454 sprintf(res_name, "musb%d", id);
@@ -473,14 +473,22 @@ static int __devinit dsps_create_musb_pdev(struct dsps_glue *glue, u8 id)
473 res->parent = NULL; 473 res->parent = NULL;
474 resources[1] = *res; 474 resources[1] = *res;
475 475
476 /* get the musb id */
477 musbid = musb_get_id(dev, GFP_KERNEL);
478 if (musbid < 0) {
479 dev_err(dev, "failed to allocate musb id\n");
480 ret = -ENOMEM;
481 goto err0;
482 }
476 /* allocate the child platform device */ 483 /* allocate the child platform device */
477 musb = platform_device_alloc("musb-hdrc", -1); 484 musb = platform_device_alloc("musb-hdrc", musbid);
478 if (!musb) { 485 if (!musb) {
479 dev_err(dev, "failed to allocate musb device\n"); 486 dev_err(dev, "failed to allocate musb device\n");
480 ret = -ENOMEM; 487 ret = -ENOMEM;
481 goto err0; 488 goto err1;
482 } 489 }
483 490
491 musb->id = musbid;
484 musb->dev.parent = dev; 492 musb->dev.parent = dev;
485 musb->dev.dma_mask = &musb_dmamask; 493 musb->dev.dma_mask = &musb_dmamask;
486 musb->dev.coherent_dma_mask = musb_dmamask; 494 musb->dev.coherent_dma_mask = musb_dmamask;
@@ -492,31 +500,34 @@ static int __devinit dsps_create_musb_pdev(struct dsps_glue *glue, u8 id)
492 ret = platform_device_add_resources(musb, resources, 2); 500 ret = platform_device_add_resources(musb, resources, 2);
493 if (ret) { 501 if (ret) {
494 dev_err(dev, "failed to add resources\n"); 502 dev_err(dev, "failed to add resources\n");
495 goto err1; 503 goto err2;
496 } 504 }
497 505
498 ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); 506 ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
499 if (ret) { 507 if (ret) {
500 dev_err(dev, "failed to add platform_data\n"); 508 dev_err(dev, "failed to add platform_data\n");
501 goto err1; 509 goto err2;
502 } 510 }
503 511
504 ret = platform_device_add(musb); 512 ret = platform_device_add(musb);
505 if (ret) { 513 if (ret) {
506 dev_err(dev, "failed to register musb device\n"); 514 dev_err(dev, "failed to register musb device\n");
507 goto err1; 515 goto err2;
508 } 516 }
509 517
510 return 0; 518 return 0;
511 519
512err1: 520err2:
513 platform_device_put(musb); 521 platform_device_put(musb);
522err1:
523 musb_put_id(dev, musbid);
514err0: 524err0:
515 return ret; 525 return ret;
516} 526}
517 527
518static void __devexit dsps_delete_musb_pdev(struct dsps_glue *glue) 528static void __devexit dsps_delete_musb_pdev(struct dsps_glue *glue)
519{ 529{
530 musb_put_id(glue->dev, glue->musb->id);
520 platform_device_del(glue->musb); 531 platform_device_del(glue->musb);
521 platform_device_put(glue->musb); 532 platform_device_put(glue->musb);
522} 533}
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index d96873ba97c7..a538fe17a966 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -478,6 +478,7 @@ static int __devinit omap2430_probe(struct platform_device *pdev)
478 struct musb_hdrc_config *config; 478 struct musb_hdrc_config *config;
479 struct resource *res; 479 struct resource *res;
480 int ret = -ENOMEM; 480 int ret = -ENOMEM;
481 int musbid;
481 482
482 glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL); 483 glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL);
483 if (!glue) { 484 if (!glue) {
@@ -485,12 +486,21 @@ static int __devinit omap2430_probe(struct platform_device *pdev)
485 goto err0; 486 goto err0;
486 } 487 }
487 488
488 musb = platform_device_alloc("musb-hdrc", -1); 489 /* get the musb id */
490 musbid = musb_get_id(&pdev->dev, GFP_KERNEL);
491 if (musbid < 0) {
492 dev_err(&pdev->dev, "failed to allocate musb id\n");
493 ret = -ENOMEM;
494 goto err0;
495 }
496
497 musb = platform_device_alloc("musb-hdrc", musbid);
489 if (!musb) { 498 if (!musb) {
490 dev_err(&pdev->dev, "failed to allocate musb device\n"); 499 dev_err(&pdev->dev, "failed to allocate musb device\n");
491 goto err0; 500 goto err1;
492 } 501 }
493 502
503 musb->id = musbid;
494 musb->dev.parent = &pdev->dev; 504 musb->dev.parent = &pdev->dev;
495 musb->dev.dma_mask = &omap2430_dmamask; 505 musb->dev.dma_mask = &omap2430_dmamask;
496 musb->dev.coherent_dma_mask = omap2430_dmamask; 506 musb->dev.coherent_dma_mask = omap2430_dmamask;
@@ -557,13 +567,13 @@ static int __devinit omap2430_probe(struct platform_device *pdev)
557 pdev->num_resources); 567 pdev->num_resources);
558 if (ret) { 568 if (ret) {
559 dev_err(&pdev->dev, "failed to add resources\n"); 569 dev_err(&pdev->dev, "failed to add resources\n");
560 goto err1; 570 goto err2;
561 } 571 }
562 572
563 ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); 573 ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
564 if (ret) { 574 if (ret) {
565 dev_err(&pdev->dev, "failed to add platform_data\n"); 575 dev_err(&pdev->dev, "failed to add platform_data\n");
566 goto err1; 576 goto err2;
567 } 577 }
568 578
569 pm_runtime_enable(&pdev->dev); 579 pm_runtime_enable(&pdev->dev);
@@ -571,14 +581,17 @@ static int __devinit omap2430_probe(struct platform_device *pdev)
571 ret = platform_device_add(musb); 581 ret = platform_device_add(musb);
572 if (ret) { 582 if (ret) {
573 dev_err(&pdev->dev, "failed to register musb device\n"); 583 dev_err(&pdev->dev, "failed to register musb device\n");
574 goto err1; 584 goto err2;
575 } 585 }
576 586
577 return 0; 587 return 0;
578 588
579err1: 589err2:
580 platform_device_put(musb); 590 platform_device_put(musb);
581 591
592err1:
593 musb_put_id(&pdev->dev, musbid);
594
582err0: 595err0:
583 return ret; 596 return ret;
584} 597}
@@ -588,6 +601,7 @@ static int __devexit omap2430_remove(struct platform_device *pdev)
588 struct omap2430_glue *glue = platform_get_drvdata(pdev); 601 struct omap2430_glue *glue = platform_get_drvdata(pdev);
589 602
590 cancel_work_sync(&glue->omap_musb_mailbox_work); 603 cancel_work_sync(&glue->omap_musb_mailbox_work);
604 musb_put_id(&pdev->dev, glue->musb->id);
591 platform_device_unregister(glue->musb); 605 platform_device_unregister(glue->musb);
592 606
593 return 0; 607 return 0;
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index 1d0c090be78c..878655f757e3 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -1159,6 +1159,7 @@ static int __devinit tusb_probe(struct platform_device *pdev)
1159 struct tusb6010_glue *glue; 1159 struct tusb6010_glue *glue;
1160 1160
1161 int ret = -ENOMEM; 1161 int ret = -ENOMEM;
1162 int musbid;
1162 1163
1163 glue = kzalloc(sizeof(*glue), GFP_KERNEL); 1164 glue = kzalloc(sizeof(*glue), GFP_KERNEL);
1164 if (!glue) { 1165 if (!glue) {
@@ -1166,12 +1167,21 @@ static int __devinit tusb_probe(struct platform_device *pdev)
1166 goto err0; 1167 goto err0;
1167 } 1168 }
1168 1169
1169 musb = platform_device_alloc("musb-hdrc", -1); 1170 /* get the musb id */
1171 musbid = musb_get_id(&pdev->dev, GFP_KERNEL);
1172 if (musbid < 0) {
1173 dev_err(&pdev->dev, "failed to allocate musb id\n");
1174 ret = -ENOMEM;
1175 goto err1;
1176 }
1177
1178 musb = platform_device_alloc("musb-hdrc", musbid);
1170 if (!musb) { 1179 if (!musb) {
1171 dev_err(&pdev->dev, "failed to allocate musb device\n"); 1180 dev_err(&pdev->dev, "failed to allocate musb device\n");
1172 goto err1; 1181 goto err2;
1173 } 1182 }
1174 1183
1184 musb->id = musbid;
1175 musb->dev.parent = &pdev->dev; 1185 musb->dev.parent = &pdev->dev;
1176 musb->dev.dma_mask = &tusb_dmamask; 1186 musb->dev.dma_mask = &tusb_dmamask;
1177 musb->dev.coherent_dma_mask = tusb_dmamask; 1187 musb->dev.coherent_dma_mask = tusb_dmamask;
@@ -1187,26 +1197,29 @@ static int __devinit tusb_probe(struct platform_device *pdev)
1187 pdev->num_resources); 1197 pdev->num_resources);
1188 if (ret) { 1198 if (ret) {
1189 dev_err(&pdev->dev, "failed to add resources\n"); 1199 dev_err(&pdev->dev, "failed to add resources\n");
1190 goto err2; 1200 goto err3;
1191 } 1201 }
1192 1202
1193 ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); 1203 ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
1194 if (ret) { 1204 if (ret) {
1195 dev_err(&pdev->dev, "failed to add platform_data\n"); 1205 dev_err(&pdev->dev, "failed to add platform_data\n");
1196 goto err2; 1206 goto err3;
1197 } 1207 }
1198 1208
1199 ret = platform_device_add(musb); 1209 ret = platform_device_add(musb);
1200 if (ret) { 1210 if (ret) {
1201 dev_err(&pdev->dev, "failed to register musb device\n"); 1211 dev_err(&pdev->dev, "failed to register musb device\n");
1202 goto err1; 1212 goto err3;
1203 } 1213 }
1204 1214
1205 return 0; 1215 return 0;
1206 1216
1207err2: 1217err3:
1208 platform_device_put(musb); 1218 platform_device_put(musb);
1209 1219
1220err2:
1221 musb_put_id(&pdev->dev, musbid);
1222
1210err1: 1223err1:
1211 kfree(glue); 1224 kfree(glue);
1212 1225
@@ -1218,6 +1231,7 @@ static int __devexit tusb_remove(struct platform_device *pdev)
1218{ 1231{
1219 struct tusb6010_glue *glue = platform_get_drvdata(pdev); 1232 struct tusb6010_glue *glue = platform_get_drvdata(pdev);
1220 1233
1234 musb_put_id(&pdev->dev, glue->musb->id);
1221 platform_device_del(glue->musb); 1235 platform_device_del(glue->musb);
1222 platform_device_put(glue->musb); 1236 platform_device_put(glue->musb);
1223 kfree(glue); 1237 kfree(glue);
diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c
index a8c0fadce1b0..d62a91fedc22 100644
--- a/drivers/usb/musb/ux500.c
+++ b/drivers/usb/musb/ux500.c
@@ -74,25 +74,34 @@ static int __devinit ux500_probe(struct platform_device *pdev)
74 goto err0; 74 goto err0;
75 } 75 }
76 76
77 musb = platform_device_alloc("musb-hdrc", -1); 77 /* get the musb id */
78 musbid = musb_get_id(&pdev->dev, GFP_KERNEL);
79 if (musbid < 0) {
80 dev_err(&pdev->dev, "failed to allocate musb id\n");
81 ret = -ENOMEM;
82 goto err1;
83 }
84
85 musb = platform_device_alloc("musb-hdrc", musbid);
78 if (!musb) { 86 if (!musb) {
79 dev_err(&pdev->dev, "failed to allocate musb device\n"); 87 dev_err(&pdev->dev, "failed to allocate musb device\n");
80 goto err1; 88 goto err2;
81 } 89 }
82 90
83 clk = clk_get(&pdev->dev, "usb"); 91 clk = clk_get(&pdev->dev, "usb");
84 if (IS_ERR(clk)) { 92 if (IS_ERR(clk)) {
85 dev_err(&pdev->dev, "failed to get clock\n"); 93 dev_err(&pdev->dev, "failed to get clock\n");
86 ret = PTR_ERR(clk); 94 ret = PTR_ERR(clk);
87 goto err2; 95 goto err3;
88 } 96 }
89 97
90 ret = clk_enable(clk); 98 ret = clk_enable(clk);
91 if (ret) { 99 if (ret) {
92 dev_err(&pdev->dev, "failed to enable clock\n"); 100 dev_err(&pdev->dev, "failed to enable clock\n");
93 goto err3; 101 goto err4;
94 } 102 }
95 103
104 musb->id = musbid;
96 musb->dev.parent = &pdev->dev; 105 musb->dev.parent = &pdev->dev;
97 musb->dev.dma_mask = pdev->dev.dma_mask; 106 musb->dev.dma_mask = pdev->dev.dma_mask;
98 musb->dev.coherent_dma_mask = pdev->dev.coherent_dma_mask; 107 musb->dev.coherent_dma_mask = pdev->dev.coherent_dma_mask;
@@ -109,32 +118,35 @@ static int __devinit ux500_probe(struct platform_device *pdev)
109 pdev->num_resources); 118 pdev->num_resources);
110 if (ret) { 119 if (ret) {
111 dev_err(&pdev->dev, "failed to add resources\n"); 120 dev_err(&pdev->dev, "failed to add resources\n");
112 goto err4; 121 goto err5;
113 } 122 }
114 123
115 ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); 124 ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
116 if (ret) { 125 if (ret) {
117 dev_err(&pdev->dev, "failed to add platform_data\n"); 126 dev_err(&pdev->dev, "failed to add platform_data\n");
118 goto err4; 127 goto err5;
119 } 128 }
120 129
121 ret = platform_device_add(musb); 130 ret = platform_device_add(musb);
122 if (ret) { 131 if (ret) {
123 dev_err(&pdev->dev, "failed to register musb device\n"); 132 dev_err(&pdev->dev, "failed to register musb device\n");
124 goto err4; 133 goto err5;
125 } 134 }
126 135
127 return 0; 136 return 0;
128 137
129err4: 138err5:
130 clk_disable(clk); 139 clk_disable(clk);
131 140
132err3: 141err4:
133 clk_put(clk); 142 clk_put(clk);
134 143
135err2: 144err3:
136 platform_device_put(musb); 145 platform_device_put(musb);
137 146
147err2:
148 musb_put_id(&pdev->dev, musbid);
149
138err1: 150err1:
139 kfree(glue); 151 kfree(glue);
140 152
@@ -146,6 +158,7 @@ static int __devexit ux500_remove(struct platform_device *pdev)
146{ 158{
147 struct ux500_glue *glue = platform_get_drvdata(pdev); 159 struct ux500_glue *glue = platform_get_drvdata(pdev);
148 160
161 musb_put_id(&pdev->dev, glue->musb->id);
149 platform_device_del(glue->musb); 162 platform_device_del(glue->musb);
150 platform_device_put(glue->musb); 163 platform_device_put(glue->musb);
151 clk_disable(glue->clk); 164 clk_disable(glue->clk);