]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - drivers/video/omap/lcd_sx1.c
ARM: OMAP: Frambuffer driver CodingStyle changes.
[linux-2.6-omap-h63xx.git] / drivers / video / omap / lcd_sx1.c
1 /*
2  * LCD panel support for the Siemens SX1 mobile phone
3  *
4  * Current version : Vovan888@gmail com, great help from FCA00000
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the
8  * Free Software Foundation; either version 2 of the License, or (at your
9  * option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19  */
20
21 #include <linux/module.h>
22 #include <linux/platform_device.h>
23 #include <linux/delay.h>
24 #include <asm/io.h>
25 #include <asm/arch/gpio.h>
26 #include <asm/arch/omapfb.h>
27 #include <asm/arch/mcbsp.h>
28 #include <asm/arch/mux.h>
29
30 /*
31  * OMAP310 GPIO registers
32  */
33 #define GPIO_DATA_INPUT         0xfffce000
34 #define GPIO_DATA_OUTPUT        0xfffce004
35 #define GPIO_DIR_CONTROL        0xfffce008
36 #define GPIO_INT_CONTROL        0xfffce00c
37 #define GPIO_INT_MASK           0xfffce010
38 #define GPIO_INT_STATUS         0xfffce014
39 #define GPIO_PIN_CONTROL        0xfffce018
40
41
42 #define A_LCD_SSC_RD    3
43 #define A_LCD_SSC_SD    7
44 #define _A_LCD_RESET    9
45 #define _A_LCD_SSC_CS   12
46 #define _A_LCD_SSC_A0   13
47
48 #define DSP_REG         0xE1017024
49
50 const unsigned char INIT_1[12] = {
51         0x1C, 0x02, 0x88, 0x00, 0x1E, 0xE0, 0x00, 0xDC, 0x00, 0x02, 0x00
52 };
53
54 const unsigned char INIT_2[127] = {
55         0x15, 0x00, 0x29, 0x00, 0x3E, 0x00, 0x51, 0x00, 0x65, 0x00, 0x7A, 0x00, 0x8D, 0x00, 0xA1, 0x00,
56         0xB6, 0x00, 0xC7, 0x00, 0xD8, 0x00, 0xEB, 0x00, 0xFB, 0x00, 0x0B, 0x01, 0x1B, 0x01, 0x27, 0x01,
57         0x34, 0x01, 0x41, 0x01, 0x4C, 0x01, 0x55, 0x01, 0x5F, 0x01, 0x68, 0x01, 0x70, 0x01, 0x78, 0x01,
58         0x7E, 0x01, 0x86, 0x01, 0x8C, 0x01, 0x94, 0x01, 0x9B, 0x01, 0xA1, 0x01, 0xA4, 0x01, 0xA9, 0x01,
59         0xAD, 0x01, 0xB2, 0x01, 0xB7, 0x01, 0xBC, 0x01, 0xC0, 0x01, 0xC4, 0x01, 0xC8, 0x01, 0xCB, 0x01,
60         0xCF, 0x01, 0xD2, 0x01, 0xD5, 0x01, 0xD8, 0x01, 0xDB, 0x01, 0xE0, 0x01, 0xE3, 0x01, 0xE6, 0x01,
61         0xE8, 0x01, 0xEB, 0x01, 0xEE, 0x01, 0xF1, 0x01, 0xF3, 0x01, 0xF8, 0x01, 0xF9, 0x01, 0xFC, 0x01,
62         0x00, 0x02, 0x03, 0x02, 0x07, 0x02, 0x09, 0x02, 0x0E, 0x02, 0x13, 0x02, 0x1C, 0x02, 0x00
63 };
64
65 const unsigned char INIT_3[15] = {
66         0x14, 0x26, 0x33, 0x3D, 0x45, 0x4D, 0x53, 0x59,
67         0x5E, 0x63, 0x67, 0x6D, 0x71, 0x78, 0xFF
68 };
69
70 static void epson_sendbyte(int flag, unsigned char byte)
71 {
72         int i, shifter = 0x80;
73
74         if (!flag)
75                 omap_set_gpio_dataout(_A_LCD_SSC_A0, 0);
76         mdelay(2);
77         omap_set_gpio_dataout(A_LCD_SSC_RD, 1);
78
79         omap_set_gpio_dataout(A_LCD_SSC_SD, flag);
80
81         OMAP_MCBSP_WRITE(OMAP1510_MCBSP3_BASE, PCR0, 0x2200);
82         OMAP_MCBSP_WRITE(OMAP1510_MCBSP3_BASE, PCR0, 0x2202);
83         for (i = 0; i < 8; i++) {
84                 OMAP_MCBSP_WRITE(OMAP1510_MCBSP3_BASE, PCR0, 0x2200);
85                 omap_set_gpio_dataout(A_LCD_SSC_SD, shifter & byte);
86                 OMAP_MCBSP_WRITE(OMAP1510_MCBSP3_BASE, PCR0, 0x2202);
87                 shifter >>= 1;
88         }
89         omap_set_gpio_dataout(_A_LCD_SSC_A0, 1);
90 }
91
92 static void init_system(void)
93 {
94         omap_mcbsp_request(OMAP_MCBSP3);
95         omap_mcbsp_stop(OMAP_MCBSP3);
96 }
97
98 static void setup_GPIO(void)
99 {
100         /* new wave */
101         omap_request_gpio(A_LCD_SSC_RD);
102         omap_request_gpio(A_LCD_SSC_SD);
103         omap_request_gpio(_A_LCD_RESET);
104         omap_request_gpio(_A_LCD_SSC_CS);
105         omap_request_gpio(_A_LCD_SSC_A0);
106
107         /* set all GPIOs to output */
108         omap_set_gpio_direction(A_LCD_SSC_RD, 0);
109         omap_set_gpio_direction(A_LCD_SSC_SD, 0);
110         omap_set_gpio_direction(_A_LCD_RESET, 0);
111         omap_set_gpio_direction(_A_LCD_SSC_CS, 0);
112         omap_set_gpio_direction(_A_LCD_SSC_A0, 0);
113
114         /* set GPIO data */
115         omap_set_gpio_dataout(A_LCD_SSC_RD, 1);
116         omap_set_gpio_dataout(A_LCD_SSC_SD, 0);
117         omap_set_gpio_dataout(_A_LCD_RESET, 0);
118         omap_set_gpio_dataout(_A_LCD_SSC_CS, 1);
119         omap_set_gpio_dataout(_A_LCD_SSC_A0, 1);
120 }
121
122 static void display_init(void)
123 {
124         int i;
125
126         omap_cfg_reg(MCBSP3_CLKX);
127
128         mdelay(2);
129         setup_GPIO();
130         mdelay(2);
131
132         /* reset LCD */
133         omap_set_gpio_dataout(A_LCD_SSC_SD, 1);
134         epson_sendbyte(0, 0x25);
135
136         omap_set_gpio_dataout(_A_LCD_RESET, 0);
137         mdelay(10);
138         omap_set_gpio_dataout(_A_LCD_RESET, 1);
139
140         omap_set_gpio_dataout(_A_LCD_SSC_CS, 1);
141         mdelay(2);
142         omap_set_gpio_dataout(_A_LCD_SSC_CS, 0);
143
144         /* init LCD, phase 1 */
145         epson_sendbyte(0, 0xCA);
146         for (i = 0; i < 10; i++)
147                 epson_sendbyte(1, INIT_1[i]);
148         omap_set_gpio_dataout(_A_LCD_SSC_CS, 1);
149         omap_set_gpio_dataout(_A_LCD_SSC_CS, 0);
150
151         /* init LCD phase 2 */
152         epson_sendbyte(0, 0xCB);
153         for( i = 0; i < 125; i++)
154                 epson_sendbyte(1, INIT_2[i]);
155         omap_set_gpio_dataout(_A_LCD_SSC_CS, 1);
156         omap_set_gpio_dataout(_A_LCD_SSC_CS, 0);
157
158         /* init LCD phase 2a */
159         epson_sendbyte(0, 0xCC);
160         for( i = 0; i < 14; i++)
161                 epson_sendbyte(1, INIT_3[i]);
162         omap_set_gpio_dataout(_A_LCD_SSC_CS, 1);
163         omap_set_gpio_dataout(_A_LCD_SSC_CS, 0);
164
165         /* init LCD phase 3 */
166         epson_sendbyte(0, 0xBC);
167         epson_sendbyte(1, 0x08);
168         omap_set_gpio_dataout(_A_LCD_SSC_CS, 1);
169         omap_set_gpio_dataout(_A_LCD_SSC_CS, 0);
170
171         /* init LCD phase 4 */
172         epson_sendbyte(0, 0x07);
173         epson_sendbyte(1, 0x05);
174         omap_set_gpio_dataout(_A_LCD_SSC_CS, 1);
175         omap_set_gpio_dataout(_A_LCD_SSC_CS, 0);
176
177         /* init LCD phase 5 */
178         epson_sendbyte(0, 0x94);
179         omap_set_gpio_dataout(_A_LCD_SSC_CS, 1);
180         omap_set_gpio_dataout(_A_LCD_SSC_CS, 0);
181
182         /* init LCD phase 6 */
183         epson_sendbyte(0, 0xC6);
184         epson_sendbyte(1, 0x80);
185         omap_set_gpio_dataout(_A_LCD_SSC_CS, 1);
186         mdelay(100); /* used to be 1000 */
187         omap_set_gpio_dataout(_A_LCD_SSC_CS, 0);
188
189         /* init LCD phase 7 */
190         epson_sendbyte(0, 0x16);
191         epson_sendbyte(1, 0x02);
192         epson_sendbyte(1, 0x00);
193         epson_sendbyte(1, 0xB1);
194         epson_sendbyte(1, 0x00);
195         omap_set_gpio_dataout(_A_LCD_SSC_CS, 1);
196         omap_set_gpio_dataout(_A_LCD_SSC_CS, 0);
197
198         /* init LCD phase 8 */
199         epson_sendbyte(0, 0x76);
200         epson_sendbyte(1, 0x00);
201         epson_sendbyte(1, 0x00);
202         epson_sendbyte(1, 0xDB);
203         epson_sendbyte(1, 0x00);
204         omap_set_gpio_dataout(_A_LCD_SSC_CS, 1);
205         omap_set_gpio_dataout(_A_LCD_SSC_CS, 0);
206
207         /* init LCD phase 9 */
208         epson_sendbyte(0, 0xAF);
209         omap_set_gpio_dataout(_A_LCD_SSC_CS, 1);
210 }
211
212 static int sx1_panel_init(struct lcd_panel *panel, struct omapfb_device *fbdev)
213 {
214         return 0;
215 }
216
217 static void sx1_panel_cleanup(struct lcd_panel *panel)
218 {
219 }
220
221 static void sx1_panel_disable(struct lcd_panel *panel)
222 {
223         printk(KERN_INFO "SX1: LCD panel disable\n");
224         sx1_setmmipower(0);
225         omap_set_gpio_dataout(_A_LCD_SSC_CS, 1);
226
227         epson_sendbyte(0, 0x25);
228         omap_set_gpio_dataout(_A_LCD_SSC_CS, 0);
229
230         epson_sendbyte(0, 0xAE);
231         omap_set_gpio_dataout(_A_LCD_SSC_CS, 1);
232         mdelay(100);
233         omap_set_gpio_dataout(_A_LCD_SSC_CS, 0);
234
235         epson_sendbyte(0, 0x95);
236         omap_set_gpio_dataout(_A_LCD_SSC_CS, 1);
237 }
238
239 static int sx1_panel_enable(struct lcd_panel *panel)
240 {
241 #if 0
242         sx1_panel_disable(); /* try to disable panel first, if we boot from Symbian */
243 #endif
244
245         printk(KERN_INFO "lcd_sx1: LCD panel enable\n");
246         init_system();
247         display_init();
248
249         sx1_setmmipower(1);
250         sx1_setbacklight(0x18);
251         sx1_setkeylight (0x06);
252         return 0;
253 }
254
255
256 static unsigned long sx1_panel_get_caps(struct lcd_panel *panel)
257 {
258         return 0;
259 }
260
261 struct lcd_panel sx1_panel = {
262         .name           = "sx1",
263         .config         = OMAP_LCDC_PANEL_TFT | OMAP_LCDC_INV_VSYNC |
264                           OMAP_LCDC_INV_HSYNC | OMAP_LCDC_INV_PIX_CLOCK |
265                           OMAP_LCDC_INV_OUTPUT_EN,
266
267         .x_res          = 176,
268         .y_res          = 220,
269         .data_lines     = 16,
270         .bpp            = 16,
271         .hsw            = 5,
272         .hfp            = 5,
273         .hbp            = 5,
274         .vsw            = 2,
275         .vfp            = 1,
276         .vbp            = 1,
277         .pixel_clock    = 1500,
278
279         .init           = sx1_panel_init,
280         .cleanup        = sx1_panel_cleanup,
281         .enable         = sx1_panel_enable,
282         .disable        = sx1_panel_disable,
283         .get_caps       = sx1_panel_get_caps,
284 };
285
286 static int sx1_panel_probe(struct platform_device *pdev)
287 {
288         omapfb_register_panel(&sx1_panel);
289         return 0;
290 }
291
292 static int sx1_panel_remove(struct platform_device *pdev)
293 {
294         return 0;
295 }
296
297 static int sx1_panel_suspend(struct platform_device *pdev, pm_message_t mesg)
298 {
299         return 0;
300 }
301
302 static int sx1_panel_resume(struct platform_device *pdev)
303 {
304         return 0;
305 }
306
307 struct platform_driver sx1_panel_driver = {
308         .probe          = sx1_panel_probe,
309         .remove         = sx1_panel_remove,
310         .suspend        = sx1_panel_suspend,
311         .resume         = sx1_panel_resume,
312         .driver = {
313                 .name   = "lcd_sx1",
314                 .owner  = THIS_MODULE,
315         },
316 };
317
318 static int sx1_panel_drv_init(void)
319 {
320         return platform_driver_register(&sx1_panel_driver);
321 }
322
323 static void sx1_panel_drv_cleanup(void)
324 {
325         platform_driver_unregister(&sx1_panel_driver);
326 }
327
328 module_init(sx1_panel_drv_init);
329 module_exit(sx1_panel_drv_cleanup);