2 * OMAP Display Subsystem Base
4 * Copyright (C) 2015-2017 Texas Instruments Incorporated - http://www.ti.com/
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
16 #include <linux/kernel.h>
17 #include <linux/module.h>
19 #include <linux/of_graph.h>
20 #include <linux/list.h>
25 static struct dss_device *dss_device;
27 static struct list_head omapdss_comp_list;
29 struct omapdss_comp_node {
30 struct list_head list;
31 struct device_node *node;
32 bool dss_core_component;
35 struct dss_device *omapdss_get_dss(void)
39 EXPORT_SYMBOL(omapdss_get_dss);
41 void omapdss_set_dss(struct dss_device *dss)
45 EXPORT_SYMBOL(omapdss_set_dss);
47 struct dispc_device *dispc_get_dispc(struct dss_device *dss)
51 EXPORT_SYMBOL(dispc_get_dispc);
53 const struct dispc_ops *dispc_get_ops(struct dss_device *dss)
55 return dss->dispc_ops;
57 EXPORT_SYMBOL(dispc_get_ops);
59 static bool omapdss_list_contains(const struct device_node *node)
61 struct omapdss_comp_node *comp;
63 list_for_each_entry(comp, &omapdss_comp_list, list) {
64 if (comp->node == node)
71 static void omapdss_walk_device(struct device *dev, struct device_node *node,
74 struct device_node *n;
75 struct omapdss_comp_node *comp = devm_kzalloc(dev, sizeof(*comp),
80 comp->dss_core_component = dss_core;
81 list_add(&comp->list, &omapdss_comp_list);
85 * of_graph_get_remote_port_parent() prints an error if there is no
86 * port/ports node. To avoid that, check first that there's the node.
88 n = of_get_child_by_name(node, "ports");
90 n = of_get_child_by_name(node, "port");
97 while ((n = of_graph_get_next_endpoint(node, n)) != NULL) {
98 struct device_node *pn = of_graph_get_remote_port_parent(n);
103 if (!of_device_is_available(pn) || omapdss_list_contains(pn)) {
108 omapdss_walk_device(dev, pn, false);
112 void omapdss_gather_components(struct device *dev)
114 struct device_node *child;
116 INIT_LIST_HEAD(&omapdss_comp_list);
118 omapdss_walk_device(dev, dev->of_node, true);
120 for_each_available_child_of_node(dev->of_node, child) {
121 if (!of_find_property(child, "compatible", NULL))
124 omapdss_walk_device(dev, child, true);
127 EXPORT_SYMBOL(omapdss_gather_components);
129 static bool omapdss_component_is_loaded(struct omapdss_comp_node *comp)
131 if (comp->dss_core_component)
133 if (omapdss_component_is_display(comp->node))
135 if (omapdss_component_is_output(comp->node))
141 bool omapdss_stack_is_ready(void)
143 struct omapdss_comp_node *comp;
145 list_for_each_entry(comp, &omapdss_comp_list, list) {
146 if (!omapdss_component_is_loaded(comp))
152 EXPORT_SYMBOL(omapdss_stack_is_ready);
154 MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@ti.com>");
155 MODULE_DESCRIPTION("OMAP Display Subsystem Base");
156 MODULE_LICENSE("GPL v2");