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: 2321 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id CA95440F47 for ; Mon, 29 Aug 2022 20:41:18 +0200 (CEST) Received: by mail-pj1-f72.google.com with SMTP id f16-20020a17090a4a9000b001f234757bbbsf3619235pjh.6 for ; Mon, 29 Aug 2022 11:41:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1661798477; cv=pass; d=google.com; s=arc-20160816; b=i0IJ2SJnLwRNcJibSTly+fYWGLiXJdzALubVzT3z5Tv8QzB4FSR+rolWoilySUAkNQ FQWJL7HvUQku66HMFZxoYylPIm4CP2IdrtBkJmI/h3lgVOgy3wKr9RfTFMzu5oNzPrvr 1+Di/4c+fMfPnjGnrXP5Uj7C6b6rvuuFyTie5c/H0VFg46Hnc8kWrsI+8R+MwtJy3jBd 8zL1nXoDXQ2OW/IBZiR4s3L8bhThYSVz+CPmKP6D/vjFiVEUeCi2cUPzCMcK79H9jJqj hLX/5n1bopZ58a0TKN7iw1YEkdpqZxV5Lx4fci0Iej0d/FW0imfhyDXFWkO3LYLA5VKG EYrw== 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=HDT1AsAQzDXJ2TDht6PQ28150a3qxOpjSuPuCfy1I74=; b=DWfFAm/qs9J9RPl6ty3nodS651xwO4rdVAhZpLExbogD0xCeYPoc7/wzYPSVDA3GrM gObtT1io4jw20oh5QPy14vnilmEXin2Px9v9NPuDl+I62Y3bWLUqVvbwUtk6/wvaUxOp xfGdWj/XOJn4RdvM8FzxzfmwKhLp5ECrpMm1xz+Z8K6o36JIN2yb/qUMAgI8TpmeE1T6 72b/9bubtDCfsxPHMTaRqvWVKJEQ5AAyffZAUl+KjuJEJSvOsAJtNpZELDAAtvmXG8y3 jALWeM6LeUTgZEKnZiGrU5G85Qt1DKPdZNsM+yIE+kx7+Zabh7gAbWyPDXVLo2qvbPJO 0kbQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ornPFx88; 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; bh=HDT1AsAQzDXJ2TDht6PQ28150a3qxOpjSuPuCfy1I74=; b=QzswPlTK/PScw36m+tqhcF1giyL6tONxZQbRf47zXe+ynX+uuIOr793LAOYg79FJki SwQKFGcwgBJAu/D4VGzxDF2Ck5r1WyuD738IeOpIyT1LTHMoOiDpP/TqsJQCkHigrDuP sPPct5Fc2HPVi2OYwecXz0WoMc8Y/jKp+oCSs= 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; bh=HDT1AsAQzDXJ2TDht6PQ28150a3qxOpjSuPuCfy1I74=; b=jFktEkMcBxfnK5jT2rSm/Zaa3L7MalA1+DqojMc0nZUORpksnkKpUPEHv2LOeDEw57 SVOrfadW/8GSYUgoctoxnw0YcUzaKle3Qbp3Ll5o8SZ9xTD+wvlsjdZjJ1mny+Y5sd0b vJlB2sDNzz52VBqs0q2nyCpRl0IzmCzOlVVrMcYkWssXRJ4o8Rqj8SFJRS0A3rjBki0D NuqjJEdkKSRuHEUOTeIglQYi36h778w5SnKq/p17KI++pjClQhfk37hfzkJpiLk0UrYt xLQnPdlK2HyuMwy9CFC0pIQdufBE6kP2W7UjM+OV9tUq2LcXUQQJNHXsxLOBTobHqzvU bqtg== X-Gm-Message-State: ACgBeo2SploL3vhtCq48uF0Pl5gsp2DjqqD5l5XQaNJhFLQgZ3BZU6FI RLQ471glZt5XSTolRQihG3Vl2rak X-Google-Smtp-Source: AA6agR5RBCnc+mnIUqZaNP83fw5neLGy++OhlSgkCRMPQRdzHIe/4XbJe0aao+bjrEssxF0OQnaU1g== X-Received: by 2002:a17:902:e5d1:b0:16f:15a1:6dbc with SMTP id u17-20020a170902e5d100b0016f15a16dbcmr17823123plf.73.1661798477636; Mon, 29 Aug 2022 11:41:17 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a63:2a4e:0:b0:41a:63e8:2535 with SMTP id q75-20020a632a4e000000b0041a63e82535ls4855319pgq.2.-pod-prod-gmail; Mon, 29 Aug 2022 11:41:17 -0700 (PDT) X-Received: by 2002:a62:17c8:0:b0:537:b287:3ef8 with SMTP id 191-20020a6217c8000000b00537b2873ef8mr17836504pfx.40.1661798476821; Mon, 29 Aug 2022 11:41:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661798476; cv=none; d=google.com; s=arc-20160816; b=RE/1CdM8AHDZpeX0+G3iMZA5phodmAo0yvtwk45t8omTXnP/rJ1YAf+312tPh2KzKs qHU31ivZ+6fmveRrg1TNHT1Yf0XLtinwkPi6ojo+EpTYcxXPZ+c/AFE4L58jXJn4G9HW BkNCdXtwlzJHwHqFURANT+2Wn4bcgIfIswt6mbtYjnPOhc0W4//U5F/smsyKkJ6JUN/s rTNAw2g2DWYcOKB8gFnzqXkhs9ApwYS61mftBTyO6Qi4D9ZXSsBDGOJGAKYwmKw8ge8P ezqTeM1ykEi09JOEU98kVM8rJi5qdaIJYBSMiS5e0u//HZlIMgP+UpiHVwVYVRL+rjIh oByg== 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=V9K+I20QaNq4O5Ra7YlAgpXXseteLWhgORIY+myzuBs=; b=gVFBAoee56pJuDHt1J0b+N2kLXPUHAnKMsBa99fWhtpUI5CgtJP5pf5wHupsYl7YXx bJ8LmU1xK2jkBxn8D4XJ7pYlKcQfx2+Sl4V/38DYEKMBA3wIRBkJQanwsri5rSV9KeIg U5bKV26yy0K/b7KxpAY1TPnfazLugeSr1uwTceshw+d6lFQUxnR4xe3Jqd702u6c9jbR 2wmRyfZ/A+K7PSP5D/4GMW2N5VBG7hjEsj1Imzsw7PS2zP3QBnc+Mnukuwia8ogHYeIv usT2RVHNXyrfM+bgu4bGKB7q+F3HzGvs0n3AAJaTF3ZCZQ6Qdyml1AfYnNaxlk0PECCu kLfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ornPFx88; 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 z9-20020a170902ccc900b0016bfe9631fcsor4174373ple.12.2022.08.29.11.41.16 for (Google Transport Security); Mon, 29 Aug 2022 11:41:16 -0700 (PDT) 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: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-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ornPFx88; 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. 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);