From patchwork Tue Sep 3 15:30:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3392 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 599C23FA4F for ; Tue, 3 Sep 2024 17:31:23 +0200 (CEST) Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-533a8a3ca6asf5365238e87.1 for ; Tue, 03 Sep 2024 08:31:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1725377483; cv=pass; d=google.com; s=arc-20240605; b=MXaTTLRLiLnb9vgXDSeQkOEME7M7DnHrMIn6WXq/XIjjc/FB2XrL2ZiPeS1BDXW0wt R/z+DoqMYCPvqPzUd7byNooEJ6Jjypn5fnHT0ZSmsJ+TXom8ZdDR0vaUx4zNCtenzWB/ n2cZA/lx6lqai88GCxD50yIVgfbNzoBsZ2XbaCCDebYlztdgBPSwsa/dc1Rd2+4FFMBi 7mLdRjtesu2wD3QsF/8uFKKe3B3CuOb1x3HcD+kErfqJrIgseLonplFcmBAJ6oySAdYE R0OSZVGvcM4hswseP+vD4H3l0eexCXhjmgC5Py0ACM1/B9aGmRbLAusc4cERyNoYL1Bd tmQQ== 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:to:from:dkim-signature; bh=CkyywR9sPN15zuNAh5hVWX9kHYxVLuxyYB8oxVa4r40=; fh=AH1HPFLK02tN+uziAhJXdn4/A2zPyg1aLJNcZYifoJU=; b=J7aqKcVVGjwvlFV/K5R47lvi5ttfJtpQ+0Fe6nCce/sM1A3MBgpYjG7eRjGyEvw76k 4hErlbtxEG+sUbtoPt6BiYkcYQfc9NwoqigqHXdttrid02koZqtLn+TyukE8PSaV6o8L oo2nCD87d7D04/g4bmgO06klaSuwctFlNuxy7whFwe9mUzCrbVhDp5lkFLheQS7xa96l 8APQPm4THxKtaqyX4GvVuPxlJhMoG58SqsvyPLquoqL3vDqiGiNVDNifsh+UAMZWU41D hRyJ3x2SUybL9yeXk8XsmJSb96ByoI0SUIQmVBJpLtIT/sTu2FIk9bOf8d2HVUqhypo+ nxuQ==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=AJdtR0kP; 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=1725377483; x=1725982283; 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:to:from:from:to:cc:subject:date:message-id:reply-to; bh=CkyywR9sPN15zuNAh5hVWX9kHYxVLuxyYB8oxVa4r40=; b=Y3fOD4xpFRNjvMjF9z6IdITLkzL55+JuygLZb37gp6MnDzTHeqHcuYNfcAZ8X+zE/D H/SvKfImFd5nn4LlrVB70SBkxfv+yPuQZ/MvYXp6gYSKROecv8djlkFOEY8RRA4rkcHG lbinsrTW6QZbAEjQa9CnJmIZMnT/ooXKVJd+I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725377483; x=1725982283; 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:to:from:x-beenthere :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=CkyywR9sPN15zuNAh5hVWX9kHYxVLuxyYB8oxVa4r40=; b=v+OTExaYAfwLl0WjlZbtnvddVmOBr1bcVA75/tJ2TXeGbJNrcQvORghy8nOwXi5uIo FfnSzWjp8QDXJ8cqrrMwzfdahepe9RTvV8XdAe4yftNIQdC3QTTTPsAqJSnYPLFbfwaJ bfpY6J/GO8HExV1ZbWQk3PLhipg9fo24ckfOLcpH+PCnyhiij9cBayIBK9mOEcgK8OwL bhOspqUZNajB/7SLOu9S14b0jXS6hGmHtHZ506UTIwR7Hf/B9R5YvKgBhaqPv94Ig1Ln eAXdJpPYsjcEl43hbVFy+VIvNsrJzSJotMjNzBoOCPF14S37ck+cJetnb1bEEq91a8u8 BWmQ== X-Forwarded-Encrypted: i=2; AJvYcCWU08WWy4ukJyBhKi/TXUQoG1sKUvJY7dlMIpRbcZWubVSHOCui+n5CW+NPq0x+GICakEgPMyl1qMRBC0cp@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0Yzx2Tmr63jMfVDaHmcwJf+JNB/qspAUgesPzaHPNyO3zDN1sBLW h0jA0FcGwjThzMJuT5hdCf07RoHtZ4iWk/FMC2rZYvIidtCnBTOOZwdbaR4ZJaJppg== X-Google-Smtp-Source: AGHT+IERz7VlbQ/czJR6hxEswD2R+ycbByjWSOLklOk67zeM9MfBGqw5fISxbNtZ2K//+ea2DGbROg== X-Received: by 2002:a05:6512:132a:b0:52c:e393:6634 with SMTP id 2adb3069b0e04-53546b4529dmr9598164e87.33.1725377482533; Tue, 03 Sep 2024 08:31:22 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6512:3b8f:b0:52e:9707:ab58 with SMTP id 2adb3069b0e04-5353d812577ls215619e87.1.-pod-prod-04-eu; Tue, 03 Sep 2024 08:31:21 -0700 (PDT) X-Received: by 2002:a05:6512:ba4:b0:533:d28:b9d9 with SMTP id 2adb3069b0e04-53546bc1e58mr9798926e87.58.1725377480510; Tue, 03 Sep 2024 08:31:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725377480; cv=none; d=google.com; s=arc-20160816; b=mrLpX+hIIVTQ7MlsR5iOA6qNFiTPG7are7UQEUtjB5JGeskBvASuCyin5FYxhGjWnl rISQJkhqBRtlWLiZ6cSy7hckzc1gZPK3ixKUG8Go+okh+s/KWitT9WY+pTiE0diHbWWQ cmAx9+KZN5ZewIezI6+IO6oFAU7E1lrJnVnQOZxdNtIn6Ef+z9tU0bD8/NAh2zh5HOpS 5Iuxdz2nFhSZasS2ah3p+zYs9AlmctMbrnGKfzC9DTTz2ZYU7g3Wqx8HEudBg1mRS6ml Pf7UxtoqP5BU4iVJWjmQWmJL1i0Xe8vY9gl/O327vQ98gnWDYgomnXVUoqMq3j5OteEC QG1w== 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:to:from:dkim-signature; bh=4Zn8ClwdXoAcaHA+tk5biLFrXll9qgGw9IRC/fcfxXM=; fh=FtQepR0uNoeKT2PVdKfTKOkvEYfwbRmoVE9BmlYw3tk=; b=HIyHjuc++Nbkx9Ti13dNTdI9r7karbOvY54nRm2O1YsW+GHqs2aRRgg4Gs+QnXvIIf mCxBhwEAwUfcTccyrEy23R2mS3/HF2XT2noXFEbMkStw88P+qdca7gig+OPWXVrzik0W rX+1YviYDxfvcM4bADK3Etb23HuCGtZcgcvxpFtupemZoK8XG31YvnPc0jW76MoIwRqB ljUJd+9/YU9Ff/86YP4a/8ljnXP+qUveo0F8HrZv/1ATwpBJmpPhRuVmtDHbYgjrAlFS dUkyWfmEBrBSKdcoPnqaSA3qzbf7thrnf39Qq6qOStyuss+paD5+7/gc9hGYVgAvlX8I YYGA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=AJdtR0kP; 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 5b1f17b1804b1-42bb70c9174sor45556965e9.13.2024.09.03.08.31.20 for (Google Transport Security); Tue, 03 Sep 2024 08:31:20 -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-Received: by 2002:a05:600c:1d20:b0:428:ea8e:b4a0 with SMTP id 5b1f17b1804b1-42c7b5a8fb2mr60389415e9.14.1725377479805; Tue, 03 Sep 2024 08:31:19 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.amarulasolutions.com ([2.196.42.65]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42bb6e273e3sm174168685e9.30.2024.09.03.08.31.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 08:31:19 -0700 (PDT) From: Dario Binacchi To: linux-amarula@amarulasolutions.com Subject: [PATCH 20/29] video: Add Synaptics R63353 panel driver Date: Tue, 3 Sep 2024 17:30:51 +0200 Message-ID: <20240903153100.918077-20-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240903153100.918077-1-dario.binacchi@amarulasolutions.com> References: <20240903153100.918077-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=AJdtR0kP; 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 --- 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 d2432d67a460..9f7cf196e3ac 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 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..25db9c3e707a --- /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), +};