From patchwork Mon Aug 29 18:40:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 12958342 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 52743ECAAD2 for ; Mon, 29 Aug 2022 18:42:39 +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=oOvs5V+vGM+18eQmVpkBgDd0L/HEvm+VRiQiDvCUiYs=; b=Y214edxnLGy9Ri HYAj/FR4MdVD0n4qCCpyJuujJOF2Z0pNkhowpHAQUJNVmKXLrul8N79pCQ9NRGmCNRsjmbDPJhUdO cAoExrdahrNr/167Wl4dANqbPRHIbUV5RbaY8Qa/SypTJIgPw9s5YQ8srB1HzBNg6qgLt3mWgaQ2I L1NJ8OXNkQEjJEdNoZMUXYPjQCGOJqC8FTltAXJhCEqDZRoS4HFabLYAo7vkZHuLjviS6jfOAec/S +2TF7o6Rw8BFITWYnrGt66gnd5xGXAWE+IApHZRif1CvosPmxasLG+EvMU9I84CNxVQK6yQt9qS6H IuylyPGPAYung+poijmw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oSjhK-00CGWZ-Iw; Mon, 29 Aug 2022 18:41:22 +0000 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oSjhH-00CGUz-DB for linux-arm-kernel@lists.infradead.org; Mon, 29 Aug 2022 18:41:20 +0000 Received: by mail-pj1-x102a.google.com with SMTP id n8-20020a17090a73c800b001fd832b54f6so6840203pjk.0 for ; Mon, 29 Aug 2022 11:41:17 -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; bh=V9K+I20QaNq4O5Ra7YlAgpXXseteLWhgORIY+myzuBs=; b=ornPFx88Hc3KxbFSN8rDnQptppeQGh6Q7FqKlH60GpmuLXnO6iJ4hYAn0e3+IxO9yq CRIYZ6CdazpE2la1L91GzJF5js/DrF8awehRmtH2Ds36jtk4vl/EIsPPQ0pGYOqHMsIm BnmCePHhicKjc9V67CaurSuWwxvA1vS6M3uAA= 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; bh=V9K+I20QaNq4O5Ra7YlAgpXXseteLWhgORIY+myzuBs=; b=mE8qJpCP7olL1djSHYEZ+IPjmQeUDhy5tdUXMJH3RhIWXa2cO9nNRKD3NUDA3yBTMs AUB9USVkYEXrz0yagnn1a5s0iFN01qC6SafK2cDcwgl8T6+UeLqbeQK5RF0nEVrOQWMl GKSG50GWsjkOYGfgmWpT+nlot7PWgzznMTTxbFbL6PCW71WR2T/bMAlYhI5ICH/oxEZZ qR9nBamqBIfhrS9WMxbwfVe7OkmGvUbbJCypBdwQhs7hMe74tMUmkkibmrikChEylWKt sQJ1YpFuc/aEYQGgilEG4vloEcJBtahpcvHb2RiIgfmDJkpCCIVaKOzCKZciybB4sFqZ fCfg== X-Gm-Message-State: ACgBeo1uG3kJbJWuB7vJkl1UKGKWMw8x9aNFS93NT+PzLwiGHaBLFttj 7LS/lefvA3iSzooV7qO69KIo1Q== X-Google-Smtp-Source: AA6agR6kwjgKG7jQbJjeT1oa/zfUjHoKziT4vv3E/X3mf9UBam5tcGdOKDGpOwEFvNbvebl8ScyNuQ== X-Received: by 2002:a17:902:f68d:b0:16f:2314:7484 with SMTP id l13-20020a170902f68d00b0016f23147484mr17308520plg.136.1661798476471; Mon, 29 Aug 2022 11:41:16 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c00a:a073:43f7:1644:6259:830d]) by smtp.gmail.com with ESMTPSA id k13-20020aa7998d000000b005385e2e86eesm1619042pfh.18.2022.08.29.11.41.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Aug 2022 11:41:16 -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 v4 03/12] drm: bridge: samsung-dsim: Lookup OF-graph or Child node devices Date: Tue, 30 Aug 2022 00:10:22 +0530 Message-Id: <20220829184031.1863663-4-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220829184031.1863663-1-jagan@amarulasolutions.com> References: <20220829184031.1863663-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220829_114119_502018_6FD885DE X-CRM114-Status: GOOD ( 18.84 ) 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. 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 ab2fa0f42f40..8130845750ac 100644 --- a/drivers/gpu/drm/bridge/samsung-dsim.c +++ b/drivers/gpu/drm/bridge/samsung-dsim.c @@ -1357,18 +1357,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);