aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2011-07-25 17:20:29 -0400
committerLiam Girdwood <lrg@slimlogic.co.uk>2011-07-28 05:20:48 -0400
commit137a6354305455d585fe99fe5e9949acd895b045 (patch)
treec4040ba3e9cc2da3c52d4fe703a819a2022c4b92 /drivers/regulator
parent54abd335fda86d305845f9e62b4bc0997386eb66 (diff)
regulator: Fix WM831x regulator ID lookups for multiple WM831xs
With multiple wm831x devices the device IDs used for the regulators will not always be contiguous so simply taking the modulus is not sufficient to look up the ID, we need to reverse the way the ID is generated. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/wm831x-dcdc.c16
-rw-r--r--drivers/regulator/wm831x-ldo.c25
2 files changed, 36 insertions, 5 deletions
diff --git a/drivers/regulator/wm831x-dcdc.c b/drivers/regulator/wm831x-dcdc.c
index a0982e809851..0c7a9d5047f4 100644
--- a/drivers/regulator/wm831x-dcdc.c
+++ b/drivers/regulator/wm831x-dcdc.c
@@ -504,11 +504,17 @@ static __devinit int wm831x_buckv_probe(struct platform_device *pdev)
504{ 504{
505 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); 505 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
506 struct wm831x_pdata *pdata = wm831x->dev->platform_data; 506 struct wm831x_pdata *pdata = wm831x->dev->platform_data;
507 int id = pdev->id % ARRAY_SIZE(pdata->dcdc); 507 int id;
508 struct wm831x_dcdc *dcdc; 508 struct wm831x_dcdc *dcdc;
509 struct resource *res; 509 struct resource *res;
510 int ret, irq; 510 int ret, irq;
511 511
512 if (pdata && pdata->wm831x_num)
513 id = (pdata->wm831x_num * 10) + 1;
514 else
515 id = 0;
516 id = pdev->id - id;
517
512 dev_dbg(&pdev->dev, "Probing DCDC%d\n", id + 1); 518 dev_dbg(&pdev->dev, "Probing DCDC%d\n", id + 1);
513 519
514 if (pdata == NULL || pdata->dcdc[id] == NULL) 520 if (pdata == NULL || pdata->dcdc[id] == NULL)
@@ -709,11 +715,17 @@ static __devinit int wm831x_buckp_probe(struct platform_device *pdev)
709{ 715{
710 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); 716 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
711 struct wm831x_pdata *pdata = wm831x->dev->platform_data; 717 struct wm831x_pdata *pdata = wm831x->dev->platform_data;
712 int id = pdev->id % ARRAY_SIZE(pdata->dcdc); 718 int id;
713 struct wm831x_dcdc *dcdc; 719 struct wm831x_dcdc *dcdc;
714 struct resource *res; 720 struct resource *res;
715 int ret, irq; 721 int ret, irq;
716 722
723 if (pdata && pdata->wm831x_num)
724 id = (pdata->wm831x_num * 10) + 1;
725 else
726 id = 0;
727 id = pdev->id - id;
728
717 dev_dbg(&pdev->dev, "Probing DCDC%d\n", id + 1); 729 dev_dbg(&pdev->dev, "Probing DCDC%d\n", id + 1);
718 730
719 if (pdata == NULL || pdata->dcdc[id] == NULL) 731 if (pdata == NULL || pdata->dcdc[id] == NULL)
diff --git a/drivers/regulator/wm831x-ldo.c b/drivers/regulator/wm831x-ldo.c
index 2220cf8defb1..6709710a059e 100644
--- a/drivers/regulator/wm831x-ldo.c
+++ b/drivers/regulator/wm831x-ldo.c
@@ -310,11 +310,17 @@ static __devinit int wm831x_gp_ldo_probe(struct platform_device *pdev)
310{ 310{
311 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); 311 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
312 struct wm831x_pdata *pdata = wm831x->dev->platform_data; 312 struct wm831x_pdata *pdata = wm831x->dev->platform_data;
313 int id = pdev->id % ARRAY_SIZE(pdata->ldo); 313 int id;
314 struct wm831x_ldo *ldo; 314 struct wm831x_ldo *ldo;
315 struct resource *res; 315 struct resource *res;
316 int ret, irq; 316 int ret, irq;
317 317
318 if (pdata && pdata->wm831x_num)
319 id = (pdata->wm831x_num * 10) + 1;
320 else
321 id = 0;
322 id = pdev->id - id;
323
318 dev_dbg(&pdev->dev, "Probing LDO%d\n", id + 1); 324 dev_dbg(&pdev->dev, "Probing LDO%d\n", id + 1);
319 325
320 if (pdata == NULL || pdata->ldo[id] == NULL) 326 if (pdata == NULL || pdata->ldo[id] == NULL)
@@ -574,11 +580,17 @@ static __devinit int wm831x_aldo_probe(struct platform_device *pdev)
574{ 580{
575 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); 581 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
576 struct wm831x_pdata *pdata = wm831x->dev->platform_data; 582 struct wm831x_pdata *pdata = wm831x->dev->platform_data;
577 int id = pdev->id % ARRAY_SIZE(pdata->ldo); 583 int id;
578 struct wm831x_ldo *ldo; 584 struct wm831x_ldo *ldo;
579 struct resource *res; 585 struct resource *res;
580 int ret, irq; 586 int ret, irq;
581 587
588 if (pdata && pdata->wm831x_num)
589 id = (pdata->wm831x_num * 10) + 1;
590 else
591 id = 0;
592 id = pdev->id - id;
593
582 dev_dbg(&pdev->dev, "Probing LDO%d\n", id + 1); 594 dev_dbg(&pdev->dev, "Probing LDO%d\n", id + 1);
583 595
584 if (pdata == NULL || pdata->ldo[id] == NULL) 596 if (pdata == NULL || pdata->ldo[id] == NULL)
@@ -764,11 +776,18 @@ static __devinit int wm831x_alive_ldo_probe(struct platform_device *pdev)
764{ 776{
765 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); 777 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
766 struct wm831x_pdata *pdata = wm831x->dev->platform_data; 778 struct wm831x_pdata *pdata = wm831x->dev->platform_data;
767 int id = pdev->id % ARRAY_SIZE(pdata->ldo); 779 int id;
768 struct wm831x_ldo *ldo; 780 struct wm831x_ldo *ldo;
769 struct resource *res; 781 struct resource *res;
770 int ret; 782 int ret;
771 783
784 if (pdata && pdata->wm831x_num)
785 id = (pdata->wm831x_num * 10) + 1;
786 else
787 id = 0;
788 id = pdev->id - id;
789
790
772 dev_dbg(&pdev->dev, "Probing LDO%d\n", id + 1); 791 dev_dbg(&pdev->dev, "Probing LDO%d\n", id + 1);
773 792
774 if (pdata == NULL || pdata->ldo[id] == NULL) 793 if (pdata == NULL || pdata->ldo[id] == NULL)