Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760790AbaGRIRf (ORCPT ); Fri, 18 Jul 2014 04:17:35 -0400 Received: from mail-ie0-f178.google.com ([209.85.223.178]:52409 "EHLO mail-ie0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760752AbaGRIRb (ORCPT ); Fri, 18 Jul 2014 04:17:31 -0400 Date: Fri, 18 Jul 2014 09:17:24 +0100 From: Lee Jones To: Javier Martinez Canillas Cc: Mark Brown , Mike Turquette , Liam Girdwood , Alessandro Zummo , Kukjin Kim , Doug Anderson , Olof Johansson , Tomeu Vizoso , Krzysztof Kozlowski , Yadwinder Singh Brar , Tushar Behera , Andreas Farber , linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v7 02/24] mfd: max77686: Add power management support Message-ID: <20140718081724.GL30888@lee--X1> References: <1404505467-26526-1-git-send-email-javier.martinez@collabora.co.uk> <1404505467-26526-3-git-send-email-javier.martinez@collabora.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1404505467-26526-3-git-send-email-javier.martinez@collabora.co.uk> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 04 Jul 2014, Javier Martinez Canillas wrote: > The driver doesn't have PM operations defined so add a suspend > and resume function handlers to allow the PMIC IRQ to wakeup > the system when it is put into a sleep state. > > Signed-off-by: Javier Martinez Canillas > Reviewed-by: Krzysztof Kozlowski > --- > drivers/mfd/max77686.c | 40 ++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 40 insertions(+) Applied now, thanks. > diff --git a/drivers/mfd/max77686.c b/drivers/mfd/max77686.c > index 3cb41d0..a38e9ee 100644 > --- a/drivers/mfd/max77686.c > +++ b/drivers/mfd/max77686.c > @@ -240,10 +240,50 @@ static const struct i2c_device_id max77686_i2c_id[] = { > }; > MODULE_DEVICE_TABLE(i2c, max77686_i2c_id); > > +#ifdef CONFIG_PM_SLEEP > +static int max77686_suspend(struct device *dev) > +{ > + struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); > + struct max77686_dev *max77686 = i2c_get_clientdata(i2c); > + > + if (device_may_wakeup(dev)) > + enable_irq_wake(max77686->irq); > + > + /* > + * IRQ must be disabled during suspend because if it happens > + * while suspended it will be handled before resuming I2C. > + * > + * When device is woken up from suspend (e.g. by RTC wake alarm), > + * an interrupt occurs before resuming I2C bus controller. > + * Interrupt handler tries to read registers but this read > + * will fail because I2C is still suspended. > + */ > + disable_irq(max77686->irq); > + > + return 0; > +} > + > +static int max77686_resume(struct device *dev) > +{ > + struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); > + struct max77686_dev *max77686 = i2c_get_clientdata(i2c); > + > + if (device_may_wakeup(dev)) > + disable_irq_wake(max77686->irq); > + > + enable_irq(max77686->irq); > + > + return 0; > +} > +#endif /* CONFIG_PM_SLEEP */ > + > +static SIMPLE_DEV_PM_OPS(max77686_pm, max77686_suspend, max77686_resume); > + > static struct i2c_driver max77686_i2c_driver = { > .driver = { > .name = "max77686", > .owner = THIS_MODULE, > + .pm = &max77686_pm, > .of_match_table = of_match_ptr(max77686_pmic_dt_match), > }, > .probe = max77686_i2c_probe, -- Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/