aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2010-12-02 02:40:34 -0500
committerFelipe Balbi <balbi@ti.com>2010-12-10 03:21:21 -0500
commite6480faa1067af91ab403fd3aaf6db2fe1134b13 (patch)
treea9f1d5ffe63228016baa0f752e1c5a9fa804132b
parente110de4d5358f2e67c333d23d608cbabe26b6220 (diff)
usb: musb: da8xx: 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>
-rw-r--r--drivers/usb/musb/da8xx.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index b80b7da44727..94ddfe01d673 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -80,6 +80,11 @@
80 80
81#define CFGCHIP2 IO_ADDRESS(DA8XX_SYSCFG0_BASE + DA8XX_CFGCHIP2_REG) 81#define CFGCHIP2 IO_ADDRESS(DA8XX_SYSCFG0_BASE + DA8XX_CFGCHIP2_REG)
82 82
83struct da8xx_glue {
84 struct device *dev;
85 struct platform_device *musb;
86};
87
83/* 88/*
84 * REVISIT (PM): we should be able to keep the PHY in low power mode most 89 * REVISIT (PM): we should be able to keep the PHY in low power mode most
85 * of the time (24 MHz oscillator and PLL off, etc.) by setting POWER.D0 90 * of the time (24 MHz oscillator and PLL off, etc.) by setting POWER.D0
@@ -489,55 +494,69 @@ static int __init da8xx_probe(struct platform_device *pdev)
489{ 494{
490 struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; 495 struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data;
491 struct platform_device *musb; 496 struct platform_device *musb;
497 struct da8xx_glue *glue;
492 498
493 int ret = -ENOMEM; 499 int ret = -ENOMEM;
494 500
501 glue = kzalloc(sizeof(*glue), GFP_KERNEL);
502 if (!glue) {
503 dev_err(&pdev->dev, "failed to allocate glue context\n");
504 goto err0;
505 }
506
495 musb = platform_device_alloc("musb-hdrc", -1); 507 musb = platform_device_alloc("musb-hdrc", -1);
496 if (!musb) { 508 if (!musb) {
497 dev_err(&pdev->dev, "failed to allocate musb device\n"); 509 dev_err(&pdev->dev, "failed to allocate musb device\n");
498 goto err0; 510 goto err1;
499 } 511 }
500 512
501 musb->dev.parent = &pdev->dev; 513 musb->dev.parent = &pdev->dev;
502 musb->dev.dma_mask = &da8xx_dmamask; 514 musb->dev.dma_mask = &da8xx_dmamask;
503 musb->dev.coherent_dma_mask = da8xx_dmamask; 515 musb->dev.coherent_dma_mask = da8xx_dmamask;
504 516
505 platform_set_drvdata(pdev, musb); 517 glue->dev = &pdev->dev;
518 glue->musb = musb;
519
520 platform_set_drvdata(pdev, glue);
506 521
507 ret = platform_device_add_resources(musb, pdev->resource, 522 ret = platform_device_add_resources(musb, pdev->resource,
508 pdev->num_resources); 523 pdev->num_resources);
509 if (ret) { 524 if (ret) {
510 dev_err(&pdev->dev, "failed to add resources\n"); 525 dev_err(&pdev->dev, "failed to add resources\n");
511 goto err1; 526 goto err2;
512 } 527 }
513 528
514 ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); 529 ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
515 if (ret) { 530 if (ret) {
516 dev_err(&pdev->dev, "failed to add platform_data\n"); 531 dev_err(&pdev->dev, "failed to add platform_data\n");
517 goto err1; 532 goto err2;
518 } 533 }
519 534
520 ret = platform_device_add(musb); 535 ret = platform_device_add(musb);
521 if (ret) { 536 if (ret) {
522 dev_err(&pdev->dev, "failed to register musb device\n"); 537 dev_err(&pdev->dev, "failed to register musb device\n");
523 goto err1; 538 goto err2;
524 } 539 }
525 540
526 return 0; 541 return 0;
527 542
528err1: 543err2:
529 platform_device_put(musb); 544 platform_device_put(musb);
530 545
546err1:
547 kfree(glue);
548
531err0: 549err0:
532 return ret; 550 return ret;
533} 551}
534 552
535static int __exit da8xx_remove(struct platform_device *pdev) 553static int __exit da8xx_remove(struct platform_device *pdev)
536{ 554{
537 struct platform_device *musb = platform_get_drvdata(pdev); 555 struct da8xx_glue *glue = platform_get_drvdata(pdev);
538 556
539 platform_device_del(musb); 557 platform_device_del(glue->musb);
540 platform_device_put(musb); 558 platform_device_put(glue->musb);
559 kfree(glue);
541 560
542 return 0; 561 return 0;
543} 562}