From patchwork Tue Dec 7 05:47:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1798 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 386753F03E for ; Tue, 7 Dec 2021 06:49:09 +0100 (CET) Received: by mail-pg1-f198.google.com with SMTP id d2-20020a656202000000b00325603f7d0bsf8135122pgv.12 for ; Mon, 06 Dec 2021 21:49:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1638856147; cv=pass; d=google.com; s=arc-20160816; b=CG6L/VIEonvjmZ2vKI9JkTah7+HJ6itDJkjr7ZuPxPPuiUVYH/cGmdjifYkfnkxM8P 3Z9Ic4Fgok0WRGVuNrB/LS8XS1LrEhwblX3rqFBldCY169gozJC6b+jIKgsnT2iBwbFT rjqzc9IAR/sS84ELB84DPhfuiLCHEXSskMJQuC1QoIG3WnCMmGO8XR2QzV3YdRAEvPrJ qc457qt0rekATnHXjYT/kVUgZfMmgEMu27fSWPlIjDQ5IhCd/bH9wtKos2mMjrN/RiVy 5+o7bTk+AGGiTfigPX3D1a2HcRS3hEkCWAJe2hfbDSTbaWnApqODagO/sYQ1A5m7pE4u fh/Q== 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:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=sJyaXjhtc024cDlLpwHz32TcBanL2kvK8O50ZN+f26k=; b=hFt/DMlpxNLygJwQoPuGzYAQvVtNwIa4LNt0qyGoy78D61vEzNEVzG91SU/InuaqH8 Gr2+owhprOJXYzpSnqwtlP9/onpc0TXLzNFW4GvuQzMUtqRjkU9wbv2G5FRk0MDSZEA0 +erQi8PJy4sPvCKAni1/XIFEtLF2UYJbkCdJVjokHBzBvaOUR+OeL1Q+HcKWI5kidcGx gINgwypJOHwCi2v3GZ1aCX0xlWYKTFx0kBKdmLvSPwD/NmfvuivwztOg3henJzDA2jE5 xuXWrMy/p9yqoJbPZPf1oFZjIKpwqmDcibOzwW8YckxFc2WRCBrWPN4bC2yNFyUabM81 +Z4Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=drb8lSpo; 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:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=sJyaXjhtc024cDlLpwHz32TcBanL2kvK8O50ZN+f26k=; b=TG3E7taBjSyw6gAGGkDA80JGPvKZ8iip1rGf0tNX9AGwsXYUeNhQ1GSm6ciiCRbR7j FsyvuZEoaU4VHJ9jZ29zNA/0JRPQ8Pzu6CfYR3mKGzR8umPj5lhoF2vskkxuzjknlUkp BAiabKrbFSFg/LUHOB7c7RpV5rclBEZlySuxE= 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: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=sJyaXjhtc024cDlLpwHz32TcBanL2kvK8O50ZN+f26k=; b=QQgOwajUH5wXksTLOHdM6Ssf3weY7XjlSeNQSVi09no32bh4Q+mmeVfOTfntj2tcKH ZI+OOu/9B1JwA/U7q/as1uz0vXEngwqRoQT0CwLjbX7i8RP34Xg9aoJZYtQWyCi2ZJCO 0FbWtIcVWo7ABRL6v73JlkKWx30Lyt6EX1B2vf6Zy3AYKtsCXZ/NY+C0AScqp2L1T3AS vrVbt8UT9xVLYISbP4xeAuv8MT6NZhq0jnWVUbHATX+828T8F9CDyU0VJh5YAFBo/u8N G0Sponq9EsnGGZzEs4F6TxtqRzh673ESQ/bIZg2Ccs53Jfh2Pbe+VSBWYRLuBsm9+5nE HKug== X-Gm-Message-State: AOAM530loePAynrrWUinyEm+jfNdJ6X4JiT0k5goX++KZcAWxGG3ccyY a84hEmRk6W0UDWl5kW16ndt6sTdl X-Google-Smtp-Source: ABdhPJwvzvxawdr6ExBw2wtHGMXuIO3n7m3lZBI5q3G13zqQ92FC/F7KpzakgFEH9eEvgyIrPGCfRA== X-Received: by 2002:a17:90b:3142:: with SMTP id ip2mr4035839pjb.207.1638856147766; Mon, 06 Dec 2021 21:49:07 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:903:1c2:: with SMTP id e2ls9527703plh.9.gmail; Mon, 06 Dec 2021 21:49:07 -0800 (PST) X-Received: by 2002:a17:90b:2252:: with SMTP id hk18mr4101275pjb.218.1638856147087; Mon, 06 Dec 2021 21:49:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1638856147; cv=none; d=google.com; s=arc-20160816; b=kTnTQxXOnt6l9VXbr2DM2HCoTwCrhtoZmLY7kspnXoSJ0RqEKF4IXznIXipEvV7P+g apTEB/n47TczJo4y/6cn7UGNV2GACrTaHWfVYPbbX4WWUDMHzmFRgi0Thlu9fUNeMaYT 8GVSalfzM84NlorET1N5G3SwLssbuJTstcY+FTZwH2rFW63KA6MTscUsdIgvwBvn5al1 q6s/UV7WGCM+A4+txw03zTLRm+gQQxptZozGE+6a2/HIBvzC8pRTZ9HcnjsgFTBZIZzm DXxbnZHsUcUrCXN7clPz8Gg6huQQ1OX0XokgApRK0ymIQ85A0JgZ1PUym30LgQ1+Wbkh f0Lg== 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=1KDzFg9UJvJcv5oD+yqgslacyH8b6y34UOPGPd05YOk=; b=EeKO8+tYPcFAZJ4W0iot1Mb2ByoiE+8VFQslv7y5KJJ1M1mv7Q10YyE4vLTwY3YjDS BWSjCaUZAIhw3vcLgNtShgPw7IgJDMmGSZbsAbqzqJsvas/Cwoo8dJPLQ2NCv2NQhO2C sIBK3GCHM/dAALJcQtTVj7x0mcyPDykB2SswHK1BBi4duT5GMW6cUP101j/KHOXw57GQ UONpY3Qe5sH5mKiFc3UjWcyJbuaHRV1XHfYpnGaktcCyr/RwZQJbawZ8NiIZgblfdIwf FCpfXTVGcLjzDLPa7J2DCqWEyo0fn8rUkiRoK5A85emnhX8QxNLqOnHPHrndM7GMJqcR 9aSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=drb8lSpo; 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 k19sor8336654pls.44.2021.12.06.21.49.07 for (Google Transport Security); Mon, 06 Dec 2021 21:49:07 -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:18d:b0:142:8ab:d11f with SMTP id z13-20020a170903018d00b0014208abd11fmr49391383plg.47.1638856146790; Mon, 06 Dec 2021 21:49:06 -0800 (PST) Received: from localhost.localdomain ([2405:201:c00a:a0a9:ac1e:ca0f:5f0a:c85a]) by smtp.gmail.com with ESMTPSA id f7sm14496352pfv.89.2021.12.06.21.48.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Dec 2021 21:49:06 -0800 (PST) From: Jagan Teki To: Rob Herring , Frank Rowand , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Laurent Pinchart , Robert Foss , Neil Armstrong , Andrzej Hajda Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH 1/2] of: Add helper to lookup non port child node Date: Tue, 7 Dec 2021 11:17:46 +0530 Message-Id: <20211207054747.461029-2-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211207054747.461029-1-jagan@amarulasolutions.com> References: <20211207054747.461029-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=drb8lSpo; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" 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: , Add of_get_non_port_child() helper that can be used to lookup non port child nodes. Some OF graphs don't require 'ports' to represent the next output instead, it simply adds a child node on a given parent node. This helper lookup that child node, however that child node is not a 'port' on given parent as 'port' based nodes are looked up via of_graph_get_remote_node(). Example OF graph representation of DSI host, which doesn't have 'ports'. dsi { #address-cells = <1>; #size-cells = <0>; port { dsi_in_tcon0: endpoint { remote-endpoint = ; }; panel@0 { reg = <0>; }; }; Signed-off-by: Jagan Teki --- drivers/of/base.c | 29 +++++++++++++++++++++++++++++ include/linux/of.h | 6 ++++++ 2 files changed, 35 insertions(+) diff --git a/drivers/of/base.c b/drivers/of/base.c index 61de453b885c..31bbf885b0f8 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -854,6 +854,35 @@ struct device_node *of_get_compatible_child(const struct device_node *parent, } EXPORT_SYMBOL(of_get_compatible_child); +/** + * of_get_non_port_child - Find the non port child node for a given parent + * @node: parent node + * + * This function looks for child node which is not port child for given parent. + * + * Return: A node pointer if found, with refcount incremented, use + * of_node_put() on it when done. + * Returns NULL if node is not found. + */ +struct device_node *of_get_non_port_child(const struct device_node *parent) +{ + struct device_node *child; + + for_each_child_of_node(parent, child) { + if (of_node_name_eq(child, "port")) + continue; + + if (!of_device_is_available(child)) { + of_node_put(child); + continue; + } + break; + } + + return child; +} +EXPORT_SYMBOL(of_get_non_port_child); + /** * of_get_child_by_name - Find the child node by name for a given parent * @node: parent node diff --git a/include/linux/of.h b/include/linux/of.h index ff143a027abc..3e699becef82 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -290,6 +290,7 @@ extern struct device_node *of_get_next_child(const struct device_node *node, extern struct device_node *of_get_next_available_child( const struct device_node *node, struct device_node *prev); +extern struct device_node *of_get_non_port_child(const struct device_node *parent); extern struct device_node *of_get_compatible_child(const struct device_node *parent, const char *compatible); extern struct device_node *of_get_child_by_name(const struct device_node *node, @@ -678,6 +679,11 @@ static inline bool of_have_populated_dt(void) return false; } +static inline struct device_node *of_get_non_port_child(const struct device_node *parent) +{ + return NULL; +} + static inline struct device_node *of_get_compatible_child(const struct device_node *parent, const char *compatible) { From patchwork Tue Dec 7 05:47:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1799 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 68F763F03E for ; Tue, 7 Dec 2021 06:49:23 +0100 (CET) Received: by mail-pg1-f200.google.com with SMTP id d2-20020a656202000000b00325603f7d0bsf8135380pgv.12 for ; Mon, 06 Dec 2021 21:49:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1638856162; cv=pass; d=google.com; s=arc-20160816; b=p0fGgo2VF9zx6S8LG6j3MUvcwIAMOIABb16KSft9ZgDbNHlGHVXFY2g4eJSQn7SCJY JX/CvATqyH+jZLNAYMI55b9jvVBPs0VS5RpATX38MCodBJBPen/yA0mydFW6CXRI5ElS nkW+GIdOlg+VcW/385r+/Zm7qOCoXxxXCww+CR5qVQ6Bzy6U6kxMXAubDrrDPhMOZEPg ybVvX94pqlaBNhoaetTfy51vzoo0B2dDO9klDZjBTNYpVkTcuBS0iuprO8+crfCCg+9d dHY0AGMkIrQpG+RdK5O+L+2iwGGbNg6Mg+4oLDJvsIGtXgQqJAX03NQZUod59ddmGu6K YRUw== 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=VSSlwRddzqG6EFX4OeipZ7LXBXwsugQEVK84+KkDkoQ=; b=WUbanEYYNEt+SKIUZnrhQlyDZyTsGRAyNggAKSXLLsAIrj7FxWnyJgCLCfsygx+zCw BjXLD9ykRuBJIcGt7qaJQxCk/LIAHKF+cN+yiuTeu+fG54ZOu5KA/zMXXnUGo9UYWOE7 e6s9frrh3GHAvhtkJDzQwuHtF0WUYu0uyHO1cBr4G84LsNmWS28OSwufMEaxII7cEsYQ /dVqRsDM/RHa8I6RIA94EjNXxlAF39BHUQntTEwx0BcYYPKDySlxhBylsfv1IQGSVHe7 ZLKme6PQcXArRmRoPn8xeMrv1dSq7KJwpb9gVm+UrOR7s+bWD+bG/Zgu7Y+YoqRlSzlK LiTA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=aD7fgD5L; 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:in-reply-to:references :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=VSSlwRddzqG6EFX4OeipZ7LXBXwsugQEVK84+KkDkoQ=; b=UbxomwIxFRJF1ddNs8NNQRCvhvYx4wo9elSo2/V12PAWpnXT9IV0/N24DGdaffH0jp 8TbG6VIkHWUTPwHMUj6AIXeQb3/wy8cv9zvHBsGPhO9oJrqv7es57Pgbm8Zp8BXwyOib BT1X9uuDStThZ4kkutTJTQjnuJVUkzsPBWazs= 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: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=VSSlwRddzqG6EFX4OeipZ7LXBXwsugQEVK84+KkDkoQ=; b=RgqIVppp0XZ149yIIyN2WuOQpZobMyXQAnm5gSndPFBulxZGq0j5tLncrEPkrUJ7sd 9CMPjDJyhoulocJQUgKXlFrlMUwSo2HqA7KDi1fOnvZV5tJ271ilAto4DZQJqTSST28x stQ4g3BryfUI1ulOIH+OAIPSlNKud5wWGJNbQegJ5JNf9dJ2QlKPQ5feahJehVcjmo0J hO/KiHbqaqu3UTH+Kh8rHkxI2+F57FCVJN5N76m1kgWuWQxRJ74KCNSyZhm9GgfhoETY 9eMWrkFQNSHAHnKT5XhWUJO7oScW+ZmQd10JsjL6BPe+G0FHb4Xws0gvAZ7oukdn6WSx royg== X-Gm-Message-State: AOAM530GIy8CtvHIwuMpHUkNpRJJOpeFQ3wVIcRj2EB92+DPhxmkhxL9 FLxX0f4NWvhfjOtXFmsU3bW7nXau X-Google-Smtp-Source: ABdhPJxEAwhnRG2NfieCR/ZRGNehEU6oxx8E5vxJc/BYngeGEQfSfDEp4a/YYNyln7rDahUUc/rWaQ== X-Received: by 2002:a17:902:ea10:b0:142:112d:c0b9 with SMTP id s16-20020a170902ea1000b00142112dc0b9mr48739595plg.35.1638856162127; Mon, 06 Dec 2021 21:49:22 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6a00:a81:: with SMTP id b1ls7375795pfl.3.gmail; Mon, 06 Dec 2021 21:49:21 -0800 (PST) X-Received: by 2002:a63:ea52:: with SMTP id l18mr7532389pgk.114.1638856161458; Mon, 06 Dec 2021 21:49:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1638856161; cv=none; d=google.com; s=arc-20160816; b=rSrOyeMuQVDPfOWMBzyEr1g7ssxOVh3+BCisCnU40YZJ9mZijpA2My8zONDYBaw6Jk hrmQiw0kgPZZVGw29LGlO6UeB1A5+Euek/vs6b/mnovXPEfAHJBFInAPlDrBzbd+M6X6 nqqVAc1IjFrNBbYaHmNfDMRzphICegbRdYTeEH13QJ6SAUEgyxlRLeF38xPTf+y8JKA9 GcZ0viR4DiZ8cVS1ZPt0Sm11AWWkzeqtsSjccti+flXZbrCj9qF1/YSrh95p6jQwTTPK e3RKEtjknvQEeOR+TDb7sddHsbpOYdPNVk6yi6UhB/8ThqGAqPJz7X0W3pqL1Ft/yMy5 FdJQ== 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=oI+jB1Oj81gXS93Xi29AaslGAFYJbNNV4lBDuspdSkg=; b=ebQOaNOy7Uhp62TQYQoMfHvgZu8hvN/Zklh4BAfrW239+dTH4wW7XDBhM0OiVWRMvZ Px0W1GthPDtZBR47mJob49ARBRrx7HS11FvigsW/Ez8P0lJCkn7AZOqPdhD6eD03hErN keX2iMOOT5zCxsjUPT2oHbYhp0PjTgk8ZTmHTSk49WT2yBDrFqFx2EefHlzo+XJbP0Jw N56vk+9zOnQtfYNVjsdsIobzyn3JaHdk1+ffMeS2oAkI4BeSLpAZlHI/8H8Xf02CjjzV Fk2LoZ1uuHlaS7B5/44vVAhEt8+4EHRSHXL/cICVs6sKfcvl2WCsZu7fwCeGLUCSerbj CqpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=aD7fgD5L; 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 w19sor8359137pll.0.2021.12.06.21.49.21 for (Google Transport Security); Mon, 06 Dec 2021 21:49:21 -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:285:b0:142:21ba:2191 with SMTP id j5-20020a170903028500b0014221ba2191mr48896433plr.28.1638856161190; Mon, 06 Dec 2021 21:49:21 -0800 (PST) Received: from localhost.localdomain ([2405:201:c00a:a0a9:ac1e:ca0f:5f0a:c85a]) by smtp.gmail.com with ESMTPSA id f7sm14496352pfv.89.2021.12.06.21.49.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Dec 2021 21:49:20 -0800 (PST) From: Jagan Teki To: Rob Herring , Frank Rowand , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Laurent Pinchart , Robert Foss , Neil Armstrong , Andrzej Hajda Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH 2/2] drm: of: Lookup if child node is panel or bridge Date: Tue, 7 Dec 2021 11:17:47 +0530 Message-Id: <20211207054747.461029-3-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211207054747.461029-1-jagan@amarulasolutions.com> References: <20211207054747.461029-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=aD7fgD5L; 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: , 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 cannot be a 'port'. Examples OF graph representation of DSI host, which doesn't have 'ports' dsi { compatible = "allwinner,sun6i-a31-mipi-dsi"; #address-cells = <1>; #size-cells = <0>; port { dsi_in_tcon0: endpoint { remote-endpoint = ; }; panel@0 { reg = <0>; }; }; dsi { compatible = "allwinner,sun6i-a31-mipi-dsi"; #address-cells = <1>; #size-cells = <0>; port { dsi_in_tcon0: endpoint { remote-endpoint = ; }; bridge@0 { reg = <0>; ports { #address-cells = <1>; #size-cells = <0>; bridge_out: port@1 { reg = <1>; bridge_out_panel: endpoint { remote-endpoint = <&panel_out_bridge>; }; }; }; }; }; dsi0 { compatible = "ste,mcde-dsi"; #address-cells = <1>; #size-cells = <0>; panel@0 { reg = <0>; }; }; Signed-off-by: Jagan Teki --- drivers/gpu/drm/drm_of.c | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c index 59d368ea006b..1c4cb809d7bc 100644 --- a/drivers/gpu/drm/drm_of.c +++ b/drivers/gpu/drm/drm_of.c @@ -249,18 +249,34 @@ int drm_of_find_panel_or_bridge(const struct device_node *np, if (panel) *panel = NULL; - /* - * 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. + /** + * Some OF graphs don't require 'ports' to represent the next output + * instead, it simply adds a child node on a given parent node. + * Lookup that child node for a given parent however that child + * cannot be a 'port'. + * + * Add precedence to lookup non port child as of_graph_get_remote_node() + * returns valid even if OF graph has 'port' but that OF graph remote + * node is not register panel or bridge. */ - if (!of_graph_is_present(np)) - return -ENODEV; + if (!of_get_child_by_name(np, "ports")) { + remote = of_get_non_port_child(np); + if (!remote) + return -ENODEV; + } else { + /* + * 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, port, endpoint); - if (!remote) - return -ENODEV; + remote = of_graph_get_remote_node(np, port, endpoint); + if (!remote) + return -ENODEV; + } if (panel) { *panel = of_drm_find_panel(remote);