lcd_ams_delta.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. /*
  2. * Based on drivers/video/omap/lcd_inn1510.c
  3. *
  4. * LCD panel support for the Amstrad E3 (Delta) videophone.
  5. *
  6. * Copyright (C) 2006 Jonathan McDowell <noodles@earth.li>
  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/io.h>
  25. #include <linux/delay.h>
  26. #include <linux/lcd.h>
  27. #include <plat/board-ams-delta.h>
  28. #include <mach/hardware.h>
  29. #include "omapfb.h"
  30. #define AMS_DELTA_DEFAULT_CONTRAST 112
  31. #define AMS_DELTA_MAX_CONTRAST 0x00FF
  32. #define AMS_DELTA_LCD_POWER 0x0100
  33. /* LCD class device section */
  34. static int ams_delta_lcd;
  35. static int ams_delta_lcd_set_power(struct lcd_device *dev, int power)
  36. {
  37. if (power == FB_BLANK_UNBLANK) {
  38. if (!(ams_delta_lcd & AMS_DELTA_LCD_POWER)) {
  39. omap_writeb(ams_delta_lcd & AMS_DELTA_MAX_CONTRAST,
  40. OMAP_PWL_ENABLE);
  41. omap_writeb(1, OMAP_PWL_CLK_ENABLE);
  42. ams_delta_lcd |= AMS_DELTA_LCD_POWER;
  43. }
  44. } else {
  45. if (ams_delta_lcd & AMS_DELTA_LCD_POWER) {
  46. omap_writeb(0, OMAP_PWL_ENABLE);
  47. omap_writeb(0, OMAP_PWL_CLK_ENABLE);
  48. ams_delta_lcd &= ~AMS_DELTA_LCD_POWER;
  49. }
  50. }
  51. return 0;
  52. }
  53. static int ams_delta_lcd_set_contrast(struct lcd_device *dev, int value)
  54. {
  55. if ((value >= 0) && (value <= AMS_DELTA_MAX_CONTRAST)) {
  56. omap_writeb(value, OMAP_PWL_ENABLE);
  57. ams_delta_lcd &= ~AMS_DELTA_MAX_CONTRAST;
  58. ams_delta_lcd |= value;
  59. }
  60. return 0;
  61. }
  62. #ifdef CONFIG_LCD_CLASS_DEVICE
  63. static int ams_delta_lcd_get_power(struct lcd_device *dev)
  64. {
  65. if (ams_delta_lcd & AMS_DELTA_LCD_POWER)
  66. return FB_BLANK_UNBLANK;
  67. else
  68. return FB_BLANK_POWERDOWN;
  69. }
  70. static int ams_delta_lcd_get_contrast(struct lcd_device *dev)
  71. {
  72. if (!(ams_delta_lcd & AMS_DELTA_LCD_POWER))
  73. return 0;
  74. return ams_delta_lcd & AMS_DELTA_MAX_CONTRAST;
  75. }
  76. static struct lcd_ops ams_delta_lcd_ops = {
  77. .get_power = ams_delta_lcd_get_power,
  78. .set_power = ams_delta_lcd_set_power,
  79. .get_contrast = ams_delta_lcd_get_contrast,
  80. .set_contrast = ams_delta_lcd_set_contrast,
  81. };
  82. #endif
  83. /* omapfb panel section */
  84. static int ams_delta_panel_init(struct lcd_panel *panel,
  85. struct omapfb_device *fbdev)
  86. {
  87. return 0;
  88. }
  89. static void ams_delta_panel_cleanup(struct lcd_panel *panel)
  90. {
  91. }
  92. static int ams_delta_panel_enable(struct lcd_panel *panel)
  93. {
  94. ams_delta_latch2_write(AMS_DELTA_LATCH2_LCD_NDISP,
  95. AMS_DELTA_LATCH2_LCD_NDISP);
  96. ams_delta_latch2_write(AMS_DELTA_LATCH2_LCD_VBLEN,
  97. AMS_DELTA_LATCH2_LCD_VBLEN);
  98. return 0;
  99. }
  100. static void ams_delta_panel_disable(struct lcd_panel *panel)
  101. {
  102. ams_delta_latch2_write(AMS_DELTA_LATCH2_LCD_VBLEN, 0);
  103. ams_delta_latch2_write(AMS_DELTA_LATCH2_LCD_NDISP, 0);
  104. }
  105. static unsigned long ams_delta_panel_get_caps(struct lcd_panel *panel)
  106. {
  107. return 0;
  108. }
  109. static struct lcd_panel ams_delta_panel = {
  110. .name = "ams-delta",
  111. .config = 0,
  112. .bpp = 12,
  113. .data_lines = 16,
  114. .x_res = 480,
  115. .y_res = 320,
  116. .pixel_clock = 4687,
  117. .hsw = 3,
  118. .hfp = 1,
  119. .hbp = 1,
  120. .vsw = 1,
  121. .vfp = 0,
  122. .vbp = 0,
  123. .pcd = 0,
  124. .acb = 37,
  125. .init = ams_delta_panel_init,
  126. .cleanup = ams_delta_panel_cleanup,
  127. .enable = ams_delta_panel_enable,
  128. .disable = ams_delta_panel_disable,
  129. .get_caps = ams_delta_panel_get_caps,
  130. };
  131. /* platform driver section */
  132. static int ams_delta_panel_probe(struct platform_device *pdev)
  133. {
  134. struct lcd_device *lcd_device = NULL;
  135. #ifdef CONFIG_LCD_CLASS_DEVICE
  136. int ret;
  137. lcd_device = lcd_device_register("omapfb", &pdev->dev, NULL,
  138. &ams_delta_lcd_ops);
  139. if (IS_ERR(lcd_device)) {
  140. ret = PTR_ERR(lcd_device);
  141. dev_err(&pdev->dev, "failed to register device\n");
  142. return ret;
  143. }
  144. platform_set_drvdata(pdev, lcd_device);
  145. lcd_device->props.max_contrast = AMS_DELTA_MAX_CONTRAST;
  146. #endif
  147. ams_delta_lcd_set_contrast(lcd_device, AMS_DELTA_DEFAULT_CONTRAST);
  148. ams_delta_lcd_set_power(lcd_device, FB_BLANK_UNBLANK);
  149. omapfb_register_panel(&ams_delta_panel);
  150. return 0;
  151. }
  152. static int ams_delta_panel_remove(struct platform_device *pdev)
  153. {
  154. return 0;
  155. }
  156. static int ams_delta_panel_suspend(struct platform_device *pdev,
  157. pm_message_t mesg)
  158. {
  159. return 0;
  160. }
  161. static int ams_delta_panel_resume(struct platform_device *pdev)
  162. {
  163. return 0;
  164. }
  165. struct platform_driver ams_delta_panel_driver = {
  166. .probe = ams_delta_panel_probe,
  167. .remove = ams_delta_panel_remove,
  168. .suspend = ams_delta_panel_suspend,
  169. .resume = ams_delta_panel_resume,
  170. .driver = {
  171. .name = "lcd_ams_delta",
  172. .owner = THIS_MODULE,
  173. },
  174. };
  175. static int __init ams_delta_panel_drv_init(void)
  176. {
  177. return platform_driver_register(&ams_delta_panel_driver);
  178. }
  179. static void __exit ams_delta_panel_drv_cleanup(void)
  180. {
  181. platform_driver_unregister(&ams_delta_panel_driver);
  182. }
  183. module_init(ams_delta_panel_drv_init);
  184. module_exit(ams_delta_panel_drv_cleanup);