Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1563793 > unrolled thread
| Started by | Enric Balletbo i Serra <enric.balletbo@collabora.com> |
|---|---|
| First post | 2017-01-20 18:00 +0100 |
| Last post | 2017-01-20 23:10 +0100 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH] leds: gpio: Add pinctrl PM select sleep,default state in suspend/resume Enric Balletbo i Serra <enric.balletbo@collabora.com> - 2017-01-20 18:00 +0100
Re: [PATCH] leds: gpio: Add pinctrl PM select sleep,default state in suspend/resume Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-01-20 22:20 +0100
Re: [PATCH] leds: gpio: Add pinctrl PM select sleep,default state in suspend/resume Jacek Anaszewski <jacek.anaszewski@gmail.com> - 2017-01-20 23:10 +0100
| From | Enric Balletbo i Serra <enric.balletbo@collabora.com> |
|---|---|
| Date | 2017-01-20 18:00 +0100 |
| Subject | [PATCH] leds: gpio: Add pinctrl PM select sleep,default state in suspend/resume |
| Message-ID | <t1KHE-1gZ-27@gated-at.bofh.it> |
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 <enric.balletbo@collabora.com>
---
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 <linux/platform_device.h>
#include <linux/property.h>
#include <linux/slab.h>
+#include <linux/pm.h>
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,
},
};
--
2.9.3
[toc] | [next] | [standalone]
| From | Andy Shevchenko <andy.shevchenko@gmail.com> |
|---|---|
| Date | 2017-01-20 22:20 +0100 |
| Message-ID | <t1OLg-3Yv-13@gated-at.bofh.it> |
| In reply to | #1563793 |
On Fri, Jan 20, 2017 at 6:45 PM, Enric Balletbo i Serra <enric.balletbo@collabora.com> wrote: > This patch allows users to use an alternate pinctrl "sleep" in order to > clamp outputs to a wanted state at suspend. > +#ifdef CONFIG_PM_SLEEP > +static int gpio_led_suspend(struct device *dev) Switch to __maybe_unused -- With Best Regards, Andy Shevchenko
[toc] | [prev] | [next] | [standalone]
| From | Jacek Anaszewski <jacek.anaszewski@gmail.com> |
|---|---|
| Date | 2017-01-20 23:10 +0100 |
| Subject | Re: [PATCH] leds: gpio: Add pinctrl PM select sleep,default state in suspend/resume |
| Message-ID | <t1PxE-4uT-15@gated-at.bofh.it> |
| In reply to | #1563793 |
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 <mranostay@gmail.com>
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 <enric.balletbo@collabora.com>
> ---
> 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 <linux/platform_device.h>
> #include <linux/property.h>
> #include <linux/slab.h>
> +#include <linux/pm.h>
>
> 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
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web