]> 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 <asm/arch/gpio.h>
28 #include <asm/arch/mux.h>
29 #include <asm/arch/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_MAX        41700 /* in pico seconds  */
42 #define LCD_PIXCLOCK_MIN        38000 /* in pico seconds */
43
44 #define ENABLE_VDAC_DEDICATED   0x03
45 #define ENABLE_VDAC_DEV_GRP     0x20
46 #define ENABLE_VPLL2_DEDICATED  0x05
47 #define ENABLE_VPLL2_DEV_GRP    0xE0
48
49 static int omap3evm_panel_init(struct lcd_panel *panel,
50                                 struct omapfb_device *fbdev)
51 {
52         omap_request_gpio(LCD_PANEL_LR);
53         omap_request_gpio(LCD_PANEL_UD);
54         omap_request_gpio(LCD_PANEL_INI);
55         omap_request_gpio(LCD_PANEL_RESB);
56         omap_request_gpio(LCD_PANEL_QVGA);
57
58         omap_set_gpio_direction(LCD_PANEL_LR, 0);
59         omap_set_gpio_direction(LCD_PANEL_UD, 0);
60         omap_set_gpio_direction(LCD_PANEL_INI, 0);
61         omap_set_gpio_direction(LCD_PANEL_RESB, 0);
62         omap_set_gpio_direction(LCD_PANEL_QVGA, 0);
63
64         twl4030_i2c_write_u8(TWL4030_MODULE_PWMA, 0x7F, 0);
65         twl4030_i2c_write_u8(TWL4030_MODULE_PWMA, 0x7F, 1);
66         twl4030_i2c_write_u8(TWL4030_MODULE_PWMB, 0x7F, 0);
67         twl4030_i2c_write_u8(TWL4030_MODULE_PWMB, 0x7F, 1);
68
69         omap_set_gpio_dataout(LCD_PANEL_RESB, 1);
70         omap_set_gpio_dataout(LCD_PANEL_INI, 1);
71         omap_set_gpio_dataout(LCD_PANEL_QVGA, 0);
72         omap_set_gpio_dataout(LCD_PANEL_LR, 1);
73         omap_set_gpio_dataout(LCD_PANEL_UD, 1);
74
75         return 0;
76 }
77
78 static void omap3evm_panel_cleanup(struct lcd_panel *panel)
79 {
80 }
81
82 static int omap3evm_panel_enable(struct lcd_panel *panel)
83 {
84         omap_set_gpio_dataout(LCD_PANEL_ENABLE_GPIO, 0);
85         return 0;
86 }
87
88 static void omap3evm_panel_disable(struct lcd_panel *panel)
89 {
90         omap_set_gpio_dataout(LCD_PANEL_ENABLE_GPIO, 1);
91 }
92
93 static unsigned long omap3evm_panel_get_caps(struct lcd_panel *panel)
94 {
95         return 0;
96 }
97
98 struct lcd_panel omap3evm_panel = {
99         .name           = "omap3evm",
100         .config         = OMAP_LCDC_PANEL_TFT | OMAP_LCDC_INV_VSYNC |
101                           OMAP_LCDC_INV_HSYNC,
102
103         .bpp            = 16,
104         .data_lines     = 18,
105         .x_res          = LCD_XRES,
106         .y_res          = LCD_YRES,
107         .hsw            = 3,            /* hsync_len (4) - 1 */
108         .hfp            = 3,            /* right_margin (4) - 1 */
109         .hbp            = 39,           /* left_margin (40) - 1 */
110         .vsw            = 1,            /* vsync_len (2) - 1 */
111         .vfp            = 2,            /* lower_margin */
112         .vbp            = 7,            /* upper_margin (8) - 1 */
113
114         .pixel_clock    = LCD_PIXCLOCK_MAX,
115
116         .init           = omap3evm_panel_init,
117         .cleanup        = omap3evm_panel_cleanup,
118         .enable         = omap3evm_panel_enable,
119         .disable        = omap3evm_panel_disable,
120         .get_caps       = omap3evm_panel_get_caps,
121 };
122
123 static int omap3evm_panel_probe(struct platform_device *pdev)
124 {
125         omapfb_register_panel(&omap3evm_panel);
126         return 0;
127 }
128
129 static int omap3evm_panel_remove(struct platform_device *pdev)
130 {
131         return 0;
132 }
133
134 static int omap3evm_panel_suspend(struct platform_device *pdev,
135                                    pm_message_t mesg)
136 {
137         return 0;
138 }
139
140 static int omap3evm_panel_resume(struct platform_device *pdev)
141 {
142         return 0;
143 }
144
145 struct platform_driver omap3evm_panel_driver = {
146         .probe          = omap3evm_panel_probe,
147         .remove         = omap3evm_panel_remove,
148         .suspend        = omap3evm_panel_suspend,
149         .resume         = omap3evm_panel_resume,
150         .driver         = {
151                 .name   = "omap3evm_lcd",
152                 .owner  = THIS_MODULE,
153         },
154 };
155
156 static int __init omap3evm_panel_drv_init(void)
157 {
158         return platform_driver_register(&omap3evm_panel_driver);
159 }
160
161 static void __exit omap3evm_panel_drv_exit(void)
162 {
163         platform_driver_unregister(&omap3evm_panel_driver);
164 }
165
166 module_init(omap3evm_panel_drv_init);
167 module_exit(omap3evm_panel_drv_exit);