Switch to experimental 60Hz settings
[pandora-kernel.git] / drivers / video / omap / lcd_omap3pandora.c
1 /*
2  * LCD panel support for OMAP3 Pandora
3  *
4  * Derived from drivers/video/omap/lcd_omap3evm.c
5  * Derived from drivers/video/omap/lcd-apollon.c
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the
9  * Free Software Foundation; either version 2 of the License, or (at your
10  * option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20  */
21
22 #include <linux/module.h>
23 #include <linux/platform_device.h>
24 #include <linux/i2c/twl4030.h>
25
26 #include <mach/gpio.h>
27 #include <mach/mux.h>
28 #include <mach/omapfb.h>
29 #include <asm/mach-types.h>
30
31 //#define LCD_PANEL_ENABLE_GPIO 154
32 //#define TWL_PWMA_PWMAOFF      0x01
33
34 #define LCD_XRES                800
35 #define LCD_YRES                480
36 #define LCD_PIXCLOCK            36000 /* in kHz */
37
38 static unsigned int bklight_level;
39
40 static int omap3pandora_panel_init(struct lcd_panel *panel,
41                                 struct omapfb_device *fbdev)
42 {
43         bklight_level = 100;
44
45         return 0;
46 }
47
48 static void omap3pandora_panel_cleanup(struct lcd_panel *panel)
49 {
50 }
51
52 static int omap3pandora_panel_enable(struct lcd_panel *panel)
53 {
54 //      omap_set_gpio_dataout(LCD_PANEL_ENABLE_GPIO, 0);
55         return 0;
56 }
57
58 static void omap3pandora_panel_disable(struct lcd_panel *panel)
59 {
60 //      omap_set_gpio_dataout(LCD_PANEL_ENABLE_GPIO, 1);
61 }
62
63 static unsigned long omap3pandora_panel_get_caps(struct lcd_panel *panel)
64 {
65         return 0;
66 }
67
68 static int omap3pandora_bklight_setlevel(struct lcd_panel *panel,
69                                                 unsigned int level)
70 {
71 /*
72         u8 c;
73         if ((level >= 0) && (level <= 100)) {
74                 c = (125 * (100 - level)) / 100 + 2;
75                 twl4030_i2c_write_u8(TWL4030_MODULE_PWMA, c, TWL_PWMA_PWMAOFF);
76                 bklight_level = level;
77         }
78 */
79         return 0;
80 }
81
82 static unsigned int omap3pandora_bklight_getlevel(struct lcd_panel *panel)
83 {
84         return bklight_level;
85 }
86
87 static unsigned int omap3pandora_bklight_getmaxlevel(struct lcd_panel *panel)
88 {
89         return 100;
90 }
91
92 struct lcd_panel omap3pandora_panel = {
93         .name           = "omap3pandora",
94         .config         = OMAP_LCDC_PANEL_TFT | OMAP_LCDC_INV_VSYNC |
95                           OMAP_LCDC_INV_HSYNC | OMAP_LCDC_INV_PIX_CLOCK,
96
97         .bpp            = 16,
98         .data_lines     = 24,
99         .x_res          = LCD_XRES,
100         .y_res          = LCD_YRES,
101
102         .hsw            = 1,            /* hsync_len */
103         .hfp            = 68,           /* right_margin */
104         .hbp            = 214,          /* left_margin */
105         .vsw            = 1,            /* vsync_len */
106         .vfp            = 39,           /* lower_margin */
107         .vbp            = 34,           /* upper_margin */
108
109         .acb            = 0x28,         /* ac-bias pin frequency */
110         .pcd            = 0,            /* pixel clock divider. Unused */
111
112         .pixel_clock    = LCD_PIXCLOCK,
113
114         .init           = omap3pandora_panel_init,
115         .cleanup        = omap3pandora_panel_cleanup,
116         .enable         = omap3pandora_panel_enable,
117         .disable        = omap3pandora_panel_disable,
118         .get_caps       = omap3pandora_panel_get_caps,
119         .set_bklight_level      = omap3pandora_bklight_setlevel,
120         .get_bklight_level      = omap3pandora_bklight_getlevel,
121         .get_bklight_max        = omap3pandora_bklight_getmaxlevel,
122 };
123
124 static int omap3pandora_panel_probe(struct platform_device *pdev)
125 {
126         omapfb_register_panel(&omap3pandora_panel);
127         return 0;
128 }
129
130 static int omap3pandora_panel_remove(struct platform_device *pdev)
131 {
132         return 0;
133 }
134
135 static int omap3pandora_panel_suspend(struct platform_device *pdev,
136                                    pm_message_t mesg)
137 {
138         return 0;
139 }
140
141 static int omap3pandora_panel_resume(struct platform_device *pdev)
142 {
143         return 0;
144 }
145
146 struct platform_driver omap3pandora_panel_driver = {
147         .probe          = omap3pandora_panel_probe,
148         .remove         = omap3pandora_panel_remove,
149         .suspend        = omap3pandora_panel_suspend,
150         .resume         = omap3pandora_panel_resume,
151         .driver         = {
152                 .name   = "pandora_lcd",
153                 .owner  = THIS_MODULE,
154         },
155 };
156
157 static int __init omap3pandora_panel_drv_init(void)
158 {
159         return platform_driver_register(&omap3pandora_panel_driver);
160 }
161
162 static void __exit omap3pandora_panel_drv_exit(void)
163 {
164         platform_driver_unregister(&omap3pandora_panel_driver);
165 }
166
167 module_init(omap3pandora_panel_drv_init);
168 module_exit(omap3pandora_panel_drv_exit);