]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - drivers/video/omap/lcd_2430sdp.c
Merge current mainline tree into linux-omap tree
[linux-2.6-omap-h63xx.git] / drivers / video / omap / lcd_2430sdp.c
1 /*
2  * LCD panel support for the TI 2430SDP board
3  *
4  * Copyright (C) 2007 MontaVista
5  * Author: Hunyue Yau <hyau@mvista.com>
6  *
7  * Derived from drivers/video/omap/lcd-apollon.c
8  *
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.
13  *
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.
18  *
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.
22  */
23
24 #include <linux/module.h>
25 #include <linux/platform_device.h>
26 #include <linux/i2c/twl4030.h>
27
28 #include <mach/gpio.h>
29 #include <mach/mux.h>
30 #include <mach/omapfb.h>
31 #include <asm/mach-types.h>
32
33 #define SDP2430_LCD_PANEL_BACKLIGHT_GPIO        91
34 #define SDP2430_LCD_PANEL_ENABLE_GPIO           154
35 #define SDP3430_LCD_PANEL_BACKLIGHT_GPIO        24
36 #define SDP3430_LCD_PANEL_ENABLE_GPIO           28
37
38 static unsigned backlight_gpio;
39 static unsigned enable_gpio;
40
41 #define LCD_PIXCLOCK_MAX                5400 /* freq 5.4 MHz */
42 #define PM_RECEIVER             TWL4030_MODULE_PM_RECEIVER
43 #define ENABLE_VAUX2_DEDICATED  0x09
44 #define ENABLE_VAUX2_DEV_GRP    0x20
45 #define ENABLE_VAUX3_DEDICATED  0x03
46 #define ENABLE_VAUX3_DEV_GRP    0x20
47
48
49 #define t2_out(c, r, v) twl4030_i2c_write_u8(c, r, v)
50
51
52 static int sdp2430_panel_init(struct lcd_panel *panel,
53                                 struct omapfb_device *fbdev)
54 {
55         if (machine_is_omap_3430sdp()) {
56                 enable_gpio    = SDP3430_LCD_PANEL_ENABLE_GPIO;
57                 backlight_gpio = SDP3430_LCD_PANEL_BACKLIGHT_GPIO;
58         } else {
59                 enable_gpio    = SDP2430_LCD_PANEL_ENABLE_GPIO;
60                 backlight_gpio = SDP2430_LCD_PANEL_BACKLIGHT_GPIO;
61         }
62
63         omap_request_gpio(enable_gpio);                 /* LCD panel */
64         omap_request_gpio(backlight_gpio);              /* LCD backlight */
65         omap_set_gpio_direction(enable_gpio, 0);        /* output */
66         omap_set_gpio_direction(backlight_gpio, 0);     /* output */
67
68         return 0;
69 }
70
71 static void sdp2430_panel_cleanup(struct lcd_panel *panel)
72 {
73 }
74
75 static int sdp2430_panel_enable(struct lcd_panel *panel)
76 {
77         u8 ded_val, ded_reg;
78         u8 grp_val, grp_reg;
79
80         if (machine_is_omap_3430sdp()) {
81                 ded_reg = TWL4030_VAUX3_DEDICATED;
82                 ded_val = ENABLE_VAUX3_DEDICATED;
83                 grp_reg = TWL4030_VAUX3_DEV_GRP;
84                 grp_val = ENABLE_VAUX3_DEV_GRP;
85         } else {
86                 ded_reg = TWL4030_VAUX2_DEDICATED;
87                 ded_val = ENABLE_VAUX2_DEDICATED;
88                 grp_reg = TWL4030_VAUX2_DEV_GRP;
89                 grp_val = ENABLE_VAUX2_DEV_GRP;
90         }
91                 
92         omap_set_gpio_dataout(enable_gpio, 1);
93         omap_set_gpio_dataout(backlight_gpio, 1);
94
95         if (0 != t2_out(PM_RECEIVER, ded_val, ded_reg))
96                 return -EIO;
97         if (0 != t2_out(PM_RECEIVER, grp_val, grp_reg))
98                 return -EIO;
99
100         return 0;
101 }
102
103 static void sdp2430_panel_disable(struct lcd_panel *panel)
104 {
105         omap_set_gpio_dataout(enable_gpio, 0);
106         omap_set_gpio_dataout(backlight_gpio, 0);
107 }
108
109 static unsigned long sdp2430_panel_get_caps(struct lcd_panel *panel)
110 {
111         return 0;
112 }
113
114 struct lcd_panel sdp2430_panel = {
115         .name           = "sdp2430",
116         .config         = OMAP_LCDC_PANEL_TFT | OMAP_LCDC_INV_VSYNC |
117                           OMAP_LCDC_INV_HSYNC,
118
119         .bpp            = 16,
120         .data_lines     = 16,
121         .x_res          = 240,
122         .y_res          = 320,
123         .hsw            = 3,            /* hsync_len (4) - 1 */
124         .hfp            = 3,            /* right_margin (4) - 1 */
125         .hbp            = 39,           /* left_margin (40) - 1 */
126         .vsw            = 1,            /* vsync_len (2) - 1 */
127         .vfp            = 2,            /* lower_margin */
128         .vbp            = 7,            /* upper_margin (8) - 1 */
129
130         .pixel_clock    = LCD_PIXCLOCK_MAX,
131
132         .init           = sdp2430_panel_init,
133         .cleanup        = sdp2430_panel_cleanup,
134         .enable         = sdp2430_panel_enable,
135         .disable        = sdp2430_panel_disable,
136         .get_caps       = sdp2430_panel_get_caps,
137 };
138
139 static int sdp2430_panel_probe(struct platform_device *pdev)
140 {
141         omapfb_register_panel(&sdp2430_panel);
142         return 0;
143 }
144
145 static int sdp2430_panel_remove(struct platform_device *pdev)
146 {
147         return 0;
148 }
149
150 static int sdp2430_panel_suspend(struct platform_device *pdev, pm_message_t mesg)
151 {
152         return 0;
153 }
154
155 static int sdp2430_panel_resume(struct platform_device *pdev)
156 {
157         return 0;
158 }
159
160 struct platform_driver sdp2430_panel_driver = {
161         .probe          = sdp2430_panel_probe,
162         .remove         = sdp2430_panel_remove,
163         .suspend        = sdp2430_panel_suspend,
164         .resume         = sdp2430_panel_resume,
165         .driver         = {
166                 .name   = "sdp2430_lcd",
167                 .owner  = THIS_MODULE,
168         },
169 };
170
171 static int __init sdp2430_panel_drv_init(void)
172 {
173         return platform_driver_register(&sdp2430_panel_driver);
174 }
175
176 static void __exit sdp2430_panel_drv_exit(void)
177 {
178         platform_driver_unregister(&sdp2430_panel_driver);
179 }
180
181 module_init(sdp2430_panel_drv_init);
182 module_exit(sdp2430_panel_drv_exit);