1 // SPDX-License-Identifier: GPL-2.0
3 // tps80031-regulator.c -- TI TPS80031 regulator driver.
5 // Regulator driver for TI TPS80031/TPS80032 Fully Integrated Power
6 // Management with Power Path and Battery Charger.
8 // Copyright (c) 2012, NVIDIA Corporation.
10 // Author: Laxman Dewangan <ldewangan@nvidia.com>
12 #include <linux/delay.h>
13 #include <linux/err.h>
14 #include <linux/init.h>
15 #include <linux/kernel.h>
16 #include <linux/mfd/tps80031.h>
17 #include <linux/module.h>
18 #include <linux/platform_device.h>
19 #include <linux/regulator/driver.h>
20 #include <linux/regulator/machine.h>
21 #include <linux/slab.h>
23 /* Flags for DCDC Voltage reading */
24 #define DCDC_OFFSET_EN BIT(0)
25 #define DCDC_EXTENDED_EN BIT(1)
26 #define TRACK_MODE_ENABLE BIT(2)
28 #define SMPS_MULTOFFSET_VIO BIT(1)
29 #define SMPS_MULTOFFSET_SMPS1 BIT(3)
30 #define SMPS_MULTOFFSET_SMPS2 BIT(4)
31 #define SMPS_MULTOFFSET_SMPS3 BIT(6)
32 #define SMPS_MULTOFFSET_SMPS4 BIT(0)
34 #define SMPS_CMD_MASK 0xC0
35 #define SMPS_VSEL_MASK 0x3F
36 #define LDO_VSEL_MASK 0x1F
37 #define LDO_TRACK_VSEL_MASK 0x3F
39 #define MISC2_LDOUSB_IN_VSYS BIT(4)
40 #define MISC2_LDOUSB_IN_PMID BIT(3)
41 #define MISC2_LDOUSB_IN_MASK 0x18
43 #define MISC2_LDO3_SEL_VIB_VAL BIT(0)
44 #define MISC2_LDO3_SEL_VIB_MASK 0x1
46 #define BOOST_HW_PWR_EN BIT(5)
47 #define BOOST_HW_PWR_EN_MASK BIT(5)
49 #define OPA_MODE_EN BIT(6)
50 #define OPA_MODE_EN_MASK BIT(6)
52 #define USB_VBUS_CTRL_SET 0x04
53 #define USB_VBUS_CTRL_CLR 0x05
54 #define VBUS_DISCHRG 0x20
56 struct tps80031_regulator_info {
57 /* Regulator register address.*/
64 /*Power request bits */
67 /* used by regulator core */
68 struct regulator_desc desc;
72 struct tps80031_regulator {
74 struct tps80031_regulator_info *rinfo;
77 unsigned int config_flags;
78 unsigned int ext_ctrl_flag;
81 static inline struct device *to_tps80031_dev(struct regulator_dev *rdev)
83 return rdev_get_dev(rdev)->parent->parent;
86 static int tps80031_reg_is_enabled(struct regulator_dev *rdev)
88 struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
89 struct device *parent = to_tps80031_dev(rdev);
93 if (ri->ext_ctrl_flag & TPS80031_EXT_PWR_REQ)
96 ret = tps80031_read(parent, TPS80031_SLAVE_ID1, ri->rinfo->state_reg,
99 dev_err(&rdev->dev, "Reg 0x%02x read failed, err = %d\n",
100 ri->rinfo->state_reg, ret);
103 return (reg_val & TPS80031_STATE_MASK) == TPS80031_STATE_ON;
106 static int tps80031_reg_enable(struct regulator_dev *rdev)
108 struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
109 struct device *parent = to_tps80031_dev(rdev);
112 if (ri->ext_ctrl_flag & TPS80031_EXT_PWR_REQ)
115 ret = tps80031_update(parent, TPS80031_SLAVE_ID1, ri->rinfo->state_reg,
116 TPS80031_STATE_ON, TPS80031_STATE_MASK);
118 dev_err(&rdev->dev, "Reg 0x%02x update failed, err = %d\n",
119 ri->rinfo->state_reg, ret);
125 static int tps80031_reg_disable(struct regulator_dev *rdev)
127 struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
128 struct device *parent = to_tps80031_dev(rdev);
131 if (ri->ext_ctrl_flag & TPS80031_EXT_PWR_REQ)
134 ret = tps80031_update(parent, TPS80031_SLAVE_ID1, ri->rinfo->state_reg,
135 TPS80031_STATE_OFF, TPS80031_STATE_MASK);
137 dev_err(&rdev->dev, "Reg 0x%02x update failed, err = %d\n",
138 ri->rinfo->state_reg, ret);
142 /* DCDC voltages for the selector of 58 to 63 */
143 static const int tps80031_dcdc_voltages[4][5] = {
144 { 1350, 1500, 1800, 1900, 2100},
145 { 1350, 1500, 1800, 1900, 2100},
146 { 2084, 2315, 2778, 2932, 3241},
147 { 4167, 2315, 2778, 2932, 3241},
150 static int tps80031_dcdc_list_voltage(struct regulator_dev *rdev, unsigned sel)
152 struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
153 int volt_index = ri->device_flags & 0x3;
158 return regulator_list_voltage_linear(rdev, sel - 1);
160 return tps80031_dcdc_voltages[volt_index][sel - 58] * 1000;
163 static int tps80031_dcdc_set_voltage_sel(struct regulator_dev *rdev,
166 struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
167 struct device *parent = to_tps80031_dev(rdev);
171 if (ri->rinfo->force_reg) {
172 ret = tps80031_read(parent, ri->rinfo->volt_id,
173 ri->rinfo->force_reg, ®_val);
175 dev_err(ri->dev, "reg 0x%02x read failed, e = %d\n",
176 ri->rinfo->force_reg, ret);
179 if (!(reg_val & SMPS_CMD_MASK)) {
180 ret = tps80031_update(parent, ri->rinfo->volt_id,
181 ri->rinfo->force_reg, vsel, SMPS_VSEL_MASK);
184 "reg 0x%02x update failed, e = %d\n",
185 ri->rinfo->force_reg, ret);
189 ret = tps80031_update(parent, ri->rinfo->volt_id,
190 ri->rinfo->volt_reg, vsel, SMPS_VSEL_MASK);
192 dev_err(ri->dev, "reg 0x%02x update failed, e = %d\n",
193 ri->rinfo->volt_reg, ret);
197 static int tps80031_dcdc_get_voltage_sel(struct regulator_dev *rdev)
199 struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
200 struct device *parent = to_tps80031_dev(rdev);
204 if (ri->rinfo->force_reg) {
205 ret = tps80031_read(parent, ri->rinfo->volt_id,
206 ri->rinfo->force_reg, &vsel);
208 dev_err(ri->dev, "reg 0x%02x read failed, e = %d\n",
209 ri->rinfo->force_reg, ret);
213 if (!(vsel & SMPS_CMD_MASK))
214 return vsel & SMPS_VSEL_MASK;
216 ret = tps80031_read(parent, ri->rinfo->volt_id,
217 ri->rinfo->volt_reg, &vsel);
219 dev_err(ri->dev, "reg 0x%02x read failed, e = %d\n",
220 ri->rinfo->volt_reg, ret);
223 return vsel & SMPS_VSEL_MASK;
226 static int tps80031_ldo_list_voltage(struct regulator_dev *rdev,
229 struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
230 struct device *parent = to_tps80031_dev(rdev);
232 /* Check for valid setting for TPS80031 or TPS80032-ES1.0 */
233 if ((ri->rinfo->desc.id == TPS80031_REGULATOR_LDO2) &&
234 (ri->device_flags & TRACK_MODE_ENABLE)) {
235 unsigned nvsel = (sel) & 0x1F;
236 if (((tps80031_get_chip_info(parent) == TPS80031) ||
237 ((tps80031_get_chip_info(parent) == TPS80032) &&
238 (tps80031_get_pmu_version(parent) == 0x0))) &&
239 ((nvsel == 0x0) || (nvsel >= 0x19 && nvsel <= 0x1F))) {
241 "Invalid sel %d in track mode LDO2\n",
247 return regulator_list_voltage_linear(rdev, sel);
250 static int tps80031_ldo_map_voltage(struct regulator_dev *rdev,
251 int min_uV, int max_uV)
253 struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
254 struct device *parent = to_tps80031_dev(rdev);
256 /* Check for valid setting for TPS80031 or TPS80032-ES1.0 */
257 if ((ri->rinfo->desc.id == TPS80031_REGULATOR_LDO2) &&
258 (ri->device_flags & TRACK_MODE_ENABLE)) {
259 if (((tps80031_get_chip_info(parent) == TPS80031) ||
260 ((tps80031_get_chip_info(parent) == TPS80032) &&
261 (tps80031_get_pmu_version(parent) == 0x0)))) {
262 return regulator_map_voltage_iterate(rdev, min_uV,
267 return regulator_map_voltage_linear(rdev, min_uV, max_uV);
270 static int tps80031_vbus_is_enabled(struct regulator_dev *rdev)
272 struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
273 struct device *parent = to_tps80031_dev(rdev);
278 ret = tps80031_read(parent, TPS80031_SLAVE_ID2,
279 TPS80031_CHARGERUSB_CTRL1, &ctrl1);
281 dev_err(ri->dev, "reg 0x%02x read failed, e = %d\n",
282 TPS80031_CHARGERUSB_CTRL1, ret);
285 ret = tps80031_read(parent, TPS80031_SLAVE_ID2,
286 TPS80031_CHARGERUSB_CTRL3, &ctrl3);
288 dev_err(ri->dev, "reg 0x%02x read failed, e = %d\n",
289 TPS80031_CHARGERUSB_CTRL3, ret);
292 if ((ctrl1 & OPA_MODE_EN) && (ctrl3 & BOOST_HW_PWR_EN))
297 static int tps80031_vbus_enable(struct regulator_dev *rdev)
299 struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
300 struct device *parent = to_tps80031_dev(rdev);
303 ret = tps80031_set_bits(parent, TPS80031_SLAVE_ID2,
304 TPS80031_CHARGERUSB_CTRL1, OPA_MODE_EN);
306 dev_err(ri->dev, "reg 0x%02x read failed, e = %d\n",
307 TPS80031_CHARGERUSB_CTRL1, ret);
311 ret = tps80031_set_bits(parent, TPS80031_SLAVE_ID2,
312 TPS80031_CHARGERUSB_CTRL3, BOOST_HW_PWR_EN);
314 dev_err(ri->dev, "reg 0x%02x read failed, e = %d\n",
315 TPS80031_CHARGERUSB_CTRL3, ret);
321 static int tps80031_vbus_disable(struct regulator_dev *rdev)
323 struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
324 struct device *parent = to_tps80031_dev(rdev);
327 if (ri->config_flags & TPS80031_VBUS_DISCHRG_EN_PDN) {
328 ret = tps80031_write(parent, TPS80031_SLAVE_ID2,
329 USB_VBUS_CTRL_SET, VBUS_DISCHRG);
331 dev_err(ri->dev, "reg 0x%02x write failed, e = %d\n",
332 USB_VBUS_CTRL_SET, ret);
337 ret = tps80031_clr_bits(parent, TPS80031_SLAVE_ID2,
338 TPS80031_CHARGERUSB_CTRL1, OPA_MODE_EN);
340 dev_err(ri->dev, "reg 0x%02x clearbit failed, e = %d\n",
341 TPS80031_CHARGERUSB_CTRL1, ret);
345 ret = tps80031_clr_bits(parent, TPS80031_SLAVE_ID2,
346 TPS80031_CHARGERUSB_CTRL3, BOOST_HW_PWR_EN);
348 dev_err(ri->dev, "reg 0x%02x clearbit failed, e = %d\n",
349 TPS80031_CHARGERUSB_CTRL3, ret);
353 mdelay(DIV_ROUND_UP(ri->rinfo->desc.enable_time, 1000));
354 if (ri->config_flags & TPS80031_VBUS_DISCHRG_EN_PDN) {
355 ret = tps80031_write(parent, TPS80031_SLAVE_ID2,
356 USB_VBUS_CTRL_CLR, VBUS_DISCHRG);
358 dev_err(ri->dev, "reg 0x%02x write failed, e = %d\n",
359 USB_VBUS_CTRL_CLR, ret);
366 static const struct regulator_ops tps80031_dcdc_ops = {
367 .list_voltage = tps80031_dcdc_list_voltage,
368 .set_voltage_sel = tps80031_dcdc_set_voltage_sel,
369 .get_voltage_sel = tps80031_dcdc_get_voltage_sel,
370 .enable = tps80031_reg_enable,
371 .disable = tps80031_reg_disable,
372 .is_enabled = tps80031_reg_is_enabled,
375 static const struct regulator_ops tps80031_ldo_ops = {
376 .list_voltage = tps80031_ldo_list_voltage,
377 .map_voltage = tps80031_ldo_map_voltage,
378 .set_voltage_sel = regulator_set_voltage_sel_regmap,
379 .get_voltage_sel = regulator_get_voltage_sel_regmap,
380 .enable = tps80031_reg_enable,
381 .disable = tps80031_reg_disable,
382 .is_enabled = tps80031_reg_is_enabled,
385 static const struct regulator_ops tps80031_vbus_sw_ops = {
386 .list_voltage = regulator_list_voltage_linear,
387 .enable = tps80031_vbus_enable,
388 .disable = tps80031_vbus_disable,
389 .is_enabled = tps80031_vbus_is_enabled,
392 static const struct regulator_ops tps80031_vbus_hw_ops = {
393 .list_voltage = regulator_list_voltage_linear,
396 static const struct regulator_ops tps80031_ext_reg_ops = {
397 .list_voltage = regulator_list_voltage_linear,
398 .enable = tps80031_reg_enable,
399 .disable = tps80031_reg_disable,
400 .is_enabled = tps80031_reg_is_enabled,
403 /* Non-exiting default definition for some register */
404 #define TPS80031_SMPS3_CFG_FORCE 0
405 #define TPS80031_SMPS4_CFG_FORCE 0
407 #define TPS80031_VBUS_CFG_TRANS 0
408 #define TPS80031_VBUS_CFG_STATE 0
410 #define TPS80031_REG_SMPS(_id, _volt_id, _pbit) \
412 .trans_reg = TPS80031_##_id##_CFG_TRANS, \
413 .state_reg = TPS80031_##_id##_CFG_STATE, \
414 .force_reg = TPS80031_##_id##_CFG_FORCE, \
415 .volt_reg = TPS80031_##_id##_CFG_VOLTAGE, \
416 .volt_id = TPS80031_SLAVE_##_volt_id, \
419 .name = "tps80031_"#_id, \
420 .id = TPS80031_REGULATOR_##_id, \
422 .ops = &tps80031_dcdc_ops, \
423 .type = REGULATOR_VOLTAGE, \
424 .owner = THIS_MODULE, \
425 .enable_time = 500, \
429 #define TPS80031_REG_LDO(_id, _preq_bit) \
431 .trans_reg = TPS80031_##_id##_CFG_TRANS, \
432 .state_reg = TPS80031_##_id##_CFG_STATE, \
433 .volt_reg = TPS80031_##_id##_CFG_VOLTAGE, \
434 .volt_id = TPS80031_SLAVE_ID1, \
435 .preq_bit = _preq_bit, \
437 .owner = THIS_MODULE, \
438 .name = "tps80031_"#_id, \
439 .id = TPS80031_REGULATOR_##_id, \
440 .ops = &tps80031_ldo_ops, \
441 .type = REGULATOR_VOLTAGE, \
444 .linear_min_sel = 1, \
446 .vsel_reg = TPS80031_##_id##_CFG_VOLTAGE, \
447 .vsel_mask = LDO_VSEL_MASK, \
448 .enable_time = 500, \
452 #define TPS80031_REG_FIXED(_id, max_mV, _ops, _delay, _pbit) \
454 .trans_reg = TPS80031_##_id##_CFG_TRANS, \
455 .state_reg = TPS80031_##_id##_CFG_STATE, \
456 .volt_id = TPS80031_SLAVE_ID1, \
459 .name = "tps80031_"#_id, \
460 .id = TPS80031_REGULATOR_##_id, \
461 .min_uV = max_mV * 1000, \
464 .type = REGULATOR_VOLTAGE, \
465 .owner = THIS_MODULE, \
466 .enable_time = _delay, \
470 static struct tps80031_regulator_info tps80031_rinfo[TPS80031_REGULATOR_MAX] = {
471 TPS80031_REG_SMPS(VIO, ID0, 4),
472 TPS80031_REG_SMPS(SMPS1, ID0, 0),
473 TPS80031_REG_SMPS(SMPS2, ID0, 1),
474 TPS80031_REG_SMPS(SMPS3, ID1, 2),
475 TPS80031_REG_SMPS(SMPS4, ID1, 3),
476 TPS80031_REG_LDO(VANA, -1),
477 TPS80031_REG_LDO(LDO1, 8),
478 TPS80031_REG_LDO(LDO2, 9),
479 TPS80031_REG_LDO(LDO3, 10),
480 TPS80031_REG_LDO(LDO4, 11),
481 TPS80031_REG_LDO(LDO5, 12),
482 TPS80031_REG_LDO(LDO6, 13),
483 TPS80031_REG_LDO(LDO7, 14),
484 TPS80031_REG_LDO(LDOLN, 15),
485 TPS80031_REG_LDO(LDOUSB, 5),
486 TPS80031_REG_FIXED(VBUS, 5000, tps80031_vbus_hw_ops, 100000, -1),
487 TPS80031_REG_FIXED(REGEN1, 3300, tps80031_ext_reg_ops, 0, 16),
488 TPS80031_REG_FIXED(REGEN2, 3300, tps80031_ext_reg_ops, 0, 17),
489 TPS80031_REG_FIXED(SYSEN, 3300, tps80031_ext_reg_ops, 0, 18),
492 static int tps80031_power_req_config(struct device *parent,
493 struct tps80031_regulator *ri,
494 struct tps80031_regulator_platform_data *tps80031_pdata)
498 if (ri->rinfo->preq_bit < 0)
499 goto skip_pwr_req_config;
501 ret = tps80031_ext_power_req_config(parent, ri->ext_ctrl_flag,
502 ri->rinfo->preq_bit, ri->rinfo->state_reg,
503 ri->rinfo->trans_reg);
505 dev_err(ri->dev, "ext powerreq config failed, err = %d\n", ret);
510 if (tps80031_pdata->ext_ctrl_flag & TPS80031_PWR_ON_ON_SLEEP) {
511 ret = tps80031_update(parent, TPS80031_SLAVE_ID1,
512 ri->rinfo->trans_reg, TPS80031_TRANS_SLEEP_ON,
513 TPS80031_TRANS_SLEEP_MASK);
515 dev_err(ri->dev, "Reg 0x%02x update failed, e %d\n",
516 ri->rinfo->trans_reg, ret);
523 static int tps80031_regulator_config(struct device *parent,
524 struct tps80031_regulator *ri,
525 struct tps80031_regulator_platform_data *tps80031_pdata)
529 switch (ri->rinfo->desc.id) {
530 case TPS80031_REGULATOR_LDOUSB:
531 if (ri->config_flags & (TPS80031_USBLDO_INPUT_VSYS |
532 TPS80031_USBLDO_INPUT_PMID)) {
534 if (ri->config_flags & TPS80031_USBLDO_INPUT_VSYS)
535 val = MISC2_LDOUSB_IN_VSYS;
537 val = MISC2_LDOUSB_IN_PMID;
539 ret = tps80031_update(parent, TPS80031_SLAVE_ID1,
541 MISC2_LDOUSB_IN_MASK);
544 "LDOUSB config failed, e= %d\n", ret);
550 case TPS80031_REGULATOR_LDO3:
551 if (ri->config_flags & TPS80031_LDO3_OUTPUT_VIB) {
552 ret = tps80031_update(parent, TPS80031_SLAVE_ID1,
553 TPS80031_MISC2, MISC2_LDO3_SEL_VIB_VAL,
554 MISC2_LDO3_SEL_VIB_MASK);
557 "LDO3 config failed, e = %d\n", ret);
563 case TPS80031_REGULATOR_VBUS:
564 /* Provide SW control Ops if VBUS is SW control */
565 if (!(ri->config_flags & TPS80031_VBUS_SW_ONLY))
566 ri->rinfo->desc.ops = &tps80031_vbus_sw_ops;
572 /* Configure Active state to ON, SLEEP to OFF and OFF_state to OFF */
573 ret = tps80031_update(parent, TPS80031_SLAVE_ID1, ri->rinfo->trans_reg,
574 TPS80031_TRANS_ACTIVE_ON | TPS80031_TRANS_SLEEP_OFF |
575 TPS80031_TRANS_OFF_OFF, TPS80031_TRANS_ACTIVE_MASK |
576 TPS80031_TRANS_SLEEP_MASK | TPS80031_TRANS_OFF_MASK);
578 dev_err(ri->dev, "trans reg update failed, e %d\n", ret);
585 static int check_smps_mode_mult(struct device *parent,
586 struct tps80031_regulator *ri)
593 ret = tps80031_read(parent, TPS80031_SLAVE_ID1,
594 TPS80031_SMPS_OFFSET, &smps_offset);
596 dev_err(parent, "Error in reading smps offset register\n");
600 ret = tps80031_read(parent, TPS80031_SLAVE_ID1,
601 TPS80031_SMPS_MULT, &smps_mult);
603 dev_err(parent, "Error in reading smps mult register\n");
607 switch (ri->rinfo->desc.id) {
608 case TPS80031_REGULATOR_VIO:
609 mult_offset = SMPS_MULTOFFSET_VIO;
611 case TPS80031_REGULATOR_SMPS1:
612 mult_offset = SMPS_MULTOFFSET_SMPS1;
614 case TPS80031_REGULATOR_SMPS2:
615 mult_offset = SMPS_MULTOFFSET_SMPS2;
617 case TPS80031_REGULATOR_SMPS3:
618 mult_offset = SMPS_MULTOFFSET_SMPS3;
620 case TPS80031_REGULATOR_SMPS4:
621 mult_offset = SMPS_MULTOFFSET_SMPS4;
623 case TPS80031_REGULATOR_LDO2:
624 ri->device_flags = smps_mult & BIT(5) ? TRACK_MODE_ENABLE : 0;
625 /* TRACK mode the ldo2 varies from 600mV to 1300mV */
626 if (ri->device_flags & TRACK_MODE_ENABLE) {
627 ri->rinfo->desc.min_uV = 600000;
628 ri->rinfo->desc.uV_step = 12500;
629 ri->rinfo->desc.n_voltages = 57;
630 ri->rinfo->desc.vsel_mask = LDO_TRACK_VSEL_MASK;
637 ri->device_flags = (smps_offset & mult_offset) ? DCDC_OFFSET_EN : 0;
638 ri->device_flags |= (smps_mult & mult_offset) ? DCDC_EXTENDED_EN : 0;
639 switch (ri->device_flags) {
641 ri->rinfo->desc.min_uV = 607700;
642 ri->rinfo->desc.uV_step = 12660;
645 ri->rinfo->desc.min_uV = 700000;
646 ri->rinfo->desc.uV_step = 12500;
648 case DCDC_EXTENDED_EN:
649 ri->rinfo->desc.min_uV = 1852000;
650 ri->rinfo->desc.uV_step = 38600;
652 case DCDC_OFFSET_EN | DCDC_EXTENDED_EN:
653 ri->rinfo->desc.min_uV = 2161000;
654 ri->rinfo->desc.uV_step = 38600;
660 static int tps80031_regulator_probe(struct platform_device *pdev)
662 struct tps80031_platform_data *pdata;
663 struct tps80031_regulator_platform_data *tps_pdata;
664 struct tps80031_regulator *ri;
665 struct tps80031_regulator *pmic;
666 struct regulator_dev *rdev;
667 struct regulator_config config = { };
668 struct tps80031 *tps80031_mfd = dev_get_drvdata(pdev->dev.parent);
672 pdata = dev_get_platdata(pdev->dev.parent);
675 dev_err(&pdev->dev, "No platform data\n");
679 pmic = devm_kcalloc(&pdev->dev,
680 TPS80031_REGULATOR_MAX, sizeof(*pmic), GFP_KERNEL);
684 for (num = 0; num < TPS80031_REGULATOR_MAX; ++num) {
685 tps_pdata = pdata->regulator_pdata[num];
687 ri->rinfo = &tps80031_rinfo[num];
688 ri->dev = &pdev->dev;
690 check_smps_mode_mult(pdev->dev.parent, ri);
691 config.dev = &pdev->dev;
692 config.init_data = NULL;
693 config.driver_data = ri;
694 config.regmap = tps80031_mfd->regmap[ri->rinfo->volt_id];
697 config.init_data = tps_pdata->reg_init_data;
698 ri->config_flags = tps_pdata->config_flags;
699 ri->ext_ctrl_flag = tps_pdata->ext_ctrl_flag;
700 ret = tps80031_regulator_config(pdev->dev.parent,
704 "regulator config failed, e %d\n", ret);
708 ret = tps80031_power_req_config(pdev->dev.parent,
712 "pwr_req config failed, err %d\n", ret);
716 rdev = devm_regulator_register(&pdev->dev, &ri->rinfo->desc,
720 "register regulator failed %s\n",
721 ri->rinfo->desc.name);
722 return PTR_ERR(rdev);
726 platform_set_drvdata(pdev, pmic);
730 static struct platform_driver tps80031_regulator_driver = {
732 .name = "tps80031-pmic",
734 .probe = tps80031_regulator_probe,
737 static int __init tps80031_regulator_init(void)
739 return platform_driver_register(&tps80031_regulator_driver);
741 subsys_initcall(tps80031_regulator_init);
743 static void __exit tps80031_regulator_exit(void)
745 platform_driver_unregister(&tps80031_regulator_driver);
747 module_exit(tps80031_regulator_exit);
749 MODULE_ALIAS("platform:tps80031-regulator");
750 MODULE_DESCRIPTION("Regulator Driver for TI TPS80031/TPS80032 PMIC");
751 MODULE_AUTHOR("Laxman Dewangan <ldewangan@nvidia.com>");
752 MODULE_LICENSE("GPL v2");