diff mbox series

sunxi: video: Support driver model LCDs

Message ID 20240614-sunxi_lcd-v1-1-1dc9257b0112@jookia.org
State Under Review
Delegated to: Anatolij Gustschin
Headers show
Series sunxi: video: Support driver model LCDs | expand

Commit Message

John Watts June 14, 2024, 12:24 p.m. UTC
Currently the LCD code only supports reading panel timings from the
device tree. Change that so it can use a real panel.

Signed-off-by: John Watts <contact@jookia.org>
---
I've been working on a panel driver port from Linux for the T113 and
found I need this code to have the panel boot correctly.
---
 drivers/video/sunxi/sunxi_lcd.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)


---
base-commit: c0ea27bccfb7d2d37fd36806ac2a2f7389099420
change-id: 20240601-sunxi_lcd-d39a4fb81c94

Best regards,
diff mbox series

Patch

diff --git a/drivers/video/sunxi/sunxi_lcd.c b/drivers/video/sunxi/sunxi_lcd.c
index 7a01cc343c..605ea90de1 100644
--- a/drivers/video/sunxi/sunxi_lcd.c
+++ b/drivers/video/sunxi/sunxi_lcd.c
@@ -8,6 +8,7 @@ 
 #include <common.h>
 #include <display.h>
 #include <log.h>
+#include <panel.h>
 #include <video_bridge.h>
 #include <backlight.h>
 #include <dm.h>
@@ -45,6 +46,7 @@  static int sunxi_lcd_enable(struct udevice *dev, int bpp,
 	       (struct sunxi_lcdc_reg *)SUNXI_LCD0_BASE;
 	struct sunxi_lcd_priv *priv = dev_get_priv(dev);
 	struct udevice *backlight;
+	struct udevice *panel;
 	int clk_div, clk_double, ret;
 
 	/* Reset off */
@@ -60,6 +62,12 @@  static int sunxi_lcd_enable(struct udevice *dev, int bpp,
 			    priv->panel_bpp, CONFIG_VIDEO_LCD_DCLK_PHASE);
 	lcdc_enable(lcdc, priv->panel_bpp);
 
+	ret = uclass_get_device(UCLASS_PANEL, 0, &panel);
+	if (ret == 0) {
+		if (panel_enable_backlight(panel) == 0)
+			return 0;
+	}
+
 	ret = uclass_get_device(UCLASS_PANEL_BACKLIGHT, 0, &backlight);
 	if (!ret)
 		backlight_enable(backlight);
@@ -116,6 +124,11 @@  static int sunxi_lcd_probe(struct udevice *dev)
 		return ret;
 	}
 
+	if (panel_get_display_timing(cdev, &priv->timing) == 0) {
+		priv->panel_bpp = 32;
+		return 0;
+	}
+
 	if (fdtdec_decode_display_timing(gd->fdt_blob, dev_of_offset(cdev),
 					 0, &priv->timing)) {
 		debug("%s: Failed to decode display timing\n", __func__);