GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / drivers / video / omap / lcd_omap2evm.c
blob7e7a65c08452d16e562ad2021197fc2bdee4c291
1 /*
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/twl.h>
29 #include <plat/mux.h>
30 #include <asm/mach-types.h>
32 #include "omapfb.h"
34 #define LCD_PANEL_ENABLE_GPIO 154
35 #define LCD_PANEL_LR 128
36 #define LCD_PANEL_UD 129
37 #define LCD_PANEL_INI 152
38 #define LCD_PANEL_QVGA 148
39 #define LCD_PANEL_RESB 153
41 #define TWL_LED_LEDEN 0x00
42 #define TWL_PWMA_PWMAON 0x00
43 #define TWL_PWMA_PWMAOFF 0x01
45 static unsigned int bklight_level;
47 static int omap2evm_panel_init(struct lcd_panel *panel,
48 struct omapfb_device *fbdev)
50 gpio_request(LCD_PANEL_ENABLE_GPIO, "LCD enable");
51 gpio_request(LCD_PANEL_LR, "LCD lr");
52 gpio_request(LCD_PANEL_UD, "LCD ud");
53 gpio_request(LCD_PANEL_INI, "LCD ini");
54 gpio_request(LCD_PANEL_QVGA, "LCD qvga");
55 gpio_request(LCD_PANEL_RESB, "LCD resb");
57 gpio_direction_output(LCD_PANEL_ENABLE_GPIO, 1);
58 gpio_direction_output(LCD_PANEL_RESB, 1);
59 gpio_direction_output(LCD_PANEL_INI, 1);
60 gpio_direction_output(LCD_PANEL_QVGA, 0);
61 gpio_direction_output(LCD_PANEL_LR, 1);
62 gpio_direction_output(LCD_PANEL_UD, 1);
64 twl_i2c_write_u8(TWL4030_MODULE_LED, 0x11, TWL_LED_LEDEN);
65 twl_i2c_write_u8(TWL4030_MODULE_PWMA, 0x01, TWL_PWMA_PWMAON);
66 twl_i2c_write_u8(TWL4030_MODULE_PWMA, 0x02, TWL_PWMA_PWMAOFF);
67 bklight_level = 100;
69 return 0;
72 static void omap2evm_panel_cleanup(struct lcd_panel *panel)
74 gpio_free(LCD_PANEL_RESB);
75 gpio_free(LCD_PANEL_QVGA);
76 gpio_free(LCD_PANEL_INI);
77 gpio_free(LCD_PANEL_UD);
78 gpio_free(LCD_PANEL_LR);
79 gpio_free(LCD_PANEL_ENABLE_GPIO);
82 static int omap2evm_panel_enable(struct lcd_panel *panel)
84 gpio_set_value(LCD_PANEL_ENABLE_GPIO, 0);
85 return 0;
88 static void omap2evm_panel_disable(struct lcd_panel *panel)
90 gpio_set_value(LCD_PANEL_ENABLE_GPIO, 1);
93 static unsigned long omap2evm_panel_get_caps(struct lcd_panel *panel)
95 return 0;
98 static int omap2evm_bklight_setlevel(struct lcd_panel *panel,
99 unsigned int level)
101 u8 c;
102 if ((level >= 0) && (level <= 100)) {
103 c = (125 * (100 - level)) / 100 + 2;
104 twl_i2c_write_u8(TWL4030_MODULE_PWMA, c, TWL_PWMA_PWMAOFF);
105 bklight_level = level;
107 return 0;
110 static unsigned int omap2evm_bklight_getlevel(struct lcd_panel *panel)
112 return bklight_level;
115 static unsigned int omap2evm_bklight_getmaxlevel(struct lcd_panel *panel)
117 return 100;
120 struct lcd_panel omap2evm_panel = {
121 .name = "omap2evm",
122 .config = OMAP_LCDC_PANEL_TFT | OMAP_LCDC_INV_VSYNC |
123 OMAP_LCDC_INV_HSYNC,
125 .bpp = 16,
126 .data_lines = 18,
127 .x_res = 480,
128 .y_res = 640,
129 .hsw = 3,
130 .hfp = 0,
131 .hbp = 28,
132 .vsw = 2,
133 .vfp = 1,
134 .vbp = 0,
136 .pixel_clock = 20000,
138 .init = omap2evm_panel_init,
139 .cleanup = omap2evm_panel_cleanup,
140 .enable = omap2evm_panel_enable,
141 .disable = omap2evm_panel_disable,
142 .get_caps = omap2evm_panel_get_caps,
143 .set_bklight_level = omap2evm_bklight_setlevel,
144 .get_bklight_level = omap2evm_bklight_getlevel,
145 .get_bklight_max = omap2evm_bklight_getmaxlevel,
148 static int omap2evm_panel_probe(struct platform_device *pdev)
150 omapfb_register_panel(&omap2evm_panel);
151 return 0;
154 static int omap2evm_panel_remove(struct platform_device *pdev)
156 return 0;
159 static int omap2evm_panel_suspend(struct platform_device *pdev,
160 pm_message_t mesg)
162 return 0;
165 static int omap2evm_panel_resume(struct platform_device *pdev)
167 return 0;
170 struct platform_driver omap2evm_panel_driver = {
171 .probe = omap2evm_panel_probe,
172 .remove = omap2evm_panel_remove,
173 .suspend = omap2evm_panel_suspend,
174 .resume = omap2evm_panel_resume,
175 .driver = {
176 .name = "omap2evm_lcd",
177 .owner = THIS_MODULE,
181 static int __init omap2evm_panel_drv_init(void)
183 return platform_driver_register(&omap2evm_panel_driver);
186 static void __exit omap2evm_panel_drv_exit(void)
188 platform_driver_unregister(&omap2evm_panel_driver);
191 module_init(omap2evm_panel_drv_init);
192 module_exit(omap2evm_panel_drv_exit);