Re: [PATCH v1 3/6] video: panel: add Renesas R61307 MIPI DSI panel driver

2023-04-19 Thread Simon Glass
On Wed, 19 Apr 2023 at 13:17, Svyatoslav Ryhel  wrote:
>
> R61307 is liquid crystal driver for high-definition
> amorphous silicon (a-Si) panels and is ideal for
> tablets and smartphones.
>
> Supported compatibles are:
> - koe,tx13d100vm0eaa
> - hitachi,tx13d100vm0eaa
>
> Tested-by: Andreas Westman Dorcsak  # LG P880 T30
> Tested-by: Svyatoslav Ryhel  # LG P895 T30
> Signed-off-by: Svyatoslav Ryhel 
> ---
>  drivers/video/Kconfig  |   9 +
>  drivers/video/Makefile |   1 +
>  drivers/video/renesas-r61307.c | 296 +
>  3 files changed, 306 insertions(+)
>  create mode 100644 drivers/video/renesas-r61307.c
>

Reviewed-by: Simon Glass 

Best to use lower-case hex consistently.


[PATCH v1 3/6] video: panel: add Renesas R61307 MIPI DSI panel driver

2023-04-19 Thread Svyatoslav Ryhel
R61307 is liquid crystal driver for high-definition
amorphous silicon (a-Si) panels and is ideal for
tablets and smartphones.

Supported compatibles are:
- koe,tx13d100vm0eaa
- hitachi,tx13d100vm0eaa

Tested-by: Andreas Westman Dorcsak  # LG P880 T30
Tested-by: Svyatoslav Ryhel  # LG P895 T30
Signed-off-by: Svyatoslav Ryhel 
---
 drivers/video/Kconfig  |   9 +
 drivers/video/Makefile |   1 +
 drivers/video/renesas-r61307.c | 296 +
 3 files changed, 306 insertions(+)
 create mode 100644 drivers/video/renesas-r61307.c

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 1695d17c8d..bfd8c4f126 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -480,6 +480,15 @@ config VIDEO_LCD_RAYDIUM_RM68200
Say Y here if you want to enable support for Raydium RM68200
720x1280 DSI video mode panel.
 
+config VIDEO_LCD_RENESAS_R61307
+   tristate "Renesas R61307 DSI video mode panel"
+   depends on PANEL && BACKLIGHT
+   select VIDEO_MIPI_DSI
+   help
+ Say Y here if you want to enable support for KOE tx13d100vm0eaa
+ IPS-LCD module with Renesas R69328 IC. The panel has a 1024x768
+ 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 05fb063105..9ab5de8858 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -56,6 +56,7 @@ obj-$(CONFIG_VIDEO_LCD_ANX9804) += anx9804.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
+obj-$(CONFIG_VIDEO_LCD_RENESAS_R61307) += renesas-r61307.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-r61307.c b/drivers/video/renesas-r61307.c
new file mode 100644
index 00..6af95f1107
--- /dev/null
+++ b/drivers/video/renesas-r61307.c
@@ -0,0 +1,296 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Renesas R61307 panel driver
+ *
+ * Copyright (c) 2022 Svyatoslav Ryhel 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define R61307_MACP0xB0 /* Manufacturer CMD Protect */
+
+#define R61307_INVERSION   0xC1
+#define R61307_GAMMA_SET_A 0xC8 /* Gamma Setting A */
+#define R61307_GAMMA_SET_B 0xC9 /* Gamma Setting B */
+#define R61307_GAMMA_SET_C 0xCA /* Gamma Setting C */
+#define R61307_CONTRAST_SET0xCC
+
+struct renesas_r61307_priv {
+   struct udevice *vcc;
+   struct udevice *iovcc;
+
+   struct udevice *backlight;
+
+   struct gpio_desc reset_gpio;
+
+   bool dig_cont_adj;
+   bool inversion;
+   u32 gamma;
+};
+
+static const u8 macp_on[] = {
+   R61307_MACP, 0x03
+};
+
+static const u8 macp_off[] = {
+   R61307_MACP, 0x04
+};
+
+static const u8 address_mode[] = {
+   MIPI_DCS_SET_ADDRESS_MODE
+};
+
+static const u8 contrast_setting[] = {
+   R61307_CONTRAST_SET,
+   0xDC, 0xB4, 0xFF
+};
+
+static const u8 column_inversion[] = {
+   R61307_INVERSION,
+   0x00, 0x50, 0x03, 0x22,
+   0x16, 0x06, 0x60, 0x11
+};
+
+static const u8 line_inversion[] = {
+   R61307_INVERSION,
+   0x00, 0x10, 0x03, 0x22,
+   0x16, 0x06, 0x60, 0x01
+};
+
+static const u8 gamma_setting[][25] = {
+   {},
+   {
+   R61307_GAMMA_SET_A,
+   0x00, 0x06, 0x0A, 0x0F,
+   0x14, 0x1F, 0x1F, 0x17,
+   0x12, 0x0C, 0x09, 0x06,
+   0x00, 0x06, 0x0A, 0x0F,
+   0x14, 0x1F, 0x1F, 0x17,
+   0x12, 0x0C, 0x09, 0x06
+   },
+   {
+   R61307_GAMMA_SET_A,
+   0x00, 0x05, 0x0B, 0x0F,
+   0x11, 0x1D, 0x20, 0x18,
+   0x18, 0x09, 0x07, 0x06,
+   0x00, 0x05, 0x0B, 0x0F,
+   0x11, 0x1D, 0x20, 0x18,
+   0x18, 0x09, 0x07, 0x06
+   },
+   {
+   R61307_GAMMA_SET_A,
+   0x0B, 0x0D, 0x10, 0x14,
+   0x13, 0x1D, 0x20, 0x18,
+   0x12, 0x09, 0x07, 0x06,
+   0x0A, 0x0C, 0x10, 0x14,
+   0x13, 0x1D, 0x20, 0x18,
+   0x12, 0x09, 0x07, 0x06
+   },
+};
+
+static struct display_timing default_timing = {
+   .pixelclock.typ = 6200,
+   .hactive.typ= 768,
+   .hfront_porch.typ   = 116,
+   .hback_porch.typ= 81,
+   .hsync_len.typ  = 5,
+   .vactive.typ= 1024,
+   .vfront_porch.typ   = 24,
+   .vback_porch.typ= 8,
+   .vsync_len.typ  = 2,
+};
+
+static int renesas_r61307_enable_backlight(struct udevice *dev)
+{
+   struct