From patchwork Wed Mar 8 16:39:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 2782 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 5B56F414B5 for ; Wed, 8 Mar 2023 17:40:34 +0100 (CET) Received: by mail-pl1-f198.google.com with SMTP id s15-20020a170902ea0f00b0019d0c7a83dfsf9669592plg.14 for ; Wed, 08 Mar 2023 08:40:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1678293633; cv=pass; d=google.com; s=arc-20160816; b=xPT2LHsv79U+eECXxl7Nea2twoKkBzqrjKfMu6Cm3RS58efg2gH7e67UzMncYmrNoC xi4nQNiQ0SC4uW7DdVOOrNEO/nfPHVjx4vfMRjtBdEAXIVRriF9VKxmzDVoYIItJMtB3 y3WzsWROfjo6/+VokccADsZX466vqqvCQlxOUuVAQg6wqLUPx/v/DSxJ45KRTKUpPOcT L7pIprHny3brAMH9WBsUWsS3suI8f8yy0I47+1/lSwvFps2AkFbev35ZE+FkYAfiSZ8t BSeuqi83p2yzlTrX42GwWkwI13cPfra/tGo18+94gGX8hzGJ3qZgh9+q/dougqqH3a/X z9qw== 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:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oqO6kdLYLiKwIN2mhp2W73KhQkznPxv5i7sdeBaIgZY=; b=zHEi66kA8E2ui2ZR7kfz5LY7iTmsc45cmYKOZ8eV32yV0OT9+rW8FBGTeZkJ3L2HcX AfsSJi81WCt8T3cO9cXYMhITZm24hFKPGH9HnYNKnRt0bqi3JB1A62tiHxnfQMVagBQq /FGPeFIeknAa4lg5wzMg/hwjsUjDaEW6AtHQLU5a1UKeSTUBmfjXdrXKDfMkJkAVXNdM hiBb1slZqArensvPJTmyv6DsHzqaQfkFnoL475/bbxaSRUfwgwca3A+nh+xZwbZFWQa3 T7ERlYmP5EV9GH6sG8EFUKLk1bEwbBDf4YWRVvfp2NrpqcyF7SfXhBsExeSMQQkoMdON CxyA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=PqE7wz15; 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; t=1678293633; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=oqO6kdLYLiKwIN2mhp2W73KhQkznPxv5i7sdeBaIgZY=; b=dpwRqp0yDFHfPW/1/uZjh4jbACkZZXH8ygCjIvgcSK0ze118sGqxewJYMHVGfWcz2O FUd615b0PtCgIOFCb+8cIz4j4aVUc8g3gD2q/SVNI/rgL+mE40zpZFkqA+6IEeqmohPp i8Km+T6vo35NjwdHZRRBrrgROXdCX+vh6XiZs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678293633; 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 :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:message-id:reply-to; bh=oqO6kdLYLiKwIN2mhp2W73KhQkznPxv5i7sdeBaIgZY=; b=mKn7u6atGX2CCMNAXMdUfxuIJ5VmD8jswdQeIx6kTnATGSBubAlvSek/qGH/xO4RxA tQydZjFNKYv/s+4mi4aZoGmJ0E8Z9bcwGS7OdPPcewGHhFsuOUL2eS/oAKyFSkA8M0MC UNcLINnp2KX9nJnmwiHxJcRgWj0TsgtfBRArhVM3nIUGPKq/RTNRPFGN6apokd5yh2tz UTojtguMJwc8T/xmqCHet8RAEMOGHp0HE3eNkEOEeqG3V8nfT5TrieDfzXIDMmdwsI31 2VdfbhkvVjg0fls/ZtNsBWf3deX4CLTjPUCF9Bgesan89V0f91BE2eZlcy6VGHqWmr+i bsWg== X-Gm-Message-State: AO0yUKXnEVx0APPb+RmzDOangOpm71VY1lrv5sXvjZBZVTFf82vtajjK 0RWhnsNbV4yODaMlZ2JzdDj+c1Gf X-Google-Smtp-Source: AK7set+byKquiVtCafZPBVAwycVxhpL08VRH5eVI/EsNrsmpR7JukAPcp7XyJUG9JBFqyHgsGh0wRw== X-Received: by 2002:a17:902:9a03:b0:19a:afc4:2300 with SMTP id v3-20020a1709029a0300b0019aafc42300mr7534336plp.6.1678293633063; Wed, 08 Mar 2023 08:40:33 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:903:2441:b0:194:d87a:ffa6 with SMTP id l1-20020a170903244100b00194d87affa6ls16406089pls.1.-pod-prod-gmail; Wed, 08 Mar 2023 08:40:32 -0800 (PST) X-Received: by 2002:a17:902:f54c:b0:19c:a9b8:4349 with SMTP id h12-20020a170902f54c00b0019ca9b84349mr23186187plf.32.1678293632094; Wed, 08 Mar 2023 08:40:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678293632; cv=none; d=google.com; s=arc-20160816; b=t/ncbZAYMFzu4wy+fwoI6Tg/OEO7E/G0NVA3ugGx0ygvq8pnjXgNzESV2nWJgIzawp oA9hDhkOqKB4FIYAB5Vvivcx7YPMzeNoG0iBfM7ffXaBI8HpS5NjWj4EWIlOu8CIYdns D4/IpkkAaViIW3fOwfbY1jhLwaHPDjop0nxeJAQ+DXGxyniIjDEJAjb8kWbLgV8QGVnQ rUSc1GFTTHI8EwVfTVn5QEnt9yHGcDuNaGG7NmrCMm+/pg7SnDeCfvlBZII18+ocDjf6 BnyCWyvwSYq2feSmflojk6UqEo9920gu3E/l4uS176bYqI7Z4PVHBkmU6LEapy1uMJ/N 9VTg== 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=+udTIu1ct3G8jeCaDXjf5KrilADcli7EoE7on9WYgu0=; b=m2faup0UK7KdsRqYnbLrvP1s5k5AuC7qOEE/MSF2rDUSv5DwOn4WLlvve+51Q/27m0 k+ESU3AHYgZnzj8Pc+DZa9sksosHjsu4DH5WOlpdECJztFHgisJa+CDOtQ1MqKd/L49G gYXXxxeBAscv/ejLMBTmU8je2G1PQkREl0xQxKUSyPMPXlHQGTy4ul0XAoiIvpVIZWad E5bNOJlWR3lJnTvySYGEl3rPzR+IK+42zNHP7jmhcNkOW4VxXDAE1Rw5I2T7+0l7PLFB knBHv5rFrffZ/FsgNUHGJ5Ym9l5dI3nC+n3QUMAL77eTQp5offgt9gekdXg5swV8oXme aBXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=PqE7wz15; 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 t4-20020a1709028c8400b0019a94423454sor5649873plo.101.2023.03.08.08.40.32 for (Google Transport Security); Wed, 08 Mar 2023 08:40:32 -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:ea11:b0:19c:e05a:ea6 with SMTP id s17-20020a170902ea1100b0019ce05a0ea6mr22145963plg.56.1678293631715; Wed, 08 Mar 2023 08:40:31 -0800 (PST) Received: from localhost.localdomain ([2405:201:c00a:a8a1:b545:91cc:80b2:f9fe]) by smtp.gmail.com with ESMTPSA id kq3-20020a170903284300b0019b9a075f1fsm10046540plb.80.2023.03.08.08.40.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Mar 2023 08:40:31 -0800 (PST) From: Jagan Teki To: Andrzej Hajda , Inki Dae , Marek Szyprowski , Neil Armstrong , Marek Vasut , Maxime Ripard Cc: Seung-Woo Kim , Kyungmin Park , Frieder Schrempf , Tim Harvey , Adam Ford , Matteo Lisi , dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org, linux-amarula , Jagan Teki Subject: [PATCH v16 02/16] drm: exynos: dsi: Lookup OF-graph or Child node devices Date: Wed, 8 Mar 2023 22:09:39 +0530 Message-Id: <20230308163953.28506-3-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230308163953.28506-1-jagan@amarulasolutions.com> References: <20230308163953.28506-1-jagan@amarulasolutions.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=PqE7wz15; 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 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: , In general, for MIPI DSI there are three ways to represent the pipeline for an upstream bridge to find the connected downstream panel or bridge. 1. Child panel or bridge as a conventional device tree child node. 2. Child panel or bridge as an OF-graph port node. 3. Child panel or bridge as an OF-graph ports node. There are three different downstream panels or bridges that are possible to connect an upstream DSI host bridge - DSI Panel, DSI Bridge, and I2C-Configured DSI bridge. An example of the downstream panel represented as a child node, &dsi { compatible = "samsung,exynos5433-mipi-dsi"; ports { port@0 { reg = <0>; dsi_to_mic: endpoint { remote-endpoint = <&mic_to_dsi>; }; }; }; panel@0 { reg = <0>; }; }; An example of the downstream bridge represented as a port node, &i2c4 { bridge@2c { compatible = "ti,sn65dsi84"; ports { port@0 { reg = <0>; bridge_in_dsi: endpoint { remote-endpoint = <&dsi_out_bridge>; data-lanes = <1 2>; }; }; port@2 { reg = <2>; bridge_out_panel: endpoint { remote-endpoint = <&panel_out_bridge>; }; }; }; }; }; &dsi { compatible = "fsl,imx8mm-mipi-dsim"; port { dsi_in_lcdif: endpoint@0 { reg = <0>; remote-endpoint = <&lcdif_out_dsi>; }; dsi_out_bridge: endpoint@1 { reg = <1>; remote-endpoint = <&bridge_in_dsi>; }; }; }; An example of the downstream bridge represented as a ports node, &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>; }; }; }; In, summary it is possible to represent all three downstream slaves devices using OF-graph port or ports node however only DSI Panel and DSI Bridge are possible but not possible to represent I2C-Configured DSI bridge child nodes since I2C-Configure bridges are child of I2C node, not upstream DSI host bridge and it is must represent them endpoint port linking. This indeed means, the OF-graph port or ports representation is mandatory for I2C-Configured DSI bridges. This patch tries to add an OF-graph port or ports representation detection code on top of existing child node detection. It is possible to replace the entire detection code using existing drm_of helper drm_of_find_panel_or_bridge but it will break the Exynos DSI since the pipeline doesn't support OF-graph port or ports node. Overall, this patch has a combination of child and OF-graph pipeline detections in order to support the backward compatibility of Exynos DSI child node and i.MX8M Mini/Nano/Plus OF-graph port or ports node pipelines. This is the first common DSI host bridge driver that needs to support all possible downstream connection pipeline combinations. Tested-by: Marek Szyprowski Reviewed-by: Marek Vasut Signed-off-by: Jagan Teki --- Changes for v16: - collect TB from Marek S - collect RB from Marek V - fix multiline comment Changes for v15: - droped from drm_of - added in exynos dsi - updated commit messages Changes for v13, v12: - none Changes for v11: - drop extra line Changes for v10: - new patch drivers/gpu/drm/exynos/exynos_drm_dsi.c | 38 +++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index df15501b1075..bb0d2502ea02 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c @@ -1470,18 +1470,52 @@ static int exynos_dsi_host_attach(struct mipi_dsi_host *host, struct device *dev = dsi->dev; struct drm_encoder *encoder = &dsi->encoder; struct drm_device *drm = encoder->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);