lcd_omap3evm.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /*
  2. * LCD panel support for the TI OMAP3 EVM board
  3. *
  4. * Author: Steve Sakoman <steve@sakoman.com>
  5. *
  6. * Derived from drivers/video/omap/lcd-apollon.c
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation; either version 2 of the License, or (at your
  11. * option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program; if not, write to the Free Software Foundation, Inc.,
  20. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  21. */
  22. #include <linux/module.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/gpio.h>
  25. #include <linux/i2c/twl.h>
  26. #include <plat/mux.h>
  27. #include <asm/mach-types.h>
  28. #include "omapfb.h"
  29. #define LCD_PANEL_ENABLE_GPIO 153
  30. #define LCD_PANEL_LR 2
  31. #define LCD_PANEL_UD 3
  32. #define LCD_PANEL_INI 152
  33. #define LCD_PANEL_QVGA 154
  34. #define LCD_PANEL_RESB 155
  35. #define ENABLE_VDAC_DEDICATED 0x03
  36. #define ENABLE_VDAC_DEV_GRP 0x20
  37. #define ENABLE_VPLL2_DEDICATED 0x05
  38. #define ENABLE_VPLL2_DEV_GRP 0xE0
  39. #define TWL_LED_LEDEN 0x00
  40. #define TWL_PWMA_PWMAON 0x00
  41. #define TWL_PWMA_PWMAOFF 0x01
  42. static unsigned int bklight_level;
  43. static int omap3evm_panel_init(struct lcd_panel *panel,
  44. struct omapfb_device *fbdev)
  45. {
  46. gpio_request(LCD_PANEL_LR, "LCD lr");
  47. gpio_request(LCD_PANEL_UD, "LCD ud");
  48. gpio_request(LCD_PANEL_INI, "LCD ini");
  49. gpio_request(LCD_PANEL_RESB, "LCD resb");
  50. gpio_request(LCD_PANEL_QVGA, "LCD qvga");
  51. gpio_direction_output(LCD_PANEL_RESB, 1);
  52. gpio_direction_output(LCD_PANEL_INI, 1);
  53. gpio_direction_output(LCD_PANEL_QVGA, 0);
  54. gpio_direction_output(LCD_PANEL_LR, 1);
  55. gpio_direction_output(LCD_PANEL_UD, 1);
  56. twl_i2c_write_u8(TWL4030_MODULE_LED, 0x11, TWL_LED_LEDEN);
  57. twl_i2c_write_u8(TWL4030_MODULE_PWMA, 0x01, TWL_PWMA_PWMAON);
  58. twl_i2c_write_u8(TWL4030_MODULE_PWMA, 0x02, TWL_PWMA_PWMAOFF);
  59. bklight_level = 100;
  60. return 0;
  61. }
  62. static void omap3evm_panel_cleanup(struct lcd_panel *panel)
  63. {
  64. gpio_free(LCD_PANEL_QVGA);
  65. gpio_free(LCD_PANEL_RESB);
  66. gpio_free(LCD_PANEL_INI);
  67. gpio_free(LCD_PANEL_UD);
  68. gpio_free(LCD_PANEL_LR);
  69. }
  70. static int omap3evm_panel_enable(struct lcd_panel *panel)
  71. {
  72. gpio_set_value(LCD_PANEL_ENABLE_GPIO, 0);
  73. return 0;
  74. }
  75. static void omap3evm_panel_disable(struct lcd_panel *panel)
  76. {
  77. gpio_set_value(LCD_PANEL_ENABLE_GPIO, 1);
  78. }
  79. static unsigned long omap3evm_panel_get_caps(struct lcd_panel *panel)
  80. {
  81. return 0;
  82. }
  83. static int omap3evm_bklight_setlevel(struct lcd_panel *panel,
  84. unsigned int level)
  85. {
  86. u8 c;
  87. if ((level >= 0) && (level <= 100)) {
  88. c = (125 * (100 - level)) / 100 + 2;
  89. twl_i2c_write_u8(TWL4030_MODULE_PWMA, c, TWL_PWMA_PWMAOFF);
  90. bklight_level = level;
  91. }
  92. return 0;
  93. }
  94. static unsigned int omap3evm_bklight_getlevel(struct lcd_panel *panel)
  95. {
  96. return bklight_level;
  97. }
  98. static unsigned int omap3evm_bklight_getmaxlevel(struct lcd_panel *panel)
  99. {
  100. return 100;
  101. }
  102. struct lcd_panel omap3evm_panel = {
  103. .name = "omap3evm",
  104. .config = OMAP_LCDC_PANEL_TFT | OMAP_LCDC_INV_VSYNC |
  105. OMAP_LCDC_INV_HSYNC,
  106. .bpp = 16,
  107. .data_lines = 18,
  108. .x_res = 480,
  109. .y_res = 640,
  110. .hsw = 3, /* hsync_len (4) - 1 */
  111. .hfp = 3, /* right_margin (4) - 1 */
  112. .hbp = 39, /* left_margin (40) - 1 */
  113. .vsw = 1, /* vsync_len (2) - 1 */
  114. .vfp = 2, /* lower_margin */
  115. .vbp = 7, /* upper_margin (8) - 1 */
  116. .pixel_clock = 26000,
  117. .init = omap3evm_panel_init,
  118. .cleanup = omap3evm_panel_cleanup,
  119. .enable = omap3evm_panel_enable,
  120. .disable = omap3evm_panel_disable,
  121. .get_caps = omap3evm_panel_get_caps,
  122. .set_bklight_level = omap3evm_bklight_setlevel,
  123. .get_bklight_level = omap3evm_bklight_getlevel,
  124. .get_bklight_max = omap3evm_bklight_getmaxlevel,
  125. };
  126. static int omap3evm_panel_probe(struct platform_device *pdev)
  127. {
  128. omapfb_register_panel(&omap3evm_panel);
  129. return 0;
  130. }
  131. static int omap3evm_panel_remove(struct platform_device *pdev)
  132. {
  133. return 0;
  134. }
  135. static int omap3evm_panel_suspend(struct platform_device *pdev,
  136. pm_message_t mesg)
  137. {
  138. return 0;
  139. }
  140. static int omap3evm_panel_resume(struct platform_device *pdev)
  141. {
  142. return 0;
  143. }
  144. struct platform_driver omap3evm_panel_driver = {
  145. .probe = omap3evm_panel_probe,
  146. .remove = omap3evm_panel_remove,
  147. .suspend = omap3evm_panel_suspend,
  148. .resume = omap3evm_panel_resume,
  149. .driver = {
  150. .name = "omap3evm_lcd",
  151. .owner = THIS_MODULE,
  152. },
  153. };
  154. static int __init omap3evm_panel_drv_init(void)
  155. {
  156. return platform_driver_register(&omap3evm_panel_driver);
  157. }
  158. static void __exit omap3evm_panel_drv_exit(void)
  159. {
  160. platform_driver_unregister(&omap3evm_panel_driver);
  161. }
  162. module_init(omap3evm_panel_drv_init);
  163. module_exit(omap3evm_panel_drv_exit);