panel-sharp-lq043t1dg01.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /*
  2. * LCD panel driver for Sharp LQ043T1DG01
  3. *
  4. * Copyright (C) 2009 Texas Instruments Inc
  5. * Author: Vaibhav Hiremath <hvaibhav@ti.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. #include <linux/module.h>
  20. #include <linux/delay.h>
  21. #include <linux/device.h>
  22. #include <linux/err.h>
  23. #include <plat/display.h>
  24. static struct omap_video_timings sharp_lq_timings = {
  25. .x_res = 480,
  26. .y_res = 272,
  27. .pixel_clock = 9000,
  28. .hsw = 42,
  29. .hfp = 3,
  30. .hbp = 2,
  31. .vsw = 11,
  32. .vfp = 3,
  33. .vbp = 2,
  34. };
  35. static int sharp_lq_panel_power_on(struct omap_dss_device *dssdev)
  36. {
  37. int r;
  38. if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE)
  39. return 0;
  40. r = omapdss_dpi_display_enable(dssdev);
  41. if (r)
  42. goto err0;
  43. /* wait couple of vsyncs until enabling the LCD */
  44. msleep(50);
  45. if (dssdev->platform_enable) {
  46. r = dssdev->platform_enable(dssdev);
  47. if (r)
  48. goto err1;
  49. }
  50. return 0;
  51. err1:
  52. omapdss_dpi_display_disable(dssdev);
  53. err0:
  54. return r;
  55. }
  56. static void sharp_lq_panel_power_off(struct omap_dss_device *dssdev)
  57. {
  58. if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE)
  59. return;
  60. if (dssdev->platform_disable)
  61. dssdev->platform_disable(dssdev);
  62. /* wait at least 5 vsyncs after disabling the LCD */
  63. msleep(100);
  64. omapdss_dpi_display_disable(dssdev);
  65. }
  66. static int sharp_lq_panel_probe(struct omap_dss_device *dssdev)
  67. {
  68. dssdev->panel.config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS |
  69. OMAP_DSS_LCD_IHS | OMAP_DSS_LCD_IEO;
  70. dssdev->panel.acb = 0x0;
  71. dssdev->panel.timings = sharp_lq_timings;
  72. return 0;
  73. }
  74. static void sharp_lq_panel_remove(struct omap_dss_device *dssdev)
  75. {
  76. }
  77. static int sharp_lq_panel_enable(struct omap_dss_device *dssdev)
  78. {
  79. int r = 0;
  80. r = sharp_lq_panel_power_on(dssdev);
  81. if (r)
  82. return r;
  83. dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
  84. return 0;
  85. }
  86. static void sharp_lq_panel_disable(struct omap_dss_device *dssdev)
  87. {
  88. sharp_lq_panel_power_off(dssdev);
  89. dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
  90. }
  91. static int sharp_lq_panel_suspend(struct omap_dss_device *dssdev)
  92. {
  93. sharp_lq_panel_power_off(dssdev);
  94. dssdev->state = OMAP_DSS_DISPLAY_SUSPENDED;
  95. return 0;
  96. }
  97. static int sharp_lq_panel_resume(struct omap_dss_device *dssdev)
  98. {
  99. int r = 0;
  100. r = sharp_lq_panel_power_on(dssdev);
  101. if (r)
  102. return r;
  103. dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
  104. return 0;
  105. }
  106. static struct omap_dss_driver sharp_lq_driver = {
  107. .probe = sharp_lq_panel_probe,
  108. .remove = sharp_lq_panel_remove,
  109. .enable = sharp_lq_panel_enable,
  110. .disable = sharp_lq_panel_disable,
  111. .suspend = sharp_lq_panel_suspend,
  112. .resume = sharp_lq_panel_resume,
  113. .driver = {
  114. .name = "sharp_lq_panel",
  115. .owner = THIS_MODULE,
  116. },
  117. };
  118. static int __init sharp_lq_panel_drv_init(void)
  119. {
  120. return omap_dss_register_driver(&sharp_lq_driver);
  121. }
  122. static void __exit sharp_lq_panel_drv_exit(void)
  123. {
  124. omap_dss_unregister_driver(&sharp_lq_driver);
  125. }
  126. module_init(sharp_lq_panel_drv_init);
  127. module_exit(sharp_lq_panel_drv_exit);
  128. MODULE_LICENSE("GPL");