[PATCH 2/9] drivers: video: simple_panel: make simple panel independent of backlight

Nikhil M Jain n-jain1 at ti.com
Fri Jan 13 09:29:20 CET 2023


This patch updates the necessary Kconfigs to make simple panel
driver independent of backlight driver and compiling backlight
related code in simple-panel driver conditionally to when user
has set CONFIG_BACKLIGHT.

Signed-off-by: Nikhil M Jain <n-jain1 at ti.com>
---
 drivers/video/Kconfig        |  3 +--
 drivers/video/simple_panel.c | 20 +++++++++++++-------
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index c841b99bb3..5030586d9f 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -28,7 +28,6 @@ config VIDEO_LOGO
 
 config BACKLIGHT
 	bool "Enable panel backlight uclass support"
-	default y
 	help
 	  This provides backlight uclass driver that enables basic panel
 	  backlight support.
@@ -206,7 +205,7 @@ config PANEL
 
 config SIMPLE_PANEL
 	bool "Enable simple panel support"
-	depends on PANEL && BACKLIGHT && DM_GPIO
+	depends on PANEL && DM_GPIO
 	default y
 	help
 	  This turns on a simple panel driver that enables a compatible
diff --git a/drivers/video/simple_panel.c b/drivers/video/simple_panel.c
index c8f7022ea6..905087bcbd 100644
--- a/drivers/video/simple_panel.c
+++ b/drivers/video/simple_panel.c
@@ -18,6 +18,7 @@ struct simple_panel_priv {
 	struct gpio_desc enable;
 };
 
+#ifdef CONFIG_BACKLIGHT
 static int simple_panel_enable_backlight(struct udevice *dev)
 {
 	struct simple_panel_priv *priv = dev_get_priv(dev);
@@ -47,6 +48,7 @@ static int simple_panel_set_backlight(struct udevice *dev, int percent)
 
 	return 0;
 }
+#endif
 
 static int simple_panel_of_to_plat(struct udevice *dev)
 {
@@ -63,11 +65,13 @@ static int simple_panel_of_to_plat(struct udevice *dev)
 				return ret;
 		}
 	}
-	ret = uclass_get_device_by_phandle(UCLASS_PANEL_BACKLIGHT, dev,
-					   "backlight", &priv->backlight);
-	if (ret) {
-		debug("%s: Cannot get backlight: ret=%d\n", __func__, ret);
-		return log_ret(ret);
+	if (IS_ENABLED(CONFIG_BACKLIGHT)) {
+		ret = uclass_get_device_by_phandle(UCLASS_PANEL_BACKLIGHT, dev,
+						   "backlight", &priv->backlight);
+		if (ret) {
+			debug("%s: Cannot get backlight: ret=%d\n", __func__, ret);
+			return log_ret(ret);
+		}
 	}
 	ret = gpio_request_by_name(dev, "enable-gpios", 0, &priv->enable,
 				   GPIOD_IS_OUT);
@@ -97,8 +101,10 @@ static int simple_panel_probe(struct udevice *dev)
 }
 
 static const struct panel_ops simple_panel_ops = {
-	.enable_backlight	= simple_panel_enable_backlight,
-	.set_backlight		= simple_panel_set_backlight,
+#ifdef CONFIG_BACKLIGHT
+		.enable_backlight	= simple_panel_enable_backlight,
+		.set_backlight		= simple_panel_set_backlight,
+#endif
 };
 
 static const struct udevice_id simple_panel_ids[] = {
-- 
2.17.1



More information about the U-Boot mailing list