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 ili9486_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("ili9486_init\n");
89 #ifdef CONFIG_MACH_MINT
259 send_cmd(0x11); // (SLPOUT)
261 mdelay(120); // 100ms
263 send_cmd(0x29); // (DISPON)
265 mdelay(100); // 100ms
267 LCD_PRINT("ili9486_init: end\n");
272 static int32_t ili9486_set_window(struct lcd_spec *self,
273 uint16_t left, uint16_t top, uint16_t right, uint16_t bottom)
275 Send_data send_cmd = self->info.mcu->ops->send_cmd;
276 Send_data send_data = self->info.mcu->ops->send_data;
278 LCD_PRINT("ili9486_set_window\n");
280 send_cmd(0x2A); // col
281 send_data((left >> 8));
282 send_data((left & 0xFF));
283 send_data((right >> 8));
284 send_data((right & 0xFF));
286 send_cmd(0x2B); // row
287 send_data((top >> 8));
288 send_data((top & 0xFF));
289 send_data((bottom >> 8));
290 send_data((bottom & 0xFF));
292 send_cmd(0x2C); //Write data
298 static int32_t ili9486_invalidate(struct lcd_spec *self)
300 LCD_PRINT("ili9486_invalidate\n");
302 return self->ops->lcd_set_window(self, 0, 0,
303 self->width-1, self->height-1);
307 static int32_t ili9486_invalidate_rect(struct lcd_spec *self,
308 uint16_t left, uint16_t top,
309 uint16_t right, uint16_t bottom)
311 Send_data send_cmd = self->info.mcu->ops->send_cmd;
312 Send_data send_data = self->info.mcu->ops->send_data;
314 LCD_PRINT("ili9486_invalidate_rect : (%d, %d, %d, %d)\n",left, top, right, bottom);
316 //send_cmd(0x44); // TE scanline
317 //send_data((top >> 8));
318 //send_data((top & 0xFF));
320 return self->ops->lcd_set_window(self, left, top,
324 static int32_t ili9486_set_direction(struct lcd_spec *self, uint16_t direction)
327 LCD_PRINT("ili9486_set_direction\n");
331 static int32_t ili9486_enter_sleep(struct lcd_spec *self, uint8_t is_sleep)
333 Send_data send_cmd = self->info.mcu->ops->send_cmd;
346 static uint32_t ili9486_read_id(struct lcd_spec *self)
348 uint32_t read_value = 0;
349 Send_data send_cmd = self->info.mcu->ops->send_cmd;
351 Read_data read_data = self->info.mcu->ops->read_data;
358 read_value += read_data()<< 16;
359 read_value += read_data()<< 8;
360 read_value += read_data();
365 static struct lcd_operations lcd_ili9486_operations = {
366 .lcd_init = ili9486_init,
367 .lcd_set_window = ili9486_set_window,
368 .lcd_invalidate = ili9486_invalidate,
369 .lcd_invalidate_rect = ili9486_invalidate_rect,
370 .lcd_set_direction = ili9486_set_direction,
371 .lcd_enter_sleep = ili9486_enter_sleep,
372 .lcd_readid = ili9486_read_id,
375 static struct timing_mcu lcd_ili9341s_timing = {
376 .rcss = 170, // 25 ns
384 #ifdef CONFIG_MACH_MINT
385 static struct timing_mcu lcd_ili9486_timing[] = {
386 [LCD_REGISTER_TIMING] = {
394 [LCD_GRAM_TIMING] = {
405 static struct timing_mcu lcd_ili9486_timing[] = {
406 [LCD_REGISTER_TIMING] = {
414 [LCD_GRAM_TIMING] = {
426 static struct info_mcu lcd_ili9486_info = {
427 .bus_mode = LCD_BUS_8080,
429 .timing = &lcd_ili9486_timing,
433 struct lcd_spec lcd_panel_ili9486 = {
436 .mode = LCD_MODE_MCU,
437 .direction = LCD_DIRECT_NORMAL,
438 .info = {.mcu = &lcd_ili9486_info},
439 .ops = &lcd_ili9486_operations,