From patchwork Tue Jan 11 18:31:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1838 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id EADCF3F1D5 for ; Tue, 11 Jan 2022 19:33:18 +0100 (CET) Received: by mail-pj1-f69.google.com with SMTP id k2-20020a17090a658200b001b399622095sf163957pjj.9 for ; Tue, 11 Jan 2022 10:33:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1641925988; cv=pass; d=google.com; s=arc-20160816; b=QATC00Eeko+K7UQ8dAbV1NJKo0YBtbEAcaIoVZHZSDiZLEXIRBJ6RrOTsMhTE+SGX4 kvuUZuB3dGAK3VqUkAuK5x0cqNCsn7sKviUJps+HhJl9z+nHQXY4xKAnTcr7z9+pXngm rNkZdBET+3UrgKr2PykJ54FnTmU4Q/2LIGr/FKdF7CUFsXFDPFz7NAc4rBhDlbfyESvB F8S6BElBG67vc1rByLt+IySFkT81oDNYdqCp4rKhF0NvjWf+etO7k+TTSW939nzVUJyP PrvxBfPAtwg/ywhJdkCBv33b0vqmMeF6RKxgUTVokkYc+ub/jJXfAijURegM0BylEiGo MFOw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=xA2hfheQhDYKzSJQ/CvpH4xXjR5YtLkQx+HLjHzj/Uw=; b=eCFGu8/r2Ro/tAt0aG5RHWpVrOQ9HBhAHq+ALXlIqEwrRtK+c+zclwCI71ZpwzpUW4 K073uevQfyQQujmme1rQ9aqPrxvH/86nf+KuGUhOC1DniXnxOscnCWhizMr8WyFOAFi1 Gu26iGjwi/a7zExARTKouJHu2s5/8O/NrnVhw+Onp3kXv0JapVptBcUHZnXGomzKlNvX 7HaLQCeCxKZ5WSdT9YP89FvMFTVxE3qPEO63VAJV0UKYy014MvHLhSlceWKGnAJiR09Z Lm0AtdcjZxo+K9v7i8xt33/WGYBXcvn6ZeiQNWrXkNOv07EaPI15G87Hvu5qV5QzCB9R eDfg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="YjPJV/f/"; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=xA2hfheQhDYKzSJQ/CvpH4xXjR5YtLkQx+HLjHzj/Uw=; b=UMDno1iwhjmk5g1EbyZ7r3obk0E7t5j6dCeBbu7TriOH2t87+TSLn4GHtYUwPBGA+C Ufrv8uQltn3ZZfaFRdIF7nUK15NsLp1/HvL5T6hNEJlLefO4e1bS7EBZDVHbhBxlg52f J5h/P4eW0J5lrrZyrOimWQdbyquejG/gxRg8Q= 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:mime-version :content-transfer-encoding:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=xA2hfheQhDYKzSJQ/CvpH4xXjR5YtLkQx+HLjHzj/Uw=; b=GLpBhTKksdO2BQDMYZaLKvE4k7YlMiPgY2QiqqCzGcRPR3cVch4bFpwzBmi5BdwxW/ KMOQBDt9F9/+1+cEHpT2PfaMWVQy4xGIkS1yOlMqFLqODE9YO6StJ65NDIa5oi939piu 5jKnic9KCw9lAIlQflbkCo+b0Qnqr5vPy6WTOCGexM9CgNdYc9wMUA3Dk22AbuZqE9fw 8a5iIPmgGjAOmLwUk81LNynPdD71LL+9XJ4MZ9LFvokLs+npgjCrd9ZE/7jeBb90Eg2m kydCiEnrARRMfbPJZKkhLNSqf8sM3JfsGmKx2+osHngMdP8dD0XsyeQUIcbcxkFbjk9a 31YA== X-Gm-Message-State: AOAM530+hdJK55AtsImalWq6k9t0SEQDEe56uqlen+shU6hKf0utC39l 1XhKr3fVgzq4JkKsCSZRAgruthSC X-Google-Smtp-Source: ABdhPJwiI2HO1oSKasNxHqv/d1gvNydkqCLA2zqJyqq8GEcIjnoKZTx+LIFIcvHajg7s7RduEy2+SQ== X-Received: by 2002:a63:9549:: with SMTP id t9mr5151283pgn.107.1641925988308; Tue, 11 Jan 2022 10:33:08 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a63:9209:: with SMTP id o9ls5598610pgd.0.gmail; Tue, 11 Jan 2022 10:33:07 -0800 (PST) X-Received: by 2002:a63:2cd2:: with SMTP id s201mr441702pgs.53.1641925987564; Tue, 11 Jan 2022 10:33:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1641925987; cv=none; d=google.com; s=arc-20160816; b=0Tg3DZnmH2rnOC1c13W5ikMwh6KqC5vqAY0mODS+Vf6U09u8Q4j7dPPoI15ABxPD+o /CWwUfdIrwDpzcV6zVFaQPD9GShI3UyeW44ejjmAegnYHzLxgwovFaWb6aL6pqGj4xDs ArG5pi9V6M8jjjb13R+lMAWglnpGC+GT9POPVhSrEYjn+y9bwmOx9DjrvtSGx3ypo/Nu h84+DmCU8lk1MH4IYL9bHJmzWsD9av0q2J9YDzWdpsQZ/Op9qHFE+qdvCZ8kts8OVyBU FmY6Oalr+CSNYSceZ354en7UIe49G5QVRBuetoA8BIP+Hn2t77afHYjy02zZPzlDXy4c ObbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=FanoeZhQY7FxJ7xchmDO1CUnX/wmanXy7A07snqKYas=; b=XUghmYUqguL2NMWloeA/BxHTV1Thys5A2c55i18ZHwZ7qVrRrcM7I03emBQfVbEnK2 4DxrFMVyRagz+GjQcKfHj/jOqquXg/ZWXOwRnS+OQn3jShrKdFujt2SfQZPNTWmQ3+P4 CMD8ufrZBXGiSJTlR8dy6b1gquBJKFQfiDr3KLfyn/3QC3sVm3qx0xEblBLYB32EEgIn nUsToz64GBqo1JQ3vzUhqNKbkdd5z+so04yLeOhSX5qxSEBKULmbRUJHaIXTV26bW24A BH06mx7U6ubK35qIxb2PI//jNREaLR7Tjq5l/sPda8M6GHtoioMjQxAaKwYUvTY1dKE/ Mjvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="YjPJV/f/"; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jagan@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 o10sor4269670plk.131.2022.01.11.10.33.06 for (Google Transport Security); Tue, 11 Jan 2022 10:33:06 -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:a17:903:230f:b0:149:f2fe:edaf with SMTP id d15-20020a170903230f00b00149f2feedafmr5754411plh.149.1641925985719; Tue, 11 Jan 2022 10:33:05 -0800 (PST) Received: from localhost.localdomain ([2405:201:c00a:a0a9:3a09:a842:9ff2:6831]) by smtp.gmail.com with ESMTPSA id h15sm4067850pfc.89.2022.01.11.10.33.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jan 2022 10:33:05 -0800 (PST) From: Jagan Teki To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Laurent Pinchart , Linus Walleij , Andrzej Hajda , Marek Szyprowski Cc: devicetree@vger.kernel.org, linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH v3] drm: of: Lookup if child node has panel or bridge Date: Wed, 12 Jan 2022 00:01:52 +0530 Message-Id: <20220111183152.494923-1-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 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="YjPJV/f/"; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jagan@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: , Some OF graphs don't require 'port' or 'ports' to represent the downstream panel or bridge; instead it simply adds a child node on a given parent node. drm_of_find_panel_or_bridge can lookup panel or bridge for a given node based on the OF graph port and endpoint and it fails to use if the given node has a child panel or bridge. This patch add support to lookup that given node has child panel or bridge however that child node is neither a 'port' nor a 'ports' node. Example OF graph representation of DSI host, which has 'port' but not has 'ports' and has child panel node. dsi { compatible = "allwinner,sun6i-a31-mipi-dsi"; #address-cells = <1>; #size-cells = <0>; port { dsi_in_tcon0: endpoint { remote-endpoint = ; }; panel@0 { reg = <0>; }; }; Example OF graph representation of DSI host, which has 'ports' but not has 'port' and has child panel node. dsi { compatible = "samsung,exynos5433-mipi-dsi"; #address-cells = <1>; #size-cells = <0>; ports { #address-cells = <1>; #size-cells = <0>; port@0 { reg = <0>; dsi_to_mic: endpoint { remote-endpoint = <&mic_to_dsi>; }; }; }; panel@0 { reg = <0>; }; }; Example OF graph representation of DSI host, which has neither a 'port' nor a 'ports' but has child panel node. dsi0 { compatible = "ste,mcde-dsi"; #address-cells = <1>; #size-cells = <0>; panel@0 { reg = <0>; }; }; Signed-off-by: Jagan Teki --- Changes for v3: - updated based on other usecase where 'ports' used along with child Changes for v2: - drop of helper https://patchwork.kernel.org/project/dri-devel/cover/20211207054747.461029-1-jagan@amarulasolutions.com/ - support 'port' alone OF graph - updated comments - added simple code drivers/gpu/drm/drm_of.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c index 59d368ea006b..aeddd39b8df6 100644 --- a/drivers/gpu/drm/drm_of.c +++ b/drivers/gpu/drm/drm_of.c @@ -249,6 +249,22 @@ int drm_of_find_panel_or_bridge(const struct device_node *np, if (panel) *panel = NULL; + /** + * Some OF graphs don't require 'port' or 'ports' to represent the + * downstream panel or bridge; instead it simply adds a child node + * on a given parent node. + * + * Lookup that child node for a given parent however that child is + * neither a 'port' nor a 'ports' node. + */ + 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, @@ -259,6 +275,8 @@ int drm_of_find_panel_or_bridge(const struct device_node *np, return -ENODEV; remote = of_graph_get_remote_node(np, port, endpoint); + +of_find_panel_or_bridge: if (!remote) return -ENODEV;