ek79023_dsi_wsvga_vdo.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  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. #endif
  38. #include "lcm_drv.h"
  39. #ifdef BUILD_LK
  40. #include <platform/mt_gpio.h>
  41. #include <platform/mt_pmic.h>
  42. #elif defined(BUILD_UBOOT)
  43. #include <asm/arch/mt_gpio.h>
  44. #else
  45. #include <mach/mt_gpio.h>
  46. #include <linux/xlog.h>
  47. #include <mach/mt_pm_ldo.h>
  48. #endif
  49. #define FRAME_WIDTH (600)
  50. #define FRAME_HEIGHT (1024)
  51. #define REGFLAG_DELAY 0xFE
  52. #define REGFLAG_END_OF_TABLE 0xFF // END OF REGISTERS MARKER
  53. #define LCM_DSI_CMD_MODE 0
  54. #define LCM_ID 0x06
  55. //#define GPIO_LCD_RST_EN GPIO131
  56. #ifdef GPIO_LCM_PWR_EN
  57. #define GPIO_LCD_PWR_EN GPIO_LCM_PWR_EN
  58. #else
  59. #define GPIO_LCD_PWR_EN 0xFFFFFFFF
  60. #endif
  61. #ifdef GPIO_LCM_RST
  62. #define GPIO_LCD_RST GPIO_LCM_RST
  63. #else
  64. #define GPIO_LCD_RST 0xFFFFFFFF
  65. #endif
  66. #ifndef BUILD_LK
  67. static bool fgisFirst = TRUE;
  68. #endif
  69. static unsigned int lcm_esd_test = FALSE; ///only for ESD test
  70. // ---------------------------------------------------------------------------
  71. // Local Variables
  72. // ---------------------------------------------------------------------------
  73. static LCM_UTIL_FUNCS lcm_util = {0};
  74. #define SET_RESET_PIN(v) lcm_set_gpio_output(GPIO_LCD_RST, v) //(lcm_util.set_reset_pin((v)))
  75. #define UDELAY(n) (lcm_util.udelay(n))
  76. #define MDELAY(n) (lcm_util.mdelay(n))
  77. //unsigned int tmp=0x50;
  78. // ---------------------------------------------------------------------------
  79. // Local Functions
  80. // ---------------------------------------------------------------------------
  81. #define dsi_set_cmdq_V2(cmd, count, ppara, force_update) lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
  82. #define dsi_set_cmdq(pdata, queue_size, force_update) lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
  83. #define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
  84. #define write_regs(addr, pdata, byte_nums) lcm_util.dsi_write_regs(addr, pdata, byte_nums)
  85. #define read_reg lcm_util.dsi_read_reg()
  86. #define read_reg_v2(cmd, buffer, buffer_size) lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
  87. static struct LCM_setting_table {
  88. unsigned cmd;
  89. unsigned char count;
  90. unsigned char para_list[128];
  91. };
  92. static struct LCM_setting_table lcm_initialization_setting[] = {
  93. /*
  94. Note :
  95. Data ID will depends on the following rule.
  96. count of parameters > 1 => Data ID = 0x39
  97. count of parameters = 1 => Data ID = 0x15
  98. count of parameters = 0 => Data ID = 0x05
  99. Structure Format :
  100. {DCS command, count of parameters, {parameter list}}
  101. {REGFLAG_DELAY, milliseconds of time, {}},
  102. */
  103. //This init code for HX9279A driver IC
  104. {0xB0, 1, {0x00}},
  105. {0xBA, 1, {0xA7}},
  106. {0xBD, 1, {0x41}},
  107. {0xBE, 1, {0x77}},
  108. {0xBF, 1, {0x1F}},
  109. {0xC0, 1, {0x0C}},
  110. {0xC1, 1, {0x78}},
  111. {0xC2, 1, {0x5C}},
  112. {0xC3, 1, {0xE8}},
  113. {0xC4, 1, {0x73}},
  114. {0xC5, 1, {0x14}},
  115. {0xC6, 1, {0x02}},
  116. {0xC7, 1, {0x14}},
  117. {0xC8, 1, {0x02}},
  118. {0xC9, 1, {0x06}},
  119. {0xCA, 1, {0x00}},
  120. {0xCB, 1, {0x00}},
  121. {0xB0, 1, {0x01}},
  122. {0xB1, 1, {0x5C}},
  123. {0xB2, 1, {0x5E}},
  124. {0xB3, 1, {0x72}},
  125. {0xB4, 1, {0xBC}},
  126. {0xB5, 1, {0xE9}},
  127. {0xB6, 1, {0x5E}},
  128. {0xB7, 1, {0x93}},
  129. {0xB8, 1, {0xBD}},
  130. {0xB9, 1, {0xFC}},
  131. {0xBA, 1, {0x2A}},
  132. {0xBB, 1, {0x54}},
  133. {0xBC, 1, {0x7C}},
  134. {0xBD, 1, {0xAE}},
  135. {0xBE, 1, {0xD3}},
  136. {0xBF, 1, {0xF2}},
  137. {0xC0, 1, {0x16}},
  138. {0xC1, 1, {0xBC}},
  139. {0xC2, 1, {0x00}},
  140. {0xC3, 1, {0x15}},
  141. {0xC4, 1, {0x6A}},
  142. {0xC5, 1, {0xAB}},
  143. {0xC6, 1, {0x03}},
  144. {0xC7, 1, {0x5C}},
  145. {0xC8, 1, {0x5E}},
  146. {0xC9, 1, {0x72}},
  147. {0xCA, 1, {0xBC}},
  148. {0xCB, 1, {0x19}},
  149. {0xCC, 1, {0x5E}},
  150. {0xCD, 1, {0x93}},
  151. {0xCE, 1, {0xBD}},
  152. {0xCF, 1, {0xFC}},
  153. {0xD0, 1, {0x2A}},
  154. {0xD1, 1, {0x54}},
  155. {0xD2, 1, {0x7C}},
  156. {0xD3, 1, {0xAE}},
  157. {0xD4, 1, {0xD3}},
  158. {0xD5, 1, {0xF2}},
  159. {0xD6, 1, {0x16}},
  160. {0xD7, 1, {0xBC}},
  161. {0xD8, 1, {0x00}},
  162. {0xD9, 1, {0x15}},
  163. {0xDA, 1, {0x6A}},
  164. {0xDB, 1, {0xAB}},
  165. {0xDC, 1, {0x03}},
  166. {0xDD, 1, {0x5C}},
  167. {0xDE, 1, {0x5E}},
  168. {0xDF, 1, {0x72}},
  169. {0xE0, 1, {0xBC}},
  170. {0xE1, 1, {0xE9}},
  171. {0xE2, 1, {0x5E}},
  172. {0xE3, 1, {0x93}},
  173. {0xE4, 1, {0xBD}},
  174. {0xE5, 1, {0xFC}},
  175. {0xE6, 1, {0x2A}},
  176. {0xE7, 1, {0x54}},
  177. {0xE8, 1, {0x7C}},
  178. {0xE9, 1, {0xAE}},
  179. {0xEA, 1, {0xD3}},
  180. {0xEB, 1, {0xF2}},
  181. {0xEC, 1, {0x16}},
  182. {0xED, 1, {0xBC}},
  183. {0xEE, 1, {0x00}},
  184. {0xEF, 1, {0x15}},
  185. {0xF0, 1, {0x6A}},
  186. {0xF1, 1, {0xAB}},
  187. {0xF2, 1, {0x03}},
  188. {0xB0, 1, {0x02}},
  189. {0xB1, 1, {0x5C}},
  190. {0xB2, 1, {0x5E}},
  191. {0xB3, 1, {0x72}},
  192. {0xB4, 1, {0xBC}},
  193. {0xB5, 1, {0xE9}},
  194. {0xB6, 1, {0x5E}},
  195. {0xB7, 1, {0x93}},
  196. {0xB8, 1, {0xBD}},
  197. {0xB9, 1, {0xFC}},
  198. {0xBA, 1, {0x2A}},
  199. {0xBB, 1, {0x54}},
  200. {0xBC, 1, {0x7C}},
  201. {0xBD, 1, {0xAE}},
  202. {0xBE, 1, {0xD3}},
  203. {0xBF, 1, {0xF2}},
  204. {0xC0, 1, {0x16}},
  205. {0xC1, 1, {0xBC}},
  206. {0xC2, 1, {0x00}},
  207. {0xC3, 1, {0x15}},
  208. {0xC4, 1, {0x6A}},
  209. {0xC5, 1, {0xAB}},
  210. {0xC6, 1, {0x03}},
  211. {0xC7, 1, {0x5C}},
  212. {0xC8, 1, {0x5E}},
  213. {0xC9, 1, {0x72}},
  214. {0xCA, 1, {0xBC}},
  215. {0xCB, 1, {0xE9}},
  216. {0xCC, 1, {0x5E}},
  217. {0xCD, 1, {0x93}},
  218. {0xCE, 1, {0xBD}},
  219. {0xCF, 1, {0xFC}},
  220. {0xD0, 1, {0x2A}},
  221. {0xD1, 1, {0x54}},
  222. {0xD2, 1, {0x7C}},
  223. {0xD3, 1, {0xAE}},
  224. {0xD4, 1, {0xD3}},
  225. {0xD5, 1, {0xF2}},
  226. {0xD6, 1, {0x16}},
  227. {0xD7, 1, {0xBC}},
  228. {0xD8, 1, {0x00}},
  229. {0xD9, 1, {0x15}},
  230. {0xDA, 1, {0x6A}},
  231. {0xDB, 1, {0xAB}},
  232. {0xDC, 1, {0x03}},
  233. {0xDD, 1, {0x5C}},
  234. {0xDE, 1, {0x5E}},
  235. {0xDF, 1, {0x72}},
  236. {0xE0, 1, {0xBC}},
  237. {0xE1, 1, {0xE9}},
  238. {0xE2, 1, {0x5E}},
  239. {0xE3, 1, {0x93}},
  240. {0xE4, 1, {0xBD}},
  241. {0xE5, 1, {0xFC}},
  242. {0xE6, 1, {0x2A}},
  243. {0xE7, 1, {0x54}},
  244. {0xE8, 1, {0x7C}},
  245. {0xE9, 1, {0xAE}},
  246. {0xEA, 1, {0xD3}},
  247. {0xEB, 1, {0xF2}},
  248. {0xEC, 1, {0x16}},
  249. {0xED, 1, {0xBC}},
  250. {0xEE, 1, {0x00}},
  251. {0xEF, 1, {0x15}},
  252. {0xF0, 1, {0x6A}},
  253. {0xF1, 1, {0xAB}},
  254. {0xF2, 1, {0x03}},
  255. {0xB0, 1, {0x03}},
  256. {0xC0, 1, {0x49}},
  257. {0xC1, 1, {0x10}},
  258. {0xC2, 1, {0x01}},
  259. {0xC3, 1, {0x28}},
  260. {0xC4, 1, {0x28}},
  261. {0xC5, 1, {0x0C}},
  262. {0xC8, 1, {0x42}},
  263. {0xC9, 1, {0x40}},
  264. {0xCA, 1, {0x01}},
  265. {0xCB, 1, {0x08}},
  266. {0xCC, 1, {0x02}},
  267. {0xCD, 1, {0x08}},
  268. {0xCE, 1, {0x09}},
  269. {0xD0, 1, {0x03}},
  270. {0xD1, 1, {0x0A}},
  271. {0xDC, 1, {0x00}},
  272. {0xDD, 1, {0x00}},
  273. {0xDE, 1, {0x00}},
  274. {0xDF, 1, {0x00}},
  275. {0xE0, 1, {0x12}},
  276. {0xE1, 1, {0x11}},
  277. {0xE2, 1, {0x05}},
  278. {0xE3, 1, {0x06}},
  279. {0xE4, 1, {0x07}},
  280. {0xE5, 1, {0x08}},
  281. {0xE6, 1, {0x09}},
  282. {0xE7, 1, {0x0A}},
  283. {0xE8, 1, {0x0B}},
  284. {0xE9, 1, {0x0C}},
  285. {0xEA, 1, {0x02}},
  286. {0xEB, 1, {0x01}},
  287. {0xEC, 1, {0x12}},
  288. {0xED, 1, {0x11}},
  289. {0xEE, 1, {0x05}},
  290. {0xEF, 1, {0x06}},
  291. {0xF0, 1, {0x07}},
  292. {0xF1, 1, {0x08}},
  293. {0xF2, 1, {0x09}},
  294. {0xF3, 1, {0x0A}},
  295. {0xF4, 1, {0x0B}},
  296. {0xF5, 1, {0x0C}},
  297. {0xF6, 1, {0x02}},
  298. {0xF7, 1, {0x01}},
  299. {0xF8, 1, {0x00}},
  300. {0xF9, 1, {0x00}},
  301. {0xFA, 1, {0x00}},
  302. {0xFB, 1, {0x00}},
  303. {0xB0, 1, {0x05}},
  304. {0xB3, 1, {0x52}},
  305. {0xB0, 1, {0x06}},
  306. {0xB8, 1, {0xA5}},
  307. {0xC0, 1, {0xA5}},
  308. {0xC5, 1, {0x44}},
  309. {0xC7, 1, {0x1F}},
  310. {0xB8, 1, {0x5A}},
  311. {0xC0, 1, {0x5A}},
  312. {0xB0, 1, {0x03}},
  313. {0xB2, 1, {0xA5}},
  314. {0xB3, 1, {0x04}},
  315. {0xB0, 1, {0x0F}},
  316. {0x11, 0, {0x00}},
  317. {0x29, 0, {0x00}},
  318. {REGFLAG_DELAY, 80, {}},
  319. {REGFLAG_END_OF_TABLE, 0x00, {}}
  320. };
  321. #if 1
  322. //static int vcom = 0x7A;
  323. static void push_table(struct LCM_setting_table *table, unsigned int count, unsigned char force_update)
  324. {
  325. unsigned int i;
  326. for(i = 0; i < count; i++) {
  327. unsigned cmd;
  328. cmd = table[i].cmd;
  329. switch (cmd) {
  330. /* case 0xb6:
  331. table[i].para_list[0] = vcom;
  332. table[i].para_list[1] = vcom;
  333. dsi_set_cmdq_V2(cmd, table[i].count, table[i].para_list, force_update);
  334. vcom -= 1;
  335. break;
  336. */
  337. case REGFLAG_DELAY :
  338. MDELAY(table[i].count);
  339. break;
  340. case REGFLAG_END_OF_TABLE :
  341. break;
  342. default:
  343. dsi_set_cmdq_V2(cmd, table[i].count, table[i].para_list, force_update);
  344. }
  345. }
  346. }
  347. #endif
  348. // ---------------------------------------------------------------------------
  349. // LCM Driver Implementations
  350. // ---------------------------------------------------------------------------
  351. static void lcm_set_util_funcs(const LCM_UTIL_FUNCS *util)
  352. {
  353. memcpy(&lcm_util, util, sizeof(LCM_UTIL_FUNCS));
  354. }
  355. static void lcm_get_params(LCM_PARAMS *params)
  356. {
  357. memset(params, 0, sizeof(LCM_PARAMS));
  358. params->type = LCM_TYPE_DSI;
  359. params->width = FRAME_WIDTH;
  360. params->height = FRAME_HEIGHT;
  361. // enable tearing-free
  362. //params->dbi.te_mode = LCM_DBI_TE_MODE_DISABLED;
  363. //params->dbi.te_edge_polarity = LCM_POLARITY_RISING;
  364. //params->dsi.mode = BURST_VDO_MODE;
  365. params->dsi.mode = SYNC_PULSE_VDO_MODE;//SYNC_EVENT_VDO_MODE; //BURST_VDO_MODE;
  366. // DSI
  367. /* Command mode setting */
  368. params->dsi.LANE_NUM = LCM_FOUR_LANE;
  369. //The following defined the fomat for data coming from LCD engine.
  370. params->dsi.data_format.color_order = LCM_COLOR_ORDER_RGB;
  371. params->dsi.data_format.trans_seq = LCM_DSI_TRANS_SEQ_MSB_FIRST;
  372. params->dsi.data_format.padding = LCM_DSI_PADDING_ON_LSB;
  373. params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888;
  374. // Highly depends on LCD driver capability.
  375. params->dsi.packet_size=256;
  376. //video mode timing
  377. params->dsi.PS=LCM_PACKED_PS_24BIT_RGB888;
  378. params->dsi.word_count=FRAME_WIDTH*3;
  379. params->dsi.vertical_sync_active = 2;
  380. params->dsi.vertical_backporch = 8;//10;
  381. params->dsi.vertical_frontporch = 14;//20;
  382. params->dsi.vertical_active_line = FRAME_HEIGHT;
  383. params->dsi.horizontal_sync_active = 24;
  384. params->dsi.horizontal_backporch = 36;//24;
  385. params->dsi.horizontal_frontporch = 100;//112;
  386. params->dsi.horizontal_active_pixel = FRAME_WIDTH;
  387. // Video mode setting
  388. //params->dsi.PS=LCM_PACKED_PS_24BIT_RGB888;
  389. //params->dsi.pll_select=1;
  390. params->dsi.PLL_CLOCK = 150;//240;//LCM_DSI_6589_PLL_CLOCK_253_5;//LCM_DSI_6589_PLL_CLOCK_240_5;//LCM_DSI_6589_PLL_CLOCK_227_5;//this value must be in MTK suggested table 227_5
  391. params->dsi.ssc_disable = 1; // disable ssc
  392. //params->dsi.cont_clock = 1; // clcok always hs mode
  393. }
  394. static void lcm_set_gpio_output(unsigned int GPIO, unsigned int output)
  395. {
  396. mt_set_gpio_mode(GPIO, GPIO_MODE_00);
  397. mt_set_gpio_dir(GPIO, GPIO_DIR_OUT);
  398. mt_set_gpio_out(GPIO, (output>0)? GPIO_OUT_ONE: GPIO_OUT_ZERO);
  399. }
  400. static void lcm_init_power(void)
  401. {
  402. #ifdef BUILD_LK
  403. printf("[LK/LCM] lcm_init_power() enter\n");
  404. lcm_set_gpio_output(GPIO_LCD_PWR_EN, GPIO_OUT_ONE);
  405. lcm_Enable_HW(1800);
  406. MDELAY(1);
  407. #else
  408. printk("[Kernel/LCM] lcm_init_power() enter\n");
  409. #endif
  410. }
  411. static void lcm_suspend_power(void)
  412. {
  413. #ifdef BUILD_LK
  414. printf("[LK/LCM] lcm_suspend_power() enter\n");
  415. lcm_set_gpio_output(GPIO_LCD_PWR_EN, GPIO_OUT_ZERO);
  416. MDELAY(20);
  417. lcm_Disable_HW();
  418. #else
  419. printk("[Kernel/LCM] lcm_suspend_power() enter\n");
  420. lcm_set_gpio_output(GPIO_LCD_PWR_EN, GPIO_OUT_ZERO);
  421. MDELAY(20);
  422. if(fgisFirst == TRUE) {
  423. fgisFirst = FALSE;
  424. hwPowerOn(MT6328_POWER_LDO_VCAMA, VOL_1800, "LCM");
  425. }
  426. hwPowerDown(MT6328_POWER_LDO_VCAMA, "LCM");
  427. #endif
  428. }
  429. static void lcm_resume_power(void)
  430. {
  431. #ifdef BUILD_LK
  432. printf("[LK/LCM] lcm_resume_power() enter\n");
  433. lcm_set_gpio_output(GPIO_LCD_PWR_EN, GPIO_OUT_ONE);
  434. lcm_Enable_HW(1800);
  435. MDELAY(20);
  436. #else
  437. printk("[Kernel/LCM] lcm_resume_power() enter\n");
  438. lcm_set_gpio_output(GPIO_LCD_PWR_EN, GPIO_OUT_ONE);
  439. hwPowerOn(MT6328_POWER_LDO_VCAMA, VOL_1800, "LCM");
  440. MDELAY(1);
  441. #endif
  442. }
  443. static void lcm_init(void)
  444. {
  445. SET_RESET_PIN(1);
  446. MDELAY(1);
  447. SET_RESET_PIN(0);
  448. MDELAY(10);
  449. SET_RESET_PIN(1);
  450. MDELAY(100);
  451. push_table(lcm_initialization_setting, sizeof(lcm_initialization_setting) / sizeof(struct LCM_setting_table), 1);
  452. }
  453. static void lcm_suspend(void)
  454. {
  455. //SET_RESET_PIN(1);
  456. //MDELAY(20);
  457. SET_RESET_PIN(0);
  458. //MDELAY(20);
  459. //SET_RESET_PIN(1);
  460. MDELAY(150);
  461. }
  462. static void lcm_resume(void)
  463. {
  464. #ifndef BUILD_LK
  465. lcm_init();
  466. #endif
  467. }
  468. static void lcm_update(unsigned int x, unsigned int y,
  469. unsigned int width, unsigned int height)
  470. {
  471. unsigned int x0 = x;
  472. unsigned int y0 = y;
  473. unsigned int x1 = x0 + width - 1;
  474. unsigned int y1 = y0 + height - 1;
  475. unsigned char x0_MSB = ((x0>>8)&0xFF);
  476. unsigned char x0_LSB = (x0&0xFF);
  477. unsigned char x1_MSB = ((x1>>8)&0xFF);
  478. unsigned char x1_LSB = (x1&0xFF);
  479. unsigned char y0_MSB = ((y0>>8)&0xFF);
  480. unsigned char y0_LSB = (y0&0xFF);
  481. unsigned char y1_MSB = ((y1>>8)&0xFF);
  482. unsigned char y1_LSB = (y1&0xFF);
  483. unsigned int data_array[16];
  484. data_array[0]= 0x00052902;
  485. data_array[1]= (x1_MSB<<24)|(x0_LSB<<16)|(x0_MSB<<8)|0x2a;
  486. data_array[2]= (x1_LSB);
  487. dsi_set_cmdq(&data_array, 3, 1);
  488. data_array[0]= 0x00052902;
  489. data_array[1]= (y1_MSB<<24)|(y0_LSB<<16)|(y0_MSB<<8)|0x2b;
  490. data_array[2]= (y1_LSB);
  491. dsi_set_cmdq(&data_array, 3, 1);
  492. data_array[0]= 0x00290508; //HW bug, so need send one HS packet
  493. dsi_set_cmdq(&data_array, 1, 1);
  494. data_array[0]= 0x002c3909;
  495. dsi_set_cmdq(&data_array, 1, 0);
  496. }
  497. static unsigned int lcm_compare_id(void)
  498. {
  499. unsigned int id=0;
  500. unsigned char buffer[4];
  501. unsigned int array[16];
  502. SET_RESET_PIN(1);
  503. MDELAY(10);
  504. SET_RESET_PIN(0);
  505. MDELAY(50);
  506. SET_RESET_PIN(1);
  507. MDELAY(120);
  508. array[0]=0x00B01501;//Enable external Command
  509. dsi_set_cmdq(&array, 1, 1);
  510. array[0] = 0x00043700;// return byte number
  511. dsi_set_cmdq(&array, 1, 1);
  512. read_reg_v2(0xff, buffer, 4);
  513. id = buffer[0];
  514. #ifdef BUILD_LK
  515. dprintf(INFO, "=====>compare id for test %s, id = 0x%08x,buffer[1] = %x,buffer[2] = %x,buffer[3] = %x\n",
  516. __func__, id, buffer[1], buffer[2], buffer[3]);
  517. #else
  518. printk("=====>compare id for test %s, id = 0x%08x,buffer[1] = %x,buffer[2] = %x,buffer[3] = %x\n",
  519. __func__, id, buffer[1], buffer[2], buffer[3]);
  520. #endif
  521. return (LCM_ID == id)?1:0;
  522. }
  523. static unsigned int lcm_esd_check(void)
  524. {
  525. #ifndef BUILD_LK
  526. char buffer[4], buffer1[7];
  527. int array[16], array1[16];
  528. if(lcm_esd_test)
  529. {
  530. lcm_esd_test = FALSE;
  531. return TRUE;
  532. }
  533. array[0] = 0x00043700;
  534. dsi_set_cmdq(array, 1, 1);
  535. read_reg_v2(0x09, buffer, 4);
  536. array1[0] = 0x00073700;
  537. dsi_set_cmdq(array1, 1, 1);
  538. read_reg_v2(0xB1, buffer1, 7);
  539. printk("esdcheck:0x%x ,0x%x ,0x%x, 0x%x\n", buffer[0], buffer[1], buffer[2], buffer[3]);
  540. if((buffer[0] == 0x80) && (buffer[1] == 0x73) && (buffer[2] == 0x4) &&
  541. (buffer1[5] == 0x11) && (buffer1[6] == 0x11))
  542. return FALSE;
  543. else
  544. return TRUE;
  545. #endif
  546. }
  547. static unsigned int lcm_esd_recover(void)
  548. {
  549. lcm_init();
  550. return TRUE;
  551. }
  552. LCM_DRIVER ek79023_dsi_wsvga_vdo_lcm_drv =
  553. {
  554. .name = "ek79023_dsi_wsvga_vdo",
  555. .set_util_funcs = lcm_set_util_funcs,
  556. .get_params = lcm_get_params,
  557. .init = lcm_init,
  558. .suspend = lcm_suspend,
  559. .resume = lcm_resume,
  560. .init_power = lcm_init_power,
  561. .resume_power = lcm_resume_power,
  562. .suspend_power = lcm_suspend_power,
  563. //.compare_id = lcm_compare_id,
  564. //.esd_check = lcm_esd_check,
  565. //.esd_recover = lcm_esd_recover,
  566. #if (LCM_DSI_CMD_MODE)
  567. //.set_backlight = lcm_setbacklight,
  568. //.set_pwm = lcm_setpwm,
  569. //.get_pwm = lcm_getpwm,
  570. .update = lcm_update
  571. #endif
  572. };