From patchwork Sun Jul 14 10:53:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Trimarchi X-Patchwork-Id: 3281 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 5CEA540F59 for ; Sun, 14 Jul 2024 12:54:07 +0200 (CEST) Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-58c98ce7d00sf2796074a12.1 for ; Sun, 14 Jul 2024 03:54:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1720954447; cv=pass; d=google.com; s=arc-20160816; b=aWHEXtarEWhOnjyd1UKGe5uwkiws4Lw0gHT7LJMHVCsmkJwv4yBZXRgWj8dG6muNJI F7606b2RzV7Jy5rDEWT5dI74O2Pcz9sM49DRgN8dCxP6nugwm50DuOBpSkQbYYlzSHj7 0KSA79ekIqqOf7s1OSeRCD/7lcgTyIL9nub8paRA0mqGcHIIM4jWUvP9s+9Jph2f1Vhm ibXHGH2hwahoUvdifKo0gKXxWh0d+IZuG3vactMgccOXQ4yXK9eICAs9I/X2RfZxntw3 KNOcXhhTT4miDB4WBMI1lQejfuhSes81K5kSNaLFaSjhVhZOXFE5HBSqnEq4BIv18wgX sSxA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=zsE0kENFnL8X5qh20uvJtlN3Nekz2Fzm2zchXHqsRpU=; fh=0Wg1KpIj/gvsgUNldV0iqZ7a7g2iwi4KG/ei1iA3/YQ=; b=tyXWmyXRWulgC9PmyDM7ZInS7aQAgrVOc2+sQ6k46lN9KXPcSmfq90vKAsqlF0SCoP 2q2ZmBqQjaDK/5Rw/C2Zx9xDVVO7Mr3IoCDjeGGnR5sgnXsUxXR1RcGXDqx297vnvvg9 6OL0BjCDUVlNoPXKf1m04+RjH2++jMpTCYTh/6uUl53ZlMnLmG4Yy8wJseOhdeVkdvFk 5unGBqMPoWVjN1l13UA8GPsZsjP1jwRFugAdO8C49135jJlChf9WBIhA0Mtf0oCGQ+C8 SrAVj3y4xOxHjfRtBlJzsxPbExVzexuWkorkpb8ZqTiJdT86XBwK26kt97VjLu1P9n0I 19qA==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=LjRRzZjy; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@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=1720954447; x=1721559247; 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=zsE0kENFnL8X5qh20uvJtlN3Nekz2Fzm2zchXHqsRpU=; b=IcwmRp+A8knHTPTQDGMaOOehRJDR89NB4KRZPe2XCYhthXOSNAi7HJIGkUH7ahd2lJ 46pq9jgZCdd2TDtNSGzFsN3nkccoDNS0nBOoXkporIxST7+trcAaOVu1ZEXYd204lBkW ERF+Ht4KFBA2hbMHwmbePfMoCPyeh5xo4wv50= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720954447; x=1721559247; 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=zsE0kENFnL8X5qh20uvJtlN3Nekz2Fzm2zchXHqsRpU=; b=u+3Du5gCUpwa+ZBnkWg/IPxV63gr+J6Roz7Ly+IbyiE5SdHh9ApkR833mqy7VushQr Z9nXBa3owO+XG9kBZqbeEpOiwJ7lxvob+R/HhcMB6+SEd2Ls1ObEQJea3anV9gofRlL4 Cjb05jLwxpyRwULFa1aveusJQ0xz1pEJ+1SzwbrVVvLK491ICfq3dFZ5xFdNQjrZ0rqf flBbnBspRKqmcLhJbcIRsqK/ugWvkN4YSMC8Ur+6VhEx1bfYIR+9xbg5pdOOsMU3nut6 qUD7LIvWDUFkRql67i6W9Mwk0yfPhUb3eDQVgdDdjL5jFmgSxs0kcvDf9cwPVNMmEi96 nk3A== X-Forwarded-Encrypted: i=2; AJvYcCXqYBmu/SqzipXY10T6MBzoHKtk8mjzhCxlApchqgDiSSiR/v8PZIyqcZEUG3xjOnkkffcmahXaGGJDD3aMoGgHtlhkAS11JdYA5qRlYA2d9PtCTSVJ4VDCgA8jWg== X-Gm-Message-State: AOJu0YxkqaSidhqsSfLEs4hCem7i5/+vWTq2I5up+cNMiE1AB9q1c2sh sO/OihbRYrL7QEwsabS83feVRviO6hDMxDFbjKVCvR8IilzfSBm7tCX62nkd3RY+nQ== X-Google-Smtp-Source: AGHT+IFBqgzMWsq1oYNb3DGE95H10O5UCa/S04BaYblCTlSRAF3Z2s4pyKCalBHsnlgHPSNPK97wTw== X-Received: by 2002:a05:6402:2787:b0:58b:fd23:7065 with SMTP id 4fb4d7f45d1cf-594ba0cbe1amr12247598a12.16.1720954447054; Sun, 14 Jul 2024 03:54:07 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:308a:b0:58f:749f:1c6c with SMTP id 4fb4d7f45d1cf-5982622cf27ls1712353a12.1.-pod-prod-01-eu; Sun, 14 Jul 2024 03:54:05 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXwtFvKL3MHlWWIiZOQ8GVMgBKfJPBrpyZhwbVa14VvarlulC2uW1e2vdFksfvEdCE3RKImWRy4OUwE6W51THj/U0q4ehc82fyS9kFy99o2Dk4g X-Received: by 2002:a17:906:6b0a:b0:a77:cf09:9c72 with SMTP id a640c23a62f3a-a780b701760mr927321666b.38.1720954445278; Sun, 14 Jul 2024 03:54:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720954445; cv=none; d=google.com; s=arc-20160816; b=X6vls3l7PEom4+a0CcqpFi7CBZ50lJNsF73g5qfM1M0v61Z/L1U1LS4G7LxNmJKVG4 Q2sPIPfBrHe3MPxA1e8cV3r1xDqMVgV7VHhwGmrz2qpzlIulYr6KH0rabBVeFsp/mPx4 luDIVwq5TCoENqbhRcsNjkvZV/sb97DL2sM1uwxhS15BM0lMixX4Zbl+nKABdjLfrjNM yl0hNaKtwwjsvByRGh4J0Aonq9zWtfUF/q/bRPRfK8RuzcPbzTdbjXoPUBLFVf9Pmokk 90ljybWOeJmo0kaFkoqjYefbkbdjZ0pvKfpckoJXWKSrQPbgT2hkFgkzZRygK92aJ6Oa N8cw== 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=533G33PCRJeQk802BHhs4iEvwTKMoiBQLtOWe/MSr6U=; fh=+k93L/nqffGm5BaxErIskxuhG3Xp5ZHlxG4yVAcgzA8=; b=Q8ngLw9BD4h5FjrnQx/YmoCfgVH9VG4CCBWP7HlCCZq0C8gcjIdQlqQQmWYGjYybR7 Ah+HysflOJxvTwJmIUd847aJuIrl8g8ZIzCANbOpRz+0pkW1xhuUNdnDrITWWV/VS1Py dYSlE4KpR0zLT97AbCifkLhIzm2H3fs0P+ELMn9TgXKYM3ZOZpZnpM4rGQiVbAYZgjPp rnqyEEFktL0Kr+/hVFV6WD0iRNPPhbE1NLBR7d1jBSvSRRSFs/6yEm1cgK/B7jGn2LKw tK9M5QwkFZmFeC8yVjA9oRr1czeIdtl7k4MxgkxZ3CvkachMU0u8IJjskgfBbAXyEaAA 3dLA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=LjRRzZjy; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@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-a79bc884c58sor48409866b.5.2024.07.14.03.54.05 for (Google Transport Security); Sun, 14 Jul 2024 03:54:05 -0700 (PDT) Received-SPF: pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Forwarded-Encrypted: i=1; AJvYcCVvMxXHE4eqJzD182OqC+02PpGAu2dCQphfMB71KJO5/+0i8CsMqehMTvHspDvee1a4sWCvhkrTK8ysroohbQAyhQqwEhTmRVcxarRRKoWaAz/U X-Received: by 2002:a17:906:7c4d:b0:a77:cdaa:88a3 with SMTP id a640c23a62f3a-a780b6b30f8mr959876366b.27.1720954444804; Sun, 14 Jul 2024 03:54:04 -0700 (PDT) Received: from panicking.. (mob-5-91-58-211.net.vodafone.it. [5.91.58.211]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a79bc5a36c7sm119966166b.7.2024.07.14.03.54.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jul 2024 03:54:04 -0700 (PDT) From: Michael Trimarchi To: Michael Trimarchi Cc: Dario Binacchi , Patrick Barsanti , linux-amarula@amarulasolutions.com Subject: [PATCH 24/25] video: Add Synaptics R63353 panel driver Date: Sun, 14 Jul 2024 12:53:27 +0200 Message-ID: <20240714105328.35825-24-michael@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240714105328.35825-1-michael@amarulasolutions.com> References: <20240714105328.35825-1-michael@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: michael@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=LjRRzZjy; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@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: , The LS068B3SX02 panel is based on the Synaptics R63353 Controller. Add a driver for it. Signed-off-by: Michael Trimarchi --- drivers/video/Kconfig | 8 ++ drivers/video/Makefile | 1 + drivers/video/synaptics-r63353.c | 230 +++++++++++++++++++++++++++++++ 3 files changed, 239 insertions(+) create mode 100644 drivers/video/synaptics-r63353.c diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index d2432d67a4..9f7cf196e3 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -592,6 +592,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 9fd3645994..4d836efcfa 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 0000000000..25db9c3e70 --- /dev/null +++ b/drivers/video/synaptics-r63353.c @@ -0,0 +1,230 @@ +// 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; + + debug("%s: called\n", __func__); + + 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), +};