From patchwork Wed May 4 11:40:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1931 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id EB07F3F067 for ; Wed, 4 May 2022 13:40:57 +0200 (CEST) Received: by mail-pl1-f197.google.com with SMTP id u9-20020a17090282c900b0015ea48078b7sf605523plz.10 for ; Wed, 04 May 2022 04:40:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1651664456; cv=pass; d=google.com; s=arc-20160816; b=RPjqJ5/0xaS0YyEK6IqILs2xE4KRF5rhA4Sd54TEBfLTQI8buFVHx53IOPeerE3vDo z8AvAz1ZJGAWmDCyZu5+wf/8v1QWsBrMGoZidIzxjL1ppQFWXRgQc2jSS7zL+EKySbQl SChYcPpnOKx504iBc8n7Zhsif9pEVjvrLd6I1jwp6Lcb4NPc6ksAktlPQU2j8dhxqWL9 ceF91HDzneaE8oI8md2PgQWym5DtoqRBkEt7IMSUPc9EqaOcHU4yCDeyMyfmFDxbQhU/ XM6QikueJ+9kUrTUAgwd6ctP5fernhFD+PQKy40lrYuIeCfv662ft25OCxuuXMNeI2zj EWDQ== 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=tAanJpiEbqxi0dbPph6yEzuXRzNrj+u3qzXl/8ml7DI=; b=zTOHOjqaPdMZ4tcASy2JIBVTzWt2URTQ0QHx5k2cnLyl/xcn/AEj3XLlKzHUwtWIZR mKSH043D0+0eke2OaBh+CTsAZzkFyABKJfhdQ96bdMH518zmnWYO0iqlzJoAs5HiaNRQ 67EFmiN/p0hspTM259dkOXp3/5ECXUrMdy8D+TXFlXRzy6AknmxXV4eHfw9b80NaOm9X lV/sgXxHYIquTHkcYQX7iUVwv238R/4t/1Efl7s7zfhEYGCxXFFre9zCHfWUtKceRsAC Rii/ktalgQBHF05+Kov/40+rNPFSbdqGbuZ4vl6vzHbqrnLsn7JQ58rT9bAIUI0DL/Ld f+Nw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=MOOp84GT; 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=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=tAanJpiEbqxi0dbPph6yEzuXRzNrj+u3qzXl/8ml7DI=; b=L2iqSmm0GzkEjZqsqcMZkU5Bg7EwWxA8siZaEyZY7byIRLkrMxoMIIw+y1uIHWsvVQ OO5Iem9sxIdiixClVB+4RmP4oSt1gLnOE2uqW/ojcQMcoc/OZzQ5Cv6t4fpP/rZ68t3+ xI8qLX+nEfktUmHxrAxXnQe88HazWE7pArkRI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=tAanJpiEbqxi0dbPph6yEzuXRzNrj+u3qzXl/8ml7DI=; b=bdJpe7Ih2qBTpp94eJYJ5eTHJeZJS2shZJ4N/CzMEXx371o+0WkiTLGxrY/DSSzyiq I5iYxhNOuKyzt13z3Do8ZaK3MlPLCDljceNhti7hmc9S1sgzAsr4MLbcGRIAoB+Cd9Xb Xvi7MTEgNiKkfXI6LLOASWohsx4nD4CTYiufLzKAng85S2/ccL8MOJI+U9uAkUAfgMNl RwV2OCrvrCUGo+La4YG5Y2ecUo7hTIfBdFUvpXstS4wlQZXeL7AicglYzYLaYHhOHTm6 UkAF/cJ/7Ko3Da41AbendBcma5bn8do/tSlCupKrn4ALgeiurKPDI73HcOUt9JyC2342 kcFA== X-Gm-Message-State: AOAM531MngvxMRmccuzK01sr9RpK8C2E75N20hB694n+YOa5oDOJsOel JegelmVQyYyknN5WQGTM73VhGYAl X-Google-Smtp-Source: ABdhPJwNG6b3W3xM5ZW0dKGRzc9qNskGVjRaGJqq31vo/tfJAv4r0ULZDa7gwS/qhI8MgVY5dfadbg== X-Received: by 2002:a63:4b17:0:b0:3c5:f761:c77a with SMTP id y23-20020a634b17000000b003c5f761c77amr816818pga.117.1651664456631; Wed, 04 May 2022 04:40:56 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:902:e811:b0:15e:a1b8:c1dc with SMTP id u17-20020a170902e81100b0015ea1b8c1dcls1192624plg.2.gmail; Wed, 04 May 2022 04:40:56 -0700 (PDT) X-Received: by 2002:a17:90b:1c02:b0:1dc:a9aa:121 with SMTP id oc2-20020a17090b1c0200b001dca9aa0121mr590624pjb.100.1651664455967; Wed, 04 May 2022 04:40:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651664455; cv=none; d=google.com; s=arc-20160816; b=PohwQGPgS/T5cuYmJfDkok0wEqq8nCxwhE6WiPs/akUZ+6uHKA5EKKngMw9UBaU0ue C42PHClQ40DinLhAFc7k/EStob1amJpFUojMsT3/p/0YIp74oa6CfbeGAblI14NxvVqg pImzUXcO/AdT5GXUXYgxwH2d377qmUqRWj183DbpyQtEQ7r+KKyhfVRksU5wwdoQ9PVI 8CXLLnbPbhPRATEDFxq+5Hm2nS/u4liJrv9/0G5WgN038ynsGZdrK3cU1OoIzaoxAw56 liZxi6aMDNsVTdnOA8CbqbE0b5TX6E2lBI9ZhCaxtH8M4wlUdEkRn7iAQGTrWunTa120 RMqw== 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=Zu930wcvNkHW2egdF99M+1+iY48wbvmQImq1ebHjMJc=; b=QTATl20uZxLbu4ibbLEQmHFJjleveC8mX7s0Ep6CKR9cEVyyuMvy2KL0r+MD6U6U2K z4YwCakjPB5IKr/RH6p2JDPaQg9itz0Njs7VD+Bvw8LOpd42TfTTTmvVo+tWO1Kzq0r2 t06vXvANme8E1cVow/ab6OHxB0+1132oJDBKNXw3aBsR1/aez0Ph6YhNp9Pbl6zQt4HG moTGU1R6T22uT1Wyrwzo3t2rLb74se67qdMkx1+9taWrTmi3OMnbhdD3NzDy9hUVp7Ws Jh/acc4AsreTRN9lNtni21Drue2y2RN3tH25bqiIpj64tqt8AlN3ZHfd3nrGyJt3hH1j ov6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=MOOp84GT; 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 s5-20020a17090a6e4500b001d29346639bsor1836671pjm.22.2022.05.04.04.40.55 for (Google Transport Security); Wed, 04 May 2022 04:40:55 -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:90b:380d:b0:1dc:8dc2:bb2c with SMTP id mq13-20020a17090b380d00b001dc8dc2bb2cmr6215480pjb.236.1651664455662; Wed, 04 May 2022 04:40:55 -0700 (PDT) Received: from localhost.localdomain ([183.83.137.38]) by smtp.gmail.com with ESMTPSA id k15-20020aa790cf000000b0050dc7628174sm8027498pfk.78.2022.05.04.04.40.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 May 2022 04:40:55 -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 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 v2 02/12] drm: bridge: samsung-dsim: Lookup OF-graph or Child node devices Date: Wed, 4 May 2022 17:10:11 +0530 Message-Id: <20220504114021.33265-3-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220504114021.33265-1-jagan@amarulasolutions.com> References: <20220504114021.33265-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=MOOp84GT; 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. 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 7745902f3f1e..f23f06d55158 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);