1 #include <linux/kernel.h>
2 #include <linux/module.h>
4 #include <linux/of_graph.h>
5 #include <linux/list.h>
8 static bool dss_initialized;
9 static const struct dispc_ops *ops;
11 static struct list_head omapdss_comp_list;
13 struct omapdss_comp_node {
14 struct list_head list;
15 struct device_node *node;
16 bool dss_core_component;
19 void omapdss_set_is_initialized(bool set)
21 dss_initialized = set;
23 EXPORT_SYMBOL(omapdss_set_is_initialized);
25 bool omapdss_is_initialized(void)
27 return dss_initialized;
29 EXPORT_SYMBOL(omapdss_is_initialized);
31 void dispc_set_ops(const struct dispc_ops *o)
35 EXPORT_SYMBOL(dispc_set_ops);
37 const struct dispc_ops *dispc_get_ops(void)
41 EXPORT_SYMBOL(dispc_get_ops);
43 static bool omapdss_list_contains(const struct device_node *node)
45 struct omapdss_comp_node *comp;
47 list_for_each_entry(comp, &omapdss_comp_list, list) {
48 if (comp->node == node)
55 static void omapdss_walk_device(struct device *dev, struct device_node *node,
58 struct device_node *n;
59 struct omapdss_comp_node *comp = devm_kzalloc(dev, sizeof(*comp),
64 comp->dss_core_component = dss_core;
65 list_add(&comp->list, &omapdss_comp_list);
69 * of_graph_get_remote_port_parent() prints an error if there is no
70 * port/ports node. To avoid that, check first that there's the node.
72 n = of_get_child_by_name(node, "ports");
74 n = of_get_child_by_name(node, "port");
81 while ((n = of_graph_get_next_endpoint(node, n)) != NULL) {
82 struct device_node *pn = of_graph_get_remote_port_parent(n);
87 if (!of_device_is_available(pn) || omapdss_list_contains(pn)) {
92 omapdss_walk_device(dev, pn, false);
96 void omapdss_gather_components(struct device *dev)
98 struct device_node *child;
100 INIT_LIST_HEAD(&omapdss_comp_list);
102 omapdss_walk_device(dev, dev->of_node, true);
104 for_each_available_child_of_node(dev->of_node, child) {
105 if (!of_find_property(child, "compatible", NULL))
108 omapdss_walk_device(dev, child, true);
111 EXPORT_SYMBOL(omapdss_gather_components);
113 static bool omapdss_component_is_loaded(struct omapdss_comp_node *comp)
115 if (comp->dss_core_component)
117 if (omapdss_component_is_display(comp->node))
119 if (omapdss_component_is_output(comp->node))
125 bool omapdss_stack_is_ready(void)
127 struct omapdss_comp_node *comp;
129 list_for_each_entry(comp, &omapdss_comp_list, list) {
130 if (!omapdss_component_is_loaded(comp))
136 EXPORT_SYMBOL(omapdss_stack_is_ready);
138 MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@ti.com>");
139 MODULE_DESCRIPTION("OMAP Display Subsystem Base");
140 MODULE_LICENSE("GPL v2");