dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jagan Teki <jagan@amarulasolutions.com>
To: Andrzej Hajda <andrzej.hajda@intel.com>,
	Inki Dae <inki.dae@samsung.com>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Joonyoung Shim <jy0922.shim@samsung.com>,
	Seung-Woo Kim <sw0312.kim@samsung.com>,
	Kyungmin Park <kyungmin.park@samsung.com>,
	Frieder Schrempf <frieder.schrempf@kontron.de>,
	Fancy Fang <chen.fang@nxp.com>,
	Tim Harvey <tharvey@gateworks.com>,
	Michael Nazzareno Trimarchi <michael@amarulasolutions.com>,
	Adam Ford <aford173@gmail.com>,
	Neil Armstrong <narmstrong@baylibre.com>,
	Robert Foss <robert.foss@linaro.org>,
	Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
	Tommaso Merciai <tommaso.merciai@amarulasolutions.com>,
	Marek Vasut <marex@denx.de>
Cc: linux-samsung-soc@vger.kernel.org,
	Matteo Lisi <matteo.lisi@engicam.com>,
	dri-devel@lists.freedesktop.org,
	NXP Linux Team <linux-imx@nxp.com>,
	linux-amarula <linux-amarula@amarulasolutions.com>,
	linux-arm-kernel@lists.infradead.org,
	Jagan Teki <jagan@amarulasolutions.com>
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	[thread overview]
Message-ID: <20220720155210.365977-4-jagan@amarulasolutions.com> (raw)
In-Reply-To: <20220720155210.365977-1-jagan@amarulasolutions.com>

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 <jagan@amarulasolutions.com>
---
 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);
-- 
2.25.1


  parent reply	other threads:[~2022-07-20 15:52 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-20 15:51 [PATCH v3 00/13] drm: bridge: Add Samsung MIPI DSIM bridge Jagan Teki
2022-07-20 15:51 ` [PATCH v3 01/13] drm: exynos: dsi: Restore proper bridge chain order Jagan Teki
2022-07-20 15:51 ` [PATCH v3 02/13] drm: bridge: Add Samsung DSIM bridge driver Jagan Teki
2022-07-26  7:28   ` Krzysztof Kozlowski
2022-07-28 10:35   ` Adam Ford
2022-07-20 15:52 ` Jagan Teki [this message]
2022-07-20 15:52 ` [PATCH v3 04/13] drm: bridge: samsung-dsim: Handle platform init via driver_data Jagan Teki
2022-07-20 15:52 ` [PATCH v3 05/13] drm: bridge: samsung-dsim: Mark PHY as optional Jagan Teki
2022-07-20 15:52 ` [PATCH v3 06/13] drm: bridge: samsung-dsim: Add DSI init in bridge pre_enable() Jagan Teki
2022-07-22 15:35   ` Marek Szyprowski
2022-07-22 16:05     ` Dave Stevenson
2022-08-29 18:30       ` Jagan Teki
2022-08-30 14:24         ` Dave Stevenson
2022-07-20 15:52 ` [PATCH v3 07/13] drm: bridge: samsung-dsim: Fix PLL_P (PMS_P) offset Jagan Teki
2022-07-20 15:52 ` [PATCH v3 08/13] drm: bridge: samsung-dsim: Add module init, exit Jagan Teki
2022-07-21 11:09   ` Marek Szyprowski
2022-07-21 11:12     ` Jagan Teki
2022-07-20 15:52 ` [PATCH v3 09/13] drm: bridge: samsung-dsim: Add atomic_check Jagan Teki
2022-07-20 15:52 ` [PATCH v3 10/13] drm: bridge: samsung-dsim: Add atomic_get_input_bus_fmts Jagan Teki
2022-07-20 15:52 ` [PATCH v3 11/13] drm: bridge: samsung-dsim: Add input_bus_flags Jagan Teki
2022-07-20 15:52 ` [PATCH v3 12/13] dt-bindings: display: exynos: dsim: Add NXP i.MX8MM support Jagan Teki
2022-07-20 15:52 ` [PATCH v3 13/13] drm: bridge: samsung-dsim: Add " Jagan Teki
2022-07-21  7:19 ` [PATCH v3 00/13] drm: bridge: Add Samsung MIPI DSIM bridge Alexander Stein

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220720155210.365977-4-jagan@amarulasolutions.com \
    --to=jagan@amarulasolutions.com \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=aford173@gmail.com \
    --cc=andrzej.hajda@intel.com \
    --cc=chen.fang@nxp.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=frieder.schrempf@kontron.de \
    --cc=inki.dae@samsung.com \
    --cc=jy0922.shim@samsung.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-amarula@amarulasolutions.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=marex@denx.de \
    --cc=matteo.lisi@engicam.com \
    --cc=michael@amarulasolutions.com \
    --cc=narmstrong@baylibre.com \
    --cc=robert.foss@linaro.org \
    --cc=sw0312.kim@samsung.com \
    --cc=tharvey@gateworks.com \
    --cc=tommaso.merciai@amarulasolutions.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox