From patchwork Mon Nov 22 06:52:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 12693265 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 0EA62C433EF for ; Mon, 22 Nov 2021 06:55:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dc62DuW/LtBBNj+bmRVL80qKo0Kprb60UiUpcJJ6id4=; b=hytC/eTieNHupP Bjr9SI8UsQQ/I+LrHBGcxDRju+qJHFSujd1yas0cKaeBIRcIRfvx3hoC+aRm8QEYhFxxaq1bmIrG1 9iPKU2+AwEyNdFxJk6ZoDzaYXAe38Kr5+d9T82fqdSFTtQyLTE/zmuaqZL1gldU0D4VVsmmHJFOHT rpos8lzVjSIncIBPFQxGqAl0zCGrmyFwD8GM6b1TKDNl/AtY4W34Ctrp10VqsNsUCZr/VHQyhz4tI mxnzNYf8JznNqtjqwFc1vZyYOjGEqf6nfy0uSEtLnWCqtPiAIwImBcwiLtBmhfXnLOSysV9LZ5sVT CqsRfjfdUT9IOUZlfFjw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mp3Ct-00EzKH-D7; Mon, 22 Nov 2021 06:53:39 +0000 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mp3Cg-00EzG0-BP for linux-arm-kernel@lists.infradead.org; Mon, 22 Nov 2021 06:53:28 +0000 Received: by mail-pj1-x1036.google.com with SMTP id iq11so12990676pjb.3 for ; Sun, 21 Nov 2021 22:53:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pkAuQsnw7QbljD+R+QwG40X6FsjkHXAAeazRxjeItzs=; b=o6wWL1yjsAfCZDtrmIbaY0nuTaL2UJLOiEhMmhAOJ9xqLCdMsgo6gmQ2GUb+z2NXOh Z5iAUQ/WRbJcEEUaf7WKkrhsz2NPSn8ukbh1GyoVOHbgsMCwXB8sdOaeDGedwh1cM2rB J/Nn7VHtHzyMkOcBdwJeTzo2q92ni2zJHp7U0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pkAuQsnw7QbljD+R+QwG40X6FsjkHXAAeazRxjeItzs=; b=B33mgZxrwlnbBGKrJUo1DX8mGnMezzkQ7kef0KYf4zgj+CkGzU9ZjCsdnjhy5K4XH6 mnEHOA7rVAVjTQLeUbEpU8+kq1NRB6+2u0ixZQbldLIaGlCqgoVgbVf7mvM8y8eIbNoP sqAgyVbrg0cenFfda1+EiyI+UADSY14fGmllIpsjZRh9AM9d6YWralHmEXKuTuRBc2xC ZWm7G7vpoCeBXi1efAu0cCIQxJPpRN0QWLCTHEQG3pLsha/m0VCpebsxYQ9KEMhwN3PP 8ux6S1ObRwASK9dyK+BeGTk+zptSKJQ0W4j7BD1m4000r+TCJFknB/MJvVuT3UMHptw4 wKlw== X-Gm-Message-State: AOAM532pnmqVNyulqF6IpGw+OpoKfZ3Zz0ZdzeXgQxV6E8xxbXjp3tFE 4KWeUZ2HExBv0+SvYJrTxalOiw== X-Google-Smtp-Source: ABdhPJxIxHzXyA9fRBFwfjRKHrDL6Qh62vnmKobqJE/aiLSGG4qGq+lY9nu34E96pmmtwbIxYdX7qg== X-Received: by 2002:a17:90a:c08a:: with SMTP id o10mr28275591pjs.44.1637564005280; Sun, 21 Nov 2021 22:53:25 -0800 (PST) Received: from localhost.localdomain ([2405:201:c00a:a0a9:eed6:c913:819a:3850]) by smtp.gmail.com with ESMTPSA id a8sm7935904pfv.176.2021.11.21.22.53.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Nov 2021 22:53:24 -0800 (PST) From: Jagan Teki To: Maxime Ripard , Chen-Yu Tsai , Laurent Pinchart , Neil Armstrong , Robert Foss , Sam Ravnborg Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@googlegroups.com, linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH v5 1/7] drm: sun4i: dsi: Drop DRM bind race with bridge attach Date: Mon, 22 Nov 2021 12:22:17 +0530 Message-Id: <20211122065223.88059-2-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211122065223.88059-1-jagan@amarulasolutions.com> References: <20211122065223.88059-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211121_225326_417024_5E2DB180 X-CRM114-Status: GOOD ( 19.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Existing host driver will keep looking for DRM pointer in sun6i_dsi_attach and defers even if the particular DSI device is found for the first time. Meanwhile it triggers the bind callback and gets the DRM pointer and then continues the sun6i_dsi_attach. This makes a deadlock situation if sun6i_dsi_attach is trying to find the bridge. If interface bridge is trying to call host attach, then host sun6i_dsi_attach is trying to find bridge and defers the interface bridge even if it found the bridge as bind callback does not complete at the movement. So, this sun6i_dsi_attach defers interface bridge and triggers the bind callback and tries to attach the bridge with a bridge pointer which is not available at the moment. Eventually these callbacks are triggered recursively, as sun6i_dsi_attach defers interface bridge and bind callback defers sun6i_dsi_attach due to invalid bridge ponter. This patch prevents this situation by probing all DSI devices on the pipeline first and then triggers the bind callback by dropping exing DRM binding logic. Signed-off-by: Jagan Teki --- Changes for v5: - new patch drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 10 +--------- drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h | 1 - 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c index 527c7b2474da..4bdcce8f1d84 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c @@ -967,14 +967,10 @@ static int sun6i_dsi_attach(struct mipi_dsi_host *host, if (IS_ERR(panel)) return PTR_ERR(panel); - if (!dsi->drm || !dsi->drm->registered) - return -EPROBE_DEFER; dsi->panel = panel; dsi->device = device; - drm_kms_helper_hotplug_event(dsi->drm); - dev_info(host->dev, "Attached device %s\n", device->name); return 0; @@ -988,8 +984,6 @@ static int sun6i_dsi_detach(struct mipi_dsi_host *host, dsi->panel = NULL; dsi->device = NULL; - drm_kms_helper_hotplug_event(dsi->drm); - return 0; } @@ -1077,8 +1071,6 @@ static int sun6i_dsi_bind(struct device *dev, struct device *master, drm_connector_attach_encoder(&dsi->connector, &dsi->encoder); - dsi->drm = drm; - return 0; err_cleanup_connector: @@ -1091,7 +1083,7 @@ static void sun6i_dsi_unbind(struct device *dev, struct device *master, { struct sun6i_dsi *dsi = dev_get_drvdata(dev); - dsi->drm = NULL; + drm_encoder_cleanup(&dsi->encoder); } static const struct component_ops sun6i_dsi_ops = { diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h index c863900ae3b4..61e88ea6044d 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h @@ -29,7 +29,6 @@ struct sun6i_dsi { struct device *dev; struct mipi_dsi_device *device; - struct drm_device *drm; struct drm_panel *panel; }; From patchwork Mon Nov 22 06:52:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 12693266 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 C43B7C433EF for ; Mon, 22 Nov 2021 06:55:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1o4M/zf39785nlwf2HpZLRiziq2rzs3/cKcA81eHSp0=; b=a84efDTAX3Zg9t j88Dg8Cdf+aLtRytMYS2lr1JUHQK2nqjB4aVSflcJBDYZQKg/4lT5gwas5mgd4oh3oJZJbn/YEDnm NxeMamkkH4/Z+lu9C0VTOsy59Yfho1G3W91wWk6fMORyPMEYV82ZM31b6JX16T40rQ+D2fndcrP8H 5lIA/iHzA+yIcXVmi8I0zknxSBMMXnGKPlwLy1p9lfJWB+fIyi7OA3jIN5cKYzv2bF7ZDRWGYlogZ 4+65JMQYwN8OK31njWuMjFOpCuBfDUN0Sdvi5TZ4oyP5xzS4i9i+oCK2IxWyOFz10UQJ5nXDx9TjC D+bQ3KnGg4ubT8N+Fmxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mp3D5-00EzPJ-KB; Mon, 22 Nov 2021 06:53:51 +0000 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mp3Ck-00EzHN-Pv for linux-arm-kernel@lists.infradead.org; Mon, 22 Nov 2021 06:53:32 +0000 Received: by mail-pj1-x102b.google.com with SMTP id iq11so12990862pjb.3 for ; Sun, 21 Nov 2021 22:53:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CqcHDPI5j3BreTYZLwb22+vjVwocrgSYWGCGb32eVhw=; b=QPVgrYGL7PI722lud6ufHHXk8XVPHAANuzPawnzxM0KCf/QE52IvTk8L5ZYpM0KSRz itRLt+uivyK9N5BnfrNhn9B/iVlismf5YHAR4+uk/bUZaVz2uU2cCS8gxnIBT00Uufw3 4u7CUd7+UsesOgQLin+fXvlVt6kVw5WKLJflc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CqcHDPI5j3BreTYZLwb22+vjVwocrgSYWGCGb32eVhw=; b=lcjHeV0Ef/koD1D+Rc5qO0UIO7HozgXejWrlRYYfGvjb8BFPrTTOr3x8Vv0gk3vVyi xj9C9j6/CuDbFT38Iq1PL5MqI/usSbOgsbDns00btIVikuj43lPm2pvowdeVBiRR6oAD WBd309qbn8hTRkpd/JMa8catDUIxlwJ+ukITSx6Fag1gne/XPE2t+QJaiMWjC2KRSCmL 5vEBH6+9SvpRklShuv+w0t9aVIRf5Y2LHuN263V9VIpb90fZT1ikyGQ/59mkaNm50IWC 2wuZr9WDfqMqVkIDzbxg/3PNt6J12pp/4joyRgae408Phqyf8kMTBLVMd/JaH2tzgWOD jfFw== X-Gm-Message-State: AOAM530yiyr0zRoyO6bmnZh/TphAUBWbZT7ylYCPdJSwyCW1bTqI6HNB K4c2SyXISfS1/xGjetPY1RQhvw== X-Google-Smtp-Source: ABdhPJzChYuIpTslj7ocMb+xUnf1Ejaew9r9ZSsFINiB4NIMgYqLG9RtizeXTUH/IXUJnLi6kUgyHw== X-Received: by 2002:a17:903:2091:b0:142:8567:e794 with SMTP id d17-20020a170903209100b001428567e794mr105544020plc.50.1637564009666; Sun, 21 Nov 2021 22:53:29 -0800 (PST) Received: from localhost.localdomain ([2405:201:c00a:a0a9:eed6:c913:819a:3850]) by smtp.gmail.com with ESMTPSA id a8sm7935904pfv.176.2021.11.21.22.53.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Nov 2021 22:53:29 -0800 (PST) From: Jagan Teki To: Maxime Ripard , Chen-Yu Tsai , Laurent Pinchart , Neil Armstrong , Robert Foss , Sam Ravnborg Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@googlegroups.com, linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH v5 2/7] drm: sun4i: dsi: Add component only once DSI device attached Date: Mon, 22 Nov 2021 12:22:18 +0530 Message-Id: <20211122065223.88059-3-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211122065223.88059-1-jagan@amarulasolutions.com> References: <20211122065223.88059-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211121_225330_882497_845C0259 X-CRM114-Status: GOOD ( 20.27 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Having component_add for running all drm bind callbacks returns error or unbound due to chain of DSI devices connected across bridge topology on a display pipeline. In a typical bridge oriented display pipeline where the host is connected to the bridge converter and that indeed connected to a panel. DRM => SUN6I DSI Host => Chipone ICN6211 => BananaPi Panel The bridge converter is looking for a panel to probe first and then attach the host. The host attach is looking for a bridge converter to probe and preserve bridge pointer, at this movement the host is trying to bind the all callbacks and one of the bind callback in the DSI host is trying to find the bridge using the bridge pointer in sun6i_dsi_attach call. chipone_probe().start drm_of_find_panel_or_bridge mipi_dsi_attach sun6i_dsi_attach drm_of_find_panel_or_bridge chipone_probe().done sun6i_dsi_probe().start mipi_dsi_host_register component_add sun6i_dsi_probe().done However, the movement when panel defers the probe, will make the bridge converter defer the host attach call which eventually found a NULL bridge pointer during DSI component bind callback. So, in order to prevent this scenario of binding invalid bridge, wait for DSI devices on the pipeline to probe first and start the binding process by moving component_add in host probe to attach call. chipone_probe().start drm_of_find_panel_or_bridge mipi_dsi_attach sun6i_dsi_attach drm_of_find_panel_or_bridge component_add chipone_probe().done sun6i_dsi_probe().start mipi_dsi_host_register sun6i_dsi_probe().done Signed-off-by: Jagan Teki --- Changes for v5: - new patch drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 119 +++++++++++++------------ 1 file changed, 60 insertions(+), 59 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c index 4bdcce8f1d84..43d9c9e5198d 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c @@ -959,11 +959,62 @@ static int sun6i_dsi_dcs_read(struct sun6i_dsi *dsi, return 1; } +static int sun6i_dsi_bind(struct device *dev, struct device *master, + void *data) +{ + struct drm_device *drm = data; + struct sun6i_dsi *dsi = dev_get_drvdata(dev); + int ret; + + drm_encoder_helper_add(&dsi->encoder, + &sun6i_dsi_enc_helper_funcs); + ret = drm_simple_encoder_init(drm, &dsi->encoder, + DRM_MODE_ENCODER_DSI); + if (ret) { + dev_err(dsi->dev, "Couldn't initialise the DSI encoder\n"); + return ret; + } + dsi->encoder.possible_crtcs = BIT(0); + + drm_connector_helper_add(&dsi->connector, + &sun6i_dsi_connector_helper_funcs); + ret = drm_connector_init(drm, &dsi->connector, + &sun6i_dsi_connector_funcs, + DRM_MODE_CONNECTOR_DSI); + if (ret) { + dev_err(dsi->dev, + "Couldn't initialise the DSI connector\n"); + goto err_cleanup_connector; + } + + drm_connector_attach_encoder(&dsi->connector, &dsi->encoder); + + return 0; + +err_cleanup_connector: + drm_encoder_cleanup(&dsi->encoder); + return ret; +} + +static void sun6i_dsi_unbind(struct device *dev, struct device *master, + void *data) +{ + struct sun6i_dsi *dsi = dev_get_drvdata(dev); + + drm_encoder_cleanup(&dsi->encoder); +} + +static const struct component_ops sun6i_dsi_ops = { + .bind = sun6i_dsi_bind, + .unbind = sun6i_dsi_unbind, +}; + static int sun6i_dsi_attach(struct mipi_dsi_host *host, struct mipi_dsi_device *device) { struct sun6i_dsi *dsi = host_to_sun6i_dsi(host); struct drm_panel *panel = of_drm_find_panel(device->dev.of_node); + int ret; if (IS_ERR(panel)) return PTR_ERR(panel); @@ -973,6 +1024,13 @@ static int sun6i_dsi_attach(struct mipi_dsi_host *host, dev_info(host->dev, "Attached device %s\n", device->name); + ret = component_add(dsi->dev, &sun6i_dsi_ops); + if (ret) { + dev_err(dsi->dev, "Couldn't register our component\n"); + mipi_dsi_host_unregister(&dsi->host); + return ret; + } + return 0; } @@ -984,6 +1042,8 @@ static int sun6i_dsi_detach(struct mipi_dsi_host *host, dsi->panel = NULL; dsi->device = NULL; + component_del(dsi->dev, &sun6i_dsi_ops); + return 0; } @@ -1041,56 +1101,6 @@ static const struct regmap_config sun6i_dsi_regmap_config = { .name = "mipi-dsi", }; -static int sun6i_dsi_bind(struct device *dev, struct device *master, - void *data) -{ - struct drm_device *drm = data; - struct sun6i_dsi *dsi = dev_get_drvdata(dev); - int ret; - - drm_encoder_helper_add(&dsi->encoder, - &sun6i_dsi_enc_helper_funcs); - ret = drm_simple_encoder_init(drm, &dsi->encoder, - DRM_MODE_ENCODER_DSI); - if (ret) { - dev_err(dsi->dev, "Couldn't initialise the DSI encoder\n"); - return ret; - } - dsi->encoder.possible_crtcs = BIT(0); - - drm_connector_helper_add(&dsi->connector, - &sun6i_dsi_connector_helper_funcs); - ret = drm_connector_init(drm, &dsi->connector, - &sun6i_dsi_connector_funcs, - DRM_MODE_CONNECTOR_DSI); - if (ret) { - dev_err(dsi->dev, - "Couldn't initialise the DSI connector\n"); - goto err_cleanup_connector; - } - - drm_connector_attach_encoder(&dsi->connector, &dsi->encoder); - - return 0; - -err_cleanup_connector: - drm_encoder_cleanup(&dsi->encoder); - return ret; -} - -static void sun6i_dsi_unbind(struct device *dev, struct device *master, - void *data) -{ - struct sun6i_dsi *dsi = dev_get_drvdata(dev); - - drm_encoder_cleanup(&dsi->encoder); -} - -static const struct component_ops sun6i_dsi_ops = { - .bind = sun6i_dsi_bind, - .unbind = sun6i_dsi_unbind, -}; - static int sun6i_dsi_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -1172,16 +1182,8 @@ static int sun6i_dsi_probe(struct platform_device *pdev) goto err_unprotect_clk; } - ret = component_add(&pdev->dev, &sun6i_dsi_ops); - if (ret) { - dev_err(dev, "Couldn't register our component\n"); - goto err_remove_dsi_host; - } - return 0; -err_remove_dsi_host: - mipi_dsi_host_unregister(&dsi->host); err_unprotect_clk: clk_rate_exclusive_put(dsi->mod_clk); err_attach_clk: @@ -1195,7 +1197,6 @@ static int sun6i_dsi_remove(struct platform_device *pdev) struct device *dev = &pdev->dev; struct sun6i_dsi *dsi = dev_get_drvdata(dev); - component_del(&pdev->dev, &sun6i_dsi_ops); mipi_dsi_host_unregister(&dsi->host); clk_rate_exclusive_put(dsi->mod_clk); From patchwork Mon Nov 22 06:52:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 12693267 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 CC439C433F5 for ; Mon, 22 Nov 2021 06:55:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=l/tJaf9J7AR69xQLu5ZcGwCDDM5L3SUDqaRg4VBvI+A=; b=i9zOCJLpaojR4G cEtlbsbO3GTaPWEdcAw43Qr46up+YvuFFLtv8dl3cbW3wb3kmFV0XhgdjYf8zyPNn42IWWC6TwiHH mTK6N+z/oKmnZ1Fvj7ocw0TSvS2Ksr2YhUtVOtsqQpif7bsVEKGE0KqFXaffSohke2kQ0NW+qOeMg 6NrMsc8/FXqxQ8eNZudb+Iqz9htlEDjoOOncnp51bFdrXU3N74o/3G4iON3BnzMloFaz9aMSN+IZ1 q2uEY+QGmUPOVZPP3UjuVch5A9/pYCuanxAnSbev6D2PUaQ7wbistVQCeZjxAnFXCWyjrITluj8A3 qArVtz9T5PAsctFOXLTA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mp3DJ-00EzTi-BG; Mon, 22 Nov 2021 06:54:05 +0000 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mp3Co-00EzIs-VO for linux-arm-kernel@lists.infradead.org; Mon, 22 Nov 2021 06:53:36 +0000 Received: by mail-pl1-x635.google.com with SMTP id v19so13247537plo.7 for ; Sun, 21 Nov 2021 22:53:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Bn7OMxc+0lRaKOfEDxXP5eAln8VQKH/m4PmaTGfkaqk=; b=h7ZUfJH9QcZu6YBVtU08V7SoBc3BG0NG/AuSC+Oz9k54sbNgD7IhUtPPH0DjflByij XgdDmmIUMZTOU9DZc/Q8ufJsdl5Er9UHjDFuX5WTvlnA6o1H10UtdwGx8JPlBBGKZjPi Koe/w9IzZE9iASScariRw4wagsbx52TtTYYzU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Bn7OMxc+0lRaKOfEDxXP5eAln8VQKH/m4PmaTGfkaqk=; b=YQT5AbLRmSCt31NE95qN6mndUBEn8CQPxxncbv4B+MO84r+r3AOzHAjhOfeAA0ZXei sbPt3oDfVFapDNfuxYc3RJJaHKUH0rKZq/ay9+nB08usI5U1u7Rc5nXE39lvjRKU0s3O RuAQvnCnRBMhoxTQk3rBkow/4MGk3UU9z9s5tK8gWcQUpQHfAE0+9uTkLATA+L9yz6vY 4TO0yPDjoM6TOGAU+2YGGAsraKzPL2QYql2DqgYPsOWfk+ASM2Cj0MUfekT15Hw6OImd g/2W37pVcaMlEDlRrdM37UmI4nUaNW3ZRLHI42XxTrwLtqQTcSVgOaU8MI/oRIgsKOBx k7qA== X-Gm-Message-State: AOAM5322TysS3LsSaUIBXTBPFxV/FRRRHXBuGkMrJEf62PZttgZ9EgYM JwdcZXMQLkYuDYu9OaSIWHuyBA== X-Google-Smtp-Source: ABdhPJwlxAdQFaIayQb58d7c2hV7+X3Ztxqsq+wNxCyJhqGAcQhAMz6nq2YDzb3X7sL6+1/v6trP8A== X-Received: by 2002:a17:90b:350c:: with SMTP id ls12mr28224649pjb.197.1637564013943; Sun, 21 Nov 2021 22:53:33 -0800 (PST) Received: from localhost.localdomain ([2405:201:c00a:a0a9:eed6:c913:819a:3850]) by smtp.gmail.com with ESMTPSA id a8sm7935904pfv.176.2021.11.21.22.53.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Nov 2021 22:53:33 -0800 (PST) From: Jagan Teki To: Maxime Ripard , Chen-Yu Tsai , Laurent Pinchart , Neil Armstrong , Robert Foss , Sam Ravnborg Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@googlegroups.com, linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH v5 3/7] drm: sun4i: dsi: Convert to bridge driver Date: Mon, 22 Nov 2021 12:22:19 +0530 Message-Id: <20211122065223.88059-4-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211122065223.88059-1-jagan@amarulasolutions.com> References: <20211122065223.88059-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211121_225335_046699_76E7883A X-CRM114-Status: GOOD ( 22.36 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Some display panels would come up with a non-DSI output, those can have an option to connect the DSI host by means of interface bridge converter. This DSI to non-DSI interface bridge converter would requires DSI Host to handle drm bridge functionalities in order to DSI Host to Interface bridge. This patch convert the existing to a drm bridge driver with a built-in encoder support for compatibility with existing component drivers. Signed-off-by: Jagan Teki --- Changes for v5: - add atomic APIs - find host and device variant DSI devices. Changes for v4, v3: - none drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 112 ++++++++++++++++++++----- drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h | 7 ++ 2 files changed, 96 insertions(+), 23 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c index 43d9c9e5198d..a6a272b55f77 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -713,10 +714,11 @@ static int sun6i_dsi_start(struct sun6i_dsi *dsi, return 0; } -static void sun6i_dsi_encoder_enable(struct drm_encoder *encoder) +static void sun6i_dsi_bridge_atomic_enable(struct drm_bridge *bridge, + struct drm_bridge_state *old_bridge_state) { - struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode; - struct sun6i_dsi *dsi = encoder_to_sun6i_dsi(encoder); + struct sun6i_dsi *dsi = bridge_to_sun6i_dsi(bridge); + struct drm_display_mode *mode = &bridge->encoder->crtc->state->adjusted_mode; struct mipi_dsi_device *device = dsi->device; union phy_configure_opts opts = { }; struct phy_configure_opts_mipi_dphy *cfg = &opts.mipi_dphy; @@ -772,6 +774,9 @@ static void sun6i_dsi_encoder_enable(struct drm_encoder *encoder) if (dsi->panel) drm_panel_prepare(dsi->panel); + if (dsi->next_bridge) + dsi->next_bridge->funcs->atomic_pre_enable(dsi->next_bridge, old_bridge_state); + /* * FIXME: This should be moved after the switch to HS mode. * @@ -787,6 +792,9 @@ static void sun6i_dsi_encoder_enable(struct drm_encoder *encoder) if (dsi->panel) drm_panel_enable(dsi->panel); + if (dsi->next_bridge) + dsi->next_bridge->funcs->atomic_enable(dsi->next_bridge, old_bridge_state); + sun6i_dsi_start(dsi, DSI_START_HSC); udelay(1000); @@ -794,15 +802,19 @@ static void sun6i_dsi_encoder_enable(struct drm_encoder *encoder) sun6i_dsi_start(dsi, DSI_START_HSD); } -static void sun6i_dsi_encoder_disable(struct drm_encoder *encoder) +static void sun6i_dsi_bridge_atomic_disable(struct drm_bridge *bridge, + struct drm_bridge_state *old_bridge_state) { - struct sun6i_dsi *dsi = encoder_to_sun6i_dsi(encoder); + struct sun6i_dsi *dsi = bridge_to_sun6i_dsi(bridge); DRM_DEBUG_DRIVER("Disabling DSI output\n"); if (dsi->panel) { drm_panel_disable(dsi->panel); drm_panel_unprepare(dsi->panel); + } else if (dsi->next_bridge) { + dsi->next_bridge->funcs->atomic_disable(dsi->next_bridge, old_bridge_state); + dsi->next_bridge->funcs->atomic_post_disable(dsi->next_bridge, old_bridge_state); } phy_power_off(dsi->dphy); @@ -842,9 +854,25 @@ static const struct drm_connector_funcs sun6i_dsi_connector_funcs = { .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, }; -static const struct drm_encoder_helper_funcs sun6i_dsi_enc_helper_funcs = { - .disable = sun6i_dsi_encoder_disable, - .enable = sun6i_dsi_encoder_enable, +static int sun6i_dsi_bridge_attach(struct drm_bridge *bridge, + enum drm_bridge_attach_flags flags) +{ + struct sun6i_dsi *dsi = bridge_to_sun6i_dsi(bridge); + + if (dsi->next_bridge) + return drm_bridge_attach(bridge->encoder, dsi->next_bridge, + NULL, 0); + + return 0; +} + +static const struct drm_bridge_funcs sun6i_dsi_bridge_funcs = { + .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state, + .atomic_reset = drm_atomic_helper_bridge_reset, + .atomic_enable = sun6i_dsi_bridge_atomic_enable, + .atomic_disable = sun6i_dsi_bridge_atomic_disable, + .attach = sun6i_dsi_bridge_attach, }; static u32 sun6i_dsi_dcs_build_pkt_hdr(struct sun6i_dsi *dsi, @@ -966,8 +994,6 @@ static int sun6i_dsi_bind(struct device *dev, struct device *master, struct sun6i_dsi *dsi = dev_get_drvdata(dev); int ret; - drm_encoder_helper_add(&dsi->encoder, - &sun6i_dsi_enc_helper_funcs); ret = drm_simple_encoder_init(drm, &dsi->encoder, DRM_MODE_ENCODER_DSI); if (ret) { @@ -976,18 +1002,26 @@ static int sun6i_dsi_bind(struct device *dev, struct device *master, } dsi->encoder.possible_crtcs = BIT(0); - drm_connector_helper_add(&dsi->connector, - &sun6i_dsi_connector_helper_funcs); - ret = drm_connector_init(drm, &dsi->connector, - &sun6i_dsi_connector_funcs, - DRM_MODE_CONNECTOR_DSI); + ret = drm_bridge_attach(&dsi->encoder, &dsi->bridge, NULL, 0); if (ret) { - dev_err(dsi->dev, - "Couldn't initialise the DSI connector\n"); + dev_err(dsi->dev, "Couldn't attach drm bridge\n"); goto err_cleanup_connector; } - drm_connector_attach_encoder(&dsi->connector, &dsi->encoder); + if (dsi->panel) { + drm_connector_helper_add(&dsi->connector, + &sun6i_dsi_connector_helper_funcs); + ret = drm_connector_init(drm, &dsi->connector, + &sun6i_dsi_connector_funcs, + DRM_MODE_CONNECTOR_DSI); + if (ret) { + dev_err(dsi->dev, + "Couldn't initialise the DSI connector\n"); + goto err_cleanup_connector; + } + + drm_connector_attach_encoder(&dsi->connector, &dsi->encoder); + } return 0; @@ -1013,16 +1047,46 @@ static int sun6i_dsi_attach(struct mipi_dsi_host *host, struct mipi_dsi_device *device) { struct sun6i_dsi *dsi = host_to_sun6i_dsi(host); - struct drm_panel *panel = of_drm_find_panel(device->dev.of_node); + struct device_node *remote = device->dev.of_node; int ret; - if (IS_ERR(panel)) - return PTR_ERR(panel); + if (!of_device_is_available(remote)) { + /** + * I2C interfaced DSI bridges will register DSI host on the + * bridge drivers instead of conventional device. + * + * Those are probed via host of_node instead of device of_node. + */ + remote = of_graph_get_remote_node(host->dev->of_node, 0, 0); + if (!remote) + return -ENODEV; + } + + dsi->panel = of_drm_find_panel(remote); + if (IS_ERR(dsi->panel)) { + dsi->panel = NULL; + + dsi->next_bridge = of_drm_find_bridge(remote); + if (IS_ERR(dsi->next_bridge)) { + dev_err(dsi->dev, "failed to find bridge\n"); + return PTR_ERR(dsi->next_bridge); + } + } else { + dsi->next_bridge = NULL; + } + + of_node_put(remote); - dsi->panel = panel; dsi->device = device; - dev_info(host->dev, "Attached device %s\n", device->name); + dev_info(host->dev, "Attached %s %s\n", + device->name, dsi->panel ? "panel" : "bridge"); + + dsi->bridge.funcs = &sun6i_dsi_bridge_funcs; + dsi->bridge.of_node = dsi->dev->of_node; + dsi->bridge.type = DRM_MODE_CONNECTOR_DSI; + + drm_bridge_add(&dsi->bridge); ret = component_add(dsi->dev, &sun6i_dsi_ops); if (ret) { @@ -1040,9 +1104,11 @@ static int sun6i_dsi_detach(struct mipi_dsi_host *host, struct sun6i_dsi *dsi = host_to_sun6i_dsi(host); dsi->panel = NULL; + dsi->next_bridge = NULL; dsi->device = NULL; component_del(dsi->dev, &sun6i_dsi_ops); + drm_bridge_remove(&dsi->bridge); return 0; } diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h index 61e88ea6044d..d269304691c9 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h @@ -16,6 +16,7 @@ #define SUN6I_DSI_TCON_DIV 4 struct sun6i_dsi { + struct drm_bridge bridge; struct drm_connector connector; struct drm_encoder encoder; struct mipi_dsi_host host; @@ -30,6 +31,7 @@ struct sun6i_dsi { struct device *dev; struct mipi_dsi_device *device; struct drm_panel *panel; + struct drm_bridge *next_bridge; }; static inline struct sun6i_dsi *host_to_sun6i_dsi(struct mipi_dsi_host *host) @@ -37,6 +39,11 @@ static inline struct sun6i_dsi *host_to_sun6i_dsi(struct mipi_dsi_host *host) return container_of(host, struct sun6i_dsi, host); }; +static inline struct sun6i_dsi *bridge_to_sun6i_dsi(struct drm_bridge *bridge) +{ + return container_of(bridge, struct sun6i_dsi, bridge); +} + static inline struct sun6i_dsi *connector_to_sun6i_dsi(struct drm_connector *connector) { return container_of(connector, struct sun6i_dsi, connector); From patchwork Mon Nov 22 06:52:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 12693268 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 D18E8C433EF for ; Mon, 22 Nov 2021 06:55:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=HWK35VRkEWgGMVkL1qeY8aoL6SfTM5GSZ2MtNCO0Fqs=; b=QUD+AYo5jMoGTc 8nkPFTfSFx4IFWClFrk+LNEJVFYQJeAFQeEaTXHia9MsCRm6jqMBLnuwoNWMa/c0IObG5ZIYIEzja aq5+tiRlNHd+rKiK+kSN6lJ/A5RBmbZiGWRNVqMbjVfskJFchooYnNia4JHnQI+n8f8JWUzxOQVkU x73icYqZYE/mQTsmoRUGH1ECtUsRBeKatvZ+rJvhvZRxZKGui8weqmLFIKuJ0VURVMOfB0A5OxRoI wsPuCjPtIwFqadHwk7/deh+sbJLsTO15s4GNFdl1Cktemrkt2pDjmM3OpauiQ5NtnXRnfCHiPXPFb MftZl8IE6r9IMg7RM3Zw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mp3DV-00EzXU-6k; Mon, 22 Nov 2021 06:54:17 +0000 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mp3Ct-00EzKJ-5i for linux-arm-kernel@lists.infradead.org; Mon, 22 Nov 2021 06:53:40 +0000 Received: by mail-pj1-x1029.google.com with SMTP id j5-20020a17090a318500b001a6c749e697so12828338pjb.1 for ; Sun, 21 Nov 2021 22:53:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wJ/t6jM/jyN5QXpQAEFQjSGSqfZWlxA85S7ihcjleN4=; b=bIadhJCzrMKxm03cp/PIBhXn18NNYdZ2YoYDS8LJ/ac/RvjLiQ2Sp7Svd4BZxnoS3g dCiCRuOmctLguhmGiwM9i1tchv8uBY0rw6O+FT0rAt5WiRTILdKeXUHxgqZhsdaGr60A Wvydha/B6xL9nEYr8dbrsNK2YwmuNWXOYj5RM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wJ/t6jM/jyN5QXpQAEFQjSGSqfZWlxA85S7ihcjleN4=; b=145K3SSv0ruwZmvhE+BrJ6nPtvMAm4P71iJ0IPXqQOMfv8cOTc6q4AlgM/ZAHP37Xb 7BVwGKvW9YxLDq9Agv3qK6pFICZX+tiBAQGGIA3MP7WYRYrQJGO1hxOLHlo8Q1Q7xhuf hkcXgjW+nKKwFqhm0Xi3UFL/0/fTuR/oEiDvFqbhwXohiQfi0ZPJUVr3w7ZVSV3MuTQp 0zH6AHmkaWwMxUOUJvtLepaKtj8aNtjaFIcIPjQ2WlOXz4Flvt54QEt4WN6gO4g4S3Qu MYh3lC7IGQgxfeWXnZ+Lt5pEhkEkLxAsE+rVtUkwtcZJc+RoIG7Kk/zvcgIaKbYE1AkE NpdA== X-Gm-Message-State: AOAM531Zn9YuLnrM1qRnqdFZbp7/wwP9Nxia/hcUsC/0haT3T8WmTVbT VAc693BEZB7/xoMzag86w+riCA== X-Google-Smtp-Source: ABdhPJz8UMA5qnotn8CuvwokGv9kesn6itqP05ipiuNNTbry3iobK0F9ZSHrkk/BBXvJzlIi9pSklQ== X-Received: by 2002:a17:90a:e7ca:: with SMTP id kb10mr28171937pjb.8.1637564018014; Sun, 21 Nov 2021 22:53:38 -0800 (PST) Received: from localhost.localdomain ([2405:201:c00a:a0a9:eed6:c913:819a:3850]) by smtp.gmail.com with ESMTPSA id a8sm7935904pfv.176.2021.11.21.22.53.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Nov 2021 22:53:37 -0800 (PST) From: Jagan Teki To: Maxime Ripard , Chen-Yu Tsai , Laurent Pinchart , Neil Armstrong , Robert Foss , Sam Ravnborg Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@googlegroups.com, linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH v5 4/7] drm: sun4i: dsi: Add mode_set function Date: Mon, 22 Nov 2021 12:22:20 +0530 Message-Id: <20211122065223.88059-5-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211122065223.88059-1-jagan@amarulasolutions.com> References: <20211122065223.88059-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211121_225339_253046_8CE2A97D X-CRM114-Status: GOOD ( 16.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Get the display mode settings via mode_set bridge function instead of explicitly de-reference. Signed-off-by: Jagan Teki --- Changes for v5: - new patch drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 12 +++++++++++- drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c index a6a272b55f77..731af31e2bde 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c @@ -718,7 +718,7 @@ static void sun6i_dsi_bridge_atomic_enable(struct drm_bridge *bridge, struct drm_bridge_state *old_bridge_state) { struct sun6i_dsi *dsi = bridge_to_sun6i_dsi(bridge); - struct drm_display_mode *mode = &bridge->encoder->crtc->state->adjusted_mode; + struct drm_display_mode *mode = &dsi->mode; struct mipi_dsi_device *device = dsi->device; union phy_configure_opts opts = { }; struct phy_configure_opts_mipi_dphy *cfg = &opts.mipi_dphy; @@ -854,6 +854,15 @@ static const struct drm_connector_funcs sun6i_dsi_connector_funcs = { .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, }; +static void sun6i_dsi_bridge_mode_set(struct drm_bridge *bridge, + const struct drm_display_mode *mode, + const struct drm_display_mode *adjusted_mode) +{ + struct sun6i_dsi *dsi = bridge_to_sun6i_dsi(bridge); + + drm_mode_copy(&dsi->mode, adjusted_mode); +} + static int sun6i_dsi_bridge_attach(struct drm_bridge *bridge, enum drm_bridge_attach_flags flags) { @@ -872,6 +881,7 @@ static const struct drm_bridge_funcs sun6i_dsi_bridge_funcs = { .atomic_reset = drm_atomic_helper_bridge_reset, .atomic_enable = sun6i_dsi_bridge_atomic_enable, .atomic_disable = sun6i_dsi_bridge_atomic_disable, + .mode_set = sun6i_dsi_bridge_mode_set, .attach = sun6i_dsi_bridge_attach, }; diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h index d269304691c9..acdd586a4157 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h @@ -20,6 +20,7 @@ struct sun6i_dsi { struct drm_connector connector; struct drm_encoder encoder; struct mipi_dsi_host host; + struct drm_display_mode mode; struct clk *bus_clk; struct clk *mod_clk; From patchwork Mon Nov 22 06:52:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 12693269 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 ECF99C433F5 for ; Mon, 22 Nov 2021 06:56:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TZygUFkt4yaA/DX318TWox/Ewg8oylERVnafiZLKFRA=; b=CirW8QRry3Eup2 Igm7v4yCGnWtxAix0i2LdXpf3cx8ysFWqgsHKvWu4Q6oCFcOpBVklJVe7zw26qq5kit78aq0BK11p 2EdJJMmGJPQ99Hfjfhwai5bBfZnDUciIDrzy1KlEpAthD9f1gEhRCoqxEoMTdKuQFxWkc+B+0FMj1 FuGil1hsPR+HYaeDQlsbdxWjIMa3TbTWVNv9QR/AThGPdKv3WfItcDzhkTedplZP7Y1ydMmC0t7wQ Tq0UqNu70VrIF9YzrxWn31pbbDKGUUaGbEl2Cv/h9bD3GOLrT2d2Kqzwu7Nz/wyi5zrhq/FbiKC56 eZNNKba3KWqSu/1VQFSg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mp3Dl-00EzdN-US; Mon, 22 Nov 2021 06:54:34 +0000 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mp3Cx-00EzLt-8i for linux-arm-kernel@lists.infradead.org; Mon, 22 Nov 2021 06:53:44 +0000 Received: by mail-pf1-x431.google.com with SMTP id o4so15196589pfp.13 for ; Sun, 21 Nov 2021 22:53:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6ZYBayqIBeNPyf7qiUQrCfEnJGA1MHxlxCodqslkh4s=; b=PaV53uN3Bh2l/u1ajsS+dqhp1L3F1BbzF1ZBQQxycWhCRwyhKvB2H88V9WiywrrVLt NjufX/Ygm6PBYGPd1QpJVMqz1tHTxwHgVvLffP5TiSdvHG9Ft5HQm1fEB4SiDydBp3Gr 2MKJYVlk0klZeV3jyDqnJ5ig7P8ZU4J+DTqbY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6ZYBayqIBeNPyf7qiUQrCfEnJGA1MHxlxCodqslkh4s=; b=wxExiDHBsTtRPXo/kbk3DK3WvsrGv2yFMR7uCkAr0DLZVZEpd7X4nefCfnINPXpIzx HOni+TVUJx5oyNPEuvkBGRRqmf2OfEvhcZpJwERKe5CIbMngIhxCCMvtpEKMp5TxPvaz FxlM+41mPaj16bAUa+9opsRkkkv1l9hgbvybU4ViYlaqLqLqxQQhomCVkADPSCsQW6A2 WNpisDbEFxxStiaPCf828UnnzKa7HAeGwiFHh1Pq3hrfQ4UDZSyhE/pFlcv9DqIAUiHl xrjqccVHLuuKupj2zYbXolbN75UdOQvXFEvIeD8NlM/nN8R0bkpdkp1tuR2E6sj/1o/6 fj7w== X-Gm-Message-State: AOAM531dKLYtgykwdyWZr7nFb3WtAZPEWKp4lxnVv5KMWqLyea2W82PR +stgHy4CsBrXqOHdZ6NzXEF43A== X-Google-Smtp-Source: ABdhPJxcXZIakoyYSn6+C8N1lINsE7W9IwpLczZBdTvnpe8G7x0c90nNZ5KsWUmK1csdTVT1THCOWA== X-Received: by 2002:a63:8a41:: with SMTP id y62mr31942595pgd.48.1637564022162; Sun, 21 Nov 2021 22:53:42 -0800 (PST) Received: from localhost.localdomain ([2405:201:c00a:a0a9:eed6:c913:819a:3850]) by smtp.gmail.com with ESMTPSA id a8sm7935904pfv.176.2021.11.21.22.53.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Nov 2021 22:53:41 -0800 (PST) From: Jagan Teki To: Maxime Ripard , Chen-Yu Tsai , Laurent Pinchart , Neil Armstrong , Robert Foss , Sam Ravnborg Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@googlegroups.com, linux-amarula@amarulasolutions.com, Jagan Teki Subject: [DO NOT MERGE] [PATCH v5 5/7] ARM: dts: sun8i: bananapi-m2m: Enable S070WV20-CT16 Panel Date: Mon, 22 Nov 2021 12:22:21 +0530 Message-Id: <20211122065223.88059-6-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211122065223.88059-1-jagan@amarulasolutions.com> References: <20211122065223.88059-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211121_225343_333658_CA8CFF0F X-CRM114-Status: GOOD ( 13.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch add support for Bananapi S070WV20-CT16 panel to BPI-M2M board. This specific DSI Bananapi S070WV20-CT16 panel driver is not available in upstream, added for testing purpose. Signed-off-by: Jagan Teki --- arch/arm/boot/dts/sun8i-r16-bananapi-m2m.dts | 40 ++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/arch/arm/boot/dts/sun8i-r16-bananapi-m2m.dts b/arch/arm/boot/dts/sun8i-r16-bananapi-m2m.dts index bf5b5e2f6168..b215c32996a3 100644 --- a/arch/arm/boot/dts/sun8i-r16-bananapi-m2m.dts +++ b/arch/arm/boot/dts/sun8i-r16-bananapi-m2m.dts @@ -44,6 +44,7 @@ #include "sun8i-a33.dtsi" #include +#include / { model = "BananaPi M2 Magic"; @@ -61,6 +62,14 @@ chosen { stdout-path = "serial0:115200n8"; }; + backlight: backlight { + compatible = "pwm-backlight"; + pwms = <&pwm 0 50000 PWM_POLARITY_INVERTED>; + brightness-levels = <1 2 4 8 16 32 64 128 255>; + default-brightness-level = <8>; + enable-gpios = <&r_pio 0 4 GPIO_ACTIVE_HIGH>; /* LCD-BL-EN: PL4 */ + }; + leds { compatible = "gpio-leds"; @@ -122,6 +131,27 @@ &dai { status = "okay"; }; +&de { + status = "okay"; +}; + +&dphy { + status = "okay"; +}; + +&dsi { + vcc-dsi-supply = <®_dcdc1>; /* VCC-DSI */ + status = "okay"; + + panel@0 { + compatible = "bananapi,s070wv20-ct16-icn6211"; + reg = <0>; + reset-gpios = <&r_pio 0 5 GPIO_ACTIVE_HIGH>; /* LCD-RST: PL5 */ + enable-gpios = <&pio 1 7 GPIO_ACTIVE_HIGH>; /* LCD-PWR-EN: PB7 */ + backlight = <&backlight>; + }; +}; + &ehci0 { status = "okay"; }; @@ -157,6 +187,12 @@ &ohci0 { status = "okay"; }; +&pwm { + pinctrl-names = "default"; + pinctrl-0 = <&pwm0_pin>; + status = "okay"; +}; + &r_rsb { status = "okay"; @@ -269,6 +305,10 @@ &sound { status = "okay"; }; +&tcon0 { + status = "okay"; +}; + &uart0 { pinctrl-names = "default"; pinctrl-0 = <&uart0_pb_pins>; From patchwork Mon Nov 22 06:52:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 12693270 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 69DF6C433F5 for ; Mon, 22 Nov 2021 06:56:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=AdpnbHbcRV0OD7N2PbpYietMEWR2+krdBmAGd/CBVms=; b=IMZfnazjGFFWbc 1NcgQv+gYwqwfI7P3MuPWUabfxq1DZkk8DT6vLXRGcfAYK3HFo4V8UoTfTh0oJxFzynBfzFU9OtNy 9+VtxUky2FR9s5yD1227eGUTKwagW/RjhVaOjbtUF+HpmAGdBK9tY5HQ/feGe5o4BmJ2pkt4LZidw 5yJlJcFI2ULP6USCcLrQJ86rO3Co+ua7BLb4HwQS0V2Oao+el3sJptyequAbl3LjF4No63DnKmT6z t1GeSNVH90mKsB77+s6wPrkCDtiYw/Dqtbvg6jcCjBtzQPsHeQJCoLFvFbD0a1rawUlnYQ0F8LUAW c1QCsNyyxbgfLqBfCX9w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mp3EA-00EzrF-SS; Mon, 22 Nov 2021 06:54:59 +0000 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mp3D1-00EzNq-Mp for linux-arm-kernel@lists.infradead.org; Mon, 22 Nov 2021 06:53:49 +0000 Received: by mail-pg1-x530.google.com with SMTP id r138so4918782pgr.13 for ; Sun, 21 Nov 2021 22:53:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xqP160R8LU5V3gmz2VYiGFoGsrEbiwdGt3q8Nn130K4=; b=R2lQlxavAQmQqeCHV4PJL0hX4asVWGfxWjZnq2AupshABRsm4dvRmevUkxIp+XZL5i imdW5UnoqL/tOuhvn34LH2ud24HWcdODoyeU71Ry9XzZ/EyMwgDt8Np2/n4yWLle53rh Zgmb7VqwH9mDQ+Chfgt8RRMGJQE2zWKbaaGo8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xqP160R8LU5V3gmz2VYiGFoGsrEbiwdGt3q8Nn130K4=; b=Gl2EdBTL12PUfgL02SeFvMNyGjUZXbk24ci3mwaudRhsXFFJIsX0hJ+jCf0BpVdeR+ cBMD+AcDisI26HM6r3aDwREIvwCebf7lDsB5MQjxbF40AyLxjGtHhszB6AcPvYzgAThi po4/4uBNqMECEavKYm4R2BfXE3quAbYcxN/T2FegOMoKvTGC2byrx2QpFi58bqQXCdg3 okGAJLvPjK8+lr0GnO2YUKlwB/dSgokAGfahzaOmSce9r7UH9DybcQwOxSenyBQ8OE/R Nnf1/7YaTT9iCCTp13mbRC5eNhpm63E1I13KDmh3fiXqMlPfJnV+o4OiR+REOsXHwPB3 1r1A== X-Gm-Message-State: AOAM530V2+cuT61OusGyNoMcZ5y4CG1SgiRnMXkyD4jMPvaQ9n5hu1Q0 UZCRRBdNNXAI1tOnIA42JQVbEA== X-Google-Smtp-Source: ABdhPJz6DZ/SRX+X8uZaDs5YozctfZcRVmLr9ghAGmBfnNqco0v8ckg+hK2XYUYYJ/hCoPEz2ZBMfw== X-Received: by 2002:a63:894a:: with SMTP id v71mr12345570pgd.337.1637564026320; Sun, 21 Nov 2021 22:53:46 -0800 (PST) Received: from localhost.localdomain ([2405:201:c00a:a0a9:eed6:c913:819a:3850]) by smtp.gmail.com with ESMTPSA id a8sm7935904pfv.176.2021.11.21.22.53.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Nov 2021 22:53:46 -0800 (PST) From: Jagan Teki To: Maxime Ripard , Chen-Yu Tsai , Laurent Pinchart , Neil Armstrong , Robert Foss , Sam Ravnborg Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@googlegroups.com, linux-amarula@amarulasolutions.com, Jagan Teki Subject: [DO NOT MERGE] [PATCH v5 6/7] ARM: dts: sun8i: bananapi-m2m: Enable ICN6211 DSI Bridge Date: Mon, 22 Nov 2021 12:22:22 +0530 Message-Id: <20211122065223.88059-7-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211122065223.88059-1-jagan@amarulasolutions.com> References: <20211122065223.88059-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211121_225347_775437_4596B23E X-CRM114-Status: GOOD ( 13.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Bananapi S070WV20-CT16 is a pure RGB output panel with ICN6211 DSI/RGB convertor bridge. Enable bridge along with associated panel. Signed-off-by: Jagan Teki --- arch/arm/boot/dts/sun8i-r16-bananapi-m2m.dts | 63 ++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/arch/arm/boot/dts/sun8i-r16-bananapi-m2m.dts b/arch/arm/boot/dts/sun8i-r16-bananapi-m2m.dts index bf5b5e2f6168..da6c1f2a0c74 100644 --- a/arch/arm/boot/dts/sun8i-r16-bananapi-m2m.dts +++ b/arch/arm/boot/dts/sun8i-r16-bananapi-m2m.dts @@ -44,6 +44,7 @@ #include "sun8i-a33.dtsi" #include +#include / { model = "BananaPi M2 Magic"; @@ -61,6 +62,14 @@ chosen { stdout-path = "serial0:115200n8"; }; + backlight: backlight { + compatible = "pwm-backlight"; + pwms = <&pwm 0 50000 PWM_POLARITY_INVERTED>; + brightness-levels = <1 2 4 8 16 32 64 128 255>; + default-brightness-level = <8>; + enable-gpios = <&r_pio 0 4 GPIO_ACTIVE_HIGH>; /* LCD-BL-EN: PL4 */ + }; + leds { compatible = "gpio-leds"; @@ -81,6 +90,18 @@ led-2 { }; }; + panel { + compatible = "bananapi,s070wv20-ct16"; + enable-gpios = <&pio 1 7 GPIO_ACTIVE_HIGH>; /* LCD-PWR-EN: PB7 */ + backlight = <&backlight>; + + port { + panel_out_bridge: endpoint { + remote-endpoint = <&bridge_out_panel>; + }; + }; + }; + reg_vcc5v0: vcc5v0 { compatible = "regulator-fixed"; regulator-name = "vcc5v0"; @@ -122,6 +143,38 @@ &dai { status = "okay"; }; +&de { + status = "okay"; +}; + +&dphy { + status = "okay"; +}; + +&dsi { + vcc-dsi-supply = <®_dcdc1>; /* VCC-DSI */ + status = "okay"; + + bridge@0 { + compatible = "chipone,icn6211"; + reg = <0>; + enable-gpios = <&r_pio 0 5 GPIO_ACTIVE_HIGH>; /* LCD-RST: PL5 */ + + ports { + #address-cells = <1>; + #size-cells = <0>; + + bridge_out: port@1 { + reg = <1>; + + bridge_out_panel: endpoint { + remote-endpoint = <&panel_out_bridge>; + }; + }; + }; + }; +}; + &ehci0 { status = "okay"; }; @@ -157,6 +210,12 @@ &ohci0 { status = "okay"; }; +&pwm { + pinctrl-names = "default"; + pinctrl-0 = <&pwm0_pin>; + status = "okay"; +}; + &r_rsb { status = "okay"; @@ -269,6 +328,10 @@ &sound { status = "okay"; }; +&tcon0 { + status = "okay"; +}; + &uart0 { pinctrl-names = "default"; pinctrl-0 = <&uart0_pb_pins>;