[PATCH v2 4/6] video: panel: add Renesas R69328 MIPI DSI panel driver

Svyatoslav Ryhel clamor95 at gmail.com
Thu Apr 20 18:17:22 CEST 2023


Driver adds support for panels with Renesas R69328 IC

Currently supported compatible is:
- jdi,dx12d100vm0eaa

Tested-by: Andreas Westman Dorcsak <hedmoo at yahoo.com> # LG P880 T30
Tested-by: Svyatoslav Ryhel <clamor95 at gmail.com> # LG P895 T30
Signed-off-by: Svyatoslav Ryhel <clamor95 at gmail.com>
Reviewed-by: Simon Glass <sjg at chromium.org>
---
 drivers/video/Kconfig          |   9 ++
 drivers/video/Makefile         |   1 +
 drivers/video/renesas-r69328.c | 232 +++++++++++++++++++++++++++++++++
 3 files changed, 242 insertions(+)
 create mode 100644 drivers/video/renesas-r69328.c

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 44f21be166..f5e3c713e5 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -489,6 +489,15 @@ config VIDEO_LCD_RENESAS_R61307
 	  IPS-LCD module with Renesas R69328 IC. The panel has a 1024x768
 	  resolution and uses 24 bit RGB per pixel.
 
+config VIDEO_LCD_RENESAS_R69328
+	tristate "Renesas R69328 720x1280 DSI video mode panel"
+	depends on PANEL && BACKLIGHT
+	select VIDEO_MIPI_DSI
+	help
+	  Say Y here if you want to enable support for JDI dx12d100vm0eaa
+	  IPS-LCD module with Renesas R69328 IC. The panel has a 720x1280
+	  resolution and uses 24 bit RGB per pixel.
+
 config VIDEO_LCD_SSD2828
 	bool "SSD2828 bridge chip"
 	---help---
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 9ab5de8858..cddfc8fd33 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -57,6 +57,7 @@ obj-$(CONFIG_VIDEO_LCD_HITACHI_TX18D42VM) += hitachi_tx18d42vm_lcd.o
 obj-$(CONFIG_VIDEO_LCD_ORISETECH_OTM8009A) += orisetech_otm8009a.o
 obj-$(CONFIG_VIDEO_LCD_RAYDIUM_RM68200) += raydium-rm68200.o
 obj-$(CONFIG_VIDEO_LCD_RENESAS_R61307) += renesas-r61307.o
+obj-$(CONFIG_VIDEO_LCD_RENESAS_R69328) += renesas-r69328.o
 obj-$(CONFIG_VIDEO_LCD_SSD2828) += ssd2828.o
 obj-$(CONFIG_VIDEO_LCD_TDO_TL070WSH30) += tdo-tl070wsh30.o
 obj-$(CONFIG_VIDEO_MCDE_SIMPLE) += mcde_simple.o
diff --git a/drivers/video/renesas-r69328.c b/drivers/video/renesas-r69328.c
new file mode 100644
index 0000000000..e135816d9d
--- /dev/null
+++ b/drivers/video/renesas-r69328.c
@@ -0,0 +1,232 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Renesas R69328 panel driver
+ *
+ * Copyright (c) 2022 Svyatoslav Ryhel <clamor95 at gmail.com>
+ */
+
+#include <common.h>
+#include <backlight.h>
+#include <dm.h>
+#include <panel.h>
+#include <log.h>
+#include <misc.h>
+#include <mipi_display.h>
+#include <mipi_dsi.h>
+#include <asm/gpio.h>
+#include <linux/delay.h>
+#include <linux/err.h>
+#include <power/regulator.h>
+
+#define R69328_MACP		0xB0 /* Manufacturer Command Access Protect */
+
+#define R69328_GAMMA_SET_A	0xC8 /* Gamma Setting A */
+#define R69328_GAMMA_SET_B	0xC9 /* Gamma Setting B */
+#define R69328_GAMMA_SET_C	0xCA /* Gamma Setting C */
+
+#define R69328_POWER_SET	0xD1
+
+struct renesas_r69328_priv {
+	struct udevice *backlight;
+
+	struct gpio_desc enable_gpio;
+	struct gpio_desc reset_gpio;
+};
+
+static const u8 address_mode[] = {
+	MIPI_DCS_SET_ADDRESS_MODE
+};
+
+#define dsi_generic_write_seq(dsi, cmd, seq...) do {			\
+		static const u8 b[] = { cmd, seq };			\
+		int ret;						\
+		ret = mipi_dsi_dcs_write_buffer(dsi, b, ARRAY_SIZE(b));	\
+		if (ret < 0)						\
+			return ret;					\
+	} while (0)
+
+static struct display_timing default_timing = {
+	.pixelclock.typ		= 68000000,
+	.hactive.typ		= 720,
+	.hfront_porch.typ	= 92,
+	.hback_porch.typ	= 62,
+	.hsync_len.typ		= 4,
+	.vactive.typ		= 1280,
+	.vfront_porch.typ	= 6,
+	.vback_porch.typ	= 3,
+	.vsync_len.typ		= 1,
+};
+
+static int renesas_r69328_enable_backlight(struct udevice *dev)
+{
+	struct renesas_r69328_priv *priv = dev_get_priv(dev);
+	int ret;
+
+	ret = dm_gpio_set_value(&priv->enable_gpio, 1);
+	if (ret) {
+		log_err("error changing enable-gpios (%d)\n", ret);
+		return ret;
+	}
+	mdelay(5);
+
+	ret = dm_gpio_set_value(&priv->reset_gpio, 0);
+	if (ret) {
+		log_err("error changing reset-gpios (%d)\n", ret);
+		return ret;
+	}
+	mdelay(5);
+
+	ret = dm_gpio_set_value(&priv->reset_gpio, 1);
+	if (ret) {
+		log_err("error changing reset-gpios (%d)\n", ret);
+		return ret;
+	}
+
+	mdelay(5);
+
+	return 0;
+}
+
+static int renesas_r69328_set_backlight(struct udevice *dev, int percent)
+{
+	struct renesas_r69328_priv *priv = dev_get_priv(dev);
+	struct mipi_dsi_panel_plat *plat = dev_get_plat(dev);
+	struct mipi_dsi_device *dsi = plat->device;
+	int ret;
+
+	mipi_dsi_dcs_write_buffer(dsi, address_mode,
+				  sizeof(address_mode));
+
+	ret = mipi_dsi_dcs_set_pixel_format(dsi, MIPI_DCS_PIXEL_FMT_24BIT << 4);
+	if (ret < 0) {
+		log_err("failed to set pixel format: %d\n", ret);
+		return ret;
+	}
+
+	ret = mipi_dsi_dcs_exit_sleep_mode(dsi);
+	if (ret < 0) {
+		log_err("failed to exit sleep mode: %d\n", ret);
+		return ret;
+	}
+
+	mdelay(100);
+
+	/* MACP Off */
+	dsi_generic_write_seq(dsi, R69328_MACP, 0x04);
+
+	dsi_generic_write_seq(dsi, R69328_POWER_SET, 0x14,
+			      0x1d, 0x21, 0x67, 0x11, 0x9a);
+
+	dsi_generic_write_seq(dsi, R69328_GAMMA_SET_A, 0x00,
+			      0x1a, 0x20, 0x28, 0x25, 0x24,
+			      0x26, 0x15, 0x13, 0x11, 0x18,
+			      0x1e, 0x1c, 0x00, 0x00, 0x1a,
+			      0x20, 0x28, 0x25, 0x24, 0x26,
+			      0x15, 0x13, 0x11, 0x18, 0x1e,
+			      0x1c, 0x00);
+	dsi_generic_write_seq(dsi, R69328_GAMMA_SET_B, 0x00,
+			      0x1a, 0x20, 0x28, 0x25, 0x24,
+			      0x26, 0x15, 0x13, 0x11, 0x18,
+			      0x1e, 0x1c, 0x00, 0x00, 0x1a,
+			      0x20, 0x28, 0x25, 0x24, 0x26,
+			      0x15, 0x13, 0x11, 0x18, 0x1e,
+			      0x1c, 0x00);
+	dsi_generic_write_seq(dsi, R69328_GAMMA_SET_C, 0x00,
+			      0x1a, 0x20, 0x28, 0x25, 0x24,
+			      0x26, 0x15, 0x13, 0x11, 0x18,
+			      0x1e, 0x1c, 0x00, 0x00, 0x1a,
+			      0x20, 0x28, 0x25, 0x24, 0x26,
+			      0x15, 0x13, 0x11, 0x18, 0x1e,
+			      0x1c, 0x00);
+
+	/* MACP On */
+	dsi_generic_write_seq(dsi, R69328_MACP, 0x03);
+
+	ret = mipi_dsi_dcs_set_display_on(dsi);
+	if (ret < 0) {
+		log_err("failed to set display on: %d\n", ret);
+		return ret;
+	}
+
+	mdelay(50);
+
+	ret = backlight_enable(priv->backlight);
+	if (ret)
+		return ret;
+
+	ret = backlight_set_brightness(priv->backlight, percent);
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+static int renesas_r69328_timings(struct udevice *dev,
+				  struct display_timing *timing)
+{
+	memcpy(timing, &default_timing, sizeof(*timing));
+	return 0;
+}
+
+static int renesas_r69328_of_to_plat(struct udevice *dev)
+{
+	struct renesas_r69328_priv *priv = dev_get_priv(dev);
+	int ret;
+
+	ret = uclass_get_device_by_phandle(UCLASS_PANEL_BACKLIGHT, dev,
+					   "backlight", &priv->backlight);
+	if (ret) {
+		log_err("cannot get backlight: ret = %d\n", ret);
+		return ret;
+	}
+
+	ret = gpio_request_by_name(dev, "enable-gpios", 0,
+				   &priv->enable_gpio, GPIOD_IS_OUT);
+	if (ret) {
+		log_err("could not decode enable-gpios (%d)\n", ret);
+		return ret;
+	}
+
+	ret = gpio_request_by_name(dev, "reset-gpios", 0,
+				   &priv->reset_gpio, GPIOD_IS_OUT);
+	if (ret) {
+		log_err("could not decode reser-gpios (%d)\n", ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+static int renesas_r69328_probe(struct udevice *dev)
+{
+	struct mipi_dsi_panel_plat *plat = dev_get_plat(dev);
+
+	/* fill characteristics of DSI data link */
+	plat->lanes = 4;
+	plat->format = MIPI_DSI_FMT_RGB888;
+	plat->mode_flags = MIPI_DSI_MODE_VIDEO;
+
+	return 0;
+}
+
+static const struct panel_ops renesas_r69328_ops = {
+	.enable_backlight	= renesas_r69328_enable_backlight,
+	.set_backlight		= renesas_r69328_set_backlight,
+	.get_display_timing	= renesas_r69328_timings,
+};
+
+static const struct udevice_id renesas_r69328_ids[] = {
+	{ .compatible = "jdi,dx12d100vm0eaa" },
+	{ }
+};
+
+U_BOOT_DRIVER(renesas_r69328) = {
+	.name		= "renesas_r69328",
+	.id		= UCLASS_PANEL,
+	.of_match	= renesas_r69328_ids,
+	.ops		= &renesas_r69328_ops,
+	.of_to_plat	= renesas_r69328_of_to_plat,
+	.probe		= renesas_r69328_probe,
+	.plat_auto	= sizeof(struct mipi_dsi_panel_plat),
+	.priv_auto	= sizeof(struct renesas_r69328_priv),
+};
-- 
2.37.2



More information about the U-Boot mailing list