From patchwork Fri Mar 3 14:51:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 2765 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 9522244AA6 for ; Fri, 3 Mar 2023 15:52:28 +0100 (CET) Received: by mail-pf1-f199.google.com with SMTP id a10-20020a056a000c8a00b005fc6b117942sf1464428pfv.2 for ; Fri, 03 Mar 2023 06:52:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1677855147; cv=pass; d=google.com; s=arc-20160816; b=lF4zuCqJ8/lWVAg4tgiu/Aea3FJD3Y46GGI2uplNAJ2so7b2NH5Z2fFU/0z1BCZjJF 1zz1pPaVitIiBK6jwcvwE6cKjviHE5F0umxRw8p9iFD/vR9NDMa+05tDCZjgjQTIWZXN +oSQNcNxi9uZFCQ9houhpRXdQjQxZPBxmKyqhM+uCeM5GSlc33HYiJbFI13MxqD4YtcC Rs2R9+cxBLh1OOD1oKFNM3JrnGI1B5qZf2J/J2wI9Gri1AFtUbhvwzr7Q4WBRtYRe+ad 77zAtR5sK0awxPyPNYEMXx/akRJvVmHEq1xMXLTxZ3D7TubLsT5QMmzhNa31NMlrLdrn LxfQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=11TLyARijp55z/SM3bsSCPN5MrNK7ssrAa6VWn15b48=; b=LcLoahArPtMe9aJmKwSccVY9N2mieofXqo37LYmgGr5lmYhUpfc7Y3KnNBJhfXJiHk eBzXLYuZ7Y1MhrrJs4i6LuycXLzccjqiXwlj7ec8q8cdfkKeVmauqt+B5Ar2e+TvPUm7 NnfXTporbCQbPUJh0ksjR6gjIi62Mjl1rL8XhIgdzi5AJPf7tEfEw72eNA8k7mci47Ld qXmSPqbqkWA5nNA12Axa5+YqBTMvKnRqdGxEHz0quEMdOtl8lK81KjV1GqmnFH2zFJ9d +gsS3sU6g3HzniTd23odarOs3BrJCHgtmvpY6kOw0LVLgUUKD6K6oVj7VWioK4LhLeOf P19g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=nwx3nUHw; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1677855147; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=11TLyARijp55z/SM3bsSCPN5MrNK7ssrAa6VWn15b48=; b=gVmYkJRnhrk5ueXfMJ2/LO0OK/gGufhjwx7CwWU7h+aRwf4ZPo7FR0tg7IYaqptCrW djKja0gCnrrWvK6LZ4MRkVRWK621bOIfop7kvmKaBgoEsLG/eH/sI+KMycHM5Ow4b5ay ss8fpElxm+9VqXV+s6t4+8d7QP7Y7zJBoBKhI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677855147; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=11TLyARijp55z/SM3bsSCPN5MrNK7ssrAa6VWn15b48=; b=kkbJWriH+raFNTCBO0vk7nYsVdo2Mgup8GbZYG1gd6loqM+9WvRU8f83O3umlLu2kE RHtEnd2mzVTPXn3O0IZBUxolcSW4dS36Gh/9cwoxi+p5XsMV/A/rk6n8qykxtzp2FGr3 tGZHx1gnUuAWSi9dGSK2ej0FLQR+ckEfuoVPay9n9v6sQzhLy8iA3ccn9mkaA91WCXVe +V7jmICz/Ylc0HrHhLhWd1SJUfSqOOFc+3CjFHziwNd0ZXZpCzBEGOtq/svpczV9YuLd 1bvvWCSFkFR/XCiYqYF03HPJgqtpgLC2hTy5kIKnGJ3gnwLkikHIoc5QnvNJaeJs4d3P gA8Q== X-Gm-Message-State: AO0yUKX8FYEQVNl9XQkDWrZA+WTIob5xSxyiOFjPe3f9lflS1JXMoehQ POnCHlmMRWdWdkn9mpB3whn2ud+1 X-Google-Smtp-Source: AK7set+SE6Mpxca1TiukAPUCKe/slJdfQLu5Sn1pEZ9wrK7icIDNsP1rPhx1rH+7DVJMJiXnnzlEfQ== X-Received: by 2002:a63:7512:0:b0:4fb:933a:919 with SMTP id q18-20020a637512000000b004fb933a0919mr577843pgc.3.1677855146835; Fri, 03 Mar 2023 06:52:26 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:902:c3c5:b0:19e:398b:8d99 with SMTP id j5-20020a170902c3c500b0019e398b8d99ls3200705plj.4.-pod-prod-gmail; Fri, 03 Mar 2023 06:52:26 -0800 (PST) X-Received: by 2002:a17:903:2450:b0:19c:e484:b45 with SMTP id l16-20020a170903245000b0019ce4840b45mr2610037pls.27.1677855145826; Fri, 03 Mar 2023 06:52:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677855145; cv=none; d=google.com; s=arc-20160816; b=BfYVYtR4enbRIzpsD2zEPOccmkrNWq3lWX5+epez9dAzAPREkfChUtGjSLdO0x5R/Q aXIoX0dpCKA1XJrJyBu3wX0s1Dk0l9oiYOZxaeyMuhAGHr+Nw7fjdKDxMCOvyN/jRHdS aLe60nZ6DFTXdM4rGZ3+wZqC8Oan5xoACgcrz1/dOd0LL3grZ9MLZZsLM0NxXhI6giOo J9TKTUlzePbuWFCdxYH0+i1iyKS9pv5AVvLhNahHsxEOWy9+NHD3C1akwXklTvUfPFdZ NYk88qX8nmm8FeHeob8tGYCewBYu0IuN4U9RvhT4hWYtidLbknDXRikQJ1OqngfV4yJs 2G3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=75obg6WaKxGAouYp8L8vU99A5I1ZieLyIbshRx9ot/0=; b=HOXhLmwVsKVWBjcjHzmzHEaHvI7lWHYna5aDg8OVMjthWrlIpHz2IXg/n0iO4bFE2N O35yhDzBVf+zzmodbUQt5wVWVwv00QI594BsaQBzWwGS/S0oPCMw2xql+j2Ewp23lo9J ABe0TIuAp1ALbbngQvzyHlgwkGRpOGo3QMblrBF2BfrfahAgIvHfm+6IS53kKrFSmtCW xmnKXosogn50CnYvMlF5WqFe5/15TJRS5yHrKL6hXtwhzuiLXwmPppBi/zLJX1v5yLhj JHobX98U0qN8K7oAdjbLxc6tnLptZU4MIaQNxqQaLNIlZ9aeesFrR3JxMx4AcFU2e9PZ vVfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=nwx3nUHw; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id b7-20020a170902650700b001994928ec9dsor1077956plk.46.2023.03.03.06.52.25 for (Google Transport Security); Fri, 03 Mar 2023 06:52:25 -0800 (PST) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a05:6a20:5487:b0:c6:d37c:2a62 with SMTP id i7-20020a056a20548700b000c6d37c2a62mr2981782pzk.11.1677855145441; Fri, 03 Mar 2023 06:52:25 -0800 (PST) Received: from localhost.localdomain ([183.83.137.89]) by smtp.gmail.com with ESMTPSA id z4-20020a63e544000000b00502fd70b0bdsm1660856pgj.52.2023.03.03.06.52.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Mar 2023 06:52:24 -0800 (PST) From: Jagan Teki To: Andrzej Hajda , Inki Dae , Marek Szyprowski , Neil Armstrong , Marek Vasut , Maxime Ripard Cc: Seung-Woo Kim , Kyungmin Park , Frieder Schrempf , Tim Harvey , Adam Ford , Matteo Lisi , dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org, linux-amarula , Jagan Teki Subject: [PATCH v15 02/16] drm: exynos: dsi: Lookup OF-graph or Child node devices Date: Fri, 3 Mar 2023 20:21:24 +0530 Message-Id: <20230303145138.29233-3-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230303145138.29233-1-jagan@amarulasolutions.com> References: <20230303145138.29233-1-jagan@amarulasolutions.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=nwx3nUHw; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , In general, for MIPI DSI there are three ways to represent the pipeline for an upstream bridge to find the connected downstream panel or bridge. 1. Child panel or bridge as a conventional device tree child node. 2. Child panel or bridge as an OF-graph port node. 3. Child panel or bridge as an OF-graph ports node. There are three different downstream panels or bridges that are possible to connect an upstream DSI host bridge - DSI Panel, DSI Bridge, and I2C-Configured DSI bridge. An example of the downstream panel represented as a child node, &dsi { compatible = "samsung,exynos5433-mipi-dsi"; ports { port@0 { reg = <0>; dsi_to_mic: endpoint { remote-endpoint = <&mic_to_dsi>; }; }; }; panel@0 { reg = <0>; }; }; An example of the downstream bridge represented as a port node, &i2c4 { bridge@2c { compatible = "ti,sn65dsi84"; ports { port@0 { reg = <0>; bridge_in_dsi: endpoint { remote-endpoint = <&dsi_out_bridge>; data-lanes = <1 2>; }; }; port@2 { reg = <2>; bridge_out_panel: endpoint { remote-endpoint = <&panel_out_bridge>; }; }; }; }; }; &dsi { compatible = "fsl,imx8mm-mipi-dsim"; port { dsi_in_lcdif: endpoint@0 { reg = <0>; remote-endpoint = <&lcdif_out_dsi>; }; dsi_out_bridge: endpoint@1 { reg = <1>; remote-endpoint = <&bridge_in_dsi>; }; }; }; An example of the downstream bridge represented as a ports node, &dsi { compatible = "fsl,imx8mm-mipi-dsim"; ports { port@0 { reg = <0>; dsi_in_lcdif: endpoint@0 { reg = <0>; remote-endpoint = <&lcdif_out_dsi>; }; }; port@1 { reg = <1>; dsi_out_bridge: endpoint { remote-endpoint = <&bridge_in_dsi>; }; }; }; In, summary it is possible to represent all three downstream slaves devices using OF-graph port or ports node however only DSI Panel and DSI Bridge are possible but not possible to represent I2C-Configured DSI bridge child nodes since I2C-Configure bridges are child of I2C node, not upstream DSI host bridge and it is must represent them endpoint port linking. This indeed means, the OF-graph port or ports representation is mandatory for I2C-Configured DSI bridges. This patch tries to add an OF-graph port or ports representation detection code on top of existing child node detection. It is possible to replace the entire detection code using existing drm_of helper drm_of_find_panel_or_bridge but it will break the Exynos DSI since the pipeline doesn't support OF-graph port or ports node. Overall, this patch has a combination of child and OF-graph pipeline detections in order to support the backward compatibility of Exynos DSI child node and i.MX8M Mini/Nano/Plus OF-graph port or ports node pipelines. This is the first common DSI host bridge driver that needs to support all possible downstream connection pipeline combinations. Signed-off-by: Jagan Teki Reviewed-by: Marek Vasut --- Changes for v15: - droped from drm_of - added in exynos dsi - updated commit messages Changes for v13, v12: - none Changes for v11: - drop extra line Changes for v10: - new patch drivers/gpu/drm/exynos/exynos_drm_dsi.c | 38 +++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index df15501b1075..f44a5a702ad5 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c @@ -1470,18 +1470,52 @@ static int exynos_dsi_host_attach(struct mipi_dsi_host *host, struct device *dev = dsi->dev; struct drm_encoder *encoder = &dsi->encoder; struct drm_device *drm = encoder->dev; + struct device_node *np = dev->of_node; + struct device_node *remote; struct drm_panel *panel; int ret; - panel = of_drm_find_panel(device->dev.of_node); + /** + * Devices can also be child nodes when we also control that device + * through the upstream device (ie, MIPI-DCS for a MIPI-DSI device). + * + * Lookup for a child node of the given parent that isn't either port + * or ports. + */ + for_each_available_child_of_node(np, remote) { + if (of_node_name_eq(remote, "port") || + of_node_name_eq(remote, "ports")) + continue; + + goto of_find_panel_or_bridge; + } + + /* + * of_graph_get_remote_node() produces a noisy error message if port + * node isn't found and the absence of the port is a legit case here, + * so at first we silently check whether graph presents in the + * device-tree node. + */ + if (!of_graph_is_present(np)) + return -ENODEV; + + remote = of_graph_get_remote_node(np, 1, 0); + +of_find_panel_or_bridge: + if (!remote) + return -ENODEV; + + panel = of_drm_find_panel(remote); if (!IS_ERR(panel)) { dsi->out_bridge = devm_drm_panel_bridge_add(dev, panel); } else { - dsi->out_bridge = of_drm_find_bridge(device->dev.of_node); + dsi->out_bridge = of_drm_find_bridge(remote); if (!dsi->out_bridge) dsi->out_bridge = ERR_PTR(-EINVAL); } + of_node_put(remote); + if (IS_ERR(dsi->out_bridge)) { ret = PTR_ERR(dsi->out_bridge); DRM_DEV_ERROR(dev, "failed to find the bridge: %d\n", ret);