2 * LCD panel support for the MISTRAL OMAP2EVM board
4 * Author: Arun C <arunedarath@mistralsolutions.com>
6 * Derived from drivers/video/omap/lcd_omap3evm.c
7 * Derived from drivers/video/omap/lcd-apollon.c
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.
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.
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.
24 #include <linux/module.h>
25 #include <linux/platform_device.h>
26 #include <linux/gpio.h>
27 #include <linux/i2c/twl4030.h>
30 #include <mach/omapfb.h>
31 #include <asm/mach-types.h>
33 #define LCD_PANEL_ENABLE_GPIO 154
34 #define LCD_PANEL_LR 128
35 #define LCD_PANEL_UD 129
36 #define LCD_PANEL_INI 152
37 #define LCD_PANEL_QVGA 148
38 #define LCD_PANEL_RESB 153
42 #define LCD_PIXCLOCK_MAX 20000 /* in kHz */
44 #define TWL_LED_LEDEN 0x00
45 #define TWL_PWMA_PWMAON 0x00
46 #define TWL_PWMA_PWMAOFF 0x01
48 static unsigned int bklight_level;
50 static int omap2evm_panel_init(struct lcd_panel *panel,
51 struct omapfb_device *fbdev)
53 gpio_request(LCD_PANEL_ENABLE_GPIO, "LCD enable");
54 gpio_request(LCD_PANEL_LR, "LCD lr");
55 gpio_request(LCD_PANEL_UD, "LCD ud");
56 gpio_request(LCD_PANEL_INI, "LCD ini");
57 gpio_request(LCD_PANEL_QVGA, "LCD qvga");
58 gpio_request(LCD_PANEL_RESB, "LCD resb");
60 gpio_direction_output(LCD_PANEL_ENABLE_GPIO, 1);
61 gpio_direction_output(LCD_PANEL_RESB, 1);
62 gpio_direction_output(LCD_PANEL_INI, 1);
63 gpio_direction_output(LCD_PANEL_QVGA, 0);
64 gpio_direction_output(LCD_PANEL_LR, 1);
65 gpio_direction_output(LCD_PANEL_UD, 1);
67 twl4030_i2c_write_u8(TWL4030_MODULE_LED, 0x11, TWL_LED_LEDEN);
68 twl4030_i2c_write_u8(TWL4030_MODULE_PWMA, 0x01, TWL_PWMA_PWMAON);
69 twl4030_i2c_write_u8(TWL4030_MODULE_PWMA, 0x02, TWL_PWMA_PWMAOFF);
75 static void omap2evm_panel_cleanup(struct lcd_panel *panel)
79 static int omap2evm_panel_enable(struct lcd_panel *panel)
81 gpio_set_value(LCD_PANEL_ENABLE_GPIO, 0);
85 static void omap2evm_panel_disable(struct lcd_panel *panel)
87 gpio_set_value(LCD_PANEL_ENABLE_GPIO, 1);
90 static unsigned long omap2evm_panel_get_caps(struct lcd_panel *panel)
95 static int omap2evm_bklight_setlevel(struct lcd_panel *panel,
99 if ((level >= 0) && (level <= 100)) {
100 c = (125 * (100 - level)) / 100 + 2;
101 twl4030_i2c_write_u8(TWL4030_MODULE_PWMA, c, TWL_PWMA_PWMAOFF);
102 bklight_level = level;
107 static unsigned int omap2evm_bklight_getlevel(struct lcd_panel *panel)
109 return bklight_level;
112 static unsigned int omap2evm_bklight_getmaxlevel(struct lcd_panel *panel)
117 struct lcd_panel omap2evm_panel = {
119 .config = OMAP_LCDC_PANEL_TFT | OMAP_LCDC_INV_VSYNC |
133 .pixel_clock = LCD_PIXCLOCK_MAX,
135 .init = omap2evm_panel_init,
136 .cleanup = omap2evm_panel_cleanup,
137 .enable = omap2evm_panel_enable,
138 .disable = omap2evm_panel_disable,
139 .get_caps = omap2evm_panel_get_caps,
140 .set_bklight_level = omap2evm_bklight_setlevel,
141 .get_bklight_level = omap2evm_bklight_getlevel,
142 .get_bklight_max = omap2evm_bklight_getmaxlevel,
145 static int omap2evm_panel_probe(struct platform_device *pdev)
147 omapfb_register_panel(&omap2evm_panel);
151 static int omap2evm_panel_remove(struct platform_device *pdev)
156 static int omap2evm_panel_suspend(struct platform_device *pdev,
162 static int omap2evm_panel_resume(struct platform_device *pdev)
167 struct platform_driver omap2evm_panel_driver = {
168 .probe = omap2evm_panel_probe,
169 .remove = omap2evm_panel_remove,
170 .suspend = omap2evm_panel_suspend,
171 .resume = omap2evm_panel_resume,
173 .name = "omap2evm_lcd",
174 .owner = THIS_MODULE,
178 static int __init omap2evm_panel_drv_init(void)
180 return platform_driver_register(&omap2evm_panel_driver);
183 static void __exit omap2evm_panel_drv_exit(void)
185 platform_driver_unregister(&omap2evm_panel_driver);
188 module_init(omap2evm_panel_drv_init);
189 module_exit(omap2evm_panel_drv_exit);