aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2018-09-21 16:32:58 -0400
committerTomi Valkeinen <tomi.valkeinen@ti.com>2019-03-18 05:42:13 -0400
commitce69aac84fe322ab5e1f91224dc15d1957ded75c (patch)
treea7715645dba03d5a48570048705734f3bcdca282
parente5906f765c68b3fa0e9806116a73c786c09642e2 (diff)
drm/omap: Simplify OF lookup of DSS devices
Now that the direction of OF graph walk has been reversed, there's no need to lookup devices by port as we have no sink device connected through multiple sink ports. Simplify OF lookup of the DSS devices to look them up by node only. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com> Tested-by: Sebastian Reichel <sebastian.reichel@collabora.com> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
-rw-r--r--drivers/gpu/drm/omapdrm/dss/base.c5
-rw-r--r--drivers/gpu/drm/omapdrm/dss/dss-of.c60
-rw-r--r--drivers/gpu/drm/omapdrm/dss/omapdss.h3
3 files changed, 10 insertions, 58 deletions
diff --git a/drivers/gpu/drm/omapdrm/dss/base.c b/drivers/gpu/drm/omapdrm/dss/base.c
index 62ccbeb99a84..d14abde3c5f0 100644
--- a/drivers/gpu/drm/omapdrm/dss/base.c
+++ b/drivers/gpu/drm/omapdrm/dss/base.c
@@ -112,13 +112,12 @@ void omapdss_device_put(struct omap_dss_device *dssdev)
112} 112}
113EXPORT_SYMBOL(omapdss_device_put); 113EXPORT_SYMBOL(omapdss_device_put);
114 114
115struct omap_dss_device *omapdss_find_device_by_port(struct device_node *src, 115struct omap_dss_device *omapdss_find_device_by_node(struct device_node *node)
116 unsigned int port)
117{ 116{
118 struct omap_dss_device *dssdev; 117 struct omap_dss_device *dssdev;
119 118
120 list_for_each_entry(dssdev, &omapdss_devices_list, list) { 119 list_for_each_entry(dssdev, &omapdss_devices_list, list) {
121 if (dssdev->dev->of_node == src && dssdev->of_ports & BIT(port)) 120 if (dssdev->dev->of_node == node)
122 return omapdss_device_get(dssdev); 121 return omapdss_device_get(dssdev);
123 } 122 }
124 123
diff --git a/drivers/gpu/drm/omapdrm/dss/dss-of.c b/drivers/gpu/drm/omapdrm/dss/dss-of.c
index 0422597ac6b0..b2094055c5fc 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss-of.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss-of.c
@@ -12,71 +12,25 @@
12 * more details. 12 * more details.
13 */ 13 */
14 14
15#include <linux/device.h>
16#include <linux/err.h> 15#include <linux/err.h>
17#include <linux/module.h>
18#include <linux/of.h> 16#include <linux/of.h>
19#include <linux/of_graph.h> 17#include <linux/of_graph.h>
20#include <linux/seq_file.h>
21 18
22#include "omapdss.h" 19#include "omapdss.h"
23 20
24static struct device_node *
25dss_of_port_get_parent_device(struct device_node *port)
26{
27 struct device_node *np;
28 int i;
29
30 if (!port)
31 return NULL;
32
33 np = of_get_parent(port);
34
35 for (i = 0; i < 2 && np; ++i) {
36 struct property *prop;
37
38 prop = of_find_property(np, "compatible", NULL);
39
40 if (prop)
41 return np;
42
43 np = of_get_next_parent(np);
44 }
45
46 return NULL;
47}
48
49struct omap_dss_device * 21struct omap_dss_device *
50omapdss_of_find_connected_device(struct device_node *node, unsigned int port) 22omapdss_of_find_connected_device(struct device_node *node, unsigned int port)
51{ 23{
52 struct device_node *src_node; 24 struct device_node *remote_node;
53 struct device_node *src_port; 25 struct omap_dss_device *dssdev;
54 struct device_node *ep;
55 struct omap_dss_device *src;
56 u32 port_number = 0;
57 26
58 /* Get the endpoint... */ 27 remote_node = of_graph_get_remote_node(node, port, 0);
59 ep = of_graph_get_endpoint_by_regs(node, port, 0); 28 if (!remote_node)
60 if (!ep)
61 return NULL; 29 return NULL;
62 30
63 /* ... and its remote port... */ 31 dssdev = omapdss_find_device_by_node(remote_node);
64 src_port = of_graph_get_remote_port(ep); 32 of_node_put(remote_node);
65 of_node_put(ep);
66 if (!src_port)
67 return NULL;
68
69 /* ... and the remote port's number and parent... */
70 of_property_read_u32(src_port, "reg", &port_number);
71 src_node = dss_of_port_get_parent_device(src_port);
72 of_node_put(src_port);
73 if (!src_node)
74 return ERR_PTR(-EINVAL);
75
76 /* ... and finally the connected device. */
77 src = omapdss_find_device_by_port(src_node, port_number);
78 of_node_put(src_node);
79 33
80 return src ? src : ERR_PTR(-EPROBE_DEFER); 34 return dssdev ? dssdev : ERR_PTR(-EPROBE_DEFER);
81} 35}
82EXPORT_SYMBOL_GPL(omapdss_of_find_connected_device); 36EXPORT_SYMBOL_GPL(omapdss_of_find_connected_device);
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index a63b1d4b7a8a..d13a6b5774e8 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -474,8 +474,7 @@ void omapdss_device_register(struct omap_dss_device *dssdev);
474void omapdss_device_unregister(struct omap_dss_device *dssdev); 474void omapdss_device_unregister(struct omap_dss_device *dssdev);
475struct omap_dss_device *omapdss_device_get(struct omap_dss_device *dssdev); 475struct omap_dss_device *omapdss_device_get(struct omap_dss_device *dssdev);
476void omapdss_device_put(struct omap_dss_device *dssdev); 476void omapdss_device_put(struct omap_dss_device *dssdev);
477struct omap_dss_device *omapdss_find_device_by_port(struct device_node *src, 477struct omap_dss_device *omapdss_find_device_by_node(struct device_node *node);
478 unsigned int port);
479int omapdss_device_connect(struct dss_device *dss, 478int omapdss_device_connect(struct dss_device *dss,
480 struct omap_dss_device *src, 479 struct omap_dss_device *src,
481 struct omap_dss_device *dst); 480 struct omap_dss_device *dst);