import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / misc / mediatek / lcm / nt35595_fhd_dsi_vdo_truly / nt35595_fhd_dsi_vdo_truly.c
1 /* BEGIN PN:DTS2013053103858 , Added by d00238048, 2013.05.31*/
2 #ifndef BUILD_LK
3 #include <linux/string.h>
4 #endif
5 #include "lcm_drv.h"
6
7 #ifdef BUILD_LK
8 #include <platform/mt_gpio.h>
9 #include <platform/mt_i2c.h>
10 #include <platform/mt_pmic.h>
11 #elif defined(BUILD_UBOOT)
12 #include <asm/arch/mt_gpio.h>
13 #else
14 #include <mach/mt_pm_ldo.h>
15 #include <mach/mt_gpio.h>
16 #endif
17 #include <cust_gpio_usage.h>
18 #include <cust_i2c.h>
19 #ifdef BUILD_LK
20 #define LCD_DEBUG(fmt) dprintf(CRITICAL,fmt)
21 #else
22 #define LCD_DEBUG(fmt) printk(fmt)
23 #endif
24
25
26 static const unsigned int BL_MIN_LEVEL =20;
27 static LCM_UTIL_FUNCS lcm_util;
28
29 #define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
30 #define MDELAY(n) (lcm_util.mdelay(n))
31
32 // ---------------------------------------------------------------------------
33 // Local Functions
34 // ---------------------------------------------------------------------------
35
36 #define dsi_set_cmdq_V2(cmd, count, ppara, force_update) lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
37 #define dsi_set_cmdq(pdata, queue_size, force_update) lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
38 #define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
39 #define write_regs(addr, pdata, byte_nums) lcm_util.dsi_write_regs(addr, pdata, byte_nums)
40 #define read_reg(cmd) lcm_util.dsi_dcs_read_lcm_reg(cmd)
41 #define read_reg_v2(cmd, buffer, buffer_size) lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
42
43 #ifndef BUILD_LK
44 #include <linux/kernel.h>
45 #include <linux/module.h>
46 #include <linux/fs.h>
47 #include <linux/slab.h>
48 #include <linux/init.h>
49 #include <linux/list.h>
50 #include <linux/i2c.h>
51 #include <linux/irq.h>
52 //#include <linux/jiffies.h>
53 #include <linux/uaccess.h>
54 //#include <linux/delay.h>
55 #include <linux/interrupt.h>
56 #include <linux/io.h>
57 #include <linux/platform_device.h>
58 /*****************************************************************************
59 * Define
60 *****************************************************************************/
61
62 #define TPS_I2C_BUSNUM I2C_I2C_LCD_BIAS_CHANNEL//for I2C channel 0
63 #define I2C_ID_NAME "tps65132"
64 #define TPS_ADDR 0x3E
65
66 /*****************************************************************************
67 * GLobal Variable
68 *****************************************************************************/
69 static struct i2c_board_info __initdata tps65132_board_info = {I2C_BOARD_INFO(I2C_ID_NAME, TPS_ADDR)};
70 static struct i2c_client *tps65132_i2c_client = NULL;
71
72
73 /*****************************************************************************
74 * Function Prototype
75 *****************************************************************************/
76 static int tps65132_probe(struct i2c_client *client, const struct i2c_device_id *id);
77 static int tps65132_remove(struct i2c_client *client);
78 /*****************************************************************************
79 * Data Structure
80 *****************************************************************************/
81
82 struct tps65132_dev {
83 struct i2c_client *client;
84
85 };
86
87 static const struct i2c_device_id tps65132_id[] = {
88 { I2C_ID_NAME, 0 },
89 { }
90 };
91
92 //#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36))
93 //static struct i2c_client_address_data addr_data = { .forces = forces,};
94 //#endif
95 static struct i2c_driver tps65132_iic_driver = {
96 .id_table = tps65132_id,
97 .probe = tps65132_probe,
98 .remove = tps65132_remove,
99 //.detect = mt6605_detect,
100 .driver = {
101 .owner = THIS_MODULE,
102 .name = "tps65132",
103 },
104
105 };
106 /*****************************************************************************
107 * Extern Area
108 *****************************************************************************/
109
110
111
112 /*****************************************************************************
113 * Function
114 *****************************************************************************/
115 static int tps65132_probe(struct i2c_client *client, const struct i2c_device_id *id)
116 {
117 printk( "tps65132_iic_probe\n");
118 printk("TPS: info==>name=%s addr=0x%x\n",client->name,client->addr);
119 tps65132_i2c_client = client;
120 return 0;
121 }
122
123
124 static int tps65132_remove(struct i2c_client *client)
125 {
126 printk( "tps65132_remove\n");
127 tps65132_i2c_client = NULL;
128 i2c_unregister_device(client);
129 return 0;
130 }
131
132
133 static int tps65132_write_bytes(unsigned char addr, unsigned char value)
134 {
135 int ret = 0;
136 struct i2c_client *client = tps65132_i2c_client;
137 char write_data[2]={0};
138 write_data[0]= addr;
139 write_data[1] = value;
140 ret=i2c_master_send(client, write_data, 2);
141 if(ret<0)
142 printk("tps65132 write data fail !!\n");
143 return ret ;
144 }
145
146
147
148 /*
149 * module load/unload record keeping
150 */
151
152 static int __init tps65132_iic_init(void)
153 {
154
155 printk( "tps65132_iic_init\n");
156 i2c_register_board_info(TPS_I2C_BUSNUM, &tps65132_board_info, 1);
157 printk( "tps65132_iic_init2\n");
158 i2c_add_driver(&tps65132_iic_driver);
159 printk( "tps65132_iic_init success\n");
160 return 0;
161 }
162
163 static void __exit tps65132_iic_exit(void)
164 {
165 printk( "tps65132_iic_exit\n");
166 i2c_del_driver(&tps65132_iic_driver);
167 }
168
169
170 module_init(tps65132_iic_init);
171 module_exit(tps65132_iic_exit);
172
173 MODULE_AUTHOR("Xiaokuan Shi");
174 MODULE_DESCRIPTION("MTK TPS65132 I2C Driver");
175 MODULE_LICENSE("GPL");
176
177 #endif
178
179 //static unsigned char lcd_id_pins_value = 0xFF;
180 static const unsigned char LCD_MODULE_ID = 0x01; // haobing modified 2013.07.11
181 // ---------------------------------------------------------------------------
182 // Local Constants
183 // ---------------------------------------------------------------------------
184 #define LCM_DSI_CMD_MODE 0
185 #define FRAME_WIDTH (1080)
186 #define FRAME_HEIGHT (1920)
187 #define GPIO_65132_EN GPIO_LCD_BIAS_ENP_PIN
188
189
190 #define REGFLAG_DELAY 0xFC
191 #define REGFLAG_END_OF_TABLE 0xFD // END OF REGISTERS MARKER
192
193
194 #ifndef TRUE
195 #define TRUE 1
196 #endif
197
198 #ifndef FALSE
199 #define FALSE 0
200 #endif
201 //static unsigned int lcm_esd_test = FALSE; ///only for ESD test
202 // ---------------------------------------------------------------------------
203 // Local Variables
204 // ---------------------------------------------------------------------------
205
206
207 struct LCM_setting_table {
208 unsigned char cmd;
209 unsigned char count;
210 unsigned char para_list[64];
211 };
212 //update initial param for IC nt35520 0.01
213 static struct LCM_setting_table lcm_suspend_setting[] = {
214 {0x28,0,{}},
215 {0x10,0,{}},
216 {REGFLAG_DELAY, 120, {}}
217 };
218
219 //update initial param for IC nt35520 0.01
220 static struct LCM_setting_table lcm_initialization_setting[] = {
221 {0xFF,1,{0x10}}, // Return To CMD1
222 {REGFLAG_DELAY, 2, {}},
223 #if (LCM_DSI_CMD_MODE)
224 {0xBB,1,{0x10}},
225 #else
226 {0xBB,1,{0x03}},
227 #endif
228 {0x3B,5,{0x03,0x0A,0x0A,0x0A,0x0A}},
229 {0x53,1,{0x24}},
230 {0x55,1,{0x00}},
231 {0x5E,1,{0x00}},
232 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
233
234 {0x11,0,{}},
235 {REGFLAG_DELAY, 150, {}},
236 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
237 {0xFF,1,{0x24}}, // CMD2 Page 4 Entrance
238 {REGFLAG_DELAY, 2, {}},
239 {0xFB,1,{0x01}},
240 {0x9D,1,{0xB0}},
241 {0x72,1,{0x00}},
242 {0x93,1,{0x04}},
243 {0x94,1,{0x04}},
244 {0x9B,1,{0x0F}},
245 {0x8A,1,{0x33}},
246 {0x86,1,{0x1B}},
247 {0x87,1,{0x39}},
248 {0x88,1,{0x1B}},
249 {0x89,1,{0x39}},
250 {0x8B,1,{0xF4}},
251 {0x8C,1,{0x01}},
252 {0x90,1,{0x79}},
253 {0x91,1,{0x4C}},
254 {0x92,1,{0x79}},
255 {0x95,1,{0xE4}},
256
257 {0xDE,1,{0xFF}},
258 {0xDF,1,{0x82}},
259
260 {0x00,1,{0x0F}},
261 {0x01,1,{0x00}},
262 {0x02,1,{0x00}},
263 {0x03,1,{0x00}},
264 {0x04,1,{0x0B}},
265 {0x05,1,{0x0C}},
266 {0x06,1,{0x00}},
267 {0x07,1,{0x00}},
268 {0x08,1,{0x00}},
269 {0x09,1,{0x00}},
270 {0x0A,1,{0X03}},
271 {0x0B,1,{0X04}},
272 {0x0C,1,{0x01}},
273 {0x0D,1,{0x13}},
274 {0x0E,1,{0x15}},
275 {0x0F,1,{0x17}},
276 {0x10,1,{0x0F}},
277 {0x11,1,{0x00}},
278 {0x12,1,{0x00}},
279 {0x13,1,{0x00}},
280 {0x14,1,{0x0B}},
281 {0x15,1,{0x0C}},
282 {0x16,1,{0x00}},
283 {0x17,1,{0x00}},
284 {0x18,1,{0x00}},
285 {0x19,1,{0x00}},
286 {0x1A,1,{0x03}},
287 {0x1B,1,{0X04}},
288 {0x1C,1,{0x01}},
289 {0x1D,1,{0x13}},
290 {0x1E,1,{0x15}},
291 {0x1F,1,{0x17}},
292
293 {0x20,1,{0x09}},
294 {0x21,1,{0x01}},
295 {0x22,1,{0x00}},
296 {0x23,1,{0x00}},
297 {0x24,1,{0x00}},
298 {0x25,1,{0x6D}},
299 {0x26,1,{0x00}},
300 {0x27,1,{0x00}},
301
302 {0x2F,1,{0x02}},
303 {0x30,1,{0x04}},
304 {0x31,1,{0x49}},
305 {0x32,1,{0x23}},
306 {0x33,1,{0x01}},
307 {0x34,1,{0x00}},
308 {0x35,1,{0x69}},
309 {0x36,1,{0x00}},
310 {0x37,1,{0x2D}},
311 {0x38,1,{0x08}},
312 {0x39,1,{0x00}},
313 {0x3A,1,{0x69}},
314
315 {0x29,1,{0x58}},
316 {0x2A,1,{0x16}},
317
318 {0x5B,1,{0x00}},
319 {0x5F,1,{0x75}},
320 {0x63,1,{0x00}},
321 {0x67,1,{0x04}},
322
323 {0x7B,1,{0x80}},
324 {0x7C,1,{0xD8}},
325 {0x7D,1,{0x60}},
326 {0x7E,1,{0x10}},
327 {0x7F,1,{0x19}},
328 {0x80,1,{0x00}},
329 {0x81,1,{0x06}},
330 {0x82,1,{0x03}},
331 {0x83,1,{0x00}},
332 {0x84,1,{0x03}},
333 {0x85,1,{0x07}},
334 {0x74,1,{0x10}},
335 {0x75,1,{0x19}},
336 {0x76,1,{0x06}},
337 {0x77,1,{0x03}},
338
339 {0x78,1,{0x00}},
340 {0x79,1,{0x00}},
341 {0x99,1,{0x33}},
342 {0x98,1,{0x00}},
343 {0xB3,1,{0x28}},
344 {0xB4,1,{0x05}},
345 {0xB5,1,{0x10}},
346
347 {0xFF,1,{0x20}}, // Page 0,1,{ power-related setting
348 {REGFLAG_DELAY, 2, {}},
349 {0x00,1,{0x01}},
350 {0x01,1,{0x55}},
351 {0x02,1,{0x45}},
352 {0x03,1,{0x55}},
353 {0x05,1,{0x50}},
354 {0x06,1,{0x9E}},
355 {0x07,1,{0xA8}},
356 {0x08,1,{0x0C}},
357 {0x0B,1,{0x96}},
358 {0x0C,1,{0x96}},
359 {0x0E,1,{0x00}},
360 {0x0F,1,{0x00}},
361 {0x11,1,{0x29}},
362 {0x12,1,{0x29}},
363 {0x13,1,{0x03}},
364 {0x14,1,{0x0A}},
365 {0x15,1,{0x99}},
366 {0x16,1,{0x99}},
367 {0x6D,1,{0x44}},
368 {0x58,1,{0x05}},
369 {0x59,1,{0x05}},
370 {0x5A,1,{0x05}},
371 {0x5B,1,{0x05}},
372 {0x5C,1,{0x00}},
373 {0x5D,1,{0x00}},
374 {0x5E,1,{0x00}},
375 {0x5F,1,{0x00}},
376
377 {0x1B,1,{0x39}},
378 {0x1C,1,{0x39}},
379 {0x1D,1,{0x47}},
380
381 {0xFF,1,{0x20}}, // Page 0,1,{ power-related setting
382 {REGFLAG_DELAY, 2, {}},
383 // R+ ,1,{}},
384 {0x75,1,{0x00}},
385 {0x76,1,{0x00}},
386 {0x77,1,{0x00}},
387 {0x78,1,{0x22}},
388 {0x79,1,{0x00}},
389 {0x7A,1,{0x46}},
390 {0x7B,1,{0x00}},
391 {0x7C,1,{0x5C}},
392 {0x7D,1,{0x00}},
393 {0x7E,1,{0x76}},
394 {0x7F,1,{0x00}},
395 {0x80,1,{0x8D}},
396 {0x81,1,{0x00}},
397 {0x82,1,{0xA6}},
398 {0x83,1,{0x00}},
399 {0x84,1,{0xB8}},
400 {0x85,1,{0x00}},
401 {0x86,1,{0xC7}},
402 {0x87,1,{0x00}},
403 {0x88,1,{0xF6}},
404 {0x89,1,{0x01}},
405 {0x8A,1,{0x1D}},
406 {0x8B,1,{0x01}},
407 {0x8C,1,{0x54}},
408 {0x8D,1,{0x01}},
409 {0x8E,1,{0x81}},
410 {0x8F,1,{0x01}},
411 {0x90,1,{0xCB}},
412 {0x91,1,{0x02}},
413 {0x92,1,{0x05}},
414 {0x93,1,{0x02}},
415 {0x94,1,{0x07}},
416 {0x95,1,{0x02}},
417 {0x96,1,{0x47}},
418 {0x97,1,{0x02}},
419 {0x98,1,{0x82}},
420 {0x99,1,{0x02}},
421 {0x9A,1,{0xAB}},
422 {0x9B,1,{0x02}},
423 {0x9C,1,{0xDC}},
424 {0x9D,1,{0x03}},
425 {0x9E,1,{0x01}},
426 {0x9F,1,{0x03}},
427 {0xA0,1,{0x3A}},
428 {0xA2,1,{0x03}},
429 {0xA3,1,{0x56}},
430 {0xA4,1,{0x03}},
431 {0xA5,1,{0x6D}},
432 {0xA6,1,{0x03}},
433 {0xA7,1,{0x89}},
434 {0xA9,1,{0x03}},
435 {0xAA,1,{0xA3}},
436 {0xAB,1,{0x03}},
437 {0xAC,1,{0xC9}},
438 {0xAD,1,{0x03}},
439 {0xAE,1,{0xDD}},
440 {0xAF,1,{0x03}},
441 {0xB0,1,{0xF5}},
442 {0xB1,1,{0x03}},
443 {0xB2,1,{0xFF}},
444 // R- ,1,{}},
445 {0xB3,1,{0x00}},
446 {0xB4,1,{0x00}},
447 {0xB5,1,{0x00}},
448 {0xB6,1,{0x22}},
449 {0xB7,1,{0x00}},
450 {0xB8,1,{0x46}},
451 {0xB9,1,{0x00}},
452 {0xBA,1,{0x5C}},
453 {0xBB,1,{0x00}},
454 {0xBC,1,{0x76}},
455 {0xBD,1,{0x00}},
456 {0xBE,1,{0x8D}},
457 {0xBF,1,{0x00}},
458 {0xC0,1,{0xA6}},
459 {0xC1,1,{0x00}},
460 {0xC2,1,{0xB8}},
461 {0xC3,1,{0x00}},
462 {0xC4,1,{0xC7}},
463 {0xC5,1,{0x00}},
464 {0xC6,1,{0xF6}},
465 {0xC7,1,{0x01}},
466 {0xC8,1,{0x1D}},
467 {0xC9,1,{0x01}},
468 {0xCA,1,{0x54}},
469 {0xCB,1,{0x01}},
470 {0xCC,1,{0x81}},
471 {0xCD,1,{0x01}},
472 {0xCE,1,{0xCB}},
473 {0xCF,1,{0x02}},
474 {0xD0,1,{0x05}},
475 {0xD1,1,{0x02}},
476 {0xD2,1,{0x07}},
477 {0xD3,1,{0x02}},
478 {0xD4,1,{0x47}},
479 {0xD5,1,{0x02}},
480 {0xD6,1,{0x82}},
481 {0xD7,1,{0x02}},
482 {0xD8,1,{0xAB}},
483 {0xD9,1,{0x02}},
484 {0xDA,1,{0xDC}},
485 {0xDB,1,{0x03}},
486 {0xDC,1,{0x01}},
487 {0xDD,1,{0x03}},
488 {0xDE,1,{0x3A}},
489 {0xDF,1,{0x03}},
490 {0xE0,1,{0x56}},
491 {0xE1,1,{0x03}},
492 {0xE2,1,{0x6D}},
493 {0xE3,1,{0x03}},
494 {0xE4,1,{0x89}},
495 {0xE5,1,{0x03}},
496 {0xE6,1,{0xA3}},
497 {0xE7,1,{0x03}},
498 {0xE8,1,{0xC9}},
499 {0xE9,1,{0x03}},
500 {0xEA,1,{0xDD}},
501 {0xEB,1,{0x03}},
502 {0xEC,1,{0xF5}},
503 {0xED,1,{0x03}},
504 {0xEE,1,{0xFF}},
505 // G+ ,1,{}},
506 {0xEF,1,{0x00}},
507 {0xF0,1,{0x00}},
508 {0xF1,1,{0x00}},
509 {0xF2,1,{0x22}},
510 {0xF3,1,{0x00}},
511 {0xF4,1,{0x46}},
512 {0xF5,1,{0x00}},
513 {0xF6,1,{0x5C}},
514 {0xF7,1,{0x00}},
515 {0xF8,1,{0x76}},
516 {0xF9,1,{0x00}},
517 {0xFA,1,{0x8D}},
518
519 {0xFF,1,{0x21}}, // Page 0,1,{ power-related setting
520 {REGFLAG_DELAY, 2, {}},
521 {0x00,1,{0x00}},
522 {0x01,1,{0xA6}},
523 {0x02,1,{0x00}},
524 {0x03,1,{0xB8}},
525 {0x04,1,{0x00}},
526 {0x05,1,{0xC7}},
527 {0x06,1,{0x00}},
528 {0x07,1,{0xF6}},
529 {0x08,1,{0x01}},
530 {0x09,1,{0x1D}},
531 {0x0A,1,{0x01}},
532 {0x0B,1,{0x54}},
533 {0x0C,1,{0x01}},
534 {0x0D,1,{0x81}},
535 {0x0E,1,{0x01}},
536 {0x0F,1,{0xCB}},
537 {0x10,1,{0x02}},
538 {0x11,1,{0x05}},
539 {0x12,1,{0x02}},
540 {0x13,1,{0x07}},
541 {0x14,1,{0x02}},
542 {0x15,1,{0x47}},
543 {0x16,1,{0x02}},
544 {0x17,1,{0x82}},
545 {0x18,1,{0x02}},
546 {0x19,1,{0xAB}},
547 {0x1A,1,{0x02}},
548 {0x1B,1,{0xDC}},
549 {0x1C,1,{0x03}},
550 {0x1D,1,{0x01}},
551 {0x1E,1,{0x03}},
552 {0x1F,1,{0x3A}},
553 {0x20,1,{0x03}},
554 {0x21,1,{0x56}},
555 {0x22,1,{0x03}},
556 {0x23,1,{0x6D}},
557 {0x24,1,{0x03}},
558 {0x25,1,{0x89}},
559 {0x26,1,{0x03}},
560 {0x27,1,{0xA3}},
561 {0x28,1,{0x03}},
562 {0x29,1,{0xC9}},
563 {0x2A,1,{0x03}},
564 {0x2B,1,{0xDD}},
565 {0x2D,1,{0x03}},
566 {0x2F,1,{0xF5}},
567 {0x30,1,{0x03}},
568 {0x31,1,{0xFF}},
569 // G- ,1,{}},
570 {0x32,1,{0x00}},
571 {0x33,1,{0x00}},
572 {0x34,1,{0x00}},
573 {0x35,1,{0x22}},
574 {0x36,1,{0x00}},
575 {0x37,1,{0x46}},
576 {0x38,1,{0x00}},
577 {0x39,1,{0x5C}},
578 {0x3A,1,{0x00}},
579 {0x3B,1,{0x76}},
580 {0x3D,1,{0x00}},
581 {0x3F,1,{0x8D}},
582 {0x40,1,{0x00}},
583 {0x41,1,{0xA6}},
584 {0x42,1,{0x00}},
585 {0x43,1,{0xB8}},
586 {0x44,1,{0x00}},
587 {0x45,1,{0xC7}},
588 {0x46,1,{0x00}},
589 {0x47,1,{0xF6}},
590 {0x48,1,{0x01}},
591 {0x49,1,{0x1D}},
592 {0x4A,1,{0x01}},
593 {0x4B,1,{0x54}},
594 {0x4C,1,{0x01}},
595 {0x4D,1,{0x81}},
596 {0x4E,1,{0x01}},
597 {0x4F,1,{0xCB}},
598 {0x50,1,{0x02}},
599 {0x51,1,{0x05}},
600 {0x52,1,{0x02}},
601 {0x53,1,{0x07}},
602 {0x54,1,{0x02}},
603 {0x55,1,{0x47}},
604 {0x56,1,{0x02}},
605 {0x58,1,{0x82}},
606 {0x59,1,{0x02}},
607 {0x5A,1,{0xAB}},
608 {0x5B,1,{0x02}},
609 {0x5C,1,{0xDC}},
610 {0x5D,1,{0x03}},
611 {0x5E,1,{0x01}},
612 {0x5F,1,{0x03}},
613 {0x60,1,{0x3A}},
614 {0x61,1,{0x03}},
615 {0x62,1,{0x56}},
616 {0x63,1,{0x03}},
617 {0x64,1,{0x6D}},
618 {0x65,1,{0x03}},
619 {0x66,1,{0x89}},
620 {0x67,1,{0x03}},
621 {0x68,1,{0xA3}},
622 {0x69,1,{0x03}},
623 {0x6A,1,{0xC9}},
624 {0x6B,1,{0x03}},
625 {0x6C,1,{0xDD}},
626 {0x6D,1,{0x03}},
627 {0x6E,1,{0xF5}},
628 {0x6F,1,{0x03}},
629 {0x70,1,{0xFF}},
630 // B+ ,1,{}},
631 {0x71,1,{0x00}},
632 {0x72,1,{0x00}},
633 {0x73,1,{0x00}},
634 {0x74,1,{0x22}},
635 {0x75,1,{0x00}},
636 {0x76,1,{0x46}},
637 {0x77,1,{0x00}},
638 {0x78,1,{0x5C}},
639 {0x79,1,{0x00}},
640 {0x7A,1,{0x76}},
641 {0x7B,1,{0x00}},
642 {0x7C,1,{0x8D}},
643 {0x7D,1,{0x00}},
644 {0x7E,1,{0xA6}},
645 {0x7F,1,{0x00}},
646 {0x80,1,{0xB8}},
647 {0x81,1,{0x00}},
648 {0x82,1,{0xC7}},
649 {0x83,1,{0x00}},
650 {0x84,1,{0xF6}},
651 {0x85,1,{0x01}},
652 {0x86,1,{0x1D}},
653 {0x87,1,{0x01}},
654 {0x88,1,{0x54}},
655 {0x89,1,{0x01}},
656 {0x8A,1,{0x81}},
657 {0x8B,1,{0x01}},
658 {0x8C,1,{0xCB}},
659 {0x8D,1,{0x02}},
660 {0x8E,1,{0x05}},
661 {0x8F,1,{0x02}},
662 {0x90,1,{0x07}},
663 {0x91,1,{0x02}},
664 {0x92,1,{0x47}},
665 {0x93,1,{0x02}},
666 {0x94,1,{0x82}},
667 {0x95,1,{0x02}},
668 {0x96,1,{0xAB}},
669 {0x97,1,{0x02}},
670 {0x98,1,{0xDC}},
671 {0x99,1,{0x03}},
672 {0x9A,1,{0x01}},
673 {0x9B,1,{0x03}},
674 {0x9C,1,{0x3A}},
675 {0x9D,1,{0x03}},
676 {0x9E,1,{0x56}},
677 {0x9F,1,{0x03}},
678 {0xA0,1,{0x6D}},
679 {0xA2,1,{0x03}},
680 {0xA3,1,{0x89}},
681 {0xA4,1,{0x03}},
682 {0xA5,1,{0xA3}},
683 {0xA6,1,{0x03}},
684 {0xA7,1,{0xC9}},
685 {0xA9,1,{0x03}},
686 {0xAA,1,{0xDD}},
687 {0xAB,1,{0x03}},
688 {0xAC,1,{0xF5}},
689 {0xAD,1,{0x03}},
690 {0xAE,1,{0xFF}},
691 // B- ,1,{}},
692 {0xAF,1,{0x00}},
693 {0xB0,1,{0x00}},
694 {0xB1,1,{0x00}},
695 {0xB2,1,{0x22}},
696 {0xB3,1,{0x00}},
697 {0xB4,1,{0x46}},
698 {0xB5,1,{0x00}},
699 {0xB6,1,{0x5C}},
700 {0xB7,1,{0x00}},
701 {0xB8,1,{0x76}},
702 {0xB9,1,{0x00}},
703 {0xBA,1,{0x8D}},
704 {0xBB,1,{0x00}},
705 {0xBC,1,{0xA6}},
706 {0xBD,1,{0x00}},
707 {0xBE,1,{0xB8}},
708 {0xBF,1,{0x00}},
709 {0xC0,1,{0xC7}},
710 {0xC1,1,{0x00}},
711 {0xC2,1,{0xF6}},
712 {0xC3,1,{0x01}},
713 {0xC4,1,{0x1D}},
714 {0xC5,1,{0x01}},
715 {0xC6,1,{0x54}},
716 {0xC7,1,{0x01}},
717 {0xC8,1,{0x81}},
718 {0xC9,1,{0x01}},
719 {0xCA,1,{0xCB}},
720 {0xCB,1,{0x02}},
721 {0xCC,1,{0x05}},
722 {0xCD,1,{0x02}},
723 {0xCE,1,{0x07}},
724 {0xCF,1,{0x02}},
725 {0xD0,1,{0x47}},
726 {0xD1,1,{0x02}},
727 {0xD2,1,{0x82}},
728 {0xD3,1,{0x02}},
729 {0xD4,1,{0xAB}},
730 {0xD5,1,{0x02}},
731 {0xD6,1,{0xDC}},
732 {0xD7,1,{0x03}},
733 {0xD8,1,{0x01}},
734 {0xD9,1,{0x03}},
735 {0xDA,1,{0x3A}},
736 {0xDB,1,{0x03}},
737 {0xDC,1,{0x56}},
738 {0xDD,1,{0x03}},
739 {0xDE,1,{0x6D}},
740 {0xDF,1,{0x03}},
741 {0xE0,1,{0x89}},
742 {0xE1,1,{0x03}},
743 {0xE2,1,{0xA3}},
744 {0xE3,1,{0x03}},
745 {0xE4,1,{0xC9}},
746 {0xE5,1,{0x03}},
747 {0xE6,1,{0xDD}},
748 {0xE7,1,{0x03}},
749 {0xE8,1,{0xF5}},
750 {0xE9,1,{0x03}},
751 {0xEA,1,{0xFF}},
752
753 {0xFF,1,{0x21}}, // Page ,1,{ Gamma Default Update
754 {REGFLAG_DELAY, 2, {}},
755 {0xEB,1,{0x30}},
756 {0xEC,1,{0x17}},
757 {0xED,1,{0x20}},
758 {0xEE,1,{0x0F}},
759 {0xEF,1,{0x1F}},
760 {0xF0,1,{0x0F}},
761 {0xF1,1,{0x0F}},
762 {0xF2,1,{0x07}},
763
764 {0xFF,1,{0x23}}, // CMD2 Page 3 Entrance
765 {REGFLAG_DELAY, 2, {}},
766 {0x08,1,{0x04}},
767 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
768 //image.first
769 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
770 {0xFF,1,{0x10}}, // Return To CMD1
771
772 {REGFLAG_DELAY, 2, {}},
773 {0x35,1,{0x00}},
774 {0x29,0,{}},
775 //{0x51,1,{0xFF}}, // write display brightness
776 };
777
778 #if 0
779 static struct LCM_setting_table lcm_set_window[] = {
780 {0x2A, 4, {0x00, 0x00, (FRAME_WIDTH>>8), (FRAME_WIDTH&0xFF)}},
781 {0x2B, 4, {0x00, 0x00, (FRAME_HEIGHT>>8), (FRAME_HEIGHT&0xFF)}},
782 {REGFLAG_END_OF_TABLE, 0x00, {}}
783 };
784 #endif
785 #if 0
786 static struct LCM_setting_table lcm_sleep_out_setting[] = {
787 //Sleep Out
788 {0x11, 1, {0x00}},
789 {REGFLAG_DELAY, 120, {}},
790
791 // Display ON
792 {0x29, 1, {0x00}},
793 {REGFLAG_DELAY, 20, {}},
794 {REGFLAG_END_OF_TABLE, 0x00, {}}
795 };
796 #endif
797
798 static struct LCM_setting_table lcm_deep_sleep_mode_in_setting[] = {
799 // Display off sequence
800 {0x28, 1, {0x00}},
801 {REGFLAG_DELAY, 20, {}},
802
803 // Sleep Mode On
804 {0x10, 1, {0x00}},
805 {REGFLAG_DELAY, 120, {}},
806 {REGFLAG_END_OF_TABLE, 0x00, {}}
807 };
808
809 static void push_table(struct LCM_setting_table *table, unsigned int count, unsigned char force_update)
810 {
811 unsigned int i;
812
813 for(i = 0; i < count; i++)
814 {
815 unsigned cmd;
816 cmd = table[i].cmd;
817
818 switch (cmd) {
819
820 case REGFLAG_DELAY :
821 if(table[i].count <= 10)
822 MDELAY(table[i].count);
823 else
824 MDELAY(table[i].count);
825 break;
826
827 case REGFLAG_END_OF_TABLE :
828 break;
829
830 default:
831 dsi_set_cmdq_V2(cmd, table[i].count, table[i].para_list, force_update);
832 }
833 }
834 }
835
836 // ---------------------------------------------------------------------------
837 // LCM Driver Implementations
838 // ---------------------------------------------------------------------------
839
840 static void lcm_set_util_funcs(const LCM_UTIL_FUNCS *util)
841 {
842 memcpy(&lcm_util, util, sizeof(LCM_UTIL_FUNCS));
843 }
844
845
846 static void lcm_get_params(LCM_PARAMS *params)
847 {
848 memset(params, 0, sizeof(LCM_PARAMS));
849
850 params->type = LCM_TYPE_DSI;
851
852 params->width = FRAME_WIDTH;
853 params->height = FRAME_HEIGHT;
854
855 #if (LCM_DSI_CMD_MODE)
856 params->dsi.mode = CMD_MODE;
857 #else
858 params->dsi.mode = SYNC_PULSE_VDO_MODE;
859 #endif
860
861 // DSI
862 /* Command mode setting */
863 params->dsi.LANE_NUM = LCM_FOUR_LANE;
864 //The following defined the fomat for data coming from LCD engine.
865 params->dsi.data_format.color_order = LCM_COLOR_ORDER_RGB;
866 params->dsi.data_format.trans_seq = LCM_DSI_TRANS_SEQ_MSB_FIRST;
867 params->dsi.data_format.padding = LCM_DSI_PADDING_ON_LSB;
868 params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888;
869
870 // Highly depends on LCD driver capability.
871 params->dsi.packet_size=256;
872 //video mode timing
873
874 params->dsi.PS=LCM_PACKED_PS_24BIT_RGB888;
875
876 params->dsi.vertical_sync_active = 2;
877 params->dsi.vertical_backporch = 8;
878 params->dsi.vertical_frontporch = 10;
879 params->dsi.vertical_active_line = FRAME_HEIGHT;
880
881 params->dsi.horizontal_sync_active = 10;
882 params->dsi.horizontal_backporch = 20;
883 params->dsi.horizontal_frontporch = 40;
884 params->dsi.horizontal_active_pixel = FRAME_WIDTH;
885 //params->dsi.ssc_disable = 1;
886 #if (LCM_DSI_CMD_MODE)
887 params->dsi.PLL_CLOCK = 500; //this value must be in MTK suggested table
888 #else
889 params->dsi.PLL_CLOCK = 450; //this value must be in MTK suggested table
890 #endif
891
892 }
893
894 #ifdef BUILD_LK
895
896 #define TPS65132_SLAVE_ADDR_WRITE 0x7C
897 static struct mt_i2c_t TPS65132_i2c;
898
899 int TPS65132_write_byte(kal_uint8 addr, kal_uint8 value)
900 {
901 kal_uint32 ret_code = I2C_OK;
902 kal_uint8 write_data[2];
903 kal_uint16 len;
904
905 write_data[0]= addr;
906 write_data[1] = value;
907
908 TPS65132_i2c.id = I2C_I2C_LCD_BIAS_CHANNEL;//I2C2;
909 /* Since i2c will left shift 1 bit, we need to set FAN5405 I2C address to >>1 */
910 TPS65132_i2c.addr = (TPS65132_SLAVE_ADDR_WRITE >> 1);
911 TPS65132_i2c.mode = ST_MODE;
912 TPS65132_i2c.speed = 100;
913 len = 2;
914
915 ret_code = i2c_write(&TPS65132_i2c, write_data, len);
916 //printf("%s: i2c_write: ret_code: %d\n", __func__, ret_code);
917
918 return ret_code;
919 }
920
921 #else
922
923 // extern int mt8193_i2c_write(u16 addr, u32 data);
924 // extern int mt8193_i2c_read(u16 addr, u32 *data);
925
926 // #define TPS65132_write_byte(add, data) mt8193_i2c_write(add, data)
927 //#define TPS65132_read_byte(add) mt8193_i2c_read(add)
928
929
930 #endif
931
932
933 static void lcm_init_power(void)
934 {
935
936 #ifdef BUILD_LK
937 mt6331_upmu_set_rg_vgp1_en(1);
938 #else
939 hwPowerOn(MT6331_POWER_LDO_VGP1, VOL_DEFAULT, "LCM_DRV");
940 #endif
941 }
942
943 static void lcm_suspend_power(void)
944 {
945 #ifdef BUILD_LK
946 mt6331_upmu_set_rg_vgp1_en(0);
947 #else
948 hwPowerDown(MT6331_POWER_LDO_VGP1, "LCM_DRV");
949 #endif
950
951 }
952
953 static void lcm_resume_power(void)
954 {
955 #ifdef BUILD_LK
956 mt6331_upmu_set_rg_vgp1_en(1);
957 #else
958 hwPowerOn(MT6331_POWER_LDO_VGP1, VOL_DEFAULT, "LCM_DRV");
959 #endif
960 }
961
962
963 static void lcm_init(void)
964 {
965 unsigned char cmd = 0x0;
966 unsigned char data = 0xFF;
967 int ret=0;
968 cmd=0x00;
969 data=0x0a;
970
971 mt_set_gpio_mode(GPIO_65132_EN, GPIO_MODE_00);
972 mt_set_gpio_dir(GPIO_65132_EN, GPIO_DIR_OUT);
973 mt_set_gpio_out(GPIO_65132_EN, GPIO_OUT_ONE);
974
975 #ifdef BUILD_LK
976 ret=TPS65132_write_byte(cmd,data);
977 if(ret)
978 dprintf(0, "[LK]nt35595----tps6132----cmd=%0x--i2c write error----\n",cmd);
979 else
980 dprintf(0, "[LK]nt35595----tps6132----cmd=%0x--i2c write success----\n",cmd);
981 #else
982 ret=tps65132_write_bytes(cmd,data);
983 if(ret<0)
984 printk("[KERNEL]nt35595----tps6132---cmd=%0x-- i2c write error-----\n",cmd);
985 else
986 printk("[KERNEL]nt35595----tps6132---cmd=%0x-- i2c write success-----\n",cmd);
987 #endif
988
989 MDELAY(500);
990 cmd=0x01;
991 data=0x0a;
992 #ifdef BUILD_LK
993 ret=TPS65132_write_byte(cmd,data);
994 if(ret)
995 dprintf(0, "[LK]nt35595----tps6132----cmd=%0x--i2c write error----\n",cmd);
996 else
997 dprintf(0, "[LK]nt35595----tps6132----cmd=%0x--i2c write success----\n",cmd);
998 #else
999 ret=tps65132_write_bytes(cmd,data);
1000 if(ret<0)
1001 printk("[KERNEL]nt35595----tps6132---cmd=%0x-- i2c write error-----\n",cmd);
1002 else
1003 printk("[KERNEL]nt35595----tps6132---cmd=%0x-- i2c write success-----\n",cmd);
1004 #endif
1005
1006 SET_RESET_PIN(1);
1007 MDELAY(10);
1008
1009 SET_RESET_PIN(0);
1010 MDELAY(10);
1011
1012 SET_RESET_PIN(1);
1013 MDELAY(10);
1014
1015 // when phone initial , config output high, enable backlight drv chip
1016 push_table(lcm_initialization_setting, sizeof(lcm_initialization_setting) / sizeof(struct LCM_setting_table), 1);
1017 }
1018
1019 static void lcm_suspend(void)
1020 {
1021 push_table(lcm_suspend_setting, sizeof(lcm_suspend_setting) / sizeof(struct LCM_setting_table), 1);
1022
1023 mt_set_gpio_mode(GPIO_65132_EN, GPIO_MODE_00);
1024 mt_set_gpio_dir(GPIO_65132_EN, GPIO_DIR_OUT);
1025 mt_set_gpio_out(GPIO_65132_EN, GPIO_OUT_ZERO);
1026
1027 }
1028
1029 static void lcm_resume(void)
1030 {
1031 SET_RESET_PIN(1);
1032 MDELAY(10);
1033
1034 SET_RESET_PIN(0);
1035 MDELAY(10);
1036
1037 SET_RESET_PIN(1);
1038 MDELAY(10);
1039
1040 lcm_init();
1041 }
1042
1043 static void lcm_update(unsigned int x, unsigned int y, unsigned int width, unsigned int height)
1044 {
1045 unsigned int x0 = x;
1046 unsigned int y0 = y;
1047 unsigned int x1 = x0 + width - 1;
1048 unsigned int y1 = y0 + height - 1;
1049
1050 unsigned char x0_MSB = ((x0>>8)&0xFF);
1051 unsigned char x0_LSB = (x0&0xFF);
1052 unsigned char x1_MSB = ((x1>>8)&0xFF);
1053 unsigned char x1_LSB = (x1&0xFF);
1054 unsigned char y0_MSB = ((y0>>8)&0xFF);
1055 unsigned char y0_LSB = (y0&0xFF);
1056 unsigned char y1_MSB = ((y1>>8)&0xFF);
1057 unsigned char y1_LSB = (y1&0xFF);
1058
1059 unsigned int data_array[16];
1060
1061 data_array[0]= 0x00053902;
1062 data_array[1]= (x1_MSB<<24)|(x0_LSB<<16)|(x0_MSB<<8)|0x2a;
1063 data_array[2]= (x1_LSB);
1064 dsi_set_cmdq(data_array, 3, 1);
1065
1066 data_array[0]= 0x00053902;
1067 data_array[1]= (y1_MSB<<24)|(y0_LSB<<16)|(y0_MSB<<8)|0x2b;
1068 data_array[2]= (y1_LSB);
1069 dsi_set_cmdq(data_array, 3, 1);
1070
1071 data_array[0]= 0x002c3909;
1072 dsi_set_cmdq(data_array, 1, 0);
1073 }
1074
1075 static unsigned int lcm_compare_id(void)
1076 {
1077
1078 }
1079
1080 LCM_DRIVER nt35595_fhd_dsi_vdo_truly_lcm_drv=
1081 {
1082 .name = "nt35595_fhd_dsi_vdo_truly_lcm_drv",
1083 .set_util_funcs = lcm_set_util_funcs,
1084 .get_params = lcm_get_params,
1085 .init = lcm_init,/*tianma init fun.*/
1086 .suspend = lcm_suspend,
1087 .resume = lcm_resume,
1088 .compare_id = lcm_compare_id,
1089 .init_power = lcm_init_power,
1090 .resume_power = lcm_resume_power,
1091 .suspend_power = lcm_suspend_power,
1092 #if (LCM_DSI_CMD_MODE)
1093 .update = lcm_update,
1094 #endif
1095
1096 };
1097 /* END PN:DTS2013053103858 , Added by d00238048, 2013.05.31*/