On Fri, Oct 21, 2011 at 1:23 AM, Linus Walleij <linus.walleij@xxxxxxxxxxxxxx> wrote: > From: Jonas Aaberg <jonas.aberg@xxxxxxxxxxxxxx> > > Turn off the clock and regulator to the I2C block using runtime > PM. > > Cc: Magnus Damm <magnus.damm@xxxxxxxxx> > Cc: Rafael J. Wysocki <rjw@xxxxxxx> > Signed-off-by: Jonas Aaberg <jonas.aberg@xxxxxxxxxxxxxx> > Signed-off-by: Linus Walleij <linus.walleij@xxxxxxxxxx> > --- > 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 -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html