base.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. #include <linux/kernel.h>
  2. #include <linux/module.h>
  3. #include <linux/of.h>
  4. #include <linux/of_graph.h>
  5. #include <linux/list.h>
  6. #include "omapdss.h"
  7. static bool dss_initialized;
  8. static const struct dispc_ops *ops;
  9. static struct list_head omapdss_comp_list;
  10. struct omapdss_comp_node {
  11. struct list_head list;
  12. struct device_node *node;
  13. bool dss_core_component;
  14. };
  15. void omapdss_set_is_initialized(bool set)
  16. {
  17. dss_initialized = set;
  18. }
  19. EXPORT_SYMBOL(omapdss_set_is_initialized);
  20. bool omapdss_is_initialized(void)
  21. {
  22. return dss_initialized;
  23. }
  24. EXPORT_SYMBOL(omapdss_is_initialized);
  25. void dispc_set_ops(const struct dispc_ops *o)
  26. {
  27. ops = o;
  28. }
  29. EXPORT_SYMBOL(dispc_set_ops);
  30. const struct dispc_ops *dispc_get_ops(void)
  31. {
  32. return ops;
  33. }
  34. EXPORT_SYMBOL(dispc_get_ops);
  35. static bool omapdss_list_contains(const struct device_node *node)
  36. {
  37. struct omapdss_comp_node *comp;
  38. list_for_each_entry(comp, &omapdss_comp_list, list) {
  39. if (comp->node == node)
  40. return true;
  41. }
  42. return false;
  43. }
  44. static void omapdss_walk_device(struct device *dev, struct device_node *node,
  45. bool dss_core)
  46. {
  47. struct device_node *n;
  48. struct omapdss_comp_node *comp = devm_kzalloc(dev, sizeof(*comp),
  49. GFP_KERNEL);
  50. if (comp) {
  51. comp->node = node;
  52. comp->dss_core_component = dss_core;
  53. list_add(&comp->list, &omapdss_comp_list);
  54. }
  55. /*
  56. * of_graph_get_remote_port_parent() prints an error if there is no
  57. * port/ports node. To avoid that, check first that there's the node.
  58. */
  59. n = of_get_child_by_name(node, "ports");
  60. if (!n)
  61. n = of_get_child_by_name(node, "port");
  62. if (!n)
  63. return;
  64. of_node_put(n);
  65. n = NULL;
  66. while ((n = of_graph_get_next_endpoint(node, n)) != NULL) {
  67. struct device_node *pn = of_graph_get_remote_port_parent(n);
  68. if (!pn)
  69. continue;
  70. if (!of_device_is_available(pn) || omapdss_list_contains(pn)) {
  71. of_node_put(pn);
  72. continue;
  73. }
  74. omapdss_walk_device(dev, pn, false);
  75. }
  76. }
  77. void omapdss_gather_components(struct device *dev)
  78. {
  79. struct device_node *child;
  80. INIT_LIST_HEAD(&omapdss_comp_list);
  81. omapdss_walk_device(dev, dev->of_node, true);
  82. for_each_available_child_of_node(dev->of_node, child) {
  83. if (!of_find_property(child, "compatible", NULL))
  84. continue;
  85. omapdss_walk_device(dev, child, true);
  86. }
  87. }
  88. EXPORT_SYMBOL(omapdss_gather_components);
  89. static bool omapdss_component_is_loaded(struct omapdss_comp_node *comp)
  90. {
  91. if (comp->dss_core_component)
  92. return true;
  93. if (omapdss_component_is_display(comp->node))
  94. return true;
  95. if (omapdss_component_is_output(comp->node))
  96. return true;
  97. return false;
  98. }
  99. bool omapdss_stack_is_ready(void)
  100. {
  101. struct omapdss_comp_node *comp;
  102. list_for_each_entry(comp, &omapdss_comp_list, list) {
  103. if (!omapdss_component_is_loaded(comp))
  104. return false;
  105. }
  106. return true;
  107. }
  108. EXPORT_SYMBOL(omapdss_stack_is_ready);
  109. MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@ti.com>");
  110. MODULE_DESCRIPTION("OMAP Display Subsystem Base");
  111. MODULE_LICENSE("GPL v2");