Linux Samsung SOC development
 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>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Marek Vasut <marex@denx.de>, Maxime Ripard <mripard@kernel.org>
Cc: Seung-Woo Kim <sw0312.kim@samsung.com>,
	Kyungmin Park <kyungmin.park@samsung.com>,
	Frieder Schrempf <frieder.schrempf@kontron.de>,
	Tim Harvey <tharvey@gateworks.com>,
	Adam Ford <aford173@gmail.com>,
	Matteo Lisi <matteo.lisi@engicam.com>,
	dri-devel@lists.freedesktop.org,
	linux-samsung-soc@vger.kernel.org,
	linux-amarula <linux-amarula@amarulasolutions.com>,
	Jagan Teki <jagan@amarulasolutions.com>
Subject: [PATCH v15 02/16] drm: exynos: dsi: Lookup OF-graph or Child node devices
Date: Fri,  3 Mar 2023 20:21:24 +0530	[thread overview]
Message-ID: <20230303145138.29233-3-jagan@amarulasolutions.com> (raw)
In-Reply-To: <20230303145138.29233-1-jagan@amarulasolutions.com>

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.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
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..f44a5a702ad5 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);
-- 
2.25.1


  parent reply	other threads:[~2023-03-03 14:52 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20230303145219eucas1p218c2e302e41464432627c8ac074302f8@eucas1p2.samsung.com>
2023-03-03 14:51 ` [PATCH v15 00/16] drm: Add Samsung MIPI DSIM bridge Jagan Teki
2023-03-03 14:51   ` [PATCH v15 01/16] drm: exynos: dsi: Drop explicit call to bridge detach Jagan Teki
2023-03-03 16:39     ` Marek Vasut
2023-03-03 14:51   ` Jagan Teki [this message]
2023-03-03 16:41     ` [PATCH v15 02/16] drm: exynos: dsi: Lookup OF-graph or Child node devices Marek Vasut
2023-03-03 14:51   ` [PATCH v15 03/16] drm: exynos: dsi: Mark PHY as optional Jagan Teki
2023-03-03 14:51   ` [PATCH v15 04/16] drm: exynos: dsi: Add platform PLL_P (PMS_P) offset Jagan Teki
2023-03-03 14:51   ` [PATCH v15 05/16] drm: exynos: dsi: Introduce hw_type platform data Jagan Teki
2023-03-03 14:51   ` [PATCH v15 06/16] drm: exynos: dsi: Handle proper host initialization Jagan Teki
2023-03-03 14:51   ` [PATCH v15 07/16] drm: exynos: dsi: Add atomic check Jagan Teki
2023-03-03 14:51   ` [PATCH v15 08/16] drm: exynos: dsi: Add input_bus_flags Jagan Teki
2023-03-03 15:00     ` Maxime Ripard
2023-03-03 15:02       ` Maxime Ripard
2023-03-03 14:51   ` [PATCH v15 09/16] drm: exynos: dsi: Add atomic_get_input_bus_fmts Jagan Teki
2023-03-03 14:51   ` [PATCH v15 10/16] drm: exynos: dsi: Consolidate component and bridge Jagan Teki
2023-03-03 14:51   ` [PATCH v15 11/16] drm: exynos: dsi: Add host helper for te_irq_handler Jagan Teki
2023-03-03 14:51   ` [PATCH v15 13/16] dt-bindings: display: exynos: dsim: Add NXP i.MX8M Mini/Nano support Jagan Teki
2023-03-03 14:51   ` [PATCH v15 14/16] drm: bridge: samsung-dsim: Add " Jagan Teki
2023-03-03 14:51   ` [PATCH v15 15/16] dt-bindings: display: exynos: dsim: Add NXP i.MX8M Plus support Jagan Teki
2023-03-03 14:51   ` [PATCH v15 16/16] drm: bridge: samsung-dsim: Add " Jagan Teki
     [not found]   ` <20230303145138.29233-13-jagan@amarulasolutions.com>
2023-03-03 15:08     ` [PATCH v15 12/16] drm: bridge: Generalize Exynos-DSI driver into a Samsung DSIM bridge Maxime Ripard
2023-03-03 15:11       ` Jagan Teki
2023-03-03 22:26   ` [PATCH v15 00/16] drm: Add Samsung MIPI " Marek Szyprowski
2023-03-04 18:59     ` Jagan Teki
2023-03-06 11:02       ` Marek Szyprowski
2023-03-06 17:24         ` Jagan Teki
2023-03-06 22:41           ` Marek Szyprowski
2023-03-07  7:55             ` Jagan Teki
2023-03-07  9:22               ` Jagan Teki
2023-03-07 10:44                 ` Marek Szyprowski
2023-03-06  5:24   ` 대인기/Tizen Platform Lab(SR)/삼성전자
2023-03-06  8:48     ` Jagan Teki
2023-03-14  0:31     ` Fabio Estevam
     [not found]       ` <CAAQKjZM66M6wgtoBmAcQifq8LgBUos0bZfbTkRBqnOb7E-05tQ@mail.gmail.com>
2023-03-23 15:34         ` Fabio Estevam
2023-03-27 14:08           ` Neil Armstrong
     [not found]             ` <CAAQKjZPmYcdUphP9w7i_O65rhXwsw2rCxAnDJ1JG73-RuLP4UQ@mail.gmail.com>
2023-03-28  7:53               ` Neil Armstrong

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=20230303145138.29233-3-jagan@amarulasolutions.com \
    --to=jagan@amarulasolutions.com \
    --cc=aford173@gmail.com \
    --cc=andrzej.hajda@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=frieder.schrempf@kontron.de \
    --cc=inki.dae@samsung.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-amarula@amarulasolutions.com \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=marex@denx.de \
    --cc=matteo.lisi@engicam.com \
    --cc=mripard@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=sw0312.kim@samsung.com \
    --cc=tharvey@gateworks.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