From: Johannes Schneider <johannes.schneider@leica-geosystems.com>
To: barebox@lists.infradead.org
Cc: thomas.haemmerle@leica-geosystems.com
Subject: [PATCH 3/6] video: backlight-pwm: make power-supply and enable-gpio optional
Date: Tue, 2 Jun 2026 04:09:49 +0000 [thread overview]
Message-ID: <20260602040953.1060278-4-johannes.schneider@leica-geosystems.com> (raw)
In-Reply-To: <20260602040953.1060278-1-johannes.schneider@leica-geosystems.com>
From: Thomas Haemmerle <thomas.haemmerle@leica-geosystems.com>
PWM backlight DT nodes for board displays often omit the power-supply regulator
(the rail is always-on) or use enable-gpios without a supply. The driver
previously treated both as mandatory and returned -ENODEV if either was absent,
blocking display initialisation on devices which use an always-on 3.3V supply
and no separate backlight enable regulator.
Guard the regulator enable/disable calls with a NULL check, handle
-ENODEV from regulator_get() as "no supply present", and use GPIOD_ASIS
for enable GPIO so the initial pin state is not disturbed.
Also improve the "Cannot find PWM device" error message to print the
actual error pointer so probe failures are diagnosable.
Assisted-by: Claude:claude-sonnet-4-6
Signed-of-by: Thomas Haemmerle <thomas.haemmerle@leica-geosystems.com>
---
drivers/video/backlight-pwm.c | 16 ++++++++++------
drivers/video/backlight.c | 3 ++-
drivers/video/fsl-ldb.c | 2 +-
3 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/drivers/video/backlight-pwm.c b/drivers/video/backlight-pwm.c
index d3c81114e0..9c8fcfbe93 100644
--- a/drivers/video/backlight-pwm.c
+++ b/drivers/video/backlight-pwm.c
@@ -37,7 +37,8 @@ static int backlight_pwm_enable(struct pwm_backlight *pwm_backlight)
if (ret)
return ret;
- regulator_enable(pwm_backlight->power);
+ if (pwm_backlight->power)
+ regulator_enable(pwm_backlight->power);
gpiod_direction_output(pwm_backlight->enable_gpio, true);
@@ -55,7 +56,8 @@ static int backlight_pwm_disable(struct pwm_backlight *pwm_backlight)
ret = gpiod_direction_output(pwm_backlight->enable_gpio, false);
if (!ret) {
- regulator_disable(pwm_backlight->power);
+ if (pwm_backlight->power)
+ regulator_disable(pwm_backlight->power);
/*
* Only disable PWM when an enable gpio is present.
@@ -148,7 +150,7 @@ static int pwm_backlight_parse_dt(struct device *dev,
pwm_backlight->backlight.brightness_max = pwm_backlight->scale;
}
- pwm_backlight->enable_gpio = gpiod_get_optional(dev, "enable-gpios", 0);
+ pwm_backlight->enable_gpio = gpiod_get_optional(dev, "enable", GPIOD_ASIS);
return 0;
}
@@ -161,7 +163,7 @@ static int backlight_pwm_of_probe(struct device *dev)
pwm = of_pwm_request(dev->of_node, NULL);
if (IS_ERR(pwm)) {
- dev_err(dev, "Cannot find PWM device\n");
+ dev_err(dev, "Cannot find PWM device: %pe\n", pwm);
return PTR_ERR(pwm);
}
@@ -175,8 +177,10 @@ static int backlight_pwm_of_probe(struct device *dev)
pwm_backlight->power = regulator_get(dev, "power");
if (IS_ERR(pwm_backlight->power)) {
- dev_err(dev, "Cannot find regulator\n");
- return PTR_ERR(pwm_backlight->power);
+ if (PTR_ERR(pwm_backlight->power) != -ENODEV)
+ return dev_errp_probe(dev, pwm_backlight->power,
+ "power supply\n");
+ pwm_backlight->power = NULL;
}
pwm_backlight->backlight.slew_time_ms = 100;
diff --git a/drivers/video/backlight.c b/drivers/video/backlight.c
index 6d8146ee5a..bf7d40b59a 100644
--- a/drivers/video/backlight.c
+++ b/drivers/video/backlight.c
@@ -94,8 +94,9 @@ int backlight_register(struct backlight_device *bl)
struct backlight_device *of_backlight_find(struct device_node *node)
{
struct backlight_device *bl;
+ int ret;
- of_device_ensure_probed(node);
+ ret = of_device_ensure_probed(node);
class_for_each_container_of_device(&backlight_class, bl, dev)
if (bl->node == node)
diff --git a/drivers/video/fsl-ldb.c b/drivers/video/fsl-ldb.c
index 0ab720032c..09804ac329 100644
--- a/drivers/video/fsl-ldb.c
+++ b/drivers/video/fsl-ldb.c
@@ -287,7 +287,7 @@ static int fsl_ldb_probe(struct device *dev)
/* Only DRM_LVDS_DUAL_LINK_ODD_EVEN_PIXELS is supported */
- dev_info(dev, "LVDS channel pixel swap not supported.\n");
+ dev_dbg(dev, "LVDS channel pixel swap not supported.\n");
fsl_ldb->vpl.node = dev->of_node;
fsl_ldb->vpl.ioctl = &fsl_ldb_ioctl;
--
2.43.0
next prev parent reply other threads:[~2026-06-02 4:11 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-02 4:09 [PATCH 0/7] video: enable boot splash on i.MX8MP with LVDS panel Johannes Schneider
2026-06-02 4:09 ` [PATCH 1/6] clk: imx8mp: add 700 MHz rate entry for VIDEO_PLL1 Johannes Schneider
2026-06-02 7:04 ` Ahmad Fatoum
2026-06-02 4:09 ` [PATCH 2/6] pmdomain: imx8mp-blk-ctrl: add media blk-ctrl power domain support Johannes Schneider
2026-06-02 7:34 ` Ahmad Fatoum
2026-06-02 4:09 ` Johannes Schneider [this message]
2026-06-02 7:22 ` [PATCH 3/6] video: backlight-pwm: make power-supply and enable-gpio optional Ahmad Fatoum
2026-06-02 4:09 ` [PATCH 4/6] video: add i.MX8MP LCDIF2 V8 framebuffer driver Johannes Schneider
2026-06-02 7:16 ` Ahmad Fatoum
2026-06-04 3:34 ` SCHNEIDER Johannes
2026-06-02 4:09 ` [PATCH 5/6] video: add generic panel-lvds driver Johannes Schneider
2026-06-02 7:12 ` Ahmad Fatoum
2026-06-02 4:09 ` [PATCH 6/6] video: imx-lcdif: drain write-combine buffer before LCDIF DMA reads pixels Johannes Schneider
2026-06-02 8:12 ` Lucas Stach
2026-06-02 9:37 ` Ahmad Fatoum
2026-06-02 12:12 ` Lucas Stach
2026-06-02 15:17 ` Michael Grzeschik
2026-06-02 17:10 ` Michael Grzeschik
2026-06-04 3:42 ` SCHNEIDER Johannes
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=20260602040953.1060278-4-johannes.schneider@leica-geosystems.com \
--to=johannes.schneider@leica-geosystems.com \
--cc=barebox@lists.infradead.org \
--cc=thomas.haemmerle@leica-geosystems.com \
/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