Version 2 with thanks to Sam Ravnborg, Mariusz Kozlowski, David Brownell
and Laura Lawrence for their comments.
This patch series provides a generic framework to allow device drivers
to control voltage and current regulators on SoC based devices (e.g.
phones, gps, media players).
The intention is to allow systems to dynamically control regulator
output in order to save power and prolong battery life. This applies to
both voltage regulators (where voltage output is controllable) and
current sinks (where current output is controllable).
The framework is designed around SoC based devices but may also be
relevant to non SoC devices. It's also been designed against two Power
Management ICs (PMICs) currently on the market - namely the Freescale
MC13783 and the Wolfson WM8350. However it is quite generic and should
apply to all PMICs.
The framework provides several interfaces :-
1. Client or Consumer driver API.
This uses a similar API to the kernel clock interface in that client
or consumer drivers can get and put a regulator (like they can with
clocks atm) and get/set voltage, current, mode, enable and disable. This
should allow clients complete control over their supply voltage and
current. This API also compiles out if not in use so drivers can be
reused in systems with no PMIC power control.
2. Regulator driver API.
This allows regulator drivers to register their regulators and provide
operations to the core. It also has a notifier call chain for
propagating regulator events to clients.
3. Platform API.
This API is for platform/device specific code and allows the creation
of voltage/current domains (with constraints) for each regulator. It can
provide regulator constraints that will prevent device damage through
over voltage or over current caused by buggy client drivers. It also
allows the creation of a regulator tree whereby some regulators are
supplied by others (similar to a clock tree).
4. Userspace.
The framework also exports a lot of useful voltage/current data to
userspace via sysfs. This could be used to monitor device and regulator
power and status.
Fwiw, there is a project page here :-
http://opensource.wolfsonmicro.com/node/15
and code in our public git tree that currently shows this API
in use:-
http://opensource.wolfsonmicro.com/cgi-bin/gitweb.cgi?p=linux-2.6-audioplus.git;a=shortlog;h=imx31
All the relevant files are under include/linux/regulator and
drivers/regulator. There are client drivers here :-
http://opensource.wolfsonmicro.com/cgi-bin/gitweb.cgi?p=linux-2.6-audioplus.git;a=blob;f=arch/arm/mach-mx3/cpufreq.c;h=77f03d85fef6b29b0ca2e820d38d9ebb068e7bf7;hb=imx31
http://opensource.wolfsonmicro.com/cgi-bin/gitweb.cgi?p=linux-2.6-audioplus.git;a=blob;f=drivers/leds/leds-wm8350.c;h=a81bbf9154b4de13c029aee0613294562a03f506;hb=imx31
http://opensource.wolfsonmicro.com/cgi-bin/gitweb.cgi?p=linux-2.6-audioplus.git;a=blob;f=drivers/video/backlight/wm8350_bl.c;h=3eafb83683b7f242ec78ff620431307c25e23202;hb=imx31
http://opensource.wolfsonmicro.com/cgi-bin/gitweb.cgi?p=linux-2.6-audioplus.git;a=blob;f=sound/soc/imx/imx32ads-wm8350.c;h=aae347ac556203fbdb64d71f4dc0be7df250767a;hb=imx31
Patch follows.
Liam
On Wed, Feb 20, 2008 at 05:08:46PM +0000, Liam Girdwood wrote:
> This patch series provides a generic framework to allow device drivers
> to control voltage and current regulators on SoC based devices (e.g.
> phones, gps, media players).
Note that I'm explicitly avoiding commenting on this as far as PXA3xx
devices go, until we're further down the road with PM support on that
SoC. It's not clear at present whether a generic PMIC framework will
be suitable for this SoC since it's my understanding from Marvell that
we need to talk to the PMIC from IRQs-off contexts.
So don't take my silence as some sort of acceptance of this code; it
isn't.
On Thu, 2008-02-21 at 08:41 +0000, Russell King - ARM Linux wrote:
> On Wed, Feb 20, 2008 at 05:08:46PM +0000, Liam Girdwood wrote:
> > This patch series provides a generic framework to allow device drivers
> > to control voltage and current regulators on SoC based devices (e.g.
> > phones, gps, media players).
>
> Note that I'm explicitly avoiding commenting on this as far as PXA3xx
> devices go, until we're further down the road with PM support on that
> SoC. It's not clear at present whether a generic PMIC framework will
> be suitable for this SoC since it's my understanding from Marvell that
> we need to talk to the PMIC from IRQs-off contexts.
>
> So don't take my silence as some sort of acceptance of this code; it
> isn't.
I wasn't ;)
It then might be worth adding this functionality at a later stage when
more can be said about PXA3xx PMIC support. We could always have a
version of the _set() functions that are designed to handle this case.
In the mean time this works well on 3 other SoC CPUs.
Liam
On Fri, Feb 22, 2008 at 12:26 AM, Liam Girdwood
<[email protected]> wrote:
> On Thu, 2008-02-21 at 08:41 +0000, Russell King - ARM Linux wrote:
> > On Wed, Feb 20, 2008 at 05:08:46PM +0000, Liam Girdwood wrote:
> > > This patch series provides a generic framework to allow device drivers
> > > to control voltage and current regulators on SoC based devices (e.g.
> > > phones, gps, media players).
> >
> > Note that I'm explicitly avoiding commenting on this as far as PXA3xx
> > devices go, until we're further down the road with PM support on that
> > SoC. It's not clear at present whether a generic PMIC framework will
> > be suitable for this SoC since it's my understanding from Marvell that
> > we need to talk to the PMIC from IRQs-off contexts.
> >
> > So don't take my silence as some sort of acceptance of this code; it
> > isn't.
>
> I wasn't ;)
>
> It then might be worth adding this functionality at a later stage when
> more can be said about PXA3xx PMIC support. We could always have a
> version of the _set() functions that are designed to handle this case.
>
> In the mean time this works well on 3 other SoC CPUs.
>
> Liam
>
Liam,
I have a rough peek into the git tree on opensource.wolfsonmicro.com,
find another PMIC framework, and here instead is a regulator framework,
looks like a simplified or dedicated one. What is their relationship?
For those PMIC that covers additional features, like
- usb vbus detection (or pull-up/pull-down)
- audio codec
- touch screen
- battery monitor/ fuel gauge
- battery charger
- possible many others
How do you plan to handle them?
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
--
Cheers
- eric
On Fri, 2008-02-22 at 11:22 +0800, eric miao wrote:
>
> I have a rough peek into the git tree on opensource.wolfsonmicro.com,
> find another PMIC framework, and here instead is a regulator framework,
> looks like a simplified or dedicated one. What is their relationship?
>
This is probably the old version you came across. It was tightly coupled
to a particular PMIC and SoC CPU and not portable. The new version that
I posted is portable and not tied to a particular PMIC or CPU
architecture. The new version is hosted in the audioplus git repository
(imx31 branch).
> For those PMIC that covers additional features, like
> - usb vbus detection (or pull-up/pull-down)
> - audio codec
> - touch screen
> - battery monitor/ fuel gauge
> - battery charger
> - possible many others
>
> How do you plan to handle them?
The WM8350 and MC13783 are both multi feature PMIC's like above. We
handle WM8350 PMIC access via a bus manager. This controls IO access to
the WM8350 so that client driver (including the regulator driver) IO
does not collide. We also cache non volatile PMIC registers to speed up
access. Please have a look at drivers/regulator/wm8350/wm8350-bus.c in
the imx31 branch for details.
Liam
> > For those PMIC that covers additional features, like
> > - usb vbus detection (or pull-up/pull-down)
> > - audio codec
> > - touch screen
> > - battery monitor/ fuel gauge
> > - battery charger
> > - possible many others
Certainly many others ... like MMC transceivers, high speed USB
transceivers, RTCs, and lots of other analog and "high voltage"
(more than 1.8V, say) circuits that should be offloaded from
SOCs for systems built with 90nm (and smaller) processes.
> > How do you plan to handle them?
>
> The WM8350 and MC13783 are both multi feature PMIC's like above. We
> handle WM8350 PMIC access via a bus manager.
I think most such PMIC cases are best modeled as multi-function
devices, plugging into numerous different frameworks. That may
be implied by "bus manager".
There are already at least two PMIC drivers in drivers/i2c/chips
in the mainstream kernel (tps65010.c and menelaus.c) and I'd think
one factor to review of this framework is whether those chips
could reasonbly be used in this framework.
So for example the tps65010 presumes that fuel gauging is done
by a separate chip (presumptively using HDQ/1-Wire), and in fact
that may be part of a battery pack. And the DAC functions, like
touchscreens and (input) codecs, use other dedicated chips. As
time goes by, those PMIC chips integrate lots more functionality..
- Dave
> This controls IO access to
> the WM8350 so that client driver (including the regulator driver) IO
> does not collide. We also cache non volatile PMIC registers to speed up
> access. Please have a look at drivers/regulator/wm8350/wm8350-bus.c in
> the imx31 branch for details.
>
> Liam
>