All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] twl-regulator: Allow CONFIG_TWL4030_ALLOW_UNSUPPORTED to be requested.
@ 2012-04-25  2:29 NeilBrown
  2012-04-25  8:24 ` Mark Brown
  0 siblings, 1 reply; 6+ messages in thread
From: NeilBrown @ 2012-04-25  2:29 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1032 bytes --]


twl-regulator.c changes behaviour slightly depending on
  CONFIG_TWL4030_ALLOW_UNSUPPORTED
However that config option is not currently listed in any Kconfig
file.
So add the option to allow it to be chosen.

Signed-off-by: NeilBrown <neilb@suse.de>

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 36db5a4..1d24cac 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -338,6 +338,15 @@ config REGULATOR_TWL4030
 	  This driver supports the voltage regulators provided by
 	  this family of companion chips.
 
+config TWL4030_ALLOW_UNSUPPORTED
+	bool "Allow unsupported voltages on TI TWL4030/TWL5030/TWL6030/TPS659x0 PMIC"
+	depends on REGULATOR_TWL4030
+	help
+	  TWL4030 regulator can (possibly) supply voltages that are not
+	  explicitly supported by TI.  Set this option to allow those
+	  voltages to be requested.
+	  If unsure, say 'N'
+
 config REGULATOR_WM831X
 	tristate "Wolfson Microelectronics WM831x PMIC regulators"
 	depends on MFD_WM831X

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

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

* Re: [PATCH] twl-regulator: Allow CONFIG_TWL4030_ALLOW_UNSUPPORTED to be requested.
  2012-04-25  2:29 [PATCH] twl-regulator: Allow CONFIG_TWL4030_ALLOW_UNSUPPORTED to be requested NeilBrown
@ 2012-04-25  8:24 ` Mark Brown
  2012-04-25  9:59   ` NeilBrown
  0 siblings, 1 reply; 6+ messages in thread
From: Mark Brown @ 2012-04-25  8:24 UTC (permalink / raw)
  To: NeilBrown; +Cc: Liam Girdwood, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 465 bytes --]

On Wed, Apr 25, 2012 at 12:29:24PM +1000, NeilBrown wrote:
> 
> twl-regulator.c changes behaviour slightly depending on
>   CONFIG_TWL4030_ALLOW_UNSUPPORTED
> However that config option is not currently listed in any Kconfig
> file.
> So add the option to allow it to be chosen.

Shouldn't this be hidden behind _EXPERIMENTAL and/or enabled by the
board in platform data/device tree?  Kconfig feels like the wrong place
to do this sort of configuration.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH] twl-regulator: Allow CONFIG_TWL4030_ALLOW_UNSUPPORTED to be requested.
  2012-04-25  8:24 ` Mark Brown
@ 2012-04-25  9:59   ` NeilBrown
  2012-04-25 10:12     ` Mark Brown
  0 siblings, 1 reply; 6+ messages in thread
From: NeilBrown @ 2012-04-25  9:59 UTC (permalink / raw)
  To: Mark Brown; +Cc: Liam Girdwood, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 946 bytes --]

On Wed, 25 Apr 2012 09:24:18 +0100 Mark Brown
<broonie@opensource.wolfsonmicro.com> wrote:

> On Wed, Apr 25, 2012 at 12:29:24PM +1000, NeilBrown wrote:
> > 
> > twl-regulator.c changes behaviour slightly depending on
> >   CONFIG_TWL4030_ALLOW_UNSUPPORTED
> > However that config option is not currently listed in any Kconfig
> > file.
> > So add the option to allow it to be chosen.
> 
> Shouldn't this be hidden behind _EXPERIMENTAL and/or enabled by the
> board in platform data/device tree?  Kconfig feels like the wrong place
> to do this sort of configuration.

That make sense - but I cannot find a good place to put the flag.
TWL doesn't have any twl-specific platform data, it just uses
struct regulator_init_data.  I don't suppose it would be acceptable
to tuck an 'allow_unsupported' flag inside 'struct regulation_constraints'?

I'm not sure how else to do it without fairly major surgery.

Thanks,
NeilBrown

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

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

* Re: [PATCH] twl-regulator: Allow CONFIG_TWL4030_ALLOW_UNSUPPORTED to be requested.
  2012-04-25  9:59   ` NeilBrown
@ 2012-04-25 10:12     ` Mark Brown
  2012-04-25 10:50       ` NeilBrown
  0 siblings, 1 reply; 6+ messages in thread
From: Mark Brown @ 2012-04-25 10:12 UTC (permalink / raw)
  To: NeilBrown; +Cc: Liam Girdwood, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 575 bytes --]

On Wed, Apr 25, 2012 at 07:59:56PM +1000, NeilBrown wrote:

> That make sense - but I cannot find a good place to put the flag.
> TWL doesn't have any twl-specific platform data, it just uses
> struct regulator_init_data.  I don't suppose it would be acceptable
> to tuck an 'allow_unsupported' flag inside 'struct regulation_constraints'?

> I'm not sure how else to do it without fairly major surgery.

This is what the driver_data in regulator_init_data is there for - to
allow device specific extensions to be added if needed.  I guess it
should be possible to use that?

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH] twl-regulator: Allow CONFIG_TWL4030_ALLOW_UNSUPPORTED to be requested.
  2012-04-25 10:12     ` Mark Brown
@ 2012-04-25 10:50       ` NeilBrown
  2012-04-26  9:28         ` Mark Brown
  0 siblings, 1 reply; 6+ messages in thread
From: NeilBrown @ 2012-04-25 10:50 UTC (permalink / raw)
  To: Mark Brown; +Cc: Liam Girdwood, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2971 bytes --]

On Wed, 25 Apr 2012 11:12:59 +0100 Mark Brown
<broonie@opensource.wolfsonmicro.com> wrote:

> On Wed, Apr 25, 2012 at 07:59:56PM +1000, NeilBrown wrote:
> 
> > That make sense - but I cannot find a good place to put the flag.
> > TWL doesn't have any twl-specific platform data, it just uses
> > struct regulator_init_data.  I don't suppose it would be acceptable
> > to tuck an 'allow_unsupported' flag inside 'struct regulation_constraints'?
> 
> > I'm not sure how else to do it without fairly major surgery.
> 
> This is what the driver_data in regulator_init_data is there for - to
> allow device specific extensions to be added if needed.  I guess it
> should be possible to use that?

Ahh... (digs around) and twl treats that as a 'long' and copies it into
  info->features
(which is otherwize set from static data).

So maybe something like that (completely untested as yet) ??
(and this seems to have changed between 3.3 and 3.4 which confused me
a bit.  But if you think this approach is OK I'll come up with something
that is right for 3.4).

Thanks,
NeilBrown

diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c
index 181a2cf..00fd3d2 100644
--- a/drivers/regulator/twl-regulator.c
+++ b/drivers/regulator/twl-regulator.c
@@ -375,14 +375,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))
 
 
@@ -456,7 +454,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
@@ -470,7 +468,7 @@ twl4030ldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV,
 		int mV = info->table[vsel];
 		int uV;
 
-		if (IS_UNSUP(mV))
+		if (IS_UNSUP(info, mV))
 			continue;
 		uV = LDO_MV(mV) * 1000;
 
diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h
index 5b87dc9..5f56743 100644
--- a/include/linux/i2c/twl.h
+++ b/include/linux/i2c/twl.h
@@ -172,6 +172,9 @@ TWL_CLASS_IS(4030, TWL4030_CLASS_ID)
 TWL_CLASS_IS(6030, TWL6030_CLASS_ID)
 
 #define TWL6025_SUBCLASS	BIT(4)  /* TWL6025 has changed registers */
+#define TWL4030_ALLOW_UNSUPPORTED BIT(0) /* Some voltages are possible
+					  * but not officially supported
+					  */
 
 /*
  * Read and write single 8-bit registers

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

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

* Re: [PATCH] twl-regulator: Allow CONFIG_TWL4030_ALLOW_UNSUPPORTED to be requested.
  2012-04-25 10:50       ` NeilBrown
@ 2012-04-26  9:28         ` Mark Brown
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2012-04-26  9:28 UTC (permalink / raw)
  To: NeilBrown; +Cc: Liam Girdwood, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 325 bytes --]

On Wed, Apr 25, 2012 at 08:50:02PM +1000, NeilBrown wrote:

> So maybe something like that (completely untested as yet) ??
> (and this seems to have changed between 3.3 and 3.4 which confused me
> a bit.  But if you think this approach is OK I'll come up with something
> that is right for 3.4).

Yes, that looks reasonable.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

end of thread, other threads:[~2012-04-26  9:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-25  2:29 [PATCH] twl-regulator: Allow CONFIG_TWL4030_ALLOW_UNSUPPORTED to be requested NeilBrown
2012-04-25  8:24 ` Mark Brown
2012-04-25  9:59   ` NeilBrown
2012-04-25 10:12     ` Mark Brown
2012-04-25 10:50       ` NeilBrown
2012-04-26  9:28         ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.