Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 03746dcb authored by Markus Pargmann's avatar Markus Pargmann Committed by Mark Brown
Browse files

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: default avatarMarkus Pargmann <mpa@pengutronix.de>
Signed-off-by: default avatarMark Brown <broonie@linaro.org>
parent 6ce4eac1
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -21,7 +21,7 @@ Required properties:


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


@@ -38,7 +38,7 @@ Required properties:
	vcc4-supply: VAUX1 and VAUX2 input.
	vcc4-supply: VAUX1 and VAUX2 input.
	vcc5-supply: VPLL and VDAC input.
	vcc5-supply: VPLL and VDAC input.
	vcc6-supply: VDIG1 and VDIG2 input.
	vcc6-supply: VDIG1 and VDIG2 input.
	vcc7-supply: VRTC input.
	vcc7-supply: VRTC and VBB input.
	vccio-supply: VIO input.
	vccio-supply: VIO input.
  tps65911:
  tps65911:
	vcc1-supply: VDD1 input.
	vcc1-supply: VDD1 input.
+55 −1
Original line number Original line Diff line number Diff line
@@ -88,6 +88,11 @@ static const unsigned int VMMC_VSEL_table[] = {
	1800000, 2800000, 3000000, 3300000,
	1800000, 2800000, 3000000, 3300000,
};
};


/* supported BBCH voltages in microvolts */
static const unsigned int VBB_VSEL_table[] = {
	3000000, 2520000, 3150000, 5000000,
};

struct tps_info {
struct tps_info {
	const char *name;
	const char *name;
	const char *vin_name;
	const char *vin_name;
@@ -183,6 +188,12 @@ static struct tps_info tps65910_regs[] = {
		.voltage_table = VMMC_VSEL_table,
		.voltage_table = VMMC_VSEL_table,
		.enable_time_us = 100,
		.enable_time_us = 100,
	},
	},
	{
		.name = "vbb",
		.vin_name = "vcc7",
		.n_voltages = ARRAY_SIZE(VBB_VSEL_table),
		.voltage_table = VBB_VSEL_table,
	},
};
};


static struct tps_info tps65911_regs[] = {
static struct tps_info tps65911_regs[] = {
@@ -339,6 +350,8 @@ static int tps65910_get_ctrl_register(int id)
		return TPS65910_VAUX33;
		return TPS65910_VAUX33;
	case TPS65910_REG_VMMC:
	case TPS65910_REG_VMMC:
		return TPS65910_VMMC;
		return TPS65910_VMMC;
	case TPS65910_REG_VBB:
		return TPS65910_BBCH;
	default:
	default:
		return -EINVAL;
		return -EINVAL;
	}
	}
@@ -528,6 +541,10 @@ static int tps65910_get_voltage_sel(struct regulator_dev *dev)
		value &= LDO_SEL_MASK;
		value &= LDO_SEL_MASK;
		value >>= LDO_SEL_SHIFT;
		value >>= LDO_SEL_SHIFT;
		break;
		break;
	case TPS65910_REG_VBB:
		value &= BBCH_BBSEL_MASK;
		value >>= BBCH_BBSEL_SHIFT;
		break;
	default:
	default:
		return -EINVAL;
		return -EINVAL;
	}
	}
@@ -638,6 +655,9 @@ static int tps65910_set_voltage_sel(struct regulator_dev *dev,
	case TPS65910_REG_VMMC:
	case TPS65910_REG_VMMC:
		return tps65910_reg_update_bits(pmic->mfd, reg, LDO_SEL_MASK,
		return tps65910_reg_update_bits(pmic->mfd, reg, LDO_SEL_MASK,
						selector << LDO_SEL_SHIFT);
						selector << LDO_SEL_SHIFT);
	case TPS65910_REG_VBB:
		return tps65910_reg_update_bits(pmic->mfd, reg, BBCH_BBSEL_MASK,
						selector << BBCH_BBSEL_SHIFT);
	}
	}


	return -EINVAL;
	return -EINVAL;
@@ -669,6 +689,9 @@ static int tps65911_set_voltage_sel(struct regulator_dev *dev,
	case TPS65910_REG_VIO:
	case TPS65910_REG_VIO:
		return tps65910_reg_update_bits(pmic->mfd, reg, LDO_SEL_MASK,
		return tps65910_reg_update_bits(pmic->mfd, reg, LDO_SEL_MASK,
						selector << LDO_SEL_SHIFT);
						selector << LDO_SEL_SHIFT);
	case TPS65910_REG_VBB:
		return tps65910_reg_update_bits(pmic->mfd, reg, BBCH_BBSEL_MASK,
						selector << BBCH_BBSEL_SHIFT);
	}
	}


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


static struct regulator_ops tps65910_ops_vbb = {
	.is_enabled		= regulator_is_enabled_regmap,
	.enable			= regulator_enable_regmap,
	.disable		= regulator_disable_regmap,
	.set_mode		= tps65910_set_mode,
	.get_mode		= tps65910_get_mode,
	.get_voltage_sel	= tps65910_get_voltage_sel,
	.set_voltage_sel	= tps65910_set_voltage_sel,
	.list_voltage		= regulator_list_voltage_table,
	.map_voltage		= regulator_map_voltage_iterate,
};

static struct regulator_ops tps65910_ops = {
static struct regulator_ops tps65910_ops = {
	.is_enabled		= regulator_is_enabled_regmap,
	.is_enabled		= regulator_is_enabled_regmap,
	.enable			= regulator_enable_regmap,
	.enable			= regulator_enable_regmap,
@@ -944,6 +979,7 @@ static struct of_regulator_match tps65910_matches[] = {
	{ .name = "vaux2",	.driver_data = (void *) &tps65910_regs[10] },
	{ .name = "vaux2",	.driver_data = (void *) &tps65910_regs[10] },
	{ .name = "vaux33",	.driver_data = (void *) &tps65910_regs[11] },
	{ .name = "vaux33",	.driver_data = (void *) &tps65910_regs[11] },
	{ .name = "vmmc",	.driver_data = (void *) &tps65910_regs[12] },
	{ .name = "vmmc",	.driver_data = (void *) &tps65910_regs[12] },
	{ .name = "vbb",	.driver_data = (void *) &tps65910_regs[13] },
};
};


static struct of_regulator_match tps65911_matches[] = {
static struct of_regulator_match tps65911_matches[] = {
@@ -1145,6 +1181,10 @@ static int tps65910_probe(struct platform_device *pdev)
				pmic->desc[i].ops = &tps65910_ops_dcdc;
				pmic->desc[i].ops = &tps65910_ops_dcdc;
				pmic->desc[i].ramp_delay = 5000;
				pmic->desc[i].ramp_delay = 5000;
			}
			}
		} else if (i == TPS65910_REG_VBB &&
				tps65910_chip_id(tps65910) == TPS65910) {
			pmic->desc[i].ops = &tps65910_ops_vbb;
			pmic->desc[i].volt_table = info->voltage_table;
		} else {
		} else {
			if (tps65910_chip_id(tps65910) == TPS65910) {
			if (tps65910_chip_id(tps65910) == TPS65910) {
				pmic->desc[i].ops = &tps65910_ops;
				pmic->desc[i].ops = &tps65910_ops;
@@ -1167,7 +1207,21 @@ static int tps65910_probe(struct platform_device *pdev)
		pmic->desc[i].type = REGULATOR_VOLTAGE;
		pmic->desc[i].type = REGULATOR_VOLTAGE;
		pmic->desc[i].owner = THIS_MODULE;
		pmic->desc[i].owner = THIS_MODULE;
		pmic->desc[i].enable_reg = pmic->get_ctrl_reg(i);
		pmic->desc[i].enable_reg = pmic->get_ctrl_reg(i);
		pmic->desc[i].enable_mask = TPS65910_SUPPLY_STATE_ENABLED;

		switch (i) {
		case TPS65910_REG_VBB:
			if (tps65910_chip_id(tps65910) == TPS65910)
				pmic->desc[i].enable_mask = BBCH_BBCHEN_MASK;
			else
				pmic->desc[i].enable_mask =
					TPS65910_SUPPLY_STATE_ENABLED;
			break;

		default:
			pmic->desc[i].enable_mask =
				TPS65910_SUPPLY_STATE_ENABLED;
			break;
		}


		config.dev = tps65910->dev;
		config.dev = tps65910->dev;
		config.init_data = reg_data;
		config.init_data = reg_data;
+2 −1
Original line number Original line Diff line number Diff line
@@ -833,6 +833,7 @@
#define TPS65910_REG_VAUX2				10
#define TPS65910_REG_VAUX2				10
#define TPS65910_REG_VAUX33				11
#define TPS65910_REG_VAUX33				11
#define TPS65910_REG_VMMC				12
#define TPS65910_REG_VMMC				12
#define TPS65910_REG_VBB				13


#define TPS65911_REG_VDDCTRL				4
#define TPS65911_REG_VDDCTRL				4
#define TPS65911_REG_LDO1				5
#define TPS65911_REG_LDO1				5
@@ -845,7 +846,7 @@
#define TPS65911_REG_LDO8				12
#define TPS65911_REG_LDO8				12


/* Max number of TPS65910/11 regulators */
/* Max number of TPS65910/11 regulators */
#define TPS65910_NUM_REGS				13
#define TPS65910_NUM_REGS				14


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