1 /* drivers/video/sc8800g/sc8800g_lcd_eR6158_truly.c
3 * Support for HX8357 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.
18 #include <asm/arch/sc8810_lcd.h>
19 #define mdelay(a) udelay(a * 1000)
24 #define LCD_PRINT printk
26 #define LCD_PRINT(...)
29 //#define CONFIG_FB_LCD_NOFMARK
31 static int32_t eR6158_truly_init(struct lcd_spec *self)
33 Send_data send_cmd = self->info.mcu->ops->send_cmd;
34 Send_data send_data = self->info.mcu->ops->send_data;
36 LCD_PRINT("eR6158_truly_init\n");
37 printk("[tong][uboot]eR6158_truly_init~~~~~~~~~~~~~~~~~~~~~\n");//tong test
42 send_cmd(0x01);//soft reset
54 send_cmd(0xB0);//{setc, [107], W, 0x000B0}
55 send_data(0x00);//{setp, [104], W, 0x00000}
70 send_data(0x00);//BLV=0,PTL=0
77 send_data(0x08);// BC=1 //div=0
78 send_data(0x16);//CLOCK
88 send_cmd(0xC8);//GAMMA
104 send_data(0x56);//43/55
117 send_data(0x3F);//320
123 send_data(0xDF);//480
125 #ifndef CONFIG_FB_LCD_NOFMARK
132 send_data(0x40);//tong test
153 send_data(0x4B);//VCM40
154 send_data(0x10);//VDV
158 send_data(0x04);//0X24
172 static int32_t eR6158_truly_set_window(struct lcd_spec *self,
173 uint16_t left, uint16_t top, uint16_t right, uint16_t bottom)
175 Send_data send_cmd = self->info.mcu->ops->send_cmd;
176 Send_data send_data = self->info.mcu->ops->send_data;
178 LCD_PRINT("eR6158_truly_set_window: %d, %d, %d, %d\n",left, top, right, bottom);
180 /* set window size */
183 send_data(left >> 8);
184 send_data(left & 0xff);
185 send_data(right >> 8);
186 send_data(right & 0xff);
191 send_data(top & 0xff);
192 send_data(bottom >> 8);
193 send_data(bottom & 0xff);
201 static int32_t eR6158_truly_invalidate(struct lcd_spec *self)
203 LCD_PRINT("eR6158_truly_invalidate\n");
205 return self->ops->lcd_set_window(self, 0, 0,
206 self->width - 1, self->height - 1);
210 static int32_t eR6158_truly_invalidate_rect(struct lcd_spec *self,
211 uint16_t left, uint16_t top,
212 uint16_t right, uint16_t bottom)
214 //Send_cmd_data send_cmd_data = self->info.mcu->ops->send_cmd_data;
216 LCD_PRINT("eR6158_truly_invalidate_rect \n");
218 return self->ops->lcd_set_window(self, left, top,
222 static int32_t eR6158_truly_set_direction(struct lcd_spec *self, uint16_t direction)
224 //Send_cmd_data send_cmd_data = self->info.mcu->ops->send_cmd_data;
226 LCD_PRINT("eR6158_truly_set_direction\n");
228 self->direction = direction;
233 static int32_t eR6158_truly_enter_sleep(struct lcd_spec *self, uint8_t is_sleep)
235 //Send_cmd_data send_cmd_data = self->info.mcu->ops->send_cmd_data;
236 Send_data send_cmd = self->info.mcu->ops->send_cmd;
237 //Send_data send_data = self->info.mcu->ops->send_data;
248 send_cmd(0x11); // SLPOUT
257 static uint32_t eR6158_truly_read_id(struct lcd_spec *self)
260 Send_data send_cmd = self->info.mcu->ops->send_cmd;
261 Read_data read_data = self->info.mcu->ops->read_data;
262 Send_data send_data = self->info.mcu->ops->send_data;
264 uint32_t uICID[5] = {0};
268 send_cmd(0x01);//soft reset
275 for(i = 0; i < 5; i++)
277 uICID[i] = read_data();
278 printk("[tong][uboot]eR6158_truly_read_id: uICID[%d] = 0x%x\n", i, uICID[i]);
281 if((uICID[1] == 0x01) && (uICID[2] == 0x22) && (uICID[3] == 0x15) && (uICID[4] == 0x81))
283 printk("[tong][uboot]LCD driver IC: r61581\n");
287 printk("[tong][uboot]LCD driver IC: hx8357c\n");
297 for(i = 0; i < 2; i++)
299 uICID[i] = read_data();
300 printk("[tong][uboot]eR6158_truly_read_id: uICID[%d] = 0x%x\n", i, uICID[i]);
303 if((uICID[1] == 0x90))
305 printk("[tong][uboot]LCD driver IC: hx8357c\n");
310 printk("[tong][uboot]LCD driver IC: r61581\n");
318 printk("[tong][uboot]eR6158_truly_read_id: 0x%x from addr:0xA1\n", uID);
323 static struct lcd_operations lcd_eR6158_truly_operations = {
324 .lcd_init = eR6158_truly_init,
325 .lcd_set_window = eR6158_truly_set_window,
326 .lcd_invalidate_rect= eR6158_truly_invalidate_rect,
327 .lcd_invalidate = eR6158_truly_invalidate,
328 .lcd_set_direction = eR6158_truly_set_direction,
329 .lcd_enter_sleep = eR6158_truly_enter_sleep,
330 .lcd_readid = eR6158_truly_read_id,
333 static struct timing_mcu lcd_eR6158_truly_timing[] = {
335 [LCD_REGISTER_TIMING] = { // read/write register timing
343 [LCD_GRAM_TIMING] = { // read/write gram timing
353 static struct info_mcu lcd_eR6158_truly_info = {
354 .bus_mode = LCD_BUS_8080,
356 .timing = lcd_eR6158_truly_timing,
360 struct lcd_spec lcd_panel_eR6158_truly = {
363 .mode = LCD_MODE_MCU,
364 .direction = LCD_DIRECT_NORMAL,
365 .info = {.mcu = &lcd_eR6158_truly_info},
366 .ops = &lcd_eR6158_truly_operations,