panel-sharp-ls037v7dw01.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*
  2. * LCD panel driver for Sharp LS037V7DW01
  3. *
  4. * Copyright (C) 2008 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. #include <linux/module.h>
  20. #include <linux/delay.h>
  21. #include <linux/device.h>
  22. #include <linux/fb.h>
  23. #include <linux/err.h>
  24. #include <linux/slab.h>
  25. #include <video/omapdss.h>
  26. struct sharp_data {
  27. };
  28. static struct omap_video_timings sharp_ls_timings = {
  29. .x_res = 480,
  30. .y_res = 640,
  31. .pixel_clock = 19200,
  32. .hsw = 2,
  33. .hfp = 1,
  34. .hbp = 28,
  35. .vsw = 1,
  36. .vfp = 1,
  37. .vbp = 1,
  38. .vsync_level = OMAPDSS_SIG_ACTIVE_LOW,
  39. .hsync_level = OMAPDSS_SIG_ACTIVE_LOW,
  40. .data_pclk_edge = OMAPDSS_DRIVE_SIG_RISING_EDGE,
  41. .de_level = OMAPDSS_SIG_ACTIVE_HIGH,
  42. .sync_pclk_edge = OMAPDSS_DRIVE_SIG_OPPOSITE_EDGES,
  43. };
  44. static int sharp_ls_panel_probe(struct omap_dss_device *dssdev)
  45. {
  46. struct sharp_data *sd;
  47. dssdev->panel.timings = sharp_ls_timings;
  48. sd = kzalloc(sizeof(*sd), GFP_KERNEL);
  49. if (!sd)
  50. return -ENOMEM;
  51. dev_set_drvdata(&dssdev->dev, sd);
  52. return 0;
  53. }
  54. static void __exit sharp_ls_panel_remove(struct omap_dss_device *dssdev)
  55. {
  56. struct sharp_data *sd = dev_get_drvdata(&dssdev->dev);
  57. kfree(sd);
  58. }
  59. static int sharp_ls_power_on(struct omap_dss_device *dssdev)
  60. {
  61. int r = 0;
  62. if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE)
  63. return 0;
  64. omapdss_dpi_set_timings(dssdev, &dssdev->panel.timings);
  65. omapdss_dpi_set_data_lines(dssdev, dssdev->phy.dpi.data_lines);
  66. r = omapdss_dpi_display_enable(dssdev);
  67. if (r)
  68. goto err0;
  69. /* wait couple of vsyncs until enabling the LCD */
  70. msleep(50);
  71. if (dssdev->platform_enable) {
  72. r = dssdev->platform_enable(dssdev);
  73. if (r)
  74. goto err1;
  75. }
  76. return 0;
  77. err1:
  78. omapdss_dpi_display_disable(dssdev);
  79. err0:
  80. return r;
  81. }
  82. static void sharp_ls_power_off(struct omap_dss_device *dssdev)
  83. {
  84. if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE)
  85. return;
  86. if (dssdev->platform_disable)
  87. dssdev->platform_disable(dssdev);
  88. /* wait at least 5 vsyncs after disabling the LCD */
  89. msleep(100);
  90. omapdss_dpi_display_disable(dssdev);
  91. }
  92. static int sharp_ls_panel_enable(struct omap_dss_device *dssdev)
  93. {
  94. int r;
  95. r = sharp_ls_power_on(dssdev);
  96. dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
  97. return r;
  98. }
  99. static void sharp_ls_panel_disable(struct omap_dss_device *dssdev)
  100. {
  101. sharp_ls_power_off(dssdev);
  102. dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
  103. }
  104. static struct omap_dss_driver sharp_ls_driver = {
  105. .probe = sharp_ls_panel_probe,
  106. .remove = __exit_p(sharp_ls_panel_remove),
  107. .enable = sharp_ls_panel_enable,
  108. .disable = sharp_ls_panel_disable,
  109. .driver = {
  110. .name = "sharp_ls_panel",
  111. .owner = THIS_MODULE,
  112. },
  113. };
  114. static int __init sharp_ls_panel_drv_init(void)
  115. {
  116. return omap_dss_register_driver(&sharp_ls_driver);
  117. }
  118. static void __exit sharp_ls_panel_drv_exit(void)
  119. {
  120. omap_dss_unregister_driver(&sharp_ls_driver);
  121. }
  122. module_init(sharp_ls_panel_drv_init);
  123. module_exit(sharp_ls_panel_drv_exit);
  124. MODULE_LICENSE("GPL");