summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/tilcdc
diff options
context:
space:
mode:
authorRob Herring2017-03-22 14:26:06 +0100
committerSean Paul2017-04-06 23:00:27 +0200
commit86418f90a4c1a0073db65d8a1e2bf94421117a60 (patch)
treea82b9534e5f5c89ceeaa93abaad71da000c7f8d3 /drivers/gpu/drm/tilcdc
parentdrm: of: introduce drm_of_find_panel_or_bridge (diff)
downloadkernel-qcow2-linux-86418f90a4c1a0073db65d8a1e2bf94421117a60.tar.gz
kernel-qcow2-linux-86418f90a4c1a0073db65d8a1e2bf94421117a60.tar.xz
kernel-qcow2-linux-86418f90a4c1a0073db65d8a1e2bf94421117a60.zip
drm: convert drivers to use of_graph_get_remote_node
Convert drivers to use the new of_graph_get_remote_node() helper instead of parsing the endpoint node and then getting the remote device node. Now drivers can just specify the device node and which port/endpoint and get back the connected remote device node. The details of the graph binding are nicely abstracted into the core OF graph code. This changes some error messages to debug messages (in the graph core). Graph connections are often "no connects" depending on the particular board, so we want to avoid spurious messages. Plus the kernel is not a DT validator. Signed-off-by: Rob Herring <robh@kernel.org> Acked-by: Neil Armstrong <narmstrong@baylibre.com> Tested-by: Liviu Dudau <liviu.dudau@arm.com> Tested-by: Eric Anholt <eric@anholt.net> Tested-by: Jyri Sarha <jsarha@ti.com> Tested by: Archit Taneja <architt@codeaurora.org> Signed-off-by: Sean Paul <seanpaul@chromium.org>
Diffstat (limited to 'drivers/gpu/drm/tilcdc')
-rw-r--r--drivers/gpu/drm/tilcdc/tilcdc_crtc.c12
-rw-r--r--drivers/gpu/drm/tilcdc/tilcdc_external.c68
2 files changed, 10 insertions, 70 deletions
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index afd2a7b2aff7..d524ed0d5146 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -23,6 +23,7 @@
#include <linux/workqueue.h>
#include <linux/completion.h>
#include <linux/dma-mapping.h>
+#include <linux/of_graph.h>
#include "tilcdc_drv.h"
#include "tilcdc_regs.h"
@@ -1035,16 +1036,7 @@ int tilcdc_crtc_create(struct drm_device *dev)
drm_crtc_helper_add(crtc, &tilcdc_crtc_helper_funcs);
if (priv->is_componentized) {
- struct device_node *ports =
- of_get_child_by_name(dev->dev->of_node, "ports");
-
- if (ports) {
- crtc->port = of_get_child_by_name(ports, "port");
- of_node_put(ports);
- } else {
- crtc->port =
- of_get_child_by_name(dev->dev->of_node, "port");
- }
+ crtc->port = of_graph_get_port_by_id(dev->dev->of_node, 0);
if (!crtc->port) { /* This should never happen */
dev_err(dev->dev, "Port node not found in %s\n",
dev->dev->of_node->full_name);
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c
index b0dd5e8634ae..711c7b3289d3 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
@@ -185,39 +185,6 @@ int tilcdc_attach_bridge(struct drm_device *ddev, struct drm_bridge *bridge)
return ret;
}
-static int tilcdc_node_has_port(struct device_node *dev_node)
-{
- struct device_node *node;
-
- node = of_get_child_by_name(dev_node, "ports");
- if (!node)
- node = of_get_child_by_name(dev_node, "port");
- if (!node)
- return 0;
- of_node_put(node);
-
- return 1;
-}
-
-static
-struct device_node *tilcdc_get_remote_node(struct device_node *node)
-{
- struct device_node *ep;
- struct device_node *parent;
-
- if (!tilcdc_node_has_port(node))
- return NULL;
-
- ep = of_graph_get_next_endpoint(node, NULL);
- if (!ep)
- return NULL;
-
- parent = of_graph_get_remote_port_parent(ep);
- of_node_put(ep);
-
- return parent;
-}
-
int tilcdc_attach_external_device(struct drm_device *ddev)
{
struct tilcdc_drm_private *priv = ddev->dev_private;
@@ -225,7 +192,7 @@ int tilcdc_attach_external_device(struct drm_device *ddev)
struct drm_bridge *bridge;
int ret;
- remote_node = tilcdc_get_remote_node(ddev->dev->of_node);
+ remote_node = of_graph_get_remote_node(ddev->dev->of_node, 0, 0);
if (!remote_node)
return 0;
@@ -264,35 +231,16 @@ int tilcdc_get_external_components(struct device *dev,
struct component_match **match)
{
struct device_node *node;
- struct device_node *ep = NULL;
- int count = 0;
- int ret = 0;
-
- if (!tilcdc_node_has_port(dev->of_node))
- return 0;
- while ((ep = of_graph_get_next_endpoint(dev->of_node, ep))) {
- node = of_graph_get_remote_port_parent(ep);
- if (!node || !of_device_is_available(node)) {
- of_node_put(node);
- continue;
- }
-
- dev_dbg(dev, "Subdevice node '%s' found\n", node->name);
-
- if (of_device_is_compatible(node, "nxp,tda998x")) {
- if (match)
- drm_of_component_match_add(dev, match,
- dev_match_of, node);
- ret = 1;
- }
+ node = of_graph_get_remote_node(dev->of_node, 0, 0);
+ if (!of_device_is_compatible(node, "nxp,tda998x")) {
of_node_put(node);
- if (count++ > 1) {
- dev_err(dev, "Only one port is supported\n");
- return -EINVAL;
- }
+ return 0;
}
- return ret;
+ if (match)
+ drm_of_component_match_add(dev, match, dev_match_of, node);
+ of_node_put(node);
+ return 1;
}