[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120425205002.104ff358@notabene.brown>
Date: Wed, 25 Apr 2012 20:50:02 +1000
From: NeilBrown <neilb@...e.de>
To: Mark Brown <broonie@...nsource.wolfsonmicro.com>
Cc: Liam Girdwood <lrg@...com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] twl-regulator: Allow CONFIG_TWL4030_ALLOW_UNSUPPORTED
to be requested.
On Wed, 25 Apr 2012 11:12:59 +0100 Mark Brown
<broonie@...nsource.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
Download attachment "signature.asc" of type "application/pgp-signature" (829 bytes)
Powered by blists - more mailing lists