Re: [PATCH 1/2] AB3100 regulator support v2

From: Mark Brown
Date: Tue Sep 01 2009 - 06:23:32 EST

On Mon, Aug 31, 2009 at 04:16:15PM +0200, Linus Walleij wrote:
> 2009/8/31 Mark Brown <broonie@xxxxxxxxxxxxxxxxxxxxxxxxxxx>:

> >> +     err = ab3100_get_register_interruptible(abreg->ab3100, abreg->regreg,
> >> +                                             &regval);

> > I did query last time if having these operations be interruptible is a
> > good idea - I can't see it helping robustness, it's not something that
> > other drivers are doing and it'd complicate things for all API users to
> > add handling for the error. I don't recall any discussion of the
> > thinking here?

> I recently renamed all the ab3100 accessor functions to *_interruptible
> to reflect the fact that the accessor mutex on ab3100 uses
> mutex_lock_interruptible() so this suffix should propagate so it is
> clear that stuff like -ERESTARTSYS can be returned.
> So the above errorcheck is probably bogus.

Oh, there's no noninterruptible version? With the naming it looked like
there was.

> That said, I think the regulator paths are entirely in-kernel and
> under such circumstances that signals from userspace are blocked
> anyway. The problem is that the ab3100 is accessed by complex

The regulator API doesn't give any guarantees that signals can't be

> userspace programs and I2C is sometimes slow so there is a need
> for being able to interrupt it, but I *could* go in and use an

While I2C isn't fast for the sorts of access regulators tend to do it's
not so slow as to make this critical.

> uniterruptable mutex if you prefer that, I'll ask around here if
> we should do this. Can the function name stand as it is for the time being?

> >> +static int ab3100_get_voltage_regulator_external(struct regulator_dev *reg)
> >> +{

> > Hrm.  I suspect that you either want to add some platform data to
> > specify the voltage as a plain number or just have boards use the
> > regulator supply mechanism with a fixed voltage regulator supplied by
> > this one if they need to specify the voltage of the supply.

> I was designing for it to be controllable but not controllable by the
> AB3100 driver, perhaps it is a regulator somewhere else here,
> defined in the board data. But I went for a fixed int member
> voltage setting for the time being, we can discuss that stuff later
> when I have some practical use for it.

I've got the same sort of external switch on the WM831x. What I did
there was just not have the voltage at all. The regulator API supports
chaining of regulators so one regulator is the supply for another so
what a board could do is set things up so that the switch on the PMIC is
the supply for an external regulator. There's already a standard driver
for simple fixed voltage regulators and if the regulator is more complex
and supports variable voltages then it can use its normal driver.

> If this sequence is a dependency graph of regulators that need to
> have deps in all strange directions you get a directed graph
> Or you could limit yourself to a directed acyclic graph
> in either case it's rather a delicate computational problem
> but I guess you're after a simple linear sequence here, like
> switch on A, B, C, D ... N in a special order?

The power sequencing provided by hardware designers is normally a simple
linear sequence of things to do to bring the system power up - normally
you'd bring some supplies up, wait for a given time period then bring
some more up and so on. Sometimes there will be some handshaking
involved (waiting for "I've started" signals from components).

> In my case it's actually not the switching-on or of that is
> the problem, it's more of putting some magic numbers
> into some registers in a special order (well, any order
> actually except for one register that is special).

> I'll see if I can think of something more elegant to
> make this more appealing, like tagging each default
> register value with a sequence number or so.

Are the magic numbers controlling things other than the settings that
are exposed through the regulator API?
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at