aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb/am35x.c
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2010-12-02 02:33:24 -0500
committerFelipe Balbi <balbi@ti.com>2010-12-10 03:21:18 -0500
commit0919dfc12a43d5ea21411e67984c268e84d05204 (patch)
tree25b72ff88cb275efa6b25ac34d5d9f05f5540b94 /drivers/usb/musb/am35x.c
parenta3cee12aa9129b576c5403a31e37d0e0113235b3 (diff)
usb: musb: am35x: give it a context structure
that structure currently only holds a device pointer to our own platform_device and musb's platform_device, but soon it will hold pointers to our clock structures and glue-specific bits and pieces. Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/musb/am35x.c')
-rw-r--r--drivers/usb/musb/am35x.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
index 0ae01f57b3df..355883c5ffed 100644
--- a/drivers/usb/musb/am35x.c
+++ b/drivers/usb/musb/am35x.c
@@ -82,6 +82,11 @@
82 82
83#define USB_MENTOR_CORE_OFFSET 0x400 83#define USB_MENTOR_CORE_OFFSET 0x400
84 84
85struct am35x_glue {
86 struct device *dev;
87 struct platform_device *musb;
88};
89
85static inline void phy_on(void) 90static inline void phy_on(void)
86{ 91{
87 unsigned long timeout = jiffies + msecs_to_jiffies(100); 92 unsigned long timeout = jiffies + msecs_to_jiffies(100);
@@ -544,55 +549,69 @@ static int __init am35x_probe(struct platform_device *pdev)
544{ 549{
545 struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; 550 struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data;
546 struct platform_device *musb; 551 struct platform_device *musb;
552 struct am35x_glue *glue;
547 553
548 int ret = -ENOMEM; 554 int ret = -ENOMEM;
549 555
556 glue = kzalloc(sizeof(*glue), GFP_KERNEL);
557 if (!glue) {
558 dev_err(&pdev->dev, "failed to allocate glue context\n");
559 goto err0;
560 }
561
550 musb = platform_device_alloc("musb-hdrc", -1); 562 musb = platform_device_alloc("musb-hdrc", -1);
551 if (!musb) { 563 if (!musb) {
552 dev_err(&pdev->dev, "failed to allocate musb device\n"); 564 dev_err(&pdev->dev, "failed to allocate musb device\n");
553 goto err0; 565 goto err1;
554 } 566 }
555 567
556 musb->dev.parent = &pdev->dev; 568 musb->dev.parent = &pdev->dev;
557 musb->dev.dma_mask = &am35x_dmamask; 569 musb->dev.dma_mask = &am35x_dmamask;
558 musb->dev.coherent_dma_mask = am35x_dmamask; 570 musb->dev.coherent_dma_mask = am35x_dmamask;
559 571
560 platform_set_drvdata(pdev, musb); 572 glue->dev = &pdev->dev;
573 glue->musb = musb;
574
575 platform_set_drvdata(pdev, glue);
561 576
562 ret = platform_device_add_resources(musb, pdev->resource, 577 ret = platform_device_add_resources(musb, pdev->resource,
563 pdev->num_resources); 578 pdev->num_resources);
564 if (ret) { 579 if (ret) {
565 dev_err(&pdev->dev, "failed to add resources\n"); 580 dev_err(&pdev->dev, "failed to add resources\n");
566 goto err1; 581 goto err2;
567 } 582 }
568 583
569 ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); 584 ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
570 if (ret) { 585 if (ret) {
571 dev_err(&pdev->dev, "failed to add platform_data\n"); 586 dev_err(&pdev->dev, "failed to add platform_data\n");
572 goto err1; 587 goto err2;
573 } 588 }
574 589
575 ret = platform_device_add(musb); 590 ret = platform_device_add(musb);
576 if (ret) { 591 if (ret) {
577 dev_err(&pdev->dev, "failed to register musb device\n"); 592 dev_err(&pdev->dev, "failed to register musb device\n");
578 goto err1; 593 goto err2;
579 } 594 }
580 595
581 return 0; 596 return 0;
582 597
583err1: 598err2:
584 platform_device_put(musb); 599 platform_device_put(musb);
585 600
601err1:
602 kfree(glue);
603
586err0: 604err0:
587 return ret; 605 return ret;
588} 606}
589 607
590static int __exit am35x_remove(struct platform_device *pdev) 608static int __exit am35x_remove(struct platform_device *pdev)
591{ 609{
592 struct platform_device *musb = platform_get_drvdata(pdev); 610 struct am35x_glue *glue = platform_get_drvdata(pdev);
593 611
594 platform_device_del(musb); 612 platform_device_del(glue->musb);
595 platform_device_put(musb); 613 platform_device_put(glue->musb);
614 kfree(glue);
596 615
597 return 0; 616 return 0;
598} 617}