Skip to contentSkip to conversation

MFD/regulator: make TWL4030_ALLOW_UNSUPPORTED more configurable.

PATCH In review NeilBrown 2 participants 4 messages May 8, 2012 – May 9, 2012

Subsystems (3)
lore
Share & tools
lore

NeilBrown

author
#0 lore raw

cover MFD/regulator: make TWL4030_ALLOW_UNSUPPORTED more configurable.

This is a resend, rebased on linux-next (next-20120508) which simplifies the second patch slightly.

Thanks,
NeilBrown

---

NeilBrown (2):
regulator: twl-regulator: make TWL4030_ALLOW_UNSUPPORTED more configurable.
MFD: twl-regulator: define all feature flags in one place.

 drivers/mfd/twl-core.c            |    7 -------
 drivers/regulator/twl-regulator.c |   10 ++++------
 include/linux/i2c/twl.h           |   13 +++++++++++--
 3 files changed, 15 insertions(+), 15 deletions(-)
Signature · 1 line
Signature
author
#1 lore raw

PATCH 1/2 MFD: twl-regulator: define all feature flags in one place.

twl-regulator has a collection of feature flags, some defined in twl-core.c and one defined in i2c/twl.h.
This is confusing for anyone adding a new feature flag.

So collect them together and place them in twl.h immediately after the structure in which they are initially set.

---

 drivers/mfd/twl-core.c  |    7 -------
 include/linux/i2c/twl.h |    8 ++++++--
 2 files changed, 6 insertions(+), 9 deletions(-)
drivers/mfd/twl-core.c +0 -7
index 7c2267e..6fc90be 100644
@@ -224,13 +224,6 @@
 #define HIGH_PERF_SQ			(1 << 3)
 #define CK32K_LOWPWR_EN			(1 << 7)
 
-
-/* chip-specific feature flags, for i2c_device_id.driver_data */
-#define TWL4030_VAUX2		BIT(0)	/* pre-5030 voltage ranges */
-#define TPS_SUBSET		BIT(1)	/* tps659[23]0 have fewer LDOs */
-#define TWL5031			BIT(2)  /* twl5031 has different registers */
-#define TWL6030_CLASS		BIT(3)	/* TWL6030 class */
-
 /*----------------------------------------------------------------------*/
 
 /* is driver active, bound to a chip? */
include/linux/i2c/twl.h +6 -2
index 1f90de0..d1afedc 100644
@@ -171,8 +171,6 @@ static inline int twl_class_is_ ##class(void)	\
 TWL_CLASS_IS(4030, TWL4030_CLASS_ID)
 TWL_CLASS_IS(6030, TWL6030_CLASS_ID)
 
-#define TWL6025_SUBCLASS	BIT(4)  /* TWL6025 has changed registers */
-
 /*
  * Read and write single 8-bit registers
  */
@@ -746,6 +744,12 @@ struct twl_regulator_driver_data {
 	void		*data;
 	unsigned long	features;
 };
+/* chip-specific feature flags, for twl_regulator_driver_data.features */
+#define TWL4030_VAUX2		BIT(0)	/* pre-5030 voltage ranges */
+#define TPS_SUBSET		BIT(1)	/* tps659[23]0 have fewer LDOs */
+#define TWL5031			BIT(2)  /* twl5031 has different registers */
+#define TWL6030_CLASS		BIT(3)	/* TWL6030 class */
+#define TWL6025_SUBCLASS	BIT(4)  /* TWL6025 has changed registers */
 
 /*----------------------------------------------------------------------*/
 
author
#2 lore raw

PATCH 2/2 regulator: twl-regulator: make TWL4030_ALLOW_UNSUPPORTED more configurable.

In reply to NeilBrown

The regulators in the twl4030 can provide some voltage settings that are not offically supported.
These settings are disabled by default, but can be enabled with
CONFIG_TWL4030_ALLOW_UNSUPPORTED=y
However
- that config variable is not mentioned in any Kconfig so cannot be used, and
- a global setting is clumsy - a per regulator setting would be better.

So define a new 'feature' flag that a board file can set to enable these unsupported volatages for boards which need them.

This flag cannot (yet) be set using device-tree.

---

 drivers/regulator/twl-regulator.c |   10 ++++------
 include/linux/i2c/twl.h           |    5 +++++
 2 files changed, 9 insertions(+), 6 deletions(-)
drivers/regulator/twl-regulator.c +4 -6
index fffacb4..c739071 100644
@@ -395,14 +395,12 @@ static int twl6030reg_set_mode(struct regulator_dev *rdev, unsigned mode)
  * VAUX3 at 3V is incorrectly listed in some TI manuals as unsupported.
  * TI are revising the twl5030/tps659x0 specs to support that 3.0V setting.
  */
-#ifdef CONFIG_TWL4030_ALLOW_UNSUPPORTED
-#define UNSUP_MASK	0x0000
-#else
 #define UNSUP_MASK	0x8000
-#endif
 
 #define UNSUP(x)	(UNSUP_MASK | (x))
-#define IS_UNSUP(x)	(UNSUP_MASK & (x))
+#define IS_UNSUP(info, x)			\
+	((UNSUP_MASK & (x)) &&			\
+	 !((info)->features & TWL4030_ALLOW_UNSUPPORTED))
 #define LDO_MV(x)	(~UNSUP_MASK & (x))
 
 
@@ -476,7 +474,7 @@ static int twl4030ldo_list_voltage(struct regulator_dev *rdev, unsigned index)
 	struct twlreg_info	*info = rdev_get_drvdata(rdev);
 	int			mV = info->table[index];
 
-	return IS_UNSUP(mV) ? 0 : (LDO_MV(mV) * 1000);
+	return IS_UNSUP(info, mV) ? 0 : (LDO_MV(mV) * 1000);
 }
 
 static int
include/linux/i2c/twl.h +5 -0
index d1afedc..3993477 100644
@@ -750,6 +750,11 @@ struct twl_regulator_driver_data {
 #define TWL5031			BIT(2)  /* twl5031 has different registers */
 #define TWL6030_CLASS		BIT(3)	/* TWL6030 class */
 #define TWL6025_SUBCLASS	BIT(4)  /* TWL6025 has changed registers */
+#define TWL4030_ALLOW_UNSUPPORTED BIT(5) /* Some voltages are possible
+					  * but not officially supported.
+					  * This flag is necessary to
+					  * enable them.
+					  */
 
 /*----------------------------------------------------------------------*/
 
#3 lore raw
In reply to NeilBrown
Quoted 2 lines · NeilBrown

This is a resend, rebased on linux-next (next-20120508) which simplifies the second patch slightly.

Applied both after fixing up the changelog for the first patch slightly.