From: Corentin LABBE <clabbe@baylibre.com>
To: lee.jones@linaro.org, daniel.thompson@linaro.org, jingoohan1@gmail.com
Cc: dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org,
linux-kernel@vger.kernel.org, khilman@baylibre.com,
Jean-Jacques Hiblot <jjhiblot@ti.com>,
Corentin LABBE <clabbe@baylibre.com>
Subject: [PATCH] backlight: led_bl: Add support for an "enable" GPIO
Date: Tue, 2 Nov 2021 10:04:55 +0000 [thread overview]
Message-ID: <20211102100455.2016610-1-clabbe@baylibre.com> (raw)
From: Jean-Jacques Hiblot <jjhiblot@ti.com>
This patch adds support for an "enable GPIO".
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Signed-off-by: Corentin LABBE <clabbe@baylibre.com>
---
drivers/video/backlight/led_bl.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/video/backlight/led_bl.c b/drivers/video/backlight/led_bl.c
index f54d256e2d54..ebd7acc32980 100644
--- a/drivers/video/backlight/led_bl.c
+++ b/drivers/video/backlight/led_bl.c
@@ -8,6 +8,7 @@
#include <linux/backlight.h>
#include <linux/leds.h>
+#include <linux/gpio.h>
#include <linux/module.h>
#include <linux/platform_device.h>
@@ -15,6 +16,7 @@ struct led_bl_data {
struct device *dev;
struct backlight_device *bl_dev;
struct led_classdev **leds;
+ struct gpio_desc *enable_gpio;
bool enabled;
int nb_leds;
unsigned int *levels;
@@ -35,6 +37,9 @@ static void led_bl_set_brightness(struct led_bl_data *priv, int level)
for (i = 0; i < priv->nb_leds; i++)
led_set_brightness(priv->leds[i], bkl_brightness);
+ if (!priv->enabled)
+ gpiod_set_value_cansleep(priv->enable_gpio, 1);
+
priv->enabled = true;
}
@@ -48,6 +53,9 @@ static void led_bl_power_off(struct led_bl_data *priv)
for (i = 0; i < priv->nb_leds; i++)
led_set_brightness(priv->leds[i], LED_OFF);
+ if (priv->enabled)
+ gpiod_set_value_cansleep(priv->enable_gpio, 0);
+
priv->enabled = false;
}
@@ -209,6 +217,11 @@ static int led_bl_probe(struct platform_device *pdev)
return PTR_ERR(priv->bl_dev);
}
+ priv->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable",
+ GPIOD_OUT_LOW);
+ if (IS_ERR(priv->enable_gpio))
+ return PTR_ERR(priv->enable_gpio);
+
for (i = 0; i < priv->nb_leds; i++)
led_sysfs_disable(priv->leds[i]);
--
2.25.1
next reply other threads:[~2021-11-02 10:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-02 10:04 Corentin LABBE [this message]
2021-11-02 11:19 ` [PATCH] backlight: led_bl: Add support for an "enable" GPIO Daniel Thompson
2021-11-02 11:25 ` Daniel Thompson
2021-11-02 21:42 ` LABBE Corentin
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=20211102100455.2016610-1-clabbe@baylibre.com \
--to=clabbe@baylibre.com \
--cc=daniel.thompson@linaro.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jingoohan1@gmail.com \
--cc=jjhiblot@ti.com \
--cc=khilman@baylibre.com \
--cc=lee.jones@linaro.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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).