1 /*
2 * LCD panel support for the TI OMAP3 EVM board
3 *
4 * Author: Steve Sakoman <steve@sakoman.com>
5 *
6 * Derived from drivers/video/omap/lcd-apollon.c
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 */
22
23 #include <linux/module.h>
24 #include <linux/platform_device.h>
25 #include <linux/gpio.h>
26 #include <linux/i2c/twl.h>
27
28 #include <plat/mux.h>
29 #include <asm/mach-types.h>
30
31 #include "omapfb.h"
32
33 #define LCD_PANEL_ENABLE_GPIO 153
34 #define LCD_PANEL_LR 2
35 #define LCD_PANEL_UD 3
36 #define LCD_PANEL_INI 152
37 #define LCD_PANEL_QVGA 154
38 #define LCD_PANEL_RESB 155
39
40 #define ENABLE_VDAC_DEDICATED 0x03
41 #define ENABLE_VDAC_DEV_GRP 0x20
42 #define ENABLE_VPLL2_DEDICATED 0x05
43 #define ENABLE_VPLL2_DEV_GRP 0xE0
44
45 #define TWL_LED_LEDEN 0x00
46 #define TWL_PWMA_PWMAON 0x00
47 #define TWL_PWMA_PWMAOFF 0x01
48
49 static unsigned int bklight_level;
50
omap3evm_panel_init(struct lcd_panel * panel,struct omapfb_device * fbdev)51 static int omap3evm_panel_init(struct lcd_panel *panel,
52 struct omapfb_device *fbdev)
53 {
54 gpio_request(LCD_PANEL_LR, "LCD lr");
55 gpio_request(LCD_PANEL_UD, "LCD ud");
56 gpio_request(LCD_PANEL_INI, "LCD ini");
57 gpio_request(LCD_PANEL_RESB, "LCD resb");
58 gpio_request(LCD_PANEL_QVGA, "LCD qvga");
59
60 gpio_direction_output(LCD_PANEL_RESB, 1);
61 gpio_direction_output(LCD_PANEL_INI, 1);
62 gpio_direction_output(LCD_PANEL_QVGA, 0);
63 gpio_direction_output(LCD_PANEL_LR, 1);
64 gpio_direction_output(LCD_PANEL_UD, 1);
65
66 twl_i2c_write_u8(TWL4030_MODULE_LED, 0x11, TWL_LED_LEDEN);
67 twl_i2c_write_u8(TWL4030_MODULE_PWMA, 0x01, TWL_PWMA_PWMAON);
68 twl_i2c_write_u8(TWL4030_MODULE_PWMA, 0x02, TWL_PWMA_PWMAOFF);
69 bklight_level = 100;
70
71 return 0;
72 }
73
omap3evm_panel_cleanup(struct lcd_panel * panel)74 static void omap3evm_panel_cleanup(struct lcd_panel *panel)
75 {
76 gpio_free(LCD_PANEL_QVGA);
77 gpio_free(LCD_PANEL_RESB);
78 gpio_free(LCD_PANEL_INI);
79 gpio_free(LCD_PANEL_UD);
80 gpio_free(LCD_PANEL_LR);
81 }
82
omap3evm_panel_enable(struct lcd_panel * panel)83 static int omap3evm_panel_enable(struct lcd_panel *panel)
84 {
85 gpio_set_value(LCD_PANEL_ENABLE_GPIO, 0);
86 return 0;
87 }
88
omap3evm_panel_disable(struct lcd_panel * panel)89 static void omap3evm_panel_disable(struct lcd_panel *panel)
90 {
91 gpio_set_value(LCD_PANEL_ENABLE_GPIO, 1);
92 }
93
omap3evm_panel_get_caps(struct lcd_panel * panel)94 static unsigned long omap3evm_panel_get_caps(struct lcd_panel *panel)
95 {
96 return 0;
97 }
98
omap3evm_bklight_setlevel(struct lcd_panel * panel,unsigned int level)99 static int omap3evm_bklight_setlevel(struct lcd_panel *panel,
100 unsigned int level)
101 {
102 u8 c;
103 if ((level >= 0) && (level <= 100)) {
104 c = (125 * (100 - level)) / 100 + 2;
105 twl_i2c_write_u8(TWL4030_MODULE_PWMA, c, TWL_PWMA_PWMAOFF);
106 bklight_level = level;
107 }
108 return 0;
109 }
110
omap3evm_bklight_getlevel(struct lcd_panel * panel)111 static unsigned int omap3evm_bklight_getlevel(struct lcd_panel *panel)
112 {
113 return bklight_level;
114 }
115
omap3evm_bklight_getmaxlevel(struct lcd_panel * panel)116 static unsigned int omap3evm_bklight_getmaxlevel(struct lcd_panel *panel)
117 {
118 return 100;
119 }
120
121 struct lcd_panel omap3evm_panel = {
122 .name = "omap3evm",
123 .config = OMAP_LCDC_PANEL_TFT | OMAP_LCDC_INV_VSYNC |
124 OMAP_LCDC_INV_HSYNC,
125
126 .bpp = 16,
127 .data_lines = 18,
128 .x_res = 480,
129 .y_res = 640,
130 .hsw = 3, /* hsync_len (4) - 1 */
131 .hfp = 3, /* right_margin (4) - 1 */
132 .hbp = 39, /* left_margin (40) - 1 */
133 .vsw = 1, /* vsync_len (2) - 1 */
134 .vfp = 2, /* lower_margin */
135 .vbp = 7, /* upper_margin (8) - 1 */
136
137 .pixel_clock = 26000,
138
139 .init = omap3evm_panel_init,
140 .cleanup = omap3evm_panel_cleanup,
141 .enable = omap3evm_panel_enable,
142 .disable = omap3evm_panel_disable,
143 .get_caps = omap3evm_panel_get_caps,
144 .set_bklight_level = omap3evm_bklight_setlevel,
145 .get_bklight_level = omap3evm_bklight_getlevel,
146 .get_bklight_max = omap3evm_bklight_getmaxlevel,
147 };
148
omap3evm_panel_probe(struct platform_device * pdev)149 static int omap3evm_panel_probe(struct platform_device *pdev)
150 {
151 omapfb_register_panel(&omap3evm_panel);
152 return 0;
153 }
154
omap3evm_panel_remove(struct platform_device * pdev)155 static int omap3evm_panel_remove(struct platform_device *pdev)
156 {
157 return 0;
158 }
159
omap3evm_panel_suspend(struct platform_device * pdev,pm_message_t mesg)160 static int omap3evm_panel_suspend(struct platform_device *pdev,
161 pm_message_t mesg)
162 {
163 return 0;
164 }
165
omap3evm_panel_resume(struct platform_device * pdev)166 static int omap3evm_panel_resume(struct platform_device *pdev)
167 {
168 return 0;
169 }
170
171 struct platform_driver omap3evm_panel_driver = {
172 .probe = omap3evm_panel_probe,
173 .remove = omap3evm_panel_remove,
174 .suspend = omap3evm_panel_suspend,
175 .resume = omap3evm_panel_resume,
176 .driver = {
177 .name = "omap3evm_lcd",
178 .owner = THIS_MODULE,
179 },
180 };
181
omap3evm_panel_drv_init(void)182 static int __init omap3evm_panel_drv_init(void)
183 {
184 return platform_driver_register(&omap3evm_panel_driver);
185 }
186
omap3evm_panel_drv_exit(void)187 static void __exit omap3evm_panel_drv_exit(void)
188 {
189 platform_driver_unregister(&omap3evm_panel_driver);
190 }
191
192 module_init(omap3evm_panel_drv_init);
193 module_exit(omap3evm_panel_drv_exit);
194