From patchwork Fri Sep 16 18:17:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 12978757 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0700DECAAA1 for ; Fri, 16 Sep 2022 18:20:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=NmaPt/0HkGiwVHx3m6h0DuGDff+fGepXUmNn9yYHLXM=; b=e4pXAGOFm8WSp5 YvYxzeuPNvJIXeYC0An1eAq/Dludn9dt9PTIk09Bd9++F9DLcZisOW8gAFjn3RTUxXbzfYGVuhH7r /wxkQPFp5SM/zHOpkc9EfnX+z1jzTpggPZ7uk7XapgDwlyQqzmHDHcqI0qW2C/l/nmMrNCUFo2ohe GZ5qU2FieV9Fqp5z1aDNc6Ck8UOesmelRzb5SWx/511BxKkxKFCL2W7v37AaMsMDh4N+nSpxmWmcg yhrtph3yDEM2y5bFk38o6xCex1RvCC1o9AXoiVAwQLxgsmSWSXlcl2Kn44BG9XrPQOIuDvPwETTnf rDxdtxfy4cc15fZFZz+A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oZFvV-00FlMF-KM; Fri, 16 Sep 2022 18:18:57 +0000 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oZFvL-00FlDQ-38 for linux-arm-kernel@lists.infradead.org; Fri, 16 Sep 2022 18:18:49 +0000 Received: by mail-pg1-x535.google.com with SMTP id t70so21081422pgc.5 for ; Fri, 16 Sep 2022 11:18:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=O4ORDYv1Lr4Erp5ISyKI1IY+eX0JNrP0U9+cbOWHuzE=; b=jp4epsHmkzL2s6fcu/NomruOZE4V3y+QjGop183xKe/qqhK8SidV5iGsR1JXBqpU9r atkYNjGp695mYOqJCthVvdz0Xm48/8HGQfGKTUCZFsYK2Rl7UWA6T0mJR4epLLpridXF krT4HWvXkD9cxVWmjkJdQs7lra5nFpXwgygQY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=O4ORDYv1Lr4Erp5ISyKI1IY+eX0JNrP0U9+cbOWHuzE=; b=mt29T+z7e4hLRjZzJQ9s8LtsbtoTiVPSgD6qSz8OnrjuYcRXMdkPQCwiaH6XgNHp6Z /Yby93N0dA/M6KLK8859JsCQ6mQL/8vUnjmTEkoTZHPUL7yr0eCyMYk0jQKh/3/z1hWh 4NFEdrjJjBjvU4ZAZT4to+FMUKJFdmxUuMimsi5WT8fPLZNOcnmW7M3TXBf5s/KK8Tah bh+YZyBJTI6FHdExZopRKx5Mq5/yv5Vcp80+TvPQ0d8zvD2a1/790RMPFS4evzrNSya9 zlkm6xwhncd//Da8/qKXb7YLZMZAAeorgOr/GzZqJ3skPfpiOIUFkaGbFng3jtukXxgz sLqg== X-Gm-Message-State: ACrzQf2k/u9oQUq7/UuZ5KCgxUx5H8gDQMnoLyG2JWX7wEdlkzkaBWnM 1PgkrNgZ+5+m1dA8xNNBiwWqjQ== X-Google-Smtp-Source: AMsMyM4iiUXwS9yxTaRCsFNp3QHSpwBGsmZV0SQiwiwBHlS3hXAoS9KPeOPpoweCiXB5Gl2Yuhrvag== X-Received: by 2002:a63:154b:0:b0:42c:60ce:8bd3 with SMTP id 11-20020a63154b000000b0042c60ce8bd3mr5671772pgv.372.1663352321699; Fri, 16 Sep 2022 11:18:41 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c00a:a073:ae5d:6ee4:5c2f:6733]) by smtp.gmail.com with ESMTPSA id d14-20020a17090a6a4e00b002007b60e288sm1770000pjm.23.2022.09.16.11.18.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 11:18:41 -0700 (PDT) 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 v5 03/11] drm: bridge: samsung-dsim: Lookup OF-graph or Child node devices Date: Fri, 16 Sep 2022 23:47:23 +0530 Message-Id: <20220916181731.89764-4-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220916181731.89764-1-jagan@amarulasolutions.com> References: <20220916181731.89764-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220916_111847_197522_1B568046 X-CRM114-Status: GOOD ( 19.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. 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 ccaf87e19e81..2e79fbfe2a7d 100644 --- a/drivers/gpu/drm/bridge/samsung-dsim.c +++ b/drivers/gpu/drm/bridge/samsung-dsim.c @@ -1340,18 +1340,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);