From patchwork Fri Sep 13 09:56:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3487 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 69D5B41280 for ; Fri, 13 Sep 2024 11:57:25 +0200 (CEST) Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a8a8d9a2a52sf154251666b.1 for ; Fri, 13 Sep 2024 02:57:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1726221445; cv=pass; d=google.com; s=arc-20240605; b=juHm62WptgJ8/Xk1tCOInvFcQdrx854r7KKMdP/PNmRVB1Wh2tt/00eGgOjz2HnLpW vU+PnxXEgFdfULidDVrQIrMyZV0Txp338cpi6n3CoYlE/A2qwfVxkJCOJ+YKtvJdHBWC aunDJp57ZHWCd8OmJi+lnjQcIeqjmbMBZ8x/cH5aPR739p1HyAGqWuqHUzLe6wgVDUfn yuifXci4F0N0kABTjASEl6PNfhx/GhTMzf3tzn/ddLL46MvTVQkFLlyoTEMCYgphCDBz gi84e8P6ydz5y1EkA+KhyzE/0AXJjCaMhTZAOccyGa9TuU6qxmjIul7rvfSKDfAOYTwU J3cQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=079s86zXqJHeXZMbpG4rBezEn3QfKKe/y+SXvQWQ7PA=; fh=eG8YzjNNyXUQFEXY1WPvhCh7Ru9DMc0Tw/OtemUV0t4=; b=PltGVT8KtBtb5M3yTUh5dhsh1q9zqPqmFAw5hcfnrNmoqIV5d1ZVR/S6sNOz7b0FXb m18CLklcpKG+1xwyfoiQfVupHYpxPioL0Sfr84sN2TdzmhpZAMf5WfG9ABt1Fpm8BY1b VDbWuWPp7N3kw0eZvHMP+SxOiAR7oxLa3Beb1g8AHA5wvT1UvBwVH7ocVdjN+4eAuxiD 6xYjLaJM9qXlx6RDtgMrAGySgn0bPYTe3Ki2UnHdu3JkPeq4P2Y8z38unOh4IOtVmaz9 f8cgugeA3FvDsAPVSNVbFkEh9/wNMfQqJHx6mD6MTjlgq4dGMi7d+UbfDzQs7RywcSiV vOqw==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=GVuTxsRy; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1726221445; x=1726826245; darn=patchwork.amarulasolutions.com; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=079s86zXqJHeXZMbpG4rBezEn3QfKKe/y+SXvQWQ7PA=; b=cu/JzYUMainmZmAq+Put9XaqWN+myFoRyD0V4vyuh9lh+LVmvHoJ+RDmIOun2XEXMy Yf2r1k2YS2g5ylkMSLQ7VTZOry8bygdvfCH8cPH7l4PvWelzrSHKQgfEwdyY4lb0OG2B EhOP9qFlqXca8ViKAHa1QB1J+q73T8ELG/DLc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726221445; x=1726826245; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :x-beenthere:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=079s86zXqJHeXZMbpG4rBezEn3QfKKe/y+SXvQWQ7PA=; b=M7unuDJO35k+/PI2/j8+zZrdes9UBhhblCulKqh5oafIwd4eceFlMFi/qTBXPOIpHd x0lmBViIyGLMwTpxldOrPA/FLCYr3c8ZqIXSJ0NWHqx6QyZUZpDT3BpKI7q7CiU7dE1q AsHUeUHCGx4m9j6N3+nUJqNdRDkihPf5JGF4PtO+ZW7wDBa7icoTHz7rtOPOx5fVea8U xFKAX5vIzKP9Xlu5eTqu+yZGG6AXFn0560IqPW2fSOxKUb7/NyjcrjcAQtaUW/tgTyNE TFZQRVKTvCx1OnYb69v7r/MTA+VxcVXst4cikpgxx2Brpch+8buFBTruGO8zjS5kGkYZ Gomw== X-Forwarded-Encrypted: i=2; AJvYcCUTtyfA7+qUEVhmHy8e7ebE9tdVcD6QoCBMeN2VLX0M7zoxiRMVqsLhP5Jmj7G2lY2hlIf5nM5nunMxj72N@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YxkUmSH+uYfMoYgh6Cr2yD8uQRpb6cf8Mdfp5BTin8OW5aUYUoP naGCDDlXQ5e1raAd+oIBjqC2kWSJnn8t6wGntTP8/2rF6RysYrWI+0hNrGf85rXqkw== X-Google-Smtp-Source: AGHT+IFmRlr+6jPMFrZ45yJXB2bRarP5dRpGsW8Ef9ArF6Tvw3FPMIKizLzXqfqxOYHSl4S3wcVijA== X-Received: by 2002:a05:6402:27c6:b0:5c3:c530:e98d with SMTP id 4fb4d7f45d1cf-5c413e5461emr5866685a12.30.1726221444954; Fri, 13 Sep 2024 02:57:24 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:5191:b0:5bf:bf:efe4 with SMTP id 4fb4d7f45d1cf-5c41408e99dls878306a12.2.-pod-prod-08-eu; Fri, 13 Sep 2024 02:57:23 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWlN670JU2n9WCpHyUMLWAdV13ssh5efOcP7U/4CzlIQu96k9cwnNKTn+/V6pHqXs2V5O7T9Df6lTo3DgPP@amarulasolutions.com X-Received: by 2002:a17:907:6d28:b0:a8d:1655:a423 with SMTP id a640c23a62f3a-a9029678c66mr643200666b.56.1726221443231; Fri, 13 Sep 2024 02:57:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726221443; cv=none; d=google.com; s=arc-20160816; b=oiUyL4GfSRP/0rNsIzbk0fYUaq1GCz4/wmo39TPBGwtHj9Xj9x45MStAy6rvxENz5b FXGijDcYshasvbvwWHt9EH4holXZ4lIzkQs9M5X/HT6nCwVGryd0gy7nh/cZ29xeowZD o4dw3ymxpp/1ljN2fSn2fplMD8hDSwc6xodwWKZh41oMwZJASOo3K9MdcDydAuumGT8Y XkMIlLJ39Nq210csomgHEdz930iRBD4uVjVSm4omAD2dkSvDbaW6rkCQadmHRQk+G2hX IfrzxjYMYtBKlXTyrmUiXvIqk71qAEUt9lY+ozN1ZVasIvZnLLt69FxtvaTtOjdNP/O8 GY+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=2GgTThR+n11+skGn4WqROLHbBMugAuPOtEXUsD/jtyU=; fh=TQxcIonlndKeDLLf2aJ022SE1lGjYyaVu9kgu/GOGgI=; b=FyZL6/qkRsuKnFuqCI2GinelcfY3sXIvij6Sz/SnhmrYELEFVF6MUmHVh/blGAoEb/ yOqrWAkTiFM9hRLYzIZLmS2bkKC8IwpO5gUCnOTLs2OqN768kOHQL/jB+LgoA/4ukTnt q8t3Af9R/HagPI4oCprc9f7EGNoJdDrQUYZ3JzF886rATH3s7RLaHdZzhMrxo918NEQA Cxy9ra1OEMSPMPQ8FO5a3GirO/hQfNGQ/YIlhYXdVQWdiwCqn2Xs9d4dMhRJR8VgeqTg bk9IcYg6bIZMRO8QmFNK0OXz7IwKvvye8RAkF/EQMnhVxSVRrhfvF91MCGKzzIr/mGvv Bflw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=GVuTxsRy; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id a640c23a62f3a-a8d258354b3sor548373466b.4.2024.09.13.02.57.23 for (Google Transport Security); Fri, 13 Sep 2024 02:57:23 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Forwarded-Encrypted: i=1; AJvYcCUhgOercUxZAPfayDHf4YrPrlNNk3yHvBy0Tk6+aQRueq9FrOqXZ9cZ40C1Ocly2h0CH6U9JoR+30c/LbKh@amarulasolutions.com X-Received: by 2002:a17:907:2da3:b0:a7d:9f92:9107 with SMTP id a640c23a62f3a-a9029690793mr628556066b.58.1726221442620; Fri, 13 Sep 2024 02:57:22 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-87-4-102-18.retail.telecomitalia.it. [87.4.102.18]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d25cee72bsm863224766b.173.2024.09.13.02.57.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Sep 2024 02:57:22 -0700 (PDT) From: Dario Binacchi To: u-boot@lists.denx.de Cc: Fabio Estevam , linux-amarula@amarulasolutions.com, michael@amarulasolutions.com, Miquel Raynal , Dario Binacchi , Anatolij Gustschin , Anton Bambura , =?utf-8?q?Jonas_Schw=C3=B6bel?= , Simon Glass , Svyatoslav Ryhel , Tom Rini , Ye Li Subject: [PATCH 19/26] video: Add Synaptics R63353 panel driver Date: Fri, 13 Sep 2024 11:56:01 +0200 Message-ID: <20240913095622.72377-20-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240913095622.72377-1-dario.binacchi@amarulasolutions.com> References: <20240913095622.72377-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=GVuTxsRy; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Michael Trimarchi The LS068B3SX02 panel is based on the Synaptics R63353 Controller. Add a driver for it. Signed-off-by: Michael Trimarchi Signed-off-by: Dario Binacchi --- drivers/video/Kconfig | 8 ++ drivers/video/Makefile | 1 + drivers/video/synaptics-r63353.c | 228 +++++++++++++++++++++++++++++++ 3 files changed, 237 insertions(+) create mode 100644 drivers/video/synaptics-r63353.c diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index cafdc15f9fe2..520577976571 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -627,6 +627,14 @@ config VIDEO_LCD_SSD2828_RESET The reset pin of SSD2828 chip. This takes a string in the format understood by 'sunxi_name_to_gpio' function, e.g. PH1 for pin 1 of port H. +config VIDEO_LCD_SYNAPTICS_R63353 + tristate "Synaptics R63353-based DSI LCD panels support" + select VIDEO_MIPI_DSI + default n + help + Say Y if you want to enable support for panels based on the + Synaptics R63353 controller. + config VIDEO_LCD_TDO_TL070WSH30 bool "TDO TL070WSH30 DSI LCD panel support" select VIDEO_MIPI_DSI diff --git a/drivers/video/Makefile b/drivers/video/Makefile index 9fd3645994f1..4d836efcfa41 100644 --- a/drivers/video/Makefile +++ b/drivers/video/Makefile @@ -66,6 +66,7 @@ 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_SYNAPTICS_R63353) += synaptics-r63353.o obj-$(CONFIG_VIDEO_LCD_TDO_TL070WSH30) += tdo-tl070wsh30.o obj-$(CONFIG_VIDEO_MCDE_SIMPLE) += mcde_simple.o obj-${CONFIG_VIDEO_MESON} += meson/ diff --git a/drivers/video/synaptics-r63353.c b/drivers/video/synaptics-r63353.c new file mode 100644 index 000000000000..86d2aea346b2 --- /dev/null +++ b/drivers/video/synaptics-r63353.c @@ -0,0 +1,228 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Synaptics R63353 Controller driver + * + * Copyright (C) 2020 BSH Hausgerate GmbH + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define R63353_INSTR(...) { \ + .len = ARRAY_SIZE(((u8[]) {__VA_ARGS__})), \ + .data = (const u8 *)&(const u8 []){__VA_ARGS__} \ + } + +struct r63353_instr { + size_t len; + const u8 * const data; +}; + +static const struct r63353_instr init_sequence[] = { + R63353_INSTR(0x51, 0xff), + R63353_INSTR(0x53, 0x0c), + R63353_INSTR(0x55, 0x00), + R63353_INSTR(0x84, 0x00), + R63353_INSTR(0x29), + R63353_INSTR(0x11), +}; + +struct r63353_panel_priv { + struct udevice *dvdd; + struct udevice *avdd; + struct udevice *backlight; + struct gpio_desc reset_gpio; +}; + +static const struct display_timing default_timing = { + .pixelclock.typ = 70000000, + .hactive.typ = 640, + .hfront_porch.typ = 35, + .hsync_len.typ = 2, + .hback_porch.typ = 150, + .vactive.typ = 1280, + .vfront_porch.typ = 2, + .vsync_len.typ = 4, + .vback_porch.typ = 1, + .flags = DISPLAY_FLAGS_DE_LOW, +}; + +static int r63353_panel_enable_backlight(struct udevice *dev) +{ + struct r63353_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 i, ret; + + ret = mipi_dsi_attach(dsi); + if (ret < 0) + return ret; + + ret = mipi_dsi_dcs_soft_reset(dsi); + if (ret < 0) { + dev_err(dev, "Failed to do Software Reset (%d)\n", ret); + goto fail; + } + + mdelay(20); + + ret = mipi_dsi_dcs_enter_sleep_mode(dsi); + if (ret < 0) { + dev_err(dev, "Failed to enter sleep mode (%d)\n", ret); + goto fail; + } + + for (i = 0; i < ARRAY_SIZE(init_sequence); i++) { + const struct r63353_instr *instr = &init_sequence[i]; + + ret = mipi_dsi_dcs_write_buffer(dsi, instr->data, instr->len); + if (ret < 0) + goto fail; + } + + mdelay(120); + + ret = mipi_dsi_dcs_exit_sleep_mode(dsi); + if (ret < 0) { + dev_err(dev, "Failed to exit sleep mode (%d)\n", ret); + goto fail; + } + + mdelay(10); + + /* This call starts sending the data on the display (LINUX LOGO) */ + ret = mipi_dsi_dcs_set_display_on(dsi); + if (ret < 0) { + dev_err(dev, "Failed to set display ON (%d)\n", ret); + goto fail; + } + + ret = backlight_enable(priv->backlight); + if (ret) + return ret; + + return 0; + +fail: + dm_gpio_set_value(&priv->reset_gpio, 0); + + return ret; +} + +static int r63353_panel_get_display_timing(struct udevice *dev, + struct display_timing *timing) +{ + struct mipi_dsi_panel_plat *plat = dev_get_plat(dev); + struct mipi_dsi_device *device = plat->device; + + memcpy(timing, &default_timing, sizeof(*timing)); + + /* fill characteristics of DSI data link */ + if (device) { + device->lanes = plat->lanes; + device->format = plat->format; + device->mode_flags = plat->mode_flags; + } + + return 0; +} + +static int r63353_panel_of_to_plat(struct udevice *dev) +{ + struct r63353_panel_priv *priv = dev_get_priv(dev); + int ret; + + ret = device_get_supply_regulator(dev, "dvdd-supply", &priv->dvdd); + if (ret) { + dev_err(dev, "failed to get power dvdd supply\n"); + return ret; + } + + ret = device_get_supply_regulator(dev, "avdd-supply", &priv->avdd); + if (ret) { + dev_err(dev, "failed to get power avdd supply\n"); + return ret; + } + + ret = gpio_request_by_name(dev, "reset-gpios", 0, &priv->reset_gpio, + GPIOD_IS_OUT); + if (ret) { + dev_err(dev, "failed to get RESET GPIO\n"); + return ret; + } + + return 0; +} + +static int r63353_panel_probe(struct udevice *dev) +{ + struct r63353_panel_priv *priv = dev_get_priv(dev); + struct mipi_dsi_panel_plat *plat = dev_get_plat(dev); + int ret; + + ret = regulator_set_enable(priv->avdd, true); + if (ret) { + dev_err(dev, "Failed to enable avdd regulator (%d)\n", ret); + return ret; + } + + mdelay(25); + + ret = regulator_set_enable(priv->dvdd, true); + if (ret) { + dev_err(dev, "Failed to enable dvdd regulator (%d)\n", ret); + regulator_set_enable(priv->avdd, false); + return ret; + } + + dm_gpio_set_value(&priv->reset_gpio, 0); + mdelay(10); + dm_gpio_set_value(&priv->reset_gpio, 1); + mdelay(120); + + /* fill characteristics of DSI data link */ + plat->lanes = 2; + plat->format = MIPI_DSI_FMT_RGB888; + plat->mode_flags = MIPI_DSI_MODE_VIDEO_HSE | MIPI_DSI_MODE_VIDEO | + MIPI_DSI_CLOCK_NON_CONTINUOUS | MIPI_DSI_MODE_LPM | + MIPI_DSI_MODE_VIDEO_SYNC_PULSE | MIPI_DSI_MODE_EOT_PACKET; + + ret = uclass_get_device_by_phandle(UCLASS_PANEL_BACKLIGHT, dev, + "backlight", &priv->backlight); + if (ret) { + dev_err(dev, "%s: Warning: cannot get backlight: ret=%d\n", + __func__, ret); + if (ret != -ENOENT) + return ret; + } + + return 0; +} + +static const struct panel_ops r63353_panel_ops = { + .enable_backlight = r63353_panel_enable_backlight, + .get_display_timing = r63353_panel_get_display_timing, +}; + +static const struct udevice_id r63353_panel_ids[] = { + { .compatible = "syna,r63353" }, + { .compatible = "sharp,ls068b3sx02" }, + { } /* sentinel */ +}; + +U_BOOT_DRIVER(r63353_panel) = { + .name = "r63353_panel", + .id = UCLASS_PANEL, + .of_match = r63353_panel_ids, + .ops = &r63353_panel_ops, + .of_to_plat = r63353_panel_of_to_plat, + .probe = r63353_panel_probe, + .plat_auto = sizeof(struct mipi_dsi_panel_plat), + .priv_auto = sizeof(struct r63353_panel_priv), +};