From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 71088C6FD18 for ; Tue, 25 Apr 2023 07:52:40 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9209B861B3; Tue, 25 Apr 2023 09:52:09 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Bro/QKgW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F39A886172; Tue, 25 Apr 2023 09:51:59 +0200 (CEST) Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id CB42F86201 for ; Tue, 25 Apr 2023 09:51:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=clamor95@gmail.com Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-958bb7731a9so543427166b.0 for ; Tue, 25 Apr 2023 00:51:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682409115; x=1685001115; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1KW/iPyoehyyrvnnOrf0CWwDtysls/ob6snDazTg57I=; b=Bro/QKgW3BeKDm87XrRPP8YaXHHA1cwgwAEfDMGtV8Un9eaECcJfEqZ3mwCAOeWJvF x0fl+eoTGWbsA5AfdTF1fT3qLRkXGanDW/w22DWpD9NGzsZPUITBdZLsp+WpqtKixH+l 0fI2bjAXfNzAPTOKkqgVtVVyNLmMTStozfDPtCVVBvgKM//mcpOXytpdV7NX/O2UE0Fa zRUbN3e1IgF2IAfCssEovYbQ8gI+Jz+/PkP/Z7vjy17pm63kCSSuyvG0y//PHMW+AlYz v5q4ac0I0ozfBwssooauJy4eO26JrSolUXyICOKdeKRjJHExMLALzmuKwdV5zxTbjjR3 g+Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682409115; x=1685001115; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1KW/iPyoehyyrvnnOrf0CWwDtysls/ob6snDazTg57I=; b=edvffiFQdf/AthCJoboNBqkJoZegHpGfbVXZ9J35yg9Y13KCZxYy23s4LsIJPznRa/ SbqN9i5mI1A0+Yz6AP5v5LF5y3/ZDHJWFXM9/SNZSjYxnCVpupD65cMbQf/9jQWI5jtG zKtamOLSYezc5q3yiRp6oS75je77wh3crd7G322vUMU3JOwdYU6uLvUFMWJxfh0aMgr6 /SUOdZkYG72xQRA6ndPAh6CjTuubDqkk/NLJ/gP+3xJUgyjEVgoxCNbaNShf0Kyy/qsS ptHjIqJTj29YcByQ3lTnSgn4UjkCqWrfGQGmHglbZlXw/nXKjPoEAU9aLajKnPh//+Q6 JD6g== X-Gm-Message-State: AAQBX9cjlaqs1wFhc3Gl5uZoDPDA63RMlO49meHTDXjqfCcBcZ24X4qq BzxMAcjpSVjO5PyK5ILrq5E= X-Google-Smtp-Source: AKy350YUr+j8QCdlhvxLMVNWmaiMeAXP7/lksib6amvMhfTuSTDxuuJf0tw9rU+eqgE9LOkEwHJNkQ== X-Received: by 2002:a17:906:38c9:b0:906:3373:cfe9 with SMTP id r9-20020a17090638c900b009063373cfe9mr12422586ejd.10.1682409114957; Tue, 25 Apr 2023 00:51:54 -0700 (PDT) Received: from xeon.. ([188.163.112.59]) by smtp.gmail.com with ESMTPSA id y15-20020a170906070f00b0094f54279f13sm6443067ejb.157.2023.04.25.00.51.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Apr 2023 00:51:54 -0700 (PDT) From: Svyatoslav Ryhel To: Anatolij Gustschin , Simon Glass , Svyatoslav Ryhel Cc: u-boot@lists.denx.de Subject: [PATCH v3 3/6] video: panel: add Renesas R61307 MIPI DSI panel driver Date: Tue, 25 Apr 2023 10:51:44 +0300 Message-Id: <20230425075147.48918-4-clamor95@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230425075147.48918-1-clamor95@gmail.com> References: <20230425075147.48918-1-clamor95@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=y Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean 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 Reviewed-by: Simon Glass --- drivers/video/Kconfig | 9 + drivers/video/Makefile | 1 + drivers/video/renesas-r61307.c | 302 +++++++++++++++++++++++++++++++++ 3 files changed, 312 insertions(+) create mode 100644 drivers/video/renesas-r61307.c diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 60048ad86a..44f21be166 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 0000000000..426fdc6224 --- /dev/null +++ b/drivers/video/renesas-r61307.c @@ -0,0 +1,302 @@ +// 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 + +/* + * The datasheet is not publicly available, all values are + * taken from the downstream. If you have access to datasheets, + * corrections are welcome. + */ + +#define R61307_MACP 0xB0 /* 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_SET 0xCC + +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 = 62000000, + .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 renesas_r61307_priv *priv = dev_get_priv(dev); + int ret; + + ret = regulator_set_enable_if_allowed(priv->vcc, 1); + if (ret) { + log_err("enabling vcc-supply failed (%d)\n", ret); + return ret; + } + mdelay(5); + + ret = regulator_set_enable_if_allowed(priv->iovcc, 1); + if (ret) { + log_err("enabling iovcc-supply failed (%d)\n", ret); + return ret; + } + + ret = dm_gpio_set_value(&priv->reset_gpio, 0); + if (ret) { + log_err("changing reset-gpio failed (%d)\n", ret); + return ret; + } + mdelay(5); + + ret = dm_gpio_set_value(&priv->reset_gpio, 1); + if (ret) { + log_err("changing reset-gpio failed (%d)\n", ret); + return ret; + } + + mdelay(5); + + return 0; +} + +static int renesas_r61307_set_backlight(struct udevice *dev, int percent) +{ + struct renesas_r61307_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; + + ret = mipi_dsi_dcs_exit_sleep_mode(dsi); + if (ret < 0) { + log_err("failed to exit sleep mode: %d\n", ret); + return ret; + } + + mdelay(80); + + mipi_dsi_dcs_write_buffer(dsi, address_mode, + sizeof(address_mode)); + + mdelay(20); + + 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; + } + + /* MACP Off */ + mipi_dsi_generic_write(dsi, macp_off, sizeof(macp_off)); + + if (priv->dig_cont_adj) + mipi_dsi_generic_write(dsi, contrast_setting, + sizeof(contrast_setting)); + + if (priv->gamma) + mipi_dsi_generic_write(dsi, gamma_setting[priv->gamma], + sizeof(gamma_setting[priv->gamma])); + + if (priv->inversion) + mipi_dsi_generic_write(dsi, column_inversion, + sizeof(column_inversion)); + else + mipi_dsi_generic_write(dsi, line_inversion, + sizeof(line_inversion)); + + /* MACP On */ + mipi_dsi_generic_write(dsi, macp_on, sizeof(macp_on)); + + 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_r61307_timings(struct udevice *dev, + struct display_timing *timing) +{ + memcpy(timing, &default_timing, sizeof(*timing)); + return 0; +} + +static int renesas_r61307_of_to_plat(struct udevice *dev) +{ + struct renesas_r61307_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 = uclass_get_device_by_phandle(UCLASS_REGULATOR, dev, + "vcc-supply", &priv->vcc); + if (ret) { + log_err("Cannot get vcc-supply: ret = %d\n", ret); + return ret; + } + + ret = uclass_get_device_by_phandle(UCLASS_REGULATOR, dev, + "iovcc-supply", &priv->iovcc); + if (ret) { + log_err("Cannot get iovcc-supply: ret = %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; + } + + priv->dig_cont_adj = dev_read_bool(dev, "renesas,contrast"); + priv->inversion = dev_read_bool(dev, "renesas,inversion"); + priv->gamma = dev_read_u32_default(dev, "renesas,gamma", 0); + + return 0; +} + +static int renesas_r61307_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_r61307_ops = { + .enable_backlight = renesas_r61307_enable_backlight, + .set_backlight = renesas_r61307_set_backlight, + .get_display_timing = renesas_r61307_timings, +}; + +static const struct udevice_id renesas_r61307_ids[] = { + { .compatible = "koe,tx13d100vm0eaa" }, + { .compatible = "hitachi,tx13d100vm0eaa" }, + { } +}; + +U_BOOT_DRIVER(renesas_r61307) = { + .name = "renesas_r61307", + .id = UCLASS_PANEL, + .of_match = renesas_r61307_ids, + .ops = &renesas_r61307_ops, + .of_to_plat = renesas_r61307_of_to_plat, + .probe = renesas_r61307_probe, + .plat_auto = sizeof(struct mipi_dsi_panel_plat), + .priv_auto = sizeof(struct renesas_r61307_priv), +}; -- 2.39.2