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 ili9341boe_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("ili9341boe_init\n");
255 send_cmd(0x11); // (SLPOUT)
257 mdelay(120); // 100ms
259 send_cmd(0x29); // (DISPON)
261 mdelay(100); // 100ms
263 LCD_PRINT("ili9341boe_init: end\n");
268 static int32_t ili9341boe_set_window(struct lcd_spec *self,
269 uint16_t left, uint16_t top, uint16_t right, uint16_t bottom)
271 Send_data send_cmd = self->info.mcu->ops->send_cmd;
272 Send_data send_data = self->info.mcu->ops->send_data;
274 LCD_PRINT("ili9341boe_set_window\n");
276 send_cmd(0x2A); // col
277 send_data((left >> 8));
278 send_data((left & 0xFF));
279 send_data((right >> 8));
280 send_data((right & 0xFF));
282 send_cmd(0x2B); // row
283 send_data((top >> 8));
284 send_data((top & 0xFF));
285 send_data((bottom >> 8));
286 send_data((bottom & 0xFF));
288 send_cmd(0x2C); //Write data
294 static int32_t ili9341boe_invalidate(struct lcd_spec *self)
296 LCD_PRINT("ili9341boe_invalidate\n");
298 return self->ops->lcd_set_window(self, 0, 0,
299 self->width-1, self->height-1);
303 static int32_t ili9341boe_invalidate_rect(struct lcd_spec *self,
304 uint16_t left, uint16_t top,
305 uint16_t right, uint16_t bottom)
307 Send_data send_cmd = self->info.mcu->ops->send_cmd;
308 Send_data send_data = self->info.mcu->ops->send_data;
310 LCD_PRINT("ili9341boe_invalidate_rect : (%d, %d, %d, %d)\n",left, top, right, bottom);
312 //send_cmd(0x44); // TE scanline
313 //send_data((top >> 8));
314 //send_data((top & 0xFF));
316 return self->ops->lcd_set_window(self, left, top,
320 static int32_t ili9341boe_set_direction(struct lcd_spec *self, uint16_t direction)
323 LCD_PRINT("ili9341boe_set_direction\n");
327 static int32_t ili9341boe_enter_sleep(struct lcd_spec *self, uint8_t is_sleep)
329 Send_data send_cmd = self->info.mcu->ops->send_cmd;
342 static uint32_t ili9341boe_read_id(struct lcd_spec *self)
344 uint32_t read_value = 0;
345 Send_data send_cmd = self->info.mcu->ops->send_cmd;
347 Read_data read_data = self->info.mcu->ops->read_data;
352 read_value += read_data()<< 16;
353 read_value += read_data()<< 8;
354 read_value += read_data();
359 static struct lcd_operations lcd_ili9341boe_operations = {
360 .lcd_init = ili9341boe_init,
361 .lcd_set_window = ili9341boe_set_window,
362 .lcd_invalidate = ili9341boe_invalidate,
363 .lcd_invalidate_rect = ili9341boe_invalidate_rect,
364 .lcd_set_direction = ili9341boe_set_direction,
365 .lcd_enter_sleep = ili9341boe_enter_sleep,
366 .lcd_readid = ili9341boe_read_id,
369 static struct timing_mcu lcd_ili9341s_timing = {
370 .rcss = 170, // 25 ns
379 static struct timing_mcu lcd_ili9341boe_timing[] = {
380 [LCD_REGISTER_TIMING] = {
388 [LCD_GRAM_TIMING] = {
399 static struct timing_mcu lcd_ili9341boe_timing[] = {
400 [LCD_REGISTER_TIMING] = {
408 [LCD_GRAM_TIMING] = {
419 static struct info_mcu lcd_ili9341boe_info = {
420 .bus_mode = LCD_BUS_8080,
422 .timing = &lcd_ili9341boe_timing,
426 struct lcd_spec lcd_panel_ili9341boe = {
429 .mode = LCD_MODE_MCU,
430 .direction = LCD_DIRECT_NORMAL,
431 .info = {.mcu = &lcd_ili9341boe_info},
432 .ops = &lcd_ili9341boe_operations,