Add linux-next specific files for 20110831
[linux-2.6/next.git] / drivers / video / omap / lcd_2430sdp.c
blobe3eccc9af78e3c18f8b4b2ec5c2f98bcac7ee464
1 /*
2 * LCD panel support for the TI 2430SDP board
4 * Copyright (C) 2007 MontaVista
5 * Author: Hunyue Yau <hyau@mvista.com>
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/delay.h>
27 #include <linux/gpio.h>
28 #include <linux/i2c/twl.h>
30 #include <plat/mux.h>
31 #include <asm/mach-types.h>
33 #include "omapfb.h"
35 #define SDP2430_LCD_PANEL_BACKLIGHT_GPIO 91
36 #define SDP2430_LCD_PANEL_ENABLE_GPIO 154
37 #define SDP3430_LCD_PANEL_BACKLIGHT_GPIO 24
38 #define SDP3430_LCD_PANEL_ENABLE_GPIO 28
40 static unsigned backlight_gpio;
41 static unsigned enable_gpio;
43 #define LCD_PIXCLOCK_MAX 5400 /* freq 5.4 MHz */
44 #define PM_RECEIVER TWL4030_MODULE_PM_RECEIVER
45 #define ENABLE_VAUX2_DEDICATED 0x09
46 #define ENABLE_VAUX2_DEV_GRP 0x20
47 #define ENABLE_VAUX3_DEDICATED 0x03
48 #define ENABLE_VAUX3_DEV_GRP 0x20
50 #define ENABLE_VPLL2_DEDICATED 0x05
51 #define ENABLE_VPLL2_DEV_GRP 0xE0
52 #define TWL4030_VPLL2_DEV_GRP 0x33
53 #define TWL4030_VPLL2_DEDICATED 0x36
55 #define t2_out(c, r, v) twl_i2c_write_u8(c, r, v)
58 static int sdp2430_panel_init(struct lcd_panel *panel,
59 struct omapfb_device *fbdev)
61 if (machine_is_omap_3430sdp()) {
62 enable_gpio = SDP3430_LCD_PANEL_ENABLE_GPIO;
63 backlight_gpio = SDP3430_LCD_PANEL_BACKLIGHT_GPIO;
64 } else {
65 enable_gpio = SDP2430_LCD_PANEL_ENABLE_GPIO;
66 backlight_gpio = SDP2430_LCD_PANEL_BACKLIGHT_GPIO;
69 gpio_request(enable_gpio, "LCD enable"); /* LCD panel */
70 gpio_request(backlight_gpio, "LCD bl"); /* LCD backlight */
71 gpio_direction_output(enable_gpio, 0);
72 gpio_direction_output(backlight_gpio, 0);
74 return 0;
77 static void sdp2430_panel_cleanup(struct lcd_panel *panel)
79 gpio_free(backlight_gpio);
80 gpio_free(enable_gpio);
83 static int sdp2430_panel_enable(struct lcd_panel *panel)
85 u8 ded_val, ded_reg;
86 u8 grp_val, grp_reg;
88 if (machine_is_omap_3430sdp()) {
89 ded_reg = TWL4030_VAUX3_DEDICATED;
90 ded_val = ENABLE_VAUX3_DEDICATED;
91 grp_reg = TWL4030_VAUX3_DEV_GRP;
92 grp_val = ENABLE_VAUX3_DEV_GRP;
94 if (omap_rev() > OMAP3430_REV_ES1_0) {
95 t2_out(PM_RECEIVER, ENABLE_VPLL2_DEDICATED,
96 TWL4030_VPLL2_DEDICATED);
97 t2_out(PM_RECEIVER, ENABLE_VPLL2_DEV_GRP,
98 TWL4030_VPLL2_DEV_GRP);
100 } else {
101 ded_reg = TWL4030_VAUX2_DEDICATED;
102 ded_val = ENABLE_VAUX2_DEDICATED;
103 grp_reg = TWL4030_VAUX2_DEV_GRP;
104 grp_val = ENABLE_VAUX2_DEV_GRP;
107 gpio_set_value(enable_gpio, 1);
108 gpio_set_value(backlight_gpio, 1);
110 if (0 != t2_out(PM_RECEIVER, ded_val, ded_reg))
111 return -EIO;
112 if (0 != t2_out(PM_RECEIVER, grp_val, grp_reg))
113 return -EIO;
115 return 0;
118 static void sdp2430_panel_disable(struct lcd_panel *panel)
120 gpio_set_value(enable_gpio, 0);
121 gpio_set_value(backlight_gpio, 0);
122 if (omap_rev() > OMAP3430_REV_ES1_0) {
123 t2_out(PM_RECEIVER, 0x0, TWL4030_VPLL2_DEDICATED);
124 t2_out(PM_RECEIVER, 0x0, TWL4030_VPLL2_DEV_GRP);
125 msleep(4);
129 static unsigned long sdp2430_panel_get_caps(struct lcd_panel *panel)
131 return 0;
134 struct lcd_panel sdp2430_panel = {
135 .name = "sdp2430",
136 .config = OMAP_LCDC_PANEL_TFT | OMAP_LCDC_INV_VSYNC |
137 OMAP_LCDC_INV_HSYNC,
139 .bpp = 16,
140 .data_lines = 16,
141 .x_res = 240,
142 .y_res = 320,
143 .hsw = 3, /* hsync_len (4) - 1 */
144 .hfp = 3, /* right_margin (4) - 1 */
145 .hbp = 39, /* left_margin (40) - 1 */
146 .vsw = 1, /* vsync_len (2) - 1 */
147 .vfp = 2, /* lower_margin */
148 .vbp = 7, /* upper_margin (8) - 1 */
150 .pixel_clock = LCD_PIXCLOCK_MAX,
152 .init = sdp2430_panel_init,
153 .cleanup = sdp2430_panel_cleanup,
154 .enable = sdp2430_panel_enable,
155 .disable = sdp2430_panel_disable,
156 .get_caps = sdp2430_panel_get_caps,
159 static int sdp2430_panel_probe(struct platform_device *pdev)
161 omapfb_register_panel(&sdp2430_panel);
162 return 0;
165 static int sdp2430_panel_remove(struct platform_device *pdev)
167 return 0;
170 static int sdp2430_panel_suspend(struct platform_device *pdev,
171 pm_message_t mesg)
173 return 0;
176 static int sdp2430_panel_resume(struct platform_device *pdev)
178 return 0;
181 struct platform_driver sdp2430_panel_driver = {
182 .probe = sdp2430_panel_probe,
183 .remove = sdp2430_panel_remove,
184 .suspend = sdp2430_panel_suspend,
185 .resume = sdp2430_panel_resume,
186 .driver = {
187 .name = "sdp2430_lcd",
188 .owner = THIS_MODULE,
192 static int __init sdp2430_panel_drv_init(void)
194 return platform_driver_register(&sdp2430_panel_driver);
197 static void __exit sdp2430_panel_drv_exit(void)
199 platform_driver_unregister(&sdp2430_panel_driver);
202 module_init(sdp2430_panel_drv_init);
203 module_exit(sdp2430_panel_drv_exit);