1 /* drivers/video/sc8825/lcd_otm8018b_mipi.c
\r
3 * Support for otm8018b mipi LCD device
\r
5 * Copyright (C) 2010 Spreadtrum
\r
7 * This software is licensed under the terms of the GNU General Public
\r
8 * License version 2, as published by the Free Software Foundation, and
\r
9 * may be copied, distributed, and modified under those terms.
\r
11 * This program is distributed in the hope that it will be useful,
\r
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 * GNU General Public License for more details.
\r
17 #include <asm/arch/tiger_lcd.h>
\r
19 #define printk printf
\r
23 #define LCD_PRINT printk
\r
25 #define LCD_PRINT(...)
\r
30 typedef struct LCM_Init_Code_tag {
\r
32 unsigned char data[MAX_DATA];
\r
35 typedef struct LCM_force_cmd_code_tag{
\r
36 unsigned int datatype;
\r
37 LCM_Init_Code real_cmd_code;
\r
38 }LCM_Force_Cmd_Code;
\r
40 #define LCM_TAG_SHIFT 24
\r
41 #define LCM_TAG_MASK ((1 << 24) -1)
\r
42 #define LCM_SEND(len) ((1 << LCM_TAG_SHIFT)| len)
\r
43 #define LCM_SLEEP(ms) ((2 << LCM_TAG_SHIFT)| ms)
\r
44 //#define ARRAY_SIZE(array) ( sizeof(array) / sizeof(array[0]))
\r
46 #define LCM_TAG_SEND (1<< 0)
\r
47 #define LCM_TAG_SLEEP (1 << 1)
\r
49 static LCM_Init_Code init_data[] = {
\r
51 {LCM_SEND(6), {4, 0, 0xff,0x80,0x09,0x01}},
\r
53 {LCM_SEND(2), {0x00,0x80}},
\r
54 {LCM_SEND(5), {3, 0, 0xff,0x80,0x09}},
\r
56 {LCM_SEND(2), {0x00,0x03}},
\r
57 {LCM_SEND(2), {0xFF,0x01}},
\r
59 {LCM_SEND(2), {0x00,0xB4}},
\r
60 {LCM_SEND(2), {0xC0,0x10}},
\r
62 {LCM_SEND(2), {0x00,0x82}},
\r
63 {LCM_SEND(2), {0xC5,0xA3}},
\r
65 {LCM_SEND(2), {0x00,0x90}},
\r
66 {LCM_SEND(5), {3, 0, 0xC5,0xC6,0x76}},
\r
68 {LCM_SEND(2), {0x00,0x00}},
\r
69 {LCM_SEND(5), {3, 0, 0xD8,0x75,0x73}},
\r
71 {LCM_SEND(2), {0x00,0x00}},
\r
72 {LCM_SEND(2), {0xD9,0x4E}},
\r
74 /*-------------Gamma+ ------*/
\r
75 {LCM_SEND(2), {0x00,0x00}},
\r
76 {LCM_SEND(19), {17, 0, 0xE1,0x0C,0x0D,0x11,0x10,0x0A,0x1B,0x0B,0x0B,0x00,0x03,0x03,0x05,0x0D,0x24,0x21,0x05}},
\r
78 {LCM_SEND(2), {0x00,0x00}},
\r
79 {LCM_SEND(19), {17, 0, 0xE2,0x0C,0x0D,0x11,0x12,0x0E,0x1D,0x0B,0x0B,0x00,0x03,0x03,0x05,0x0D,0x25,0x21,0x05}},
\r
81 {LCM_SEND(2), {0x00,0x81}},
\r
82 {LCM_SEND(2), {0xC1,0x66}},
\r
83 {LCM_SEND(2), {0x00,0xA1}},
\r
84 {LCM_SEND(2), {0xC1,0x08}},
\r
86 {LCM_SEND(2), {0x00,0x89}},
\r
87 {LCM_SEND(2), {0xC4,0x08}},
\r
89 {LCM_SEND(2), {0x00,0xA2}},
\r
90 {LCM_SEND(6), {4, 0, 0xC0,0x1B,0x00,0x02}},
\r
92 {LCM_SEND(2), {0x00,0x81}},
\r
93 {LCM_SEND(2), {0xC4,0x83}},
\r
95 {LCM_SEND(2), {0x00,0x92}},
\r
96 {LCM_SEND(2), {0xC5,0x01}},
\r
98 {LCM_SEND(2), {0x00,0xB1}},
\r
99 {LCM_SEND(2), {0xC5,0xA9}},
\r
101 /*C09x : mck_shift1/mck_shift2/mck_shift3*/
\r
102 {LCM_SEND(2), {0x00,0x90}},
\r
103 {LCM_SEND(9), {7, 0, 0xC0,0x00,0x44,0x00,0x00,0x00,0x03}},
\r
105 /*C1Ax : hs_shift/vs_shift*/
\r
106 {LCM_SEND(2), {0x00,0xA6}},
\r
107 {LCM_SEND(6), {4, 0, 0xC1,0x00,0x00,0x00}},
\r
109 //CE8x : vst1, vst2, vst3, vst4
\r
110 {LCM_SEND(2), {0x00,0x80}},
\r
111 {LCM_SEND(15), {13, 0, 0xCE,0x87,0x03,0x00,0x85,0x03,0x00,0x86,0x03,0x00,0x84,0x03,0x00}},
\r
113 //CEAx : clka1, clka2
\r
114 {LCM_SEND(2), {0x00,0xA0}},
\r
115 {LCM_SEND(17), {15, 0, 0xCE,0x38,0x03,0x03,0x58,0x00,0x00,0x00,0x38,0x02,0x03,0x59,0x00,0x00,0x00}},
\r
117 //CEBx : clka3, clka4
\r
118 {LCM_SEND(2), {0x00,0xB0}},
\r
119 {LCM_SEND(17), {15, 0, 0xCE,0x38,0x01,0x03,0x5A,0x00,0x00,0x00,0x38,0x00,0x03,0x5B,0x00,0x00,0x00}},
\r
121 //CECx : clkb1, clkb2
\r
122 {LCM_SEND(2), {0x00,0xC0}},
\r
123 {LCM_SEND(17), {15, 0, 0xCE,0x30,0x00,0x03,0x5C,0x00,0x00,0x00,0x30,0x01,0x03,0x5D,0x00,0x00,0x00}},
\r
125 //CEDx : clkb3, clkb4
\r
126 {LCM_SEND(2), {0x00,0xD0}},
\r
127 {LCM_SEND(17), {15, 0, 0xCE,0x30,0x02,0x03,0x5E,0x00,0x00,0x00,0x30,0x03,0x03,0x5F,0x00,0x00,0x00}},
\r
129 {LCM_SEND(2), {0x00, 0xC7}},
\r
130 {LCM_SEND(2), {0xCF, 0x00}},
\r
132 {LCM_SEND(2), {0x00, 0xC9}},
\r
133 {LCM_SEND(2), {0xCF, 0x00}},
\r
135 {LCM_SEND(2), {0x00, 0xC4}},
\r
136 {LCM_SEND(9), {7, 0, 0xCB,0x04,0x04,0x04,0x04,0x04,0x04}},
\r
138 {LCM_SEND(2), {0x00, 0xD9}},
\r
139 {LCM_SEND(9), {7, 0, 0xCB,0x04,0x04,0x04,0x04,0x04,0x04}},
\r
141 {LCM_SEND(2), {0x00, 0x84}},
\r
142 {LCM_SEND(9), {7, 0, 0xCC,0x0C,0x0A,0x10,0x0E,0x03,0x04}},
\r
144 {LCM_SEND(2), {0x00,0x9E}},
\r
145 {LCM_SEND(2), {0xCC,0x0B}},
\r
147 {LCM_SEND(2), {0x00,0xA0}},
\r
148 {LCM_SEND(8), {6, 0, 0xCC,0x09,0x0F,0x0D,0x01,0x02}},
\r
150 {LCM_SEND(2), {0x00,0xB4}},
\r
151 {LCM_SEND(9), {7, 0, 0xCC,0x0D,0x0F,0x09,0x0B,0x02,0x01}},
\r
153 {LCM_SEND(2), {0x00,0xCE}},
\r
154 {LCM_SEND(2), {0xCC,0x0E}},
\r
156 {LCM_SEND(2), {0x00,0xD0}},
\r
157 {LCM_SEND(8), {6, 0, 0xCC,0x10,0x0A,0x0C,0x04,0x03}},
\r
159 {LCM_SEND(2), {0x00,0x00}},
\r
160 {LCM_SEND(2), {0x3A,0x77}},
\r
162 {LCM_SEND(2), {0x11, 0x00}}, // sleep out
\r
164 {LCM_SEND(2), {0x29, 0x00}}, // display on
\r
166 {LCM_SEND(1), {0x2C}}, // normal on
\r
172 static LCM_Force_Cmd_Code rd_prep_code[]={
\r
173 {0x37, {LCM_SEND(2), {0x5, 0}}},
\r
176 static LCM_Init_Code disp_on = {LCM_SEND(1), {0x29}};
\r
178 static LCM_Init_Code sleep_in = {LCM_SEND(1), {0x10}};
\r
180 static LCM_Init_Code sleep_out = {LCM_SEND(1), {0x11}};
\r
182 static int32_t otm8018b_mipi_init(struct panel_spec *self)
\r
185 LCM_Init_Code *init = init_data;
\r
188 mipi_set_cmd_mode_t mipi_set_cmd_mode = self->info.mipi->ops->mipi_set_cmd_mode;
\r
189 mipi_gen_write_t mipi_gen_write = self->info.mipi->ops->mipi_gen_write;
\r
191 LCD_PRINT("otm8018b_mipi_init\n");
\r
193 mipi_set_cmd_mode();
\r
195 for(i = 0; i < ARRAY_SIZE(init_data); i++){
\r
196 tag = (init->tag >>24);
\r
197 if(tag & LCM_TAG_SEND){
\r
198 mipi_gen_write(init->data, (init->tag & LCM_TAG_MASK));
\r
199 }else if(tag & LCM_TAG_SLEEP){
\r
200 udelay((init->tag & LCM_TAG_MASK) * 1000);
\r
207 static uint32_t otm8018b_readid(struct panel_spec *self)
\r
209 /*Jessica TODO: need read id*/
\r
212 LCM_Force_Cmd_Code * rd_prepare = rd_prep_code;
\r
213 uint8_t read_data[5] = {0};
\r
214 int32_t read_rtn = 0;
\r
215 unsigned int tag = 0;
\r
217 mipi_set_cmd_mode_t mipi_set_cmd_mode = self->info.mipi->ops->mipi_set_cmd_mode;
\r
218 mipi_force_write_t mipi_force_write = self->info.mipi->ops->mipi_force_write;
\r
219 mipi_force_read_t mipi_force_read = self->info.mipi->ops->mipi_force_read;
\r
221 printk("lcd_otm8018b_mipi read id!\n");
\r
222 mipi_set_cmd_mode();
\r
223 for(j = 0; j < 4; j++){
\r
224 rd_prepare = rd_prep_code;
\r
225 for(i = 0; i < ARRAY_SIZE(rd_prep_code); i++){
\r
226 tag = (rd_prepare->real_cmd_code.tag >> 24);
\r
227 if(tag & LCM_TAG_SEND){
\r
228 mipi_force_write(rd_prepare->datatype, rd_prepare->real_cmd_code.data, (rd_prepare->real_cmd_code.tag & LCM_TAG_MASK));
\r
229 }else if(tag & LCM_TAG_SLEEP){
\r
230 udelay((rd_prepare->real_cmd_code.tag & LCM_TAG_MASK) * 1000);
\r
235 read_rtn = mipi_force_read(0xa1, 3,(uint8_t *)read_data);
\r
236 printk("lcd_otm8018b_mipi read id 0xa1 value is 0x%x, 0x%x, 0x%x, 0x%x, 0x%x!\n",
\r
237 read_data[0], read_data[1], read_data[2], read_data[3], read_data[4]);
\r
239 if((0x01 == read_data[0])&&(0x8b == read_data[1])&&(0x80 == read_data[2])&&(0x09 == read_data[3])&&(0xff == read_data[4])){
\r
240 printk("lcd_otm8018b_mipi read id success!\n");
\r
245 printk("lcd_otm8018b_mipi identify fail!\n");
\r
249 static struct panel_operations lcd_otm8018b_mipi_operations = {
\r
250 .panel_init = otm8018b_mipi_init,
\r
251 .panel_readid = otm8018b_readid,
\r
254 static struct timing_rgb lcd_otm8018b_mipi_timing = {
\r
255 .hfp = 80, /* unit: pixel */
\r
258 .vfp = 10, /*unit: line*/
\r
263 static struct info_mipi lcd_otm8018b_mipi_info = {
\r
264 .work_mode = SPRDFB_MIPI_MODE_VIDEO,
\r
265 .video_bus_width = 24, /*18,16*/
\r
267 .phy_feq = 500*1000,
\r
268 //.h_sync_pol = SPRDFB_POLARITY_POS,
\r
269 //.v_sync_pol = SPRDFB_POLARITY_POS,
\r
270 //.de_pol = SPRDFB_POLARITY_POS,
\r
271 .te_pol = SPRDFB_POLARITY_POS,
\r
272 //.color_mode_pol = SPRDFB_POLARITY_POS,
\r
273 //.shut_down_pol = SPRDFB_POLARITY_POS,
\r
274 .timing = &lcd_otm8018b_mipi_timing,
\r
278 struct panel_spec lcd_otm8018b_mipi_spec = {
\r
281 .type = LCD_MODE_DSI,
\r
282 .direction = LCD_DIRECT_NORMAL,
\r
284 .mipi = &lcd_otm8018b_mipi_info
\r
286 .ops = &lcd_otm8018b_mipi_operations,
\r