display.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. #include <plat/omap-pm.h>
  27. static struct platform_device omap_display_device = {
  28. .name = "omapdss",
  29. .id = -1,
  30. .dev = {
  31. .platform_data = NULL,
  32. },
  33. };
  34. static struct omap_device_pm_latency omap_dss_latency[] = {
  35. [0] = {
  36. .deactivate_func = omap_device_idle_hwmods,
  37. .activate_func = omap_device_enable_hwmods,
  38. .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
  39. },
  40. };
  41. struct omap_dss_hwmod_data {
  42. const char *oh_name;
  43. const char *dev_name;
  44. const int id;
  45. };
  46. static const struct omap_dss_hwmod_data omap2_dss_hwmod_data[] __initdata = {
  47. { "dss_core", "omapdss_dss", -1 },
  48. { "dss_dispc", "omapdss_dispc", -1 },
  49. { "dss_rfbi", "omapdss_rfbi", -1 },
  50. { "dss_venc", "omapdss_venc", -1 },
  51. };
  52. static const struct omap_dss_hwmod_data omap3_dss_hwmod_data[] __initdata = {
  53. { "dss_core", "omapdss_dss", -1 },
  54. { "dss_dispc", "omapdss_dispc", -1 },
  55. { "dss_rfbi", "omapdss_rfbi", -1 },
  56. { "dss_venc", "omapdss_venc", -1 },
  57. { "dss_dsi1", "omapdss_dsi1", -1 },
  58. };
  59. static const struct omap_dss_hwmod_data omap4_dss_hwmod_data[] __initdata = {
  60. { "dss_core", "omapdss_dss", -1 },
  61. { "dss_dispc", "omapdss_dispc", -1 },
  62. { "dss_rfbi", "omapdss_rfbi", -1 },
  63. { "dss_venc", "omapdss_venc", -1 },
  64. { "dss_dsi1", "omapdss_dsi1", -1 },
  65. { "dss_dsi2", "omapdss_dsi2", -1 },
  66. { "dss_hdmi", "omapdss_hdmi", -1 },
  67. };
  68. int __init omap_display_init(struct omap_dss_board_info *board_data)
  69. {
  70. int r = 0;
  71. struct omap_hwmod *oh;
  72. struct omap_device *od;
  73. int i, oh_count;
  74. struct omap_display_platform_data pdata;
  75. const struct omap_dss_hwmod_data *curr_dss_hwmod;
  76. memset(&pdata, 0, sizeof(pdata));
  77. if (cpu_is_omap24xx()) {
  78. curr_dss_hwmod = omap2_dss_hwmod_data;
  79. oh_count = ARRAY_SIZE(omap2_dss_hwmod_data);
  80. } else if (cpu_is_omap34xx()) {
  81. curr_dss_hwmod = omap3_dss_hwmod_data;
  82. oh_count = ARRAY_SIZE(omap3_dss_hwmod_data);
  83. } else {
  84. curr_dss_hwmod = omap4_dss_hwmod_data;
  85. oh_count = ARRAY_SIZE(omap4_dss_hwmod_data);
  86. }
  87. pdata.board_data = board_data;
  88. pdata.board_data->get_context_loss_count =
  89. omap_pm_get_dev_context_loss_count;
  90. for (i = 0; i < oh_count; i++) {
  91. oh = omap_hwmod_lookup(curr_dss_hwmod[i].oh_name);
  92. if (!oh) {
  93. pr_err("Could not look up %s\n",
  94. curr_dss_hwmod[i].oh_name);
  95. return -ENODEV;
  96. }
  97. od = omap_device_build(curr_dss_hwmod[i].dev_name,
  98. curr_dss_hwmod[i].id, oh, &pdata,
  99. sizeof(struct omap_display_platform_data),
  100. omap_dss_latency,
  101. ARRAY_SIZE(omap_dss_latency), 0);
  102. if (WARN((IS_ERR(od)), "Could not build omap_device for %s\n",
  103. curr_dss_hwmod[i].oh_name))
  104. return -ENODEV;
  105. }
  106. omap_display_device.dev.platform_data = board_data;
  107. r = platform_device_register(&omap_display_device);
  108. if (r < 0)
  109. printk(KERN_ERR "Unable to register OMAP-Display device\n");
  110. return r;
  111. }