]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - drivers/video/omap/lcd_3430sdp.c
Revert "OMAP: DISPC: Fix to disable also interface clocks. 2nd."
[linux-2.6-omap-h63xx.git] / drivers / video / omap / lcd_3430sdp.c
1 /*
2  * LCD panel support for the TI 3430SDP board
3  *
4  * Copyright (C) 2008 Texas Instruments
5  * Author: Iqbal Shareef <iqbal@ti.com>
6  *
7  * Derived from drivers/video/omap/lcd_2430sdp.c
8  * Copyright (C) 2007 MontaVista
9  * Author: Hunyue Yau <hyau@mvista.com>
10  *
11  * This program is free software; you can redistribute it and/or modify it
12  * under the terms of the GNU General Public License as published by the
13  * Free Software Foundation; either version 2 of the License, or (at your
14  * option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful, but
17  * WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License along
22  * with this program; if not, write to the Free Software Foundation, Inc.,
23  * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24  */
25
26 #include <linux/module.h>
27 #include <linux/platform_device.h>
28 #include <linux/i2c/twl4030.h>
29
30 #include <asm/arch/gpio.h>
31 #include <asm/arch/omapfb.h>
32
33 #define SDP3430_LCD_PANEL_BACKLIGHT_GPIO        8
34 #define SDP3430_LCD_PANEL_ENABLE_GPIO           5
35
36 static unsigned backlight_gpio;
37 static unsigned enable_gpio;
38
39 #define LCD_PIXCLOCK_MAX                        167000
40 #define ENABLE_VAUX2_DEDICATED                  0x03
41 #define ENABLE_VAUX2_DEV_GRP                    0x20
42 #define ENABLE_VAUX3_DEDICATED                  0x05
43 #define ENABLE_VAUX3_DEV_GRP                    0xE0
44
45 static int sdp3430_panel_init(struct lcd_panel *panel,
46                                 struct omapfb_device *fbdev)
47 {
48         enable_gpio    = SDP3430_LCD_PANEL_ENABLE_GPIO;
49         backlight_gpio = SDP3430_LCD_PANEL_BACKLIGHT_GPIO;
50
51         omap_request_gpio(enable_gpio);                 /* LCD panel */
52         omap_request_gpio(backlight_gpio);              /* LCD backlight */
53         omap_set_gpio_direction(enable_gpio, 0);        /* output */
54         omap_set_gpio_direction(backlight_gpio, 0);     /* output */
55
56         return 0;
57 }
58
59 static void sdp3430_panel_cleanup(struct lcd_panel *panel)
60 {
61         omap_free_gpio(backlight_gpio);
62         omap_free_gpio(enable_gpio);
63 }
64
65 static int sdp3430_panel_enable(struct lcd_panel *panel)
66 {
67         omap_set_gpio_dataout(enable_gpio, 1);
68         omap_set_gpio_dataout(backlight_gpio, 1);
69
70         if (0 != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, ENABLE_VAUX3_DEDICATED,
71                                         TWL4030_VAUX3_DEDICATED))
72                 return -EIO;
73         if (0 != twl4030_i2c_write_u8(PM_RECEIVER, ENABLE_VAUX3_DEV_GRP,
74                                         TWL4030_VAUX3_DEV_GRP))
75                 return -EIO;
76
77         return 0;
78 }
79
80 static void sdp3430_panel_disable(struct lcd_panel *panel)
81 {
82         omap_set_gpio_dataout(enable_gpio, 0);
83         omap_set_gpio_dataout(backlight_gpio, 0);
84 }
85
86 static unsigned long sdp3430_panel_get_caps(struct lcd_panel *panel)
87 {
88         return 0;
89 }
90
91 struct lcd_panel sdp3430_panel = {
92         .name           = "sdp3430",
93         .config         = OMAP_LCDC_PANEL_TFT | OMAP_LCDC_INV_VSYNC |
94                           OMAP_LCDC_INV_HSYNC,
95
96         .bpp            = 16,
97         .data_lines     = 16,
98         .x_res          = 240,
99         .y_res          = 320,
100         .hsw            = 3,            /* hsync_len (4) - 1 */
101         .hfp            = 3,            /* right_margin (4) - 1 */
102         .hbp            = 39,           /* left_margin (40) - 1 */
103         .vsw            = 1,            /* vsync_len (2) - 1 */
104         .vfp            = 2,            /* lower_margin */
105         .vbp            = 7,            /* upper_margin (8) - 1 */
106
107         .pixel_clock    = LCD_PIXCLOCK_MAX,
108
109         .init           = sdp3430_panel_init,
110         .cleanup        = sdp3430_panel_cleanup,
111         .enable         = sdp3430_panel_enable,
112         .disable        = sdp3430_panel_disable,
113         .get_caps       = sdp3430_panel_get_caps,
114 };
115
116 static int sdp3430_panel_probe(struct platform_device *pdev)
117 {
118         omapfb_register_panel(&sdp3430_panel);
119         return 0;
120 }
121
122 static int sdp3430_panel_remove(struct platform_device *pdev)
123 {
124         return 0;
125 }
126
127 static int sdp3430_panel_suspend(struct platform_device *pdev,
128                                         pm_message_t mesg)
129 {
130         return 0;
131 }
132
133 static int sdp3430_panel_resume(struct platform_device *pdev)
134 {
135         return 0;
136 }
137
138 struct platform_driver sdp3430_panel_driver = {
139         .probe          = sdp3430_panel_probe,
140         .remove         = sdp3430_panel_remove,
141         .suspend        = sdp3430_panel_suspend,
142         .resume         = sdp3430_panel_resume,
143         .driver         = {
144                 .name           = "sdp3430_lcd",
145                 .owner          = THIS_MODULE,
146         },
147 };
148
149 static int __init sdp3430_panel_drv_init(void)
150 {
151         return platform_driver_register(&sdp3430_panel_driver);
152 }
153
154 static void __exit sdp3430_panel_drv_exit(void)
155 {
156         platform_driver_unregister(&sdp3430_panel_driver);
157 }
158
159 module_init(sdp3430_panel_drv_init);
160 module_exit(sdp3430_panel_drv_exit);
161
162 MODULE_ALIAS("platform:sdp3430_lcd");