ft8006p_hd720_dsi_vdo.c 18 KB

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