1 /* drivers/video/sc8800g/sc8800g_lcd_s6d0139.c
3 * Support for s6d0139 LCD device
5 * Copyright (C) 2010 Spreadtrum
7 * This software is licensed under the terms of the GNU General Public
8 * License version 2, as published by the Free Software Foundation, and
9 * may be copied, distributed, and modified under those terms.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
17 #include <asm/arch/tiger_lcd.h>
23 #define LCD_PRINT printk
25 #define LCD_PRINT(...)
30 static int32_t s6d0139_init(struct panel_spec *self)
32 send_cmd_data_t send_cmd_data = self->info.mcu->ops->send_cmd_data;
33 send_data_t send_cmd = self->info.mcu->ops->send_cmd;
34 send_data_t send_data = self->info.mcu->ops->send_data;
35 LCD_PRINT("s6d0139_init\n");
38 self->ops->panel_reset(self);
40 /* start init sequence */
41 send_cmd_data(0x0000, 0x0001);
44 send_cmd_data(0x0007, 0x0000);
45 send_cmd_data(0x0013, 0x0000);
46 send_cmd_data(0x0011, 0x2604);
47 send_cmd_data(0x0014, 0x1212);
48 send_cmd_data(0x0010, 0x3C00);
49 send_cmd_data(0x0013, 0x0040);
51 send_cmd_data(0x0013, 0x0060);
53 send_cmd_data(0x0013, 0x0070);
55 send_cmd_data(0x0001, 0x0127);
56 send_cmd_data(0x0002, 0x0700);
57 send_cmd_data(0x0003, 0x1030);
58 send_cmd_data(0x0007, 0x0000);
59 send_cmd_data(0x0008, 0x0404);
60 send_cmd_data(0x000B, 0x0200);
61 send_cmd_data(0x000C, 0x0000);
62 send_cmd_data(0x0015, 0x0000);
65 send_cmd_data(0x0030, 0x0000);
66 send_cmd_data(0x0031, 0x0606);
67 send_cmd_data(0x0032, 0x0006);
68 send_cmd_data(0x0033, 0x0403);
69 send_cmd_data(0x0034, 0x0107);
70 send_cmd_data(0x0035, 0x0101);
71 send_cmd_data(0x0036, 0x0707);
72 send_cmd_data(0x0037, 0x0304);
73 send_cmd_data(0x0038, 0x0A00);
74 send_cmd_data(0x0039, 0x0706);
75 send_cmd_data(0x0040, 0x0000);
76 send_cmd_data(0x0041, 0x0000);
77 send_cmd_data(0x0042, 0x013F);
78 send_cmd_data(0x0043, 0x0000);
79 send_cmd_data(0x0044, 0x0000);
80 send_cmd_data(0x0045, 0x0000);
81 send_cmd_data(0x0046, 0xEF00);
82 send_cmd_data(0x0047, 0x013F);
83 send_cmd_data(0x0048, 0x0000);
84 send_cmd_data(0x0007, 0x0011);
86 send_cmd_data(0x0007, 0x0017);
87 send_cmd_data(0x0020, 0x0000);
88 send_cmd_data(0x0021, 0x0000);
96 for (i=0; i<320*240/3; i++)
98 for (i=0; i< 320*240/3; i++)
100 for (i=0; i< 320*240/3; i++)
107 static int32_t s6d0139_set_window(struct panel_spec *self,
108 uint16_t left, uint16_t top, uint16_t right, uint16_t bottom)
110 send_cmd_data_t send_cmd_data = self->info.mcu->ops->send_cmd_data;
111 send_data_t send_cmd = self->info.mcu->ops->send_cmd;
112 LCD_PRINT("s6d0139_set_window\n");
114 send_cmd_data(0x46, ((right << 8) & 0xff00)|(left&0xff));
115 send_cmd_data(0x47, bottom);
116 send_cmd_data(0x48, top);
118 switch (self->direction) {
119 case LCD_DIRECT_NORMAL:
120 case LCD_DIRECT_ROT_270:
121 send_cmd_data(0x0020, left);
122 send_cmd_data(0x0021, top);
124 case LCD_DIRECT_ROT_90:
125 case LCD_DIRECT_MIR_H:
126 send_cmd_data(0x0020, right);
127 send_cmd_data(0x0021, top);
129 case LCD_DIRECT_ROT_180:
130 case LCD_DIRECT_MIR_HV:
131 send_cmd_data(0x0020, right);
132 send_cmd_data(0x0021, bottom);
134 case LCD_DIRECT_MIR_V:
135 send_cmd_data(0x0020, left);
136 send_cmd_data(0x0021, bottom);
139 LCD_PRINT("unknown lcd direction!\n");
148 static int32_t s6d0139_invalidate(struct panel_spec *self)
150 LCD_PRINT("s6d0139_invalidate\n");
152 return self->ops->panel_set_window(self, 0, 0,
153 self->width-1, self->height-1);
157 static int32_t s6d0139_set_direction(struct panel_spec *self, uint16_t direction)
159 send_cmd_data_t send_cmd_data = self->info.mcu->ops->send_cmd_data;
160 LCD_PRINT("s6d0139_set_direction\n");
163 case LCD_DIRECT_NORMAL:
164 send_cmd_data(0x0003, 0x1030);
166 case LCD_DIRECT_ROT_90:
167 send_cmd_data(0x0003, 0x1028);
169 case LCD_DIRECT_ROT_180:
170 case LCD_DIRECT_MIR_HV:
171 send_cmd_data(0x0003, 0x1000);
173 case LCD_DIRECT_ROT_270:
174 send_cmd_data(0x0003, 0x1018);
176 case LCD_DIRECT_MIR_H:
177 send_cmd_data(0x0003, 0x1020);
179 case LCD_DIRECT_MIR_V:
180 send_cmd_data(0x0003, 0x1010);
183 LCD_PRINT("unknown lcd direction!\n");
184 send_cmd_data(0x0003, 0x1030);
185 direction = LCD_DIRECT_NORMAL;
189 self->direction = direction;
194 static struct panel_operations lcd_s6d0139_operations = {
195 .panel_init = s6d0139_init,
196 .panel_set_window = s6d0139_set_window,
197 .panel_invalidate = s6d0139_invalidate,
198 .panel_set_direction = s6d0139_set_direction,
202 static struct timing_mcu lcd_s6d0139_timing[] = {
203 [0] = { /* read/write register timing (ns) */
211 [1] = { /* read/write gram timing (ns) */
212 .rcss = 25, /* 25 ns */
221 static struct info_mcu lcd_s6d0139_info = {
222 .bus_mode = LCD_BUS_8080,
224 .bpp = 16, /*RGB565*/
225 .timing = lcd_s6d0139_timing,
229 struct panel_spec lcd_s6d0139_spec = {
232 .type = LCD_MODE_MCU,
233 .direction = LCD_DIRECT_NORMAL,
235 .mcu = &lcd_s6d0139_info
237 .ops = &lcd_s6d0139_operations,