From patchwork Thu Nov 10 18:38:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 2469 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 2509B3F039 for ; Thu, 10 Nov 2022 19:40:47 +0100 (CET) Received: by mail-pj1-f70.google.com with SMTP id j21-20020a17090a7e9500b00212b3905d87sf1494278pjl.9 for ; Thu, 10 Nov 2022 10:40:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668105646; cv=pass; d=google.com; s=arc-20160816; b=dD6nc5rLBeKEpMHXbto5GvNRuaEIQp7Z17g9NolAGumYIQshmCTHPY7WSoY3MJc3fW WbqYzqJ7aQrzhf7syXN5UJKIRiqjbITc/UynA8C7Ctg1m1hibXRcVPqUyTRirWIqEtBK 0vZnaxzrdeJAxj7fFRnFZtoxY+h7ULeQt4pMIMOqU/3rz2Z+6crVAolx6GLYrD7Yo+t6 BASo2BxoXs2JOlwkGhaDKdKEqXOc9RcAj6xsuKk5QGXe8hpfICCc4/izusImCcDQKLHA 6wOl5w4YReTqG2jc/PA87VhUo4ZqoOLuYv8ttLaadCb/m0aOP7rH/VDaXP0iJTSlNvaw flEQ== 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=EFceTau3J18WOKo+N3zUOtanCGvn5IvJFDmixpL5bdY=; b=jtAonAJS9kLZ3WM/dgCYrRAEmURpFJdhRclq3i8NHDfreasJ1y56//l1SEkR/0mSQu bdHxzbLOMBlOvNlfB0gCYmQwCVmZjkUyAlkBCfEDHL0NzcX65ULJM36YJKUIq1zGVYt/ 14IuEXrArcgqL8PCv0AspnnuAh7MNSHhhQOrsG876aJGGemIn1Od9ffdKg1ceI4NZ97Z gbZZgB5V8m8trzICLP4SySbCDlBAr5UxdCfWolwBo5dDAFPJMns2VR0yabyD9uXLk84A wqH5bGO6T8u6vXAxGgkB+gonxr2593jQGRrbLBEUAxuet6lU9+jpCSO1GDuHC384cL2k 4n9g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=CtMOAp3V; 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=EFceTau3J18WOKo+N3zUOtanCGvn5IvJFDmixpL5bdY=; b=fnG7m2U482aj0UeKdgAl7t9W94zAISwiPXQx4jTOxWR7j4fA79KsF/t4PYRUwiUzp5 D6/XUHp/DttaVhbicIeTKdBhstNafPY4hDk7S57qt+ZtRK85f50rXfYvEmJ3IQwQv31P EdeB+QjDruuaJ0Tc/m1d2Li+h5ZCsrL8/wvQA= 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=EFceTau3J18WOKo+N3zUOtanCGvn5IvJFDmixpL5bdY=; b=fw5MmMdPB99tdtZkVbqRW9CmJUmA2W8QuB9KhGF//9IXD4x+MxzoITEhrjYbMdwQWu 6k5D98tUMTQYmssjnAfonVM/6UU45tXaK7eEf0vNCQ9XHY/DjgZ4QjDi9EibTh6nt9iR GNBrXIb6Pw/v2aHE8sDd91InIoQNjeuXHnzpl50BHM++/eaGQru9RDZkWuwmP+zCNZEC T+ws8U2tatT5QQfkWIVVmpTNs2hc1+Inw3OAjLXBCe6eUvfRPsemm9w3CLMYy0htDQwU ZuzwKv13g6GDCsG4a5habGK27ofFfdaptvdNhdSNmifjKs1VHY2dfTq5w8xzKNgRBs03 gZwQ== X-Gm-Message-State: ACrzQf0MgK6gZjIc4zuUZr8OsuHNTgkDj/MT9EB9pTSssNVDUOYeUTP5 zC4JH/rw4/eVs3Wc8UVfU/WLymVD X-Google-Smtp-Source: AMsMyM7cbAFw1pfUdZ8T1gzlz9Qa4ch7EemL25yEhUV6RFdf9Bsie6MMY8yRSfavjxVMBeq+9kZvWA== X-Received: by 2002:a17:90b:d88:b0:211:4d8:1c93 with SMTP id bg8-20020a17090b0d8800b0021104d81c93mr83476388pjb.41.1668105645981; Thu, 10 Nov 2022 10:40:45 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:903:2645:b0:188:62b8:814f with SMTP id je5-20020a170903264500b0018862b8814fls1666806plb.1.-pod-prod-gmail; Thu, 10 Nov 2022 10:40:45 -0800 (PST) X-Received: by 2002:a17:90a:be01:b0:20d:747a:c507 with SMTP id a1-20020a17090abe0100b0020d747ac507mr1714036pjs.145.1668105645175; Thu, 10 Nov 2022 10:40:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668105645; cv=none; d=google.com; s=arc-20160816; b=R+vRxyhlxKSi93X2HVAmxP9WnAv5v/NW9HuG1v9P2xnzizpkwJQ9pnrBDqrqUBcxfH 9HR5kTRxXNlPUQ0DzEhmMV7zMIhzlI3Wb8/Zbw9qHnoT10CCxbx3x4vVca48IqFCa6le PIKzAqX+cvRxq1QKZbdQuFhPhYQn6L9PdkIU4UahMU9XIz6/7uei8p7XA10NvgjyKh4g 6MX7qZiOP8TQvtz1XAGfdmm5WNxktZUWTZ64XJdsX5H7ArpZcV0JR+pvx5ovXZXfK9z9 AKApClJiNJhcI3DTtcQxouS/0ajRvP+zWB4qAPFjmT2D932/69cQI5VwSuZLpcsZ7iti 2QSw== 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=+e2h+lCQ/0aC2q9ZjBOYGxDlyScJI/33GnJoPGCGoxA=; b=kZoPp0YOiROZ5eu4NAbkRRwsZUgF5wAi/ABQOE9XfpZWR/3iPOnNsoX3yqGipodv4Z EuiWArgKWN7p82SFrGD2FWDOjb7n4rv7AM5FbqJ1V8hzUQHGHaI3Os5fGkm6PEZ5+sfK GRx7UcweXS8ZqTSO9z0SaTNAlilsyjQCYnoyZSG5KxDO27QK9hX/Q6URne+IY3B+FY+u toFv3FV5YiR7YwXR6eYcGYhwRexYyKe5xGFVjsMx3QFDPTUWVbzF5NHwWf0A53S8CZvJ fqifzhONEzsQlDr4cIuus5CpWupAeOOvt5fuxjaMtNf5uDklOXPaPhb2MV7i+VVOZ+YY 6c0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=CtMOAp3V; 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 p9-20020a1709028a8900b0017f853b66fdsor22284plo.94.2022.11.10.10.40.45 for (Google Transport Security); Thu, 10 Nov 2022 10:40:45 -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:d4c7:b0:186:8cda:c9c3 with SMTP id o7-20020a170902d4c700b001868cdac9c3mr63797254plg.154.1668105644850; Thu, 10 Nov 2022 10:40:44 -0800 (PST) Received: from localhost.localdomain ([2405:201:c00a:a809:b5a4:486a:f07:f67e]) by smtp.gmail.com with ESMTPSA id c2-20020a170903234200b001869efb722csm11635627plh.215.2022.11.10.10.40.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 10:40:44 -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 Subject: [PATCH v8 04/14] drm: bridge: samsung-dsim: Lookup OF-graph or Child node devices Date: Fri, 11 Nov 2022 00:08:43 +0530 Message-Id: <20221110183853.3678209-5-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221110183853.3678209-1-jagan@amarulasolutions.com> References: <20221110183853.3678209-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=CtMOAp3V; 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: , The child devices in MIPI DSI can be binding with OF-graph and also via child nodes. The OF-graph interface represents the child devices via remote and associated endpoint numbers like 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>; }; }; }; The child node interface represents the child devices via conventional child nodes on given DSI parent like dsi { compatible = "samsung,exynos5433-mipi-dsi"; ports { port@0 { reg = <0>; dsi_to_mic: endpoint { remote-endpoint = <&mic_to_dsi>; }; }; }; panel@0 { reg = <0>; }; }; As Samsung DSIM bridge is common DSI IP across all Exynos DSI and NXP i.MX8M host controllers, this patch adds support to lookup the child devices whether its bindings on the associated host represent OF-graph or child node interfaces. v8, v7, v6, v5, v4, v3: * none v2: * new patch Signed-off-by: Jagan Teki --- drivers/gpu/drm/bridge/samsung-dsim.c | 38 +++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c index b63e0479e71d..1c1a824b4ea7 100644 --- a/drivers/gpu/drm/bridge/samsung-dsim.c +++ b/drivers/gpu/drm/bridge/samsung-dsim.c @@ -1356,18 +1356,52 @@ static int samsung_dsim_host_attach(struct mipi_dsi_host *host, struct samsung_dsim *dsi = host_to_dsi(host); const struct samsung_dsim_plat_data *pdata = dsi->plat_data; struct device *dev = dsi->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);