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: 12631281 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 86B8BC433F5 for ; Mon, 22 Nov 2021 06:53:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 44D3789C28; Mon, 22 Nov 2021 06:53:27 +0000 (UTC) Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by gabe.freedesktop.org (Postfix) with ESMTPS id A92BF89C28 for ; Mon, 22 Nov 2021 06:53:25 +0000 (UTC) Received: by mail-pl1-x62e.google.com with SMTP id v19so13247342plo.7 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=RkxOsf01ffAvoIw70wgYHukISWaM74DLIQ6II2MaZbsNpR5PMSafLkD+YDPaMc61zL xu+kbCYYZEBhFlTsMi0JGRlGZx8tuYw4RcCd9h/lDNAYLtvdZEhi2cXtZBwestrZWaWi xFFCv58LliL7P4iET8Jxyb4PwJ5Ciz60pLLascpCaJl3e8c2kHII1DDOoZ38FjYpcgqm UhvGPgDFtORB1wUaSbo+UDty1cshqRtcoELha+eQN4MeTTFepHAsMAiXMzF/X+QoS4bq UnbXwekwhZlLmT+F0VpQRRpN+mkKXqh6G4w8DRXWp19uSQTh3f5wsTcO2cgxJccjJlpN gNWg== X-Gm-Message-State: AOAM533r77FNm6q/6poR55NgQa/Z7gjzlISJYozV3q6yXXrrF1iUFvoO ajmswrXvnajODkWOxqzCX7K37t6mk8tuGg== 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 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-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: linux-sunxi@googlegroups.com, linux-amarula@amarulasolutions.com, linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, Jagan Teki Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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: 12631283 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 C6207C433F5 for ; Mon, 22 Nov 2021 06:53:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C78D689CA0; Mon, 22 Nov 2021 06:53:30 +0000 (UTC) Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by gabe.freedesktop.org (Postfix) with ESMTPS id 146AD89CA0 for ; Mon, 22 Nov 2021 06:53:30 +0000 (UTC) Received: by mail-pj1-x1035.google.com with SMTP id v23so13004498pjr.5 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=5GmSWN1p44fc38suWqlE6Ah/ExLaGhxCNkRDVufjmvzz27SPHbFh2PHBfCIsCo8ID8 7ZdQuF+8sghMXLrTF8OSGCaDPClTgfrXeyldvg2M3mhLHcUC8QhFyS37WII+w7JhAA+W uSEpcqUQ9xQkWuI62pNn5GHOjLlNbNttwXLjw5egSO+BueqasnvwKPl8z89r4NamAUQ5 vgxfNea5i1CQUctyRQJ4eKBfEsX3HWLUMu0jqadv6O7727oBvPtNngmSXPNq//fYEaNH yqE0zdknt9B0KZ2kU+9VxyOYa/FCdWY5NXrW8gm5g3t7kGF9a+QYYJBziRvd3AGMmjDA ZY4g== X-Gm-Message-State: AOAM533tZcqFLgwUfNjEJAubDyDLs8t2MLfZuvZm2reuIzzgGGz+ik0w Xgvl3erYehCBDLyZgmqIrxgCVQ== 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 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-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: linux-sunxi@googlegroups.com, linux-amarula@amarulasolutions.com, linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, Jagan Teki Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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: 12631289 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 A2FD9C433F5 for ; Mon, 22 Nov 2021 06:53:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BBBD989D79; Mon, 22 Nov 2021 06:53:35 +0000 (UTC) Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6E30E89D79 for ; Mon, 22 Nov 2021 06:53:34 +0000 (UTC) Received: by mail-pl1-x62b.google.com with SMTP id z6so12057306plk.6 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=5EvrF0GbmuXIAmKKudfRC/mGqthXFEvz/W36+3h+Tk+fkL4dzmUNj0RQAPvFLTzaO0 4sEQ5Prez7I8Ezj6M132fiI+66Ue5/AuvwzvGOMdCko38Tsq+q00Wd5mZSVyGp5GgJ2H i5OWG3w9cwn6/LhLIkkQknqMZEg7dAylkh4Sq1rm1Qch2NDmfpYp3iew86QGEAGS1A7p ElBiwGYmxf2x6C+zFqZfn93CSOV7J9bLjcLyVpEw5Y7u998HL6sks5/tOAaU5bFdqzM4 Qvb1S/NifzLhRqK5keI9/wzv3OYSXHlOe0bF1Z5+/0Pg/+4owqWuG70VBKRj+/RuzPdx 4K+A== X-Gm-Message-State: AOAM530BxXfMxmbSj25TbuJk4x2NBbeiBOpNTWyg7geywbxIxwSuqt7G Uf1LLbq7oYMYmlorzlqmugxgcQ== 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 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-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: linux-sunxi@googlegroups.com, linux-amarula@amarulasolutions.com, linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, Jagan Teki Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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: 12631291 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 7F2C2C433FE for ; Mon, 22 Nov 2021 06:53:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B8BBA89D8A; Mon, 22 Nov 2021 06:53:39 +0000 (UTC) Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by gabe.freedesktop.org (Postfix) with ESMTPS id 77A1189D89 for ; Mon, 22 Nov 2021 06:53:38 +0000 (UTC) Received: by mail-pj1-x1036.google.com with SMTP id np6-20020a17090b4c4600b001a90b011e06so14408932pjb.5 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=N3VaEfgzhz4OAPY35VTjkGVmvRuI0SIToqeyOkXLmNgthajy0A4hJ6DDxQS7EclpK4 wSQT0mID4VDOV8qGf9TP0JL2DDN/cfk+EcQfvUB7iPw/I7iPWEp1pIfunJJLZc1eKGkT oQc7t/zHbJrbCyLpb5BRXVU1DanrQUtr2NlRRrOI9lhK5b+0BbttoeMzGwuMJ5Rl4E1s XgR1vcLu4KnAvef10EjikkElqHDF3MH8tdHBy05cFGbaKukxJzzBox285ptmJMMhIhXe A+oVAGjYpxSl71enVfYuhwlGnZwGvjLfnouSRUgQurKXr2ZsNnXRPygQ27YNTCJ2Qxjo zxeg== X-Gm-Message-State: AOAM530hcxWAsGzeux00fuKX1SzzvwhSAQhHN1mLHKiZy9PPj7CqK4ko rg3qEM9FBJ6sornIuvVCSb6Z+Q== 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 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-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: linux-sunxi@googlegroups.com, linux-amarula@amarulasolutions.com, linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, Jagan Teki Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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: 12631293 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 EA399C433F5 for ; Mon, 22 Nov 2021 06:53:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 496F489DA5; Mon, 22 Nov 2021 06:53:44 +0000 (UTC) Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8A3BC89DA2 for ; Mon, 22 Nov 2021 06:53:42 +0000 (UTC) Received: by mail-pg1-x52f.google.com with SMTP id h63so14449512pgc.12 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=AE2aGVa7xM6zsgqHKHJ17OQCuxq5gvYWq8vi97yy0rfYUl10MnHLqPkwV6UqrISaj/ ObI6FSzl9CFBA042S99H01YxzV5xQgn7bPZ9gqixTO5l356PeK/cKMsVpMQ14fkZfnWk tuJUenP841rgEoyvXiwvTBHYJqrEFU8Swh1mXI7a4+KnTnVsy2aHDnVWMj4VbXTe/0Ec EKQ/I326ZjL4WOop+NBPOEXHc26xnvMo42HP2ZG+KIO0vJq+UK4mEWYHVTS9VJ6eQm8W 0bkIq0zT33m8dua0nEzXteizlGKpFtVzLecIVt9Yw9FueNKB8Aa1a2+4G4Cw0GDBcM5p BkxQ== X-Gm-Message-State: AOAM53121Y8xREt0Hoor1LEYuO8aENhkyTiLAzuclipU9OU0GxM6/oFG ETPzZkmLwqQ+0TBzPqfZNYFHjw== 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 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-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: linux-sunxi@googlegroups.com, linux-amarula@amarulasolutions.com, linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, Jagan Teki Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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: 12631295 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 C03B0C433EF for ; Mon, 22 Nov 2021 06:53:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2401A89DA9; Mon, 22 Nov 2021 06:53:48 +0000 (UTC) Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by gabe.freedesktop.org (Postfix) with ESMTPS id D3B9E89DB5 for ; Mon, 22 Nov 2021 06:53:46 +0000 (UTC) Received: by mail-pg1-x530.google.com with SMTP id f65so4854953pgc.0 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=79mKfZt38wOGbnOWPgv4A/cAJ9gIRuBPB5P5xbUSWBgYY03FC8jNUFRYOk+trVeSns d3MoC4rFYINVbxDsjsB8UoMwzkM0LDR8Ayk0WkN45sJJXtBOHgzYl+khjYfqI4EBneLP cWLbPsCyzQq9+7DCjwvoi3aE2ErsitjrIMG7R+m5rB82/HhhQcgGHRNUoQse2SdLrJ3R tI2ySoK8r3QcdX/yEgkB5EuVhieUKE6hi3UCp8dB31PJ25QhYWodlfT6LSPtpcRx2JrO X8B3nILsNXyhpmEYeZ/CWg4y8jh+1sELDnVIAqDb3k7OCAkqNWR8j1NRmQ+EzQ7OwZJQ vp+g== X-Gm-Message-State: AOAM533lWdppVRrDhLJu71M4T5sZOviKSuxeICw55cmUnRNrUflfw1BB 0u+QjdquazkiKNAGqQg4qwzAvA== 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 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-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: linux-sunxi@googlegroups.com, linux-amarula@amarulasolutions.com, linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, Jagan Teki Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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>;