All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Heiko Stübner" <heiko@sntech.de>
To: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Liam Girdwood <lrg@ti.com>, linux-kernel@vger.kernel.org
Subject: Re: [RFC] Add gpio based voltage switching regulator
Date: Wed, 28 Sep 2011 10:02:54 +0200	[thread overview]
Message-ID: <201109281002.57101.heiko@sntech.de> (raw)
In-Reply-To: <20110926125155.GH2946@opensource.wolfsonmicro.com>

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

  reply	other threads:[~2011-09-28  8:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-26  6:52 [RFC] Add gpio based voltage switching regulator Heiko Stübner
2011-09-26 12:51 ` Mark Brown
2011-09-28  8:02   ` Heiko Stübner [this message]
2011-09-28  9:03     ` Mark Brown
2011-09-30 10:59       ` [RFC v2] Add gpio-regulator driver Heiko Stübner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201109281002.57101.heiko@sntech.de \
    --to=heiko@sntech.de \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lrg@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.