aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb/musb_dsps.c
diff options
context:
space:
mode:
authorAjay Kumar Gupta <ajay.gupta@ti.com>2012-08-31 07:09:53 -0400
committerFelipe Balbi <balbi@ti.com>2012-09-11 10:36:17 -0400
commit65145677a65c31a8fd2704e244801bdb11061f9a (patch)
treeec41e085649faa01566739f7bfcd22af3e4aaead /drivers/usb/musb/musb_dsps.c
parentdb4a93202e086dbdb5789149666dbbff48f708bf (diff)
usb: musb: dsps: add dt support
Added device tree support for dsps musb glue driver and updated the Documentation with device tree binding information. Signed-off-by: Ajay Kumar Gupta <ajay.gupta@ti.com> Signed-off-by: Santhapuri, Damodar <damodar.santhapuri@ti.com> Signed-off-by: Ravi Babu <ravibabu@ti.com> [afzal@ti.com: use '-' instead of '_' for dt properties] Signed-off-by: Afzal Mohammed <afzal@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/musb/musb_dsps.c')
-rw-r--r--drivers/usb/musb/musb_dsps.c60
1 files changed, 51 insertions, 9 deletions
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index 796fc6085fce..b8aecbba7407 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -31,6 +31,7 @@
31 31
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/io.h> 33#include <linux/io.h>
34#include <linux/of.h>
34#include <linux/err.h> 35#include <linux/err.h>
35#include <linux/platform_device.h> 36#include <linux/platform_device.h>
36#include <linux/dma-mapping.h> 37#include <linux/dma-mapping.h>
@@ -45,6 +46,10 @@
45 46
46#include "musb_core.h" 47#include "musb_core.h"
47 48
49#ifdef CONFIG_OF
50static const struct of_device_id musb_dsps_of_match[];
51#endif
52
48/** 53/**
49 * avoid using musb_readx()/musb_writex() as glue layer should not be 54 * avoid using musb_readx()/musb_writex() as glue layer should not be
50 * dependent on musb core layer symbols. 55 * dependent on musb core layer symbols.
@@ -448,6 +453,8 @@ static int __devinit dsps_create_musb_pdev(struct dsps_glue *glue, u8 id)
448 struct device *dev = glue->dev; 453 struct device *dev = glue->dev;
449 struct platform_device *pdev = to_platform_device(dev); 454 struct platform_device *pdev = to_platform_device(dev);
450 struct musb_hdrc_platform_data *pdata = dev->platform_data; 455 struct musb_hdrc_platform_data *pdata = dev->platform_data;
456 struct device_node *np = pdev->dev.of_node;
457 struct musb_hdrc_config *config;
451 struct platform_device *musb; 458 struct platform_device *musb;
452 struct resource *res; 459 struct resource *res;
453 struct resource resources[2]; 460 struct resource resources[2];
@@ -499,14 +506,40 @@ static int __devinit dsps_create_musb_pdev(struct dsps_glue *glue, u8 id)
499 506
500 glue->musb[id] = musb; 507 glue->musb[id] = musb;
501 508
502 pdata->platform_ops = &dsps_ops;
503
504 ret = platform_device_add_resources(musb, resources, 2); 509 ret = platform_device_add_resources(musb, resources, 2);
505 if (ret) { 510 if (ret) {
506 dev_err(dev, "failed to add resources\n"); 511 dev_err(dev, "failed to add resources\n");
507 goto err2; 512 goto err2;
508 } 513 }
509 514
515 if (np) {
516 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
517 if (!pdata) {
518 dev_err(&pdev->dev,
519 "failed to allocate musb platfrom data\n");
520 ret = -ENOMEM;
521 goto err2;
522 }
523
524 config = devm_kzalloc(&pdev->dev, sizeof(*config), GFP_KERNEL);
525 if (!config) {
526 dev_err(&pdev->dev,
527 "failed to allocate musb hdrc config\n");
528 goto err2;
529 }
530
531 of_property_read_u32(np, "num-eps", (u32 *)&config->num_eps);
532 of_property_read_u32(np, "ram-bits", (u32 *)&config->ram_bits);
533 sprintf(res_name, "port%d-mode", id);
534 of_property_read_u32(np, res_name, (u32 *)&pdata->mode);
535 of_property_read_u32(np, "power", (u32 *)&pdata->power);
536 config->multipoint = of_property_read_bool(np, "multipoint");
537
538 pdata->config = config;
539 }
540
541 pdata->platform_ops = &dsps_ops;
542
510 ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); 543 ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
511 if (ret) { 544 if (ret) {
512 dev_err(dev, "failed to add platform_data\n"); 545 dev_err(dev, "failed to add platform_data\n");
@@ -538,13 +571,21 @@ static void dsps_delete_musb_pdev(struct dsps_glue *glue, u8 id)
538 571
539static int __devinit dsps_probe(struct platform_device *pdev) 572static int __devinit dsps_probe(struct platform_device *pdev)
540{ 573{
541 const struct platform_device_id *id = platform_get_device_id(pdev); 574 struct device_node *np = pdev->dev.of_node;
542 const struct dsps_musb_wrapper *wrp = 575 const struct of_device_id *match;
543 (struct dsps_musb_wrapper *)id->driver_data; 576 const struct dsps_musb_wrapper *wrp;
544 struct dsps_glue *glue; 577 struct dsps_glue *glue;
545 struct resource *iomem; 578 struct resource *iomem;
546 int ret, i; 579 int ret, i;
547 580
581 match = of_match_node(musb_dsps_of_match, np);
582 if (!match) {
583 dev_err(&pdev->dev, "fail to get matching of_match struct\n");
584 ret = -EINVAL;
585 goto err0;
586 }
587 wrp = match->data;
588
548 /* allocate glue */ 589 /* allocate glue */
549 glue = kzalloc(sizeof(*glue), GFP_KERNEL); 590 glue = kzalloc(sizeof(*glue), GFP_KERNEL);
550 if (!glue) { 591 if (!glue) {
@@ -693,13 +734,14 @@ static const struct platform_device_id musb_dsps_id_table[] __devinitconst = {
693}; 734};
694MODULE_DEVICE_TABLE(platform, musb_dsps_id_table); 735MODULE_DEVICE_TABLE(platform, musb_dsps_id_table);
695 736
737#ifdef CONFIG_OF
696static const struct of_device_id musb_dsps_of_match[] __devinitconst = { 738static const struct of_device_id musb_dsps_of_match[] __devinitconst = {
697 { .compatible = "musb-ti81xx", }, 739 { .compatible = "ti,musb-am33xx",
698 { .compatible = "ti,ti81xx-musb", }, 740 .data = (void *) &ti81xx_driver_data, },
699 { .compatible = "ti,am335x-musb", },
700 { }, 741 { },
701}; 742};
702MODULE_DEVICE_TABLE(of, musb_dsps_of_match); 743MODULE_DEVICE_TABLE(of, musb_dsps_of_match);
744#endif
703 745
704static struct platform_driver dsps_usbss_driver = { 746static struct platform_driver dsps_usbss_driver = {
705 .probe = dsps_probe, 747 .probe = dsps_probe,
@@ -707,7 +749,7 @@ static struct platform_driver dsps_usbss_driver = {
707 .driver = { 749 .driver = {
708 .name = "musb-dsps", 750 .name = "musb-dsps",
709 .pm = &dsps_pm_ops, 751 .pm = &dsps_pm_ops,
710 .of_match_table = musb_dsps_of_match, 752 .of_match_table = of_match_ptr(musb_dsps_of_match),
711 }, 753 },
712 .id_table = musb_dsps_id_table, 754 .id_table = musb_dsps_id_table,
713}; 755};