ft8006p_hd720_dsi_vdo.c~ 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. /*
  2. * Copyright (C) 2015 MediaTek Inc.
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #define LOG_TAG "LCM"
  14. #ifndef BUILD_LK
  15. #include <linux/string.h>
  16. #endif
  17. #ifdef BUILD_LK
  18. #include <platform/upmu_common.h>
  19. #include <platform/mt_gpio.h>
  20. #include <platform/mt_i2c.h>
  21. #include <platform/mt_pmic.h>
  22. #include <string.h>
  23. #ifndef MACH_FPGA
  24. #include <lcm_pmic.h>
  25. #endif
  26. #include "lcm_drv.h"
  27. #elif defined(BUILD_UBOOT)
  28. #include <asm/arch/mt_gpio.h>
  29. #include "lcm_drv.h"
  30. #else
  31. #include "lcm_drv.h"
  32. #include <linux/gpio.h>
  33. #include <linux/of.h>
  34. #include <linux/of_address.h>
  35. #include <linux/of_device.h>
  36. #include <linux/of_gpio.h>
  37. #include <mt-plat/upmu_common.h>//add by hxq
  38. #include <mach/mtk_pmic.h>//add by hxq for vldo28
  39. #ifdef CONFIG_OF
  40. #include <linux/regulator/consumer.h>
  41. #endif
  42. #endif
  43. #ifdef BUILD_LK
  44. #define LCM_LOGI(string, args...) dprintf(0, "[LK/"LOG_TAG"]"string, ##args)
  45. #define LCM_LOGD(string, args...) dprintf(1, "[LK/"LOG_TAG"]"string, ##args)
  46. #else
  47. #define LCM_LOGI(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
  48. #define LCM_LOGD(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
  49. #endif
  50. #define LCM_ID (0x98)
  51. static const unsigned int BL_MIN_LEVEL = 20;
  52. static LCM_UTIL_FUNCS lcm_util;1111
  53. #define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
  54. #define MDELAY(n) (lcm_util.mdelay(n))
  55. #define UDELAY(n) (lcm_util.udelay(n))
  56. // ---------------------------------------------------------------------------
  57. // Local Functions
  58. // ---------------------------------------------------------------------------
  59. #define GPIO_TP_RESET (GPIO54 | 0x80000000)
  60. #define GPIO_LCD_RST (GPIO45 | 0x80000000)//lcd rst stbyb
  61. #define dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update) \
  62. lcm_util.dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update)
  63. #define dsi_set_cmdq_V2(cmd, count, ppara, force_update) \
  64. lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
  65. #define dsi_set_cmdq(pdata, queue_size, force_update) \
  66. lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
  67. #define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
  68. #define write_regs(addr, pdata, byte_nums) \
  69. lcm_util.dsi_write_regs(addr, pdata, byte_nums)
  70. #define read_reg(cmd) \
  71. lcm_util.dsi_dcs_read_lcm_reg(cmd)
  72. #define read_reg_v2(cmd, buffer, buffer_size) \
  73. lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
  74. #ifndef BUILD_LK
  75. #include <linux/kernel.h>
  76. #include <linux/module.h>
  77. #include <linux/fs.h>
  78. #include <linux/slab.h>
  79. #include <linux/init.h>
  80. #include <linux/list.h>
  81. #include <linux/i2c.h>
  82. #include <linux/irq.h>
  83. /* #include <linux/jiffies.h> */
  84. /* #include <linux/delay.h> */
  85. #include <linux/uaccess.h>
  86. #include <linux/interrupt.h>
  87. #include <linux/io.h>
  88. #include <linux/platform_device.h>
  89. #endif
  90. /* static unsigned char lcd_id_pins_value = 0xFF; */
  91. static const unsigned char LCD_MODULE_ID = 0x01;
  92. #define LCM_DSI_CMD_MODE 0
  93. #define FRAME_WIDTH (576)
  94. #define FRAME_HEIGHT (1440)
  95. #define REGFLAG_DELAY 0xFFFC
  96. #define REGFLAG_UDELAY 0xFFFB
  97. #define REGFLAG_END_OF_TABLE 0xFFFD
  98. #ifndef TRUE
  99. #define TRUE 1
  100. #endif
  101. #ifndef FALSE
  102. #define FALSE 0
  103. #endif
  104. struct LCM_setting_table {
  105. unsigned int cmd;
  106. unsigned char count;
  107. unsigned char para_list[64];
  108. };
  109. static struct LCM_setting_table lcm_suspend_setting[] = {
  110. {0x28, 0, {} },
  111. {REGFLAG_DELAY, 20, {} },
  112. {0x10, 0, {} },
  113. {REGFLAG_DELAY, 120, {} },
  114. {REGFLAG_END_OF_TABLE, 0x00, {} }
  115. };
  116. static struct LCM_setting_table init_setting_vdo[] = {
  117. //------------- Display Initial Code Setting -------------------------
  118. //Stop reload
  119. {0x41, 1, {0x5A} },
  120. //INT CANCEL
  121. {0x4C, 1, {0x03} },
  122. //VCOM
  123. {0x41, 2, {0x5A,0x03} },
  124. {0x80, 2, {0xB0,0x00} },
  125. //----------------------LCD initial code start----------------------//
  126. //Blank 9
  127. {0x41, 2, {0x5A,0x09} },
  128. {0x80, 5, {0xa5,0x00,0xa5,0x00,0x01} },//
  129. //Blank 10
  130. {0x41, 2, {0x5A,0x0A} },
  131. {0x80, 16, {0xA5,0x15,0xA5,0xAA,0xA5,0x88,0x42,0x38,0x03,0x03,0x03,0x07,0x70,0x35,0x65,0x34} },
  132. {0x90, 16, {0x0C,0x0F,0x22,0x00,0x2A,0x18,0x64,0x00,0x88,0x03,0x03,0xEE,0xEE,0x00,0x3F,0x2A} },
  133. {0xA0, 16, {0x00,0x30,0x02,0x32,0x11,0x0D,0x60,0x01,0xFF,0xFF,0x03,0x40,0x42,0x0F,0x94,0x11} },
  134. {0xB0, 16, {0xE8,0x03,0x00,0x00,0x11,0x0D,0x60,0x00,0xFF,0xFF,0x03,0xFF,0x34,0x0C,0x0F,0x0E} },
  135. {0xC0, 10, {0x1F,0x03,0x00,0x08,0x20,0x34,0x00,0x00,0x00,0x00} },
  136. //Blank 11
  137. // {0x41, 2, 0x5A,0x0B} },
  138. //{0x80, 16, 0xFF,0xAA,0xAA,0x00,0x00,0x05,0x20,0x38,0x43,0x53,0x62,0x6F,0x70,0x7C,0x7C,0x8F} },
  139. //{0x90, 16, 0x76,0x65,0x67,0x5E,0x57,0x4C,0x3D,0x36,0x29,0x1A,0x07,0x03,0x00,0x05,0x20,0x38} },
  140. //{0xA0, 16, 0x43,0x53,0x62,0x6F,0x70,0x7C,0x7C,0x8F,0x76,0x65,0x67,0x5E,0x57,0x4C,0x3D,0x36} },
  141. //{0xB0, 5, 0x29,0x1A,0x07,0x03,0x00} },
  142. {0x41, 2, {0x5A,0x0B} },
  143. {0x80, 16, {0xFF,0xAA,0xAA,0x00,0x00,0x07,0x18,0x27,0x31,0x3B,0x4C,0x59,0x5B,0x67,0x69,0x7E} },
  144. {0x90, 16, {0x86,0x73,0x74,0x68,0x60,0x55,0x43,0x39,0x30,0x1E,0x09,0x03,0x00,0x07,0x18,0x27} },
  145. {0xA0, 16, {0x31,0x3B,0x4C,0x59,0x5B,0x67,0x69,0x7E,0x86,0x73,0x74,0x68,0x60,0x55,0x43,0x39} },
  146. {0xB0, 5, {0x30,0x1E,0x09,0x03,0x00} },
  147. //Blank 12
  148. {0x41, 2, {0x5A,0x0C} },
  149. {0x80, 16, {0x00,0x00,0x20,0x42,0x00,0x00,0x80,0x05,0x54,0x00,0x00,0x00,0x20,0x42,0x00,0x00} },
  150. {0x90, 2, {0x80,0x05} },
  151. //Blank 13
  152. {0x41, 2, {0x5A,0x0D} },
  153. {0x80, 16, {0x7A,0x40,0x02,0xA0,0x05,0x6E,0x01,0xE6,0x00,0x0A,0x0A,0x0A,0x0A,0x00,0x01,0x03} },
  154. {0x90, 16, {0x00,0x00,0x00,0x00,0xAC,0xA2,0x2A,0x00,0x00,0x00,0xAC,0xA2,0x2A,0x57,0x31,0x00} },
  155. {0xA0, 16, {0x01,0x00,0x00,0x00,0x00,0xAC,0xA2,0x2A,0xAA,0xC2,0x2A,0xAC,0xA2,0x2A,0xAA,0xC2} },
  156. {0xB0, 6, {0x2A,0x00,0x00,0x00,0xAA,0x52} },
  157. //Blank 14
  158. {0x41, 2, {0x5A,0x0E} },
  159. {0x80, 12, {0xF0,0xB1,0x71,0xEF,0x4B,0x00,0x37,0x0F,0xAA,0xAA,0x00,0x00} },
  160. //Blank 15
  161. {0x41, 2, {0x5A,0x0F} },
  162. {0x80, 11, {0xFF,0x00,0x55,0x55,0x23,0x88,0x88,0x1C,0x00,0x5A,0x5A} },
  163. //Blank 16
  164. {0x41, 2, {0x5A,0x10} },
  165. {0x80, 16, {0xB5,0x45,0x09,0x18,0x01,0x3C,0x94,0x32,0x10,0xC4,0xC4,0x04,0x00,0x60,0xC0,0x00} },
  166. {0x90, 16, {0x04,0x00,0x00,0x86,0x10,0x31,0x98,0x34,0x34,0x34,0x26,0x26,0x3E,0x1A,0x62,0x20} },
  167. {0xA0, 4, {0x0C,0x40,0x00,0x8A} },
  168. //Blank 17
  169. {0x41, 2, {0x5A,0x11} },
  170. {0x80, 16, {0x00,0x00,0x03,0xE7,0x1F,0x57,0x80,0x39,0x40,0x02,0x8F,0x1A,0x30,0x88,0x41,0x8A} },
  171. {0x90, 15, {0x39,0x28,0xA9,0xC5,0x9A,0x7B,0xF0,0x07,0x7E,0xE0,0x07,0x7E,0x20,0x10,0x00} },
  172. //Blank 18
  173. {0x41, 2, {0x5A,0x12} },
  174. {0x80, 16, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x37} },
  175. {0x90, 16, {0x2D,0x23,0x19,0x0F,0x05,0xFB,0xF1,0xE7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00} },
  176. {0xA0, 16, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00} },
  177. {0xB0, 16, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2D,0x23,0x05,0xFB,0x00,0x2D,0x23} },
  178. {0xC0, 4, {0x05,0xFB,0x00,0x01} },
  179. //Blank 19
  180. {0x41, 2, {0x5A,0x13} },
  181. {0x80, 16, {0xFD,0x0F,0x00,0x0C,0x00,0x80,0x00,0x81,0x00,0x07,0x22,0x06,0xE7,0xB9,0x86,0x1A} },
  182. {0x90, 16, {0x32,0x00,0xA2,0x2D,0x65,0x00,0x00,0x00,0x00,0xD0,0xC9,0xB7,0xFE,0x26,0x6F,0x32} },
  183. {0xA0, 3, {0x22,0x90,0x04} },
  184. //Blank 20
  185. {0x41, 2, {0x5A,0x14} },
  186. {0x80, 16, {0x91,0x01,0x80,0xA6,0xD0,0xDF,0xEF,0xF7,0xFB,0xFD,0x00,0x00,0x00,0xD0,0x8A,0x11} },
  187. {0x90, 16, {0x4D,0x7A,0x40,0x7C,0x68,0xD2,0x03,0x62,0x43,0x93,0x1E,0x10,0x17,0x9A,0xF4,0x80} },
  188. {0xA0, 16, {0x98,0xD1,0xA4,0x47,0x98,0x81,0x26,0x8D,0x00,0xA7,0x95,0xE1,0x60,0x20,0x40,0x00} },
  189. {0xB0, 16, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x5A,0xA3,0x55,0x00,0x80,0x42} },
  190. {0xC0, 16, {0xA1,0xF0,0x16,0xFE,0x5F,0x02,0xE7,0x00,0xDE,0xC1,0xFF,0x4B,0xE0,0x1C,0xC0,0x1B} },
  191. {0xD0, 16, {0xF8,0x7F,0x09,0x9C,0x03,0x78,0x01,0xFF,0x2F,0x81,0x73,0x00,0x6F,0xE3,0xFF,0x25} },
  192. {0xE0, 16, {0x70,0x0E,0xE0,0x5D,0xFC,0xBF,0x04,0xCE,0x01,0xBC,0x89,0xFF,0x97,0xC0,0x39,0x80} },
  193. {0xF0, 16, {0xF7,0xF0,0xFF,0x12,0x38,0x07,0x30,0x02,0x7E,0xBF,0x11,0x00,0x00,0x00,0x00,0x00} },
  194. //Blank 21
  195. {0x41, 2, {0x5A,0x15} },
  196. {0x80, 16, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xA4,0xAD,0xC1,0xEF} },
  197. {0x90, 16, {0xE7,0x01,0xA9,0x95,0x90,0x51,0xAB,0x0D,0xA1,0xD5,0x2E,0x64,0xD4,0x6A,0x43,0x68} },
  198. {0xA0, 16, {0xB5,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00} },
  199. {0xB0, 16, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x26,0x00,0xE0,0x01,0x28,0x6D,0xB8,0x62} },
  200. {0xC0, 16, {0xE0,0xBA,0xAA,0x00,0x40,0x10,0x08,0xC2,0x30,0x10,0xD5,0xB6,0x6D,0xDB,0x86,0x2A} },
  201. {0xD0, 16, {0x06,0xAE,0xEB,0xEA,0x38,0x8A,0x62,0x18,0x82,0x60,0x49,0x6D,0xDB,0xB6,0x6D,0xB8} },
  202. {0xE0, 16, {0x62,0xE0,0xBA,0xAA,0x82,0x60,0x18,0x8A,0xE2,0x38,0x92,0xD5,0xB6,0x6D,0xDB,0x86} },
  203. {0xF0, 16, {0x2A,0x06,0xAE,0xEB,0xCA,0x30,0x08,0x42,0x10,0x00,0x40,0x41,0x6D,0xDB,0xB6,0x00} },
  204. //Blank 22
  205. {0x41, 2, {0x5A,0x16} },
  206. {0x80, 16, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00} },
  207. {0x90, 10, {0x00,0x00,0x00,0x00,0x80,0x42,0x26,0x01,0x00,0x00} },
  208. //Blank 24
  209. {0x41, 2, {0x5A,0x18} },
  210. {0x80, 16, {0xEF,0xBD,0xF7,0xDE,0x7B,0xEF,0xBD,0x07,0x08,0x08,0x0A,0x0C,0x0C,0x0C,0x0C,0x0C} },
  211. {0x90, 16, {0x0C,0x0C,0x0C,0x5C,0x09,0xA8,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0x5A} },
  212. {0xA0, 16, {0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x09,0x04,0xFF,0x00,0x80} },
  213. {0xB0, 15, {0x80,0x00,0x04,0x20,0x00,0x01,0x08,0x40,0x00,0x02,0x10,0x80,0x00,0x04,0x00} },
  214. //Blank 25
  215. {0x41, 2, {0x5A,0x19} },
  216. {0x80, 16, {0xF0,0xD9,0xC8,0xBA,0xAF,0xA6,0x9E,0x98,0x92,0x8D,0x88,0x84,0x00,0x60,0xF6,0xCF} },
  217. {0x90, 16, {0xFC,0x6F,0xF6,0xEF,0xCF,0xAF,0x0F,0xFF,0xAF,0xB5,0x71,0x0E,0x6C,0x4A,0x69,0x08} },
  218. {0xA0, 4, {0x00,0x00,0x02,0x00} },
  219. //Blank 26
  220. {0x41, 2, {0x5A,0x1A} },
  221. {0x80, 16, {0xFF,0x04,0x04,0x08,0x0C,0x00,0x10,0x14,0x18,0x1C,0x00,0x20,0x28,0x30,0x38,0x00} },
  222. {0x90, 16, {0x40,0x48,0x50,0x58,0x00,0x60,0x68,0x70,0x78,0x00,0x80,0x88,0x90,0x98,0x00,0xA0} },
  223. {0xA0, 16, {0xA8,0xB0,0xB8,0x00,0xC0,0xC8,0xD0,0xD8,0x00,0xE0,0xE8,0xF0,0xF8,0x00,0xFC,0xFE} },
  224. {0xB0, 16, {0xFF,0x00,0x00,0x04,0x08,0x0C,0x00,0x10,0x14,0x18,0x1C,0x00,0x20,0x28,0x30,0x38} },
  225. {0xC0, 16, {0x00,0x40,0x48,0x50,0x58,0x00,0x60,0x68,0x70,0x78,0x00,0x80,0x88,0x90,0x98,0x00} },
  226. {0xD0, 16, {0xA0,0xA8,0xB0,0xB8,0x00,0xC0,0xC8,0xD0,0xD8,0x00,0xE0,0xE8,0xF0,0xF8,0x00,0xFC} },
  227. {0xE0, 16, {0xFE,0xFF,0x00,0x00,0x04,0x08,0x0C,0x00,0x10,0x14,0x18,0x1C,0x00,0x20,0x28,0x30} },
  228. {0xF0, 16, {0x38,0x00,0x40,0x48,0x50,0x58,0x00,0x60,0x68,0x70,0x78,0x00,0x80,0x88,0x90,0x98} },
  229. //Blank 27
  230. {0x41, 2, {0x5A,0x1B} },
  231. {0x80, 16, {0x00,0xA0,0xA8,0xB0,0xB8,0x00,0xC0,0xC8,0xD0,0xD8,0x00,0xE0,0xE8,0xF0,0xF8,0x00} },
  232. {0x90, 5, {0xFC,0xFE,0xFF,0x00,0x00} },
  233. //Blank 28
  234. {0x41, 2, {0x5A,0x1C} },
  235. {0x80, 16, {0x33,0x22,0x00,0x03,0x5A,0x02,0x5A,0x54,0xE5,0xFF,0xC7,0x20,0x18,0x28,0x18,0x08} },
  236. {0x90, 16, {0x10,0x0C,0x07,0x09,0x06,0x06,0x0A,0x10,0x0C,0x09,0x0B,0x06,0x26,0xF2,0x78,0x40} },
  237. {0xA0, 16, {0x20,0x08,0x08,0x06,0x13,0xC0,0x34,0x1E,0x0A,0x08,0x66,0xD1,0xA0,0x1C,0x20,0x20} },
  238. {0xB0, 16, {0x18,0x04,0x20,0x00,0xC0,0x04,0x28,0x01,0x4C,0x00,0x23,0x18,0x10,0x0A,0x06,0xC9} },
  239. {0xC0, 16, {0x04,0x70,0x41,0x58,0x54,0xB5,0x4A,0x55,0x15,0x00,0x78,0xF8,0x99,0x99,0x99,0x99} },
  240. {0xD0, 16, {0x99,0x99,0x88,0x88,0x88,0x88,0x88,0x88,0x08,0xC4,0xE3,0x81,0x00,0x20,0x80,0x27} },
  241. {0xE0, 16, {0xE2,0x89,0x00,0x00,0x00,0x00,0x40,0x00,0x80,0x30,0x04,0x41,0x06,0x00,0x00,0x00} },
  242. {0xF0, 16, {0x00,0x92,0x24,0x49,0x92,0x04,0x00,0x00,0x00,0x00,0x92,0x04,0x00,0xC0,0x03,0x40} },
  243. //Blank 29
  244. {0x41, 2, {0x5A,0x1D} },
  245. {0x80, 16, {0x00,0x01,0x54,0x0B,0x23,0x18,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00} },
  246. //Blank 34
  247. {0x41, 2, {0x5A,0x22} },
  248. {0x80, 16, {0x00,0x5E,0x00,0x00,0x00,0x00,0x00,0x00,0x5E,0x00,0x00,0x00,0x00,0x00,0x00} },
  249. //Blank 36
  250. {0x41, 2, {0x5A,0x24} },
  251. {0x80, 16, {0x2D,0xD3,0x00,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x1F,0x00,0xAA,0x3E,0x00} },
  252. {0x90, 4, {0x00,0x00,0x00,0x00} },
  253. //Blank 37
  254. {0x41, 2, {0x5A,0x25} },
  255. {0x80, 16, {0x01,0x05,0x00,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF} },
  256. {0x90, 11, {0x0F,0x00,0x00,0x24,0x00,0x00,0x00,0x00,0xFF,0x07,0x35} },
  257. //Blank 38
  258. {0x41, 2, {0x5A,0x26} },
  259. {0x80, 16, {0x00,0x83,0x00,0xFF,0xFF,0x60,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0xB4,0x85} },
  260. {0x90, 3, {0x5A,0xA5,0x5A} },
  261. //----------------------LCD initial code End----------------------//
  262. //SPI FINISH
  263. {0x90, 1, {0xA5} },
  264. //Blank select 2F
  265. {0x41, 2, {0x00,0x2F} },
  266. { 0x11, 0x01, {0x00} },
  267. {REGFLAG_DELAY, 120, {} },
  268. { 0x29, 0x01, {0x00} },
  269. {REGFLAG_DELAY, 50, {} },
  270. { REGFLAG_END_OF_TABLE, 0x00, {} }
  271. };
  272. static void push_table(struct LCM_setting_table *table, unsigned int count, unsigned char force_update)
  273. {
  274. unsigned int i;
  275. for(i = 0; i < count; i++)
  276. {
  277. unsigned cmd;
  278. cmd = table[i].cmd;
  279. switch (cmd) {
  280. case REGFLAG_DELAY :
  281. if(table[i].count <= 10)
  282. MDELAY(table[i].count);
  283. else
  284. MDELAY(table[i].count);
  285. break;
  286. case REGFLAG_UDELAY :
  287. UDELAY(table[i].count);
  288. break;
  289. case REGFLAG_END_OF_TABLE :
  290. break;
  291. default:
  292. dsi_set_cmdq_V2(cmd, table[i].count, table[i].para_list, force_update);
  293. }
  294. }
  295. }
  296. static void lcm_set_util_funcs(const LCM_UTIL_FUNCS *util)
  297. {
  298. memcpy(&lcm_util, util, sizeof(LCM_UTIL_FUNCS));
  299. }
  300. static void lcm_get_params(LCM_PARAMS *params)
  301. {
  302. memset(params, 0, sizeof(LCM_PARAMS));
  303. params->type = LCM_TYPE_DSI;
  304. params->width = FRAME_WIDTH;
  305. params->height = FRAME_HEIGHT;
  306. #if (LCM_DSI_CMD_MODE)
  307. params->dsi.mode = CMD_MODE;
  308. #else
  309. params->dsi.mode = SYNC_PULSE_VDO_MODE;//SYNC_EVENT_VDO_MODE; //SYNC_PULSE_VDO_MODE;
  310. #endif
  311. /* DSI */
  312. /* Command mode setting */
  313. params->dsi.LANE_NUM = LCM_FOUR_LANE;
  314. /* The following defined the fomat for data coming from LCD engine. */
  315. //params->dsi.data_format.color_order = LCM_COLOR_ORDER_RGB;
  316. //params->dsi.data_format.trans_seq = LCM_DSI_TRANS_SEQ_MSB_FIRST;
  317. //params->dsi.data_format.padding = LCM_DSI_PADDING_ON_LSB;
  318. params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888;
  319. /* Highly depends on LCD driver capability. */
  320. params->dsi.packet_size = 256;
  321. /* video mode timing */
  322. params->dsi.PS = LCM_PACKED_PS_24BIT_RGB888;
  323. params->dsi.vertical_sync_active = 8;
  324. params->dsi.vertical_backporch = 50;
  325. params->dsi.vertical_frontporch = 180;
  326. //params->dsi.vertical_frontporch_for_low_power = 540;
  327. params->dsi.vertical_active_line = FRAME_HEIGHT;
  328. params->dsi.horizontal_sync_active = 14;
  329. params->dsi.horizontal_backporch = 25;
  330. params->dsi.horizontal_frontporch = 45;
  331. params->dsi.horizontal_active_pixel = FRAME_WIDTH;
  332. //params->dsi.ssc_disable = 1;
  333. #if (LCM_DSI_CMD_MODE)
  334. params->dsi.PLL_CLOCK = 240;
  335. #else
  336. params->dsi.PLL_CLOCK = 240;
  337. #endif
  338. /*
  339. params->dsi.clk_lp_per_line_enable = 0;
  340. params->dsi.esd_check_enable = 1;
  341. params->dsi.customization_esd_check_enable = 0;
  342. params->dsi.lcm_esd_check_table[0].cmd = 0x0A;
  343. params->dsi.lcm_esd_check_table[0].count = 1;
  344. params->dsi.lcm_esd_check_table[0].para_list[0] = 0x9C;
  345. */
  346. }
  347. //add vldo28_sw_en by rq start 20181222
  348. #if 1
  349. void pmic_ldo_vldo28_sw_en(int en_value)
  350. {
  351. unsigned short read_back;
  352. printf("ldo : VLDO28; sw enable = %d\n", en_value);
  353. pmic_set_register_value(PMIC_RG_LDO_VLDO28_EN_0, en_value);
  354. pmic_set_register_value(PMIC_RG_LDO_VLDO28_EN_1, en_value);
  355. /* read back check */
  356. read_back = pmic_get_register_value(PMIC_RG_LDO_VLDO28_EN_0);
  357. printf("ldo : VLDO28; sw en_value readback = %d\n", read_back);
  358. }
  359. #endif
  360. //add vldo28_sw_en by rq end 20181222
  361. static void lcm_init(void)
  362. {
  363. int ret = 0;
  364. LCM_LOGD("lcm_init\n");
  365. //add power_en by rq start 20181222
  366. pmic_ldo_vldo28_sw_en(1);//TP power
  367. MDELAY(5);
  368. mt_set_gpio_mode(GPIO_LCD_RST, GPIO_MODE_00);
  369. mt_set_gpio_dir(GPIO_LCD_RST, GPIO_DIR_OUT);
  370. mt_set_gpio_out(GPIO_LCD_RST, 0);
  371. MDELAY(5);
  372. mt_set_gpio_mode(GPIO_TP_RESET, GPIO_MODE_00);
  373. mt_set_gpio_dir(GPIO_TP_RESET, GPIO_DIR_OUT);
  374. mt_set_gpio_out(GPIO_TP_RESET, 0);
  375. //add power_en by rq end 20181222
  376. MDELAY(10);
  377. mt_set_gpio_out(GPIO_TP_RESET, 1);//TP_RST on
  378. MDELAY(20);
  379. mt_set_gpio_out(GPIO_LCD_RST, 1);
  380. MDELAY(10);
  381. mt_set_gpio_out(GPIO_LCD_RST, 0);
  382. MDELAY(20);
  383. mt_set_gpio_out(GPIO_LCD_RST, 1);//LCD_RST on
  384. //SET_RESET_PIN(1);
  385. MDELAY(120);//need > 50mS
  386. push_table(init_setting_vdo, sizeof(init_setting_vdo) / sizeof(struct LCM_setting_table), 1);
  387. //MDELAY(200);
  388. LCM_LOGI("ft8006p----rt5081----lcm mode = vdo mode ----\n");
  389. }
  390. static void lcm_suspend(void)
  391. {
  392. int ret = 0;
  393. LCM_LOGD("lcm_suspend\n");
  394. push_table(lcm_suspend_setting, sizeof(lcm_suspend_setting) / sizeof(struct LCM_setting_table), 1);
  395. MDELAY(10);
  396. /* SET_RESET_PIN(0); */
  397. }
  398. static void lcm_resume(void)
  399. {
  400. /*LCM_LOGD("lcm_resume\n");*/
  401. lcm_init();
  402. }
  403. static unsigned int lcm_compare_id(void)
  404. {
  405. return 1;
  406. }
  407. /* return TRUE: need recovery */
  408. /* return FALSE: No need recovery */
  409. LCM_DRIVER ft8006p_hd720_dsi_vdo_lcm_drv = {
  410. .name = "ft8006p_hd720_dsi_vdo",
  411. .set_util_funcs = lcm_set_util_funcs,
  412. .get_params = lcm_get_params,
  413. .init = lcm_init,
  414. .suspend = lcm_suspend,
  415. .resume = lcm_resume,
  416. .compare_id = lcm_compare_id,
  417. };