From patchwork Mon Jan 23 12:23:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 2636 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 67FC73F039 for ; Mon, 23 Jan 2023 13:23:45 +0100 (CET) Received: by mail-pg1-f198.google.com with SMTP id d10-20020a631d4a000000b00491da16dc44sf5358979pgm.16 for ; Mon, 23 Jan 2023 04:23:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1674476624; cv=pass; d=google.com; s=arc-20160816; b=L1xdoCzCx2201XFdHp1oYCcNxaEtAGh9Kvq2WlSpOPK7y6spoXF+4cl0U69FtNEkYU 32t/h17ZSkiQKHKtw48GBJSLZfARfOSERJXRI5yz/Dc4cVZPAHTUHSpKcKaAJT5RlDjn fR0HFaVjIrML/7u9YoWDmB93vWAr9h2yejAeU452MJlI+7Zd4J+FjErFDynppRkGt5QX qc0eRtFZPFlT8Yw4Gx45B8zsu+s6qQIVMn63R3RKmVQsNkVSWuq68mMVmfRAu7UjJVoL bD3Tm5z4jAuaBvOgZtwKaDmDNZL1IW9bB4sSPZOlxTtAjS9QY5bjD9qmV9ZcJKf6JzQV 6Bpg== 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=3Y7s/ulxHFSGawNxIH6V1omksNFZCAlQ3JqaXKlMUBI=; b=IR7qNDQkMTJ2Nms3p8wxEl+oEPG6CP4ygnQNUIRJNl7pp4JjYTa6vJSeverJ94ciIn ekAbkHog/B34ABPWqJZ6NO2tzZTDwGXNUB0dx1dpUSM3v7fyb7oai2FZ+Je2QHGAxdj1 8cbxGn/qhsqFDPkt165an09G9YENGJzBc/q3R5TeNz1wMl+VR+DAgRl1lBpEMD4MDRhM 6EuV6J2sktExX1Xdh/8Hrcps//f/1ke94H3HQmIt2lcAykKlbyqbtFVx5Gj9kpghVKb4 4/UYSX5qPqX7skyWlAAWUzfSByBKg/C8BzabsvYYNFB/EF5axE+981WDjemKqid8Cgyu w0ig== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ryMoHDS3; 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=3Y7s/ulxHFSGawNxIH6V1omksNFZCAlQ3JqaXKlMUBI=; b=eX+4viCkoOQ82HuvH2lm73PoEzIuiMzHsIKSUQYvn+FZJAyqkeQHlLpC3S+dW7diNr d3Oz979SSfyZnsKR5KVlP1AQvL/yZn36VqKY8HS6eojCCNtaxKwzpf33tD2C1zLrT9eh igJVfq2B5vCspPGp12lhPRg/QXLI/7cuq6csc= 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=3Y7s/ulxHFSGawNxIH6V1omksNFZCAlQ3JqaXKlMUBI=; b=VSrtagBpJJz12gob89rRyBLd7uRWHGJ4Z5fLoqi+3uZspmD40j+D32WdNbqGVu59/+ J1TWgpSun5TKS8xaE3SdyS5Usdnffzd6pBXDs5MF5Oa8WIobsYFbjtqw4RBgjT/7O/As 4kOzdEl50XFizTYZ2ZlAEuTH0QixPOyYhR078SKeIXFgsGs4Bhf0H9tfLGQ3OjyLtfk8 BpARhTHuCYTGl44Qt+5kfSCi30P37ufBEqpzndhbs8WflN6mBly3laX1zCBWEvN+t7zM 8yKKawUfjqrel/MZ8mlTrjZkR7h9RzVXh0huDvU5h61tQNbQLTsMQsVbT2hqFFlQrHna v2Eg== X-Gm-Message-State: AFqh2kraO0SBHpp1fGyud/v1gkBLcHdsRyEu5NMi8Rjv5lowt4EneLFB yQM44cmkjIWsXKCmFRIhb9cdO5uI X-Google-Smtp-Source: AMrXdXtiG0kXokyOoAl2s+TNkmiaA9XhE717Hb0fY8ypY3mKjOFo0OEcvk7YuMcUjE4UDf5iAD4woA== X-Received: by 2002:a17:90a:2849:b0:229:b7c:e55e with SMTP id p9-20020a17090a284900b002290b7ce55emr2291300pjf.179.1674476623984; Mon, 23 Jan 2023 04:23:43 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:903:4283:b0:178:3881:c7e3 with SMTP id ju3-20020a170903428300b001783881c7e3ls12693402plb.11.-pod-prod-gmail; Mon, 23 Jan 2023 04:23:43 -0800 (PST) X-Received: by 2002:a17:902:b282:b0:194:810a:d69b with SMTP id u2-20020a170902b28200b00194810ad69bmr24815112plr.3.1674476623086; Mon, 23 Jan 2023 04:23:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674476623; cv=none; d=google.com; s=arc-20160816; b=ju729XnX14H41bT75y4gW5uqdR9+xOHX+HJ+7fjTu35J4LPjoPG33+78a9FI6EzZkY /ucJlQx24EHBgmsxg1pVK8g1YKLHoiRQ7C7JGgobhe17cANLAHtD16uMxXsihnGYogbz WHq3Qf9SOdYucjBSch05ezPHL3Tf/bh9AK0466Jw2Au7jjMW26KSYHQ9fmySL9+xs9UX hPhe1cYN27iRzZw+8OYLlVdAyub2xdnRg4sIGNLyVteMwHiYlYXDAET++bpP4WJU3I8u 2JlmbfD2my2XLbxLvzQrxOG9dcLu9ff0jdsy9su3QU0d1P3RXdF4SJPrzKceSGByuYfv mJQA== 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=MmdIsQUt1eQ5Mg1zNk3b8g7tN9qiVqUYt0El2a9KJYU=; b=oDayWAlFvXNpUU17D4aDggg/xFYCK0rrZORewlcwsf+WhQrgsN5cuZHNBtfZ6S/Hr7 ea0f5urno/+oEQHj7HYOZvSsYjhZkmVvGeTQ9YDue8CTUUE/caHWyb5Y3YKmUSxFFzul 9o39nbZGaFF57HQ85JElXEtqfTyavFnWvOhO8Zy1OrsqrvfYAaDy3/GFeOhCgAWOFYBA aNSmLNUNOtNIO1FFOunqUuqPOIOfwZSXEjAsTOOiaiBF9j43+OLtG98dfqGaXF6R4j83 bIqoNLsdWcGtRgS3HCq8bm5RDZKJdtg71da4riQTVprEYdJlG3AKINQQupDIrAXMtiXZ dm1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ryMoHDS3; 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 k4-20020a170902694400b0019607a9c7bfsor646337plt.20.2023.01.23.04.23.43 for (Google Transport Security); Mon, 23 Jan 2023 04:23:43 -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:b209:b0:194:7aae:f272 with SMTP id t9-20020a170902b20900b001947aaef272mr24074654plr.30.1674476622742; Mon, 23 Jan 2023 04:23:42 -0800 (PST) Received: from localhost.localdomain ([2405:201:c00a:a15f:2279:f361:f93b:7971]) by smtp.gmail.com with ESMTPSA id w10-20020a170902e88a00b001960806728asm1291811plg.88.2023.01.23.04.23.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 04:23:42 -0800 (PST) From: Jagan Teki To: Andrzej Hajda , Inki Dae , Marek Szyprowski , Joonyoung Shim , Seung-Woo Kim , Kyungmin Park , Frieder Schrempf , Fancy Fang , Tim Harvey , Michael Nazzareno Trimarchi , Adam Ford , Neil Armstrong , Robert Foss , Laurent Pinchart , Tommaso Merciai , 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 v11 01/18] drm: of: Lookup if child node has DSI panel or bridge Date: Mon, 23 Jan 2023 17:53:02 +0530 Message-Id: <20230123122319.261341-2-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230123122319.261341-1-jagan@amarulasolutions.com> References: <20230123122319.261341-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=ryMoHDS3; 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 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 7bbcb999bb75..e165951e3545 100644 --- a/drivers/gpu/drm/drm_of.c +++ b/drivers/gpu/drm/drm_of.c @@ -216,6 +216,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 @@ -238,7 +267,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) @@ -259,30 +287,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 10ab58c40746..7a97157c1fa0 100644 --- a/include/drm/drm_of.h +++ b/include/drm/drm_of.h @@ -47,6 +47,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); @@ -99,6 +103,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)