linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Magnus Damm <magnus.damm-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Linus Walleij <linus.walleij-0IS4wlFg1OjSUeElwK9/Pw@public.gmane.org>
Cc: Ben Dooks <ben-i2c-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Jonas Aaberg
	<jonas.aberg-0IS4wlFg1OjSUeElwK9/Pw@public.gmane.org>,
	"Rafael J. Wysocki" <rjw-KKrjLPT3xs0@public.gmane.org>,
	Linus Walleij
	<linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Subject: Re: [PATCH 2/2] i2c/nomadik: runtime PM support
Date: Fri, 21 Oct 2011 01:44:40 +0900	[thread overview]
Message-ID: <CANqRtoSxHHKxLaKd-qPjCDomp5o-iiij8hqLCs7GNhs4xCV-jg@mail.gmail.com> (raw)
In-Reply-To: <1319127798-13395-1-git-send-email-linus.walleij-0IS4wlFg1OjSUeElwK9/Pw@public.gmane.org>

On Fri, Oct 21, 2011 at 1:23 AM, Linus Walleij
<linus.walleij-0IS4wlFg1OjSUeElwK9/Pw@public.gmane.org> wrote:
> From: Jonas Aaberg <jonas.aberg-0IS4wlFg1OjSUeElwK9/Pw@public.gmane.org>
>
> Turn off the clock and regulator to the I2C block using runtime
> PM.
>
> Cc: Magnus Damm <magnus.damm-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Cc: Rafael J. Wysocki <rjw-KKrjLPT3xs0@public.gmane.org>
> Signed-off-by: Jonas Aaberg <jonas.aberg-0IS4wlFg1OjSUeElwK9/Pw@public.gmane.org>
> Signed-off-by: Linus Walleij <linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> ---
>  drivers/i2c/busses/i2c-nomadik.c |   53 ++++++++++++++++++++++++++++----------
>  1 files changed, 39 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c
> index ce4fd80..9ac9870 100644
> --- a/drivers/i2c/busses/i2c-nomadik.c
> +++ b/drivers/i2c/busses/i2c-nomadik.c

[snip]

> +static int nmk_i2c_runtime_suspend(struct device *dev)
> +{
> +       struct platform_device *pdev = to_platform_device(dev);
> +       struct nmk_i2c_dev *nmk_i2c = platform_get_drvdata(pdev);
> +
> +       clk_disable(nmk_i2c->clk);
> +       if (nmk_i2c->regulator)
> +               regulator_disable(nmk_i2c->regulator);
> +       return 0;
> +}
> +
> +static int nmk_i2c_runtime_resume(struct device *dev)
> +{
> +       struct platform_device *pdev = to_platform_device(dev);
> +       struct nmk_i2c_dev *nmk_i2c = platform_get_drvdata(pdev);
> +
> +       if (nmk_i2c->regulator)
> +               regulator_enable(nmk_i2c->regulator);
> +       clk_enable(nmk_i2c->clk);
> +       return 0;
> +}
> +

Hm, on SH-Mobile ARM we never control any clocks from the driver
runtime pm callbacks.

In our case the SoC code may associate various clocks with the struct
device and those clocks will be disabled and enabled automatically
when the driver does runtime pm put() and get() touch zero use count
for the device. The driver is happily unaware how many and which
clocks that are associated with the struct device.

So the clocks are started and stopped depending on the use count value
for a single device, but the actual driver callbacks are not however
invoked. In our case the runtime suspend callbacks are only invoked
when all the devices in the power domain happen to have a zero runtime
pm use count. So if you control your clocks from those callbacks then
they will be mostly left on which may not be what you want.

Perhaps your soc-specific code invokes the runtime pm suspend / resume
callbacks regardless of the state of all devices in a certain power
domain?

Cheers,

/ magnus

  parent reply	other threads:[~2011-10-20 16:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-20 16:23 [PATCH 2/2] i2c/nomadik: runtime PM support Linus Walleij
     [not found] ` <1319127798-13395-1-git-send-email-linus.walleij-0IS4wlFg1OjSUeElwK9/Pw@public.gmane.org>
2011-10-20 16:44   ` Magnus Damm [this message]
     [not found]     ` <CANqRtoSxHHKxLaKd-qPjCDomp5o-iiij8hqLCs7GNhs4xCV-jg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-10-21 11:19       ` Linus Walleij
     [not found]         ` <CACRpkdZmifrV3o59JrWx2Z6DAqHO80W4d=7NJ6OipAOrbazgXg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-10-24 14:32           ` Magnus Damm
     [not found]             ` <CANqRtoRw5+1yrEuphdYT+wq2ooHTojj00i5yGLPMWomUBPSP1Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-10-24 17:17               ` Linus Walleij

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=CANqRtoSxHHKxLaKd-qPjCDomp5o-iiij8hqLCs7GNhs4xCV-jg@mail.gmail.com \
    --to=magnus.damm-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=ben-i2c-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org \
    --cc=jonas.aberg-0IS4wlFg1OjSUeElwK9/Pw@public.gmane.org \
    --cc=linus.walleij-0IS4wlFg1OjSUeElwK9/Pw@public.gmane.org \
    --cc=linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=rjw-KKrjLPT3xs0@public.gmane.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).