Skip to contentSkip to conversation

Add all TWL4030 regulators to Regulator framework

PATCH Superseded Juha Keski-Saari 7 participants 15 messages Nov 18, 2009 – Nov 23, 2009

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Add all TWL4030 regulators to Regulator framework

This patch adds all the remaining TWL4030 regulators into the implementation. These changes are based on top of Linus' tree master branch, since it is ahead of the mfd-2.6.

Juha Keski-Saari (1):
Add all TWL regulators to Regulator framework

 drivers/mfd/twl4030-core.c            |   30 ++++++++++++++++++++++++++----
 drivers/regulator/twl4030-regulator.c |   27 +++++++++++++++++----------
 include/linux/i2c/twl4030.h           |    8 ++++++--
 3 files changed, 49 insertions(+), 16 deletions(-)
#1 lore raw

PATCH 1/1 Add all TWL4030 regulators to Regulator framework

This patch adds all the remaining TWL4030 regulators into the implementation, also adding VINT* regulators in this way since they can be derived out from the TWL

---
 drivers/mfd/twl4030-core.c            |   30 ++++++++++++++++++++++++++----
 drivers/regulator/twl4030-regulator.c |   27 +++++++++++++++++----------
 include/linux/i2c/twl4030.h           |    8 ++++++--
 3 files changed, 49 insertions(+), 16 deletions(-)
drivers/mfd/twl4030-core.c +26 -4
index a1c47ee..0748b43 100644
@@ -602,13 +602,15 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)
 	}
 
 	if (twl_has_regulator()) {
-		/*
-		child = add_regulator(TWL4030_REG_VPLL1, pdata->vpll1);
+		child = add_regulator(TWL4030_REG_VDD1, pdata->vdd1);
 		if (IS_ERR(child))
 			return PTR_ERR(child);
-		*/
 
-		child = add_regulator(TWL4030_REG_VMMC1, pdata->vmmc1);
+		child = add_regulator(TWL4030_REG_VDD2, pdata->vdd2);
+		if (IS_ERR(child))
+			return PTR_ERR(child);
+
+		child = add_regulator(TWL4030_REG_VIO, pdata->vio);
 		if (IS_ERR(child))
 			return PTR_ERR(child);
 
@@ -616,12 +618,32 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)
 		if (IS_ERR(child))
 			return PTR_ERR(child);
 
+		child = add_regulator(TWL4030_REG_VPLL1, pdata->vpll1);
+		if (IS_ERR(child))
+			return PTR_ERR(child);
+
+		child = add_regulator(TWL4030_REG_VMMC1, pdata->vmmc1);
+		if (IS_ERR(child))
+			return PTR_ERR(child);
+
 		child = add_regulator((features & TWL4030_VAUX2)
 					? TWL4030_REG_VAUX2_4030
 					: TWL4030_REG_VAUX2,
 				pdata->vaux2);
 		if (IS_ERR(child))
 			return PTR_ERR(child);
+
+		child = add_regulator(TWL4030_REG_VINTANA1, pdata->vintana1);
+		if (IS_ERR(child))
+			return PTR_ERR(child);
+
+		child = add_regulator(TWL4030_REG_VINTANA2, pdata->vintana2);
+		if (IS_ERR(child))
+			return PTR_ERR(child);
+
+		child = add_regulator(TWL4030_REG_VINTDIG, pdata->vintdig);
+		if (IS_ERR(child))
+			return PTR_ERR(child);
 	}
 
 	/* maybe add LDOs that are omitted on cost-reduced parts */
drivers/regulator/twl4030-regulator.c +17 -10
index e2032fb..949c414 100644
@@ -260,7 +260,18 @@ static const u16 VSIM_VSEL_table[] = {
 static const u16 VDAC_VSEL_table[] = {
 	1200, 1300, 1800, 1800,
 };
-
+static const u16 VDD1_VSEL_table[] = {
+	800, 1450,
+};
+static const u16 VDD2_VSEL_table[] = {
+	800, 1450, 1500,
+};
+static const u16 VIO_VSEL_table[] = {
+	1800, 1850,
+};
+static const u16 VINTANA2_VSEL_table[] = {
+	2500, 2750,
+};
 
 static int twl4030ldo_list_voltage(struct regulator_dev *rdev, unsigned index)
 {
@@ -397,20 +408,16 @@ static struct twlreg_info twl4030_regs[] = {
 	TWL_ADJUSTABLE_LDO(VAUX4, 0x23, 4),
 	TWL_ADJUSTABLE_LDO(VMMC1, 0x27, 5),
 	TWL_ADJUSTABLE_LDO(VMMC2, 0x2b, 6),
-	/*
 	TWL_ADJUSTABLE_LDO(VPLL1, 0x2f, 7),
-	*/
 	TWL_ADJUSTABLE_LDO(VPLL2, 0x33, 8),
 	TWL_ADJUSTABLE_LDO(VSIM, 0x37, 9),
 	TWL_ADJUSTABLE_LDO(VDAC, 0x3b, 10),
-	/*
-	TWL_ADJUSTABLE_LDO(VINTANA1, 0x3f, 11),
+	TWL_FIXED_LDO(VINTANA1, 0x3f, 1500, 11),
 	TWL_ADJUSTABLE_LDO(VINTANA2, 0x43, 12),
-	TWL_ADJUSTABLE_LDO(VINTDIG, 0x47, 13),
-	TWL_SMPS(VIO, 0x4b, 14),
-	TWL_SMPS(VDD1, 0x55, 15),
-	TWL_SMPS(VDD2, 0x63, 16),
-	 */
+	TWL_FIXED_LDO(VINTDIG, 0x47, 1500, 13),
+	TWL_ADJUSTABLE_LDO(VIO, 0x4b, 14),
+	TWL_ADJUSTABLE_LDO(VDD1, 0x55, 15),
+	TWL_ADJUSTABLE_LDO(VDD2, 0x63, 16),
 	TWL_FIXED_LDO(VUSB1V5, 0x71, 1500, 17),
 	TWL_FIXED_LDO(VUSB1V8, 0x74, 1800, 18),
 	TWL_FIXED_LDO(VUSB3V1, 0x77, 3100, 19),
include/linux/i2c/twl4030.h +6 -2
index 508824e..d26f96d 100644
@@ -421,8 +421,12 @@ struct twl4030_platform_data {
 	struct regulator_init_data		*vaux2;
 	struct regulator_init_data		*vaux3;
 	struct regulator_init_data		*vaux4;
-
-	/* REVISIT more to come ... _nothing_ should be hard-wired */
+	struct regulator_init_data		*vio;
+	struct regulator_init_data		*vdd1;
+	struct regulator_init_data		*vdd2;
+	struct regulator_init_data		*vintana1;
+	struct regulator_init_data		*vintana2;
+	struct regulator_init_data		*vintdig;
 };
 
 /*----------------------------------------------------------------------*/
Signature · 1 line
1.6.3.3
#2 lore raw
Quoted 5 lines · Juha Keski-Saari

This patch adds all the remaining TWL4030 regulators into the implementation, also adding VINT* regulators in this way since they can be derived out from the TWL

This is fine from an API point of view but I worry that if any of the boards are using regulator_has_full_constraints() then this will break them by causing them to be powered off at the end of init. Have you checked the in-tree twl4030 users for this?

#3 lore raw
Quoted 11 lines · Mark Brown
Quoted 5 lines · Juha Keski-Saari

This patch adds all the remaining TWL4030 regulators into the implementation, also adding VINT* regulators in this way since they can be derived out from the TWL

This is fine from an API point of view but I worry that if any of the boards are using regulator_has_full_constraints() then this will break them by causing them to be powered off at the end of init. Have you checked the in-tree twl4030 users for this?

Looks like no one is using the regulator_has_full_constraints(). At least the twl4030 users.

But maybe these VINT* should be set as always_on in twl4030-regulator driver?

Signature · 1 line
Eduardo Valentin
#4 lore raw
Quoted 1 line · Eduardo Valentin

But maybe these VINT* should be set as always_on in twl4030-regulator driver?

Can they support any external load at all? If not then it would make sense for the chip driver to at least provide a default set of constraints for them rather than forcing all the machine drivers to do it manually.

#5 lore raw
Quoted 8 lines · ext Mark Brown
Quoted 1 line · Eduardo Valentin

But maybe these VINT* should be set as always_on in twl4030-regulator driver?

Can they support any external load at all? If not then it would make sense for the chip driver to at least provide a default set of constraints for them rather than forcing all the machine drivers to do it manually.

From the TRM it appears that the max current output values are as follows

VINTANA1 - 30mA
VINTANA2 - 250mA
VINTDIG - 100mA

Theoretically they may be able to support external load depending on your machine configuration but still I think providing constraints for them in the chip driver could be a good idea since the "always-on" limitation is imposed by the chip and not the machine. Without these three supplies the TWL does not function properly, if at all. Also worth noting is that the current implementation of RegulatorFW doesn't appear to be able to turn these supplies off (comparing TWL register content with framework status).

#6 lore raw
Quoted 12 lines · On Thu, Nov 19, 2009 at 08:04:08AM +0100, Keski-Saari Juha.1…
Quoted 8 lines · ext Mark Brown
Quoted 1 line · Eduardo Valentin

But maybe these VINT* should be set as always_on in twl4030-regulator driver?

Can they support any external load at all? If not then it would make sense for the chip driver to at least provide a default set of constraints for them rather than forcing all the machine drivers to do it manually.

From the TRM it appears that the max current output values are as follows

Quoted 8 lines

VINTANA1 - 30mA
VINTANA2 - 250mA
VINTDIG - 100mA

Theoretically they may be able to support external load depending on your machine configuration but still I think providing constraints for them in the chip driver could be a good idea since the "always-on" limitation is imposed by the chip and not the machine. Without these three supplies the TWL does not function properly, if at all. Also worth noting is that the current implementation of RegulatorFW doesn't appear to be able to turn these supplies off (comparing TWL register content with framework status).

VINTANA2 can be turned off if MADC, audio and USB are not used.

Cheers,

Peter.

Signature · 1 line
goa is a state of mind
Acked-by
#7 lore raw
Quoted 1 line · On Thu, Nov 19, 2009 at 11:24:12AM +0200, Peter 'p2' De Schrijver wrote:

VINTANA2 can be turned off if MADC, audio and USB are not used.

Sounds like it'd be useful to add regulator support for those drivers, then.

In any case, since nobody is using regulator_has_full_constraints()

Acked-by
#8 lore raw

Hi Mark,

Quoted 10 lines · Mark Brown
Quoted 1 line · On Thu, Nov 19, 2009 at 11:24:12AM +0200, Peter 'p2' De Schrijver wrote:

VINTANA2 can be turned off if MADC, audio and USB are not used.

Sounds like it'd be useful to add regulator support for those drivers, then.

In any case, since nobody is using regulator_has_full_constraints()

Would you mind carrying this one with your twl4030-mfd branch ? It doesnt apply cleanly to my tree due to the missing twl4030 patches from Peter.

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/
#9 lore raw
Quoted 10 lines · Samuel Ortiz

Hi Mark,

Quoted 7 lines · Mark Brown
Quoted 1 line · On Thu, Nov 19, 2009 at 11:24:12AM +0200, Peter 'p2' De Schrijver wrote:

VINTANA2 can be turned off if MADC, audio and USB are not used.

Sounds like it'd be useful to add regulator support for those drivers, then.

Quoted 7 lines
Quoted 3 lines

In any case, since nobody is using regulator_has_full_constraints()

Would you mind carrying this one with your twl4030-mfd branch ? It doesnt apply cleanly to my tree due to the missing twl4030 patches from Peter.

Juha, this doesn't apply to regulator for-next either. Is it possible to split it out into a patch for mfd and a patch for regulator (against their for-next branches) ?

Thanks

Liam

#10 lore raw
Quoted 10 lines · Liam Girdwood
Quoted 4 lines · Samuel Ortiz

Would you mind carrying this one with your twl4030-mfd branch ? It doesnt apply cleanly to my tree due to the missing twl4030 patches from Peter.

Juha, this doesn't apply to regulator for-next either. Is it possible to split it out into a patch for mfd and a patch for regulator (against their for-next branches) ?

Either the existing twl4030-mfd branch or split patches work for me.

#11 lore raw
Quoted 6 lines · Mark Brown
Quoted 4 lines · Liam Girdwood
Quoted 2 lines · Samuel Ortiz

Would you mind carrying this one with your twl4030-mfd branch ? It doesnt apply cleanly to my tree due to the missing twl4030 patches from Peter.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Juha, this doesn't apply to regulator for-next either. Is it possible to split it out into a patch for mfd and a patch for regulator (against their for-next branches) ?

Either the existing twl4030-mfd branch or split patches work for me.

What's the upstream path for your twl4030-mfd ASoC branch ?

Regulator + mfd patches either go upstream via the regulator or mfd repositories.

Liam

#12 lore raw
Quoted 5 lines · Liam Girdwood
Quoted 1 line · Mark Brown

Either the existing twl4030-mfd branch or split patches work for me.

What's the upstream path for your twl4030-mfd ASoC branch ?

ALSA with bits also pulled into the OMAP tree.

Quoted 2 lines

Regulator + mfd patches either go upstream via the regulator or mfd repositories.

Yes, ideally - the existing stuff is going via ALSA since the MFD and ASoC sides can't be split up sensibly without breaking bisection.

Another option would be to hold off on applying the patch until things have settled down in the merge window and then push it via regulator - the ALSA tree normally goes in early in the merge window.

author Acked-by Mark Brown Acked-by Samuel Ortiz
#13 lore raw
In reply to Mark Brown

twl4030-mfd: Add all TWL regulators to RegFW

---
 drivers/mfd/twl4030-core.c            |   26 ++++++++++++++++++++++++--
 drivers/regulator/twl4030-regulator.c |   26 +++++++++++++++++---------
 include/linux/i2c/twl4030.h           |    8 ++++++--
 3 files changed, 47 insertions(+), 13 deletions(-)
drivers/mfd/twl4030-core.c +24 -2
index 0ee81e4..2d659e6 100644
@@ -572,11 +572,21 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)
 	}
 
 	if (twl_has_regulator()) {
-		/*
 		child = add_regulator(TWL4030_REG_VPLL1, pdata->vpll1);
 		if (IS_ERR(child))
 			return PTR_ERR(child);
-		*/
+
+		child = add_regulator(TWL4030_REG_VIO, pdata->vio);
+		if (IS_ERR(child))
+			return PTR_ERR(child);
+
+		child = add_regulator(TWL4030_REG_VDD1, pdata->vdd1);
+		if (IS_ERR(child))
+			return PTR_ERR(child);
+
+		child = add_regulator(TWL4030_REG_VDD2, pdata->vdd2);
+		if (IS_ERR(child))
+			return PTR_ERR(child);
 
 		child = add_regulator(TWL4030_REG_VMMC1, pdata->vmmc1);
 		if (IS_ERR(child))
@@ -592,6 +602,18 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)
 				pdata->vaux2);
 		if (IS_ERR(child))
 			return PTR_ERR(child);
+
+		child = add_regulator(TWL4030_REG_VINTANA1, pdata->vintana1);
+		if (IS_ERR(child))
+			return PTR_ERR(child);
+
+		child = add_regulator(TWL4030_REG_VINTANA2, pdata->vintana2);
+		if (IS_ERR(child))
+			return PTR_ERR(child);
+
+		child = add_regulator(TWL4030_REG_VINTDIG, pdata->vintdig);
+		if (IS_ERR(child))
+			return PTR_ERR(child);
 	}
 
 	if (twl_has_regulator() && usb_transceiver) {
drivers/regulator/twl4030-regulator.c +17 -9
index e2032fb..edd1a1f 100644
@@ -260,6 +260,18 @@ static const u16 VSIM_VSEL_table[] = {
 static const u16 VDAC_VSEL_table[] = {
 	1200, 1300, 1800, 1800,
 };
+static const u16 VDD1_VSEL_table[] = {
+	800, 1450,
+};
+static const u16 VDD2_VSEL_table[] = {
+	800, 1450, 1500,
+};
+static const u16 VIO_VSEL_table[] = {
+	1800, 1850,
+};
+static const u16 VINTANA2_VSEL_table[] = {
+	2500, 2750,
+};
 
 
 static int twl4030ldo_list_voltage(struct regulator_dev *rdev, unsigned index)
@@ -397,20 +409,16 @@ static struct twlreg_info twl4030_regs[] = {
 	TWL_ADJUSTABLE_LDO(VAUX4, 0x23, 4),
 	TWL_ADJUSTABLE_LDO(VMMC1, 0x27, 5),
 	TWL_ADJUSTABLE_LDO(VMMC2, 0x2b, 6),
-	/*
 	TWL_ADJUSTABLE_LDO(VPLL1, 0x2f, 7),
-	*/
 	TWL_ADJUSTABLE_LDO(VPLL2, 0x33, 8),
 	TWL_ADJUSTABLE_LDO(VSIM, 0x37, 9),
 	TWL_ADJUSTABLE_LDO(VDAC, 0x3b, 10),
-	/*
-	TWL_ADJUSTABLE_LDO(VINTANA1, 0x3f, 11),
+	TWL_FIXED_LDO(VINTANA1, 0x3f, 1500, 11),
 	TWL_ADJUSTABLE_LDO(VINTANA2, 0x43, 12),
-	TWL_ADJUSTABLE_LDO(VINTDIG, 0x47, 13),
-	TWL_SMPS(VIO, 0x4b, 14),
-	TWL_SMPS(VDD1, 0x55, 15),
-	TWL_SMPS(VDD2, 0x63, 16),
-	 */
+	TWL_FIXED_LDO(VINTDIG, 0x47, 1500, 13),
+	TWL_ADJUSTABLE_LDO(VIO, 0x4b, 14),
+	TWL_ADJUSTABLE_LDO(VDD1, 0x55, 15),
+	TWL_ADJUSTABLE_LDO(VDD2, 0x63, 16),
 	TWL_FIXED_LDO(VUSB1V5, 0x71, 1500, 17),
 	TWL_FIXED_LDO(VUSB1V8, 0x74, 1800, 18),
 	TWL_FIXED_LDO(VUSB3V1, 0x77, 3100, 19),
include/linux/i2c/twl4030.h +6 -2
index c188961..bf143d8 100644
@@ -440,8 +440,12 @@ struct twl4030_platform_data {
 	struct regulator_init_data		*vaux2;
 	struct regulator_init_data		*vaux3;
 	struct regulator_init_data		*vaux4;
-
-	/* REVISIT more to come ... _nothing_ should be hard-wired */
+	struct regulator_init_data		*vio;
+	struct regulator_init_data		*vdd1;
+	struct regulator_init_data		*vdd2;
+	struct regulator_init_data		*vintana1;
+	struct regulator_init_data		*vintana2;
+	struct regulator_init_data		*vintdig;
 };
 
 /*----------------------------------------------------------------------*/
Signature · 1 line
1.6.3.3
#14 lore raw
In reply to Juha Keski-Saari
Quoted 24 lines · Juha Keski-Saari

This patch adds all the remaining TWL4030 regulators into the implementation, also adding VINT* regulators in this way since they can be derived out from the TWL

---
 drivers/mfd/twl4030-core.c            |   30 ++++++++++++++++++++++++++----
 drivers/regulator/twl4030-regulator.c |   27 +++++++++++++++++----------
 include/linux/i2c/twl4030.h           |    8 ++++++--
 3 files changed, 49 insertions(+), 16 deletions(-)
drivers/mfd/twl4030-core.c +1 -2
index a1c47ee..0748b43 100644
@@ -602,13 +602,15 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)
 	}
 
 	if (twl_has_regulator()) {
-		/*
-		child = add_regulator(TWL4030_REG_VPLL1, pdata->vpll1);
+		child = add_regulator(TWL4030_REG_VDD1, pdata->vdd1);
 		if (IS_ERR(child))
 			return PTR_ERR(child);

drivers/mfd/twl4030-core.c add_children(struct twl4030_platform_data *pdata, unsigned long features) · line 615

Quoted 10 lines
drivers/mfd/twl4030-core.c +5 -2
-		*/
 
-		child = add_regulator(TWL4030_REG_VMMC1, pdata->vmmc1);
+		child = add_regulator(TWL4030_REG_VDD2, pdata->vdd2);
+		if (IS_ERR(child))
+			return PTR_ERR(child);
+
+		child = add_regulator(TWL4030_REG_VIO, pdata->vio);
 		if (IS_ERR(child))
 			return PTR_ERR(child);

Not specifically targeted at this patch - this driver error handling is severely lacking and leaves bund of devices behind when one of them fails to be added.

Signature · 1 line
Dmitry