[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <201109281002.57101.heiko@sntech.de>
Date: Wed, 28 Sep 2011 10:02:54 +0200
From: Heiko Stübner <heiko@...ech.de>
To: Mark Brown <broonie@...nsource.wolfsonmicro.com>
Cc: Liam Girdwood <lrg@...com>, linux-kernel@...r.kernel.org
Subject: Re: [RFC] Add gpio based voltage switching regulator
Hi Mark,
thanks for your comments.
Am Montag, 26. September 2011, 14:51:55 schrieb Mark Brown:
> On Mon, Sep 26, 2011 at 08:52:18AM +0200, Heiko Stübner wrote:
> > This patch adds support for regulators that can switch between
> > two voltage levels by setting a gpio.
>
> This really should be scalable beyond two voltages, or at least prepared
> for that possibility.
I think I've come up with a solution for this but would like to make sure I'm
on the right track. So my general idea is to define the platform_data like
static struct switched_voltage_config es600_dcdc3 = {
[...]
.switch_gpios = {
GPIO1, /* bit 0 in matrix */
GPIO2, /* bit 1 in matrix */
},
.nr_switch_gpios = 2,
.switch_matrix = {
{ .microvolts = 1000000, .gpio_state = (0 << 1) | (0 << 0) },
{ .microvolts = 1100000, .gpio_state = (0 << 1) | (1 << 0) },
{ .microvolts = 1200000, .gpio_state = (1 << 1) | (0 << 0) },
{ .microvolts = 1300000, .gpio_state = (1 << 1) | (1 << 0) },
},
.nr_switch_matrix = 4,
[...]
};
i.e. each voltage keeps the target gpio state in a bit-field which makes the
mapping current_state -> voltage in get_voltage very easy.
set_voltage would then look like
gpio_state = get_gpio_state_for_voltage(microvolts);
for(ptr = 0; ptr < nr_switch_gpios; ptr++) {
state = ( gpio_state & (1 << ptr) ) >> ptr;
gpio_set_value(switch_gpios[ptr], state);
}
i.e. simply extracting the target setting from the bitfield for each gpio.
If using integers for the state, this would scale up to 16 gpios and
voltage-permutations thereof.
Reasonable?
> > Handling of set_voltage calls with a range that fits neither the
> > low nor the high voltage is determined by the inbetween_high
> > option. When set to 1 the high voltage is used, on 0 the low
> > voltage is used and on -EINVAL an error is returned, disallowing
> > the usage of the voltage range.
>
> No, don't do this. If you can't set the requested voltage then fail.
> This is not in the least bit driver specific.
ok
> > @@ -0,0 +1,320 @@
> > +/*
> > + * switched.c
>
> This needs a better name.
"gpio-regulator"?
I'm quite open to suggestions :-)
> Otherwise this looks good, the main thing is the ability to support more
> voltages.
Heiko
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists