1 /* drivers/video/sc8810/lcd_hx8369.c
3 * Support for hx8369 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/sc8810_lcd.h>
23 #define LCD_PRINT printk
25 #define LCD_PRINT(...)
28 static int32_t hx8369_init(struct lcd_spec *self)
30 Send_data send_cmd = self->info.mcu->ops->send_cmd;
31 Send_data send_data = self->info.mcu->ops->send_data;
33 LCD_PRINT("hx8369_init\n");
35 send_cmd(0xB9); // SET password
40 send_cmd(0xB1); //Set Power
61 send_cmd(0xB2); // SET Display 480x800
78 send_cmd(0xB4); // SET Display 480x800
87 send_data(0x09);//05 42HZ 07 50HZ 0B 100% 67HZ
90 send_cmd(0xB6); // SET VCOM
94 send_cmd(0xD5); // SET GIP
100 send_data(0x02); //04
123 send_cmd(0xE0); // Set Gamma
158 send_cmd(0x35); // TE on
160 //send_cmd(0x34); // TE off
162 send_cmd(0x3A); // set CSEL
163 send_data(0x07); // CSEL=0x06, 16bit-color CSEL=0x06, 18bit-color CSEL=0x07, 24bit-color
167 send_cmd(0x2D); //Look up table//
171 send_data(4*i);//Green
173 send_data(8*i);//Blue
178 send_cmd(0x2D); //Look up table//
182 send_data(4*i);//Green
184 send_data(4*i);//Blue
186 //24 bit don't need to set 2DH
188 send_cmd(0x11); //Sleep Out
189 LCD_DelayMS(120); //120ms
191 if (0) { // for test the lcd
193 send_cmd(0x2C); //Write data
194 for (i = 0; i < 480*800/3; i++)
196 for (i = 0; i < 480*800/3; i++)
198 for (i = 0; i < 480*800/3; i++)
201 send_cmd(0x29); //Display On
202 LCD_DelayMS(120); //120ms
203 send_cmd(0x2C); //Write data
204 //LCD_DelayMS(120); //120ms
205 LCD_PRINT("hx8369_init: end\n");
211 static int32_t hx8369_set_window(struct lcd_spec *self,
212 uint16_t left, uint16_t top, uint16_t right, uint16_t bottom)
214 Send_data send_cmd = self->info.mcu->ops->send_cmd;
215 Send_data send_data = self->info.mcu->ops->send_data;
217 LCD_PRINT("hx8369_set_window\n");
219 send_cmd(0x2A); // col
220 send_data((left >> 8));
221 send_data((left & 0xFF));
222 send_data((right >> 8));
223 send_data((right & 0xFF));
225 send_cmd(0x2B); // row
226 send_data((top >> 8));
227 send_data((top & 0xFF));
228 send_data((bottom >> 8));
229 send_data((bottom & 0xFF));
231 send_cmd(0x2C); //Write data
237 static int32_t hx8369_invalidate(struct lcd_spec *self)
239 LCD_PRINT("hx8369_invalidate\n");
241 return self->ops->lcd_set_window(self, 0, 0,
242 self->width-1, self->height-1);
246 static int32_t hx8369_invalidate_rect(struct lcd_spec *self,
247 uint16_t left, uint16_t top,
248 uint16_t right, uint16_t bottom)
250 LCD_PRINT("hx8369_invalidate_rect \n");
252 return self->ops->lcd_set_window(self, left, top,
256 static int32_t hx8369_set_direction(struct lcd_spec *self, uint16_t direction)
258 Send_data send_cmd = self->info.mcu->ops->send_cmd;
259 Send_data send_data = self->info.mcu->ops->send_data;
261 LCD_PRINT("hx8369_set_direction\n");
265 case LCD_DIRECT_NORMAL:
268 case LCD_DIRECT_ROT_90:
271 case LCD_DIRECT_ROT_180:
274 case LCD_DIRECT_ROT_270:
277 case LCD_DIRECT_MIR_H:
280 case LCD_DIRECT_MIR_V:
283 case LCD_DIRECT_MIR_HV:
287 LCD_PRINT("unknown lcd direction!\n");
289 direction = LCD_DIRECT_NORMAL;
293 self->direction = direction;
298 static int32_t hx8369_enter_sleep(struct lcd_spec *self, uint8_t is_sleep)
300 Send_data send_cmd = self->info.mcu->ops->send_cmd;
301 Send_data send_data = self->info.mcu->ops->send_data;
320 static int32_t hx8369_read_id(struct lcd_spec *self)
322 Send_data send_cmd = self->info.mcu->ops->send_cmd;
323 Send_data send_data = self->info.mcu->ops->send_data;
324 Read_data read_data = self->info.mcu->ops->read_data;
336 static struct lcd_operations lcd_hx8369_operations = {
337 .lcd_init = hx8369_init,
338 .lcd_set_window = hx8369_set_window,
339 .lcd_invalidate = hx8369_invalidate,
340 .lcd_invalidate_rect = hx8369_invalidate_rect,
341 .lcd_set_direction = hx8369_set_direction,
342 .lcd_enter_sleep = hx8369_enter_sleep,
343 .lcd_readid = hx8369_read_id,
346 static struct timing_mcu lcd_hx8369_timing[] = {
347 [LCD_REGISTER_TIMING] = { // read/write register timing
355 [LCD_GRAM_TIMING] = { // read/write gram timing
366 static struct info_mcu lcd_hx8369_info = {
367 .bus_mode = LCD_BUS_8080,
369 .timing = lcd_hx8369_timing,
373 struct lcd_spec lcd_panel_hx8369 = {
376 .mode = LCD_MODE_MCU,
377 .direction = LCD_DIRECT_NORMAL,
378 .info = {.mcu = &lcd_hx8369_info},
379 .ops = &lcd_hx8369_operations,