From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752464AbdATWBi (ORCPT ); Fri, 20 Jan 2017 17:01:38 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:35751 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752161AbdATWAY (ORCPT ); Fri, 20 Jan 2017 17:00:24 -0500 Subject: Re: [PATCH] leds: gpio: Add pinctrl PM select sleep,default state in suspend/resume To: Enric Balletbo i Serra References: <20170120164553.27565-1-enric.balletbo@collabora.com> Cc: Richard Purdie , Pavel Machek , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org From: Jacek Anaszewski X-Enigmail-Draft-Status: N1110 Message-ID: Date: Fri, 20 Jan 2017 22:59:38 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.5.1 MIME-Version: 1.0 In-Reply-To: <20170120164553.27565-1-enric.balletbo@collabora.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Enric, LED subsystem core already registers its pm ops. (see drivers/leds/led-class.c and leds_class_dev_pm_ops). It results in setting brightness of all LED class devices marked with LED_CORE_SUSPENDRESUME flag to 0 on suspend and bringing back previous brightness on resume. In this case you would have to track the state of all LED class devices exposed by leds-gpio and call pinctrl_pm_select_sleep_state() when they all are off. Now, if in this state and turning any of the LEDs on, then pinctrl_pm_select_default_state() would have to be called. Compare the following patch: commit a8c170b015ff6695641bdfbdb74729411ba1e9e5 Author: Matt Ranostay Date: Fri Oct 28 18:20:42 2016 -0700 leds: pca963x: enable low-power state Allow chip to enter low power state when no LEDs are being lit or in blink mode. On 01/20/2017 05:45 PM, Enric Balletbo i Serra wrote: > This patch allows users to use an alternate pinctrl "sleep" in order to > clamp outputs to a wanted state at suspend. > > Signed-off-by: Enric Balletbo i Serra > --- > drivers/leds/leds-gpio.c | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c > index d400dca..a2e9bdb 100644 > --- a/drivers/leds/leds-gpio.c > +++ b/drivers/leds/leds-gpio.c > @@ -20,6 +20,7 @@ > #include > #include > #include > +#include > > struct gpio_led_data { > struct led_classdev cdev; > @@ -269,12 +270,31 @@ static void gpio_led_shutdown(struct platform_device *pdev) > } > } > > +#ifdef CONFIG_PM_SLEEP > +static int gpio_led_suspend(struct device *dev) > +{ > + pinctrl_pm_select_sleep_state(dev); > + > + return 0; > +} > + > +static int gpio_led_resume(struct device *dev) > +{ > + pinctrl_pm_select_default_state(dev); > + > + return 0; > +} > +#endif > + > +static SIMPLE_DEV_PM_OPS(gpio_led_pm, gpio_led_suspend, gpio_led_resume); > + > static struct platform_driver gpio_led_driver = { > .probe = gpio_led_probe, > .shutdown = gpio_led_shutdown, > .driver = { > .name = "leds-gpio", > .of_match_table = of_gpio_leds_match, > + .pm = &gpio_led_pm, > }, > }; > > -- Best regards, Jacek Anaszewski