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>
23 static bool dss_initialized;
24 static const struct dispc_ops *ops;
26 static struct list_head omapdss_comp_list;
28 struct omapdss_comp_node {
29 struct list_head list;
30 struct device_node *node;
31 bool dss_core_component;
34 void omapdss_set_is_initialized(bool set)
36 dss_initialized = set;
38 EXPORT_SYMBOL(omapdss_set_is_initialized);
40 bool omapdss_is_initialized(void)
42 return dss_initialized;
44 EXPORT_SYMBOL(omapdss_is_initialized);
46 void dispc_set_ops(const struct dispc_ops *o)
50 EXPORT_SYMBOL(dispc_set_ops);
52 const struct dispc_ops *dispc_get_ops(void)
56 EXPORT_SYMBOL(dispc_get_ops);
58 static bool omapdss_list_contains(const struct device_node *node)
60 struct omapdss_comp_node *comp;
62 list_for_each_entry(comp, &omapdss_comp_list, list) {
63 if (comp->node == node)
70 static void omapdss_walk_device(struct device *dev, struct device_node *node,
73 struct device_node *n;
74 struct omapdss_comp_node *comp = devm_kzalloc(dev, sizeof(*comp),
79 comp->dss_core_component = dss_core;
80 list_add(&comp->list, &omapdss_comp_list);
84 * of_graph_get_remote_port_parent() prints an error if there is no
85 * port/ports node. To avoid that, check first that there's the node.
87 n = of_get_child_by_name(node, "ports");
89 n = of_get_child_by_name(node, "port");
96 while ((n = of_graph_get_next_endpoint(node, n)) != NULL) {
97 struct device_node *pn = of_graph_get_remote_port_parent(n);
102 if (!of_device_is_available(pn) || omapdss_list_contains(pn)) {
107 omapdss_walk_device(dev, pn, false);
111 void omapdss_gather_components(struct device *dev)
113 struct device_node *child;
115 INIT_LIST_HEAD(&omapdss_comp_list);
117 omapdss_walk_device(dev, dev->of_node, true);
119 for_each_available_child_of_node(dev->of_node, child) {
120 if (!of_find_property(child, "compatible", NULL))
123 omapdss_walk_device(dev, child, true);
126 EXPORT_SYMBOL(omapdss_gather_components);
128 static bool omapdss_component_is_loaded(struct omapdss_comp_node *comp)
130 if (comp->dss_core_component)
132 if (omapdss_component_is_display(comp->node))
134 if (omapdss_component_is_output(comp->node))
140 bool omapdss_stack_is_ready(void)
142 struct omapdss_comp_node *comp;
144 list_for_each_entry(comp, &omapdss_comp_list, list) {
145 if (!omapdss_component_is_loaded(comp))
151 EXPORT_SYMBOL(omapdss_stack_is_ready);
154 MODULE_DESCRIPTION("OMAP Display Subsystem Base");
155 MODULE_LICENSE("GPL v2");