display.c 4.6 KB

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