From patchwork Fri Jun 9 14:59:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 13274075 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7AFB1C7EE2E for ; Fri, 9 Jun 2023 15:00:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9585310E6BE; Fri, 9 Jun 2023 15:00:03 +0000 (UTC) X-Greylist: delayed 667 seconds by postgrey-1.36 at gabe; Fri, 09 Jun 2023 14:59:57 UTC Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::221]) by gabe.freedesktop.org (Postfix) with ESMTPS id BAFF110E6BE for ; Fri, 9 Jun 2023 14:59:57 +0000 (UTC) X-GND-Sasl: miquel.raynal@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1686322795; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GOXmbDeINpoIDU/vXw0yK73QV+pWdXwKgrY443WDF0c=; b=QUwyXPjor572e2TjjtQxrFxJHfm8wwz/SEkCiifzuHh1it6PtCu2pId/zUAfKqIR8dx+Iz EOKAlWdba8cDelXYokYfmFGh7jyc+rFU/LrMcEZtbFEAObR3/BI+oI5jtox8wZDoJbmHk9 f5DQhcmBLfbGkwXdxd2W99Uc2szW5h9Wd1qqU4VdrJQ+w2tZ8yfAMrOXyPfLD3diySwIXf nK5XevurV9SwDreS09Jnjer2EGwTigCtWcgTsEHFVaBBnxeq9s4SDnlVi2eejhsyF3TTuV wSrikPg+y2kUsu1ill6m8s54ni5ndC47FAjpWM+Xj5C5HJGpQDxShFVVZqXOig== X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 83A9D240007; Fri, 9 Jun 2023 14:59:54 +0000 (UTC) From: Miquel Raynal To: Thierry Reding , Sam Ravnborg , David Airlie , Daniel Vetter , Maxime Ripard , dri-devel@lists.freedesktop.org Subject: [PATCH 1/7] drm/panel: sitronix-st7789v: Prevent core spi warnings Date: Fri, 9 Jun 2023 16:59:45 +0200 Message-Id: <20230609145951.853533-2-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609145951.853533-1-miquel.raynal@bootlin.com> References: <20230609145951.853533-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Krzysztof Kozlowski , Rob Herring , Thomas Petazzoni , Miquel Raynal Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The spi core warns us about using an of_device_id table without a spi_device_id table aside for module utilities in orter to not rely on OF modaliases. Just add this table using the device name without the vendor prefix (as it is usually done). Signed-off-by: Miquel Raynal Reviewed-by: Sam Ravnborg --- drivers/gpu/drm/panel/panel-sitronix-st7789v.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c index bbc4569cbcdc..c67b9adb157f 100644 --- a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c +++ b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c @@ -400,9 +400,16 @@ static const struct of_device_id st7789v_of_match[] = { }; MODULE_DEVICE_TABLE(of, st7789v_of_match); +static const struct spi_device_id st7789v_ids[] = { + { "st7789v", }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(spi, st7789v_ids); + static struct spi_driver st7789v_driver = { .probe = st7789v_probe, .remove = st7789v_remove, + .id_table = st7789v_ids, .driver = { .name = "st7789v", .of_match_table = st7789v_of_match, From patchwork Fri Jun 9 14:59:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 13274079 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 53229C87FDE for ; Fri, 9 Jun 2023 15:00:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3FF5C10E6BD; Fri, 9 Jun 2023 15:00:09 +0000 (UTC) Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::221]) by gabe.freedesktop.org (Postfix) with ESMTPS id 189DA10E6C1 for ; Fri, 9 Jun 2023 14:59:57 +0000 (UTC) X-GND-Sasl: miquel.raynal@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1686322796; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Nq6EroddWpsFxHMt68/nfoMOdKtHAf27aF2fFd7Umk4=; b=gEpvYVFP+WvhW6wKXVnxEg8n7BqHXZgpOr99f4i/fZk/S4i+s1LKeNHOOIIJ/ZxwQfgI7X L5cx26jgOp0sjAx4C5Br+/Ki5SaaToEiWB64judDAUP7FHV6UHtlaHlvmoyl9v3PjbVuUZ LjaLQw1msB12Q25czgj1EPQV0MPwRP3GQ/XFwiRrn5l+DrYTeMHTAHHrOk1e64YKz9WMP9 NcWwiXeCaBTK/WGIQvFvkYL2dLDaGznVpcvnxk1sVkTgBCKEystklVltyCUNtL2efYjFaO iyXpi0QDrZ7I1aZDIceLMvIQhJBQr0GYXny/PIJYAngFy2OZggdrTDSMNrOkfQ== X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id BD5FD24000B; Fri, 9 Jun 2023 14:59:55 +0000 (UTC) From: Miquel Raynal To: Thierry Reding , Sam Ravnborg , David Airlie , Daniel Vetter , Maxime Ripard , dri-devel@lists.freedesktop.org Subject: [PATCH 2/7] drm/panel: sitronix-st7789v: Use 9 bits per spi word by default Date: Fri, 9 Jun 2023 16:59:46 +0200 Message-Id: <20230609145951.853533-3-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609145951.853533-1-miquel.raynal@bootlin.com> References: <20230609145951.853533-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Krzysztof Kozlowski , Rob Herring , Thomas Petazzoni , Miquel Raynal Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The Sitronix controller expects 9-bit words, provide this as default at probe time rather than specifying this in each and every access. Signed-off-by: Miquel Raynal Reviewed-by: Sam Ravnborg --- drivers/gpu/drm/panel/panel-sitronix-st7789v.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c index c67b9adb157f..e9ca7ebb458a 100644 --- a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c +++ b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c @@ -138,7 +138,6 @@ static int st7789v_spi_write(struct st7789v *ctx, enum st7789v_prefix prefix, spi_message_init(&msg); xfer.tx_buf = &txbuf; - xfer.bits_per_word = 9; xfer.len = sizeof(txbuf); spi_message_add_tail(&xfer, &msg); @@ -365,6 +364,13 @@ static int st7789v_probe(struct spi_device *spi) spi_set_drvdata(spi, ctx); ctx->spi = spi; + spi->bits_per_word = 9; + ret = spi_setup(spi); + if (ret < 0) { + dev_err(&spi->dev, "spi_setup failed: %d\n", ret); + return ret; + } + drm_panel_init(&ctx->panel, &spi->dev, &st7789v_drm_funcs, DRM_MODE_CONNECTOR_DPI); From patchwork Fri Jun 9 14:59:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 13274078 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 18E9BC7EE45 for ; Fri, 9 Jun 2023 15:00:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5170E10E6C0; Fri, 9 Jun 2023 15:00:09 +0000 (UTC) Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::221]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3988810E07D for ; Fri, 9 Jun 2023 14:59:59 +0000 (UTC) X-GND-Sasl: miquel.raynal@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1686322797; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eWmXyHaEO4mtkrfotZ0GVoh1PNJaSqyVIp9+8qmmMVQ=; b=GqgmofFZ8/g7Rl5pyey2Ku8d+5UlSGmZAsoLRwlBMxYDrzOvG4zFgW9oeCEE6ANjowgsLU zcHjzrRtgOgbeSdCk8oKQe3pkZ3IDF2v8QMe/5VjqQ4G7JrVz1NFNMKQfmRWKx/JpJ82/z sqe15sf0ONYhSPHWLlTnaql1giRyvBIKVK7wTwCezv3WfYJVibtaHGcvHDsIzWNIX47FNR +vaLOK8tz7tcEDCRZ74oBEfLaAdFcJysByPF86K4zJ58rp4vM00tuQ/0pZScMuLjDoZS3d TpCjdQDPg1eTVU3oTjN1p1J772pnkKaHdD1LCNE0QUXUbBP+fsEuoy6WM0x7fw== X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id D4B16240009; Fri, 9 Jun 2023 14:59:56 +0000 (UTC) From: Miquel Raynal To: Thierry Reding , Sam Ravnborg , David Airlie , Daniel Vetter , Maxime Ripard , dri-devel@lists.freedesktop.org Subject: [PATCH 3/7] drm/panel: sitronix-st7789v: Specify the expected bus format Date: Fri, 9 Jun 2023 16:59:47 +0200 Message-Id: <20230609145951.853533-4-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609145951.853533-1-miquel.raynal@bootlin.com> References: <20230609145951.853533-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Krzysztof Kozlowski , Rob Herring , Thomas Petazzoni , Miquel Raynal Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The LCD controller supports RGB444, RGB565 and RGB888. The value that is written in the COLMOD register indicates using RGB888, so let's clearly specify the in-use bus format. Signed-off-by: Miquel Raynal --- drivers/gpu/drm/panel/panel-sitronix-st7789v.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c index e9ca7ebb458a..0abb45bea18d 100644 --- a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c +++ b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -170,6 +171,7 @@ static int st7789v_get_modes(struct drm_panel *panel, struct drm_connector *connector) { struct drm_display_mode *mode; + u32 bus_format = MEDIA_BUS_FMT_RGB666_1X18; mode = drm_mode_duplicate(connector->dev, &default_mode); if (!mode) { @@ -186,6 +188,8 @@ static int st7789v_get_modes(struct drm_panel *panel, connector->display_info.width_mm = 61; connector->display_info.height_mm = 103; + drm_display_info_set_bus_formats(&connector->display_info, + &bus_format, 1); return 1; } From patchwork Fri Jun 9 14:59:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 13274074 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 78B41C7EE2E for ; Fri, 9 Jun 2023 15:00:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 74DDC10E6C5; Fri, 9 Jun 2023 15:00:01 +0000 (UTC) Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::221]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5201E10E6D9 for ; Fri, 9 Jun 2023 15:00:00 +0000 (UTC) X-GND-Sasl: miquel.raynal@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1686322799; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nkO/Yx1g5fUFscK6SXf1oYePN1dBcfgeIQishrjax9Y=; b=b26cyEGiP/4WbeJB/EMzSH3bUSUVKnwmNzjcraJwT0ygt+Xp0vOsZkKvv6p4tnjaP+7STx 9UWb+lXLHAeJ4Iwk7qldte4+GYVsEgD+fElB/SE8DTxM2qngUgQtEqTGiNIm6e//8qfTvH 4ZRE3/0qeNjuYoXcz0ow5Gsom/rgkZZiTWL0w3Z3iCnJMQ6oGuBSOiexIWLfeDDy4nWj/H jjCP1Vj8mEfwyVIC9P2Sw6kpxanGPVwXJgtyWFDVW1gpc1tAN3w7o/zrQIOZZOKnCvL1zm DIR0BHUBLuRjdh5WvoPoUDsJU5hDP1L39R5GnnqwKny7g+CD2I9ksP9jthQdWw== X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 14459240006; Fri, 9 Jun 2023 14:59:58 +0000 (UTC) From: Miquel Raynal To: Thierry Reding , Sam Ravnborg , David Airlie , Daniel Vetter , Maxime Ripard , dri-devel@lists.freedesktop.org Subject: [PATCH 4/7] drm/panel: sitronix-st7789v: Use platform data Date: Fri, 9 Jun 2023 16:59:48 +0200 Message-Id: <20230609145951.853533-5-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609145951.853533-1-miquel.raynal@bootlin.com> References: <20230609145951.853533-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Krzysztof Kozlowski , Rob Herring , Thomas Petazzoni , Miquel Raynal Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The Sitronix ST7789V LCD controller is actually packaged in a number of different panels with slightly different properties. Before introducing the support for another pannel using this same LCD controller, let's move all the panel-specific information into a dedicated structure that is available as platform data. There is no functional change. Signed-off-by: Miquel Raynal Reviewed-by: Sam Ravnborg --- .../gpu/drm/panel/panel-sitronix-st7789v.c | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c index 0abb45bea18d..212bccc31804 100644 --- a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c +++ b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c @@ -112,11 +112,19 @@ return val; \ } while (0) +struct st7789v_panel_info { + const struct drm_display_mode *display_mode; + u16 width_mm; + u16 height_mm; + u32 bus_format; +}; + struct st7789v { struct drm_panel panel; struct spi_device *spi; struct gpio_desc *reset; struct regulator *power; + const struct st7789v_panel_info *panel_info; }; enum st7789v_prefix { @@ -170,10 +178,11 @@ static const struct drm_display_mode default_mode = { static int st7789v_get_modes(struct drm_panel *panel, struct drm_connector *connector) { + struct st7789v *ctx = panel_to_st7789v(panel); + const struct st7789v_panel_info *panel_info = ctx->panel_info; struct drm_display_mode *mode; - u32 bus_format = MEDIA_BUS_FMT_RGB666_1X18; - mode = drm_mode_duplicate(connector->dev, &default_mode); + mode = drm_mode_duplicate(connector->dev, panel_info->display_mode); if (!mode) { dev_err(panel->dev, "failed to add mode %ux%ux@%u\n", default_mode.hdisplay, default_mode.vdisplay, @@ -186,10 +195,10 @@ static int st7789v_get_modes(struct drm_panel *panel, mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; drm_mode_probed_add(connector, mode); - connector->display_info.width_mm = 61; - connector->display_info.height_mm = 103; + connector->display_info.width_mm = panel_info->width_mm; + connector->display_info.height_mm = panel_info->height_mm; drm_display_info_set_bus_formats(&connector->display_info, - &bus_format, 1); + &panel_info->bus_format, 1); return 1; } @@ -365,6 +374,8 @@ static int st7789v_probe(struct spi_device *spi) if (!ctx) return -ENOMEM; + ctx->panel_info = device_get_match_data(&spi->dev); + spi_set_drvdata(spi, ctx); ctx->spi = spi; @@ -404,8 +415,15 @@ static void st7789v_remove(struct spi_device *spi) drm_panel_remove(&ctx->panel); } +static const struct st7789v_panel_info st7789v_info = { + .display_mode = &default_mode, + .width_mm = 64, + .height_mm = 103, + .bus_format = MEDIA_BUS_FMT_RGB666_1X18, +}; + static const struct of_device_id st7789v_of_match[] = { - { .compatible = "sitronix,st7789v" }, + { .compatible = "sitronix,st7789v", .data = &st7789v_info }, { } }; MODULE_DEVICE_TABLE(of, st7789v_of_match); From patchwork Fri Jun 9 14:59:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 13274077 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9D652C7EE2E for ; Fri, 9 Jun 2023 15:00:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C18C510E6BC; Fri, 9 Jun 2023 15:00:08 +0000 (UTC) Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::221]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7075310E6C1 for ; Fri, 9 Jun 2023 15:00:01 +0000 (UTC) X-GND-Sasl: miquel.raynal@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1686322800; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=V5FRfPCwQJ17mhgzs0DzGHbHHXENt7bzJ7+A1d6ujS4=; b=QSJquyXAM5UyM4CvGaETzuty2pzzdGY57ot/mY+aBGjTaCDLrPVZPboqViSNs34OMaO6RX zbQm71eXlludQuIU3hkn1G8bV1N4xgsDIXkJg3OC05qpEHTFrJ3PTd0b1vdoZmecUIsrp1 FKuU45XNWx87V2c2pNEpn2uuAF/d0V+k+8ArWEADsdWaS9LQkjMe+Np7kOcg+1JtxD9g7w GhIMOdjL45QYEWB6fsmxZaLP4klMl8Ialq2qLyP7qYB55F6PZzCMjkiJEeRj4+Rg13y9XV 9dt3NeXnhBYubFvhp4Ov5grxQYd8e7z69vdqz39uUvk8ezTWNKi84m7P510/Kg== X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 2E16224000E; Fri, 9 Jun 2023 14:59:59 +0000 (UTC) From: Miquel Raynal To: Thierry Reding , Sam Ravnborg , David Airlie , Daniel Vetter , Maxime Ripard , dri-devel@lists.freedesktop.org Subject: [PATCH 5/7] dt-bindings: display: st7789v: Add the edt, et028013dma panel compatible Date: Fri, 9 Jun 2023 16:59:49 +0200 Message-Id: <20230609145951.853533-6-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609145951.853533-1-miquel.raynal@bootlin.com> References: <20230609145951.853533-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Krzysztof Kozlowski , Rob Herring , Thomas Petazzoni , Miquel Raynal Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The ST7789V LCD controller is also embedded in the ET028013DMA panel. In fact, "sitronix,st7789v" might not be totally relevant alone as most of the time -if not all- the LCD controller will always be packaged into a display with its own physical properties. Let's keep "sitronix,st7789v" valid alone for backward compatibility, but we should definitely provide two compatibles to fully describe such panel, so let's expect to have both when describing a panel such as the EDT ET028013DMA. Signed-off-by: Miquel Raynal --- .../bindings/display/panel/sitronix,st7789v.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/display/panel/sitronix,st7789v.yaml b/Documentation/devicetree/bindings/display/panel/sitronix,st7789v.yaml index d984b59daa4a..d4c8af9a973d 100644 --- a/Documentation/devicetree/bindings/display/panel/sitronix,st7789v.yaml +++ b/Documentation/devicetree/bindings/display/panel/sitronix,st7789v.yaml @@ -15,7 +15,12 @@ allOf: properties: compatible: - const: sitronix,st7789v + oneOf: + - items: + - enum: + - edt,et028013dma + - const: sitronix,st7789v + - const: sitronix,st7789v reg: true reset-gpios: true From patchwork Fri Jun 9 14:59:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 13274076 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9ECCAC7EE29 for ; Fri, 9 Jun 2023 15:00:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 54B5B10E6BF; Fri, 9 Jun 2023 15:00:07 +0000 (UTC) Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::221]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5DCB810E07D for ; Fri, 9 Jun 2023 15:00:04 +0000 (UTC) X-GND-Sasl: miquel.raynal@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1686322803; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x0Ol7r2bSGZjgU05xeiKYdfnfAnDr0eHIQSuJwPZLwg=; b=LN37CM19UQxIT8tPsPiMiTQEyBOyMqRAU9tI/6oDGyfmTztCyPwP0b8xsyvHZg1k/T7gXL 8xoh6y/xmq3W+S1p7gRJg8AIRC7yKT1DyOXFLjmjL+qB4rEVWoBgSguZeO1c/yxOkG+nK4 lBOpqiaQ3znrEm+zTYrCdHpqMeKag2X55vrCCG+TBPAjOi61249QyXGmrT1X+ManGYYaP/ L6YJSv4AuCJWL9pKiqdHYm28aNMZesPmcKAamMYKK92eq4iaBdkoT8KesA/gcmd/BsBnbf aL7IVUHs/so4dvyhRCxNRrp+z7z1wnK4a94KCgRqSn8uRybzM8wcuw2BD9Wteg== X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 4E621240004; Fri, 9 Jun 2023 15:00:00 +0000 (UTC) From: Miquel Raynal To: Thierry Reding , Sam Ravnborg , David Airlie , Daniel Vetter , Maxime Ripard , dri-devel@lists.freedesktop.org Subject: [PATCH 6/7] drm/panel: sitronix-st7789v: Add EDT ET028013DMA panel support Date: Fri, 9 Jun 2023 16:59:50 +0200 Message-Id: <20230609145951.853533-7-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609145951.853533-1-miquel.raynal@bootlin.com> References: <20230609145951.853533-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Krzysztof Kozlowski , Rob Herring , Thomas Petazzoni , Miquel Raynal Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This panel from Emerging Display Technologies Corporation features an ST7789V2 panel inside which is almost identical to what the Sitronix panel driver supports. In practice, the module physical size is specific, and experiments show that the display will malfunction if any of the following situation occurs: * Pixel clock is above 3MHz * Pixel clock is not inverted I could not properly identify the reasons behind these failures, scope captures show valid input signals. Signed-off-by: Miquel Raynal --- .../gpu/drm/panel/panel-sitronix-st7789v.c | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c index 212bccc31804..7de192a3a8aa 100644 --- a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c +++ b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c @@ -30,7 +30,8 @@ #define ST7789V_RGBCTRL_RCM(n) (((n) & 3) << 5) #define ST7789V_RGBCTRL_VSYNC_HIGH BIT(3) #define ST7789V_RGBCTRL_HSYNC_HIGH BIT(2) -#define ST7789V_RGBCTRL_PCLK_HIGH BIT(1) +#define ST7789V_RGBCTRL_PCLK_FALLING BIT(1) +#define ST7789V_RGBCTRL_PCLK_RISING 0 #define ST7789V_RGBCTRL_VBP(n) ((n) & 0x7f) #define ST7789V_RGBCTRL_HBP(n) ((n) & 0x1f) @@ -117,6 +118,7 @@ struct st7789v_panel_info { u16 width_mm; u16 height_mm; u32 bus_format; + u32 bus_flags; }; struct st7789v { @@ -175,6 +177,18 @@ static const struct drm_display_mode default_mode = { .vtotal = 320 + 8 + 4 + 4, }; +static const struct drm_display_mode slow_mode = { + .clock = 3000, + .hdisplay = 240, + .hsync_start = 240 + 38, + .hsync_end = 240 + 38 + 10, + .htotal = 240 + 38 + 10 + 10, + .vdisplay = 320, + .vsync_start = 320 + 8, + .vsync_end = 320 + 8 + 4, + .vtotal = 320 + 8 + 4 + 4, +}; + static int st7789v_get_modes(struct drm_panel *panel, struct drm_connector *connector) { @@ -197,6 +211,7 @@ static int st7789v_get_modes(struct drm_panel *panel, connector->display_info.width_mm = panel_info->width_mm; connector->display_info.height_mm = panel_info->height_mm; + connector->display_info.bus_flags = panel_info->bus_flags; drm_display_info_set_bus_formats(&connector->display_info, &panel_info->bus_format, 1); @@ -206,8 +221,13 @@ static int st7789v_get_modes(struct drm_panel *panel, static int st7789v_prepare(struct drm_panel *panel) { struct st7789v *ctx = panel_to_st7789v(panel); + const struct st7789v_panel_info *panel_info = ctx->panel_info; + u8 pck = ST7789V_RGBCTRL_PCLK_FALLING; int ret; + if (panel_info->bus_flags & DRM_BUS_FLAG_PIXDATA_SAMPLE_POSEDGE) + pck = ST7789V_RGBCTRL_PCLK_RISING; + ret = regulator_enable(ctx->power); if (ret) return ret; @@ -321,7 +341,7 @@ static int st7789v_prepare(struct drm_panel *panel) ST7789V_RGBCTRL_RCM(2) | ST7789V_RGBCTRL_VSYNC_HIGH | ST7789V_RGBCTRL_HSYNC_HIGH | - ST7789V_RGBCTRL_PCLK_HIGH)); + pck)); ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_RGBCTRL_VBP(8))); ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_RGBCTRL_HBP(20))); @@ -422,14 +442,24 @@ static const struct st7789v_panel_info st7789v_info = { .bus_format = MEDIA_BUS_FMT_RGB666_1X18, }; +static const struct st7789v_panel_info et028013dma_info = { + .display_mode = &slow_mode, + .width_mm = 43, + .height_mm = 58, + .bus_format = MEDIA_BUS_FMT_RGB666_1X18, + .bus_flags = DRM_BUS_FLAG_PIXDATA_SAMPLE_POSEDGE, +}; + static const struct of_device_id st7789v_of_match[] = { { .compatible = "sitronix,st7789v", .data = &st7789v_info }, + { .compatible = "edt,et028013dma", .data = &et028013dma_info }, { } }; MODULE_DEVICE_TABLE(of, st7789v_of_match); static const struct spi_device_id st7789v_ids[] = { { "st7789v", }, + { "et028013dma", }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(spi, st7789v_ids); From patchwork Fri Jun 9 14:59:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 13274080 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 49A21C7EE29 for ; Fri, 9 Jun 2023 15:00:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1E2CB10E6C1; Fri, 9 Jun 2023 15:00:17 +0000 (UTC) Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::221]) by gabe.freedesktop.org (Postfix) with ESMTPS id DD3B410E6C1 for ; Fri, 9 Jun 2023 15:00:10 +0000 (UTC) X-GND-Sasl: miquel.raynal@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1686322809; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IHdWZ/LF6LZj1Fecr8t0A5xeUUG4Fy7gytd6NnGPbpI=; b=b2Wz8H6JxE5R9I/FVcOC5BClLZkgmxcrmSMTkluWopssooQF9z2zg6hnaerRA4rT7Udosv Ouf2qNFIGzsny6soYrhyAQ+5A3qAQyLoGOdvnCLF0WPT21UjXeDNYOs7blX96FDmDAgW/7 4gyUj4bxRKaatGWyE9bFKWfiYVGcKfDswoAMq7TpRIKdWJjdcacUf1mZ9kLjng9SYTLRiY xvdOqq8Cdy67HUUxhZoy7+67w4CTJwUlAgUiuFkN3ShrlSkk4hCI5NJ1mUFiwbrJ3tl8ot +NJfdZeY6tGpiybIT6K1Gl2XIwmUH9CqMuPaOIHZsP4DmBZzQNLmILBgVi7Bug== X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id C04AA240013; Fri, 9 Jun 2023 15:00:03 +0000 (UTC) From: Miquel Raynal To: Thierry Reding , Sam Ravnborg , David Airlie , Daniel Vetter , Maxime Ripard , dri-devel@lists.freedesktop.org Subject: [PATCH 7/7] drm/panel: sitronix-st7789v: Check display ID Date: Fri, 9 Jun 2023 16:59:51 +0200 Message-Id: <20230609145951.853533-8-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609145951.853533-1-miquel.raynal@bootlin.com> References: <20230609145951.853533-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Krzysztof Kozlowski , Rob Herring , Thomas Petazzoni , Miquel Raynal Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" A very basic debugging rule when a device is connected for the first time is to access a read-only register which contains known data in order to ensure the communication protocol is properly working. This driver lacked any read helper which is often a critical peace for fastening bring-ups. Add a read helper and use it to verify the communication with the panel is working as soon as possible in order to fail early if this is not the case. Signed-off-by: Miquel Raynal Acked-by: Sam Ravnborg --- .../gpu/drm/panel/panel-sitronix-st7789v.c | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c index 7de192a3a8aa..fb21d52a7a63 100644 --- a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c +++ b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c @@ -113,6 +113,9 @@ return val; \ } while (0) +#define ST7789V_IDS { 0x85, 0x85, 0x52 } +#define ST7789V_IDS_SIZE 3 + struct st7789v_panel_info { const struct drm_display_mode *display_mode; u16 width_mm; @@ -165,6 +168,77 @@ static int st7789v_write_data(struct st7789v *ctx, u8 cmd) return st7789v_spi_write(ctx, ST7789V_DATA, cmd); } +static int st7789v_read_data(struct st7789v *ctx, u8 cmd, u8 *buf, + unsigned int len) +{ + struct spi_transfer xfer[2] = { }; + struct spi_message msg; + u16 txbuf = ((ST7789V_COMMAND & 1) << 8) | cmd; + u16 rxbuf[4] = {}; + u8 bit9 = 0; + int ret, i; + + switch (len) { + case 1: + case 3: + case 4: + break; + default: + return -EOPNOTSUPP; + } + + spi_message_init(&msg); + + xfer[0].tx_buf = &txbuf; + xfer[0].len = sizeof(txbuf); + spi_message_add_tail(&xfer[0], &msg); + + xfer[1].rx_buf = rxbuf; + xfer[1].len = len * 2; + spi_message_add_tail(&xfer[1], &msg); + + ret = spi_sync(ctx->spi, &msg); + if (ret) + return ret; + + for (i = 0; i < len; i++) { + buf[i] = rxbuf[i] >> i | (bit9 << (9 - i)); + if (i) + bit9 = rxbuf[i] & GENMASK(i - 1, 0); + } + + return 0; +} + +static int st7789v_check_id(struct drm_panel *panel) +{ + const u8 st7789v_ids[ST7789V_IDS_SIZE] = ST7789V_IDS; + struct st7789v *ctx = panel_to_st7789v(panel); + bool invalid_ids = false; + int ret, i; + u8 ids[3]; + + ret = st7789v_read_data(ctx, MIPI_DCS_GET_DISPLAY_ID, ids, ST7789V_IDS_SIZE); + if (ret) { + dev_err(panel->dev, "Failed to read IDs\n"); + return ret; + } + + for (i = 0; i < ST7789V_IDS_SIZE; i++) { + if (ids[i] != st7789v_ids[i]) { + invalid_ids = true; + break; + } + } + + if (invalid_ids) { + dev_err(panel->dev, "Unrecognized panel IDs"); + return -EIO; + } + + return 0; +} + static const struct drm_display_mode default_mode = { .clock = 7000, .hdisplay = 240, @@ -237,6 +311,10 @@ static int st7789v_prepare(struct drm_panel *panel) gpiod_set_value(ctx->reset, 0); msleep(120); + ret = st7789v_check_id(panel); + if (ret) + return ret; + ST7789V_TEST(ret, st7789v_write_command(ctx, MIPI_DCS_EXIT_SLEEP_MODE)); /* We need to wait 120ms after a sleep out command */