diff options
author | Markus Pargmann <mpa@pengutronix.de> | 2013-12-20 06:43:27 -0500 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-12-21 09:49:19 -0500 |
commit | 03746dcbde75fc2b0ee8a9d65e3fb3efee8deb4a (patch) | |
tree | d2e3c19951753e58df2d6e93d5ce26ab28999a8a /drivers/regulator/tps65910-regulator.c | |
parent | 6ce4eac1f600b34f2f7f58f9cd8f0503d79e42ae (diff) |
regulator: tps65910: Add backup battery regulator
tps65910 has a backup battery charger with a configurable voltage. This
patch adds a regulator for the backup battery.
Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/regulator/tps65910-regulator.c')
-rw-r--r-- | drivers/regulator/tps65910-regulator.c | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/drivers/regulator/tps65910-regulator.c b/drivers/regulator/tps65910-regulator.c index a00132e31ec7..979ea0a99a79 100644 --- a/drivers/regulator/tps65910-regulator.c +++ b/drivers/regulator/tps65910-regulator.c | |||
@@ -88,6 +88,11 @@ static const unsigned int VMMC_VSEL_table[] = { | |||
88 | 1800000, 2800000, 3000000, 3300000, | 88 | 1800000, 2800000, 3000000, 3300000, |
89 | }; | 89 | }; |
90 | 90 | ||
91 | /* supported BBCH voltages in microvolts */ | ||
92 | static const unsigned int VBB_VSEL_table[] = { | ||
93 | 3000000, 2520000, 3150000, 5000000, | ||
94 | }; | ||
95 | |||
91 | struct tps_info { | 96 | struct tps_info { |
92 | const char *name; | 97 | const char *name; |
93 | const char *vin_name; | 98 | const char *vin_name; |
@@ -183,6 +188,12 @@ static struct tps_info tps65910_regs[] = { | |||
183 | .voltage_table = VMMC_VSEL_table, | 188 | .voltage_table = VMMC_VSEL_table, |
184 | .enable_time_us = 100, | 189 | .enable_time_us = 100, |
185 | }, | 190 | }, |
191 | { | ||
192 | .name = "vbb", | ||
193 | .vin_name = "vcc7", | ||
194 | .n_voltages = ARRAY_SIZE(VBB_VSEL_table), | ||
195 | .voltage_table = VBB_VSEL_table, | ||
196 | }, | ||
186 | }; | 197 | }; |
187 | 198 | ||
188 | static struct tps_info tps65911_regs[] = { | 199 | static struct tps_info tps65911_regs[] = { |
@@ -339,6 +350,8 @@ static int tps65910_get_ctrl_register(int id) | |||
339 | return TPS65910_VAUX33; | 350 | return TPS65910_VAUX33; |
340 | case TPS65910_REG_VMMC: | 351 | case TPS65910_REG_VMMC: |
341 | return TPS65910_VMMC; | 352 | return TPS65910_VMMC; |
353 | case TPS65910_REG_VBB: | ||
354 | return TPS65910_BBCH; | ||
342 | default: | 355 | default: |
343 | return -EINVAL; | 356 | return -EINVAL; |
344 | } | 357 | } |
@@ -528,6 +541,10 @@ static int tps65910_get_voltage_sel(struct regulator_dev *dev) | |||
528 | value &= LDO_SEL_MASK; | 541 | value &= LDO_SEL_MASK; |
529 | value >>= LDO_SEL_SHIFT; | 542 | value >>= LDO_SEL_SHIFT; |
530 | break; | 543 | break; |
544 | case TPS65910_REG_VBB: | ||
545 | value &= BBCH_BBSEL_MASK; | ||
546 | value >>= BBCH_BBSEL_SHIFT; | ||
547 | break; | ||
531 | default: | 548 | default: |
532 | return -EINVAL; | 549 | return -EINVAL; |
533 | } | 550 | } |
@@ -638,6 +655,9 @@ static int tps65910_set_voltage_sel(struct regulator_dev *dev, | |||
638 | case TPS65910_REG_VMMC: | 655 | case TPS65910_REG_VMMC: |
639 | return tps65910_reg_update_bits(pmic->mfd, reg, LDO_SEL_MASK, | 656 | return tps65910_reg_update_bits(pmic->mfd, reg, LDO_SEL_MASK, |
640 | selector << LDO_SEL_SHIFT); | 657 | selector << LDO_SEL_SHIFT); |
658 | case TPS65910_REG_VBB: | ||
659 | return tps65910_reg_update_bits(pmic->mfd, reg, BBCH_BBSEL_MASK, | ||
660 | selector << BBCH_BBSEL_SHIFT); | ||
641 | } | 661 | } |
642 | 662 | ||
643 | return -EINVAL; | 663 | return -EINVAL; |
@@ -669,6 +689,9 @@ static int tps65911_set_voltage_sel(struct regulator_dev *dev, | |||
669 | case TPS65910_REG_VIO: | 689 | case TPS65910_REG_VIO: |
670 | return tps65910_reg_update_bits(pmic->mfd, reg, LDO_SEL_MASK, | 690 | return tps65910_reg_update_bits(pmic->mfd, reg, LDO_SEL_MASK, |
671 | selector << LDO_SEL_SHIFT); | 691 | selector << LDO_SEL_SHIFT); |
692 | case TPS65910_REG_VBB: | ||
693 | return tps65910_reg_update_bits(pmic->mfd, reg, BBCH_BBSEL_MASK, | ||
694 | selector << BBCH_BBSEL_SHIFT); | ||
672 | } | 695 | } |
673 | 696 | ||
674 | return -EINVAL; | 697 | return -EINVAL; |
@@ -762,6 +785,18 @@ static struct regulator_ops tps65910_ops_vdd3 = { | |||
762 | .map_voltage = regulator_map_voltage_ascend, | 785 | .map_voltage = regulator_map_voltage_ascend, |
763 | }; | 786 | }; |
764 | 787 | ||
788 | static struct regulator_ops tps65910_ops_vbb = { | ||
789 | .is_enabled = regulator_is_enabled_regmap, | ||
790 | .enable = regulator_enable_regmap, | ||
791 | .disable = regulator_disable_regmap, | ||
792 | .set_mode = tps65910_set_mode, | ||
793 | .get_mode = tps65910_get_mode, | ||
794 | .get_voltage_sel = tps65910_get_voltage_sel, | ||
795 | .set_voltage_sel = tps65910_set_voltage_sel, | ||
796 | .list_voltage = regulator_list_voltage_table, | ||
797 | .map_voltage = regulator_map_voltage_iterate, | ||
798 | }; | ||
799 | |||
765 | static struct regulator_ops tps65910_ops = { | 800 | static struct regulator_ops tps65910_ops = { |
766 | .is_enabled = regulator_is_enabled_regmap, | 801 | .is_enabled = regulator_is_enabled_regmap, |
767 | .enable = regulator_enable_regmap, | 802 | .enable = regulator_enable_regmap, |
@@ -944,6 +979,7 @@ static struct of_regulator_match tps65910_matches[] = { | |||
944 | { .name = "vaux2", .driver_data = (void *) &tps65910_regs[10] }, | 979 | { .name = "vaux2", .driver_data = (void *) &tps65910_regs[10] }, |
945 | { .name = "vaux33", .driver_data = (void *) &tps65910_regs[11] }, | 980 | { .name = "vaux33", .driver_data = (void *) &tps65910_regs[11] }, |
946 | { .name = "vmmc", .driver_data = (void *) &tps65910_regs[12] }, | 981 | { .name = "vmmc", .driver_data = (void *) &tps65910_regs[12] }, |
982 | { .name = "vbb", .driver_data = (void *) &tps65910_regs[13] }, | ||
947 | }; | 983 | }; |
948 | 984 | ||
949 | static struct of_regulator_match tps65911_matches[] = { | 985 | static struct of_regulator_match tps65911_matches[] = { |
@@ -1145,6 +1181,10 @@ static int tps65910_probe(struct platform_device *pdev) | |||
1145 | pmic->desc[i].ops = &tps65910_ops_dcdc; | 1181 | pmic->desc[i].ops = &tps65910_ops_dcdc; |
1146 | pmic->desc[i].ramp_delay = 5000; | 1182 | pmic->desc[i].ramp_delay = 5000; |
1147 | } | 1183 | } |
1184 | } else if (i == TPS65910_REG_VBB && | ||
1185 | tps65910_chip_id(tps65910) == TPS65910) { | ||
1186 | pmic->desc[i].ops = &tps65910_ops_vbb; | ||
1187 | pmic->desc[i].volt_table = info->voltage_table; | ||
1148 | } else { | 1188 | } else { |
1149 | if (tps65910_chip_id(tps65910) == TPS65910) { | 1189 | if (tps65910_chip_id(tps65910) == TPS65910) { |
1150 | pmic->desc[i].ops = &tps65910_ops; | 1190 | pmic->desc[i].ops = &tps65910_ops; |
@@ -1167,7 +1207,21 @@ static int tps65910_probe(struct platform_device *pdev) | |||
1167 | pmic->desc[i].type = REGULATOR_VOLTAGE; | 1207 | pmic->desc[i].type = REGULATOR_VOLTAGE; |
1168 | pmic->desc[i].owner = THIS_MODULE; | 1208 | pmic->desc[i].owner = THIS_MODULE; |
1169 | pmic->desc[i].enable_reg = pmic->get_ctrl_reg(i); | 1209 | pmic->desc[i].enable_reg = pmic->get_ctrl_reg(i); |
1170 | pmic->desc[i].enable_mask = TPS65910_SUPPLY_STATE_ENABLED; | 1210 | |
1211 | switch (i) { | ||
1212 | case TPS65910_REG_VBB: | ||
1213 | if (tps65910_chip_id(tps65910) == TPS65910) | ||
1214 | pmic->desc[i].enable_mask = BBCH_BBCHEN_MASK; | ||
1215 | else | ||
1216 | pmic->desc[i].enable_mask = | ||
1217 | TPS65910_SUPPLY_STATE_ENABLED; | ||
1218 | break; | ||
1219 | |||
1220 | default: | ||
1221 | pmic->desc[i].enable_mask = | ||
1222 | TPS65910_SUPPLY_STATE_ENABLED; | ||
1223 | break; | ||
1224 | } | ||
1171 | 1225 | ||
1172 | config.dev = tps65910->dev; | 1226 | config.dev = tps65910->dev; |
1173 | config.init_data = reg_data; | 1227 | config.init_data = reg_data; |