diff options
author | B, Ravi <ravibabu@ti.com> | 2012-08-31 07:09:49 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2012-09-11 10:34:41 -0400 |
commit | 65b3d52d02a558fbfe08e43688e15390c5ab3067 (patch) | |
tree | 0082a0e45c26ff015a7b0976e917c83d87db8e70 /drivers/usb/musb/davinci.c | |
parent | 00a0b1d58af873d842580dcac55f3b156c3a4077 (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/davinci.c')
-rw-r--r-- | drivers/usb/musb/davinci.c | 34 |
1 files changed, 24 insertions, 10 deletions
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 | ||
573 | err4: | 583 | err5: |
574 | clk_disable(clk); | 584 | clk_disable(clk); |
575 | 585 | ||
576 | err3: | 586 | err4: |
577 | clk_put(clk); | 587 | clk_put(clk); |
578 | 588 | ||
579 | err2: | 589 | err3: |
580 | platform_device_put(musb); | 590 | platform_device_put(musb); |
581 | 591 | ||
592 | err2: | ||
593 | musb_put_id(&pdev->dev, musbid); | ||
594 | |||
582 | err1: | 595 | err1: |
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); |