All of lore.kernel.org
 help / color / mirror / Atom feed
From: Svyatoslav Ryhel <clamor95@gmail.com>
To: "Tom Rini" <trini@konsulko.com>,
	"Anatolij Gustschin" <agust@denx.de>,
	"Simon Glass" <sjg@chromium.org>,
	"Svyatoslav Ryhel" <clamor95@gmail.com>,
	"Anton Bambura" <jenneron@protonmail.com>,
	"Jonas Schwöbel" <jonasschwoebel@yahoo.de>
Cc: u-boot@lists.denx.de
Subject: [PATCH v2 2/7] video: panel: add Samsung LTL106HL02 MIPI DSI panel driver
Date: Wed, 31 Jan 2024 08:57:16 +0200	[thread overview]
Message-ID: <20240131065721.4245-3-clamor95@gmail.com> (raw)
In-Reply-To: <20240131065721.4245-1-clamor95@gmail.com>

From: Anton Bambura <jenneron@protonmail.com>

LTL106HL02 is a color active matrix TFT (Thin Film Transistor)
liquid crystal display (LCD) that uses amorphous silicon TFT as
switching devices. This model is composed of a TFT LCD panel, a
driver circuit and a backlight unit. The resolution of a 10.6"
contains 1920 x 1080 pixels and can display up to 16,8M color
with wide viewing angle.

Co-developed-by: Jonas Schwöbel <jonasschwoebel@yahoo.de>
Signed-off-by: Jonas Schwöbel <jonasschwoebel@yahoo.de>
Co-developed-by: Svyatoslav Ryhel <clamor95@gmail.com>
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
Signed-off-by: Anton Bambura <jenneron@protonmail.com>
---
 drivers/video/Kconfig              |   9 ++
 drivers/video/Makefile             |   1 +
 drivers/video/samsung-ltl106hl02.c | 157 +++++++++++++++++++++++++++++
 3 files changed, 167 insertions(+)
 create mode 100644 drivers/video/samsung-ltl106hl02.c

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 05567a0095..52b515197d 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -555,6 +555,15 @@ config VIDEO_LCD_RENESAS_R69328
 	  IPS-LCD module with Renesas R69328 IC. The panel has a 720x1280
 	  resolution and uses 24 bit RGB per pixel.
 
+config VIDEO_LCD_SAMSUNG_LTL106HL02
+	tristate "Samsung LTL106HL02 1920x1080 DSI video mode panel"
+	depends on PANEL && BACKLIGHT
+	select VIDEO_MIPI_DSI
+	help
+	  Say Y here if you want to enable support for Samsung LTL106HL02
+	  LCD module found in Microsoft Surface 2. The panel has a FullHD
+	  resolution (1920x1080).
+
 config VIDEO_LCD_SSD2828
 	bool "SSD2828 bridge chip"
 	---help---
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index bb6d9b74b9..f3f70cd04a 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -63,6 +63,7 @@ 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_SAMSUNG_LTL106HL02) += samsung-ltl106hl02.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/samsung-ltl106hl02.c b/drivers/video/samsung-ltl106hl02.c
new file mode 100644
index 0000000000..5e6c11c4be
--- /dev/null
+++ b/drivers/video/samsung-ltl106hl02.c
@@ -0,0 +1,157 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Samsung LTL106HL02-001 DSI panel driver
+ *
+ * Copyright (c) 2020 Anton Bambura <jenneron@protonmail.com>
+ * Copyright (c) 2023 Svyatoslav Ryhel <clamor95@gmail.com>
+ * Copyright (c) 2024 Jonas Schwöbel <jonasschwoebel@yahoo.de>
+ */
+
+#include <backlight.h>
+#include <dm.h>
+#include <panel.h>
+#include <log.h>
+#include <mipi_dsi.h>
+#include <asm/gpio.h>
+#include <linux/delay.h>
+#include <power/regulator.h>
+
+struct samsung_ltl106hl02_priv {
+	struct udevice *vdd;
+	struct udevice *backlight;
+
+	struct gpio_desc reset_gpio;
+};
+
+static struct display_timing default_timing = {
+	.pixelclock.typ		= 137000000,
+	.hactive.typ		= 1920,
+	.hfront_porch.typ	= 32,
+	.hback_porch.typ	= 64,
+	.hsync_len.typ		= 32,
+	.vactive.typ		= 1080,
+	.vfront_porch.typ	= 2,
+	.vback_porch.typ	= 26,
+	.vsync_len.typ		= 3,
+};
+
+static int samsung_ltl106hl02_enable_backlight(struct udevice *dev)
+{
+	struct mipi_dsi_panel_plat *plat = dev_get_plat(dev);
+	struct mipi_dsi_device *dsi = plat->device;
+	int ret;
+
+	ret = mipi_dsi_dcs_exit_sleep_mode(dsi);
+	if (ret < 0) {
+		log_debug("%s: failed to exit sleep mode: %d\n",
+			  __func__, ret);
+		return ret;
+	}
+	mdelay(70);
+
+	ret = mipi_dsi_dcs_set_display_on(dsi);
+	if (ret < 0) {
+		log_debug("%s: failed to enable display: %d\n",
+			  __func__, ret);
+		return ret;
+	}
+	mdelay(5);
+
+	return 0;
+}
+
+static int samsung_ltl106hl02_set_backlight(struct udevice *dev, int percent)
+{
+	struct samsung_ltl106hl02_priv *priv = dev_get_priv(dev);
+	int ret;
+
+	ret = backlight_enable(priv->backlight);
+	if (ret)
+		return ret;
+
+	return backlight_set_brightness(priv->backlight, percent);
+}
+
+static int samsung_ltl106hl02_timings(struct udevice *dev,
+				      struct display_timing *timing)
+{
+	memcpy(timing, &default_timing, sizeof(*timing));
+	return 0;
+}
+
+static int samsung_ltl106hl02_of_to_plat(struct udevice *dev)
+{
+	struct samsung_ltl106hl02_priv *priv = dev_get_priv(dev);
+	int ret;
+
+	ret = uclass_get_device_by_phandle(UCLASS_PANEL_BACKLIGHT, dev,
+					   "backlight", &priv->backlight);
+	if (ret) {
+		log_debug("%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)
+		log_debug("%s: cannot get vdd-supply: error %d\n",
+			  __func__, ret);
+
+	ret = gpio_request_by_name(dev, "reset-gpios", 0,
+				   &priv->reset_gpio, GPIOD_IS_OUT);
+	if (ret)
+		log_debug("%s: cannot get reset-gpios: error %d\n",
+			  __func__, ret);
+
+	return 0;
+}
+
+static int samsung_ltl106hl02_hw_init(struct udevice *dev)
+{
+	struct samsung_ltl106hl02_priv *priv = dev_get_priv(dev);
+
+	dm_gpio_set_value(&priv->reset_gpio, 1);
+	regulator_set_enable_if_allowed(priv->vdd, 1);
+
+	/* Dataheets states at least 8.5 msec for vdd stabilization */
+	mdelay(10);
+
+	dm_gpio_set_value(&priv->reset_gpio, 0);
+
+	return 0;
+}
+
+static int samsung_ltl106hl02_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 samsung_ltl106hl02_hw_init(dev);
+}
+
+static const struct panel_ops samsung_ltl106hl02_ops = {
+	.enable_backlight	= samsung_ltl106hl02_enable_backlight,
+	.set_backlight		= samsung_ltl106hl02_set_backlight,
+	.get_display_timing	= samsung_ltl106hl02_timings,
+};
+
+static const struct udevice_id samsung_ltl106hl02_ids[] = {
+	{ .compatible = "samsung,ltl106hl02-001" },
+	{ }
+};
+
+U_BOOT_DRIVER(samsung_ltl106hl02) = {
+	.name		= "samsung_ltl106hl02",
+	.id		= UCLASS_PANEL,
+	.of_match	= samsung_ltl106hl02_ids,
+	.ops		= &samsung_ltl106hl02_ops,
+	.of_to_plat	= samsung_ltl106hl02_of_to_plat,
+	.probe		= samsung_ltl106hl02_probe,
+	.plat_auto	= sizeof(struct mipi_dsi_panel_plat),
+	.priv_auto	= sizeof(struct samsung_ltl106hl02_priv),
+};
-- 
2.40.1


  parent reply	other threads:[~2024-01-31  6:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-31  6:57 [PATCH v2 0/7] Tegra panel improvements Svyatoslav Ryhel
2024-01-31  6:57 ` [PATCH v2 1/7] video: panel: add LG LG070WX3 MIPI DSI panel driver Svyatoslav Ryhel
2024-01-31  6:57 ` Svyatoslav Ryhel [this message]
2024-01-31  6:57 ` [PATCH v2 3/7] video: bridge: add Toshiba TC358768 RGB to DSI bridge support Svyatoslav Ryhel
2024-01-31  6:57 ` [PATCH v2 4/7] video: bridge: add basic support for the Parade DP501 transmitter Svyatoslav Ryhel
2024-01-31  6:57 ` [PATCH v2 5/7] video: endeavoru-panel: shift the init sequence by one step earlier Svyatoslav Ryhel
2024-01-31  6:57 ` [PATCH v2 6/7] video: bridge: ssd2825: " Svyatoslav Ryhel
2024-01-31  6:57 ` [PATCH v2 7/7] video: renesas: " Svyatoslav Ryhel
2024-04-19 11:29 ` [PATCH v2 0/7] Tegra panel improvements Svyatoslav Ryhel
2024-04-19 14:05   ` Tom Rini
2024-04-20 15:14     ` Anatolij Gustschin
2024-04-20 23:03 ` Anatolij Gustschin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240131065721.4245-3-clamor95@gmail.com \
    --to=clamor95@gmail.com \
    --cc=agust@denx.de \
    --cc=jenneron@protonmail.com \
    --cc=jonasschwoebel@yahoo.de \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.