From patchwork Mon Feb 27 11:39:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 2741 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 10D853F9C2 for ; Mon, 27 Feb 2023 12:39:47 +0100 (CET) Received: by mail-pg1-f197.google.com with SMTP id d18-20020a63f252000000b00502f11fb2fcsf1770811pgk.6 for ; Mon, 27 Feb 2023 03:39:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1677497986; cv=pass; d=google.com; s=arc-20160816; b=wmIrXh1EyUeo6aUbiWn+UT1nwlKI9cvVLFAhpkiFtFsD6EVfbmPqijKASArxdWmTai 8XUlJp9OJ6xzz3Une/ghQelzVOgF6mBj/nOqBl64YbfttnfrArdifZlCRkD22d0e+Kff JmWbaMD1L6sKREB4TLHDGqRwEUpwKfoVyoPgfwD2WPMysyqkT0KNe1ped3EyPZdmZrfl uBvM8RpbZuFQ+muqxV/Euu6lwucsP6WeXbbYWSJtRFfV3nu+6X5HsEqSBNbPNUls4trl VOrbgEAKT55pwQRU25B7H60ocP7RWkqATe97FcbLexf70z+CusXn1ZDWZtriQqV45RWE +m4w== 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=WEY6/o3Iz6e/T5XVcQP5WzEvCt/oldJnH9+r2evMzRo=; b=L/JGRwOuEYZ3sLl/kS8apS+ZBw8K32ODs+NBaFrNdcC9gAZohCAxugDR5g0pRNrslG 9FSdJKbz5K0nAorpqwtfC/3V7cAL/m1TgjtWhkQ+yOt2nbOlBvYvrObEjGBz0pjzlvcs IvgX3X55twQzOHKGEVkBUxgxazWP0V47zTc88z/c9nM39Mmxxjo0JX8xalZi9XED9xAv ngHOxKl56YkKgT+dhnMI/tTtb6WbgsWy0N90mBKkeaLYLtvtDbDWVblHtS2GwfALzyAC qt+NnEKZCKXphnOpNH8dHRmTzOR2zmfrcvloCCbZ//G9fh2It9GB+w7y1uQCpc5q3t0l HtOA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=i5B0Fixj; 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; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=WEY6/o3Iz6e/T5XVcQP5WzEvCt/oldJnH9+r2evMzRo=; b=cCwSxSQuASuuaihAoHh9wyORfw+mg8RKnJsOelwr3pHQfdA/JjZvaYNW4zZKhU2J4e NXPmC5OcvU5ws0z+u/1okWY5v2g3RK4LSvlQvD6Ag8swaGRczlGKuVHg24qS9bBxtCIa wMRlsH6VerGJJ86jPG/aClEuQtM2ei7hRvDkU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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: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=WEY6/o3Iz6e/T5XVcQP5WzEvCt/oldJnH9+r2evMzRo=; b=PAdoiplvCYXxX97EjbYPcMM7bmlylX+E/ZxUl/HhC878Jtn/yHZEPILs00zrw4Vb6S JO8vDtj0qmypjWHGooadAf1A2jRstSRQ8YEVtqy0Z6pc+xBuDjgnHjVevqC1t5X9wE0n vFPHMZ1NwS91dP65uu1mp9f7SrXKX0Grb+rgUavBn831aw5Kt59iP2oC/b1iUmnIv/zy ka43AjPn8PcHAH2mVHDxakgI4/2RZKrP6A8tfV54L+B+8Bf8XE1BFZfWDMy+LJvvECZ/ AuNVwOXQnf6Uon2pDocA6uIOHYu9thgB4Ic+PoEwaCXh/Xrz1WC+W3/v3TgCBs/pAbvP wSRQ== X-Gm-Message-State: AO0yUKURPkI/FPaX8iZ+qmcmXsEp61QVTZIAOFspaSSq6F2WWBqoiJZ5 MLjjHf629k5/uHo9YVrwzFZLOu9NgaWqYg== X-Google-Smtp-Source: AK7set/5h+vwoa8EYlLORaPgOSH2xHjv75ZmtAXRqPEb9RT45ufqsl52NQFOwBL9xKqDAANJNFagUQ== X-Received: by 2002:a63:7555:0:b0:4fd:4602:1b9a with SMTP id f21-20020a637555000000b004fd46021b9amr5880466pgn.9.1677497985842; Mon, 27 Feb 2023 03:39:45 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:90a:2881:b0:225:cae6:ff24 with SMTP id f1-20020a17090a288100b00225cae6ff24ls4577586pjd.2.-pod-preprod-gmail; Mon, 27 Feb 2023 03:39:45 -0800 (PST) X-Received: by 2002:a17:902:fb8c:b0:19c:f8c9:4dff with SMTP id lg12-20020a170902fb8c00b0019cf8c94dffmr5567252plb.38.1677497984957; Mon, 27 Feb 2023 03:39:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677497984; cv=none; d=google.com; s=arc-20160816; b=wUv9HLEW9MMZbN2/pGkKYAZ0fdw2I/66PFJVoGZp1HfrmnQWXFBNRQYu5fuUmGQRq3 fs1XFn8nhPO9iTjl4cbJ3TNY5OpZuHOn5Ojo16VSkvLr7BcXNE4nxMvXlQOBdUPfN4rH bzQXf0vT81bB6uyQ84cKof+BTxY2qEW4m06nnPCNDXSEk974U349zZ8nEvLP4zPNyNTM LiaxNOxrMeq5LYb0tN+dkeakYLdB0rUgh+YBorOcmFDMKlXIPQkN8kXuCdrlZz3fASv5 t6NLY7jqh+l2i1TO3GTtiDIje1R4cHtK+PIz5iUadu2ew9/ob7GT8NVyTZ9YPj5+Snzs LJVA== 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=gbvjHStPQvWuSxXASASmwsU09AsH+4vOrw1mjy5ckwY=; b=BIo0bxaC0kpbojKyzyYNqKY9CQAmPN5L1SPCmIKuYCfVoCd+UP/qYOJaw7lh+UATER DJE+HGXeQAUyMxiYPAwnn8pHx3KHK9QRFgsjFfOXE30a4xePvux5SjDSr3ajDz2Bz0lJ CzI4SGML7ZIuA/AtUHOpP5o5I6/BaoZIrtQ+lTWv/mpWgjRU1mb5tQJ285zbSZOMnauj Wjae3qK3ao5+5iv8MMiBVj9prfU7gqwt3R707sKRTMJ4fQW7168r5vSOcHfJaHwE0Zri XgW9mR2Zxn9TcM/2S50D+u94GB1KRQjCuN0STMFTlhMSxDcB0bnSo0oTG8vcC6BeLp0t j3uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=i5B0Fixj; 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 je9-20020a170903264900b0019ac76a59b9sor2139109plb.169.2023.02.27.03.39.44 for (Google Transport Security); Mon, 27 Feb 2023 03:39:44 -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:902:db0f:b0:19c:edcd:26cf with SMTP id m15-20020a170902db0f00b0019cedcd26cfmr9443714plx.61.1677497984630; Mon, 27 Feb 2023 03:39:44 -0800 (PST) Received: from localhost.localdomain ([94.140.8.120]) by smtp.gmail.com with ESMTPSA id k10-20020a170902ba8a00b0019c919bccf8sm4395277pls.86.2023.02.27.03.39.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 03:39:44 -0800 (PST) From: Jagan Teki To: Andrzej Hajda , Inki Dae , Marek Szyprowski , Seung-Woo Kim , Kyungmin Park , Frieder Schrempf , Tim Harvey , Adam Ford , Laurent Pinchart , Marek Vasut Cc: Matteo Lisi , dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, NXP Linux Team , linux-amarula , Jagan Teki , Maxime Ripard , Linus Walleij , Maarten Lankhorst Subject: [PATCH v13 01/18] drm: of: Lookup if child node has DSI panel or bridge Date: Mon, 27 Feb 2023 17:09:08 +0530 Message-Id: <20230227113925.875425-2-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230227113925.875425-1-jagan@amarulasolutions.com> References: <20230227113925.875425-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=i5B0Fixj; 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 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: , Devices can also be child nodes when we also control that device through the upstream device (ie, MIPI-DCS for a MIPI-DSI device). Unlike the drm_of_find_panel_or_bridge helper it requires a special case to lookup a child node of the given parent that isn't either port or ports. Lookup for a child DSI node of the given parent that isn't either port or ports. If it is found then it will directly find the panel or bridge otherwise lookup for the child node with a given port and endpoint number as drm_of_find_panel_or_bridge does. Supporting this feature via existing drm_of_find_panel_or_bridge found several issues while handling usecases. Here is the previously failed attempt of similar and the same has been reverted later. commit <80253168dbfd> ("drm: of: Lookup if child node has panel or bridge") So, add a separate helper to handle this DSI use case. 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>; }; }; Cc: Maxime Ripard Cc: Laurent Pinchart Cc: Linus Walleij Cc: Maarten Lankhorst Signed-off-by: Jagan Teki --- Changes for v13, v12: - none Changes for v11: - drop extra line Changes for v10: - new patch drivers/gpu/drm/drm_of.c | 112 ++++++++++++++++++++++++++++++++------- include/drm/drm_of.h | 12 +++++ 2 files changed, 104 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c index 177b600895d3..87cfd685318a 100644 --- a/drivers/gpu/drm/drm_of.c +++ b/drivers/gpu/drm/drm_of.c @@ -217,6 +217,35 @@ int drm_of_encoder_active_endpoint(struct device_node *node, } EXPORT_SYMBOL_GPL(drm_of_encoder_active_endpoint); +static int of_drm_find_panel_or_bridge(struct device_node *remote, + struct drm_panel **panel, + struct drm_bridge **bridge) +{ + int ret = -EPROBE_DEFER; + + if (panel) { + *panel = of_drm_find_panel(remote); + if (!IS_ERR(*panel)) + ret = 0; + else + *panel = NULL; + } + + /* No panel found yet, check for a bridge next. */ + if (bridge) { + if (ret) { + *bridge = of_drm_find_bridge(remote); + if (*bridge) + ret = 0; + } else { + *bridge = NULL; + } + } + + of_node_put(remote); + return ret; +} + /** * drm_of_find_panel_or_bridge - return connected panel or bridge device * @np: device tree node containing encoder output ports @@ -239,7 +268,6 @@ int drm_of_find_panel_or_bridge(const struct device_node *np, struct drm_panel **panel, struct drm_bridge **bridge) { - int ret = -EPROBE_DEFER; struct device_node *remote; if (!panel && !bridge) @@ -260,30 +288,74 @@ int drm_of_find_panel_or_bridge(const struct device_node *np, if (!remote) return -ENODEV; - if (panel) { - *panel = of_drm_find_panel(remote); - if (!IS_ERR(*panel)) - ret = 0; - else - *panel = NULL; - } + return of_drm_find_panel_or_bridge(remote, panel, bridge); +} +EXPORT_SYMBOL_GPL(drm_of_find_panel_or_bridge); - /* No panel found yet, check for a bridge next. */ - if (bridge) { - if (ret) { - *bridge = of_drm_find_bridge(remote); - if (*bridge) - ret = 0; - } else { - *bridge = NULL; - } +/** + * drm_of_dsi_find_panel_or_bridge - return connected DSI panel or bridge device + * @np: device tree node containing encoder output ports + * @port: port in the device tree node + * @endpoint: endpoint in the device tree node + * @panel: pointer to hold returned drm_panel + * @bridge: pointer to hold returned drm_bridge + * + * Lookup for a child DSI node of the given parent that isn't either port + * or ports. If it is found then it will directly find the panel or bridge + * otherwise lookup for the child node with a given port and endpoint number + * as drm_of_find_panel_or_bridge does. + * + * Lookup a given child DSI node or a DT node's port and endpoint number, + * find the connected node and return either the associated struct drm_panel + * or drm_bridge device. Either @panel or @bridge must not be NULL. + * + * Returns zero if successful, or one of the standard error codes if it fails. + */ +int drm_of_dsi_find_panel_or_bridge(const struct device_node *np, + int port, int endpoint, + struct drm_panel **panel, + struct drm_bridge **bridge) +{ + struct device_node *remote; + + if (!panel && !bridge) + return -EINVAL; + if (panel) + *panel = NULL; + /** + * 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_node_put(remote); - return ret; + /* + * 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); + +of_find_panel_or_bridge: + if (!remote) + return -ENODEV; + + return of_drm_find_panel_or_bridge(remote, panel, bridge); } -EXPORT_SYMBOL_GPL(drm_of_find_panel_or_bridge); +EXPORT_SYMBOL_GPL(drm_of_dsi_find_panel_or_bridge); enum drm_of_lvds_pixels { DRM_OF_LVDS_EVEN = BIT(0), diff --git a/include/drm/drm_of.h b/include/drm/drm_of.h index 082a6e980d01..5e0d958121ce 100644 --- a/include/drm/drm_of.h +++ b/include/drm/drm_of.h @@ -49,6 +49,10 @@ int drm_of_find_panel_or_bridge(const struct device_node *np, int port, int endpoint, struct drm_panel **panel, struct drm_bridge **bridge); +int drm_of_dsi_find_panel_or_bridge(const struct device_node *np, + int port, int endpoint, + struct drm_panel **panel, + struct drm_bridge **bridge); int drm_of_lvds_get_dual_link_pixel_order(const struct device_node *port1, const struct device_node *port2); int drm_of_lvds_get_data_mapping(const struct device_node *port); @@ -101,6 +105,14 @@ static inline int drm_of_find_panel_or_bridge(const struct device_node *np, return -EINVAL; } +static inline int drm_of_dsi_find_panel_or_bridge(const struct device_node *np, + int port, int endpoint, + struct drm_panel **panel, + struct drm_bridge **bridge) +{ + return -EINVAL; +} + static inline int drm_of_lvds_get_dual_link_pixel_order(const struct device_node *port1, const struct device_node *port2)