2 * Copyright (C) 2013 Texas Instruments
3 * Author: Tomi Valkeinen <tomi.valkeinen@ti.com>
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.
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
15 #include <linux/device.h>
16 #include <linux/err.h>
17 #include <linux/module.h>
19 #include <linux/seq_file.h>
21 #include <video/omapdss.h>
24 omapdss_of_get_next_port(const struct device_node
*parent
,
25 struct device_node
*prev
)
27 struct device_node
*port
= NULL
;
33 struct device_node
*ports
;
35 * It's the first call, we have to find a port subnode
36 * within this node or within an optional 'ports' node.
38 ports
= of_get_child_by_name(parent
, "ports");
42 port
= of_get_child_by_name(parent
, "port");
44 /* release the 'ports' node */
47 struct device_node
*ports
;
49 ports
= of_get_parent(prev
);
54 port
= of_get_next_child(ports
, prev
);
60 } while (of_node_cmp(port
->name
, "port") != 0);
65 EXPORT_SYMBOL_GPL(omapdss_of_get_next_port
);
68 omapdss_of_get_next_endpoint(const struct device_node
*parent
,
69 struct device_node
*prev
)
71 struct device_node
*ep
= NULL
;
77 ep
= of_get_next_child(parent
, prev
);
81 } while (of_node_cmp(ep
->name
, "endpoint") != 0);
85 EXPORT_SYMBOL_GPL(omapdss_of_get_next_endpoint
);
87 static struct device_node
*
88 omapdss_of_get_remote_device_node(const struct device_node
*node
)
90 struct device_node
*np
;
93 np
= of_parse_phandle(node
, "remote-endpoint", 0);
98 np
= of_get_next_parent(np
);
100 for (i
= 0; i
< 3 && np
; ++i
) {
101 struct property
*prop
;
103 prop
= of_find_property(np
, "compatible", NULL
);
108 np
= of_get_next_parent(np
);
115 omapdss_of_get_first_endpoint(const struct device_node
*parent
)
117 struct device_node
*port
, *ep
;
119 port
= omapdss_of_get_next_port(parent
, NULL
);
124 ep
= omapdss_of_get_next_endpoint(port
, NULL
);
130 EXPORT_SYMBOL_GPL(omapdss_of_get_first_endpoint
);
132 struct omap_dss_device
*
133 omapdss_of_find_source_for_first_ep(struct device_node
*node
)
135 struct device_node
*ep
;
136 struct device_node
*src_node
;
137 struct omap_dss_device
*src
;
139 ep
= omapdss_of_get_first_endpoint(node
);
141 return ERR_PTR(-EINVAL
);
143 src_node
= omapdss_of_get_remote_device_node(ep
);
148 return ERR_PTR(-EINVAL
);
150 src
= omap_dss_find_output_by_node(src_node
);
152 of_node_put(src_node
);
155 return ERR_PTR(-EPROBE_DEFER
);
159 EXPORT_SYMBOL_GPL(omapdss_of_find_source_for_first_ep
);