panel-sharp-ls037v7dw01.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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/regulator/consumer.h>
  23. #include <linux/err.h>
  24. #include <plat/display.h>
  25. struct sharp_data {
  26. /* XXX This regulator should actually be in SDP board file, not here,
  27. * as it doesn't actually power the LCD, but something else that
  28. * affects the output to LCD (I think. Somebody clarify). It doesn't do
  29. * harm here, as SDP is the only board using this currently */
  30. struct regulator *vdvi_reg;
  31. };
  32. static struct omap_video_timings sharp_ls_timings = {
  33. .x_res = 480,
  34. .y_res = 640,
  35. .pixel_clock = 19200,
  36. .hsw = 2,
  37. .hfp = 1,
  38. .hbp = 28,
  39. .vsw = 1,
  40. .vfp = 1,
  41. .vbp = 1,
  42. };
  43. static int sharp_ls_panel_probe(struct omap_dss_device *dssdev)
  44. {
  45. struct sharp_data *sd;
  46. dssdev->panel.config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS |
  47. OMAP_DSS_LCD_IHS;
  48. dssdev->panel.acb = 0x28;
  49. dssdev->panel.timings = sharp_ls_timings;
  50. sd = kzalloc(sizeof(*sd), GFP_KERNEL);
  51. if (!sd)
  52. return -ENOMEM;
  53. dev_set_drvdata(&dssdev->dev, sd);
  54. sd->vdvi_reg = regulator_get(&dssdev->dev, "vdvi");
  55. if (IS_ERR(sd->vdvi_reg)) {
  56. kfree(sd);
  57. pr_err("failed to get VDVI regulator\n");
  58. return PTR_ERR(sd->vdvi_reg);
  59. }
  60. return 0;
  61. }
  62. static void sharp_ls_panel_remove(struct omap_dss_device *dssdev)
  63. {
  64. struct sharp_data *sd = dev_get_drvdata(&dssdev->dev);
  65. regulator_put(sd->vdvi_reg);
  66. kfree(sd);
  67. }
  68. static int sharp_ls_panel_enable(struct omap_dss_device *dssdev)
  69. {
  70. struct sharp_data *sd = dev_get_drvdata(&dssdev->dev);
  71. int r = 0;
  72. /* wait couple of vsyncs until enabling the LCD */
  73. msleep(50);
  74. regulator_enable(sd->vdvi_reg);
  75. if (dssdev->platform_enable)
  76. r = dssdev->platform_enable(dssdev);
  77. return r;
  78. }
  79. static void sharp_ls_panel_disable(struct omap_dss_device *dssdev)
  80. {
  81. struct sharp_data *sd = dev_get_drvdata(&dssdev->dev);
  82. if (dssdev->platform_disable)
  83. dssdev->platform_disable(dssdev);
  84. regulator_disable(sd->vdvi_reg);
  85. /* wait at least 5 vsyncs after disabling the LCD */
  86. msleep(100);
  87. }
  88. static int sharp_ls_panel_suspend(struct omap_dss_device *dssdev)
  89. {
  90. sharp_ls_panel_disable(dssdev);
  91. return 0;
  92. }
  93. static int sharp_ls_panel_resume(struct omap_dss_device *dssdev)
  94. {
  95. return sharp_ls_panel_enable(dssdev);
  96. }
  97. static struct omap_dss_driver sharp_ls_driver = {
  98. .probe = sharp_ls_panel_probe,
  99. .remove = sharp_ls_panel_remove,
  100. .enable = sharp_ls_panel_enable,
  101. .disable = sharp_ls_panel_disable,
  102. .suspend = sharp_ls_panel_suspend,
  103. .resume = sharp_ls_panel_resume,
  104. .driver = {
  105. .name = "sharp_ls_panel",
  106. .owner = THIS_MODULE,
  107. },
  108. };
  109. static int __init sharp_ls_panel_drv_init(void)
  110. {
  111. return omap_dss_register_driver(&sharp_ls_driver);
  112. }
  113. static void __exit sharp_ls_panel_drv_exit(void)
  114. {
  115. omap_dss_unregister_driver(&sharp_ls_driver);
  116. }
  117. module_init(sharp_ls_panel_drv_init);
  118. module_exit(sharp_ls_panel_drv_exit);
  119. MODULE_LICENSE("GPL");