Skip to content

Commit 03746dc

Browse files
Markus Pargmannbroonie
authored andcommitted
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>
1 parent 6ce4eac commit 03746dc

3 files changed

Lines changed: 59 additions & 4 deletions

File tree

‎Documentation/devicetree/bindings/mfd/tps65910.txt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Required properties:
2121

2222
The valid regulator-compatible values are:
2323
tps65910: vrtc, vio, vdd1, vdd2, vdd3, vdig1, vdig2, vpll, vdac, vaux1,
24-
vaux2, vaux33, vmmc
24+
vaux2, vaux33, vmmc, vbb
2525
tps65911: vrtc, vio, vdd1, vdd3, vddctrl, ldo1, ldo2, ldo3, ldo4, ldo5,
2626
ldo6, ldo7, ldo8
2727

@@ -38,7 +38,7 @@ Required properties:
3838
vcc4-supply: VAUX1 and VAUX2 input.
3939
vcc5-supply: VPLL and VDAC input.
4040
vcc6-supply: VDIG1 and VDIG2 input.
41-
vcc7-supply: VRTC input.
41+
vcc7-supply: VRTC and VBB input.
4242
vccio-supply: VIO input.
4343
tps65911:
4444
vcc1-supply: VDD1 input.

‎drivers/regulator/tps65910-regulator.c‎

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ static const unsigned int VMMC_VSEL_table[] = {
8888
1800000, 2800000, 3000000, 3300000,
8989
};
9090

91+
/* supported BBCH voltages in microvolts */
92+
static const unsigned int VBB_VSEL_table[] = {
93+
3000000, 2520000, 3150000, 5000000,
94+
};
95+
9196
struct tps_info {
9297
const char *name;
9398
const char *vin_name;
@@ -183,6 +188,12 @@ static struct tps_info tps65910_regs[] = {
183188
.voltage_table = VMMC_VSEL_table,
184189
.enable_time_us = 100,
185190
},
191+
{
192+
.name = "vbb",
193+
.vin_name = "vcc7",
194+
.n_voltages = ARRAY_SIZE(VBB_VSEL_table),
195+
.voltage_table = VBB_VSEL_table,
196+
},
186197
};
187198

188199
static struct tps_info tps65911_regs[] = {
@@ -339,6 +350,8 @@ static int tps65910_get_ctrl_register(int id)
339350
return TPS65910_VAUX33;
340351
case TPS65910_REG_VMMC:
341352
return TPS65910_VMMC;
353+
case TPS65910_REG_VBB:
354+
return TPS65910_BBCH;
342355
default:
343356
return -EINVAL;
344357
}
@@ -528,6 +541,10 @@ static int tps65910_get_voltage_sel(struct regulator_dev *dev)
528541
value &= LDO_SEL_MASK;
529542
value >>= LDO_SEL_SHIFT;
530543
break;
544+
case TPS65910_REG_VBB:
545+
value &= BBCH_BBSEL_MASK;
546+
value >>= BBCH_BBSEL_SHIFT;
547+
break;
531548
default:
532549
return -EINVAL;
533550
}
@@ -638,6 +655,9 @@ static int tps65910_set_voltage_sel(struct regulator_dev *dev,
638655
case TPS65910_REG_VMMC:
639656
return tps65910_reg_update_bits(pmic->mfd, reg, LDO_SEL_MASK,
640657
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);
641661
}
642662

643663
return -EINVAL;
@@ -669,6 +689,9 @@ static int tps65911_set_voltage_sel(struct regulator_dev *dev,
669689
case TPS65910_REG_VIO:
670690
return tps65910_reg_update_bits(pmic->mfd, reg, LDO_SEL_MASK,
671691
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);
672695
}
673696

674697
return -EINVAL;
@@ -762,6 +785,18 @@ static struct regulator_ops tps65910_ops_vdd3 = {
762785
.map_voltage = regulator_map_voltage_ascend,
763786
};
764787

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+
765800
static struct regulator_ops tps65910_ops = {
766801
.is_enabled = regulator_is_enabled_regmap,
767802
.enable = regulator_enable_regmap,
@@ -944,6 +979,7 @@ static struct of_regulator_match tps65910_matches[] = {
944979
{ .name = "vaux2", .driver_data = (void *) &tps65910_regs[10] },
945980
{ .name = "vaux33", .driver_data = (void *) &tps65910_regs[11] },
946981
{ .name = "vmmc", .driver_data = (void *) &tps65910_regs[12] },
982+
{ .name = "vbb", .driver_data = (void *) &tps65910_regs[13] },
947983
};
948984

949985
static struct of_regulator_match tps65911_matches[] = {
@@ -1145,6 +1181,10 @@ static int tps65910_probe(struct platform_device *pdev)
11451181
pmic->desc[i].ops = &tps65910_ops_dcdc;
11461182
pmic->desc[i].ramp_delay = 5000;
11471183
}
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;
11481188
} else {
11491189
if (tps65910_chip_id(tps65910) == TPS65910) {
11501190
pmic->desc[i].ops = &tps65910_ops;
@@ -1167,7 +1207,21 @@ static int tps65910_probe(struct platform_device *pdev)
11671207
pmic->desc[i].type = REGULATOR_VOLTAGE;
11681208
pmic->desc[i].owner = THIS_MODULE;
11691209
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+
}
11711225

11721226
config.dev = tps65910->dev;
11731227
config.init_data = reg_data;

‎include/linux/mfd/tps65910.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,7 @@
833833
#define TPS65910_REG_VAUX2 10
834834
#define TPS65910_REG_VAUX33 11
835835
#define TPS65910_REG_VMMC 12
836+
#define TPS65910_REG_VBB 13
836837

837838
#define TPS65911_REG_VDDCTRL 4
838839
#define TPS65911_REG_LDO1 5
@@ -845,7 +846,7 @@
845846
#define TPS65911_REG_LDO8 12
846847

847848
/* Max number of TPS65910/11 regulators */
848-
#define TPS65910_NUM_REGS 13
849+
#define TPS65910_NUM_REGS 14
849850

850851
/* External sleep controls through EN1/EN2/EN3/SLEEP inputs */
851852
#define TPS65910_SLEEP_CONTROL_EXT_INPUT_EN1 0x1

0 commit comments

Comments
 (0)