diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-04-15 07:38:42 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-04-16 14:52:51 -0400 |
commit | 3d138fccc4066e00419d2638081011ea6da3f6a7 (patch) | |
tree | a909a4ef25a415bd93428878fda8cc8162b4fb0f | |
parent | cd6dffb4c6c476f5787f4df3eda7ecb16e25780d (diff) |
regulator: wm831x-dcdc: Use generic regmap enable/disable operations
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@ti.com>
-rw-r--r-- | drivers/regulator/wm831x-dcdc.c | 70 |
1 files changed, 23 insertions, 47 deletions
diff --git a/drivers/regulator/wm831x-dcdc.c b/drivers/regulator/wm831x-dcdc.c index 97c7e267c813..3de56f5e0f7d 100644 --- a/drivers/regulator/wm831x-dcdc.c +++ b/drivers/regulator/wm831x-dcdc.c | |||
@@ -60,41 +60,6 @@ struct wm831x_dcdc { | |||
60 | int dvs_vsel; | 60 | int dvs_vsel; |
61 | }; | 61 | }; |
62 | 62 | ||
63 | static int wm831x_dcdc_is_enabled(struct regulator_dev *rdev) | ||
64 | { | ||
65 | struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev); | ||
66 | struct wm831x *wm831x = dcdc->wm831x; | ||
67 | int mask = 1 << rdev_get_id(rdev); | ||
68 | int reg; | ||
69 | |||
70 | reg = wm831x_reg_read(wm831x, WM831X_DCDC_ENABLE); | ||
71 | if (reg < 0) | ||
72 | return reg; | ||
73 | |||
74 | if (reg & mask) | ||
75 | return 1; | ||
76 | else | ||
77 | return 0; | ||
78 | } | ||
79 | |||
80 | static int wm831x_dcdc_enable(struct regulator_dev *rdev) | ||
81 | { | ||
82 | struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev); | ||
83 | struct wm831x *wm831x = dcdc->wm831x; | ||
84 | int mask = 1 << rdev_get_id(rdev); | ||
85 | |||
86 | return wm831x_set_bits(wm831x, WM831X_DCDC_ENABLE, mask, mask); | ||
87 | } | ||
88 | |||
89 | static int wm831x_dcdc_disable(struct regulator_dev *rdev) | ||
90 | { | ||
91 | struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev); | ||
92 | struct wm831x *wm831x = dcdc->wm831x; | ||
93 | int mask = 1 << rdev_get_id(rdev); | ||
94 | |||
95 | return wm831x_set_bits(wm831x, WM831X_DCDC_ENABLE, mask, 0); | ||
96 | } | ||
97 | |||
98 | static unsigned int wm831x_dcdc_get_mode(struct regulator_dev *rdev) | 63 | static unsigned int wm831x_dcdc_get_mode(struct regulator_dev *rdev) |
99 | 64 | ||
100 | { | 65 | { |
@@ -414,9 +379,9 @@ static struct regulator_ops wm831x_buckv_ops = { | |||
414 | .set_current_limit = wm831x_buckv_set_current_limit, | 379 | .set_current_limit = wm831x_buckv_set_current_limit, |
415 | .get_current_limit = wm831x_buckv_get_current_limit, | 380 | .get_current_limit = wm831x_buckv_get_current_limit, |
416 | 381 | ||
417 | .is_enabled = wm831x_dcdc_is_enabled, | 382 | .is_enabled = regulator_is_enabled_regmap, |
418 | .enable = wm831x_dcdc_enable, | 383 | .enable = regulator_enable_regmap, |
419 | .disable = wm831x_dcdc_disable, | 384 | .disable = regulator_disable_regmap, |
420 | .get_status = wm831x_dcdc_get_status, | 385 | .get_status = wm831x_dcdc_get_status, |
421 | .get_mode = wm831x_dcdc_get_mode, | 386 | .get_mode = wm831x_dcdc_get_mode, |
422 | .set_mode = wm831x_dcdc_set_mode, | 387 | .set_mode = wm831x_dcdc_set_mode, |
@@ -539,6 +504,8 @@ static __devinit int wm831x_buckv_probe(struct platform_device *pdev) | |||
539 | dcdc->desc.n_voltages = WM831X_BUCKV_MAX_SELECTOR + 1; | 504 | dcdc->desc.n_voltages = WM831X_BUCKV_MAX_SELECTOR + 1; |
540 | dcdc->desc.ops = &wm831x_buckv_ops; | 505 | dcdc->desc.ops = &wm831x_buckv_ops; |
541 | dcdc->desc.owner = THIS_MODULE; | 506 | dcdc->desc.owner = THIS_MODULE; |
507 | dcdc->desc.enable_reg = WM831X_DCDC_ENABLE; | ||
508 | dcdc->desc.enable_mask = 1 << id; | ||
542 | 509 | ||
543 | ret = wm831x_reg_read(wm831x, dcdc->base + WM831X_DCDC_ON_CONFIG); | 510 | ret = wm831x_reg_read(wm831x, dcdc->base + WM831X_DCDC_ON_CONFIG); |
544 | if (ret < 0) { | 511 | if (ret < 0) { |
@@ -560,6 +527,7 @@ static __devinit int wm831x_buckv_probe(struct platform_device *pdev) | |||
560 | config.dev = pdev->dev.parent; | 527 | config.dev = pdev->dev.parent; |
561 | config.init_data = pdata->dcdc[id]; | 528 | config.init_data = pdata->dcdc[id]; |
562 | config.driver_data = dcdc; | 529 | config.driver_data = dcdc; |
530 | config.regmap = wm831x->regmap; | ||
563 | 531 | ||
564 | dcdc->regulator = regulator_register(&dcdc->desc, &config); | 532 | dcdc->regulator = regulator_register(&dcdc->desc, &config); |
565 | if (IS_ERR(dcdc->regulator)) { | 533 | if (IS_ERR(dcdc->regulator)) { |
@@ -685,9 +653,9 @@ static struct regulator_ops wm831x_buckp_ops = { | |||
685 | .list_voltage = wm831x_buckp_list_voltage, | 653 | .list_voltage = wm831x_buckp_list_voltage, |
686 | .set_suspend_voltage = wm831x_buckp_set_suspend_voltage, | 654 | .set_suspend_voltage = wm831x_buckp_set_suspend_voltage, |
687 | 655 | ||
688 | .is_enabled = wm831x_dcdc_is_enabled, | 656 | .is_enabled = regulator_is_enabled_regmap, |
689 | .enable = wm831x_dcdc_enable, | 657 | .enable = regulator_enable_regmap, |
690 | .disable = wm831x_dcdc_disable, | 658 | .disable = regulator_disable_regmap, |
691 | .get_status = wm831x_dcdc_get_status, | 659 | .get_status = wm831x_dcdc_get_status, |
692 | .get_mode = wm831x_dcdc_get_mode, | 660 | .get_mode = wm831x_dcdc_get_mode, |
693 | .set_mode = wm831x_dcdc_set_mode, | 661 | .set_mode = wm831x_dcdc_set_mode, |
@@ -741,6 +709,8 @@ static __devinit int wm831x_buckp_probe(struct platform_device *pdev) | |||
741 | dcdc->desc.owner = THIS_MODULE; | 709 | dcdc->desc.owner = THIS_MODULE; |
742 | dcdc->desc.vsel_reg = dcdc->base + WM831X_DCDC_ON_CONFIG; | 710 | dcdc->desc.vsel_reg = dcdc->base + WM831X_DCDC_ON_CONFIG; |
743 | dcdc->desc.vsel_mask = WM831X_DC3_ON_VSEL_MASK; | 711 | dcdc->desc.vsel_mask = WM831X_DC3_ON_VSEL_MASK; |
712 | dcdc->desc.enable_reg = WM831X_DCDC_ENABLE; | ||
713 | dcdc->desc.enable_mask = 1 << id; | ||
744 | 714 | ||
745 | config.dev = pdev->dev.parent; | 715 | config.dev = pdev->dev.parent; |
746 | config.init_data = pdata->dcdc[id]; | 716 | config.init_data = pdata->dcdc[id]; |
@@ -829,9 +799,9 @@ static int wm831x_boostp_get_status(struct regulator_dev *rdev) | |||
829 | static struct regulator_ops wm831x_boostp_ops = { | 799 | static struct regulator_ops wm831x_boostp_ops = { |
830 | .get_status = wm831x_boostp_get_status, | 800 | .get_status = wm831x_boostp_get_status, |
831 | 801 | ||
832 | .is_enabled = wm831x_dcdc_is_enabled, | 802 | .is_enabled = regulator_is_enabled_regmap, |
833 | .enable = wm831x_dcdc_enable, | 803 | .enable = regulator_enable_regmap, |
834 | .disable = wm831x_dcdc_disable, | 804 | .disable = regulator_disable_regmap, |
835 | }; | 805 | }; |
836 | 806 | ||
837 | static __devinit int wm831x_boostp_probe(struct platform_device *pdev) | 807 | static __devinit int wm831x_boostp_probe(struct platform_device *pdev) |
@@ -871,10 +841,13 @@ static __devinit int wm831x_boostp_probe(struct platform_device *pdev) | |||
871 | dcdc->desc.type = REGULATOR_VOLTAGE; | 841 | dcdc->desc.type = REGULATOR_VOLTAGE; |
872 | dcdc->desc.ops = &wm831x_boostp_ops; | 842 | dcdc->desc.ops = &wm831x_boostp_ops; |
873 | dcdc->desc.owner = THIS_MODULE; | 843 | dcdc->desc.owner = THIS_MODULE; |
844 | dcdc->desc.enable_reg = WM831X_DCDC_ENABLE; | ||
845 | dcdc->desc.enable_mask = 1 << id; | ||
874 | 846 | ||
875 | config.dev = pdev->dev.parent; | 847 | config.dev = pdev->dev.parent; |
876 | config.init_data = pdata->dcdc[id]; | 848 | config.init_data = pdata->dcdc[id]; |
877 | config.driver_data = dcdc; | 849 | config.driver_data = dcdc; |
850 | config.regmap = wm831x->regmap; | ||
878 | 851 | ||
879 | dcdc->regulator = regulator_register(&dcdc->desc, &config); | 852 | dcdc->regulator = regulator_register(&dcdc->desc, &config); |
880 | if (IS_ERR(dcdc->regulator)) { | 853 | if (IS_ERR(dcdc->regulator)) { |
@@ -935,9 +908,9 @@ static struct platform_driver wm831x_boostp_driver = { | |||
935 | #define WM831X_EPE_BASE 6 | 908 | #define WM831X_EPE_BASE 6 |
936 | 909 | ||
937 | static struct regulator_ops wm831x_epe_ops = { | 910 | static struct regulator_ops wm831x_epe_ops = { |
938 | .is_enabled = wm831x_dcdc_is_enabled, | 911 | .is_enabled = regulator_is_enabled_regmap, |
939 | .enable = wm831x_dcdc_enable, | 912 | .enable = regulator_enable_regmap, |
940 | .disable = wm831x_dcdc_disable, | 913 | .disable = regulator_disable_regmap, |
941 | .get_status = wm831x_dcdc_get_status, | 914 | .get_status = wm831x_dcdc_get_status, |
942 | }; | 915 | }; |
943 | 916 | ||
@@ -972,10 +945,13 @@ static __devinit int wm831x_epe_probe(struct platform_device *pdev) | |||
972 | dcdc->desc.ops = &wm831x_epe_ops; | 945 | dcdc->desc.ops = &wm831x_epe_ops; |
973 | dcdc->desc.type = REGULATOR_VOLTAGE; | 946 | dcdc->desc.type = REGULATOR_VOLTAGE; |
974 | dcdc->desc.owner = THIS_MODULE; | 947 | dcdc->desc.owner = THIS_MODULE; |
948 | dcdc->desc.enable_reg = WM831X_DCDC_ENABLE; | ||
949 | dcdc->desc.enable_mask = 1 << dcdc->desc.id; | ||
975 | 950 | ||
976 | config.dev = pdev->dev.parent; | 951 | config.dev = pdev->dev.parent; |
977 | config.init_data = pdata->epe[id]; | 952 | config.init_data = pdata->epe[id]; |
978 | config.driver_data = dcdc; | 953 | config.driver_data = dcdc; |
954 | config.regmap = wm831x->regmap; | ||
979 | 955 | ||
980 | dcdc->regulator = regulator_register(&dcdc->desc, &config); | 956 | dcdc->regulator = regulator_register(&dcdc->desc, &config); |
981 | if (IS_ERR(dcdc->regulator)) { | 957 | if (IS_ERR(dcdc->regulator)) { |