hx8394c_wxga_dsi_vdo.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. /* Copyright Statement:
  2. *
  3. * This software/firmware and related documentation ("MediaTek Software") are
  4. * protected under relevant copyright laws. The information contained herein
  5. * is confidential and proprietary to MediaTek Inc. and/or its licensors.
  6. * Without the prior written permission of MediaTek inc. and/or its licensors,
  7. * any reproduction, modification, use or disclosure of MediaTek Software,
  8. * and information contained herein, in whole or in part, shall be strictly prohibited.
  9. */
  10. /* MediaTek Inc. (C) 2015. All rights reserved.
  11. *
  12. * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  13. * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  14. * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON
  15. * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  16. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  17. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  18. * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  19. * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  20. * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
  21. * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
  22. * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
  23. * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
  24. * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
  25. * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
  26. * CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  27. * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  28. * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
  29. * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
  30. *
  31. * The following software/firmware and/or related documentation ("MediaTek Software")
  32. * have been modified by MediaTek Inc. All revisions are subject to any receiver\'s
  33. * applicable license agreements with MediaTek Inc.
  34. */
  35. #ifndef BUILD_LK
  36. #include <linux/string.h>
  37. #include <linux/gpio.h>
  38. #include <linux/pinctrl/consumer.h>
  39. #endif
  40. #ifdef BUILD_LK
  41. #include <platform/mt_gpio.h>
  42. #include <platform/mt_pmic.h>
  43. #include <platform/mt_i2c.h>
  44. #include <platform/upmu_common.h>
  45. #include "ddp_hal.h"
  46. #else
  47. #include <mach/mt_gpio.h>
  48. #include <mach/mt_pm_ldo.h>
  49. #include <mach/upmu_hw.h>
  50. #include <mach/upmu_common.h>
  51. #include "ddp_hal.h"
  52. #endif
  53. #include "lcm_drv.h"
  54. #define LCM_DEBUG (1)
  55. #if LCM_DEBUG
  56. #define LCM_PREFIX "hx8394"
  57. #if defined(BUILD_LK)||defined(BUILD_UBOOT)
  58. #define PRINT_FUN printf
  59. #define LCM_LOG_LEVEL
  60. #define LCM_MODULE_PART "lk"
  61. #else
  62. #define PRINT_FUN printk
  63. #define LCM_LOG_LEVEL KERN_ERR
  64. #define LCM_MODULE_PART "kernel"
  65. #endif
  66. #define LCM_ALOGD(fmt, ...) \
  67. do { \
  68. PRINT_FUN(LCM_LOG_LEVEL "<<-" LCM_PREFIX "-dbg-%s>> [%04d] [@%s] " fmt "\n", LCM_MODULE_PART, __LINE__, __FUNCTION__,##__VA_ARGS__); \
  69. } while (0)
  70. #define LCM_ALOGE(fmt, ...) \
  71. do { \
  72. PRINT_FUN(LCM_LOG_LEVEL "<<-" LCM_PREFIX "-err-%s>> [%04d] [@%s] " fmt "\n", LCM_MODULE_PART, __LINE__, __FUNCTION__,##__VA_ARGS__); \
  73. } while (0)
  74. #define LCM_ALOGF() \
  75. do { \
  76. PRINT_FUN(LCM_LOG_LEVEL "<<-" LCM_PREFIX "-fun-%s>> [%04d] [@%s] %s() is call!\n", LCM_MODULE_PART, __LINE__, __FUNCTION__, __FUNCTION__); \
  77. } while (0)
  78. #else
  79. #define LCM_ALOGF() do {} while (0)
  80. #define LCM_ALOGD(fmt, ...) do {} while (0)
  81. #define LCM_ALOGE(fmt, ...) \
  82. do { \
  83. PRINT_FUN(LCM_LOG_LEVEL "<<-" LCM_PREFIX "-err-%s>> [%04d] [@%s] " fmt "\n", LCM_MODULE_PART, __LINE__, __FUNCTION__,##__VA_ARGS__); \
  84. } while (0)
  85. #endif
  86. // ---------------------------------------------------------------------------
  87. // Local Constants
  88. // ---------------------------------------------------------------------------
  89. #define FRAME_WIDTH (800)
  90. #define FRAME_HEIGHT (1280)
  91. #define LCM_ID (0x8394)
  92. #ifdef GPIO_LCM_BL_EN
  93. #define GPIO_LCD_BL_EN GPIO_LCM_BL_EN
  94. #else
  95. #define GPIO_LCD_BL_EN 0xFFFFFFFF //GPIO66
  96. #endif
  97. #ifdef GPIO_LCM_PWR
  98. #define GPIO_LCD_PWR GPIO_LCM_PWR
  99. #else
  100. #define GPIO_LCD_PWR GPIO9
  101. #endif
  102. #ifdef GPIO_LCM_RST
  103. #define GPIO_LCD_RST GPIO_LCM_RST
  104. #else
  105. #define GPIO_LCD_RST 0xFFFFFFFF
  106. #endif
  107. #define REGFLAG_DELAY 0xFE
  108. #define REGFLAG_END_OF_TABLE 0xFF
  109. // ---------------------------------------------------------------------------
  110. // Local Variables
  111. // ---------------------------------------------------------------------------
  112. static LCM_UTIL_FUNCS lcm_util = {0};
  113. #define SET_RESET_PIN(v) lcm_set_gpio_output(GPIO_LCD_RST, v) //(lcm_util.set_reset_pin((v)))
  114. #define UDELAY(n) (lcm_util.udelay(n))
  115. #define MDELAY(n) (lcm_util.mdelay(n))
  116. // ---------------------------------------------------------------------------
  117. // Local Functions
  118. // ---------------------------------------------------------------------------
  119. #define dsi_set_cmdq_V2(cmd, count, ppara, force_update) lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
  120. #define dsi_set_cmdq(pdata, queue_size, force_update) lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
  121. #define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
  122. #define write_regs(addr, pdata, byte_nums) lcm_util.dsi_write_regs(addr, pdata, byte_nums)
  123. #define read_reg lcm_util.dsi_read_reg()
  124. #define read_reg_v2(cmd, buffer, buffer_size) lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
  125. #define dsi_set_cmdq_V3(para_tbl,size,force_update) lcm_util.dsi_set_cmdq_V3(para_tbl,size,force_update)
  126. extern void DSI_clk_HS_mode(DISP_MODULE_ENUM module, void* cmdq, bool enter);
  127. struct LCM_setting_table {
  128. unsigned int cmd;
  129. unsigned char count;
  130. unsigned char para_list[64];
  131. };
  132. #ifdef PUSH_TABLET_USING
  133. #if 0
  134. static struct LCM_setting_table lcm_initialization_setting[] = {
  135. /*
  136. Note :
  137. Data ID will depends on the following rule.
  138. count of parameters > 1 => Data ID = 0x39
  139. count of parameters = 1 => Data ID = 0x15
  140. count of parameters = 0 => Data ID = 0x05
  141. Structure Format :
  142. {DCS command, count of parameters, {parameter list}}
  143. {REGFLAG_DELAY, milliseconds of time, {}},
  144. ...
  145. Setting ending by predefined flag
  146. {REGFLAG_END_OF_TABLE, 0x00, {}}
  147. */
  148. {0xB9,3, {0xFF,0x83,0x94}},
  149. {REGFLAG_DELAY, 5, {}},
  150. {0xBA,1, {0x22}},
  151. {REGFLAG_DELAY, 5, {}},
  152. {0xB1,15,{0x64,0x10,0x30,0x44,0x34,0x11,0xf1,0x81,0x70,0xD9,0x34,0x80,0xC0,0xD2,0x01}},
  153. {REGFLAG_DELAY, 5, {}},
  154. {0xB2,12,{0x45,0x64,0x04,0x08,0x40,0x1C,0x08,0x08,0x1C,0x4D,0x00,0x00}},
  155. {REGFLAG_DELAY, 5, {}},
  156. {0xB4,22,{0x00,0xFF,0x18,0x60,0x60,0x60,0x00,0x00,0x01,0x30,0x04,0x68,0x18,0x60,0x60,0x60,0x00,0x00,0x01,0x30,0x04,0x68}},
  157. {REGFLAG_DELAY, 5, {}},
  158. {0xB6,2, {0x5C,0x5C}},
  159. {REGFLAG_DELAY, 5, {}},
  160. {0xCC,1, {0x09}},
  161. {REGFLAG_DELAY, 5, {}},
  162. {0xD3,32,{0x00,0x00,0x00,0x01,0x07,0x00,0x08,0x32,0x10,0x0A,0x00,0x05,0x00,0x20,0x0A,0x05,0x09,0x00,0x32,0x10,0x08,0x00,0x11,0x11,0x0D,0x07,0x23,0x0D,0x07,0x47,0x0D,0x08}},
  163. {REGFLAG_DELAY, 5, {}},
  164. {0xD5,44,{0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x03,0x03,0x03,0x03,0x02,0x02,0x02,0x02,0x20,0x20,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x21,0x21,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18}},
  165. {REGFLAG_DELAY, 5, {}},
  166. {0xE0,42,{0x02,0x0A,0x10,0x28,0x30,0x3e,0x1D,0x3A,0x05,0x0B,0x0D,0x17,0x0E,0x12,0x15,0x12,0x13,0x06,0x12,0x14,0x18,0x02,0x0A,0x10,0x28,0x30,0x3E,0x1D,0x3A,0x05,0x0B,0x0D,0x17,0x0E,0x12,0x15,0x12,0x13,0x06,0x12,0x14,0x18}},
  167. {REGFLAG_DELAY, 200, {}},
  168. {0xC9,5, {0x1F,0x2E,0x1E,0x1E,0x10}},
  169. {REGFLAG_DELAY, 200, {}},
  170. {0x11,1, {0x00}},
  171. {REGFLAG_DELAY, 200, {}},
  172. {0x29,1, {0x00}},
  173. {REGFLAG_DELAY, 250, {}},
  174. // Setting ending by predefined flag
  175. //{REGFLAG_END_OF_TABLE, 0x00, {}}
  176. };
  177. #else
  178. static struct LCM_setting_table lcm_initialization_setting[] = {
  179. {0xB9,3, {0xFF,0x83,0x94}},
  180. {0xBA,1, {0x22}},
  181. {0xB1,15,{0x64,0x10,0x30,0x44,0x34,0x11,0xf1,0x81,0x70,0xD9,0x34,0x80,0xC0,0xD2,0x01}},
  182. {0xB2,12,{0x45,0x64,0x04,0x08,0x40,0x1C,0x08,0x08,0x1C,0x4D,0x00,0x00}},
  183. {0xB4,22,{0x00,0xFF,0x18,0x60,0x60,0x60,0x00,0x00,0x01,0x30,0x04,0x68,0x18,0x60,0x60,0x60,0x00,0x00,0x01,0x30,0x04,0x68}},
  184. {0xB6,2, {0x5C,0x5C}},
  185. {0xCC,1, {0x09}},
  186. {0xD3,32,{0x00,0x00,0x00,0x01,0x07,0x00,0x08,0x32,0x10,0x0A,0x00,0x05,0x00,0x20,0x0A,0x05,0x09,0x00,0x32,0x10,0x08,0x00,0x11,0x11,0x0D,0x07,0x23,0x0D,0x07,0x47,0x0D,0x08}},
  187. {0xD5,44,{0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x03,0x03,0x03,0x03,0x02,0x02,0x02,0x02,0x20,0x20,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x21,0x21,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18}},
  188. {0xE0,42,{0x02,0x0A,0x10,0x28,0x30,0x3E,0x1D,0x3A,0x05,0x0B,0x0D,0x17,0x0E,0x12,0x15,0x12,0x13,0x06,0x12,0x14,0x18,0x02,0x0A,0x10,0x28,0x30,0x3E,0x1D,0x3A,0x05,0x0B,0x0D,0x17,0x0E,0x12,0x15,0x12,0x13,0x06,0x12,0x14,0x18}},
  189. {REGFLAG_DELAY, 200, {}},
  190. {0xC9,5, {0x1F,0x2E,0x1E,0x1E,0x10}},
  191. {REGFLAG_DELAY, 200, {}},
  192. {0x11,0, {}},
  193. {REGFLAG_DELAY, 200, {}},
  194. {0x29,0, {}},
  195. {REGFLAG_DELAY, 250, {}},
  196. {REGFLAG_END_OF_TABLE, 0x00, {}}
  197. };
  198. #endif
  199. #endif
  200. static void init_lcm_registers(void)
  201. {
  202. unsigned int data_array[16];
  203. #ifdef BUILD_LK
  204. printf("%s, LK\n", __func__);
  205. #else
  206. printk("%s, KE\n", __func__);
  207. #endif
  208. #ifdef PUSH_TABLET_USING
  209. push_table(lcm_initialization_setting, sizeof(lcm_initialization_setting) / sizeof(struct LCM_setting_table), 1);
  210. #else
  211. data_array[0] = 0x00043902;
  212. data_array[1] = 0x9483ffb9;
  213. dsi_set_cmdq(data_array, 2, 1);
  214. data_array[0] = 0x22ba1500;
  215. dsi_set_cmdq(data_array, 1, 1);
  216. data_array[0] = 0x00103902;
  217. data_array[1] = 0x301064b1;
  218. data_array[2] = 0xf1113444;
  219. data_array[3] = 0x34D97081;
  220. data_array[4] = 0x01D2C080;
  221. dsi_set_cmdq(data_array, 5, 1);
  222. data_array[0] = 0x000d3902;
  223. data_array[1] = 0x046445b2;
  224. data_array[2] = 0x081C4008;
  225. data_array[3] = 0x004D1C08;
  226. data_array[4] = 0x00;
  227. dsi_set_cmdq(data_array, 5, 1);
  228. data_array[0] = 0x00173902;
  229. data_array[1] = 0x18ff00b4;
  230. data_array[2] = 0x00606060;
  231. data_array[3] = 0x04300100;
  232. data_array[4] = 0x60601868;
  233. data_array[5] = 0x01000060;
  234. data_array[6] = 0x00680430;
  235. dsi_set_cmdq(data_array, 7, 1);
  236. data_array[0] = 0x00033902;
  237. data_array[1] = 0x005c5cb6;
  238. dsi_set_cmdq(data_array, 2, 1);
  239. data_array[0] = 0x09cc1500;
  240. dsi_set_cmdq(data_array, 1, 1);
  241. data_array[0] = 0x00213902;
  242. data_array[1] = 0x000000d3;
  243. data_array[2] = 0x08000701;
  244. data_array[3] = 0x000A1032;
  245. data_array[4] = 0x0A200005;
  246. data_array[5] = 0x32000905;
  247. data_array[6] = 0x11000810;
  248. data_array[7] = 0x23070D11;
  249. data_array[8] = 0x0D47070D;
  250. data_array[9] = 0x08;
  251. dsi_set_cmdq(data_array, 10, 1);
  252. data_array[0] = 0x002d3902;
  253. data_array[1] = 0x010101d5;
  254. data_array[2] = 0x00000001;
  255. data_array[3] = 0x03030300;
  256. data_array[4] = 0x02020203;
  257. data_array[5] = 0x18202002;
  258. data_array[6] = 0x18181818;
  259. data_array[7] = 0x18181818;
  260. data_array[8] = 0x21181818;
  261. data_array[9] = 0x18181821;
  262. data_array[10] = 0x18181818;
  263. data_array[11] = 0x18181818;
  264. data_array[12] = 0x18;
  265. dsi_set_cmdq(data_array, 13, 1);
  266. data_array[0] = 0x002b3902;
  267. data_array[1] = 0x100a02e0;
  268. data_array[2] = 0x1D3E3028;
  269. data_array[3] = 0x0D0B053A;
  270. data_array[4] = 0x15120E17;
  271. data_array[5] = 0x12061312;
  272. data_array[6] = 0x0A021814;
  273. data_array[7] = 0x3E302810;
  274. data_array[8] = 0x0B053A1D;
  275. data_array[9] = 0x120E170D;
  276. data_array[10] = 0x13061215;
  277. data_array[11] = 0x00181412;
  278. dsi_set_cmdq(data_array, 12, 1);
  279. /*MDELAY(200);*/
  280. data_array[0] = 0x00063902;
  281. data_array[1] = 0x1e2e1fc9;
  282. data_array[2] = 0x101e;
  283. dsi_set_cmdq(data_array, 3, 1);
  284. /*MDELAY(200);*/
  285. data_array[0] = 0x00110500;
  286. dsi_set_cmdq(data_array, 1, 1);
  287. MDELAY(120);
  288. data_array[0] = 0x00290500;
  289. dsi_set_cmdq(data_array, 1, 1);
  290. MDELAY(20);
  291. #endif
  292. }
  293. #ifdef PUSH_TABLET_USING
  294. static void push_table(struct LCM_setting_table *table, unsigned int count, unsigned char force_update)
  295. {
  296. unsigned int i;
  297. unsigned cmd;
  298. for (i = 0; i < count; i++) {
  299. cmd = table[i].cmd;
  300. switch (cmd) {
  301. case REGFLAG_DELAY :
  302. MDELAY(table[i].count);
  303. break;
  304. case REGFLAG_END_OF_TABLE :
  305. break;
  306. default:
  307. dsi_set_cmdq_V2(cmd, table[i].count, table[i].para_list, force_update);
  308. }
  309. }
  310. }
  311. #endif
  312. static void lcm_set_gpio_output(unsigned int GPIO, unsigned int output)
  313. {
  314. if (GPIO == 0xFFFFFFFF) {
  315. #ifdef BUILD_LK
  316. printf("[LK/LCM] GPIO_LCD_PWR = 0x%x\n", GPIO_LCD_PWR);
  317. printf("[LK/LCM] GPIO_LCD_RST = 0x%x\n", GPIO_LCD_RST);
  318. #elif (defined BUILD_UBOOT)
  319. #else
  320. #endif
  321. return;
  322. }
  323. #ifdef BUILD_LK
  324. mt_set_gpio_mode(GPIO, GPIO_MODE_00);
  325. mt_set_gpio_dir(GPIO, GPIO_DIR_OUT);
  326. mt_set_gpio_out(GPIO, (output > 0) ? GPIO_OUT_ONE : GPIO_OUT_ZERO);
  327. #else
  328. gpio_set_value(GPIO, (output > 0) ? GPIO_OUT_ONE : GPIO_OUT_ZERO);
  329. #endif
  330. }
  331. // ---------------------------------------------------------------------------
  332. // LCM Driver Implementations
  333. // ---------------------------------------------------------------------------
  334. static void lcm_set_util_funcs(const LCM_UTIL_FUNCS *util)
  335. {
  336. memcpy(&lcm_util, util, sizeof(LCM_UTIL_FUNCS));
  337. }
  338. static void lcm_get_params(LCM_PARAMS *params)
  339. {
  340. LCM_ALOGF();
  341. memset(params, 0, sizeof(LCM_PARAMS));
  342. params->type = LCM_TYPE_DSI;
  343. params->width = FRAME_WIDTH;
  344. params->height = FRAME_HEIGHT;
  345. params->dsi.mode = SYNC_PULSE_VDO_MODE;
  346. // DSI
  347. /* Command mode setting */
  348. params->dsi.LANE_NUM = LCM_THREE_LANE;
  349. //The following defined the fomat for data coming from LCD engine.
  350. params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888;
  351. // Video mode setting
  352. params->dsi.PS = LCM_PACKED_PS_24BIT_RGB888;
  353. params->dsi.vertical_sync_active = 3;
  354. params->dsi.vertical_backporch = 8;//3;//4
  355. params->dsi.vertical_frontporch = 60;
  356. params->dsi.vertical_active_line = FRAME_HEIGHT;
  357. params->dsi.horizontal_sync_active = 48;//12;//20;
  358. params->dsi.horizontal_backporch = 80;//32;//48; //10 OK
  359. params->dsi.horizontal_frontporch = 52;
  360. params->dsi.horizontal_active_pixel = FRAME_WIDTH;
  361. params->dsi.PLL_CLOCK = 338;
  362. params->dsi.cont_clock = 1;
  363. }
  364. static void lcm_power_init(void)
  365. {
  366. LCM_ALOGF();
  367. #ifdef BUILD_LK
  368. lcm_set_gpio_output(GPIO_LCD_PWR, GPIO_OUT_ONE);
  369. SET_RESET_PIN(1);
  370. MDELAY(10);
  371. SET_RESET_PIN(0);
  372. MDELAY(10);
  373. SET_RESET_PIN(1);
  374. /*MDELAY(50);*/
  375. MDELAY(10);
  376. lcm_set_gpio_output(GPIO_LCD_BL_EN, GPIO_OUT_ONE);
  377. #else
  378. #endif
  379. }
  380. static void lcm_init(void)
  381. {
  382. LCM_ALOGF();
  383. DSI_clk_HS_mode(DISP_MODULE_DSI0, NULL, 1);
  384. #ifdef BUILD_LK
  385. init_lcm_registers();
  386. #else
  387. lcm_request_gpio_control();
  388. #endif
  389. }
  390. static void lcm_suspend(void)
  391. {
  392. LCM_ALOGF();
  393. #ifndef BUILD_LK
  394. lcm_set_gpio_output(GPIO_LCD_PWR, GPIO_OUT_ZERO);
  395. MDELAY(10);
  396. SET_RESET_PIN(0);
  397. MDELAY(10);
  398. #endif
  399. }
  400. static void lcm_resume(void)
  401. {
  402. LCM_ALOGF();
  403. #ifndef BUILD_LK
  404. lcm_set_gpio_output(GPIO_LCD_PWR, GPIO_OUT_ONE);
  405. SET_RESET_PIN(1);
  406. MDELAY(10);
  407. SET_RESET_PIN(0);
  408. MDELAY(10);
  409. SET_RESET_PIN(1);
  410. /*MDELAY(50);*/
  411. MDELAY(10);
  412. DSI_clk_HS_mode(DISP_MODULE_DSI0, NULL, 1);
  413. init_lcm_registers();
  414. #endif
  415. }
  416. static unsigned int lcm_compare_id(void)
  417. {
  418. unsigned int id = 0;
  419. unsigned char buffer[3];
  420. unsigned int data_array[16];
  421. LCM_ALOGF();
  422. SET_RESET_PIN(1); //NOTE:should reset LCM firstly
  423. MDELAY(10);
  424. SET_RESET_PIN(0);
  425. MDELAY(10);
  426. SET_RESET_PIN(1);
  427. MDELAY(10);
  428. MDELAY(20);
  429. data_array[0]=0x00043902;
  430. data_array[1]=0x9483FFB9;
  431. dsi_set_cmdq(data_array, 2, 1);
  432. MDELAY(10);
  433. data_array[0] = 0x00033700;
  434. dsi_set_cmdq(data_array, 1, 1);
  435. read_reg_v2(0x04, buffer, 3);
  436. id = (buffer[0] << 8) | buffer [1]; //we only need ID
  437. LCM_ALOGD("read id, buf:0x%02x ,0x%02x,0x%02x, id=0X%X", buffer[0], buffer[1], buffer[2], id);
  438. return (LCM_ID == id)?1:0;
  439. }
  440. LCM_DRIVER hx8394c_wxga_dsi_vdo_lcm_drv = {
  441. .name = "hx8394c_wxga_dsi_vdo",
  442. .set_util_funcs = lcm_set_util_funcs,
  443. .get_params = lcm_get_params,
  444. .init_power = lcm_power_init,
  445. .init = lcm_init,
  446. .suspend = lcm_suspend,
  447. .resume = lcm_resume,
  448. .compare_id = lcm_compare_id,
  449. };