display.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. #include "control.h"
  28. static struct platform_device omap_display_device = {
  29. .name = "omapdss",
  30. .id = -1,
  31. .dev = {
  32. .platform_data = NULL,
  33. },
  34. };
  35. static struct omap_device_pm_latency omap_dss_latency[] = {
  36. [0] = {
  37. .deactivate_func = omap_device_idle_hwmods,
  38. .activate_func = omap_device_enable_hwmods,
  39. .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
  40. },
  41. };
  42. struct omap_dss_hwmod_data {
  43. const char *oh_name;
  44. const char *dev_name;
  45. const int id;
  46. };
  47. static const struct omap_dss_hwmod_data omap2_dss_hwmod_data[] __initdata = {
  48. { "dss_core", "omapdss_dss", -1 },
  49. { "dss_dispc", "omapdss_dispc", -1 },
  50. { "dss_rfbi", "omapdss_rfbi", -1 },
  51. { "dss_venc", "omapdss_venc", -1 },
  52. };
  53. static const struct omap_dss_hwmod_data omap3_dss_hwmod_data[] __initdata = {
  54. { "dss_core", "omapdss_dss", -1 },
  55. { "dss_dispc", "omapdss_dispc", -1 },
  56. { "dss_rfbi", "omapdss_rfbi", -1 },
  57. { "dss_venc", "omapdss_venc", -1 },
  58. { "dss_dsi1", "omapdss_dsi", 0 },
  59. };
  60. static const struct omap_dss_hwmod_data omap4_dss_hwmod_data[] __initdata = {
  61. { "dss_core", "omapdss_dss", -1 },
  62. { "dss_dispc", "omapdss_dispc", -1 },
  63. { "dss_rfbi", "omapdss_rfbi", -1 },
  64. { "dss_venc", "omapdss_venc", -1 },
  65. { "dss_dsi1", "omapdss_dsi", 0 },
  66. { "dss_dsi2", "omapdss_dsi", 1 },
  67. { "dss_hdmi", "omapdss_hdmi", -1 },
  68. };
  69. static int omap4_dsi_mux_pads(int dsi_id, unsigned lanes)
  70. {
  71. u32 enable_mask, enable_shift;
  72. u32 pipd_mask, pipd_shift;
  73. u32 reg;
  74. if (dsi_id == 0) {
  75. enable_mask = OMAP4_DSI1_LANEENABLE_MASK;
  76. enable_shift = OMAP4_DSI1_LANEENABLE_SHIFT;
  77. pipd_mask = OMAP4_DSI1_PIPD_MASK;
  78. pipd_shift = OMAP4_DSI1_PIPD_SHIFT;
  79. } else if (dsi_id == 1) {
  80. enable_mask = OMAP4_DSI2_LANEENABLE_MASK;
  81. enable_shift = OMAP4_DSI2_LANEENABLE_SHIFT;
  82. pipd_mask = OMAP4_DSI2_PIPD_MASK;
  83. pipd_shift = OMAP4_DSI2_PIPD_SHIFT;
  84. } else {
  85. return -ENODEV;
  86. }
  87. reg = omap4_ctrl_pad_readl(OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_DSIPHY);
  88. reg &= ~enable_mask;
  89. reg &= ~pipd_mask;
  90. reg |= (lanes << enable_shift) & enable_mask;
  91. reg |= (lanes << pipd_shift) & pipd_mask;
  92. omap4_ctrl_pad_writel(reg, OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_DSIPHY);
  93. return 0;
  94. }
  95. static int omap_dsi_enable_pads(int dsi_id, unsigned lane_mask)
  96. {
  97. if (cpu_is_omap44xx())
  98. return omap4_dsi_mux_pads(dsi_id, lane_mask);
  99. return 0;
  100. }
  101. static void omap_dsi_disable_pads(int dsi_id, unsigned lane_mask)
  102. {
  103. if (cpu_is_omap44xx())
  104. omap4_dsi_mux_pads(dsi_id, 0);
  105. }
  106. int __init omap_display_init(struct omap_dss_board_info *board_data)
  107. {
  108. int r = 0;
  109. struct omap_hwmod *oh;
  110. struct omap_device *od;
  111. int i, oh_count;
  112. struct omap_display_platform_data pdata;
  113. const struct omap_dss_hwmod_data *curr_dss_hwmod;
  114. memset(&pdata, 0, sizeof(pdata));
  115. if (cpu_is_omap24xx()) {
  116. curr_dss_hwmod = omap2_dss_hwmod_data;
  117. oh_count = ARRAY_SIZE(omap2_dss_hwmod_data);
  118. } else if (cpu_is_omap34xx()) {
  119. curr_dss_hwmod = omap3_dss_hwmod_data;
  120. oh_count = ARRAY_SIZE(omap3_dss_hwmod_data);
  121. } else {
  122. curr_dss_hwmod = omap4_dss_hwmod_data;
  123. oh_count = ARRAY_SIZE(omap4_dss_hwmod_data);
  124. }
  125. if (board_data->dsi_enable_pads == NULL)
  126. board_data->dsi_enable_pads = omap_dsi_enable_pads;
  127. if (board_data->dsi_disable_pads == NULL)
  128. board_data->dsi_disable_pads = omap_dsi_disable_pads;
  129. pdata.board_data = board_data;
  130. pdata.board_data->get_context_loss_count =
  131. omap_pm_get_dev_context_loss_count;
  132. for (i = 0; i < oh_count; i++) {
  133. oh = omap_hwmod_lookup(curr_dss_hwmod[i].oh_name);
  134. if (!oh) {
  135. pr_err("Could not look up %s\n",
  136. curr_dss_hwmod[i].oh_name);
  137. return -ENODEV;
  138. }
  139. od = omap_device_build(curr_dss_hwmod[i].dev_name,
  140. curr_dss_hwmod[i].id, oh, &pdata,
  141. sizeof(struct omap_display_platform_data),
  142. omap_dss_latency,
  143. ARRAY_SIZE(omap_dss_latency), 0);
  144. if (WARN((IS_ERR(od)), "Could not build omap_device for %s\n",
  145. curr_dss_hwmod[i].oh_name))
  146. return -ENODEV;
  147. }
  148. omap_display_device.dev.platform_data = board_data;
  149. r = platform_device_register(&omap_display_device);
  150. if (r < 0)
  151. printk(KERN_ERR "Unable to register OMAP-Display device\n");
  152. return r;
  153. }