[PATCH v2 10/11] video: simple-panel: support panel-lvds DT bindings

Johannes Schneider <[email protected]>
Newsgroups org.infradead.lists.barebox
Message-ID <20260604065006.2933142-11-johannes.schneider@leica-geosystems.com>
simple-panel already parses display-timings, enable-gpios and a
backlight phandle from DT, which is exactly what a Linux panel-lvds
node provides.  Unlike Linux's drivers/gpu/drm/panel/panel-simple.c
we have no hardcoded panel tables, so there's nothing LVDS-specific
left for a dedicated driver to do.  Bring panel-lvds DTs in:

  - Match "panel-lvds" in the of_device_id table.

  - Read modes from a "panel-timing" subnode as a fallback when
    "display-timings" isn't present.  Linux's panel-lvds binding uses
    the singular form; without this, the panel reports "No modes
    found" and the display chain has nothing to allocate a fb for.

  - Switch the power-supply lookup to regulator_get_optional() and
    treat -ENODEV as "no supply".  Many panel-lvds DTs omit
    "power-supply" because the rail is hard-wired; the call sites
    already pass NULL through safely.

Signed-off-by: Johannes Schneider <[email protected]>
---
 drivers/video/simple-panel.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/drivers/video/simple-panel.c b/drivers/video/simple-panel.c
index 63a032a9b8..66d519425a 100644
--- a/drivers/video/simple-panel.c
+++ b/drivers/video/simple-panel.c
@@ -112,6 +112,19 @@ static int simple_panel_get_modes(struct simple_panel *panel, struct display_tim
 		return 0;
 	}
 
+	/* panel-lvds DTs put the single mode in "panel-timing", not "display-timings" */
+	if (of_get_child_by_name(panel->dev->of_node, "panel-timing")) {
+		struct fb_videomode *mode = xzalloc(sizeof(*mode));
+
+		ret = of_get_display_timing(panel->dev->of_node, "panel-timing", mode);
+		if (!ret) {
+			timings->modes = mode;
+			timings->num_modes = 1;
+			return 0;
+		}
+		free(mode);
+	}
+
 	dev_err(panel->dev, "No modes found\n");
 
 	return -ENOENT;
@@ -162,9 +175,12 @@ static int simple_panel_probe(struct device *dev)
 
 	panel->backlight_node = of_parse_phandle(node, "backlight", 0);
 
-	panel->power = regulator_get(dev, "power");
-	if (IS_ERR(panel->power))
-		return dev_errp_probe(dev, panel->power, "Cannot find regulator\n");
+	panel->power = regulator_get_optional(dev, "power");
+	if (IS_ERR(panel->power)) {
+		if (PTR_ERR(panel->power) != -ENODEV)
+			return dev_errp_probe(dev, panel->power, "power supply\n");
+		panel->power = NULL;
+	}
 
 	ret = vpl_register(&panel->vpl);
 	if (ret)
@@ -175,6 +191,7 @@ static int simple_panel_probe(struct device *dev)
 
 static struct of_device_id simple_panel_of_ids[] = {
 	{ .compatible = "simple-panel", },
+	{ .compatible = "panel-lvds", },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, simple_panel_of_ids);
-- 
2.43.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.