[PATCH 3/6] video: backlight-pwm: make power-supply and enable-gpio optional
Johannes Schneider
johannes.schneider at leica-geosystems.com
Mon Jun 1 21:09:49 PDT 2026
From: Thomas Haemmerle <thomas.haemmerle at 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 at 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
More information about the barebox
mailing list