diff options
author | Axel Lin <axel.lin@ingics.com> | 2013-02-13 04:01:09 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-02-13 07:58:40 -0500 |
commit | d94d9aca5bccba682b5a764c962bcdde7c4bf95a (patch) | |
tree | 9b3867a140bdec47a32759aff37bc7d18d9fa8ce /drivers | |
parent | c51ce403d3d9e3d54339c4563f17e958f3bc64df (diff) |
regulator: tps51632: Use regulator_[get|set]_voltage_sel_regmap
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/regulator/tps51632-regulator.c | 52 |
1 files changed, 8 insertions, 44 deletions
diff --git a/drivers/regulator/tps51632-regulator.c b/drivers/regulator/tps51632-regulator.c index 7560d0768b77..6e67be75ea1b 100644 --- a/drivers/regulator/tps51632-regulator.c +++ b/drivers/regulator/tps51632-regulator.c | |||
@@ -88,49 +88,8 @@ struct tps51632_chip { | |||
88 | struct regulator_desc desc; | 88 | struct regulator_desc desc; |
89 | struct regulator_dev *rdev; | 89 | struct regulator_dev *rdev; |
90 | struct regmap *regmap; | 90 | struct regmap *regmap; |
91 | bool enable_pwm_dvfs; | ||
92 | }; | 91 | }; |
93 | 92 | ||
94 | static int tps51632_dcdc_get_voltage_sel(struct regulator_dev *rdev) | ||
95 | { | ||
96 | struct tps51632_chip *tps = rdev_get_drvdata(rdev); | ||
97 | unsigned int data; | ||
98 | int ret; | ||
99 | unsigned int reg = TPS51632_VOLTAGE_SELECT_REG; | ||
100 | int vsel; | ||
101 | |||
102 | if (tps->enable_pwm_dvfs) | ||
103 | reg = TPS51632_VOLTAGE_BASE_REG; | ||
104 | |||
105 | ret = regmap_read(tps->regmap, reg, &data); | ||
106 | if (ret < 0) { | ||
107 | dev_err(tps->dev, "reg read failed, err %d\n", ret); | ||
108 | return ret; | ||
109 | } | ||
110 | |||
111 | vsel = data & TPS51632_VOUT_MASK; | ||
112 | return vsel; | ||
113 | } | ||
114 | |||
115 | static int tps51632_dcdc_set_voltage_sel(struct regulator_dev *rdev, | ||
116 | unsigned selector) | ||
117 | { | ||
118 | struct tps51632_chip *tps = rdev_get_drvdata(rdev); | ||
119 | int ret; | ||
120 | unsigned int reg = TPS51632_VOLTAGE_SELECT_REG; | ||
121 | |||
122 | if (tps->enable_pwm_dvfs) | ||
123 | reg = TPS51632_VOLTAGE_BASE_REG; | ||
124 | |||
125 | if (selector > TPS51632_MAX_VSEL) | ||
126 | return -EINVAL; | ||
127 | |||
128 | ret = regmap_write(tps->regmap, reg, selector); | ||
129 | if (ret < 0) | ||
130 | dev_err(tps->dev, "reg write failed, err %d\n", ret); | ||
131 | return ret; | ||
132 | } | ||
133 | |||
134 | static int tps51632_dcdc_set_ramp_delay(struct regulator_dev *rdev, | 93 | static int tps51632_dcdc_set_ramp_delay(struct regulator_dev *rdev, |
135 | int ramp_delay) | 94 | int ramp_delay) |
136 | { | 95 | { |
@@ -147,8 +106,8 @@ static int tps51632_dcdc_set_ramp_delay(struct regulator_dev *rdev, | |||
147 | } | 106 | } |
148 | 107 | ||
149 | static struct regulator_ops tps51632_dcdc_ops = { | 108 | static struct regulator_ops tps51632_dcdc_ops = { |
150 | .get_voltage_sel = tps51632_dcdc_get_voltage_sel, | 109 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
151 | .set_voltage_sel = tps51632_dcdc_set_voltage_sel, | 110 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
152 | .list_voltage = regulator_list_voltage_linear, | 111 | .list_voltage = regulator_list_voltage_linear, |
153 | .set_voltage_time_sel = regulator_set_voltage_time_sel, | 112 | .set_voltage_time_sel = regulator_set_voltage_time_sel, |
154 | .set_ramp_delay = tps51632_dcdc_set_ramp_delay, | 113 | .set_ramp_delay = tps51632_dcdc_set_ramp_delay, |
@@ -165,7 +124,6 @@ static int tps51632_init_dcdc(struct tps51632_chip *tps, | |||
165 | goto skip_pwm_config; | 124 | goto skip_pwm_config; |
166 | 125 | ||
167 | control |= TPS51632_DVFS_PWMEN; | 126 | control |= TPS51632_DVFS_PWMEN; |
168 | tps->enable_pwm_dvfs = pdata->enable_pwm_dvfs; | ||
169 | vsel = TPS51632_VOLT_VSEL(pdata->base_voltage_uV); | 127 | vsel = TPS51632_VOLT_VSEL(pdata->base_voltage_uV); |
170 | ret = regmap_write(tps->regmap, TPS51632_VOLTAGE_BASE_REG, vsel); | 128 | ret = regmap_write(tps->regmap, TPS51632_VOLTAGE_BASE_REG, vsel); |
171 | if (ret < 0) { | 129 | if (ret < 0) { |
@@ -358,6 +316,12 @@ static int tps51632_probe(struct i2c_client *client, | |||
358 | tps->desc.type = REGULATOR_VOLTAGE; | 316 | tps->desc.type = REGULATOR_VOLTAGE; |
359 | tps->desc.owner = THIS_MODULE; | 317 | tps->desc.owner = THIS_MODULE; |
360 | 318 | ||
319 | if (pdata->enable_pwm_dvfs) | ||
320 | tps->desc.vsel_reg = TPS51632_VOLTAGE_BASE_REG; | ||
321 | else | ||
322 | tps->desc.vsel_reg = TPS51632_VOLTAGE_SELECT_REG; | ||
323 | tps->desc.vsel_mask = TPS51632_VOUT_MASK; | ||
324 | |||
361 | tps->regmap = devm_regmap_init_i2c(client, &tps51632_regmap_config); | 325 | tps->regmap = devm_regmap_init_i2c(client, &tps51632_regmap_config); |
362 | if (IS_ERR(tps->regmap)) { | 326 | if (IS_ERR(tps->regmap)) { |
363 | ret = PTR_ERR(tps->regmap); | 327 | ret = PTR_ERR(tps->regmap); |