panel-toppoly-tdo35s.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /*
  2. * LCD panel driver for Toppoly TDO35S
  3. *
  4. * Copyright (C) 2009 CompuLab, Ltd.
  5. * Author: Mike Rapoport <mike@compulab.co.il>
  6. *
  7. * Based on generic panel support
  8. * Copyright (C) 2008 Nokia Corporation
  9. * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
  10. *
  11. * This program is free software; you can redistribute it and/or modify it
  12. * under the terms of the GNU General Public License version 2 as published by
  13. * the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful, but WITHOUT
  16. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  17. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  18. * more details.
  19. *
  20. * You should have received a copy of the GNU General Public License along with
  21. * this program. If not, see <http://www.gnu.org/licenses/>.
  22. */
  23. #include <linux/module.h>
  24. #include <linux/delay.h>
  25. #include <plat/display.h>
  26. static struct omap_video_timings toppoly_tdo_panel_timings = {
  27. /* 640 x 480 @ 60 Hz Reduced blanking VESA CVT 0.31M3-R */
  28. .x_res = 480,
  29. .y_res = 640,
  30. .pixel_clock = 26000,
  31. .hfp = 104,
  32. .hsw = 8,
  33. .hbp = 8,
  34. .vfp = 4,
  35. .vsw = 2,
  36. .vbp = 2,
  37. };
  38. static int toppoly_tdo_panel_power_on(struct omap_dss_device *dssdev)
  39. {
  40. int r;
  41. if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE)
  42. return 0;
  43. r = omapdss_dpi_display_enable(dssdev);
  44. if (r)
  45. goto err0;
  46. if (dssdev->platform_enable) {
  47. r = dssdev->platform_enable(dssdev);
  48. if (r)
  49. goto err1;
  50. }
  51. return 0;
  52. err1:
  53. omapdss_dpi_display_disable(dssdev);
  54. err0:
  55. return r;
  56. }
  57. static void toppoly_tdo_panel_power_off(struct omap_dss_device *dssdev)
  58. {
  59. if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE)
  60. return;
  61. if (dssdev->platform_disable)
  62. dssdev->platform_disable(dssdev);
  63. omapdss_dpi_display_disable(dssdev);
  64. }
  65. static int toppoly_tdo_panel_probe(struct omap_dss_device *dssdev)
  66. {
  67. dssdev->panel.config = OMAP_DSS_LCD_TFT |
  68. OMAP_DSS_LCD_IVS |
  69. OMAP_DSS_LCD_IHS |
  70. OMAP_DSS_LCD_IPC |
  71. OMAP_DSS_LCD_ONOFF;
  72. dssdev->panel.timings = toppoly_tdo_panel_timings;
  73. return 0;
  74. }
  75. static void toppoly_tdo_panel_remove(struct omap_dss_device *dssdev)
  76. {
  77. }
  78. static int toppoly_tdo_panel_enable(struct omap_dss_device *dssdev)
  79. {
  80. int r = 0;
  81. r = toppoly_tdo_panel_power_on(dssdev);
  82. if (r)
  83. return r;
  84. dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
  85. return 0;
  86. }
  87. static void toppoly_tdo_panel_disable(struct omap_dss_device *dssdev)
  88. {
  89. toppoly_tdo_panel_power_off(dssdev);
  90. dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
  91. }
  92. static int toppoly_tdo_panel_suspend(struct omap_dss_device *dssdev)
  93. {
  94. toppoly_tdo_panel_power_off(dssdev);
  95. dssdev->state = OMAP_DSS_DISPLAY_SUSPENDED;
  96. return 0;
  97. }
  98. static int toppoly_tdo_panel_resume(struct omap_dss_device *dssdev)
  99. {
  100. int r = 0;
  101. r = toppoly_tdo_panel_power_on(dssdev);
  102. if (r)
  103. return r;
  104. dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
  105. return 0;
  106. }
  107. static struct omap_dss_driver generic_driver = {
  108. .probe = toppoly_tdo_panel_probe,
  109. .remove = toppoly_tdo_panel_remove,
  110. .enable = toppoly_tdo_panel_enable,
  111. .disable = toppoly_tdo_panel_disable,
  112. .suspend = toppoly_tdo_panel_suspend,
  113. .resume = toppoly_tdo_panel_resume,
  114. .driver = {
  115. .name = "toppoly_tdo35s_panel",
  116. .owner = THIS_MODULE,
  117. },
  118. };
  119. static int __init toppoly_tdo_panel_drv_init(void)
  120. {
  121. return omap_dss_register_driver(&generic_driver);
  122. }
  123. static void __exit toppoly_tdo_panel_drv_exit(void)
  124. {
  125. omap_dss_unregister_driver(&generic_driver);
  126. }
  127. module_init(toppoly_tdo_panel_drv_init);
  128. module_exit(toppoly_tdo_panel_drv_exit);
  129. MODULE_LICENSE("GPL");