diff options
author | Eric Jeong <eric.jeong.opensource@diasemi.com> | 2016-09-26 03:33:27 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2016-09-26 11:59:08 -0400 |
commit | 5ff00f6aa84b7f4203f525fc6c4a4291e32c314d (patch) | |
tree | 95c7aeac31b0127426b5730592396ea53e723ddd /drivers/regulator | |
parent | 29b4817d4018df78086157ea3a55c1d9424a7cfc (diff) |
regulator: pv88080: Update regulator for PV88080 BB silicon support
Three files are modified, the driver, header file and the binding document.
Updates for the regulator source file include and .of_match_table entry
and node match checking in the probe() function for a compatible pv88080
silicon type. A new "HVBUCK" is added in source file and added
regsiter definition in header file for pv88080 bb silicion.
The binding documentation changes have been made to reflect these updates.
Signed-off-by: Eric Jeong <eric.jeong.opensource@diasemi.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/pv88080-regulator.c | 263 | ||||
-rw-r--r-- | drivers/regulator/pv88080-regulator.h | 114 |
2 files changed, 304 insertions, 73 deletions
diff --git a/drivers/regulator/pv88080-regulator.c b/drivers/regulator/pv88080-regulator.c index 81950bdb1cc4..954a20eeb26f 100644 --- a/drivers/regulator/pv88080-regulator.c +++ b/drivers/regulator/pv88080-regulator.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/err.h> | 16 | #include <linux/err.h> |
17 | #include <linux/i2c.h> | 17 | #include <linux/i2c.h> |
18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
19 | #include <linux/of.h> | ||
19 | #include <linux/init.h> | 20 | #include <linux/init.h> |
20 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
21 | #include <linux/regulator/driver.h> | 22 | #include <linux/regulator/driver.h> |
@@ -26,7 +27,7 @@ | |||
26 | #include <linux/regulator/of_regulator.h> | 27 | #include <linux/regulator/of_regulator.h> |
27 | #include "pv88080-regulator.h" | 28 | #include "pv88080-regulator.h" |
28 | 29 | ||
29 | #define PV88080_MAX_REGULATORS 3 | 30 | #define PV88080_MAX_REGULATORS 4 |
30 | 31 | ||
31 | /* PV88080 REGULATOR IDs */ | 32 | /* PV88080 REGULATOR IDs */ |
32 | enum { | 33 | enum { |
@@ -34,6 +35,12 @@ enum { | |||
34 | PV88080_ID_BUCK1, | 35 | PV88080_ID_BUCK1, |
35 | PV88080_ID_BUCK2, | 36 | PV88080_ID_BUCK2, |
36 | PV88080_ID_BUCK3, | 37 | PV88080_ID_BUCK3, |
38 | PV88080_ID_HVBUCK, | ||
39 | }; | ||
40 | |||
41 | enum pv88080_types { | ||
42 | TYPE_PV88080_AA, | ||
43 | TYPE_PV88080_BA, | ||
37 | }; | 44 | }; |
38 | 45 | ||
39 | struct pv88080_regulator { | 46 | struct pv88080_regulator { |
@@ -42,7 +49,8 @@ struct pv88080_regulator { | |||
42 | unsigned int n_current_limits; | 49 | unsigned int n_current_limits; |
43 | const int *current_limits; | 50 | const int *current_limits; |
44 | unsigned int limit_mask; | 51 | unsigned int limit_mask; |
45 | unsigned int conf; | 52 | unsigned int mode_reg; |
53 | unsigned int limit_reg; | ||
46 | unsigned int conf2; | 54 | unsigned int conf2; |
47 | unsigned int conf5; | 55 | unsigned int conf5; |
48 | }; | 56 | }; |
@@ -51,6 +59,8 @@ struct pv88080 { | |||
51 | struct device *dev; | 59 | struct device *dev; |
52 | struct regmap *regmap; | 60 | struct regmap *regmap; |
53 | struct regulator_dev *rdev[PV88080_MAX_REGULATORS]; | 61 | struct regulator_dev *rdev[PV88080_MAX_REGULATORS]; |
62 | unsigned long type; | ||
63 | const struct pv88080_compatible_regmap *regmap_config; | ||
54 | }; | 64 | }; |
55 | 65 | ||
56 | struct pv88080_buck_voltage { | 66 | struct pv88080_buck_voltage { |
@@ -59,6 +69,30 @@ struct pv88080_buck_voltage { | |||
59 | int uV_step; | 69 | int uV_step; |
60 | }; | 70 | }; |
61 | 71 | ||
72 | struct pv88080_buck_regmap { | ||
73 | /* REGS */ | ||
74 | int buck_enable_reg; | ||
75 | int buck_vsel_reg; | ||
76 | int buck_mode_reg; | ||
77 | int buck_limit_reg; | ||
78 | int buck_vdac_range_reg; | ||
79 | int buck_vrange_gain_reg; | ||
80 | /* MASKS */ | ||
81 | int buck_enable_mask; | ||
82 | int buck_vsel_mask; | ||
83 | int buck_limit_mask; | ||
84 | }; | ||
85 | |||
86 | struct pv88080_compatible_regmap { | ||
87 | /* BUCK1, 2, 3 */ | ||
88 | struct pv88080_buck_regmap buck_regmap[PV88080_MAX_REGULATORS-1]; | ||
89 | /* HVBUCK */ | ||
90 | int hvbuck_enable_reg; | ||
91 | int hvbuck_vsel_reg; | ||
92 | int hvbuck_enable_mask; | ||
93 | int hvbuck_vsel_mask; | ||
94 | }; | ||
95 | |||
62 | static const struct regmap_config pv88080_regmap_config = { | 96 | static const struct regmap_config pv88080_regmap_config = { |
63 | .reg_bits = 8, | 97 | .reg_bits = 8, |
64 | .val_bits = 8, | 98 | .val_bits = 8, |
@@ -89,13 +123,111 @@ static const struct pv88080_buck_voltage pv88080_buck_vol[2] = { | |||
89 | }, | 123 | }, |
90 | }; | 124 | }; |
91 | 125 | ||
126 | static const struct pv88080_compatible_regmap pv88080_aa_regs = { | ||
127 | /* BUCK1 */ | ||
128 | .buck_regmap[0] = { | ||
129 | .buck_enable_reg = PV88080AA_REG_BUCK1_CONF0, | ||
130 | .buck_vsel_reg = PV88080AA_REG_BUCK1_CONF0, | ||
131 | .buck_mode_reg = PV88080AA_REG_BUCK1_CONF1, | ||
132 | .buck_limit_reg = PV88080AA_REG_BUCK1_CONF1, | ||
133 | .buck_vdac_range_reg = PV88080AA_REG_BUCK1_CONF2, | ||
134 | .buck_vrange_gain_reg = PV88080AA_REG_BUCK1_CONF5, | ||
135 | .buck_enable_mask = PV88080_BUCK1_EN, | ||
136 | .buck_vsel_mask = PV88080_VBUCK1_MASK, | ||
137 | .buck_limit_mask = PV88080_BUCK1_ILIM_MASK, | ||
138 | }, | ||
139 | /* BUCK2 */ | ||
140 | .buck_regmap[1] = { | ||
141 | .buck_enable_reg = PV88080AA_REG_BUCK2_CONF0, | ||
142 | .buck_vsel_reg = PV88080AA_REG_BUCK2_CONF0, | ||
143 | .buck_mode_reg = PV88080AA_REG_BUCK2_CONF1, | ||
144 | .buck_limit_reg = PV88080AA_REG_BUCK2_CONF1, | ||
145 | .buck_vdac_range_reg = PV88080AA_REG_BUCK2_CONF2, | ||
146 | .buck_vrange_gain_reg = PV88080AA_REG_BUCK2_CONF5, | ||
147 | .buck_enable_mask = PV88080_BUCK2_EN, | ||
148 | .buck_vsel_mask = PV88080_VBUCK2_MASK, | ||
149 | .buck_limit_mask = PV88080_BUCK2_ILIM_MASK, | ||
150 | }, | ||
151 | /* BUCK3 */ | ||
152 | .buck_regmap[2] = { | ||
153 | .buck_enable_reg = PV88080AA_REG_BUCK3_CONF0, | ||
154 | .buck_vsel_reg = PV88080AA_REG_BUCK3_CONF0, | ||
155 | .buck_mode_reg = PV88080AA_REG_BUCK3_CONF1, | ||
156 | .buck_limit_reg = PV88080AA_REG_BUCK3_CONF1, | ||
157 | .buck_vdac_range_reg = PV88080AA_REG_BUCK3_CONF2, | ||
158 | .buck_vrange_gain_reg = PV88080AA_REG_BUCK3_CONF5, | ||
159 | .buck_enable_mask = PV88080_BUCK3_EN, | ||
160 | .buck_vsel_mask = PV88080_VBUCK3_MASK, | ||
161 | .buck_limit_mask = PV88080_BUCK3_ILIM_MASK, | ||
162 | }, | ||
163 | /* HVBUCK */ | ||
164 | .hvbuck_enable_reg = PV88080AA_REG_HVBUCK_CONF2, | ||
165 | .hvbuck_vsel_reg = PV88080AA_REG_HVBUCK_CONF1, | ||
166 | .hvbuck_enable_mask = PV88080_HVBUCK_EN, | ||
167 | .hvbuck_vsel_mask = PV88080_VHVBUCK_MASK, | ||
168 | }; | ||
169 | |||
170 | static const struct pv88080_compatible_regmap pv88080_ba_regs = { | ||
171 | /* BUCK1 */ | ||
172 | .buck_regmap[0] = { | ||
173 | .buck_enable_reg = PV88080BA_REG_BUCK1_CONF0, | ||
174 | .buck_vsel_reg = PV88080BA_REG_BUCK1_CONF0, | ||
175 | .buck_mode_reg = PV88080BA_REG_BUCK1_CONF1, | ||
176 | .buck_limit_reg = PV88080BA_REG_BUCK1_CONF1, | ||
177 | .buck_vdac_range_reg = PV88080BA_REG_BUCK1_CONF2, | ||
178 | .buck_vrange_gain_reg = PV88080BA_REG_BUCK1_CONF5, | ||
179 | .buck_enable_mask = PV88080_BUCK1_EN, | ||
180 | .buck_vsel_mask = PV88080_VBUCK1_MASK, | ||
181 | .buck_limit_mask = PV88080_BUCK1_ILIM_MASK, | ||
182 | }, | ||
183 | /* BUCK2 */ | ||
184 | .buck_regmap[1] = { | ||
185 | .buck_enable_reg = PV88080BA_REG_BUCK2_CONF0, | ||
186 | .buck_vsel_reg = PV88080BA_REG_BUCK2_CONF0, | ||
187 | .buck_mode_reg = PV88080BA_REG_BUCK2_CONF1, | ||
188 | .buck_limit_reg = PV88080BA_REG_BUCK2_CONF1, | ||
189 | .buck_vdac_range_reg = PV88080BA_REG_BUCK2_CONF2, | ||
190 | .buck_vrange_gain_reg = PV88080BA_REG_BUCK2_CONF5, | ||
191 | .buck_enable_mask = PV88080_BUCK2_EN, | ||
192 | .buck_vsel_mask = PV88080_VBUCK2_MASK, | ||
193 | .buck_limit_mask = PV88080_BUCK2_ILIM_MASK, | ||
194 | }, | ||
195 | /* BUCK3 */ | ||
196 | .buck_regmap[2] = { | ||
197 | .buck_enable_reg = PV88080BA_REG_BUCK3_CONF0, | ||
198 | .buck_vsel_reg = PV88080BA_REG_BUCK3_CONF0, | ||
199 | .buck_mode_reg = PV88080BA_REG_BUCK3_CONF1, | ||
200 | .buck_limit_reg = PV88080BA_REG_BUCK3_CONF1, | ||
201 | .buck_vdac_range_reg = PV88080BA_REG_BUCK3_CONF2, | ||
202 | .buck_vrange_gain_reg = PV88080BA_REG_BUCK3_CONF5, | ||
203 | .buck_enable_mask = PV88080_BUCK3_EN, | ||
204 | .buck_vsel_mask = PV88080_VBUCK3_MASK, | ||
205 | .buck_limit_mask = PV88080_BUCK3_ILIM_MASK, | ||
206 | }, | ||
207 | /* HVBUCK */ | ||
208 | .hvbuck_enable_reg = PV88080BA_REG_HVBUCK_CONF2, | ||
209 | .hvbuck_vsel_reg = PV88080BA_REG_HVBUCK_CONF1, | ||
210 | .hvbuck_enable_mask = PV88080_HVBUCK_EN, | ||
211 | .hvbuck_vsel_mask = PV88080_VHVBUCK_MASK, | ||
212 | }; | ||
213 | |||
214 | #ifdef CONFIG_OF | ||
215 | static const struct of_device_id pv88080_dt_ids[] = { | ||
216 | { .compatible = "pvs,pv88080", .data = (void *)TYPE_PV88080_AA }, | ||
217 | { .compatible = "pvs,pv88080-aa", .data = (void *)TYPE_PV88080_AA }, | ||
218 | { .compatible = "pvs,pv88080-ba", .data = (void *)TYPE_PV88080_BA }, | ||
219 | {}, | ||
220 | }; | ||
221 | MODULE_DEVICE_TABLE(of, pv88080_dt_ids); | ||
222 | #endif | ||
223 | |||
92 | static unsigned int pv88080_buck_get_mode(struct regulator_dev *rdev) | 224 | static unsigned int pv88080_buck_get_mode(struct regulator_dev *rdev) |
93 | { | 225 | { |
94 | struct pv88080_regulator *info = rdev_get_drvdata(rdev); | 226 | struct pv88080_regulator *info = rdev_get_drvdata(rdev); |
95 | unsigned int data; | 227 | unsigned int data; |
96 | int ret, mode = 0; | 228 | int ret, mode = 0; |
97 | 229 | ||
98 | ret = regmap_read(rdev->regmap, info->conf, &data); | 230 | ret = regmap_read(rdev->regmap, info->mode_reg, &data); |
99 | if (ret < 0) | 231 | if (ret < 0) |
100 | return ret; | 232 | return ret; |
101 | 233 | ||
@@ -136,7 +268,7 @@ static int pv88080_buck_set_mode(struct regulator_dev *rdev, | |||
136 | return -EINVAL; | 268 | return -EINVAL; |
137 | } | 269 | } |
138 | 270 | ||
139 | return regmap_update_bits(rdev->regmap, info->conf, | 271 | return regmap_update_bits(rdev->regmap, info->mode_reg, |
140 | PV88080_BUCK1_MODE_MASK, val); | 272 | PV88080_BUCK1_MODE_MASK, val); |
141 | } | 273 | } |
142 | 274 | ||
@@ -151,7 +283,7 @@ static int pv88080_set_current_limit(struct regulator_dev *rdev, int min, | |||
151 | if (min <= info->current_limits[i] | 283 | if (min <= info->current_limits[i] |
152 | && max >= info->current_limits[i]) { | 284 | && max >= info->current_limits[i]) { |
153 | return regmap_update_bits(rdev->regmap, | 285 | return regmap_update_bits(rdev->regmap, |
154 | info->conf, | 286 | info->limit_reg, |
155 | info->limit_mask, | 287 | info->limit_mask, |
156 | i << PV88080_BUCK1_ILIM_SHIFT); | 288 | i << PV88080_BUCK1_ILIM_SHIFT); |
157 | } | 289 | } |
@@ -166,7 +298,7 @@ static int pv88080_get_current_limit(struct regulator_dev *rdev) | |||
166 | unsigned int data; | 298 | unsigned int data; |
167 | int ret; | 299 | int ret; |
168 | 300 | ||
169 | ret = regmap_read(rdev->regmap, info->conf, &data); | 301 | ret = regmap_read(rdev->regmap, info->limit_reg, &data); |
170 | if (ret < 0) | 302 | if (ret < 0) |
171 | return ret; | 303 | return ret; |
172 | 304 | ||
@@ -187,6 +319,15 @@ static struct regulator_ops pv88080_buck_ops = { | |||
187 | .get_current_limit = pv88080_get_current_limit, | 319 | .get_current_limit = pv88080_get_current_limit, |
188 | }; | 320 | }; |
189 | 321 | ||
322 | static struct regulator_ops pv88080_hvbuck_ops = { | ||
323 | .enable = regulator_enable_regmap, | ||
324 | .disable = regulator_disable_regmap, | ||
325 | .is_enabled = regulator_is_enabled_regmap, | ||
326 | .set_voltage_sel = regulator_set_voltage_sel_regmap, | ||
327 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | ||
328 | .list_voltage = regulator_list_voltage_linear, | ||
329 | }; | ||
330 | |||
190 | #define PV88080_BUCK(chip, regl_name, min, step, max, limits_array) \ | 331 | #define PV88080_BUCK(chip, regl_name, min, step, max, limits_array) \ |
191 | {\ | 332 | {\ |
192 | .desc = {\ | 333 | .desc = {\ |
@@ -200,17 +341,25 @@ static struct regulator_ops pv88080_buck_ops = { | |||
200 | .min_uV = min, \ | 341 | .min_uV = min, \ |
201 | .uV_step = step, \ | 342 | .uV_step = step, \ |
202 | .n_voltages = ((max) - (min))/(step) + 1, \ | 343 | .n_voltages = ((max) - (min))/(step) + 1, \ |
203 | .enable_reg = PV88080_REG_##regl_name##_CONF0, \ | ||
204 | .enable_mask = PV88080_##regl_name##_EN, \ | ||
205 | .vsel_reg = PV88080_REG_##regl_name##_CONF0, \ | ||
206 | .vsel_mask = PV88080_V##regl_name##_MASK, \ | ||
207 | },\ | 344 | },\ |
208 | .current_limits = limits_array, \ | 345 | .current_limits = limits_array, \ |
209 | .n_current_limits = ARRAY_SIZE(limits_array), \ | 346 | .n_current_limits = ARRAY_SIZE(limits_array), \ |
210 | .limit_mask = PV88080_##regl_name##_ILIM_MASK, \ | 347 | } |
211 | .conf = PV88080_REG_##regl_name##_CONF1, \ | 348 | |
212 | .conf2 = PV88080_REG_##regl_name##_CONF2, \ | 349 | #define PV88080_HVBUCK(chip, regl_name, min, step, max) \ |
213 | .conf5 = PV88080_REG_##regl_name##_CONF5, \ | 350 | {\ |
351 | .desc = {\ | ||
352 | .id = chip##_ID_##regl_name,\ | ||
353 | .name = __stringify(chip##_##regl_name),\ | ||
354 | .of_match = of_match_ptr(#regl_name),\ | ||
355 | .regulators_node = of_match_ptr("regulators"),\ | ||
356 | .type = REGULATOR_VOLTAGE,\ | ||
357 | .owner = THIS_MODULE,\ | ||
358 | .ops = &pv88080_hvbuck_ops,\ | ||
359 | .min_uV = min, \ | ||
360 | .uV_step = step, \ | ||
361 | .n_voltages = ((max) - (min))/(step) + 1, \ | ||
362 | },\ | ||
214 | } | 363 | } |
215 | 364 | ||
216 | static struct pv88080_regulator pv88080_regulator_info[] = { | 365 | static struct pv88080_regulator pv88080_regulator_info[] = { |
@@ -220,6 +369,7 @@ static struct pv88080_regulator pv88080_regulator_info[] = { | |||
220 | pv88080_buck23_limits), | 369 | pv88080_buck23_limits), |
221 | PV88080_BUCK(PV88080, BUCK3, 600000, 6250, 1393750, | 370 | PV88080_BUCK(PV88080, BUCK3, 600000, 6250, 1393750, |
222 | pv88080_buck23_limits), | 371 | pv88080_buck23_limits), |
372 | PV88080_HVBUCK(PV88080, HVBUCK, 0, 5000, 1275000), | ||
223 | }; | 373 | }; |
224 | 374 | ||
225 | static irqreturn_t pv88080_irq_handler(int irq, void *data) | 375 | static irqreturn_t pv88080_irq_handler(int irq, void *data) |
@@ -280,6 +430,8 @@ static int pv88080_i2c_probe(struct i2c_client *i2c, | |||
280 | { | 430 | { |
281 | struct regulator_init_data *init_data = dev_get_platdata(&i2c->dev); | 431 | struct regulator_init_data *init_data = dev_get_platdata(&i2c->dev); |
282 | struct pv88080 *chip; | 432 | struct pv88080 *chip; |
433 | const struct pv88080_compatible_regmap *regmap_config; | ||
434 | const struct of_device_id *match; | ||
283 | struct regulator_config config = { }; | 435 | struct regulator_config config = { }; |
284 | int i, error, ret; | 436 | int i, error, ret; |
285 | unsigned int conf2, conf5; | 437 | unsigned int conf2, conf5; |
@@ -297,6 +449,17 @@ static int pv88080_i2c_probe(struct i2c_client *i2c, | |||
297 | return error; | 449 | return error; |
298 | } | 450 | } |
299 | 451 | ||
452 | if (i2c->dev.of_node) { | ||
453 | match = of_match_node(pv88080_dt_ids, i2c->dev.of_node); | ||
454 | if (!match) { | ||
455 | dev_err(chip->dev, "Failed to get of_match_node\n"); | ||
456 | return -EINVAL; | ||
457 | } | ||
458 | chip->type = (unsigned long)match->data; | ||
459 | } else { | ||
460 | chip->type = id->driver_data; | ||
461 | } | ||
462 | |||
300 | i2c_set_clientdata(i2c, chip); | 463 | i2c_set_clientdata(i2c, chip); |
301 | 464 | ||
302 | if (i2c->irq != 0) { | 465 | if (i2c->irq != 0) { |
@@ -336,31 +499,58 @@ static int pv88080_i2c_probe(struct i2c_client *i2c, | |||
336 | "Failed to update mask reg: %d\n", ret); | 499 | "Failed to update mask reg: %d\n", ret); |
337 | return ret; | 500 | return ret; |
338 | } | 501 | } |
339 | |||
340 | } else { | 502 | } else { |
341 | dev_warn(chip->dev, "No IRQ configured\n"); | 503 | dev_warn(chip->dev, "No IRQ configured\n"); |
342 | } | 504 | } |
343 | 505 | ||
506 | switch (chip->type) { | ||
507 | case TYPE_PV88080_AA: | ||
508 | chip->regmap_config = &pv88080_aa_regs; | ||
509 | break; | ||
510 | case TYPE_PV88080_BA: | ||
511 | chip->regmap_config = &pv88080_ba_regs; | ||
512 | break; | ||
513 | } | ||
514 | |||
515 | regmap_config = chip->regmap_config; | ||
344 | config.dev = chip->dev; | 516 | config.dev = chip->dev; |
345 | config.regmap = chip->regmap; | 517 | config.regmap = chip->regmap; |
346 | 518 | ||
347 | for (i = 0; i < PV88080_MAX_REGULATORS; i++) { | 519 | /* Registeration for BUCK1, 2, 3 */ |
520 | for (i = 0; i < PV88080_MAX_REGULATORS-1; i++) { | ||
348 | if (init_data) | 521 | if (init_data) |
349 | config.init_data = &init_data[i]; | 522 | config.init_data = &init_data[i]; |
350 | 523 | ||
524 | pv88080_regulator_info[i].limit_reg | ||
525 | = regmap_config->buck_regmap[i].buck_limit_reg; | ||
526 | pv88080_regulator_info[i].limit_mask | ||
527 | = regmap_config->buck_regmap[i].buck_limit_mask; | ||
528 | pv88080_regulator_info[i].mode_reg | ||
529 | = regmap_config->buck_regmap[i].buck_mode_reg; | ||
530 | pv88080_regulator_info[i].conf2 | ||
531 | = regmap_config->buck_regmap[i].buck_vdac_range_reg; | ||
532 | pv88080_regulator_info[i].conf5 | ||
533 | = regmap_config->buck_regmap[i].buck_vrange_gain_reg; | ||
534 | pv88080_regulator_info[i].desc.enable_reg | ||
535 | = regmap_config->buck_regmap[i].buck_enable_reg; | ||
536 | pv88080_regulator_info[i].desc.enable_mask | ||
537 | = regmap_config->buck_regmap[i].buck_enable_mask; | ||
538 | pv88080_regulator_info[i].desc.vsel_reg | ||
539 | = regmap_config->buck_regmap[i].buck_vsel_reg; | ||
540 | pv88080_regulator_info[i].desc.vsel_mask | ||
541 | = regmap_config->buck_regmap[i].buck_vsel_mask; | ||
542 | |||
351 | ret = regmap_read(chip->regmap, | 543 | ret = regmap_read(chip->regmap, |
352 | pv88080_regulator_info[i].conf2, &conf2); | 544 | pv88080_regulator_info[i].conf2, &conf2); |
353 | if (ret < 0) | 545 | if (ret < 0) |
354 | return ret; | 546 | return ret; |
355 | |||
356 | conf2 = ((conf2 >> PV88080_BUCK_VDAC_RANGE_SHIFT) & | 547 | conf2 = ((conf2 >> PV88080_BUCK_VDAC_RANGE_SHIFT) & |
357 | PV88080_BUCK_VDAC_RANGE_MASK); | 548 | PV88080_BUCK_VDAC_RANGE_MASK); |
358 | 549 | ||
359 | ret = regmap_read(chip->regmap, | 550 | ret = regmap_read(chip->regmap, |
360 | pv88080_regulator_info[i].conf5, &conf5); | 551 | pv88080_regulator_info[i].conf5, &conf5); |
361 | if (ret < 0) | 552 | if (ret < 0) |
362 | return ret; | 553 | return ret; |
363 | |||
364 | conf5 = ((conf5 >> PV88080_BUCK_VRANGE_GAIN_SHIFT) & | 554 | conf5 = ((conf5 >> PV88080_BUCK_VRANGE_GAIN_SHIFT) & |
365 | PV88080_BUCK_VRANGE_GAIN_MASK); | 555 | PV88080_BUCK_VRANGE_GAIN_MASK); |
366 | 556 | ||
@@ -383,23 +573,38 @@ static int pv88080_i2c_probe(struct i2c_client *i2c, | |||
383 | } | 573 | } |
384 | } | 574 | } |
385 | 575 | ||
576 | pv88080_regulator_info[PV88080_ID_HVBUCK].desc.enable_reg | ||
577 | = regmap_config->hvbuck_enable_reg; | ||
578 | pv88080_regulator_info[PV88080_ID_HVBUCK].desc.enable_mask | ||
579 | = regmap_config->hvbuck_enable_mask; | ||
580 | pv88080_regulator_info[PV88080_ID_HVBUCK].desc.vsel_reg | ||
581 | = regmap_config->hvbuck_vsel_reg; | ||
582 | pv88080_regulator_info[PV88080_ID_HVBUCK].desc.vsel_mask | ||
583 | = regmap_config->hvbuck_vsel_mask; | ||
584 | |||
585 | /* Registeration for HVBUCK */ | ||
586 | if (init_data) | ||
587 | config.init_data = &init_data[PV88080_ID_HVBUCK]; | ||
588 | |||
589 | config.driver_data = (void *)&pv88080_regulator_info[PV88080_ID_HVBUCK]; | ||
590 | chip->rdev[PV88080_ID_HVBUCK] = devm_regulator_register(chip->dev, | ||
591 | &pv88080_regulator_info[PV88080_ID_HVBUCK].desc, &config); | ||
592 | if (IS_ERR(chip->rdev[PV88080_ID_HVBUCK])) { | ||
593 | dev_err(chip->dev, "Failed to register PV88080 regulator\n"); | ||
594 | return PTR_ERR(chip->rdev[PV88080_ID_HVBUCK]); | ||
595 | } | ||
596 | |||
386 | return 0; | 597 | return 0; |
387 | } | 598 | } |
388 | 599 | ||
389 | static const struct i2c_device_id pv88080_i2c_id[] = { | 600 | static const struct i2c_device_id pv88080_i2c_id[] = { |
390 | {"pv88080", 0}, | 601 | { "pv88080", TYPE_PV88080_AA }, |
602 | { "pv88080-aa", TYPE_PV88080_AA }, | ||
603 | { "pv88080-ba", TYPE_PV88080_BA }, | ||
391 | {}, | 604 | {}, |
392 | }; | 605 | }; |
393 | MODULE_DEVICE_TABLE(i2c, pv88080_i2c_id); | 606 | MODULE_DEVICE_TABLE(i2c, pv88080_i2c_id); |
394 | 607 | ||
395 | #ifdef CONFIG_OF | ||
396 | static const struct of_device_id pv88080_dt_ids[] = { | ||
397 | { .compatible = "pvs,pv88080", .data = &pv88080_i2c_id[0] }, | ||
398 | {}, | ||
399 | }; | ||
400 | MODULE_DEVICE_TABLE(of, pv88080_dt_ids); | ||
401 | #endif | ||
402 | |||
403 | static struct i2c_driver pv88080_regulator_driver = { | 608 | static struct i2c_driver pv88080_regulator_driver = { |
404 | .driver = { | 609 | .driver = { |
405 | .name = "pv88080", | 610 | .name = "pv88080", |
diff --git a/drivers/regulator/pv88080-regulator.h b/drivers/regulator/pv88080-regulator.h index 5e9afde606f4..ae25ff360e3d 100644 --- a/drivers/regulator/pv88080-regulator.h +++ b/drivers/regulator/pv88080-regulator.h | |||
@@ -17,55 +17,75 @@ | |||
17 | #define __PV88080_REGISTERS_H__ | 17 | #define __PV88080_REGISTERS_H__ |
18 | 18 | ||
19 | /* System Control and Event Registers */ | 19 | /* System Control and Event Registers */ |
20 | #define PV88080_REG_EVENT_A 0x04 | 20 | #define PV88080_REG_EVENT_A 0x04 |
21 | #define PV88080_REG_MASK_A 0x09 | 21 | #define PV88080_REG_MASK_A 0x09 |
22 | #define PV88080_REG_MASK_B 0x0a | 22 | #define PV88080_REG_MASK_B 0x0A |
23 | #define PV88080_REG_MASK_C 0x0b | 23 | #define PV88080_REG_MASK_C 0x0B |
24 | 24 | ||
25 | /* Regulator Registers */ | 25 | /* Regulator Registers - rev. AA */ |
26 | #define PV88080_REG_BUCK1_CONF0 0x27 | 26 | #define PV88080AA_REG_HVBUCK_CONF1 0x2D |
27 | #define PV88080_REG_BUCK1_CONF1 0x28 | 27 | #define PV88080AA_REG_HVBUCK_CONF2 0x2E |
28 | #define PV88080_REG_BUCK1_CONF2 0x59 | 28 | #define PV88080AA_REG_BUCK1_CONF0 0x27 |
29 | #define PV88080_REG_BUCK1_CONF5 0x5c | 29 | #define PV88080AA_REG_BUCK1_CONF1 0x28 |
30 | #define PV88080_REG_BUCK2_CONF0 0x29 | 30 | #define PV88080AA_REG_BUCK1_CONF2 0x59 |
31 | #define PV88080_REG_BUCK2_CONF1 0x2a | 31 | #define PV88080AA_REG_BUCK1_CONF5 0x5C |
32 | #define PV88080_REG_BUCK2_CONF2 0x61 | 32 | #define PV88080AA_REG_BUCK2_CONF0 0x29 |
33 | #define PV88080_REG_BUCK2_CONF5 0x64 | 33 | #define PV88080AA_REG_BUCK2_CONF1 0x2A |
34 | #define PV88080_REG_BUCK3_CONF0 0x2b | 34 | #define PV88080AA_REG_BUCK2_CONF2 0x61 |
35 | #define PV88080_REG_BUCK3_CONF1 0x2c | 35 | #define PV88080AA_REG_BUCK2_CONF5 0x64 |
36 | #define PV88080_REG_BUCK3_CONF2 0x69 | 36 | #define PV88080AA_REG_BUCK3_CONF0 0x2B |
37 | #define PV88080_REG_BUCK3_CONF5 0x6c | 37 | #define PV88080AA_REG_BUCK3_CONF1 0x2C |
38 | #define PV88080AA_REG_BUCK3_CONF2 0x69 | ||
39 | #define PV88080AA_REG_BUCK3_CONF5 0x6C | ||
40 | |||
41 | /* Regulator Registers - rev. BA */ | ||
42 | #define PV88080BA_REG_HVBUCK_CONF1 0x33 | ||
43 | #define PV88080BA_REG_HVBUCK_CONF2 0x34 | ||
44 | #define PV88080BA_REG_BUCK1_CONF0 0x2A | ||
45 | #define PV88080BA_REG_BUCK1_CONF1 0x2C | ||
46 | #define PV88080BA_REG_BUCK1_CONF2 0x5A | ||
47 | #define PV88080BA_REG_BUCK1_CONF5 0x5D | ||
48 | #define PV88080BA_REG_BUCK2_CONF0 0x2D | ||
49 | #define PV88080BA_REG_BUCK2_CONF1 0x2F | ||
50 | #define PV88080BA_REG_BUCK2_CONF2 0x63 | ||
51 | #define PV88080BA_REG_BUCK2_CONF5 0x66 | ||
52 | #define PV88080BA_REG_BUCK3_CONF0 0x30 | ||
53 | #define PV88080BA_REG_BUCK3_CONF1 0x32 | ||
54 | #define PV88080BA_REG_BUCK3_CONF2 0x6C | ||
55 | #define PV88080BA_REG_BUCK3_CONF5 0x6F | ||
38 | 56 | ||
39 | /* PV88080_REG_EVENT_A (addr=0x04) */ | 57 | /* PV88080_REG_EVENT_A (addr=0x04) */ |
40 | #define PV88080_E_VDD_FLT 0x01 | 58 | #define PV88080_E_VDD_FLT 0x01 |
41 | #define PV88080_E_OVER_TEMP 0x02 | 59 | #define PV88080_E_OVER_TEMP 0x02 |
42 | 60 | ||
43 | /* PV88080_REG_MASK_A (addr=0x09) */ | 61 | /* PV88080_REG_MASK_A (addr=0x09) */ |
44 | #define PV88080_M_VDD_FLT 0x01 | 62 | #define PV88080_M_VDD_FLT 0x01 |
45 | #define PV88080_M_OVER_TEMP 0x02 | 63 | #define PV88080_M_OVER_TEMP 0x02 |
46 | 64 | ||
47 | /* PV88080_REG_BUCK1_CONF0 (addr=0x27) */ | 65 | /* PV88080_REG_BUCK1_CONF0 (addr=0x27|0x2A) */ |
48 | #define PV88080_BUCK1_EN 0x80 | 66 | #define PV88080_BUCK1_EN 0x80 |
49 | #define PV88080_VBUCK1_MASK 0x7F | 67 | #define PV88080_VBUCK1_MASK 0x7F |
50 | /* PV88080_REG_BUCK2_CONF0 (addr=0x29) */ | 68 | |
69 | /* PV88080_REG_BUCK2_CONF0 (addr=0x29|0x2D) */ | ||
51 | #define PV88080_BUCK2_EN 0x80 | 70 | #define PV88080_BUCK2_EN 0x80 |
52 | #define PV88080_VBUCK2_MASK 0x7F | 71 | #define PV88080_VBUCK2_MASK 0x7F |
53 | /* PV88080_REG_BUCK3_CONF0 (addr=0x2b) */ | 72 | |
73 | /* PV88080_REG_BUCK3_CONF0 (addr=0x2B|0x30) */ | ||
54 | #define PV88080_BUCK3_EN 0x80 | 74 | #define PV88080_BUCK3_EN 0x80 |
55 | #define PV88080_VBUCK3_MASK 0x7F | 75 | #define PV88080_VBUCK3_MASK 0x7F |
56 | 76 | ||
57 | /* PV88080_REG_BUCK1_CONF1 (addr=0x28) */ | 77 | /* PV88080_REG_BUCK1_CONF1 (addr=0x28|0x2C) */ |
58 | #define PV88080_BUCK1_ILIM_SHIFT 2 | 78 | #define PV88080_BUCK1_ILIM_SHIFT 2 |
59 | #define PV88080_BUCK1_ILIM_MASK 0x0C | 79 | #define PV88080_BUCK1_ILIM_MASK 0x0C |
60 | #define PV88080_BUCK1_MODE_MASK 0x03 | 80 | #define PV88080_BUCK1_MODE_MASK 0x03 |
61 | 81 | ||
62 | /* PV88080_REG_BUCK2_CONF1 (addr=0x2a) */ | 82 | /* PV88080_REG_BUCK2_CONF1 (addr=0x2A|0x2F) */ |
63 | #define PV88080_BUCK2_ILIM_SHIFT 2 | 83 | #define PV88080_BUCK2_ILIM_SHIFT 2 |
64 | #define PV88080_BUCK2_ILIM_MASK 0x0C | 84 | #define PV88080_BUCK2_ILIM_MASK 0x0C |
65 | #define PV88080_BUCK2_MODE_MASK 0x03 | 85 | #define PV88080_BUCK2_MODE_MASK 0x03 |
66 | 86 | ||
67 | /* PV88080_REG_BUCK3_CONF1 (addr=0x2c) */ | 87 | /* PV88080_REG_BUCK3_CONF1 (addr=0x2C|0x32) */ |
68 | #define PV88080_BUCK3_ILIM_SHIFT 2 | 88 | #define PV88080_BUCK3_ILIM_SHIFT 2 |
69 | #define PV88080_BUCK3_ILIM_MASK 0x0C | 89 | #define PV88080_BUCK3_ILIM_MASK 0x0C |
70 | #define PV88080_BUCK3_MODE_MASK 0x03 | 90 | #define PV88080_BUCK3_MODE_MASK 0x03 |
71 | 91 | ||
@@ -73,20 +93,26 @@ | |||
73 | #define PV88080_BUCK_MODE_AUTO 0x01 | 93 | #define PV88080_BUCK_MODE_AUTO 0x01 |
74 | #define PV88080_BUCK_MODE_SYNC 0x02 | 94 | #define PV88080_BUCK_MODE_SYNC 0x02 |
75 | 95 | ||
76 | /* PV88080_REG_BUCK2_CONF2 (addr=0x61) */ | 96 | /* PV88080_REG_HVBUCK_CONF1 (addr=0x2D|0x33) */ |
77 | /* PV88080_REG_BUCK3_CONF2 (addr=0x69) */ | 97 | #define PV88080_VHVBUCK_MASK 0xFF |
78 | #define PV88080_BUCK_VDAC_RANGE_SHIFT 7 | 98 | |
79 | #define PV88080_BUCK_VDAC_RANGE_MASK 0x01 | 99 | /* PV88080_REG_HVBUCK_CONF1 (addr=0x2E|0x34) */ |
100 | #define PV88080_HVBUCK_EN 0x01 | ||
101 | |||
102 | /* PV88080_REG_BUCK2_CONF2 (addr=0x61|0x63) */ | ||
103 | /* PV88080_REG_BUCK3_CONF2 (addr=0x69|0x6C) */ | ||
104 | #define PV88080_BUCK_VDAC_RANGE_SHIFT 7 | ||
105 | #define PV88080_BUCK_VDAC_RANGE_MASK 0x01 | ||
80 | 106 | ||
81 | #define PV88080_BUCK_VDAC_RANGE_1 0x00 | 107 | #define PV88080_BUCK_VDAC_RANGE_1 0x00 |
82 | #define PV88080_BUCK_VDAC_RANGE_2 0x01 | 108 | #define PV88080_BUCK_VDAC_RANGE_2 0x01 |
83 | 109 | ||
84 | /* PV88080_REG_BUCK2_CONF5 (addr=0x64) */ | 110 | /* PV88080_REG_BUCK2_CONF5 (addr=0x64|0x66) */ |
85 | /* PV88080_REG_BUCK3_CONF5 (addr=0x6c) */ | 111 | /* PV88080_REG_BUCK3_CONF5 (addr=0x6C|0x6F) */ |
86 | #define PV88080_BUCK_VRANGE_GAIN_SHIFT 0 | 112 | #define PV88080_BUCK_VRANGE_GAIN_SHIFT 0 |
87 | #define PV88080_BUCK_VRANGE_GAIN_MASK 0x01 | 113 | #define PV88080_BUCK_VRANGE_GAIN_MASK 0x01 |
88 | 114 | ||
89 | #define PV88080_BUCK_VRANGE_GAIN_1 0x00 | 115 | #define PV88080_BUCK_VRANGE_GAIN_1 0x00 |
90 | #define PV88080_BUCK_VRANGE_GAIN_2 0x01 | 116 | #define PV88080_BUCK_VRANGE_GAIN_2 0x01 |
91 | 117 | ||
92 | #endif /* __PV88080_REGISTERS_H__ */ | 118 | #endif /* __PV88080_REGISTERS_H__ */ |