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 5D8ACC6FD18 for ; Wed, 19 Apr 2023 19:18:19 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 45810862B4; Wed, 19 Apr 2023 21:17:14 +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="rYu4bCIT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2E59B85CC7; Wed, 19 Apr 2023 21:16:59 +0200 (CEST) Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) (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 47CED862B5 for ; Wed, 19 Apr 2023 21:16:51 +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-x631.google.com with SMTP id dx24so830250ejb.11 for ; Wed, 19 Apr 2023 12:16:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681931811; x=1684523811; 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=7XwNbBL2BmCAU4xfdpvqIf7tKXJd4k/ZHQvrAkRf6MY=; b=rYu4bCITBOvaQNrX0to8O7Wzz0JnDmxEdJDgj5KVQeB7UceS5X4079u7tEswSHE2Zx W9NDjW8kRs8DIMrjjCEQVG0KTQaXA/4lNq1mkZq2QmsU1rSKZL5ZWE8Zg1wjcnQ1M5Z1 0HovDfMcnIxtJNzeyRZ3XJCftsqKW5/X+lg5V28L0q1l1aSVpkGBMQNBAaDS7Hhb8NIe EmgOTOX98Z6y/PxEPScuvFSC1w5RETDUeqHA2QUH5E0ekIYdk0c7ruxUkCjBIzy1BdlE m7/N+rfE6qK3PYRd5w6QRnmYcw35v7uZM+Zga+4bsRvGouomWGTzui1287d60f24VVCE 0ySQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681931811; x=1684523811; 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=7XwNbBL2BmCAU4xfdpvqIf7tKXJd4k/ZHQvrAkRf6MY=; b=iqPs460mLn7/+7OotKzW+NulnnF9JcuL7uYiqhT3IEQw6umxI2us9cSXSPXA7fgwcp nt06t0Ex5r0EcbW8VOGeEnWWGTbqvtNmLpqI1+DBTTYwZsYUJwXimhRbFt1E6QwczX21 wswEwOGBrX3eMQ7UDrvTXnBCNC0bMZGkBxdr39OvRyChFtyaVctZF+uxpJJo3dTBJrZf MX3J6eoUf2zbrpMFjNilEk202sKPymhNrwcx8jv3yvWCXRKkjrx9U0pOb0/ZKKyOs1G5 VstRECcoj2/DEPF/ddUjE+qB0ieTPUZcJjupXPWcdrDK8vetFsYE2XeqmQx5OTb4umOH Ofig== X-Gm-Message-State: AAQBX9fsBN0zIwkUhMWsGGIKIKf2cJ7ugguVMeG+NMgp5GASX6yur6KI 4Wfk2Sm8xQ5o7WOSubWMmNndUmX2tH+jBA== X-Google-Smtp-Source: AKy350bb8rZjoS50W1A8+0EesDQPC0azc56NiROYERg+lI443X571XgfhbXgu2RvCM/vFd15OzLSWg== X-Received: by 2002:a17:907:2d1f:b0:94f:322d:909d with SMTP id gs31-20020a1709072d1f00b0094f322d909dmr17178283ejc.63.1681931810968; Wed, 19 Apr 2023 12:16:50 -0700 (PDT) Received: from xeon.. ([188.163.112.59]) by smtp.gmail.com with ESMTPSA id tk9-20020a170907c28900b0094f5179540fsm5448465ejc.83.2023.04.19.12.16.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 12:16:50 -0700 (PDT) From: Svyatoslav Ryhel To: Anatolij Gustschin , Svyatoslav Ryhel Cc: u-boot@lists.denx.de Subject: [PATCH v1 6/6] video: panel: add generic endeavoru panel Date: Wed, 19 Apr 2023 22:16:30 +0300 Message-Id: <20230419191630.10112-7-clamor95@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230419191630.10112-1-clamor95@gmail.com> References: <20230419191630.10112-1-clamor95@gmail.com> MIME-Version: 1.0 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 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 # HTC One X T30 Sony Tested-by: Svyatoslav Ryhel # HTC One X T30 Sharp Signed-off-by: Svyatoslav Ryhel --- 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 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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