aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb/da8xx.c
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/da8xx.c
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/da8xx.c')
-rw-r--r--drivers/usb/musb/da8xx.c34
1 files changed, 24 insertions, 10 deletions
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);