linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] regulator: tps65910: Add backup battery regulator
@ 2013-12-18 14:50 Markus Pargmann
  2013-12-18 14:50 ` [PATCH 2/2] ARM: dts: tps65910 " Markus Pargmann
  2013-12-18 16:24 ` [PATCH 1/2] regulator: tps65910: Add " Mark Brown
  0 siblings, 2 replies; 6+ messages in thread
From: Markus Pargmann @ 2013-12-18 14:50 UTC (permalink / raw)
  To: linux-arm-kernel

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>
---
 drivers/regulator/tps65910-regulator.c | 32 ++++++++++++++++++++++++++++++--
 include/linux/mfd/tps65910.h           |  3 ++-
 2 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/drivers/regulator/tps65910-regulator.c b/drivers/regulator/tps65910-regulator.c
index a00132e..74f5e05 100644
--- a/drivers/regulator/tps65910-regulator.c
+++ b/drivers/regulator/tps65910-regulator.c
@@ -88,6 +88,11 @@ static const unsigned int VMMC_VSEL_table[] = {
 	1800000, 2800000, 3000000, 3300000,
 };
 
+/* supported BBCH voltages in microvolts */
+static const unsigned int VBB_VSEL_table[] = {
+	3000000, 2520000, 3150000, 5000000,
+};
+
 struct tps_info {
 	const char *name;
 	const char *vin_name;
@@ -183,6 +188,12 @@ static struct tps_info tps65910_regs[] = {
 		.voltage_table = VMMC_VSEL_table,
 		.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[] = {
@@ -339,6 +350,8 @@ static int tps65910_get_ctrl_register(int id)
 		return TPS65910_VAUX33;
 	case TPS65910_REG_VMMC:
 		return TPS65910_VMMC;
+	case TPS65910_REG_VBB:
+		return TPS65910_BBCH;
 	default:
 		return -EINVAL;
 	}
@@ -528,6 +541,10 @@ static int tps65910_get_voltage_sel(struct regulator_dev *dev)
 		value &= LDO_SEL_MASK;
 		value >>= LDO_SEL_SHIFT;
 		break;
+	case TPS65910_REG_VBB:
+		value &= BBCH_BBSEL_MASK;
+		value >>= BBCH_BBSEL_SHIFT;
+		break;
 	default:
 		return -EINVAL;
 	}
@@ -638,6 +655,9 @@ static int tps65910_set_voltage_sel(struct regulator_dev *dev,
 	case TPS65910_REG_VMMC:
 		return tps65910_reg_update_bits(pmic->mfd, reg, LDO_SEL_MASK,
 						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;
@@ -669,6 +689,9 @@ static int tps65911_set_voltage_sel(struct regulator_dev *dev,
 	case TPS65910_REG_VIO:
 		return tps65910_reg_update_bits(pmic->mfd, reg, LDO_SEL_MASK,
 						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;
@@ -771,7 +794,7 @@ static struct regulator_ops tps65910_ops = {
 	.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_ascend,
+	.map_voltage		= regulator_map_voltage_iterate,
 };
 
 static struct regulator_ops tps65911_ops = {
@@ -944,6 +967,7 @@ static struct of_regulator_match tps65910_matches[] = {
 	{ .name = "vaux2",	.driver_data = (void *) &tps65910_regs[10] },
 	{ .name = "vaux33",	.driver_data = (void *) &tps65910_regs[11] },
 	{ .name = "vmmc",	.driver_data = (void *) &tps65910_regs[12] },
+	{ .name = "vbb",	.driver_data = (void *) &tps65910_regs[13] },
 };
 
 static struct of_regulator_match tps65911_matches[] = {
@@ -1167,7 +1191,11 @@ static int tps65910_probe(struct platform_device *pdev)
 		pmic->desc[i].type = REGULATOR_VOLTAGE;
 		pmic->desc[i].owner = THIS_MODULE;
 		pmic->desc[i].enable_reg = pmic->get_ctrl_reg(i);
-		pmic->desc[i].enable_mask = TPS65910_SUPPLY_STATE_ENABLED;
+		if (tps65910_chip_id(tps65910) == TPS65910 &&
+				i == TPS65910_REG_VBB)
+			pmic->desc[i].enable_mask = BBCH_BBCHEN_MASK;
+		else
+			pmic->desc[i].enable_mask = TPS65910_SUPPLY_STATE_ENABLED;
 
 		config.dev = tps65910->dev;
 		config.init_data = reg_data;
diff --git a/include/linux/mfd/tps65910.h b/include/linux/mfd/tps65910.h
index 20e433e..1adeee1 100644
--- a/include/linux/mfd/tps65910.h
+++ b/include/linux/mfd/tps65910.h
@@ -833,6 +833,7 @@
 #define TPS65910_REG_VAUX2				10
 #define TPS65910_REG_VAUX33				11
 #define TPS65910_REG_VMMC				12
+#define TPS65910_REG_VBB				13
 
 #define TPS65911_REG_VDDCTRL				4
 #define TPS65911_REG_LDO1				5
@@ -845,7 +846,7 @@
 #define TPS65911_REG_LDO8				12
 
 /* 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 */
 #define TPS65910_SLEEP_CONTROL_EXT_INPUT_EN1		0x1
-- 
1.8.5.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] ARM: dts: tps65910 backup battery regulator
  2013-12-18 14:50 [PATCH 1/2] regulator: tps65910: Add backup battery regulator Markus Pargmann
@ 2013-12-18 14:50 ` Markus Pargmann
  2013-12-18 16:25   ` Mark Brown
  2013-12-18 16:24 ` [PATCH 1/2] regulator: tps65910: Add " Mark Brown
  1 sibling, 1 reply; 6+ messages in thread
From: Markus Pargmann @ 2013-12-18 14:50 UTC (permalink / raw)
  To: linux-arm-kernel

This patch adds a devicetree node for the backup battery regulator.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
---
 arch/arm/boot/dts/tps65910.dtsi | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/boot/dts/tps65910.dtsi b/arch/arm/boot/dts/tps65910.dtsi
index 92693a8..b0ac665 100644
--- a/arch/arm/boot/dts/tps65910.dtsi
+++ b/arch/arm/boot/dts/tps65910.dtsi
@@ -82,5 +82,10 @@
 			reg = <12>;
 			regulator-compatible = "vmmc";
 		};
+
+		vbb_reg: regulator at 13 {
+			reg = <13>;
+			regulator-compatible = "vbb";
+		};
 	};
 };
-- 
1.8.5.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 1/2] regulator: tps65910: Add backup battery regulator
  2013-12-18 14:50 [PATCH 1/2] regulator: tps65910: Add backup battery regulator Markus Pargmann
  2013-12-18 14:50 ` [PATCH 2/2] ARM: dts: tps65910 " Markus Pargmann
@ 2013-12-18 16:24 ` Mark Brown
  2013-12-19  8:23   ` Markus Pargmann
  1 sibling, 1 reply; 6+ messages in thread
From: Mark Brown @ 2013-12-18 16:24 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Dec 18, 2013 at 03:50:07PM +0100, Markus Pargmann wrote:

> @@ -771,7 +794,7 @@ static struct regulator_ops tps65910_ops = {
>  	.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_ascend,
> +	.map_voltage		= regulator_map_voltage_iterate,
>  };

You should make separate ops for this rather than make all the other
regulators take the performance hit.

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

Ugh, these numbered tables aren't good.  Not a problem from this patch
though.

> -		pmic->desc[i].enable_mask = TPS65910_SUPPLY_STATE_ENABLED;
> +		if (tps65910_chip_id(tps65910) == TPS65910 &&
> +				i == TPS65910_REG_VBB)
> +			pmic->desc[i].enable_mask = BBCH_BBCHEN_MASK;
> +		else
> +			pmic->desc[i].enable_mask = TPS65910_SUPPLY_STATE_ENABLED;

switch statements please - it means if additional things need
customising they can drop right in.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131218/7e36be7e/attachment.sig>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/2] ARM: dts: tps65910 backup battery regulator
  2013-12-18 14:50 ` [PATCH 2/2] ARM: dts: tps65910 " Markus Pargmann
@ 2013-12-18 16:25   ` Mark Brown
  2013-12-19  8:25     ` Markus Pargmann
  0 siblings, 1 reply; 6+ messages in thread
From: Mark Brown @ 2013-12-18 16:25 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Dec 18, 2013 at 03:50:08PM +0100, Markus Pargmann wrote:
> This patch adds a devicetree node for the backup battery regulator.

Your previous patch missed an update to the binding documentation for
the regulator driver.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131218/e5893e0e/attachment.sig>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] regulator: tps65910: Add backup battery regulator
  2013-12-18 16:24 ` [PATCH 1/2] regulator: tps65910: Add " Mark Brown
@ 2013-12-19  8:23   ` Markus Pargmann
  0 siblings, 0 replies; 6+ messages in thread
From: Markus Pargmann @ 2013-12-19  8:23 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Dec 18, 2013 at 04:24:52PM +0000, Mark Brown wrote:
> On Wed, Dec 18, 2013 at 03:50:07PM +0100, Markus Pargmann wrote:
> 
> > @@ -771,7 +794,7 @@ static struct regulator_ops tps65910_ops = {
> >  	.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_ascend,
> > +	.map_voltage		= regulator_map_voltage_iterate,
> >  };
> 
> You should make separate ops for this rather than make all the other
> regulators take the performance hit.

Fixed.

> 
> >  static struct regulator_ops tps65911_ops = {
> > @@ -944,6 +967,7 @@ static struct of_regulator_match tps65910_matches[] = {
> >  	{ .name = "vaux2",	.driver_data = (void *) &tps65910_regs[10] },
> >  	{ .name = "vaux33",	.driver_data = (void *) &tps65910_regs[11] },
> >  	{ .name = "vmmc",	.driver_data = (void *) &tps65910_regs[12] },
> > +	{ .name = "vbb",	.driver_data = (void *) &tps65910_regs[13] },
> >  };
> 
> Ugh, these numbered tables aren't good.  Not a problem from this patch
> though.
> 
> > -		pmic->desc[i].enable_mask = TPS65910_SUPPLY_STATE_ENABLED;
> > +		if (tps65910_chip_id(tps65910) == TPS65910 &&
> > +				i == TPS65910_REG_VBB)
> > +			pmic->desc[i].enable_mask = BBCH_BBCHEN_MASK;
> > +		else
> > +			pmic->desc[i].enable_mask = TPS65910_SUPPLY_STATE_ENABLED;
> 
> switch statements please - it means if additional things need
> customising they can drop right in.

Fixed.


Thank you,

Markus


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/2] ARM: dts: tps65910 backup battery regulator
  2013-12-18 16:25   ` Mark Brown
@ 2013-12-19  8:25     ` Markus Pargmann
  0 siblings, 0 replies; 6+ messages in thread
From: Markus Pargmann @ 2013-12-19  8:25 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Dec 18, 2013 at 04:25:46PM +0000, Mark Brown wrote:
> On Wed, Dec 18, 2013 at 03:50:08PM +0100, Markus Pargmann wrote:
> > This patch adds a devicetree node for the backup battery regulator.
> 
> Your previous patch missed an update to the binding documentation for
> the regulator driver.

Right, thank you, I added vbb to the tps65910 mfd binding documentation.

Regards,

Markus



-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-12-19  8:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-18 14:50 [PATCH 1/2] regulator: tps65910: Add backup battery regulator Markus Pargmann
2013-12-18 14:50 ` [PATCH 2/2] ARM: dts: tps65910 " Markus Pargmann
2013-12-18 16:25   ` Mark Brown
2013-12-19  8:25     ` Markus Pargmann
2013-12-18 16:24 ` [PATCH 1/2] regulator: tps65910: Add " Mark Brown
2013-12-19  8:23   ` Markus Pargmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).