lcd_ldp.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. /*
  2. * LCD panel support for the TI LDP board
  3. *
  4. * Copyright (C) 2007 WindRiver
  5. * Author: Stanley Miao <stanley.miao@windriver.com>
  6. *
  7. * Derived from drivers/video/omap/lcd-2430sdp.c
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License as published by the
  11. * Free Software Foundation; either version 2 of the License, or (at your
  12. * option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program; if not, write to the Free Software Foundation, Inc.,
  21. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22. */
  23. #include <linux/module.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/delay.h>
  26. #include <linux/i2c/twl.h>
  27. #include <mach/gpio.h>
  28. #include <plat/mux.h>
  29. #include <asm/mach-types.h>
  30. #include "omapfb.h"
  31. #define LCD_PANEL_BACKLIGHT_GPIO (15 + OMAP_MAX_GPIO_LINES)
  32. #define LCD_PANEL_ENABLE_GPIO (7 + OMAP_MAX_GPIO_LINES)
  33. #define LCD_PANEL_RESET_GPIO 55
  34. #define LCD_PANEL_QVGA_GPIO 56
  35. #ifdef CONFIG_FB_OMAP_LCD_VGA
  36. #define LCD_XRES 480
  37. #define LCD_YRES 640
  38. #define LCD_PIXCLOCK_MAX 41700
  39. #else
  40. #define LCD_XRES 240
  41. #define LCD_YRES 320
  42. #define LCD_PIXCLOCK_MAX 185186
  43. #endif
  44. #define PM_RECEIVER TWL4030_MODULE_PM_RECEIVER
  45. #define ENABLE_VAUX2_DEDICATED 0x09
  46. #define ENABLE_VAUX2_DEV_GRP 0x20
  47. #define ENABLE_VAUX3_DEDICATED 0x03
  48. #define ENABLE_VAUX3_DEV_GRP 0x20
  49. #define ENABLE_VPLL2_DEDICATED 0x05
  50. #define ENABLE_VPLL2_DEV_GRP 0xE0
  51. #define TWL4030_VPLL2_DEV_GRP 0x33
  52. #define TWL4030_VPLL2_DEDICATED 0x36
  53. #define t2_out(c, r, v) twl_i2c_write_u8(c, r, v)
  54. static int ldp_panel_init(struct lcd_panel *panel,
  55. struct omapfb_device *fbdev)
  56. {
  57. gpio_request(LCD_PANEL_RESET_GPIO, "lcd reset");
  58. gpio_request(LCD_PANEL_QVGA_GPIO, "lcd qvga");
  59. gpio_request(LCD_PANEL_ENABLE_GPIO, "lcd panel");
  60. gpio_request(LCD_PANEL_BACKLIGHT_GPIO, "lcd backlight");
  61. gpio_direction_output(LCD_PANEL_QVGA_GPIO, 0);
  62. gpio_direction_output(LCD_PANEL_RESET_GPIO, 0);
  63. gpio_direction_output(LCD_PANEL_ENABLE_GPIO, 0);
  64. gpio_direction_output(LCD_PANEL_BACKLIGHT_GPIO, 0);
  65. #ifdef CONFIG_FB_OMAP_LCD_VGA
  66. gpio_set_value(LCD_PANEL_QVGA_GPIO, 0);
  67. #else
  68. gpio_set_value(LCD_PANEL_QVGA_GPIO, 1);
  69. #endif
  70. gpio_set_value(LCD_PANEL_RESET_GPIO, 1);
  71. return 0;
  72. }
  73. static void ldp_panel_cleanup(struct lcd_panel *panel)
  74. {
  75. gpio_free(LCD_PANEL_BACKLIGHT_GPIO);
  76. gpio_free(LCD_PANEL_ENABLE_GPIO);
  77. gpio_free(LCD_PANEL_QVGA_GPIO);
  78. gpio_free(LCD_PANEL_RESET_GPIO);
  79. }
  80. static int ldp_panel_enable(struct lcd_panel *panel)
  81. {
  82. if (0 != t2_out(PM_RECEIVER, ENABLE_VPLL2_DEDICATED,
  83. TWL4030_VPLL2_DEDICATED))
  84. return -EIO;
  85. if (0 != t2_out(PM_RECEIVER, ENABLE_VPLL2_DEV_GRP,
  86. TWL4030_VPLL2_DEV_GRP))
  87. return -EIO;
  88. gpio_direction_output(LCD_PANEL_ENABLE_GPIO, 1);
  89. gpio_direction_output(LCD_PANEL_BACKLIGHT_GPIO, 1);
  90. if (0 != t2_out(PM_RECEIVER, ENABLE_VAUX3_DEDICATED,
  91. TWL4030_VAUX3_DEDICATED))
  92. return -EIO;
  93. if (0 != t2_out(PM_RECEIVER, ENABLE_VAUX3_DEV_GRP,
  94. TWL4030_VAUX3_DEV_GRP))
  95. return -EIO;
  96. return 0;
  97. }
  98. static void ldp_panel_disable(struct lcd_panel *panel)
  99. {
  100. gpio_direction_output(LCD_PANEL_ENABLE_GPIO, 0);
  101. gpio_direction_output(LCD_PANEL_BACKLIGHT_GPIO, 0);
  102. t2_out(PM_RECEIVER, 0x0, TWL4030_VPLL2_DEDICATED);
  103. t2_out(PM_RECEIVER, 0x0, TWL4030_VPLL2_DEV_GRP);
  104. msleep(4);
  105. }
  106. static unsigned long ldp_panel_get_caps(struct lcd_panel *panel)
  107. {
  108. return 0;
  109. }
  110. struct lcd_panel ldp_panel = {
  111. .name = "ldp",
  112. .config = OMAP_LCDC_PANEL_TFT | OMAP_LCDC_INV_VSYNC |
  113. OMAP_LCDC_INV_HSYNC,
  114. .bpp = 16,
  115. .data_lines = 18,
  116. .x_res = LCD_XRES,
  117. .y_res = LCD_YRES,
  118. .hsw = 3, /* hsync_len (4) - 1 */
  119. .hfp = 3, /* right_margin (4) - 1 */
  120. .hbp = 39, /* left_margin (40) - 1 */
  121. .vsw = 1, /* vsync_len (2) - 1 */
  122. .vfp = 2, /* lower_margin */
  123. .vbp = 7, /* upper_margin (8) - 1 */
  124. .pixel_clock = LCD_PIXCLOCK_MAX,
  125. .init = ldp_panel_init,
  126. .cleanup = ldp_panel_cleanup,
  127. .enable = ldp_panel_enable,
  128. .disable = ldp_panel_disable,
  129. .get_caps = ldp_panel_get_caps,
  130. };
  131. static int ldp_panel_probe(struct platform_device *pdev)
  132. {
  133. omapfb_register_panel(&ldp_panel);
  134. return 0;
  135. }
  136. static int ldp_panel_remove(struct platform_device *pdev)
  137. {
  138. return 0;
  139. }
  140. static int ldp_panel_suspend(struct platform_device *pdev, pm_message_t mesg)
  141. {
  142. return 0;
  143. }
  144. static int ldp_panel_resume(struct platform_device *pdev)
  145. {
  146. return 0;
  147. }
  148. struct platform_driver ldp_panel_driver = {
  149. .probe = ldp_panel_probe,
  150. .remove = ldp_panel_remove,
  151. .suspend = ldp_panel_suspend,
  152. .resume = ldp_panel_resume,
  153. .driver = {
  154. .name = "ldp_lcd",
  155. .owner = THIS_MODULE,
  156. },
  157. };
  158. static int __init ldp_panel_drv_init(void)
  159. {
  160. return platform_driver_register(&ldp_panel_driver);
  161. }
  162. static void __exit ldp_panel_drv_exit(void)
  163. {
  164. platform_driver_unregister(&ldp_panel_driver);
  165. }
  166. module_init(ldp_panel_drv_init);
  167. module_exit(ldp_panel_drv_exit);