diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-05-19 22:31:58 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-06-03 08:25:01 -0400 |
commit | a3beb74261f26142019847128b2441b0301797ac (patch) | |
tree | 9cf77fbde6f91dc8d152d41b7bc27101bffb271b /drivers/regulator/ab3100.c | |
parent | 3a4b0a07fa69cbfbdd4bc2ebe769cf789949db46 (diff) |
regulator: ab3100: Use regulator_list_voltage_table()
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/ab3100.c')
-rw-r--r-- | drivers/regulator/ab3100.c | 50 |
1 files changed, 14 insertions, 36 deletions
diff --git a/drivers/regulator/ab3100.c b/drivers/regulator/ab3100.c index 03f4d9c604ec..b088b6c228c8 100644 --- a/drivers/regulator/ab3100.c +++ b/drivers/regulator/ab3100.c | |||
@@ -45,9 +45,6 @@ | |||
45 | * @regreg: regulator register number in the AB3100 | 45 | * @regreg: regulator register number in the AB3100 |
46 | * @fixed_voltage: a fixed voltage for this regulator, if this | 46 | * @fixed_voltage: a fixed voltage for this regulator, if this |
47 | * 0 the voltages array is used instead. | 47 | * 0 the voltages array is used instead. |
48 | * @typ_voltages: an array of available typical voltages for | ||
49 | * this regulator | ||
50 | * @voltages_len: length of the array of available voltages | ||
51 | */ | 48 | */ |
52 | struct ab3100_regulator { | 49 | struct ab3100_regulator { |
53 | struct regulator_dev *rdev; | 50 | struct regulator_dev *rdev; |
@@ -55,8 +52,6 @@ struct ab3100_regulator { | |||
55 | struct ab3100_platform_data *plfdata; | 52 | struct ab3100_platform_data *plfdata; |
56 | u8 regreg; | 53 | u8 regreg; |
57 | int fixed_voltage; | 54 | int fixed_voltage; |
58 | int const *typ_voltages; | ||
59 | u8 voltages_len; | ||
60 | }; | 55 | }; |
61 | 56 | ||
62 | /* The order in which registers are initialized */ | 57 | /* The order in which registers are initialized */ |
@@ -80,7 +75,7 @@ static const u8 ab3100_reg_init_order[AB3100_NUM_REGULATORS+2] = { | |||
80 | #define LDO_C_VOLTAGE 2650000 | 75 | #define LDO_C_VOLTAGE 2650000 |
81 | #define LDO_D_VOLTAGE 2650000 | 76 | #define LDO_D_VOLTAGE 2650000 |
82 | 77 | ||
83 | static const int ldo_e_buck_typ_voltages[] = { | 78 | static const unsigned int ldo_e_buck_typ_voltages[] = { |
84 | 1800000, | 79 | 1800000, |
85 | 1400000, | 80 | 1400000, |
86 | 1300000, | 81 | 1300000, |
@@ -90,7 +85,7 @@ static const int ldo_e_buck_typ_voltages[] = { | |||
90 | 900000, | 85 | 900000, |
91 | }; | 86 | }; |
92 | 87 | ||
93 | static const int ldo_f_typ_voltages[] = { | 88 | static const unsigned int ldo_f_typ_voltages[] = { |
94 | 1800000, | 89 | 1800000, |
95 | 1400000, | 90 | 1400000, |
96 | 1300000, | 91 | 1300000, |
@@ -101,21 +96,21 @@ static const int ldo_f_typ_voltages[] = { | |||
101 | 2650000, | 96 | 2650000, |
102 | }; | 97 | }; |
103 | 98 | ||
104 | static const int ldo_g_typ_voltages[] = { | 99 | static const unsigned int ldo_g_typ_voltages[] = { |
105 | 2850000, | 100 | 2850000, |
106 | 2750000, | 101 | 2750000, |
107 | 1800000, | 102 | 1800000, |
108 | 1500000, | 103 | 1500000, |
109 | }; | 104 | }; |
110 | 105 | ||
111 | static const int ldo_h_typ_voltages[] = { | 106 | static const unsigned int ldo_h_typ_voltages[] = { |
112 | 2750000, | 107 | 2750000, |
113 | 1800000, | 108 | 1800000, |
114 | 1500000, | 109 | 1500000, |
115 | 1200000, | 110 | 1200000, |
116 | }; | 111 | }; |
117 | 112 | ||
118 | static const int ldo_k_typ_voltages[] = { | 113 | static const unsigned int ldo_k_typ_voltages[] = { |
119 | 2750000, | 114 | 2750000, |
120 | 1800000, | 115 | 1800000, |
121 | }; | 116 | }; |
@@ -138,28 +133,18 @@ ab3100_regulators[AB3100_NUM_REGULATORS] = { | |||
138 | }, | 133 | }, |
139 | { | 134 | { |
140 | .regreg = AB3100_LDO_E, | 135 | .regreg = AB3100_LDO_E, |
141 | .typ_voltages = ldo_e_buck_typ_voltages, | ||
142 | .voltages_len = ARRAY_SIZE(ldo_e_buck_typ_voltages), | ||
143 | }, | 136 | }, |
144 | { | 137 | { |
145 | .regreg = AB3100_LDO_F, | 138 | .regreg = AB3100_LDO_F, |
146 | .typ_voltages = ldo_f_typ_voltages, | ||
147 | .voltages_len = ARRAY_SIZE(ldo_f_typ_voltages), | ||
148 | }, | 139 | }, |
149 | { | 140 | { |
150 | .regreg = AB3100_LDO_G, | 141 | .regreg = AB3100_LDO_G, |
151 | .typ_voltages = ldo_g_typ_voltages, | ||
152 | .voltages_len = ARRAY_SIZE(ldo_g_typ_voltages), | ||
153 | }, | 142 | }, |
154 | { | 143 | { |
155 | .regreg = AB3100_LDO_H, | 144 | .regreg = AB3100_LDO_H, |
156 | .typ_voltages = ldo_h_typ_voltages, | ||
157 | .voltages_len = ARRAY_SIZE(ldo_h_typ_voltages), | ||
158 | }, | 145 | }, |
159 | { | 146 | { |
160 | .regreg = AB3100_LDO_K, | 147 | .regreg = AB3100_LDO_K, |
161 | .typ_voltages = ldo_k_typ_voltages, | ||
162 | .voltages_len = ARRAY_SIZE(ldo_k_typ_voltages), | ||
163 | }, | 148 | }, |
164 | { | 149 | { |
165 | .regreg = AB3100_LDO_EXT, | 150 | .regreg = AB3100_LDO_EXT, |
@@ -167,8 +152,6 @@ ab3100_regulators[AB3100_NUM_REGULATORS] = { | |||
167 | }, | 152 | }, |
168 | { | 153 | { |
169 | .regreg = AB3100_BUCK, | 154 | .regreg = AB3100_BUCK, |
170 | .typ_voltages = ldo_e_buck_typ_voltages, | ||
171 | .voltages_len = ARRAY_SIZE(ldo_e_buck_typ_voltages), | ||
172 | }, | 155 | }, |
173 | }; | 156 | }; |
174 | 157 | ||
@@ -257,16 +240,6 @@ static int ab3100_is_enabled_regulator(struct regulator_dev *reg) | |||
257 | return regval & AB3100_REG_ON_MASK; | 240 | return regval & AB3100_REG_ON_MASK; |
258 | } | 241 | } |
259 | 242 | ||
260 | static int ab3100_list_voltage_regulator(struct regulator_dev *reg, | ||
261 | unsigned selector) | ||
262 | { | ||
263 | struct ab3100_regulator *abreg = reg->reg_data; | ||
264 | |||
265 | if (selector >= abreg->voltages_len) | ||
266 | return -EINVAL; | ||
267 | return abreg->typ_voltages[selector]; | ||
268 | } | ||
269 | |||
270 | static int ab3100_get_voltage_regulator(struct regulator_dev *reg) | 243 | static int ab3100_get_voltage_regulator(struct regulator_dev *reg) |
271 | { | 244 | { |
272 | struct ab3100_regulator *abreg = reg->reg_data; | 245 | struct ab3100_regulator *abreg = reg->reg_data; |
@@ -294,14 +267,14 @@ static int ab3100_get_voltage_regulator(struct regulator_dev *reg) | |||
294 | regval &= 0xE0; | 267 | regval &= 0xE0; |
295 | regval >>= 5; | 268 | regval >>= 5; |
296 | 269 | ||
297 | if (regval >= abreg->voltages_len) { | 270 | if (regval >= reg->desc->n_voltages) { |
298 | dev_err(®->dev, | 271 | dev_err(®->dev, |
299 | "regulator register %02x contains an illegal voltage setting\n", | 272 | "regulator register %02x contains an illegal voltage setting\n", |
300 | abreg->regreg); | 273 | abreg->regreg); |
301 | return -EINVAL; | 274 | return -EINVAL; |
302 | } | 275 | } |
303 | 276 | ||
304 | return abreg->typ_voltages[regval]; | 277 | return reg->desc->volt_table[regval]; |
305 | } | 278 | } |
306 | 279 | ||
307 | static int ab3100_set_voltage_regulator_sel(struct regulator_dev *reg, | 280 | static int ab3100_set_voltage_regulator_sel(struct regulator_dev *reg, |
@@ -423,7 +396,7 @@ static struct regulator_ops regulator_ops_variable = { | |||
423 | .is_enabled = ab3100_is_enabled_regulator, | 396 | .is_enabled = ab3100_is_enabled_regulator, |
424 | .get_voltage = ab3100_get_voltage_regulator, | 397 | .get_voltage = ab3100_get_voltage_regulator, |
425 | .set_voltage_sel = ab3100_set_voltage_regulator_sel, | 398 | .set_voltage_sel = ab3100_set_voltage_regulator_sel, |
426 | .list_voltage = ab3100_list_voltage_regulator, | 399 | .list_voltage = regulator_list_voltage_table, |
427 | .enable_time = ab3100_enable_time_regulator, | 400 | .enable_time = ab3100_enable_time_regulator, |
428 | }; | 401 | }; |
429 | 402 | ||
@@ -434,7 +407,7 @@ static struct regulator_ops regulator_ops_variable_sleepable = { | |||
434 | .get_voltage = ab3100_get_voltage_regulator, | 407 | .get_voltage = ab3100_get_voltage_regulator, |
435 | .set_voltage_sel = ab3100_set_voltage_regulator_sel, | 408 | .set_voltage_sel = ab3100_set_voltage_regulator_sel, |
436 | .set_suspend_voltage = ab3100_set_suspend_voltage_regulator, | 409 | .set_suspend_voltage = ab3100_set_suspend_voltage_regulator, |
437 | .list_voltage = ab3100_list_voltage_regulator, | 410 | .list_voltage = regulator_list_voltage_table, |
438 | .enable_time = ab3100_enable_time_regulator, | 411 | .enable_time = ab3100_enable_time_regulator, |
439 | }; | 412 | }; |
440 | 413 | ||
@@ -479,6 +452,7 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = { | |||
479 | .id = AB3100_LDO_E, | 452 | .id = AB3100_LDO_E, |
480 | .ops = ®ulator_ops_variable_sleepable, | 453 | .ops = ®ulator_ops_variable_sleepable, |
481 | .n_voltages = ARRAY_SIZE(ldo_e_buck_typ_voltages), | 454 | .n_voltages = ARRAY_SIZE(ldo_e_buck_typ_voltages), |
455 | .volt_table = ldo_e_buck_typ_voltages, | ||
482 | .type = REGULATOR_VOLTAGE, | 456 | .type = REGULATOR_VOLTAGE, |
483 | .owner = THIS_MODULE, | 457 | .owner = THIS_MODULE, |
484 | }, | 458 | }, |
@@ -487,6 +461,7 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = { | |||
487 | .id = AB3100_LDO_F, | 461 | .id = AB3100_LDO_F, |
488 | .ops = ®ulator_ops_variable, | 462 | .ops = ®ulator_ops_variable, |
489 | .n_voltages = ARRAY_SIZE(ldo_f_typ_voltages), | 463 | .n_voltages = ARRAY_SIZE(ldo_f_typ_voltages), |
464 | .volt_table = ldo_f_typ_voltages, | ||
490 | .type = REGULATOR_VOLTAGE, | 465 | .type = REGULATOR_VOLTAGE, |
491 | .owner = THIS_MODULE, | 466 | .owner = THIS_MODULE, |
492 | }, | 467 | }, |
@@ -495,6 +470,7 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = { | |||
495 | .id = AB3100_LDO_G, | 470 | .id = AB3100_LDO_G, |
496 | .ops = ®ulator_ops_variable, | 471 | .ops = ®ulator_ops_variable, |
497 | .n_voltages = ARRAY_SIZE(ldo_g_typ_voltages), | 472 | .n_voltages = ARRAY_SIZE(ldo_g_typ_voltages), |
473 | .volt_table = ldo_g_typ_voltages, | ||
498 | .type = REGULATOR_VOLTAGE, | 474 | .type = REGULATOR_VOLTAGE, |
499 | .owner = THIS_MODULE, | 475 | .owner = THIS_MODULE, |
500 | }, | 476 | }, |
@@ -503,6 +479,7 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = { | |||
503 | .id = AB3100_LDO_H, | 479 | .id = AB3100_LDO_H, |
504 | .ops = ®ulator_ops_variable, | 480 | .ops = ®ulator_ops_variable, |
505 | .n_voltages = ARRAY_SIZE(ldo_h_typ_voltages), | 481 | .n_voltages = ARRAY_SIZE(ldo_h_typ_voltages), |
482 | .volt_table = ldo_h_typ_voltages, | ||
506 | .type = REGULATOR_VOLTAGE, | 483 | .type = REGULATOR_VOLTAGE, |
507 | .owner = THIS_MODULE, | 484 | .owner = THIS_MODULE, |
508 | }, | 485 | }, |
@@ -511,6 +488,7 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = { | |||
511 | .id = AB3100_LDO_K, | 488 | .id = AB3100_LDO_K, |
512 | .ops = ®ulator_ops_variable, | 489 | .ops = ®ulator_ops_variable, |
513 | .n_voltages = ARRAY_SIZE(ldo_k_typ_voltages), | 490 | .n_voltages = ARRAY_SIZE(ldo_k_typ_voltages), |
491 | .volt_table = ldo_k_typ_voltages, | ||
514 | .type = REGULATOR_VOLTAGE, | 492 | .type = REGULATOR_VOLTAGE, |
515 | .owner = THIS_MODULE, | 493 | .owner = THIS_MODULE, |
516 | }, | 494 | }, |