]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - drivers/video/omap/lcd_omap3evm.c
Merge current mainline tree into linux-omap tree
[linux-2.6-omap-h63xx.git] / drivers / video / omap / lcd_omap3evm.c
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
23 #include <linux/module.h>
24 #include <linux/platform_device.h>
25 #include <linux/i2c/twl4030.h>
26
27 #include <mach/gpio.h>
28 #include <mach/mux.h>
29 #include <mach/omapfb.h>
30 #include <asm/mach-types.h>
31
32 #define LCD_PANEL_ENABLE_GPIO       153
33 #define LCD_PANEL_LR                2
34 #define LCD_PANEL_UD                3
35 #define LCD_PANEL_INI               152
36 #define LCD_PANEL_QVGA              154
37 #define LCD_PANEL_RESB              155
38
39 #define LCD_XRES                480
40 #define LCD_YRES                640
41 #define LCD_PIXCLOCK            26000 /* in kHz  */
42
43 #define ENABLE_VDAC_DEDICATED   0x03
44 #define ENABLE_VDAC_DEV_GRP     0x20
45 #define ENABLE_VPLL2_DEDICATED  0x05
46 #define ENABLE_VPLL2_DEV_GRP    0xE0
47
48 #define TWL_LED_LEDEN           0x00
49 #define TWL_PWMA_PWMAON         0x00
50 #define TWL_PWMA_PWMAOFF        0x01
51
52 static unsigned int bklight_level;
53
54 static int omap3evm_panel_init(struct lcd_panel *panel,
55                                 struct omapfb_device *fbdev)
56 {
57         omap_request_gpio(LCD_PANEL_LR);
58         omap_request_gpio(LCD_PANEL_UD);
59         omap_request_gpio(LCD_PANEL_INI);
60         omap_request_gpio(LCD_PANEL_RESB);
61         omap_request_gpio(LCD_PANEL_QVGA);
62
63         omap_set_gpio_direction(LCD_PANEL_LR, 0);
64         omap_set_gpio_direction(LCD_PANEL_UD, 0);
65         omap_set_gpio_direction(LCD_PANEL_INI, 0);
66         omap_set_gpio_direction(LCD_PANEL_RESB, 0);
67         omap_set_gpio_direction(LCD_PANEL_QVGA, 0);
68
69         twl4030_i2c_write_u8(TWL4030_MODULE_LED, 0x11, TWL_LED_LEDEN);
70         twl4030_i2c_write_u8(TWL4030_MODULE_PWMA, 0x01, TWL_PWMA_PWMAON);
71         twl4030_i2c_write_u8(TWL4030_MODULE_PWMA, 0x02, TWL_PWMA_PWMAOFF);
72         bklight_level = 100;
73
74         omap_set_gpio_dataout(LCD_PANEL_RESB, 1);
75         omap_set_gpio_dataout(LCD_PANEL_INI, 1);
76         omap_set_gpio_dataout(LCD_PANEL_QVGA, 0);
77         omap_set_gpio_dataout(LCD_PANEL_LR, 1);
78         omap_set_gpio_dataout(LCD_PANEL_UD, 1);
79
80         return 0;
81 }
82
83 static void omap3evm_panel_cleanup(struct lcd_panel *panel)
84 {
85 }
86
87 static int omap3evm_panel_enable(struct lcd_panel *panel)
88 {
89         omap_set_gpio_dataout(LCD_PANEL_ENABLE_GPIO, 0);
90         return 0;
91 }
92
93 static void omap3evm_panel_disable(struct lcd_panel *panel)
94 {
95         omap_set_gpio_dataout(LCD_PANEL_ENABLE_GPIO, 1);
96 }
97
98 static unsigned long omap3evm_panel_get_caps(struct lcd_panel *panel)
99 {
100         return 0;
101 }
102
103 static int omap3evm_bklight_setlevel(struct lcd_panel *panel,
104                                                 unsigned int level)
105 {
106         u8 c;
107         if ((level >= 0) && (level <= 100)) {
108                 c = (125 * (100 - level)) / 100 + 2;
109                 twl4030_i2c_write_u8(TWL4030_MODULE_PWMA, c, TWL_PWMA_PWMAOFF);
110                 bklight_level = level;
111         }
112         return 0;
113 }
114
115 static unsigned int omap3evm_bklight_getlevel(struct lcd_panel *panel)
116 {
117         return bklight_level;
118 }
119
120 static unsigned int omap3evm_bklight_getmaxlevel(struct lcd_panel *panel)
121 {
122         return 100;
123 }
124
125 struct lcd_panel omap3evm_panel = {
126         .name           = "omap3evm",
127         .config         = OMAP_LCDC_PANEL_TFT | OMAP_LCDC_INV_VSYNC |
128                           OMAP_LCDC_INV_HSYNC,
129
130         .bpp            = 16,
131         .data_lines     = 18,
132         .x_res          = LCD_XRES,
133         .y_res          = LCD_YRES,
134         .hsw            = 3,            /* hsync_len (4) - 1 */
135         .hfp            = 3,            /* right_margin (4) - 1 */
136         .hbp            = 39,           /* left_margin (40) - 1 */
137         .vsw            = 1,            /* vsync_len (2) - 1 */
138         .vfp            = 2,            /* lower_margin */
139         .vbp            = 7,            /* upper_margin (8) - 1 */
140
141         .pixel_clock    = LCD_PIXCLOCK,
142
143         .init           = omap3evm_panel_init,
144         .cleanup        = omap3evm_panel_cleanup,
145         .enable         = omap3evm_panel_enable,
146         .disable        = omap3evm_panel_disable,
147         .get_caps       = omap3evm_panel_get_caps,
148         .set_bklight_level      = omap3evm_bklight_setlevel,
149         .get_bklight_level      = omap3evm_bklight_getlevel,
150         .get_bklight_max        = omap3evm_bklight_getmaxlevel,
151 };
152
153 static int omap3evm_panel_probe(struct platform_device *pdev)
154 {
155         omapfb_register_panel(&omap3evm_panel);
156         return 0;
157 }
158
159 static int omap3evm_panel_remove(struct platform_device *pdev)
160 {
161         return 0;
162 }
163
164 static int omap3evm_panel_suspend(struct platform_device *pdev,
165                                    pm_message_t mesg)
166 {
167         return 0;
168 }
169
170 static int omap3evm_panel_resume(struct platform_device *pdev)
171 {
172         return 0;
173 }
174
175 struct platform_driver omap3evm_panel_driver = {
176         .probe          = omap3evm_panel_probe,
177         .remove         = omap3evm_panel_remove,
178         .suspend        = omap3evm_panel_suspend,
179         .resume         = omap3evm_panel_resume,
180         .driver         = {
181                 .name   = "omap3evm_lcd",
182                 .owner  = THIS_MODULE,
183         },
184 };
185
186 static int __init omap3evm_panel_drv_init(void)
187 {
188         return platform_driver_register(&omap3evm_panel_driver);
189 }
190
191 static void __exit omap3evm_panel_drv_exit(void)
192 {
193         platform_driver_unregister(&omap3evm_panel_driver);
194 }
195
196 module_init(omap3evm_panel_drv_init);
197 module_exit(omap3evm_panel_drv_exit);