From patchwork Wed Jul 20 15:52:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 2190 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 169F33F03E for ; Wed, 20 Jul 2022 17:52:54 +0200 (CEST) Received: by mail-pl1-f199.google.com with SMTP id m14-20020a170902db0e00b0016d2dcb9b7bsf128648plx.17 for ; Wed, 20 Jul 2022 08:52:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1658332373; cv=pass; d=google.com; s=arc-20160816; b=xza3+hRtOsQz/+aJcb8jYW1+Q5xtvpyp7HDbQhe1/16Fj8CrewdvqXrM7BjD6alm0Q mW4FrM78nv+WycKML6rZiUQ+6vdtrnCjqH5uEBWuUyg0WZUjAYaRYhPhmXHr9S2vkQEQ GkHJCiL3sbi4jBioQuhZa8MlxFyTMcNBcyHEZv6cu2zYdLls6IQqZ8a64C7Nx+9CNfvi GqmVfok9JSEKOsVVsRVc2mC650LuxiLHOa/JjXw3KPXVutAt+0NKn+HKvWXYRue+23+q oI3iFaVxsUsr9RqhtsnDJZCLXEa8CSXCIcxdoCMR15ACbiIAjye+7/U9If7MJOJpdqJp joLQ== 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=YFijcjiJGwY26+w/K1WQGQLKsBh4M3JqXPCEklI9T9Y=; b=HSRV+eJDVqIwGAvz5VibPuCPoppOP7DCCeLCgZZm0dhtfxHEUVD+tf3Zy533XRYnZm P4l6z7g+4BarZrdHF28Gt3FKROzKyRa/yf0y73qEp88xEzWlbIMODD6j7QQBdQIR5K84 724lN3zQTWtypxuF54W57XTwneVzKBhCdB6kon0Tn65RmyHCklediFVZWW50Rp+QvBug A4chuhs8m4EvMIwEDbiIoMLYPINaPCVyN9beYyszsXAquFMihu61lUmZos6EyNp+EDsn a2wAPwJ5/w6NTPrTSOwwenwReued9RU7Vb0kLY77ONMmRgQEeDUQKTq+DyyHr/0jKAwQ EqhQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=PaszaOkY; 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=YFijcjiJGwY26+w/K1WQGQLKsBh4M3JqXPCEklI9T9Y=; b=cY7Adu5gHSYnw3prBCKKq7SJS9h+2oG1MnEzUfCl/CRMFGO44T4bmqLcv84Qa3Y4D8 ZhVFtWfrs8+qlChuhur0PWRgbvurO1JzAVZtSCLRJyrxMmqlRyvCG3Wy2bxyEP+vcHVW 1gYq4EMDMMLGhZ+ek74Dmbs1hGpDu5AfE9aPk= 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=YFijcjiJGwY26+w/K1WQGQLKsBh4M3JqXPCEklI9T9Y=; b=WG0Q9AyW7t2tUrvoiZ6sr328WUzQls9tYUsZgKjkhEECgYWVuQ9xHAqDNRKKYHx9Ty yfeZhSjsBI6g47BLA+BKzdGxMQVhY0dAHGt6GzDjcujEW2jJdRUdMDJlPcMnJy3t4dCE V6XdJJBqbeMmLEd/oNcXmFYjheQLSarAe+R6UFCyDyb1xSQRDFMFcf7GkPn2PsiS/Nad y+0NiLWkXqEtKZWDKhnul19ZQV7Khxx94nNcBL0j5DMZqs6Vh+7jspvqqvDLv0cGmstc /CMRwrQO3CPU1DChDKKFgN1UNRajFodEzjSm6yuwa6OzX4ZqOxws9eDpoYfvQpvlsfjw ln6A== X-Gm-Message-State: AJIora95UMlqv3gNfUdEm7BoSqeMDELH1I0Hr0mWelVCfyhgPTNal00p v4Va/hjzqci1cayfzRY2cRFym2qt X-Google-Smtp-Source: AGRyM1vpxz+wGfPuGecm+9Yxnx2EayMXlZt5aI9f2dBQXqJ7bEDhwZFoQB4J4aq95gh4mMFSqi+PpQ== X-Received: by 2002:a63:de0f:0:b0:41a:6684:98cc with SMTP id f15-20020a63de0f000000b0041a668498ccmr3043801pgg.582.1658332372733; Wed, 20 Jul 2022 08:52:52 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:902:da8f:b0:16c:eb79:c6f3 with SMTP id j15-20020a170902da8f00b0016ceb79c6f3ls1625075plx.5.-pod-prod-gmail; Wed, 20 Jul 2022 08:52:52 -0700 (PDT) X-Received: by 2002:a17:90b:1e04:b0:1f0:61a4:d747 with SMTP id pg4-20020a17090b1e0400b001f061a4d747mr6252603pjb.58.1658332371944; Wed, 20 Jul 2022 08:52:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658332371; cv=none; d=google.com; s=arc-20160816; b=jDZQ3kaHW2SOeDqUO6kVHhaDzNi0D5yyQLzeOw7GX7hBeDKRAVQlBlwT2vqcwGarEK kfMKI+k8SOXdKFVpIi8uvKUJ/z4GB7v67O3itwqbLTYUsPa6BYNdcDivc2G/vg7srdwE LRxQqH/qoPI0C+yF/cb2Eyx66jxEKtlzc79x8iPaTat8zA8tg8Se1eCRBZlEHKm+MeSU HWpC1SApSHCdgkZ6EYmMIwIKSJjyAn89QH4GIOfJT5Lv6jqlYSHUBFDTUGXlv/BruSce O/+yNEzYmtOIsFXVz3VZqBMIdZM5xFijCb2wxinZsSfJgaug8T1yuFFELcKfQiyINPvF zQDw== 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=iLxDXrnWztCpLdw3kYeARw1Pm9i++dE2YdXdMibsoFo=; b=aW7tpSnkFW1ToTTeQZkHsXcE4L7G17D40J/BTGH/QWARJywsd2IhlT/XNmGEuzCfn7 GbYfkh94ghl7RL1BCnFaMARWoFd5XZ/Kljsq5iVnvRmsptPckJ5mZ42ym4ge+XNXoxu7 zWjXoyHpelTqsKHXpBQiuuSESMzU3MZORfJMX8sLWBViHJ3ukCQNomuysQ3ic+PiGMDS OLym1Zur5tC43nM13PMKvtfai4/FNi7Q0CyrN9BhvYFWSOrmdSVfAnLxSCIH61ZpwVMH VxgQlDXSbMBRV5HzjIQhPwc48c+7WlVPMiWemjnmT3tbBVSpQS1K9UrQbu/n320ha9DO SSGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=PaszaOkY; 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 f78-20020a623851000000b00528916bd95asor9335688pfa.38.2022.07.20.08.52.51 for (Google Transport Security); Wed, 20 Jul 2022 08:52:51 -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:a63:8841:0:b0:412:b40b:cfb5 with SMTP id l62-20020a638841000000b00412b40bcfb5mr35384538pgd.197.1658332371457; Wed, 20 Jul 2022 08:52:51 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c00a:a073:d177:d5:aee:4f03]) by smtp.gmail.com with ESMTPSA id a8-20020a170902710800b0015e8d4eb1d7sm13919198pll.33.2022.07.20.08.52.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jul 2022 08:52:51 -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 v3 03/13] drm: bridge: samsung-dsim: Lookup OF-graph or Child node devices Date: Wed, 20 Jul 2022 21:22:00 +0530 Message-Id: <20220720155210.365977-4-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220720155210.365977-1-jagan@amarulasolutions.com> References: <20220720155210.365977-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=PaszaOkY; 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. 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 21975ed513bd..20db345abf8b 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);