[PATCH v1 6/6] video: panel: add generic endeavoru panel

Svyatoslav Ryhel clamor95 at gmail.com
Wed Apr 19 21:16:30 CEST 2023


Family of panels used by HTC in One X. Though were used variants
at least from 3 vendors, this driver provides generic support for
all of them.

Tested-by: Ion Agorria <ion at agorria.com> # HTC One X T30 Sony
Tested-by: Svyatoslav Ryhel <clamor95 at gmail.com> # HTC One X T30 Sharp
Signed-off-by: Svyatoslav Ryhel <clamor95 at gmail.com>
---
 drivers/video/Kconfig           |  11 ++
 drivers/video/Makefile          |   1 +
 drivers/video/endeavoru-panel.c | 252 ++++++++++++++++++++++++++++++++
 3 files changed, 264 insertions(+)
 create mode 100644 drivers/video/endeavoru-panel.c

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 2218eab3dd..44c36ba7e6 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -466,6 +466,17 @@ config VIDEO_BCM2835
 	  that same resolution (or as near as possible) and 32bpp depth, so
 	  that U-Boot can access it with full colour depth.
 
+config VIDEO_LCD_ENDEAVORU
+	tristate "Endeavoru 720x1280 DSI video mode panel"
+	depends on PANEL && BACKLIGHT
+	select VIDEO_MIPI_DSI
+	help
+	  Say Y here if you want to enable support for the IPS-LCD panel
+	  module for HTC One X. Driver supports a family of panels,
+	  made at least by 3 vendors (Sharp, Sony and AUO), but set up
+	  using the same DSI command sequence. The panel has a 720x1280
+	  resolution and uses 24 bit RGB per pixel.
+
 config VIDEO_LCD_ORISETECH_OTM8009A
 	bool "OTM8009A DSI LCD panel support"
 	select VIDEO_MIPI_DSI
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index cddfc8fd33..4aff7771a8 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -53,6 +53,7 @@ obj-$(CONFIG_VIDEO_EFI) += efi.o
 obj-$(CONFIG_VIDEO_IPUV3) += imx/
 obj-$(CONFIG_VIDEO_IVYBRIDGE_IGD) += ivybridge_igd.o
 obj-$(CONFIG_VIDEO_LCD_ANX9804) += anx9804.o
+obj-$(CONFIG_VIDEO_LCD_ENDEAVORU) += endeavoru-panel.o
 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
diff --git a/drivers/video/endeavoru-panel.c b/drivers/video/endeavoru-panel.c
new file mode 100644
index 0000000000..1c665222b8
--- /dev/null
+++ b/drivers/video/endeavoru-panel.c
@@ -0,0 +1,252 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * 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>
+
+struct endeavoru_panel_priv {
+	struct udevice *vdd;
+	struct udevice *vddio;
+
+	struct udevice *backlight;
+
+	struct gpio_desc reset_gpio;
+};
+
+static struct display_timing default_timing = {
+	.pixelclock.typ		= 63200000,
+	.hactive.typ		= 720,
+	.hfront_porch.typ	= 55,
+	.hback_porch.typ	= 29,
+	.hsync_len.typ		= 16,
+	.vactive.typ		= 1280,
+	.vfront_porch.typ	= 2,
+	.vback_porch.typ	= 1,
+	.vsync_len.typ		= 1,
+};
+
+static void dcs_write_one(struct mipi_dsi_device *dsi, u8 cmd, u8 data)
+{
+	mipi_dsi_dcs_write(dsi, cmd, &data, 1);
+}
+
+/*
+ * This panel is not able to auto-increment all cmd addresses so for some of
+ * them, we need to send them one by one...
+ */
+#define dcs_write_seq(dsi, cmd, seq...)			\
+({							\
+	static const u8 d[] = { seq };			\
+	unsigned int i;					\
+							\
+	for (i = 0; i < ARRAY_SIZE(d) ; i++)		\
+		dcs_write_one(dsi, cmd + i, d[i]);	\
+})
+
+static int endeavoru_panel_enable_backlight(struct udevice *dev)
+{
+	struct endeavoru_panel_priv *priv = dev_get_priv(dev);
+	int ret;
+
+	ret = dm_gpio_set_value(&priv->reset_gpio, 1);
+	if (ret) {
+		printf("%s: error changing reset-gpios (%d)\n", __func__, ret);
+		return ret;
+	}
+	mdelay(5);
+
+	ret = regulator_set_enable_if_allowed(priv->vddio, 1);
+	if (ret) {
+		printf("%s: error enabling iovcc-supply (%d)\n", __func__, ret);
+		return ret;
+	}
+	mdelay(1);
+
+	ret = regulator_set_enable_if_allowed(priv->vdd, 1);
+	if (ret) {
+		printf("%s: error enabling vcc-supply (%d)\n", __func__, ret);
+		return ret;
+	}
+	mdelay(20);
+
+	ret = dm_gpio_set_value(&priv->reset_gpio, 0);
+	if (ret) {
+		printf("%s: error changing reset-gpios (%d)\n", __func__, ret);
+		return ret;
+	}
+	mdelay(2);
+
+	/* Reset panel */
+	ret = dm_gpio_set_value(&priv->reset_gpio, 1);
+	if (ret) {
+		printf("%s: error changing reset-gpios (%d)\n", __func__, ret);
+		return ret;
+	}
+	mdelay(1);
+
+	ret = dm_gpio_set_value(&priv->reset_gpio, 0);
+	if (ret) {
+		printf("%s: error changing reset-gpios (%d)\n", __func__, ret);
+		return ret;
+	}
+	mdelay(25);
+
+	return 0;
+}
+
+static int endeavoru_panel_set_backlight(struct udevice *dev, int percent)
+{
+	struct endeavoru_panel_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;
+
+	dcs_write_one(dsi, 0xC2, 0x08);
+
+	/* color enhancement 2.2 */
+	dcs_write_one(dsi, 0xFF, 0x03);
+	dcs_write_one(dsi, 0xFE, 0x08);
+	dcs_write_one(dsi, 0x18, 0x00);
+	dcs_write_one(dsi, 0x19, 0x00);
+	dcs_write_one(dsi, 0x1A, 0x00);
+	dcs_write_one(dsi, 0x25, 0x26);
+
+	dcs_write_seq(dsi, 0x00, 0x00, 0x05, 0x10, 0x17,
+		     0x22, 0x26, 0x29, 0x29, 0x26, 0x23,
+		     0x17, 0x12, 0x06, 0x02, 0x01, 0x00);
+
+	dcs_write_one(dsi, 0xFB, 0x01);
+	dcs_write_one(dsi, 0xFF, 0x00);
+	dcs_write_one(dsi, 0xFE, 0x01);
+
+	mipi_dsi_dcs_exit_sleep_mode(dsi);
+
+	mdelay(105);
+
+	dcs_write_one(dsi, 0x35, 0x00);
+
+	/* PWM frequency adjust */
+	dcs_write_one(dsi, 0xFF, 0x04);
+	dcs_write_one(dsi, 0x0A, 0x07);
+	dcs_write_one(dsi, 0x09, 0x20);
+	dcs_write_one(dsi, 0xFF, 0x00);
+
+	dcs_write_one(dsi, 0xFF, 0xEE);
+	dcs_write_one(dsi, 0x12, 0x50);
+	dcs_write_one(dsi, 0x13, 0x02);
+	dcs_write_one(dsi, 0x6A, 0x60);
+	dcs_write_one(dsi, 0xFB, 0x01);
+	dcs_write_one(dsi, 0xFF, 0x00);
+
+	mipi_dsi_dcs_set_display_on(dsi);
+
+	mdelay(42);
+
+	dcs_write_one(dsi, 0xBA, 0x01);
+
+	dcs_write_one(dsi, 0x53, 0x24);
+	dcs_write_one(dsi, 0x55, 0x80);
+	dcs_write_one(dsi, 0x5E, 0x06);
+
+	ret = backlight_enable(priv->backlight);
+	if (ret)
+		return ret;
+
+	/* Set backlight */
+	dcs_write_one(dsi, 0x51, 0x96);
+
+	ret = backlight_set_brightness(priv->backlight, percent);
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+static int endeavoru_panel_timings(struct udevice *dev,
+				   struct display_timing *timing)
+{
+	memcpy(timing, &default_timing, sizeof(*timing));
+	return 0;
+}
+
+static int endeavoru_panel_of_to_plat(struct udevice *dev)
+{
+	struct endeavoru_panel_priv *priv = dev_get_priv(dev);
+	int ret;
+
+	ret = uclass_get_device_by_phandle(UCLASS_PANEL_BACKLIGHT, dev,
+					   "backlight", &priv->backlight);
+	if (ret) {
+		printf("%s: Cannot get backlight: ret = %d\n", __func__, ret);
+		return ret;
+	}
+
+	ret = uclass_get_device_by_phandle(UCLASS_REGULATOR, dev,
+					   "vdd-supply", &priv->vdd);
+	if (ret) {
+		printf("%s: Cannot get vdd-supply: ret = %d\n", __func__, ret);
+		return ret;
+	}
+
+	ret = uclass_get_device_by_phandle(UCLASS_REGULATOR, dev,
+					   "vddio-supply", &priv->vddio);
+	if (ret) {
+		printf("%s: Cannot get vddio-supply: ret = %d\n", __func__, ret);
+		return ret;
+	}
+
+	ret = gpio_request_by_name(dev, "reset-gpios", 0,
+				   &priv->reset_gpio, GPIOD_IS_OUT);
+	if (ret) {
+		printf("%s: Could not decode reser-gpios (%d)\n", __func__, ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+static int endeavoru_panel_probe(struct udevice *dev)
+{
+	struct mipi_dsi_panel_plat *plat = dev_get_plat(dev);
+
+	/* fill characteristics of DSI data link */
+	plat->lanes = 2;
+	plat->format = MIPI_DSI_FMT_RGB888;
+	plat->mode_flags = MIPI_DSI_MODE_VIDEO;
+
+	return 0;
+}
+
+static const struct panel_ops endeavoru_panel_ops = {
+	.enable_backlight	= endeavoru_panel_enable_backlight,
+	.set_backlight		= endeavoru_panel_set_backlight,
+	.get_display_timing	= endeavoru_panel_timings,
+};
+
+static const struct udevice_id endeavoru_panel_ids[] = {
+	{ .compatible = "htc,edge-panel" },
+	{ }
+};
+
+U_BOOT_DRIVER(endeavoru_panel) = {
+	.name		= "endeavoru_panel",
+	.id		= UCLASS_PANEL,
+	.of_match	= endeavoru_panel_ids,
+	.ops		= &endeavoru_panel_ops,
+	.of_to_plat	= endeavoru_panel_of_to_plat,
+	.probe		= endeavoru_panel_probe,
+	.plat_auto	= sizeof(struct mipi_dsi_panel_plat),
+	.priv_auto	= sizeof(struct endeavoru_panel_priv),
+};
-- 
2.37.2



More information about the U-Boot mailing list