display.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*
  2. * OMAP2plus display device setup / initialization.
  3. *
  4. * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
  5. * Senthilvadivu Guruswamy
  6. * Sumit Semwal
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. *
  12. * This program is distributed "as is" WITHOUT ANY WARRANTY of any
  13. * kind, whether express or implied; without even the implied warranty
  14. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. */
  17. #include <linux/kernel.h>
  18. #include <linux/init.h>
  19. #include <linux/platform_device.h>
  20. #include <linux/io.h>
  21. #include <linux/clk.h>
  22. #include <linux/err.h>
  23. #include <video/omapdss.h>
  24. #include <plat/omap_hwmod.h>
  25. #include <plat/omap_device.h>
  26. static struct platform_device omap_display_device = {
  27. .name = "omapdss",
  28. .id = -1,
  29. .dev = {
  30. .platform_data = NULL,
  31. },
  32. };
  33. static struct omap_device_pm_latency omap_dss_latency[] = {
  34. [0] = {
  35. .deactivate_func = omap_device_idle_hwmods,
  36. .activate_func = omap_device_enable_hwmods,
  37. .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
  38. },
  39. };
  40. /* oh_core is used for getting opt-clocks */
  41. static struct omap_hwmod *oh_core;
  42. static bool opt_clock_available(const char *clk_role)
  43. {
  44. int i;
  45. for (i = 0; i < oh_core->opt_clks_cnt; i++) {
  46. if (!strcmp(oh_core->opt_clks[i].role, clk_role))
  47. return true;
  48. }
  49. return false;
  50. }
  51. struct omap_dss_hwmod_data {
  52. const char *oh_name;
  53. const char *dev_name;
  54. const int id;
  55. };
  56. static const struct omap_dss_hwmod_data omap2_dss_hwmod_data[] __initdata = {
  57. { "dss_core", "omapdss_dss", -1 },
  58. { "dss_dispc", "omapdss_dispc", -1 },
  59. { "dss_rfbi", "omapdss_rfbi", -1 },
  60. { "dss_venc", "omapdss_venc", -1 },
  61. };
  62. static const struct omap_dss_hwmod_data omap3_dss_hwmod_data[] __initdata = {
  63. { "dss_core", "omapdss_dss", -1 },
  64. { "dss_dispc", "omapdss_dispc", -1 },
  65. { "dss_rfbi", "omapdss_rfbi", -1 },
  66. { "dss_venc", "omapdss_venc", -1 },
  67. { "dss_dsi1", "omapdss_dsi1", -1 },
  68. };
  69. static const struct omap_dss_hwmod_data omap4_dss_hwmod_data[] __initdata = {
  70. { "dss_core", "omapdss_dss", -1 },
  71. { "dss_dispc", "omapdss_dispc", -1 },
  72. { "dss_rfbi", "omapdss_rfbi", -1 },
  73. { "dss_venc", "omapdss_venc", -1 },
  74. { "dss_dsi1", "omapdss_dsi1", -1 },
  75. { "dss_dsi2", "omapdss_dsi2", -1 },
  76. { "dss_hdmi", "omapdss_hdmi", -1 },
  77. };
  78. int __init omap_display_init(struct omap_dss_board_info *board_data)
  79. {
  80. int r = 0;
  81. struct omap_hwmod *oh;
  82. struct omap_device *od;
  83. int i, oh_count;
  84. struct omap_display_platform_data pdata;
  85. const struct omap_dss_hwmod_data *curr_dss_hwmod;
  86. memset(&pdata, 0, sizeof(pdata));
  87. if (cpu_is_omap24xx()) {
  88. curr_dss_hwmod = omap2_dss_hwmod_data;
  89. oh_count = ARRAY_SIZE(omap2_dss_hwmod_data);
  90. } else if (cpu_is_omap34xx()) {
  91. curr_dss_hwmod = omap3_dss_hwmod_data;
  92. oh_count = ARRAY_SIZE(omap3_dss_hwmod_data);
  93. } else {
  94. curr_dss_hwmod = omap4_dss_hwmod_data;
  95. oh_count = ARRAY_SIZE(omap4_dss_hwmod_data);
  96. }
  97. /* opt_clks are always associated with dss hwmod */
  98. oh_core = omap_hwmod_lookup("dss_core");
  99. if (!oh_core) {
  100. pr_err("Could not look up dss_core.\n");
  101. return -ENODEV;
  102. }
  103. pdata.board_data = board_data;
  104. pdata.board_data->get_last_off_on_transaction_id = NULL;
  105. pdata.opt_clock_available = opt_clock_available;
  106. for (i = 0; i < oh_count; i++) {
  107. oh = omap_hwmod_lookup(curr_dss_hwmod[i].oh_name);
  108. if (!oh) {
  109. pr_err("Could not look up %s\n",
  110. curr_dss_hwmod[i].oh_name);
  111. return -ENODEV;
  112. }
  113. od = omap_device_build(curr_dss_hwmod[i].dev_name,
  114. curr_dss_hwmod[i].id, oh, &pdata,
  115. sizeof(struct omap_display_platform_data),
  116. omap_dss_latency,
  117. ARRAY_SIZE(omap_dss_latency), 0);
  118. if (WARN((IS_ERR(od)), "Could not build omap_device for %s\n",
  119. curr_dss_hwmod[i].oh_name))
  120. return -ENODEV;
  121. }
  122. omap_display_device.dev.platform_data = board_data;
  123. r = platform_device_register(&omap_display_device);
  124. if (r < 0)
  125. printk(KERN_ERR "Unable to register OMAP-Display device\n");
  126. return r;
  127. }