1 /* drivers/video/sprdfb/lcd_s6e88oa_mipi.c
\r
3 * Support for s6e88oa mipi LCD device
\r
5 * Copyright (C) 2010 Spreadtrum
\r
8 #include <asm/arch/sprd_lcd.h>
\r
9 #include "../sprdfb.h"
\r
10 #define printk printf
\r
14 #define LCD_PRINT printk
\r
16 #define LCD_PRINT(...)
\r
19 #define MAX_DATA 150
\r
22 typedef struct LCM_Init_Code_tag {
\r
24 unsigned char data[MAX_DATA];
\r
27 typedef struct LCM_force_cmd_code_tag{
\r
28 unsigned int datatype;
\r
29 LCM_Init_Code real_cmd_code;
\r
30 }LCM_Force_Cmd_Code;
\r
32 #define LCM_TAG_SHIFT 24
\r
33 #define LCM_TAG_MASK ((1 << 24) -1)
\r
34 #define LCM_SEND(len) ((1 << LCM_TAG_SHIFT)| len)
\r
35 #define LCM_SLEEP(ms) ((2 << LCM_TAG_SHIFT)| ms)
\r
36 //#define ARRAY_SIZE(array) ( sizeof(array) / sizeof(array[0]))
\r
38 #define LCM_TAG_SEND (1<< 0)
\r
39 #define LCM_TAG_SLEEP (1 << 1)
\r
42 static LCM_Init_Code init_data[] = {
\r
43 {LCM_SLEEP(5)}, /*>5ms*/
\r
44 /*level2_comma_set */
\r
45 {LCM_SEND(5), {3, 0, 0xF0,\
\r
47 /* {LCM_SEND(5), {3, 0, 0xFC,\
\r
51 {LCM_SEND(1), {0x11} },
\r
52 {LCM_SLEEP(25)}, /*>120ms*/
\r
55 {LCM_SEND(6), {4, 0, 0xB8,\
\r
56 0x38, 0x0B, 0x2D} },
\r
62 {LCM_SEND(36), {34, 0, 0xCA,\
\r
63 0x01, 0x00, 0x01, 0x00, 0x01, 0x00,\
\r
72 0x00, 0x00, 0x00} },
\r
74 {LCM_SEND(8), {6, 0, 0xB2,\
\r
75 0x40, 0x08, 0x20, 0x00, 0x08} },
\r
77 {LCM_SEND(5), {3, 0, 0xB6,\
\r
80 {LCM_SEND(2), {0x55,\
\r
84 {LCM_SEND(2), {0xF7,\
\r
87 {LCM_SEND(1), {0x29} },
\r
88 {LCM_SLEEP(120)}, /*>120ms*/
\r
92 static LCM_Init_Code disp_on = {LCM_SEND(1), {0x29}};
\r
94 static LCM_Init_Code sleep_in[] = {
\r
95 {LCM_SEND(1), {0x28}},
\r
96 {LCM_SLEEP(150)}, //>150ms
\r
97 {LCM_SEND(1), {0x10}},
\r
98 {LCM_SLEEP(150)}, //>150ms
\r
101 static LCM_Init_Code sleep_out[] = {
\r
102 {LCM_SEND(1), {0x11}},
\r
103 {LCM_SLEEP(120)},//>120ms
\r
104 {LCM_SEND(1), {0x29}},
\r
105 {LCM_SLEEP(20)}, //>20ms
\r
108 //extern void (*lcd_panel_cabc_pwm_bl)(int brightness);
\r
109 //extern void backlight_control(int brigtness);
\r
110 static int32_t s6e88oa_mipi_init(struct panel_spec *self)
\r
113 LCM_Init_Code *init = init_data;
\r
116 //lcd_panel_cabc_pwm_bl = backlight_control;
\r
118 mipi_set_cmd_mode_t mipi_set_cmd_mode = self->info.mipi->ops->mipi_set_cmd_mode;
\r
119 mipi_dcs_write_t mipi_dcs_write = self->info.mipi->ops->mipi_dcs_write;
\r
120 mipi_eotp_set_t mipi_eotp_set = self->info.mipi->ops->mipi_eotp_set;
\r
122 LCD_PRINT("lcd_s6e88oa_init\n");
\r
124 mipi_set_cmd_mode();
\r
125 mipi_eotp_set(0,0);
\r
127 for(i = 0; i < ARRAY_SIZE(init_data); i++){
\r
128 tag = (init->tag >>24);
\r
129 if(tag & LCM_TAG_SEND){
\r
130 mipi_dcs_write(init->data, (init->tag & LCM_TAG_MASK));
\r
132 }else if(tag & LCM_TAG_SLEEP){
\r
133 mdelay(init->tag & LCM_TAG_MASK);//udelay((init->tag & LCM_TAG_MASK) * 1000);
\r
137 mipi_eotp_set(0,0);
\r
142 static uint32_t s6e88oa_readid(struct panel_spec *self)
\r
146 uint8_t read_data[3] = {0};
\r
147 int32_t read_rtn = 0;
\r
148 uint8_t param[2] = {0};
\r
149 mipi_set_cmd_mode_t mipi_set_cmd_mode = self->info.mipi->ops->mipi_set_cmd_mode;
\r
150 mipi_force_write_t mipi_force_write = self->info.mipi->ops->mipi_force_write;
\r
151 mipi_force_read_t mipi_force_read = self->info.mipi->ops->mipi_force_read;
\r
152 mipi_eotp_set_t mipi_eotp_set = self->info.mipi->ops->mipi_eotp_set;
\r
154 LCD_PRINT("lcd_s6e88oa_mipi read id!\n");
\r
156 mipi_set_cmd_mode();
\r
157 mipi_eotp_set(0,0);
\r
159 for(j = 0; j < 4; j++){
\r
162 mipi_force_write(0x37, param, 2);
\r
163 read_rtn = mipi_force_read(0xda,1,&read_data[0]);
\r
164 read_rtn = mipi_force_read(0xdb,1,&read_data[1]);
\r
165 read_rtn = mipi_force_read(0xdc,1,&read_data[2]);
\r
166 if((0x52 == read_data[0])&&(0x00 == read_data[1])&&(0x00 == read_data[2]))
\r
168 LCD_PRINT("lcd_s6e88oa_mipi read id success!\n");
\r
172 LCD_PRINT("lcd_s6e88oa_mipi read id fail! 0xda,0xdb,0xdc is 0x%x,0x%x,0x%x!\n",read_data[0],read_data[1],read_data[2]);
\r
173 mipi_eotp_set(0,0);
\r
179 static struct panel_operations lcd_s6e88oa_mipi_operations = {
\r
180 .panel_init = s6e88oa_mipi_init,
\r
181 .panel_readid = s6e88oa_readid,
\r
184 static struct timing_rgb lcd_s6e88oa_mipi_timing = {
\r
185 .hfp = 110, /* unit: pixel */
\r
188 .vfp = 13, /*unit: line*/
\r
194 static struct info_mipi lcd_s6e88oa_mipi_info = {
\r
195 .work_mode = SPRDFB_MIPI_MODE_VIDEO,
\r
196 .video_bus_width = 24, /*18,16*/
\r
198 .phy_feq = 450 * 1000,
\r
199 .h_sync_pol = SPRDFB_POLARITY_POS,
\r
200 .v_sync_pol = SPRDFB_POLARITY_POS,
\r
201 .de_pol = SPRDFB_POLARITY_POS,
\r
202 .te_pol = SPRDFB_POLARITY_POS,
\r
203 .color_mode_pol = SPRDFB_POLARITY_NEG,
\r
204 .shut_down_pol = SPRDFB_POLARITY_NEG,
\r
205 .timing = &lcd_s6e88oa_mipi_timing,
\r
209 struct panel_spec lcd_s6e88oa_mipi_spec = {
\r
213 .type = LCD_MODE_DSI,
\r
214 .direction = LCD_DIRECT_NORMAL,
\r
216 .mipi = &lcd_s6e88oa_mipi_info
\r
218 .ops = &lcd_s6e88oa_mipi_operations,
\r