Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.07 KB | None | 0 0
  1. #ifdef BUILD_LK
  2. #else
  3. #include <linux/string.h>
  4. #endif
  5.  
  6. #include "lcm_drv.h"
  7. #ifdef BUILD_LK
  8. #include <platform/mt_gpio.h>
  9. #elif defined(BUILD_UBOOT)
  10. #include <asm/arch/mt_gpio.h>
  11. #else
  12. #include <mach/mt_gpio.h>
  13. #endif
  14.  
  15. #include <cust_adc.h>
  16. #define MIN_VOLTAGE (0) //++++rgk bug-id:no modify by yangjuwei 20140401
  17. #define MAX_VOLTAGE (300) //++++rgk bug-id:no modify by yangjuwei 20140401
  18.  
  19. #define FRAME_WIDTH (720)
  20. #define FRAME_HEIGHT (1280)
  21.  
  22. #define GPIO_LCD_ENN GPIO_LCD_BIAS_ENN_PIN //sophiarui
  23. #define GPIO_LCD_ENP GPIO_LCD_BIAS_ENP_PIN //sophiarui
  24.  
  25. #define REGFLAG_DELAY 0XFFE
  26. #define REGFLAG_END_OF_TABLE 0x1FF // END OF REGISTERS MARKER
  27.  
  28. #define LCM_DSI_CMD_MODE 0
  29.  
  30. static unsigned int lcm_esd_test = FALSE; ///only for ESD test
  31.  
  32. static LCM_UTIL_FUNCS lcm_util = {0};
  33.  
  34. #define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
  35.  
  36. #define UDELAY(n) (lcm_util.udelay(n))
  37. #define MDELAY(n) (lcm_util.mdelay(n))
  38.  
  39.  
  40. // ---------------------------------------------------------------------------
  41. // Local Functions
  42. // ---------------------------------------------------------------------------
  43. #define dsi_set_cmdq_V2(cmd, count, ppara, force_update) lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
  44. #define dsi_set_cmdq(pdata, queue_size, force_update) lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
  45. #define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
  46. #define write_regs(addr, pdata, byte_nums) lcm_util.dsi_write_regs(addr, pdata, byte_nums)
  47. #define read_reg lcm_util.dsi_read_reg()
  48. #define read_reg_v2(cmd, buffer, buffer_size) lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
  49. extern int IMM_GetOneChannelValue(int dwChannel, int data[4], int* rawdata);
  50.  
  51. static struct LCM_setting_table {
  52. unsigned cmd;
  53. unsigned char count;
  54. unsigned char para_list[64];
  55. };
  56. #ifndef BUILD_LK
  57. extern atomic_t ESDCheck_byCPU;
  58. #endif
  59.  
  60. static void lcm_set_util_funcs(const LCM_UTIL_FUNCS *util)
  61. {
  62. memcpy(&lcm_util, util, sizeof(LCM_UTIL_FUNCS));
  63. }
  64.  
  65.  
  66. static void lcm_get_params(LCM_PARAMS *params)
  67. {
  68.  
  69. memset(params, 0, sizeof(LCM_PARAMS));
  70.  
  71. params->type = LCM_TYPE_DSI;
  72.  
  73. params->width = FRAME_WIDTH;
  74. params->height = FRAME_HEIGHT;
  75.  
  76.  
  77. #if (LCM_DSI_CMD_MODE)
  78. params->dsi.mode = CMD_MODE;
  79. #else
  80. params->dsi.mode = SYNC_PULSE_VDO_MODE; //SYNC_PULSE_VDO_MODE;//BURST_VDO_MODE;
  81. #endif
  82.  
  83. // DSI
  84. /* Command mode setting */
  85. //1 Three lane or Four lane
  86. params->dsi.LANE_NUM = LCM_FOUR_LANE;
  87. //The following defined the fomat for data coming from LCD engine.
  88. params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888;
  89.  
  90. // Video mode setting
  91. params->dsi.PS=LCM_PACKED_PS_24BIT_RGB888;
  92.  
  93. params->dsi.vertical_sync_active = 8;// 3 2
  94. params->dsi.vertical_backporch = 18;// 20 1
  95. params->dsi.vertical_frontporch = 20; // 1 12
  96. params->dsi.vertical_active_line = FRAME_HEIGHT;
  97.  
  98. params->dsi.horizontal_sync_active = 20;// 50 2
  99. params->dsi.horizontal_backporch = 60;//90
  100. params->dsi.horizontal_frontporch = 70;//90
  101. params->dsi.horizontal_active_pixel = FRAME_WIDTH;
  102. // params->dsi.ssc_disable = 1;
  103. params->dsi.HS_TRAIL = 6;
  104. /*ui = 1000/(dis_params->PLL_CLOCK*2) + 0x01;
  105. cycle_time = 8000/(dis_params->PLL_CLOCK*2) + 0x01;
  106. HS_TRAIL = (0x04*ui + 0x50)/cycle_time;*/
  107. //params->dsi.LPX=8;
  108.  
  109. // Bit rate calculation
  110. //1 Every lane speed
  111. //params->dsi.pll_select=1;
  112. //params->dsi.PLL_CLOCK = LCM_DSI_6589_PLL_CLOCK_377;
  113. params->dsi.PLL_CLOCK=215;//208//270
  114. //params->dsi.noncont_clock=1;
  115. //params->dsi.noncont_clock_period=2;
  116. //params->dsi.pll_div1=0; // div1=0,1,2,3;div1_real=1,2,4,4 ----0: 546Mbps 1:273Mbps
  117. //params->dsi.pll_div2=0; // div2=0,1,2,3;div1_real=1,2,4,4
  118.  
  119. // params->dsi.fbk_div =7; // fref=26MHz, fvco=fref*(fbk_div+1)*2/(div1_real*div2_real)
  120. //params->dsi.compatibility_for_nvk = 1; // this parameter would be set to 1 if DriverIC is NTK's and when force match DSI clock for NTK's
  121. params->dsi.esd_check_enable = 1;
  122. params->dsi.customization_esd_check_enable = 1;
  123. params->dsi.lcm_esd_check_table[0].cmd = 0x09;
  124. params->dsi.lcm_esd_check_table[0].count = 3;
  125. params->dsi.lcm_esd_check_table[0].para_list[0] = 0x80;
  126. params->dsi.lcm_esd_check_table[0].para_list[1] = 0x03;
  127. params->dsi.lcm_esd_check_table[0].para_list[2] = 0x06;
  128.  
  129.  
  130. }
  131.  
  132. //static unsigned int vcom = 0x30;
  133. static void push_table(struct LCM_setting_table *table, unsigned int count, unsigned char force_update)
  134. {
  135. unsigned int i;
  136.  
  137. for(i = 0; i < count; i++)
  138. {
  139. unsigned cmd;
  140. cmd = table[i].cmd;
  141.  
  142. switch (cmd)
  143. {
  144. case REGFLAG_DELAY :
  145. MDELAY(table[i].count);
  146. break;
  147. case REGFLAG_END_OF_TABLE :
  148. break;
  149. /*case 0xd9 :
  150. table[i].para_list[0] = vcom;
  151. vcom +=2;
  152. dsi_set_cmdq_V2(cmd, table[i].count, table[i].para_list, force_update);
  153. break;*/
  154. default:
  155. dsi_set_cmdq_V2(cmd, table[i].count, table[i].para_list, force_update);
  156. }
  157. }
  158. }
  159.  
  160. static struct LCM_setting_table lcm_initialization_setting[] = {
  161. {0xFF,3,{0x98,0x81,0x03}},
  162.  
  163. {0x01,1,{0x00}},
  164.  
  165. {0x02,1,{0x00}},
  166.  
  167. {0x03,1,{0x53}},
  168.  
  169. {0x04,1,{0x13}},
  170.  
  171. {0x05,1,{0x13}},
  172.  
  173. {0x06,1,{0x06}},
  174.  
  175. {0x07,1,{0x00}},
  176.  
  177. {0x08,1,{0x04}},
  178.  
  179. {0x09,1,{0x00}},
  180.  
  181. {0x0a,1,{0x00}},
  182.  
  183. {0x0b,1,{0x00}},
  184.  
  185. {0x0C,1,{0x00}},
  186.  
  187. {0x0D,1,{0x00}},
  188.  
  189. {0x0E,1,{0x00}},
  190.  
  191. {0x0f,1,{0x00}},
  192.  
  193. {0x10,1,{0x00}},
  194.  
  195. {0x11,1,{0x00}},
  196.  
  197. {0x12,1,{0x00}},
  198.  
  199. {0x13,1,{0x00}},
  200.  
  201. {0x14,1,{0x00}},
  202.  
  203. {0x15,1,{0x00}},
  204.  
  205. {0x16,1,{0x00}},
  206.  
  207. {0x17,1,{0x00}},
  208.  
  209. {0x18,1,{0x00}},
  210.  
  211. {0x19,1,{0x00}},
  212.  
  213. {0x1A,1,{0x00}},
  214.  
  215. {0x1B,1,{0x00}},
  216.  
  217. {0x1C,1,{0x00}},
  218.  
  219. {0x1D,1,{0x00}},
  220.  
  221. {0x1E,1,{0xC0}},
  222.  
  223. {0x1F,1,{0x80}},
  224.  
  225. {0x20,1,{0x04}},
  226.  
  227. {0x21,1,{0x0B}},
  228.  
  229. {0x22,1,{0x00}},
  230.  
  231. {0x23,1,{0x00}},
  232.  
  233. {0x24,1,{0x00}},
  234.  
  235. {0x25,1,{0x00}},
  236.  
  237. {0x26,1,{0x00}},
  238.  
  239. {0x27,1,{0x00}},
  240.  
  241. {0x28,1,{0x55}},
  242.  
  243. {0x29,1,{0x03}},
  244.  
  245. {0x2A,1,{0x00}},
  246.  
  247. {0x2B,1,{0x00}},
  248.  
  249. {0x2C,1,{0x00}},
  250.  
  251. {0x2D,1,{0x00}},
  252.  
  253. {0x2E,1,{0x00}},
  254.  
  255. {0x2F,1,{0x00}},
  256.  
  257. {0x30,1,{0x00}},
  258.  
  259. {0x31,1,{0x00}},
  260.  
  261. {0x32,1,{0x00}},
  262.  
  263. {0x33,1,{0x00}},
  264.  
  265. {0x34,1,{0x04}},
  266.  
  267. {0x35,1,{0x05}},
  268.  
  269. {0x36,1,{0x05}},
  270.  
  271. {0x37,1,{0x00}},
  272.  
  273. {0x38,1,{0x3C}},
  274.  
  275. {0x39,1,{0x00}},
  276.  
  277. {0x3A,1,{0x40}},
  278.  
  279. {0x3B,1,{0x40}},
  280.  
  281. {0x3C,1,{0x00}},
  282.  
  283. {0x3D,1,{0x00}},
  284.  
  285. {0x3E,1,{0x00}},
  286.  
  287. {0x3F,1,{0x00}},
  288.  
  289. {0x40,1,{0x00}},
  290.  
  291. {0x41,1,{0x00}},
  292.  
  293. {0x42,1,{0x00}},
  294.  
  295. {0x43,1,{0x00}},
  296.  
  297. {0x44,1,{0x00}},
  298.  
  299. {0x50,1,{0x01}},
  300.  
  301. {0x51,1,{0x23}},
  302.  
  303. {0x52,1,{0x45}},
  304.  
  305. {0x53,1,{0x67}},
  306.  
  307. {0x54,1,{0x89}},
  308.  
  309. {0x55,1,{0xAB}},
  310.  
  311. {0x56,1,{0x01}},
  312.  
  313. {0x57,1,{0x23}},
  314.  
  315. {0x58,1,{0x45}},
  316.  
  317. {0x59,1,{0x67}},
  318.  
  319. {0x5A,1,{0x89}},
  320.  
  321. {0x5B,1,{0xAB}},
  322.  
  323. {0x5C,1,{0xCD}},
  324.  
  325. {0x5D,1,{0xEF}},
  326.  
  327. {0x5E,1,{0x01}},
  328.  
  329. {0x5F,1,{0x14}},
  330.  
  331. {0x60,1,{0x15}},
  332.  
  333. {0x61,1,{0x0C}},
  334.  
  335. {0x62,1,{0x0D}},
  336.  
  337. {0x63,1,{0x0E}},
  338.  
  339. {0x64,1,{0x0F}},
  340.  
  341. {0x65,1,{0x10}},
  342.  
  343. {0x66,1,{0x11}},
  344.  
  345. {0x67,1,{0x08}},
  346.  
  347. {0x68,1,{0x02}},
  348.  
  349. {0x69,1,{0x0A}},
  350.  
  351. {0x6A,1,{0x02}},
  352.  
  353. {0x6B,1,{0x02}},
  354.  
  355. {0x6C,1,{0x02}},
  356.  
  357. {0x6D,1,{0x02}},
  358.  
  359. {0x6E,1,{0x02}},
  360.  
  361. {0x6F,1,{0x02}},
  362.  
  363. {0x70,1,{0x02}},
  364.  
  365. {0x71,1,{0x02}},
  366.  
  367. {0x72,1,{0x06}},
  368.  
  369. {0x73,1,{0x02}},
  370.  
  371. {0x74,1,{0x02}},
  372.  
  373. {0x75,1,{0x14}},
  374.  
  375. {0x76,1,{0x15}},
  376.  
  377. {0x77,1,{0x11}},
  378.  
  379. {0x78,1,{0x10}},
  380.  
  381. {0x79,1,{0x0F}},
  382.  
  383. {0x7A,1,{0x0E}},
  384.  
  385. {0x7B,1,{0x0D}},
  386.  
  387. {0x7C,1,{0x0C}},
  388.  
  389. {0x7D,1,{0x06}},
  390.  
  391. {0x7E,1,{0x02}},
  392.  
  393. {0x7F,1,{0x0A}},
  394.  
  395. {0x80,1,{0x02}},
  396.  
  397. {0x81,1,{0x02}},
  398.  
  399. {0x82,1,{0x02}},
  400.  
  401. {0x83,1,{0x02}},
  402.  
  403. {0x84,1,{0x02}},
  404.  
  405. {0x85,1,{0x02}},
  406.  
  407. {0x86,1,{0x02}},
  408.  
  409. {0x87,1,{0x02}},
  410.  
  411. {0x88,1,{0x08}},
  412.  
  413. {0x89,1,{0x02}},
  414.  
  415. {0x8A,1,{0x02}},
  416.  
  417. {0xFF,3,{0x98,0x81,0x04}},
  418.  
  419. {0x6C,1,{0x15}},
  420.  
  421. {0x6E,1,{0x3B}},
  422. {0xb5,1,{0x06}},
  423. {0x31,1,{0x75}},
  424.  
  425.  
  426. {0x6F,1,{0x57}}, // reg vcl + pumping ratio VGH=4x VGL=-2.5x
  427.  
  428. {0x3A,1,{0xA4}},
  429.  
  430. {0x8D,1,{0x15}},
  431.  
  432. {0x87,1,{0xBA}},
  433.  
  434. {0x26,1,{0x76}},
  435.  
  436. {0XB2,1,{0XD1}},
  437.  
  438. {0X88,1,{0X0B}},
  439.  
  440. {0xFF,3,{0x98,0x81,0x01}},
  441.  
  442. {0x22,1,{0x0A}},
  443.  
  444. {0x31,1,{0x00}},
  445.  
  446. {0x53,1,{0x8A}},
  447.  
  448. {0x55,1,{0x88}},
  449.  
  450. {0x50,1,{0xA0}},
  451.  
  452. {0x51,1,{0xA0}},
  453.  
  454. {0x60,1,{0x14}},
  455.  
  456. {0xA0,1,{0x08}},
  457.  
  458. {0xA1,1,{0x21}},
  459.  
  460. {0xA2,1,{0x30}},
  461.  
  462. {0xA3,1,{0x0F}},
  463.  
  464. {0xA4,1,{0x11}},
  465.  
  466. {0xA5,1,{0x27}},
  467.  
  468. {0xA6,1,{0x1C}},
  469.  
  470. {0xA7,1,{0x1E}},
  471.  
  472. {0xA8,1,{0x8C}},
  473.  
  474. {0xA9,1,{0x1B}},
  475.  
  476. {0xAA,1,{0x28}},
  477.  
  478. {0xAB,1,{0x74}},
  479.  
  480. {0xAC,1,{0x1A}},
  481.  
  482. {0xAD,1,{0x19}},
  483.  
  484. {0xAE,1,{0x4D}},
  485.  
  486. {0xAF,1,{0x21}},
  487.  
  488. {0xB0,1,{0x28}},
  489.  
  490. {0xB1,1,{0x4a}},
  491.  
  492. {0xB2,1,{0x5b}},
  493.  
  494. {0xB3,1,{0x2C}},
  495.  
  496. {0xC0,1,{0x08}},
  497.  
  498. {0xC1,1,{0x21}},
  499.  
  500. {0xC2,1,{0x30}},
  501.  
  502. {0xC3,1,{0x0F}},
  503.  
  504. {0xC4,1,{0x11}},
  505.  
  506. {0xC5,1,{0x27}},
  507.  
  508. {0xC6,1,{0x1C}},
  509.  
  510. {0xC7,1,{0x1E}},
  511.  
  512. {0xC8,1,{0x8C}},
  513.  
  514. {0xC9,1,{0x1B}},
  515.  
  516. {0xCA,1,{0x28}},
  517.  
  518. {0xCB,1,{0x74}},
  519.  
  520. {0xCC,1,{0x1A}},
  521.  
  522. {0xCD,1,{0x19}},
  523.  
  524. {0xCE,1,{0x4D}},
  525.  
  526. {0xCF,1,{0x21}},
  527.  
  528. {0xD0,1,{0x28}},
  529.  
  530. {0xD1,1,{0x4a}},
  531.  
  532. {0xD2,1,{0x59}},
  533.  
  534. {0xD3,1,{0x2C}},
  535.  
  536. {0xFF,3,{0x98,0x81,0x00}},
  537.  
  538. {0x35,1,{0x00}},
  539.  
  540. {0x11,1,{0x00}},
  541.  
  542. {REGFLAG_DELAY, 120, {}},
  543.  
  544. {0x29,1,{0x00}},
  545.  
  546. {REGFLAG_DELAY, 20, {}},
  547.  
  548. {REGFLAG_END_OF_TABLE, 0x00, {}},
  549. };
  550.  
  551. #ifdef BUILD_LK
  552. #include <platform/mt_gpio.h>
  553. #include <platform/mt_i2c.h>
  554. #include <platform/mt_pmic.h>
  555.  
  556. #define TPS65132_SLAVE_ADDR_WRITE 0x7C
  557. static struct mt_i2c_t TPS65132_i2c;
  558.  
  559. static int TPS65132_write_byte(kal_uint8 addr, kal_uint8 value)
  560. {
  561. kal_uint32 ret_code = I2C_OK;
  562. kal_uint8 write_data[2];
  563. kal_uint16 len;
  564.  
  565. write_data[0]= addr;
  566. write_data[1] = value;
  567.  
  568. TPS65132_i2c.id = 1;//I2C2;
  569. /* Since i2c will left shift 1 bit, we need to set FAN5405 I2C address to >>1 */
  570. TPS65132_i2c.addr = (TPS65132_SLAVE_ADDR_WRITE >> 1);
  571. TPS65132_i2c.mode = ST_MODE;
  572. TPS65132_i2c.speed = 100;
  573. len = 2;
  574.  
  575. ret_code = i2c_write(&TPS65132_i2c, write_data, len);
  576. //printf("%s: i2c_write: ret_code: %d\n", __func__, ret_code);
  577.  
  578. return ret_code;
  579. }
  580. #else
  581. extern int tps65132_write_bytes(unsigned char addr, unsigned char value);
  582. #endif
  583. static void lcm_init(void)
  584. {
  585. int ret=0;
  586.  
  587. //printk("%s %d\n", __func__,__LINE__);
  588.  
  589. mt_set_gpio_mode(GPIO_LCD_ENP, GPIO_MODE_00);
  590. mt_set_gpio_dir(GPIO_LCD_ENP, GPIO_DIR_OUT);
  591. mt_set_gpio_out(GPIO_LCD_ENP, GPIO_OUT_ONE);
  592. #ifdef BUILD_LK
  593. ret=TPS65132_write_byte(0x0, 0xC); //5.2V
  594. if(ret)
  595. dprintf("[LK]ili9881c_txd ----tps6132----ret=%0x--i2c write error----\n",ret);
  596. else
  597. dprintf("[LK]ili9881c_txd ----tps6132----ret=%0x--i2c write success----\n",ret);
  598. #else
  599. ret=tps65132_write_bytes(0x0, 0xC);
  600.  
  601. if(ret<0)
  602. printk("[KERNEL]ili9881c_txd ----tps6132---ret=%0x-- i2c write error-----\n",ret);
  603. else
  604. printk("[KERNEL]ili9881c_txd ----tps6132---ret=%0x-- i2c write success-----\n",ret);
  605. #endif
  606. MDELAY(5);
  607.  
  608. mt_set_gpio_mode(GPIO_LCD_ENN, GPIO_MODE_00);
  609. mt_set_gpio_dir(GPIO_LCD_ENN, GPIO_DIR_OUT);
  610. mt_set_gpio_out(GPIO_LCD_ENN, GPIO_OUT_ONE);
  611. #ifdef BUILD_LK
  612. ret=TPS65132_write_byte(0x1, 0xC); //-5.2v
  613. if(ret)
  614. dprintf(0, "[LK]ili9881c_txd ----tps6132----ret=%0x--i2c write error----\n",ret);
  615. else
  616. dprintf(0, "[LK]ili9881c_txd ----tps6132----ret=%0x--i2c write success----\n",ret);
  617. #else
  618. ret=tps65132_write_bytes(0x1, 0xC);
  619. if(ret<0)
  620. printk("[KERNEL]ili9881c_txd ----tps6132---ret=%0x-- i2c write error-----\n",ret);
  621. else
  622. printk("[KERNEL]ili9881c_txd ----tps6132---ret=%0x-- i2c write success-----\n",ret);
  623. #endif
  624. //MDELAY(10);
  625.  
  626. SET_RESET_PIN(1);
  627. MDELAY(1);
  628. SET_RESET_PIN(0);
  629. MDELAY(10);
  630. SET_RESET_PIN(1);
  631. MDELAY(120);
  632. push_table(lcm_initialization_setting, sizeof(lcm_initialization_setting) / sizeof(struct LCM_setting_table), 1);
  633.  
  634. }
  635.  
  636. static void lcm_update(unsigned int x, unsigned int y,
  637. unsigned int width, unsigned int height)
  638. {
  639. unsigned int x0 = x;
  640. unsigned int y0 = y;
  641. unsigned int x1 = x0 + width - 1;
  642. unsigned int y1 = y0 + height - 1;
  643.  
  644. unsigned char x0_MSB = ((x0>>8)&0xFF);
  645. unsigned char x0_LSB = (x0&0xFF);
  646. unsigned char x1_MSB = ((x1>>8)&0xFF);
  647. unsigned char x1_LSB = (x1&0xFF);
  648. unsigned char y0_MSB = ((y0>>8)&0xFF);
  649. unsigned char y0_LSB = (y0&0xFF);
  650. unsigned char y1_MSB = ((y1>>8)&0xFF);
  651. unsigned char y1_LSB = (y1&0xFF);
  652.  
  653. unsigned int data_array[16];
  654.  
  655. data_array[0]= 0x00053902;
  656. data_array[1]= (x1_MSB<<24)|(x0_LSB<<16)|(x0_MSB<<8)|0x2a;
  657. data_array[2]= (x1_LSB);
  658. dsi_set_cmdq(&data_array, 3, 1);
  659.  
  660. data_array[0]= 0x00053902;
  661. data_array[1]= (y1_MSB<<24)|(y0_LSB<<16)|(y0_MSB<<8)|0x2b;
  662. data_array[2]= (y1_LSB);
  663. dsi_set_cmdq(&data_array, 3, 1);
  664.  
  665. data_array[0]= 0x00290508;
  666. dsi_set_cmdq(&data_array, 1, 1);
  667.  
  668. data_array[0]= 0x002c3909;
  669. dsi_set_cmdq(&data_array, 1, 0);
  670.  
  671.  
  672. }
  673.  
  674. static struct LCM_setting_table lcm_exit_sleep_mode_setting[] = {
  675. {0x11,1,{0x00}}, // Sleep out
  676.  
  677. {REGFLAG_DELAY, 120, {}},
  678.  
  679. {0x29,1,{0x00}}, // Display on
  680.  
  681. {REGFLAG_DELAY, 20, {}},
  682.  
  683. {REGFLAG_END_OF_TABLE, 0x00, {}},
  684. };
  685.  
  686. static struct LCM_setting_table lcm_deep_sleep_mode_in_setting[] = {
  687. {0x28,1,{0x00}}, // Display off
  688.  
  689. {REGFLAG_DELAY, 20, {}},
  690.  
  691. {0x10,1,{0x00}}, // Enter Sleep mode
  692.  
  693. {REGFLAG_DELAY, 120, {}},
  694.  
  695. {REGFLAG_END_OF_TABLE, 0x00, {}},
  696. };
  697.  
  698. static void lcm_suspend(void)
  699. {
  700. push_table(lcm_deep_sleep_mode_in_setting, sizeof(lcm_deep_sleep_mode_in_setting) / sizeof(struct LCM_setting_table), 1);
  701.  
  702. SET_RESET_PIN(1);
  703. MDELAY(1);
  704. SET_RESET_PIN(0);
  705. MDELAY(10);
  706. SET_RESET_PIN(1);
  707. MDELAY(120);
  708. lcm_util.set_gpio_out(GPIO_LCD_ENN , 0);//power on +5
  709. MDELAY(10);
  710. lcm_util.set_gpio_out(GPIO_LCD_ENP , 0);//power on -5
  711. MDELAY(10);
  712. }
  713.  
  714. static void lcm_resume(void)
  715. {
  716. lcm_init();
  717. }
  718.  
  719.  
  720. static unsigned int lcm_compare_id(void)
  721. {
  722. unsigned int hd_id1=0;
  723. int array[4], ret=0;
  724. char buffer[3];
  725. char id_high=0;
  726. char id_low=0;
  727. int id=0;
  728.  
  729. mt_set_gpio_mode(GPIO_LCD_ENP, GPIO_MODE_00);
  730. mt_set_gpio_dir(GPIO_LCD_ENP, GPIO_DIR_OUT);
  731. mt_set_gpio_out(GPIO_LCD_ENP, GPIO_OUT_ONE);
  732.  
  733. #ifdef BUILD_LK
  734. ret=TPS65132_write_byte(0x0 ,0xC); //5.2V
  735. if(ret)
  736. printf("[LK]ili9881c_dsi_vdo_txd ----tps65132----ret=%0x--i2c write error----\n",ret);
  737. else
  738. printf("[LK]ili9881c_dsi_vdo_txd ----tps6132----ret=%0x--i2c write success----\n",ret);
  739. #else
  740. ret=tps65132_write_bytes(0x0, 0xC);
  741.  
  742. if(ret<0)
  743. printk("[KERNEL]ili9881c_dsi_vdo_txd ----tps65132---ret=%0x-- i2c write error-----\n",ret);
  744. else
  745. printk("[KERNEL]ili9881c_dsi_vdo_txd ----tps65132---ret=%0x-- i2c write success-----\n",ret);
  746. #endif
  747. MDELAY(5);
  748. mt_set_gpio_mode(GPIO_LCD_ENN, GPIO_MODE_00);
  749. mt_set_gpio_dir(GPIO_LCD_ENN, GPIO_DIR_OUT);
  750. mt_set_gpio_out(GPIO_LCD_ENN, GPIO_OUT_ONE);
  751. #ifdef BUILD_LK
  752. ret=TPS65132_write_byte(0x1, 0xC); //-5.2v
  753. if(ret)
  754. dprintf(0, "[LK]ili9881c_dsi_vdo_txd ----tps65132----ret=%0x--i2c write error----\n",ret);
  755. else
  756. dprintf(0, "[LK]ili9881c_dsi_vdo_txd ----tps65132----ret=%0x--i2c write success----\n",ret);
  757. #else
  758. ret=tps65132_write_bytes(0x1, 0xC);
  759. if(ret<0)
  760. printk("[KERNEL]ili9881c_dsi_vdo_txd ----tps6132---ret=%0x-- i2c write error-----\n",ret);
  761. else
  762. printk("[KERNEL]ili9881c_dsi_vdo_txd ----tps6132---ret=%0x-- i2c write success-----\n",ret);
  763. #endif
  764. MDELAY(5);
  765.  
  766. SET_RESET_PIN(1);
  767. MDELAY(20);
  768. SET_RESET_PIN(0);
  769. MDELAY(20);
  770. SET_RESET_PIN(1);
  771. MDELAY(100);
  772.  
  773. //{0x39, 0xFF, 5, { 0xFF,0x98,0x06,0x04,0x01}}, // Change to Page 1 CMD
  774. array[0] = 0x00043902;
  775. array[1] = 0x018198FF;
  776. dsi_set_cmdq(array, 2, 1);
  777.  
  778. array[0] = 0x00013700;
  779. dsi_set_cmdq(array, 1, 1);
  780. read_reg_v2(0x00, &buffer[0], 1); //0x98
  781.  
  782. id = buffer[0];
  783.  
  784.  
  785. #ifdef BUILD_LK
  786.  
  787. hd_id1= mt_get_gpio_in(GPIO_LCD_ID1);//should be
  788. printf("jinmin ili9881c_dsi_vdo_txd [lk]=%d %d %d \n", buffer[0],buffer[1], buffer[2]);
  789. printf("id =0x%x\n", id);
  790. #else
  791. printk("jinmin ili9881c_dsi_vdo_txd [kernel]=%d %d %d \n", buffer[0],buffer[1], buffer[2]);
  792. printk("id =0x%x\n", id);
  793. #endif
  794.  
  795. if (0x98==id ) {
  796. //if(hd_id1==0)
  797. return 1;
  798. //else
  799. //return 0;
  800. }
  801. else
  802. return 0;
  803. }
  804.  
  805.  
  806. // zhoulidong add for lcm detect (start)
  807. static unsigned int rgk_lcm_compare_id(void)
  808. {
  809. int data[4] = {0,0,0,0};
  810. int res = 0;
  811. int rawdata = 0;
  812. int lcm_vol = 0;
  813.  
  814. #ifdef AUXADC_LCM_VOLTAGE_CHANNEL
  815. res = IMM_GetOneChannelValue(AUXADC_LCM_VOLTAGE_CHANNEL,data,&rawdata);
  816. if(res < 0)
  817. {
  818. #ifdef BUILD_LK
  819. printf("[adc_uboot]: jinmin get data error\n");
  820. #endif
  821. return 0;
  822.  
  823. }
  824. #endif
  825.  
  826. lcm_vol = data[0]*1000+data[1]*10;
  827.  
  828. #ifdef BUILD_LK
  829. printf("[adc_uboot]: jinmin lcm_vol= %d\n",lcm_vol);
  830. #endif
  831.  
  832. if (lcm_vol>=MIN_VOLTAGE &&lcm_vol <= MAX_VOLTAGE)// && lcm_compare_id())
  833. {
  834. return 1;
  835. }
  836.  
  837. return 0;
  838.  
  839. }
  840.  
  841. //add by yangjuwei
  842. static unsigned int lcm_ata_check(unsigned char *buffer)
  843. {
  844. #ifndef BUILD_LK
  845. int array[4];
  846. char buf[3];
  847. char id_high=0;
  848. char id_low=0;
  849. int id=0;
  850.  
  851. array[0] = 0x00043902;
  852. array[1] = 0x018198FF;
  853. dsi_set_cmdq(array, 2, 1);
  854.  
  855. array[0] = 0x00013700;
  856. dsi_set_cmdq(array, 1, 1);
  857. atomic_set(&ESDCheck_byCPU,1);
  858. read_reg_v2(0x00, &buf[0], 1); //0x98
  859. atomic_set(&ESDCheck_byCPU,0);
  860. id = buf[0];
  861. return (0x98 == id)?1:0;
  862. #else
  863. return 0;
  864. #endif
  865. }
  866.  
  867. LCM_DRIVER ili9881c_dsi_vdo_txd_lcm_drv =
  868. {
  869. .name = "ili9881c_dsi_vdo_txd",
  870. .set_util_funcs = lcm_set_util_funcs,
  871. .get_params = lcm_get_params,
  872. .init = lcm_init,
  873. .suspend = lcm_suspend,
  874. .resume = lcm_resume,
  875. .compare_id = lcm_compare_id,
  876. .ata_check = lcm_ata_check,
  877. #if (LCM_DSI_CMD_MODE)
  878. //.set_backlight = lcm_setbacklight,
  879. //.update = lcm_update,
  880. #endif
  881. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement