1 /* drivers/video/sc8810/lcd_ili9341s.c
3 * Support for ili9341s 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.
19 #include <asm/arch/sc8810_lcd.h>
20 #define mdelay(a) udelay(a * 1000)
25 #define LCD_PRINT printk
27 #define LCD_PRINT(...)
30 static void __raw_bits_or(unsigned int v, unsigned int a)
32 __raw_writel((__raw_readl(a) | v), a);
35 static int32_t ili9341s_init(struct lcd_spec *self)
37 Send_data send_cmd = self->info.mcu->ops->send_cmd;
38 Send_data send_data = self->info.mcu->ops->send_data;
40 LCD_PRINT("ili9341s_init\n");
254 send_cmd( 0x11 ); // (SLPOUT)
256 mdelay(130); // 120ms
258 send_cmd( 0x29); // (DISPON)
262 if (1) { // for test the lcd
264 send_cmd(0x2C); //Write data
265 for (i = 0; i < 240*320/3; i++)
267 for (i = 0; i < 240*320/3; i++)
269 for (i = 0; i < 240*320/3; i++)
272 send_cmd(0x29); //Display On
274 send_cmd(0x2C); //Write data
275 //mdelay(120); //120ms
277 LCD_PRINT("ili9341s_init: end\n");
282 static int32_t ili9341s_set_window(struct lcd_spec *self,
283 uint16_t left, uint16_t top, uint16_t right, uint16_t bottom)
285 Send_data send_cmd = self->info.mcu->ops->send_cmd;
286 Send_data send_data = self->info.mcu->ops->send_data;
288 LCD_PRINT("ili9341s_set_window\n");
290 send_cmd(0x2A); // col
291 send_data((left >> 8));
292 send_data((left & 0xFF));
293 send_data((right >> 8));
294 send_data((right & 0xFF));
296 send_cmd(0x2B); // row
297 send_data((top >> 8));
298 send_data((top & 0xFF));
299 send_data((bottom >> 8));
300 send_data((bottom & 0xFF));
302 send_cmd(0x2C); //Write data
308 static int32_t ili9341s_invalidate(struct lcd_spec *self)
310 LCD_PRINT("ili9341s_invalidate\n");
312 return self->ops->lcd_set_window(self, 0, 0,
313 self->width-1, self->height-1);
317 static int32_t ili9341s_invalidate_rect(struct lcd_spec *self,
318 uint16_t left, uint16_t top,
319 uint16_t right, uint16_t bottom)
321 Send_data send_cmd = self->info.mcu->ops->send_cmd;
322 Send_data send_data = self->info.mcu->ops->send_data;
324 LCD_PRINT("ili9341s_invalidate_rect : (%d, %d, %d, %d)\n",left, top, right, bottom);
326 //send_cmd(0x44); // TE scanline
327 //send_data((top >> 8));
328 //send_data((top & 0xFF));
330 return self->ops->lcd_set_window(self, left, top,
334 static int32_t ili9341s_set_direction(struct lcd_spec *self, uint16_t direction)
336 Send_data send_cmd = self->info.mcu->ops->send_cmd;
337 Send_data send_data = self->info.mcu->ops->send_data;
339 LCD_PRINT("ili9341s_set_direction\n");
344 case LCD_DIRECT_NORMAL:
347 case LCD_DIRECT_ROT_90:
350 case LCD_DIRECT_ROT_180:
353 case LCD_DIRECT_ROT_270:
356 case LCD_DIRECT_MIR_H:
359 case LCD_DIRECT_MIR_V:
362 case LCD_DIRECT_MIR_HV:
366 LCD_PRINT("unknown lcd direction!\n");
368 direction = LCD_DIRECT_NORMAL;
372 self->direction = direction;
377 static int32_t ili9341s_enter_sleep(struct lcd_spec *self, uint8_t is_sleep)
379 Send_data send_cmd = self->info.mcu->ops->send_cmd;
394 static uint32_t ili9341s_read_id(struct lcd_spec *self)
397 Send_data send_cmd = self->info.mcu->ops->send_cmd;
398 Send_data send_data = self->info.mcu->ops->send_data;
399 Read_data read_data = self->info.mcu->ops->read_data;
403 lcd_id = read_data();
404 LCD_PRINT("11111read_id=%x---------------------\n",lcd_id);
405 lcd_id = read_data();
406 LCD_PRINT("read_id=%x---------------------\n",lcd_id);
407 lcd_id = read_data();
408 LCD_PRINT("read_id=%x---------------------\n",lcd_id);
416 static struct lcd_operations lcd_ili9341s_operations = {
417 .lcd_init = ili9341s_init,
418 .lcd_set_window = ili9341s_set_window,
419 .lcd_invalidate = ili9341s_invalidate,
420 .lcd_invalidate_rect = ili9341s_invalidate_rect,
421 .lcd_set_direction = ili9341s_set_direction,
422 .lcd_enter_sleep = ili9341s_enter_sleep,
423 .lcd_readid = ili9341s_read_id,
426 static struct timing_mcu lcd_ili9341s_timing = {
427 .rcss = 170, // 25 ns
436 static struct timing_mcu lcd_ili9341s_timing[] = {
437 [LCD_REGISTER_TIMING] = {
445 [LCD_GRAM_TIMING] = {
456 static struct info_mcu lcd_ili9341s_info = {
457 .bus_mode = LCD_BUS_8080,
459 .timing = &lcd_ili9341s_timing,
463 struct lcd_spec lcd_panel_ili9341s = {
466 .mode = LCD_MODE_MCU,
467 .direction = LCD_DIRECT_NORMAL,
468 .info = {.mcu = &lcd_ili9341s_info},
469 .ops = &lcd_ili9341s_operations,