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_ldp.c
blob0f5952cae85e6b2ddfd47ffd66ac1c0f7c88a919
1 /*
2 * LCD panel support for the TI LDP board
4 * Copyright (C) 2007 WindRiver
5 * Author: Stanley Miao <stanley.miao@windriver.com>
7 * Derived from drivers/video/omap/lcd-2430sdp.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/i2c/twl.h>
29 #include <mach/gpio.h>
30 #include <plat/mux.h>
31 #include <asm/mach-types.h>
33 #include "omapfb.h"
35 #define LCD_PANEL_BACKLIGHT_GPIO (15 + OMAP_MAX_GPIO_LINES)
36 #define LCD_PANEL_ENABLE_GPIO (7 + OMAP_MAX_GPIO_LINES)
38 #define LCD_PANEL_RESET_GPIO 55
39 #define LCD_PANEL_QVGA_GPIO 56
41 #ifdef CONFIG_FB_OMAP_LCD_VGA
42 #define LCD_XRES 480
43 #define LCD_YRES 640
44 #define LCD_PIXCLOCK_MAX 41700
45 #else
46 #define LCD_XRES 240
47 #define LCD_YRES 320
48 #define LCD_PIXCLOCK_MAX 185186
49 #endif
51 #define PM_RECEIVER TWL4030_MODULE_PM_RECEIVER
52 #define ENABLE_VAUX2_DEDICATED 0x09
53 #define ENABLE_VAUX2_DEV_GRP 0x20
54 #define ENABLE_VAUX3_DEDICATED 0x03
55 #define ENABLE_VAUX3_DEV_GRP 0x20
57 #define ENABLE_VPLL2_DEDICATED 0x05
58 #define ENABLE_VPLL2_DEV_GRP 0xE0
59 #define TWL4030_VPLL2_DEV_GRP 0x33
60 #define TWL4030_VPLL2_DEDICATED 0x36
62 #define t2_out(c, r, v) twl_i2c_write_u8(c, r, v)
65 static int ldp_panel_init(struct lcd_panel *panel,
66 struct omapfb_device *fbdev)
68 gpio_request(LCD_PANEL_RESET_GPIO, "lcd reset");
69 gpio_request(LCD_PANEL_QVGA_GPIO, "lcd qvga");
70 gpio_request(LCD_PANEL_ENABLE_GPIO, "lcd panel");
71 gpio_request(LCD_PANEL_BACKLIGHT_GPIO, "lcd backlight");
73 gpio_direction_output(LCD_PANEL_QVGA_GPIO, 0);
74 gpio_direction_output(LCD_PANEL_RESET_GPIO, 0);
75 gpio_direction_output(LCD_PANEL_ENABLE_GPIO, 0);
76 gpio_direction_output(LCD_PANEL_BACKLIGHT_GPIO, 0);
78 #ifdef CONFIG_FB_OMAP_LCD_VGA
79 gpio_set_value(LCD_PANEL_QVGA_GPIO, 0);
80 #else
81 gpio_set_value(LCD_PANEL_QVGA_GPIO, 1);
82 #endif
83 gpio_set_value(LCD_PANEL_RESET_GPIO, 1);
85 return 0;
88 static void ldp_panel_cleanup(struct lcd_panel *panel)
90 gpio_free(LCD_PANEL_BACKLIGHT_GPIO);
91 gpio_free(LCD_PANEL_ENABLE_GPIO);
92 gpio_free(LCD_PANEL_QVGA_GPIO);
93 gpio_free(LCD_PANEL_RESET_GPIO);
96 static int ldp_panel_enable(struct lcd_panel *panel)
98 if (0 != t2_out(PM_RECEIVER, ENABLE_VPLL2_DEDICATED,
99 TWL4030_VPLL2_DEDICATED))
100 return -EIO;
101 if (0 != t2_out(PM_RECEIVER, ENABLE_VPLL2_DEV_GRP,
102 TWL4030_VPLL2_DEV_GRP))
103 return -EIO;
105 gpio_direction_output(LCD_PANEL_ENABLE_GPIO, 1);
106 gpio_direction_output(LCD_PANEL_BACKLIGHT_GPIO, 1);
108 if (0 != t2_out(PM_RECEIVER, ENABLE_VAUX3_DEDICATED,
109 TWL4030_VAUX3_DEDICATED))
110 return -EIO;
111 if (0 != t2_out(PM_RECEIVER, ENABLE_VAUX3_DEV_GRP,
112 TWL4030_VAUX3_DEV_GRP))
113 return -EIO;
115 return 0;
118 static void ldp_panel_disable(struct lcd_panel *panel)
120 gpio_direction_output(LCD_PANEL_ENABLE_GPIO, 0);
121 gpio_direction_output(LCD_PANEL_BACKLIGHT_GPIO, 0);
123 t2_out(PM_RECEIVER, 0x0, TWL4030_VPLL2_DEDICATED);
124 t2_out(PM_RECEIVER, 0x0, TWL4030_VPLL2_DEV_GRP);
125 msleep(4);
128 static unsigned long ldp_panel_get_caps(struct lcd_panel *panel)
130 return 0;
133 struct lcd_panel ldp_panel = {
134 .name = "ldp",
135 .config = OMAP_LCDC_PANEL_TFT | OMAP_LCDC_INV_VSYNC |
136 OMAP_LCDC_INV_HSYNC,
138 .bpp = 16,
139 .data_lines = 18,
140 .x_res = LCD_XRES,
141 .y_res = LCD_YRES,
142 .hsw = 3, /* hsync_len (4) - 1 */
143 .hfp = 3, /* right_margin (4) - 1 */
144 .hbp = 39, /* left_margin (40) - 1 */
145 .vsw = 1, /* vsync_len (2) - 1 */
146 .vfp = 2, /* lower_margin */
147 .vbp = 7, /* upper_margin (8) - 1 */
149 .pixel_clock = LCD_PIXCLOCK_MAX,
151 .init = ldp_panel_init,
152 .cleanup = ldp_panel_cleanup,
153 .enable = ldp_panel_enable,
154 .disable = ldp_panel_disable,
155 .get_caps = ldp_panel_get_caps,
158 static int ldp_panel_probe(struct platform_device *pdev)
160 omapfb_register_panel(&ldp_panel);
161 return 0;
164 static int ldp_panel_remove(struct platform_device *pdev)
166 return 0;
169 static int ldp_panel_suspend(struct platform_device *pdev, pm_message_t mesg)
171 return 0;
174 static int ldp_panel_resume(struct platform_device *pdev)
176 return 0;
179 struct platform_driver ldp_panel_driver = {
180 .probe = ldp_panel_probe,
181 .remove = ldp_panel_remove,
182 .suspend = ldp_panel_suspend,
183 .resume = ldp_panel_resume,
184 .driver = {
185 .name = "ldp_lcd",
186 .owner = THIS_MODULE,
190 static int __init ldp_panel_drv_init(void)
192 return platform_driver_register(&ldp_panel_driver);
195 static void __exit ldp_panel_drv_exit(void)
197 platform_driver_unregister(&ldp_panel_driver);
200 module_init(ldp_panel_drv_init);
201 module_exit(ldp_panel_drv_exit);