diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-06-28 21:45:16 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-07-01 14:12:58 -0400 |
commit | d172f319c1094ef22d2a00f43e8a7da4dd02c8f3 (patch) | |
tree | dc2f67f935ead2e08631fe71ff461ec84144d295 /drivers/regulator | |
parent | e2eb169b1bc207dd1a79109d85b098b241be2e9b (diff) |
regulator: tps65217: Convert LDO1 to use regulator_list_voltage_table
Convert tps65217_pmic_ldo1_ops to use regulator_list_voltage_table.
We have n_voltages and volt_table settings in regulator_desc,
so we don't need the table and table_len fields in struct tps_info.
Thus remove them from struct tps_info.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/tps65217-regulator.c | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/drivers/regulator/tps65217-regulator.c b/drivers/regulator/tps65217-regulator.c index f5fa05b5bea4..3a2b839276fe 100644 --- a/drivers/regulator/tps65217-regulator.c +++ b/drivers/regulator/tps65217-regulator.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include <linux/regulator/machine.h> | 26 | #include <linux/regulator/machine.h> |
27 | #include <linux/mfd/tps65217.h> | 27 | #include <linux/mfd/tps65217.h> |
28 | 28 | ||
29 | #define TPS65217_REGULATOR(_name, _id, _ops, _n, _vr, _vm, _em) \ | 29 | #define TPS65217_REGULATOR(_name, _id, _ops, _n, _vr, _vm, _em, _t) \ |
30 | { \ | 30 | { \ |
31 | .name = _name, \ | 31 | .name = _name, \ |
32 | .id = _id, \ | 32 | .id = _id, \ |
@@ -38,20 +38,19 @@ | |||
38 | .vsel_mask = _vm, \ | 38 | .vsel_mask = _vm, \ |
39 | .enable_reg = TPS65217_REG_ENABLE, \ | 39 | .enable_reg = TPS65217_REG_ENABLE, \ |
40 | .enable_mask = _em, \ | 40 | .enable_mask = _em, \ |
41 | .volt_table = _t, \ | ||
41 | } \ | 42 | } \ |
42 | 43 | ||
43 | #define TPS65217_INFO(_nm, _min, _max, _f1, _f2, _t, _n)\ | 44 | #define TPS65217_INFO(_nm, _min, _max, _f1, _f2) \ |
44 | { \ | 45 | { \ |
45 | .name = _nm, \ | 46 | .name = _nm, \ |
46 | .min_uV = _min, \ | 47 | .min_uV = _min, \ |
47 | .max_uV = _max, \ | 48 | .max_uV = _max, \ |
48 | .vsel_to_uv = _f1, \ | 49 | .vsel_to_uv = _f1, \ |
49 | .uv_to_vsel = _f2, \ | 50 | .uv_to_vsel = _f2, \ |
50 | .table = _t, \ | ||
51 | .table_len = _n, \ | ||
52 | } | 51 | } |
53 | 52 | ||
54 | static const int LDO1_VSEL_table[] = { | 53 | static const unsigned int LDO1_VSEL_table[] = { |
55 | 1000000, 1100000, 1200000, 1250000, | 54 | 1000000, 1100000, 1200000, 1250000, |
56 | 1300000, 1350000, 1400000, 1500000, | 55 | 1300000, 1350000, 1400000, 1500000, |
57 | 1600000, 1800000, 2500000, 2750000, | 56 | 1600000, 1800000, 2500000, 2750000, |
@@ -128,19 +127,18 @@ static int tps65217_uv_to_vsel2(int uV, unsigned int *vsel) | |||
128 | 127 | ||
129 | static struct tps_info tps65217_pmic_regs[] = { | 128 | static struct tps_info tps65217_pmic_regs[] = { |
130 | TPS65217_INFO("DCDC1", 900000, 1800000, tps65217_vsel_to_uv1, | 129 | TPS65217_INFO("DCDC1", 900000, 1800000, tps65217_vsel_to_uv1, |
131 | tps65217_uv_to_vsel1, NULL, 64), | 130 | tps65217_uv_to_vsel1), |
132 | TPS65217_INFO("DCDC2", 900000, 3300000, tps65217_vsel_to_uv1, | 131 | TPS65217_INFO("DCDC2", 900000, 3300000, tps65217_vsel_to_uv1, |
133 | tps65217_uv_to_vsel1, NULL, 64), | 132 | tps65217_uv_to_vsel1), |
134 | TPS65217_INFO("DCDC3", 900000, 1500000, tps65217_vsel_to_uv1, | 133 | TPS65217_INFO("DCDC3", 900000, 1500000, tps65217_vsel_to_uv1, |
135 | tps65217_uv_to_vsel1, NULL, 64), | 134 | tps65217_uv_to_vsel1), |
136 | TPS65217_INFO("LDO1", 1000000, 3300000, NULL, NULL, LDO1_VSEL_table, | 135 | TPS65217_INFO("LDO1", 1000000, 3300000, NULL, NULL), |
137 | 16), | ||
138 | TPS65217_INFO("LDO2", 900000, 3300000, tps65217_vsel_to_uv1, | 136 | TPS65217_INFO("LDO2", 900000, 3300000, tps65217_vsel_to_uv1, |
139 | tps65217_uv_to_vsel1, NULL, 64), | 137 | tps65217_uv_to_vsel1), |
140 | TPS65217_INFO("LDO3", 1800000, 3300000, tps65217_vsel_to_uv2, | 138 | TPS65217_INFO("LDO3", 1800000, 3300000, tps65217_vsel_to_uv2, |
141 | tps65217_uv_to_vsel2, NULL, 32), | 139 | tps65217_uv_to_vsel2), |
142 | TPS65217_INFO("LDO4", 1800000, 3300000, tps65217_vsel_to_uv2, | 140 | TPS65217_INFO("LDO4", 1800000, 3300000, tps65217_vsel_to_uv2, |
143 | tps65217_uv_to_vsel2, NULL, 32), | 141 | tps65217_uv_to_vsel2), |
144 | }; | 142 | }; |
145 | 143 | ||
146 | static int tps65217_pmic_enable(struct regulator_dev *dev) | 144 | static int tps65217_pmic_enable(struct regulator_dev *dev) |
@@ -230,12 +228,9 @@ static int tps65217_pmic_list_voltage(struct regulator_dev *dev, | |||
230 | if (rid < TPS65217_DCDC_1 || rid > TPS65217_LDO_4) | 228 | if (rid < TPS65217_DCDC_1 || rid > TPS65217_LDO_4) |
231 | return -EINVAL; | 229 | return -EINVAL; |
232 | 230 | ||
233 | if (selector >= tps->info[rid]->table_len) | 231 | if (selector >= dev->desc->n_voltages) |
234 | return -EINVAL; | 232 | return -EINVAL; |
235 | 233 | ||
236 | if (tps->info[rid]->table) | ||
237 | return tps->info[rid]->table[selector]; | ||
238 | |||
239 | return tps->info[rid]->vsel_to_uv(selector); | 234 | return tps->info[rid]->vsel_to_uv(selector); |
240 | } | 235 | } |
241 | 236 | ||
@@ -257,31 +252,33 @@ static struct regulator_ops tps65217_pmic_ldo1_ops = { | |||
257 | .disable = tps65217_pmic_disable, | 252 | .disable = tps65217_pmic_disable, |
258 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | 253 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
259 | .set_voltage_sel = tps65217_pmic_set_voltage_sel, | 254 | .set_voltage_sel = tps65217_pmic_set_voltage_sel, |
260 | .list_voltage = tps65217_pmic_list_voltage, | 255 | .list_voltage = regulator_list_voltage_table, |
261 | }; | 256 | }; |
262 | 257 | ||
263 | static const struct regulator_desc regulators[] = { | 258 | static const struct regulator_desc regulators[] = { |
264 | TPS65217_REGULATOR("DCDC1", TPS65217_DCDC_1, tps65217_pmic_ops, 64, | 259 | TPS65217_REGULATOR("DCDC1", TPS65217_DCDC_1, tps65217_pmic_ops, 64, |
265 | TPS65217_REG_DEFDCDC1, TPS65217_DEFDCDCX_DCDC_MASK, | 260 | TPS65217_REG_DEFDCDC1, TPS65217_DEFDCDCX_DCDC_MASK, |
266 | TPS65217_ENABLE_DC1_EN), | 261 | TPS65217_ENABLE_DC1_EN, NULL), |
267 | TPS65217_REGULATOR("DCDC2", TPS65217_DCDC_2, tps65217_pmic_ops, 64, | 262 | TPS65217_REGULATOR("DCDC2", TPS65217_DCDC_2, tps65217_pmic_ops, 64, |
268 | TPS65217_REG_DEFDCDC2, TPS65217_DEFDCDCX_DCDC_MASK, | 263 | TPS65217_REG_DEFDCDC2, TPS65217_DEFDCDCX_DCDC_MASK, |
269 | TPS65217_ENABLE_DC2_EN), | 264 | TPS65217_ENABLE_DC2_EN, NULL), |
270 | TPS65217_REGULATOR("DCDC3", TPS65217_DCDC_3, tps65217_pmic_ops, 64, | 265 | TPS65217_REGULATOR("DCDC3", TPS65217_DCDC_3, tps65217_pmic_ops, 64, |
271 | TPS65217_REG_DEFDCDC3, TPS65217_DEFDCDCX_DCDC_MASK, | 266 | TPS65217_REG_DEFDCDC3, TPS65217_DEFDCDCX_DCDC_MASK, |
272 | TPS65217_ENABLE_DC3_EN), | 267 | TPS65217_ENABLE_DC3_EN, NULL), |
273 | TPS65217_REGULATOR("LDO1", TPS65217_LDO_1, tps65217_pmic_ldo1_ops, 16, | 268 | TPS65217_REGULATOR("LDO1", TPS65217_LDO_1, tps65217_pmic_ldo1_ops, 16, |
274 | TPS65217_REG_DEFLDO1, TPS65217_DEFLDO1_LDO1_MASK, | 269 | TPS65217_REG_DEFLDO1, TPS65217_DEFLDO1_LDO1_MASK, |
275 | TPS65217_ENABLE_LDO1_EN), | 270 | TPS65217_ENABLE_LDO1_EN, LDO1_VSEL_table), |
276 | TPS65217_REGULATOR("LDO2", TPS65217_LDO_2, tps65217_pmic_ops, 64, | 271 | TPS65217_REGULATOR("LDO2", TPS65217_LDO_2, tps65217_pmic_ops, 64, |
277 | TPS65217_REG_DEFLDO2, TPS65217_DEFLDO2_LDO2_MASK, | 272 | TPS65217_REG_DEFLDO2, TPS65217_DEFLDO2_LDO2_MASK, |
278 | TPS65217_ENABLE_LDO2_EN), | 273 | TPS65217_ENABLE_LDO2_EN, NULL), |
279 | TPS65217_REGULATOR("LDO3", TPS65217_LDO_3, tps65217_pmic_ops, 32, | 274 | TPS65217_REGULATOR("LDO3", TPS65217_LDO_3, tps65217_pmic_ops, 32, |
280 | TPS65217_REG_DEFLS1, TPS65217_DEFLDO3_LDO3_MASK, | 275 | TPS65217_REG_DEFLS1, TPS65217_DEFLDO3_LDO3_MASK, |
281 | TPS65217_ENABLE_LS1_EN | TPS65217_DEFLDO3_LDO3_EN), | 276 | TPS65217_ENABLE_LS1_EN | TPS65217_DEFLDO3_LDO3_EN, |
277 | NULL), | ||
282 | TPS65217_REGULATOR("LDO4", TPS65217_LDO_4, tps65217_pmic_ops, 32, | 278 | TPS65217_REGULATOR("LDO4", TPS65217_LDO_4, tps65217_pmic_ops, 32, |
283 | TPS65217_REG_DEFLS2, TPS65217_DEFLDO4_LDO4_MASK, | 279 | TPS65217_REG_DEFLS2, TPS65217_DEFLDO4_LDO4_MASK, |
284 | TPS65217_ENABLE_LS2_EN | TPS65217_DEFLDO4_LDO4_EN), | 280 | TPS65217_ENABLE_LS2_EN | TPS65217_DEFLDO4_LDO4_EN, |
281 | NULL), | ||
285 | }; | 282 | }; |
286 | 283 | ||
287 | static int __devinit tps65217_regulator_probe(struct platform_device *pdev) | 284 | static int __devinit tps65217_regulator_probe(struct platform_device *pdev) |