aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb/davinci.c
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2010-12-02 02:38:12 -0500
committerFelipe Balbi <balbi@ti.com>2010-12-10 03:21:20 -0500
commite110de4d5358f2e67c333d23d608cbabe26b6220 (patch)
treef4e57f2f3dff20fc30c02451ecc81c919c8a8023 /drivers/usb/musb/davinci.c
parent1add75d2bd1a44553e2c40e30db5f90a500dc1ab (diff)
usb: musb: davinci: 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/davinci.c')
-rw-r--r--drivers/usb/musb/davinci.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c
index bdf1940d6fee..661870a1cd4d 100644
--- a/drivers/usb/musb/davinci.c
+++ b/drivers/usb/musb/davinci.c
@@ -53,6 +53,11 @@
53#define USB_PHY_CTRL IO_ADDRESS(USBPHY_CTL_PADDR) 53#define USB_PHY_CTRL IO_ADDRESS(USBPHY_CTL_PADDR)
54#define DM355_DEEPSLEEP IO_ADDRESS(DM355_DEEPSLEEP_PADDR) 54#define DM355_DEEPSLEEP IO_ADDRESS(DM355_DEEPSLEEP_PADDR)
55 55
56struct davinci_glue {
57 struct device *dev;
58 struct platform_device *musb;
59};
60
56/* REVISIT (PM) we should be able to keep the PHY in low power mode most 61/* REVISIT (PM) we should be able to keep the PHY in low power mode most
57 * of the time (24 MHZ oscillator and PLL off, etc) by setting POWER.D0 62 * of the time (24 MHZ oscillator and PLL off, etc) by setting POWER.D0
58 * and, when in host mode, autosuspending idle root ports... PHYPLLON 63 * and, when in host mode, autosuspending idle root ports... PHYPLLON
@@ -523,55 +528,69 @@ static int __init davinci_probe(struct platform_device *pdev)
523{ 528{
524 struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; 529 struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data;
525 struct platform_device *musb; 530 struct platform_device *musb;
531 struct davinci_glue *glue;
526 532
527 int ret = -ENOMEM; 533 int ret = -ENOMEM;
528 534
535 glue = kzalloc(sizeof(*glue), GFP_KERNEL);
536 if (!glue) {
537 dev_err(&pdev->dev, "failed to allocate glue context\n");
538 goto err0;
539 }
540
529 musb = platform_device_alloc("musb-hdrc", -1); 541 musb = platform_device_alloc("musb-hdrc", -1);
530 if (!musb) { 542 if (!musb) {
531 dev_err(&pdev->dev, "failed to allocate musb device\n"); 543 dev_err(&pdev->dev, "failed to allocate musb device\n");
532 goto err0; 544 goto err1;
533 } 545 }
534 546
535 musb->dev.parent = &pdev->dev; 547 musb->dev.parent = &pdev->dev;
536 musb->dev.dma_mask = &davinci_dmamask; 548 musb->dev.dma_mask = &davinci_dmamask;
537 musb->dev.coherent_dma_mask = davinci_dmamask; 549 musb->dev.coherent_dma_mask = davinci_dmamask;
538 550
539 platform_set_drvdata(pdev, musb); 551 glue->dev = &pdev->dev;
552 glue->musb = musb;
553
554 platform_set_drvdata(pdev, glue);
540 555
541 ret = platform_device_add_resources(musb, pdev->resource, 556 ret = platform_device_add_resources(musb, pdev->resource,
542 pdev->num_resources); 557 pdev->num_resources);
543 if (ret) { 558 if (ret) {
544 dev_err(&pdev->dev, "failed to add resources\n"); 559 dev_err(&pdev->dev, "failed to add resources\n");
545 goto err1; 560 goto err2;
546 } 561 }
547 562
548 ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); 563 ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
549 if (ret) { 564 if (ret) {
550 dev_err(&pdev->dev, "failed to add platform_data\n"); 565 dev_err(&pdev->dev, "failed to add platform_data\n");
551 goto err1; 566 goto err2;
552 } 567 }
553 568
554 ret = platform_device_add(musb); 569 ret = platform_device_add(musb);
555 if (ret) { 570 if (ret) {
556 dev_err(&pdev->dev, "failed to register musb device\n"); 571 dev_err(&pdev->dev, "failed to register musb device\n");
557 goto err1; 572 goto err2;
558 } 573 }
559 574
560 return 0; 575 return 0;
561 576
562err1: 577err2:
563 platform_device_put(musb); 578 platform_device_put(musb);
564 579
580err1:
581 kfree(glue);
582
565err0: 583err0:
566 return ret; 584 return ret;
567} 585}
568 586
569static int __exit davinci_remove(struct platform_device *pdev) 587static int __exit davinci_remove(struct platform_device *pdev)
570{ 588{
571 struct platform_device *musb = platform_get_drvdata(pdev); 589 struct davinci_glue *glue = platform_get_drvdata(pdev);
572 590
573 platform_device_del(musb); 591 platform_device_del(glue->musb);
574 platform_device_put(musb); 592 platform_device_put(glue->musb);
593 kfree(glue);
575 594
576 return 0; 595 return 0;
577} 596}