diff options
author | Krzysztof Kozlowski <k.kozlowski@samsung.com> | 2013-12-17 08:23:18 -0500 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-12-18 08:27:50 -0500 |
commit | d13733f4a24d93c582f22f17b5434cf195b7d505 (patch) | |
tree | 7168b747b76e2c0fc41c80fbd017889438d64c61 /drivers/regulator | |
parent | f37ff6b6ab9bff6f78dbfbdd123673a09e04cb7f (diff) |
regulator: s5m8767: Do not use sec_reg* regmap helpers
Replace calls to sec_reg* helpers with direct usage of regmap API. The
sec_reg* helpers are error-prone as they mix u8 with unsigned int and
order of some of parameters (val and mask in sec_reg_update()).
Also the helpers do not give any way of useful abstraction as they just
call corresponding regmap function.
This patch replaces:
- sec_reg_read() with regmap_read(),
- sec_reg_write() with regmap_write(),
- sec_reg_update() with regmap_update_bits().
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/s5m8767.c | 71 |
1 files changed, 41 insertions, 30 deletions
diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c index 27741df28ad7..850473a96dd0 100644 --- a/drivers/regulator/s5m8767.c +++ b/drivers/regulator/s5m8767.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/mfd/samsung/core.h> | 23 | #include <linux/mfd/samsung/core.h> |
24 | #include <linux/mfd/samsung/s5m8767.h> | 24 | #include <linux/mfd/samsung/s5m8767.h> |
25 | #include <linux/regulator/of_regulator.h> | 25 | #include <linux/regulator/of_regulator.h> |
26 | #include <linux/regmap.h> | ||
26 | 27 | ||
27 | #define S5M8767_OPMODE_NORMAL_MODE 0x1 | 28 | #define S5M8767_OPMODE_NORMAL_MODE 0x1 |
28 | 29 | ||
@@ -226,7 +227,7 @@ static int s5m8767_reg_is_enabled(struct regulator_dev *rdev) | |||
226 | else if (ret) | 227 | else if (ret) |
227 | return ret; | 228 | return ret; |
228 | 229 | ||
229 | ret = sec_reg_read(s5m8767->iodev, reg, &val); | 230 | ret = regmap_read(s5m8767->iodev->regmap_pmic, reg, &val); |
230 | if (ret) | 231 | if (ret) |
231 | return ret; | 232 | return ret; |
232 | 233 | ||
@@ -243,21 +244,21 @@ static int s5m8767_reg_enable(struct regulator_dev *rdev) | |||
243 | if (ret) | 244 | if (ret) |
244 | return ret; | 245 | return ret; |
245 | 246 | ||
246 | return sec_reg_update(s5m8767->iodev, reg, enable_ctrl, | 247 | return regmap_update_bits(s5m8767->iodev->regmap_pmic, reg, |
247 | S5M8767_ENCTRL_MASK); | 248 | S5M8767_ENCTRL_MASK, enable_ctrl); |
248 | } | 249 | } |
249 | 250 | ||
250 | static int s5m8767_reg_disable(struct regulator_dev *rdev) | 251 | static int s5m8767_reg_disable(struct regulator_dev *rdev) |
251 | { | 252 | { |
252 | struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev); | 253 | struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev); |
253 | int ret, reg; | 254 | int ret, reg, enable_ctrl; |
254 | int mask = S5M8767_ENCTRL_MASK, enable_ctrl; | ||
255 | 255 | ||
256 | ret = s5m8767_get_register(rdev, ®, &enable_ctrl); | 256 | ret = s5m8767_get_register(rdev, ®, &enable_ctrl); |
257 | if (ret) | 257 | if (ret) |
258 | return ret; | 258 | return ret; |
259 | 259 | ||
260 | return sec_reg_update(s5m8767->iodev, reg, ~mask, mask); | 260 | return regmap_update_bits(s5m8767->iodev->regmap_pmic, reg, |
261 | S5M8767_ENCTRL_MASK, ~S5M8767_ENCTRL_MASK); | ||
261 | } | 262 | } |
262 | 263 | ||
263 | static int s5m8767_get_vsel_reg(int reg_id, struct s5m8767_info *s5m8767) | 264 | static int s5m8767_get_vsel_reg(int reg_id, struct s5m8767_info *s5m8767) |
@@ -749,17 +750,20 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) | |||
749 | buck_init = s5m8767_convert_voltage_to_sel(&buck_voltage_val2, | 750 | buck_init = s5m8767_convert_voltage_to_sel(&buck_voltage_val2, |
750 | pdata->buck2_init); | 751 | pdata->buck2_init); |
751 | 752 | ||
752 | sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK2DVS2, buck_init); | 753 | regmap_write(s5m8767->iodev->regmap_pmic, S5M8767_REG_BUCK2DVS2, |
754 | buck_init); | ||
753 | 755 | ||
754 | buck_init = s5m8767_convert_voltage_to_sel(&buck_voltage_val2, | 756 | buck_init = s5m8767_convert_voltage_to_sel(&buck_voltage_val2, |
755 | pdata->buck3_init); | 757 | pdata->buck3_init); |
756 | 758 | ||
757 | sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK3DVS2, buck_init); | 759 | regmap_write(s5m8767->iodev->regmap_pmic, S5M8767_REG_BUCK3DVS2, |
760 | buck_init); | ||
758 | 761 | ||
759 | buck_init = s5m8767_convert_voltage_to_sel(&buck_voltage_val2, | 762 | buck_init = s5m8767_convert_voltage_to_sel(&buck_voltage_val2, |
760 | pdata->buck4_init); | 763 | pdata->buck4_init); |
761 | 764 | ||
762 | sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK4DVS2, buck_init); | 765 | regmap_write(s5m8767->iodev->regmap_pmic, S5M8767_REG_BUCK4DVS2, |
766 | buck_init); | ||
763 | 767 | ||
764 | for (i = 0; i < 8; i++) { | 768 | for (i = 0; i < 8; i++) { |
765 | if (s5m8767->buck2_gpiodvs) { | 769 | if (s5m8767->buck2_gpiodvs) { |
@@ -841,43 +845,49 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) | |||
841 | 845 | ||
842 | if (pdata->buck2_gpiodvs || pdata->buck3_gpiodvs || | 846 | if (pdata->buck2_gpiodvs || pdata->buck3_gpiodvs || |
843 | pdata->buck4_gpiodvs) { | 847 | pdata->buck4_gpiodvs) { |
844 | sec_reg_update(s5m8767->iodev, S5M8767_REG_BUCK2CTRL, | 848 | regmap_update_bits(s5m8767->iodev->regmap_pmic, |
845 | (pdata->buck2_gpiodvs) ? (1 << 1) : (0 << 1), | 849 | S5M8767_REG_BUCK2CTRL, 1 << 1, |
846 | 1 << 1); | 850 | (pdata->buck2_gpiodvs) ? (1 << 1) : (0 << 1)); |
847 | sec_reg_update(s5m8767->iodev, S5M8767_REG_BUCK3CTRL, | 851 | regmap_update_bits(s5m8767->iodev->regmap_pmic, |
848 | (pdata->buck3_gpiodvs) ? (1 << 1) : (0 << 1), | 852 | S5M8767_REG_BUCK3CTRL, 1 << 1, |
849 | 1 << 1); | 853 | (pdata->buck3_gpiodvs) ? (1 << 1) : (0 << 1)); |
850 | sec_reg_update(s5m8767->iodev, S5M8767_REG_BUCK4CTRL, | 854 | regmap_update_bits(s5m8767->iodev->regmap_pmic, |
851 | (pdata->buck4_gpiodvs) ? (1 << 1) : (0 << 1), | 855 | S5M8767_REG_BUCK4CTRL, 1 << 1, |
852 | 1 << 1); | 856 | (pdata->buck4_gpiodvs) ? (1 << 1) : (0 << 1)); |
853 | } | 857 | } |
854 | 858 | ||
855 | /* Initialize GPIO DVS registers */ | 859 | /* Initialize GPIO DVS registers */ |
856 | for (i = 0; i < 8; i++) { | 860 | for (i = 0; i < 8; i++) { |
857 | if (s5m8767->buck2_gpiodvs) { | 861 | if (s5m8767->buck2_gpiodvs) { |
858 | sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK2DVS1 + i, | 862 | regmap_write(s5m8767->iodev->regmap_pmic, |
859 | s5m8767->buck2_vol[i]); | 863 | S5M8767_REG_BUCK2DVS1 + i, |
864 | s5m8767->buck2_vol[i]); | ||
860 | } | 865 | } |
861 | 866 | ||
862 | if (s5m8767->buck3_gpiodvs) { | 867 | if (s5m8767->buck3_gpiodvs) { |
863 | sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK3DVS1 + i, | 868 | regmap_write(s5m8767->iodev->regmap_pmic, |
864 | s5m8767->buck3_vol[i]); | 869 | S5M8767_REG_BUCK3DVS1 + i, |
870 | s5m8767->buck3_vol[i]); | ||
865 | } | 871 | } |
866 | 872 | ||
867 | if (s5m8767->buck4_gpiodvs) { | 873 | if (s5m8767->buck4_gpiodvs) { |
868 | sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK4DVS1 + i, | 874 | regmap_write(s5m8767->iodev->regmap_pmic, |
869 | s5m8767->buck4_vol[i]); | 875 | S5M8767_REG_BUCK4DVS1 + i, |
876 | s5m8767->buck4_vol[i]); | ||
870 | } | 877 | } |
871 | } | 878 | } |
872 | 879 | ||
873 | if (s5m8767->buck2_ramp) | 880 | if (s5m8767->buck2_ramp) |
874 | sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP, 0x08, 0x08); | 881 | regmap_update_bits(s5m8767->iodev->regmap_pmic, |
882 | S5M8767_REG_DVSRAMP, 0x08, 0x08); | ||
875 | 883 | ||
876 | if (s5m8767->buck3_ramp) | 884 | if (s5m8767->buck3_ramp) |
877 | sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP, 0x04, 0x04); | 885 | regmap_update_bits(s5m8767->iodev->regmap_pmic, |
886 | S5M8767_REG_DVSRAMP, 0x04, 0x04); | ||
878 | 887 | ||
879 | if (s5m8767->buck4_ramp) | 888 | if (s5m8767->buck4_ramp) |
880 | sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP, 0x02, 0x02); | 889 | regmap_update_bits(s5m8767->iodev->regmap_pmic, |
890 | S5M8767_REG_DVSRAMP, 0x02, 0x02); | ||
881 | 891 | ||
882 | if (s5m8767->buck2_ramp || s5m8767->buck3_ramp | 892 | if (s5m8767->buck2_ramp || s5m8767->buck3_ramp |
883 | || s5m8767->buck4_ramp) { | 893 | || s5m8767->buck4_ramp) { |
@@ -901,9 +911,10 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) | |||
901 | default: | 911 | default: |
902 | val = S5M8767_DVS_BUCK_RAMP_10; | 912 | val = S5M8767_DVS_BUCK_RAMP_10; |
903 | } | 913 | } |
904 | sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP, | 914 | regmap_update_bits(s5m8767->iodev->regmap_pmic, |
905 | val << S5M8767_DVS_BUCK_RAMP_SHIFT, | 915 | S5M8767_REG_DVSRAMP, |
906 | S5M8767_DVS_BUCK_RAMP_MASK); | 916 | S5M8767_DVS_BUCK_RAMP_MASK, |
917 | val << S5M8767_DVS_BUCK_RAMP_SHIFT); | ||
907 | } | 918 | } |
908 | 919 | ||
909 | for (i = 0; i < pdata->num_regulators; i++) { | 920 | for (i = 0; i < pdata->num_regulators; i++) { |