sdi.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /*
  2. * linux/drivers/video/omap2/dss/sdi.c
  3. *
  4. * Copyright (C) 2009 Nokia Corporation
  5. * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License version 2 as published by
  9. * the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful, but WITHOUT
  12. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  14. * more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along with
  17. * this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #define DSS_SUBSYS_NAME "SDI"
  20. #include <linux/kernel.h>
  21. #include <linux/delay.h>
  22. #include <linux/err.h>
  23. #include <linux/regulator/consumer.h>
  24. #include <linux/export.h>
  25. #include <video/omapdss.h>
  26. #include "dss.h"
  27. static struct {
  28. bool update_enabled;
  29. struct regulator *vdds_sdi_reg;
  30. } sdi;
  31. static void sdi_basic_init(struct omap_dss_device *dssdev)
  32. {
  33. dispc_mgr_set_io_pad_mode(DSS_IO_PAD_MODE_BYPASS);
  34. dispc_mgr_enable_stallmode(dssdev->manager->id, false);
  35. dispc_mgr_set_lcd_display_type(dssdev->manager->id,
  36. OMAP_DSS_LCD_DISPLAY_TFT);
  37. dispc_mgr_set_tft_data_lines(dssdev->manager->id, 24);
  38. dispc_lcd_enable_signal_polarity(1);
  39. }
  40. int omapdss_sdi_display_enable(struct omap_dss_device *dssdev)
  41. {
  42. struct omap_video_timings *t = &dssdev->panel.timings;
  43. struct dss_clock_info dss_cinfo;
  44. struct dispc_clock_info dispc_cinfo;
  45. u16 lck_div, pck_div;
  46. unsigned long fck;
  47. unsigned long pck;
  48. int r;
  49. if (dssdev->manager == NULL) {
  50. DSSERR("failed to enable display: no manager\n");
  51. return -ENODEV;
  52. }
  53. r = omap_dss_start_device(dssdev);
  54. if (r) {
  55. DSSERR("failed to start device\n");
  56. goto err_start_dev;
  57. }
  58. r = regulator_enable(sdi.vdds_sdi_reg);
  59. if (r)
  60. goto err_reg_enable;
  61. r = dss_runtime_get();
  62. if (r)
  63. goto err_get_dss;
  64. r = dispc_runtime_get();
  65. if (r)
  66. goto err_get_dispc;
  67. sdi_basic_init(dssdev);
  68. /* 15.5.9.1.2 */
  69. dssdev->panel.config |= OMAP_DSS_LCD_RF | OMAP_DSS_LCD_ONOFF;
  70. dispc_mgr_set_pol_freq(dssdev->manager->id, dssdev->panel.config,
  71. dssdev->panel.acbi, dssdev->panel.acb);
  72. r = dss_calc_clock_div(1, t->pixel_clock * 1000,
  73. &dss_cinfo, &dispc_cinfo);
  74. if (r)
  75. goto err_calc_clock_div;
  76. fck = dss_cinfo.fck;
  77. lck_div = dispc_cinfo.lck_div;
  78. pck_div = dispc_cinfo.pck_div;
  79. pck = fck / lck_div / pck_div / 1000;
  80. if (pck != t->pixel_clock) {
  81. DSSWARN("Could not find exact pixel clock. Requested %d kHz, "
  82. "got %lu kHz\n",
  83. t->pixel_clock, pck);
  84. t->pixel_clock = pck;
  85. }
  86. dispc_mgr_set_lcd_timings(dssdev->manager->id, t);
  87. r = dss_set_clock_div(&dss_cinfo);
  88. if (r)
  89. goto err_set_dss_clock_div;
  90. r = dispc_mgr_set_clock_div(dssdev->manager->id, &dispc_cinfo);
  91. if (r)
  92. goto err_set_dispc_clock_div;
  93. dss_sdi_init(dssdev->phy.sdi.datapairs);
  94. r = dss_sdi_enable();
  95. if (r)
  96. goto err_sdi_enable;
  97. mdelay(2);
  98. r = dss_mgr_enable(dssdev->manager);
  99. if (r)
  100. goto err_mgr_enable;
  101. return 0;
  102. err_mgr_enable:
  103. dss_sdi_disable();
  104. err_sdi_enable:
  105. err_set_dispc_clock_div:
  106. err_set_dss_clock_div:
  107. err_calc_clock_div:
  108. dispc_runtime_put();
  109. err_get_dispc:
  110. dss_runtime_put();
  111. err_get_dss:
  112. regulator_disable(sdi.vdds_sdi_reg);
  113. err_reg_enable:
  114. omap_dss_stop_device(dssdev);
  115. err_start_dev:
  116. return r;
  117. }
  118. EXPORT_SYMBOL(omapdss_sdi_display_enable);
  119. void omapdss_sdi_display_disable(struct omap_dss_device *dssdev)
  120. {
  121. dss_mgr_disable(dssdev->manager);
  122. dss_sdi_disable();
  123. dispc_runtime_put();
  124. dss_runtime_put();
  125. regulator_disable(sdi.vdds_sdi_reg);
  126. omap_dss_stop_device(dssdev);
  127. }
  128. EXPORT_SYMBOL(omapdss_sdi_display_disable);
  129. int sdi_init_display(struct omap_dss_device *dssdev)
  130. {
  131. DSSDBG("SDI init\n");
  132. if (sdi.vdds_sdi_reg == NULL) {
  133. struct regulator *vdds_sdi;
  134. vdds_sdi = dss_get_vdds_sdi();
  135. if (IS_ERR(vdds_sdi)) {
  136. DSSERR("can't get VDDS_SDI regulator\n");
  137. return PTR_ERR(vdds_sdi);
  138. }
  139. sdi.vdds_sdi_reg = vdds_sdi;
  140. }
  141. return 0;
  142. }
  143. int sdi_init(void)
  144. {
  145. return 0;
  146. }
  147. void sdi_exit(void)
  148. {
  149. }