aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2013-12-03 09:57:40 -0500
committerTomi Valkeinen <tomi.valkeinen@ti.com>2014-03-19 05:03:06 -0400
commit4e7470ddca671aee2f5d11ba68573c94feddc5c2 (patch)
tree53f266284e095985c4b04a5e2d0d943748113091 /drivers/video
parenta6ec216493da705a5f6fc96098c5f4af10e2be44 (diff)
OMAPDSS: add of helpers
Add helpers to get ports and endpoints from DT data. These helpers parse v4l2 style ports and endpoints, but compared to the v4l2 helpers, these allow iterating ports and endpoints separately. This is a temporary solution until we get generic code to parse the ports and endpoints. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Reviewed-by: Archit Taneja <archit@ti.com>
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/omap2/dss/Makefile2
-rw-r--r--drivers/video/omap2/dss/dss-of.c159
2 files changed, 160 insertions, 1 deletions
diff --git a/drivers/video/omap2/dss/Makefile b/drivers/video/omap2/dss/Makefile
index d3aa91bdd6a8..8aec8bda27cc 100644
--- a/drivers/video/omap2/dss/Makefile
+++ b/drivers/video/omap2/dss/Makefile
@@ -1,7 +1,7 @@
1obj-$(CONFIG_OMAP2_DSS) += omapdss.o 1obj-$(CONFIG_OMAP2_DSS) += omapdss.o
2# Core DSS files 2# Core DSS files
3omapdss-y := core.o dss.o dss_features.o dispc.o dispc_coefs.o display.o \ 3omapdss-y := core.o dss.o dss_features.o dispc.o dispc_coefs.o display.o \
4 output.o 4 output.o dss-of.o
5# DSS compat layer files 5# DSS compat layer files
6omapdss-y += manager.o manager-sysfs.o overlay.o overlay-sysfs.o apply.o \ 6omapdss-y += manager.o manager-sysfs.o overlay.o overlay-sysfs.o apply.o \
7 dispc-compat.o display-sysfs.o 7 dispc-compat.o display-sysfs.o
diff --git a/drivers/video/omap2/dss/dss-of.c b/drivers/video/omap2/dss/dss-of.c
new file mode 100644
index 000000000000..a4b20aaf6142
--- /dev/null
+++ b/drivers/video/omap2/dss/dss-of.c
@@ -0,0 +1,159 @@
1/*
2 * Copyright (C) 2013 Texas Instruments
3 * Author: Tomi Valkeinen <tomi.valkeinen@ti.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 */
14
15#include <linux/device.h>
16#include <linux/err.h>
17#include <linux/module.h>
18#include <linux/of.h>
19#include <linux/seq_file.h>
20
21#include <video/omapdss.h>
22
23struct device_node *
24omapdss_of_get_next_port(const struct device_node *parent,
25 struct device_node *prev)
26{
27 struct device_node *port = NULL;
28
29 if (!parent)
30 return NULL;
31
32 if (!prev) {
33 struct device_node *ports;
34 /*
35 * It's the first call, we have to find a port subnode
36 * within this node or within an optional 'ports' node.
37 */
38 ports = of_get_child_by_name(parent, "ports");
39 if (ports)
40 parent = ports;
41
42 port = of_get_child_by_name(parent, "port");
43
44 /* release the 'ports' node */
45 of_node_put(ports);
46 } else {
47 struct device_node *ports;
48
49 ports = of_get_parent(prev);
50 if (!ports)
51 return NULL;
52
53 do {
54 port = of_get_next_child(ports, prev);
55 if (!port) {
56 of_node_put(ports);
57 return NULL;
58 }
59 prev = port;
60 } while (of_node_cmp(port->name, "port") != 0);
61 }
62
63 return port;
64}
65EXPORT_SYMBOL_GPL(omapdss_of_get_next_port);
66
67struct device_node *
68omapdss_of_get_next_endpoint(const struct device_node *parent,
69 struct device_node *prev)
70{
71 struct device_node *ep = NULL;
72
73 if (!parent)
74 return NULL;
75
76 do {
77 ep = of_get_next_child(parent, prev);
78 if (!ep)
79 return NULL;
80 prev = ep;
81 } while (of_node_cmp(ep->name, "endpoint") != 0);
82
83 return ep;
84}
85EXPORT_SYMBOL_GPL(omapdss_of_get_next_endpoint);
86
87static struct device_node *
88omapdss_of_get_remote_device_node(const struct device_node *node)
89{
90 struct device_node *np;
91 int i;
92
93 np = of_parse_phandle(node, "remote-endpoint", 0);
94
95 if (!np)
96 return NULL;
97
98 np = of_get_next_parent(np);
99
100 for (i = 0; i < 3 && np; ++i) {
101 struct property *prop;
102
103 prop = of_find_property(np, "compatible", NULL);
104
105 if (prop)
106 return np;
107
108 np = of_get_next_parent(np);
109 }
110
111 return NULL;
112}
113
114struct device_node *
115omapdss_of_get_first_endpoint(const struct device_node *parent)
116{
117 struct device_node *port, *ep;
118
119 port = omapdss_of_get_next_port(parent, NULL);
120
121 if (!port)
122 return NULL;
123
124 ep = omapdss_of_get_next_endpoint(port, NULL);
125
126 of_node_put(port);
127
128 return ep;
129}
130EXPORT_SYMBOL_GPL(omapdss_of_get_first_endpoint);
131
132struct omap_dss_device *
133omapdss_of_find_source_for_first_ep(struct device_node *node)
134{
135 struct device_node *ep;
136 struct device_node *src_node;
137 struct omap_dss_device *src;
138
139 ep = omapdss_of_get_first_endpoint(node);
140 if (!ep)
141 return ERR_PTR(-EINVAL);
142
143 src_node = omapdss_of_get_remote_device_node(ep);
144
145 of_node_put(ep);
146
147 if (!src_node)
148 return ERR_PTR(-EINVAL);
149
150 src = omap_dss_find_output_by_node(src_node);
151
152 of_node_put(src_node);
153
154 if (!src)
155 return ERR_PTR(-EPROBE_DEFER);
156
157 return src;
158}
159EXPORT_SYMBOL_GPL(omapdss_of_find_source_for_first_ep);