linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] drm/msm: Use device graph to parse connected panels
@ 2015-06-26  7:43 Archit Taneja
  2015-06-26  7:43 ` [PATCH v2 1/3] drm/msm: dsi host: add missing of_node_put() Archit Taneja
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Archit Taneja @ 2015-06-26  7:43 UTC (permalink / raw)
  To: dri-devel; +Cc: linux-arm-msm, srinivas.kandagatla

drm/msm currently relies on phandles/child nodes to get data about
connected panels to LVDS and DSI. This method has known limitations.

Use device graphs in DT to represent the connections between the encoder
outputs and the panels. Use of_graph helpers in the driver to get the
panel device node.

The usage of device graphs should also simplify management in dual dsi
mode. I haven't tried this out yet, though.

changes in v2:

- Fix usage of of_node_put()

Archit Taneja (3):
  drm/msm: dsi host: add missing of_node_put()
  drm/msm: dsi host: Use device graph parsing to parse connected panel
  drm/msm: mdp4 lvds: get panel node via of graph parsing

 Documentation/devicetree/bindings/drm/msm/dsi.txt | 15 ++++++
 drivers/gpu/drm/msm/dsi/dsi_host.c                | 62 ++++++++++++++++++-----
 drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c           | 33 ++++++++----
 drivers/gpu/drm/msm/msm_drv.h                     |  1 +
 4 files changed, 88 insertions(+), 23 deletions(-)

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 1/3] drm/msm: dsi host: add missing of_node_put()
  2015-06-26  7:43 [PATCH v2 0/3] drm/msm: Use device graph to parse connected panels Archit Taneja
@ 2015-06-26  7:43 ` Archit Taneja
  2015-06-26  7:43 ` [PATCH v2 2/3] drm/msm: dsi host: Use device graph parsing to parse connected panel Archit Taneja
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Archit Taneja @ 2015-06-26  7:43 UTC (permalink / raw)
  To: dri-devel; +Cc: linux-arm-msm, srinivas.kandagatla

Decrement device node refcount if of_get_child_by_name is successfully
called.

Signed-off-by: Archit Taneja <architt@codeaurora.org>
---
 drivers/gpu/drm/msm/dsi/dsi_host.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
index 984f9ef..5c3e82d 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -1586,8 +1586,12 @@ int msm_dsi_host_register(struct mipi_dsi_host *host, bool check_defer)
 			node = of_get_child_by_name(msm_host->pdev->dev.of_node,
 							"panel");
 			if (node) {
-				if (!of_drm_find_panel(node))
+				if (!of_drm_find_panel(node)) {
+					of_node_put(node);
 					return -EPROBE_DEFER;
+				}
+
+				of_node_put(node);
 			}
 		}
 	}
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 2/3] drm/msm: dsi host: Use device graph parsing to parse connected panel
  2015-06-26  7:43 [PATCH v2 0/3] drm/msm: Use device graph to parse connected panels Archit Taneja
  2015-06-26  7:43 ` [PATCH v2 1/3] drm/msm: dsi host: add missing of_node_put() Archit Taneja
@ 2015-06-26  7:43 ` Archit Taneja
  2015-06-26  7:43 ` [PATCH v2 3/3] drm/msm: mdp4 lvds: get panel node via of graph parsing Archit Taneja
  2015-08-02 16:18 ` [PATCH v3 0/3] drm/msm: Use device graph to parse connected panels Archit Taneja
  3 siblings, 0 replies; 8+ messages in thread
From: Archit Taneja @ 2015-06-26  7:43 UTC (permalink / raw)
  To: dri-devel
  Cc: robdclark, linux-arm-msm, hali, srinivas.kandagatla, Archit Taneja

The dsi host looks for the connected panel node by parsing for a child
named 'panel'. This hierarchy isn't very flexible. The connected
panel is forced to be a child to the dsi host, and hence, a mipi dsi
device. This isn't suitable for dsi devices that don't use mipi dsi
as their control bus.

Follow the of_graph approach of creating ports and endpoints to
represent the connections between the dsi host and the panel connected
to it. In our case, the dsi host will only have one output port, linked
to the panel's input port.

Update DT binding documentation with device graph usage info.

Signed-off-by: Archit Taneja <architt@codeaurora.org>
---
 Documentation/devicetree/bindings/drm/msm/dsi.txt | 15 ++++++
 drivers/gpu/drm/msm/dsi/dsi_host.c                | 66 ++++++++++++++++-------
 2 files changed, 63 insertions(+), 18 deletions(-)

diff --git a/Documentation/devicetree/bindings/drm/msm/dsi.txt b/Documentation/devicetree/bindings/drm/msm/dsi.txt
index 6ccd860..c88ec3c 100644
--- a/Documentation/devicetree/bindings/drm/msm/dsi.txt
+++ b/Documentation/devicetree/bindings/drm/msm/dsi.txt
@@ -25,6 +25,9 @@ Required properties:
 - vddio-supply: phandle to vdd-io regulator device node
 - vdda-supply: phandle to vdda regulator device node
 - qcom,dsi-phy: phandle to DSI PHY device node
+- port: DSI controller output port. This contains one endpoint subnode, with its
+  remote-endpoint set to the phandle of the connected panel's endpoint.
+  See Documentation/devicetree/bindings/graph.txt for device graph info.
 
 Optional properties:
 - panel@0: Node of panel connected to this DSI controller.
@@ -101,6 +104,18 @@ Example:
 
 			power-supply = <...>;
 			backlight = <...>;
+
+			port {
+				panel_in: endpoint {
+					remote-endpoint = <&dsi0_out>;
+				};
+			};
+		};
+
+		port {
+			dsi0_out: endpoint {
+				remote-endpoint = <&panel_in>;
+			};
 		};
 	};
 
diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
index 5c3e82d..5b9077d 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -20,6 +20,7 @@
 #include <linux/of_device.h>
 #include <linux/of_gpio.h>
 #include <linux/of_irq.h>
+#include <linux/of_graph.h>
 #include <linux/regulator/consumer.h>
 #include <linux/spinlock.h>
 #include <video/mipi_display.h>
@@ -1383,7 +1384,7 @@ static int dsi_host_attach(struct mipi_dsi_host *host,
 	msm_host->format = dsi->format;
 	msm_host->mode_flags = dsi->mode_flags;
 
-	msm_host->panel_node = dsi->dev.of_node;
+	WARN_ON(dsi->dev.of_node != msm_host->panel_node);
 
 	/* Some gpios defined in panel DT need to be controlled by host */
 	ret = dsi_host_init_panel_gpios(msm_host, &dsi->dev);
@@ -1433,6 +1434,46 @@ static struct mipi_dsi_host_ops dsi_host_ops = {
 	.transfer = dsi_host_transfer,
 };
 
+static int msm_dsi_host_parse_dt(struct msm_dsi_host *msm_host)
+{
+	struct device *dev = &msm_host->pdev->dev;
+	struct device_node *np = dev->of_node;
+	struct device_node *endpoint, *panel_node;
+	int ret;
+
+	ret = of_property_read_u32(np, "qcom,dsi-host-index", &msm_host->id);
+	if (ret) {
+		dev_err(dev, "%s: host index not specified, ret=%d\n",
+			__func__, ret);
+		return ret;
+	}
+
+	/*
+	 * get the first endpoint node. in our case, dsi has one output port
+	 * to which the panel is connected.
+	 */
+	endpoint = of_graph_get_next_endpoint(np, NULL);
+	if (IS_ERR(endpoint)) {
+		dev_err(dev, "%s: no valid endpoint\n", __func__);
+		return PTR_ERR(endpoint);
+	}
+
+	/* get panel node from the output port's endpoint data */
+	panel_node = of_graph_get_remote_port_parent(endpoint);
+	if (IS_ERR(panel_node)) {
+		dev_err(dev, "%s: no valid device\n", __func__);
+		of_node_put(endpoint);
+		return PTR_ERR(panel_node);
+	}
+
+	of_node_put(endpoint);
+	of_node_put(panel_node);
+
+	msm_host->panel_node = panel_node;
+
+	return 0;
+}
+
 int msm_dsi_host_init(struct msm_dsi *msm_dsi)
 {
 	struct msm_dsi_host *msm_host = NULL;
@@ -1447,15 +1488,13 @@ int msm_dsi_host_init(struct msm_dsi *msm_dsi)
 		goto fail;
 	}
 
-	ret = of_property_read_u32(pdev->dev.of_node,
-				"qcom,dsi-host-index", &msm_host->id);
+	msm_host->pdev = pdev;
+
+	ret = msm_dsi_host_parse_dt(msm_host);
 	if (ret) {
-		dev_err(&pdev->dev,
-			"%s: host index not specified, ret=%d\n",
-			__func__, ret);
+		pr_err("%s: failed to parse dt\n", __func__);
 		goto fail;
 	}
-	msm_host->pdev = pdev;
 
 	ret = dsi_clk_init(msm_host);
 	if (ret) {
@@ -1563,7 +1602,6 @@ int msm_dsi_host_modeset_init(struct mipi_dsi_host *host,
 int msm_dsi_host_register(struct mipi_dsi_host *host, bool check_defer)
 {
 	struct msm_dsi_host *msm_host = to_msm_dsi_host(host);
-	struct device_node *node;
 	int ret;
 
 	/* Register mipi dsi host */
@@ -1583,16 +1621,8 @@ int msm_dsi_host_register(struct mipi_dsi_host *host, bool check_defer)
 		 * create framebuffer.
 		 */
 		if (check_defer) {
-			node = of_get_child_by_name(msm_host->pdev->dev.of_node,
-							"panel");
-			if (node) {
-				if (!of_drm_find_panel(node)) {
-					of_node_put(node);
-					return -EPROBE_DEFER;
-				}
-
-				of_node_put(node);
-			}
+			if (!of_drm_find_panel(msm_host->panel_node))
+				return -EPROBE_DEFER;
 		}
 	}
 
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 3/3] drm/msm: mdp4 lvds: get panel node via of graph parsing
  2015-06-26  7:43 [PATCH v2 0/3] drm/msm: Use device graph to parse connected panels Archit Taneja
  2015-06-26  7:43 ` [PATCH v2 1/3] drm/msm: dsi host: add missing of_node_put() Archit Taneja
  2015-06-26  7:43 ` [PATCH v2 2/3] drm/msm: dsi host: Use device graph parsing to parse connected panel Archit Taneja
@ 2015-06-26  7:43 ` Archit Taneja
  2015-08-02 16:18 ` [PATCH v3 0/3] drm/msm: Use device graph to parse connected panels Archit Taneja
  3 siblings, 0 replies; 8+ messages in thread
From: Archit Taneja @ 2015-06-26  7:43 UTC (permalink / raw)
  To: dri-devel; +Cc: linux-arm-msm, srinivas.kandagatla

We currently get the output connected to LVDS by looking for a phandle
called 'qcom,lvds-panel' under the mdp DT node.

Use the more standard of_graph approach to create an lvds output port,
and retrieve the panel node from the port's endpoint data.

Signed-off-by: Archit Taneja <architt@codeaurora.org>
---
 drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c | 33 ++++++++++++++++++++++++---------
 drivers/gpu/drm/msm/msm_drv.h           |  1 +
 2 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
index 531e4ac..1bb9d8b 100644
--- a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
+++ b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
@@ -241,22 +241,37 @@ int mdp4_enable(struct mdp4_kms *mdp4_kms)
 }
 
 #ifdef CONFIG_OF
-static struct drm_panel *detect_panel(struct drm_device *dev, const char *name)
+static struct drm_panel *detect_panel(struct drm_device *dev)
 {
-	struct device_node *n;
+	struct device_node *endpoint, *panel_node;
+	struct device_node *np = dev->dev->of_node;
 	struct drm_panel *panel = NULL;
 
-	n = of_parse_phandle(dev->dev->of_node, name, 0);
-	if (n) {
-		panel = of_drm_find_panel(n);
-		if (!panel)
-			panel = ERR_PTR(-EPROBE_DEFER);
+	endpoint = of_graph_get_next_endpoint(np, NULL);
+	if (IS_ERR(endpoint)) {
+		dev_err(dev->dev, "no valid endpoint\n");
+		return ERR_CAST(endpoint);
+	}
+
+	panel_node = of_graph_get_remote_port_parent(endpoint);
+	if (IS_ERR(panel_node)) {
+		dev_err(dev->dev, "no valid panel node\n");
+		of_node_put(endpoint);
+		return ERR_CAST(panel_node);
+	}
+
+	of_node_put(endpoint);
+
+	panel = of_drm_find_panel(panel_node);
+	if (IS_ERR(panel)) {
+		of_node_put(panel_node);
+		return ERR_PTR(-EPROBE_DEFER);
 	}
 
 	return panel;
 }
 #else
-static struct drm_panel *detect_panel(struct drm_device *dev, const char *name)
+static struct drm_panel *detect_panel(struct drm_device *dev)
 {
 	// ??? maybe use a module param to specify which panel is attached?
 }
@@ -294,7 +309,7 @@ static int modeset_init(struct mdp4_kms *mdp4_kms)
 	 * Setup the LCDC/LVDS path: RGB2 -> DMA_P -> LCDC -> LVDS:
 	 */
 
-	panel = detect_panel(dev, "qcom,lvds-panel");
+	panel = detect_panel(dev);
 	if (IS_ERR(panel)) {
 		ret = PTR_ERR(panel);
 		dev_err(dev->dev, "failed to detect LVDS panel: %d\n", ret);
diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
index e7c5ea1..0cbeb1d 100644
--- a/drivers/gpu/drm/msm/msm_drv.h
+++ b/drivers/gpu/drm/msm/msm_drv.h
@@ -30,6 +30,7 @@
 #include <linux/list.h>
 #include <linux/iommu.h>
 #include <linux/types.h>
+#include <linux/of_graph.h>
 #include <asm/sizes.h>
 
 #ifndef CONFIG_OF
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v3 0/3] drm/msm: Use device graph to parse connected panels
  2015-06-26  7:43 [PATCH v2 0/3] drm/msm: Use device graph to parse connected panels Archit Taneja
                   ` (2 preceding siblings ...)
  2015-06-26  7:43 ` [PATCH v2 3/3] drm/msm: mdp4 lvds: get panel node via of graph parsing Archit Taneja
@ 2015-08-02 16:18 ` Archit Taneja
  2015-08-02 16:18   ` [PATCH v3 1/3] drm/msm: dsi host: add missing of_node_put() Archit Taneja
                     ` (2 more replies)
  3 siblings, 3 replies; 8+ messages in thread
From: Archit Taneja @ 2015-08-02 16:18 UTC (permalink / raw)
  To: dri-devel, hali
  Cc: robdclark, linux-arm-msm, srinivas.kandagatla, Archit Taneja

drm/msm currently relies on phandles/child nodes to get data about
connected panels to LVDS and DSI. This method has known limitations.

Use device graphs in DT to represent the connections between the encoder
outputs and the panels. Use of_graph helpers in the driver to get the
panel device node.

The usage of device graphs should also simplify management in dual dsi
mode. I haven't tried this out yet, though.

changes in v3:

- Some changes suggested by Hai
- error handling when using of_graph helpers

changes in v2:

- Fix usage of of_node_put()

Archit Taneja (3):
  drm/msm: dsi host: add missing of_node_put()
  drm/msm: dsi host: Use device graph parsing to parse connected panel
  drm/msm: mdp4 lvds: get panel node via of graph parsing

 Documentation/devicetree/bindings/drm/msm/dsi.txt | 15 +++++
 drivers/gpu/drm/msm/dsi/dsi_host.c                | 68 ++++++++++++++++++-----
 drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c           | 33 ++++++++---
 drivers/gpu/drm/msm/msm_drv.h                     |  1 +
 4 files changed, 93 insertions(+), 24 deletions(-)

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v3 1/3] drm/msm: dsi host: add missing of_node_put()
  2015-08-02 16:18 ` [PATCH v3 0/3] drm/msm: Use device graph to parse connected panels Archit Taneja
@ 2015-08-02 16:18   ` Archit Taneja
  2015-08-02 16:18   ` [PATCH v3 2/3] drm/msm: dsi host: Use device graph parsing to parse connected panel Archit Taneja
  2015-08-02 16:18   ` [PATCH v3 3/3] drm/msm: mdp4 lvds: get panel node via of graph parsing Archit Taneja
  2 siblings, 0 replies; 8+ messages in thread
From: Archit Taneja @ 2015-08-02 16:18 UTC (permalink / raw)
  To: dri-devel, hali
  Cc: robdclark, linux-arm-msm, srinivas.kandagatla, Archit Taneja

Decrement device node refcount if of_get_child_by_name is successfully
called.

Signed-off-by: Archit Taneja <architt@codeaurora.org>
---
 drivers/gpu/drm/msm/dsi/dsi_host.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
index de04009..e2c9610 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -1582,8 +1582,12 @@ int msm_dsi_host_register(struct mipi_dsi_host *host, bool check_defer)
 			node = of_get_child_by_name(msm_host->pdev->dev.of_node,
 							"panel");
 			if (node) {
-				if (!of_drm_find_panel(node))
+				if (!of_drm_find_panel(node)) {
+					of_node_put(node);
 					return -EPROBE_DEFER;
+				}
+
+				of_node_put(node);
 			}
 		}
 	}
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v3 2/3] drm/msm: dsi host: Use device graph parsing to parse connected panel
  2015-08-02 16:18 ` [PATCH v3 0/3] drm/msm: Use device graph to parse connected panels Archit Taneja
  2015-08-02 16:18   ` [PATCH v3 1/3] drm/msm: dsi host: add missing of_node_put() Archit Taneja
@ 2015-08-02 16:18   ` Archit Taneja
  2015-08-02 16:18   ` [PATCH v3 3/3] drm/msm: mdp4 lvds: get panel node via of graph parsing Archit Taneja
  2 siblings, 0 replies; 8+ messages in thread
From: Archit Taneja @ 2015-08-02 16:18 UTC (permalink / raw)
  To: dri-devel, hali
  Cc: robdclark, linux-arm-msm, srinivas.kandagatla, Archit Taneja

The dsi host looks for the connected panel node by parsing for a child
named 'panel'. This hierarchy isn't very flexible. The connected
panel is forced to be a child to the dsi host, and hence, a mipi dsi
device. This isn't suitable for dsi devices that don't use mipi dsi
as their control bus.

Follow the of_graph approach of creating ports and endpoints to
represent the connections between the dsi host and the panel connected
to it. In our case, the dsi host will only have one output port, linked
to the panel's input port.

Update DT binding documentation with device graph usage info.

v3:
- Fix return value checks of of_graph_* calls.
- Don't make port a mandatory DT property
- Fix defer check when no panel node specified
- Rename parse_dt func to align with other dsi_host funcs

Reviewed-by: Hai Li <hali@codeaurora.org>
Signed-off-by: Archit Taneja <architt@codeaurora.org>
---
 Documentation/devicetree/bindings/drm/msm/dsi.txt | 15 +++++
 drivers/gpu/drm/msm/dsi/dsi_host.c                | 72 +++++++++++++++++------
 2 files changed, 68 insertions(+), 19 deletions(-)

diff --git a/Documentation/devicetree/bindings/drm/msm/dsi.txt b/Documentation/devicetree/bindings/drm/msm/dsi.txt
index cd8fe6c..6cada5a 100644
--- a/Documentation/devicetree/bindings/drm/msm/dsi.txt
+++ b/Documentation/devicetree/bindings/drm/msm/dsi.txt
@@ -38,6 +38,9 @@ Optional properties:
   driving a 2-DSI panel whose 2 links need receive command simultaneously.
 - interrupt-parent: phandle to the MDP block if the interrupt signal is routed
   through MDP block
+- port: DSI controller output port. This contains one endpoint subnode, with its
+  remote-endpoint set to the phandle of the connected panel's endpoint.
+  See Documentation/devicetree/bindings/graph.txt for device graph info.
 
 DSI PHY:
 Required properties:
@@ -101,6 +104,18 @@ Example:
 
 			power-supply = <...>;
 			backlight = <...>;
+
+			port {
+				panel_in: endpoint {
+					remote-endpoint = <&dsi0_out>;
+				};
+			};
+		};
+
+		port {
+			dsi0_out: endpoint {
+				remote-endpoint = <&panel_in>;
+			};
 		};
 	};
 
diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
index e2c9610..914559c 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -20,6 +20,7 @@
 #include <linux/of_device.h>
 #include <linux/of_gpio.h>
 #include <linux/of_irq.h>
+#include <linux/of_graph.h>
 #include <linux/regulator/consumer.h>
 #include <linux/spinlock.h>
 #include <video/mipi_display.h>
@@ -1379,7 +1380,7 @@ static int dsi_host_attach(struct mipi_dsi_host *host,
 	msm_host->format = dsi->format;
 	msm_host->mode_flags = dsi->mode_flags;
 
-	msm_host->panel_node = dsi->dev.of_node;
+	WARN_ON(dsi->dev.of_node != msm_host->panel_node);
 
 	/* Some gpios defined in panel DT need to be controlled by host */
 	ret = dsi_host_init_panel_gpios(msm_host, &dsi->dev);
@@ -1429,6 +1430,48 @@ static struct mipi_dsi_host_ops dsi_host_ops = {
 	.transfer = dsi_host_transfer,
 };
 
+static int dsi_host_parse_dt(struct msm_dsi_host *msm_host)
+{
+	struct device *dev = &msm_host->pdev->dev;
+	struct device_node *np = dev->of_node;
+	struct device_node *endpoint, *panel_node;
+	int ret;
+
+	ret = of_property_read_u32(np, "qcom,dsi-host-index", &msm_host->id);
+	if (ret) {
+		dev_err(dev, "%s: host index not specified, ret=%d\n",
+			__func__, ret);
+		return ret;
+	}
+
+	/*
+	 * Get the first endpoint node. In our case, dsi has one output port
+	 * to which the panel is connected. Don't return an error if a port
+	 * isn't defined. It's possible that there is nothing connected to
+	 * the dsi output.
+	 */
+	endpoint = of_graph_get_next_endpoint(np, NULL);
+	if (!endpoint) {
+		dev_dbg(dev, "%s: no endpoint\n", __func__);
+		return 0;
+	}
+
+	/* Get panel node from the output port's endpoint data */
+	panel_node = of_graph_get_remote_port_parent(endpoint);
+	if (!panel_node) {
+		dev_err(dev, "%s: no valid device\n", __func__);
+		of_node_put(endpoint);
+		return -ENODEV;
+	}
+
+	of_node_put(endpoint);
+	of_node_put(panel_node);
+
+	msm_host->panel_node = panel_node;
+
+	return 0;
+}
+
 int msm_dsi_host_init(struct msm_dsi *msm_dsi)
 {
 	struct msm_dsi_host *msm_host = NULL;
@@ -1443,15 +1486,13 @@ int msm_dsi_host_init(struct msm_dsi *msm_dsi)
 		goto fail;
 	}
 
-	ret = of_property_read_u32(pdev->dev.of_node,
-				"qcom,dsi-host-index", &msm_host->id);
+	msm_host->pdev = pdev;
+
+	ret = dsi_host_parse_dt(msm_host);
 	if (ret) {
-		dev_err(&pdev->dev,
-			"%s: host index not specified, ret=%d\n",
-			__func__, ret);
+		pr_err("%s: failed to parse dt\n", __func__);
 		goto fail;
 	}
-	msm_host->pdev = pdev;
 
 	ret = dsi_clk_init(msm_host);
 	if (ret) {
@@ -1559,7 +1600,6 @@ int msm_dsi_host_modeset_init(struct mipi_dsi_host *host,
 int msm_dsi_host_register(struct mipi_dsi_host *host, bool check_defer)
 {
 	struct msm_dsi_host *msm_host = to_msm_dsi_host(host);
-	struct device_node *node;
 	int ret;
 
 	/* Register mipi dsi host */
@@ -1577,18 +1617,12 @@ int msm_dsi_host_register(struct mipi_dsi_host *host, bool check_defer)
 		 * It makes sure panel is connected when fbcon detects
 		 * connector status and gets the proper display mode to
 		 * create framebuffer.
+		 * Don't try to defer if there is nothing connected to the dsi
+		 * output
 		 */
-		if (check_defer) {
-			node = of_get_child_by_name(msm_host->pdev->dev.of_node,
-							"panel");
-			if (node) {
-				if (!of_drm_find_panel(node)) {
-					of_node_put(node);
-					return -EPROBE_DEFER;
-				}
-
-				of_node_put(node);
-			}
+		if (check_defer && msm_host->panel_node) {
+			if (!of_drm_find_panel(msm_host->panel_node))
+				return -EPROBE_DEFER;
 		}
 	}
 
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v3 3/3] drm/msm: mdp4 lvds: get panel node via of graph parsing
  2015-08-02 16:18 ` [PATCH v3 0/3] drm/msm: Use device graph to parse connected panels Archit Taneja
  2015-08-02 16:18   ` [PATCH v3 1/3] drm/msm: dsi host: add missing of_node_put() Archit Taneja
  2015-08-02 16:18   ` [PATCH v3 2/3] drm/msm: dsi host: Use device graph parsing to parse connected panel Archit Taneja
@ 2015-08-02 16:18   ` Archit Taneja
  2 siblings, 0 replies; 8+ messages in thread
From: Archit Taneja @ 2015-08-02 16:18 UTC (permalink / raw)
  To: dri-devel, hali; +Cc: linux-arm-msm, srinivas.kandagatla

We currently get the output connected to LVDS by looking for a phandle
called 'qcom,lvds-panel' under the mdp DT node.

Use the more standard of_graph approach to create an lvds output port,
and retrieve the panel node from the port's endpoint data.

v3
- Fix return value checks of of_graph_* calls.

Tested-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Archit Taneja <architt@codeaurora.org>
---
 drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c | 33 ++++++++++++++++++++++++---------
 drivers/gpu/drm/msm/msm_drv.h           |  1 +
 2 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
index 531e4ac..601dcc0 100644
--- a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
+++ b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
@@ -241,22 +241,37 @@ int mdp4_enable(struct mdp4_kms *mdp4_kms)
 }
 
 #ifdef CONFIG_OF
-static struct drm_panel *detect_panel(struct drm_device *dev, const char *name)
+static struct drm_panel *detect_panel(struct drm_device *dev)
 {
-	struct device_node *n;
+	struct device_node *endpoint, *panel_node;
+	struct device_node *np = dev->dev->of_node;
 	struct drm_panel *panel = NULL;
 
-	n = of_parse_phandle(dev->dev->of_node, name, 0);
-	if (n) {
-		panel = of_drm_find_panel(n);
-		if (!panel)
-			panel = ERR_PTR(-EPROBE_DEFER);
+	endpoint = of_graph_get_next_endpoint(np, NULL);
+	if (!endpoint) {
+		dev_err(dev->dev, "no valid endpoint\n");
+		return ERR_PTR(-ENODEV);
+	}
+
+	panel_node = of_graph_get_remote_port_parent(endpoint);
+	if (!panel_node) {
+		dev_err(dev->dev, "no valid panel node\n");
+		of_node_put(endpoint);
+		return ERR_PTR(-ENODEV);
+	}
+
+	of_node_put(endpoint);
+
+	panel = of_drm_find_panel(panel_node);
+	if (!panel) {
+		of_node_put(panel_node);
+		return ERR_PTR(-EPROBE_DEFER);
 	}
 
 	return panel;
 }
 #else
-static struct drm_panel *detect_panel(struct drm_device *dev, const char *name)
+static struct drm_panel *detect_panel(struct drm_device *dev)
 {
 	// ??? maybe use a module param to specify which panel is attached?
 }
@@ -294,7 +309,7 @@ static int modeset_init(struct mdp4_kms *mdp4_kms)
 	 * Setup the LCDC/LVDS path: RGB2 -> DMA_P -> LCDC -> LVDS:
 	 */
 
-	panel = detect_panel(dev, "qcom,lvds-panel");
+	panel = detect_panel(dev);
 	if (IS_ERR(panel)) {
 		ret = PTR_ERR(panel);
 		dev_err(dev->dev, "failed to detect LVDS panel: %d\n", ret);
diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
index e7c5ea1..0cbeb1d 100644
--- a/drivers/gpu/drm/msm/msm_drv.h
+++ b/drivers/gpu/drm/msm/msm_drv.h
@@ -30,6 +30,7 @@
 #include <linux/list.h>
 #include <linux/iommu.h>
 #include <linux/types.h>
+#include <linux/of_graph.h>
 #include <asm/sizes.h>
 
 #ifndef CONFIG_OF
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-08-02 16:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-26  7:43 [PATCH v2 0/3] drm/msm: Use device graph to parse connected panels Archit Taneja
2015-06-26  7:43 ` [PATCH v2 1/3] drm/msm: dsi host: add missing of_node_put() Archit Taneja
2015-06-26  7:43 ` [PATCH v2 2/3] drm/msm: dsi host: Use device graph parsing to parse connected panel Archit Taneja
2015-06-26  7:43 ` [PATCH v2 3/3] drm/msm: mdp4 lvds: get panel node via of graph parsing Archit Taneja
2015-08-02 16:18 ` [PATCH v3 0/3] drm/msm: Use device graph to parse connected panels Archit Taneja
2015-08-02 16:18   ` [PATCH v3 1/3] drm/msm: dsi host: add missing of_node_put() Archit Taneja
2015-08-02 16:18   ` [PATCH v3 2/3] drm/msm: dsi host: Use device graph parsing to parse connected panel Archit Taneja
2015-08-02 16:18   ` [PATCH v3 3/3] drm/msm: mdp4 lvds: get panel node via of graph parsing Archit Taneja

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).