cpt_clap070wp03xg_sn65dsi83.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  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. #else
  38. #include <string.h>
  39. #endif
  40. #ifdef BUILD_LK
  41. #include <platform/mt_gpio.h>
  42. #include <platform/mt_i2c.h>
  43. #include <platform/mt_pmic.h>
  44. #include "ddp_dsi.h"
  45. #include "ddp_hal.h"
  46. #elif (defined BUILD_UBOOT)
  47. #include <asm/arch/mt6577_gpio.h>
  48. #else
  49. #include <mach/mt_gpio.h>
  50. #include <mach/mt_pm_ldo.h>
  51. #include "sn65dsi83_i2c.h"
  52. #include "ddp_dsi.h"
  53. #include "ddp_hal.h"
  54. #endif
  55. #include "lcm_drv.h"
  56. #define LVDS_PANEL_8BITS_SUPPORT
  57. #define SN65DSI83_PATTERN
  58. /* --------------------------------------------------------------------------- */
  59. /* Local Constants */
  60. /* --------------------------------------------------------------------------- */
  61. #define FRAME_WIDTH (800)
  62. #define FRAME_HEIGHT (1280)
  63. /* GPIO131 VDD33_LCD */
  64. #ifdef GPIO_LCM_PWR_EN
  65. #define GPIO_LCD_PWR_EN GPIO_LCM_PWR_EN
  66. #else
  67. #define GPIO_LCD_PWR_EN 0xFFFFFFFF
  68. #endif
  69. /* GPIO42 VDD18_LVDS for SN65DSI83 power */
  70. #ifdef GPIO_LCM_PWR2_EN
  71. #define GPIO_LCD_PWR2_EN GPIO_LCM_PWR2_EN
  72. #else
  73. #define GPIO_LCD_PWR2_EN 0xFFFFFFFF
  74. #endif
  75. /* VGP6_PMU AVDDVGH/VGL/VCOM for panel power */
  76. /* GPIO103 LCM_RST for panel */
  77. #ifdef GPIO_LCM_RST
  78. #define GPIO_LCD_RST_EN GPIO_LCM_RST
  79. #else
  80. #define GPIO_LCD_RST_EN 0xFFFFFFFF
  81. #endif
  82. /* GPIO127 LVDS_EN_R for SN65DSI83 */
  83. #ifdef GPIO_LCM_BRIDGE_EN
  84. #define GPIO_LCD_BRIDGE_EN GPIO_LCM_BRIDGE_EN
  85. #else
  86. #define GPIO_LCD_BRIDGE_EN 0xFFFFFFFF
  87. #endif
  88. /* GPIO87 DISP_PWM0 for backlight panel */
  89. #ifdef GPIO_LCM_BL_EN
  90. #define GPIO_LCD_BL_EN GPIO_LCM_BL_EN
  91. #else
  92. #define GPIO_LCD_BL_EN 0xFFFFFFFF
  93. #endif
  94. /* GPIO102 LCM_STBY_2V8 for panel */
  95. #ifdef GPIO_LCM_STB
  96. #define GPIO_LCD_STB_EN GPIO_LCM_STB
  97. #else
  98. #define GPIO_LCD_STB_EN 0xFFFFFFFF
  99. #endif
  100. /* the following don't use by lcm driver */
  101. #ifdef GPIO_LCM_LVL_SHIFT_EN
  102. #define GPIO_SHIFT_EN GPIO_LCM_LVL_SHIFT_EN
  103. #else
  104. #define GPIO_SHIFT_EN 0xFFFFFFFF
  105. #endif
  106. #define SN65DSI_DEBUG //for check system(bb dsi and ti chip) status
  107. /* --------------------------------------------------------------------------- */
  108. /* Local Variables */
  109. /* --------------------------------------------------------------------------- */
  110. static LCM_UTIL_FUNCS lcm_util = {
  111. .set_reset_pin = NULL,
  112. .udelay = NULL,
  113. .mdelay = NULL,
  114. };
  115. #define SET_RESET_PIN(v) (mt_set_reset_pin((v)))
  116. #define UDELAY(n) (lcm_util.udelay(n))
  117. #define MDELAY(n) (lcm_util.mdelay(n))
  118. #define REGFLAG_DELAY 0xAB
  119. typedef unsigned char kal_uint8;
  120. typedef struct {
  121. unsigned char cmd;
  122. unsigned char data;
  123. } sn65dsi8x_setting_table;
  124. /* --------------------------------------------------------------------------- */
  125. /* Local Functions */
  126. /* --------------------------------------------------------------------------- */
  127. extern void DSI_clk_HS_mode(DISP_MODULE_ENUM module, void* cmdq, bool enter);
  128. extern void upmu_set_rg_vgp6_vosel(U32 val);
  129. extern void upmu_set_rg_vgp6_sw_en(U32 val);
  130. #ifdef BUILD_LK
  131. #define sn65dsi83_SLAVE_ADDR_WRITE 0x58
  132. #define SN65DSI83_I2C_ID I2C4
  133. static struct mt_i2c_t sn65dsi83_i2c;
  134. /**********************************************************
  135. *
  136. * [I2C Function For Read/Write fan5405]
  137. *
  138. *********************************************************/
  139. kal_uint32 sn65dsi83_write_byte(kal_uint8 addr, kal_uint8 value)
  140. {
  141. kal_uint32 ret_code = I2C_OK;
  142. kal_uint8 write_data[2];
  143. kal_uint16 len;
  144. write_data[0]= addr;
  145. write_data[1] = value;
  146. sn65dsi83_i2c.id = SN65DSI83_I2C_ID;
  147. /* Since i2c will left shift 1 bit, we need to set SN65DSI83 I2C address to >>1 */
  148. sn65dsi83_i2c.addr = (sn65dsi83_SLAVE_ADDR_WRITE >> 1);
  149. sn65dsi83_i2c.mode = ST_MODE;
  150. sn65dsi83_i2c.speed = 100;
  151. len = 2;
  152. ret_code = i2c_write(&sn65dsi83_i2c, write_data, len);
  153. return ret_code;
  154. }
  155. kal_uint32 sn65dsi83_read_byte (kal_uint8 addr, kal_uint8 *dataBuffer)
  156. {
  157. kal_uint32 ret_code = I2C_OK;
  158. kal_uint16 len;
  159. *dataBuffer = addr;
  160. sn65dsi83_i2c.id = SN65DSI83_I2C_ID;
  161. /* Since i2c will left shift 1 bit, we need to set SN65DSI83 I2C address to >>1 */
  162. sn65dsi83_i2c.addr = (sn65dsi83_SLAVE_ADDR_WRITE >> 1);
  163. sn65dsi83_i2c.mode = ST_MODE;
  164. sn65dsi83_i2c.speed = 100;
  165. len = 1;
  166. ret_code = i2c_write_read(&sn65dsi83_i2c, dataBuffer, len, len);
  167. return ret_code;
  168. }
  169. /******************************************************************************
  170. *IIC drvier,:protocol type 2 add by chenguangjian end
  171. ******************************************************************************/
  172. #else
  173. extern int sn65dsi83_read_byte(kal_uint8 cmd, kal_uint8 *returnData);
  174. extern int sn65dsi83_write_byte(kal_uint8 cmd, kal_uint8 Data);
  175. #endif
  176. /* sn65dis83 chip init table */
  177. static sn65dsi8x_setting_table sn65dis83_init_table[] = {
  178. #if defined(LVDS_PANEL_8BITS_SUPPORT)
  179. #if 0
  180. {0x09, 0x00},
  181. {0x0A, 0x05},
  182. {0x0B, 0x10},
  183. {0x0D, 0x00},
  184. {0x10, 0x26},
  185. {0x11, 0x00},
  186. {0x12, 0x2c},
  187. {0x13, 0x00},
  188. {0x18, 0x78},
  189. {0x19, 0x00},
  190. {0x1A, 0x03},
  191. {0x1B, 0x00},
  192. {0x20, 0x20},
  193. {0x21, 0x03},
  194. {0x22, 0x00},
  195. {0x23, 0x00},
  196. {0x24, 0x00},
  197. {0x25, 0x05}, // 0x00
  198. {0x26, 0x00},
  199. {0x27, 0x00},
  200. {0x28, 0x21},
  201. {0x29, 0x00},
  202. {0x2A, 0x00},
  203. {0x2B, 0x00},
  204. {0x2C, 0x0a},
  205. {0x2D, 0x00},
  206. {0x2E, 0x00},
  207. {0x2F, 0x00},
  208. {0x30, 0x02},
  209. {0x31, 0x00},
  210. {0x32, 0x00},
  211. {0x33, 0x00},
  212. {0x34, 0x18},
  213. {0x35, 0x00},
  214. {0x36, 0x02}, // 0x00
  215. {0x37, 0x00},
  216. {0x38, 0x1e}, // 0x00
  217. {0x39, 0x00},
  218. {0x3A, 0x04}, // 0x00
  219. {0x3B, 0x00},
  220. {0x3C, 0x10}, // 0x00
  221. {0x3D, 0x00},
  222. {0x3E, 0x00},
  223. {0x0D, 0x01},
  224. {REGFLAG_DELAY, 0x0a},
  225. {0x09, 0x01},
  226. {0xFF, 0x00},
  227. #else
  228. {0x09, 0x00},
  229. {0x0A, 0x05},
  230. {0x0B, 0x10},
  231. {0x0D, 0x00},
  232. {0x10, 0x26},
  233. {0x11, 0x00},
  234. {0x12, 0x2c},
  235. {0x13, 0x00},
  236. {0x18, 0x78},
  237. {0x19, 0x00},
  238. {0x1A, 0x03},
  239. {0x1B, 0x00},
  240. {0x20, 0x20},
  241. {0x21, 0x03},
  242. {0x22, 0x00},
  243. {0x23, 0x00},
  244. {0x24, 0x00},
  245. {0x25, 0x00}, // 0x00
  246. {0x26, 0x00},
  247. {0x27, 0x00},
  248. {0x28, 0x21},
  249. {0x29, 0x00},
  250. {0x2A, 0x00},
  251. {0x2B, 0x00},
  252. {0x2C, 0x0a},
  253. {0x2D, 0x00},
  254. {0x2E, 0x00},
  255. {0x2F, 0x00},
  256. {0x30, 0x02},
  257. {0x31, 0x00},
  258. {0x32, 0x00},
  259. {0x33, 0x00},
  260. {0x34, 0x18},
  261. {0x35, 0x00},
  262. {0x36, 0x00}, // 0x00
  263. {0x37, 0x00},
  264. {0x38, 0x00}, // 0x00
  265. {0x39, 0x00},
  266. {0x3A, 0x00}, // 0x00
  267. {0x3B, 0x00},
  268. {0x3C, 0x00}, // 0x00
  269. {0x3D, 0x00},
  270. {0x3E, 0x00},
  271. {0x0D, 0x01},
  272. {REGFLAG_DELAY, 0x0a},
  273. {0x09, 0x01},
  274. {0xFF, 0x00},
  275. #endif
  276. #endif
  277. };
  278. static void push_table(sn65dsi8x_setting_table *table, unsigned int count)
  279. {
  280. unsigned int i;
  281. for (i = 0; i < count; i++) {
  282. unsigned cmd;
  283. cmd = table[i].cmd;
  284. switch (cmd) {
  285. case REGFLAG_DELAY:
  286. MDELAY(table[i].data);
  287. break;
  288. case 0xFF:
  289. break;
  290. default:
  291. #ifdef BUILD_LK
  292. sn65dsi83_write_byte(cmd, table[i].data);
  293. #else
  294. sn65dsi83_write_byte(cmd, table[i].data);
  295. #endif
  296. }
  297. }
  298. }
  299. #ifdef SN65DSI_DEBUG
  300. static void dump_reg_table(sn65dsi8x_setting_table *table, unsigned int count)
  301. {
  302. unsigned int i;
  303. unsigned char data;
  304. for (i = 0; i < count; i++) {
  305. unsigned cmd;
  306. cmd = table[i].cmd;
  307. switch (cmd) {
  308. case REGFLAG_DELAY:
  309. MDELAY(table[i].data);
  310. break;
  311. case 0xFF:
  312. break;
  313. default:
  314. #ifdef BUILD_LK
  315. sn65dsi83_read_byte(cmd,&data);
  316. printf("dump cmd=0x%x data=0x%x \n",cmd,data);
  317. #else
  318. sn65dsi83_read_byte(cmd,&data);
  319. printk("dump cmd=0x%x data=0x%x \n",cmd,data);
  320. #endif
  321. }
  322. }
  323. }
  324. #endif
  325. void init_sn65dsi8x(void)
  326. {
  327. #ifdef SN65DSI_DEBUG
  328. unsigned char data;
  329. #endif
  330. push_table(sn65dis83_init_table,
  331. sizeof(sn65dis83_init_table) / sizeof(sn65dsi8x_setting_table));
  332. #ifdef SN65DSI_DEBUG
  333. sn65dsi83_write_byte(0xe0,1);
  334. sn65dsi83_write_byte(0xe1,0xff);
  335. MDELAY(5);
  336. sn65dsi83_read_byte(0xe5, &data);
  337. #ifdef BUILD_LK
  338. printf("dump cmd=0xe5 data=0x%x \n",data);
  339. #else
  340. printk("dump cmd=0xe5 data=0x%x \n",data);
  341. #endif
  342. dump_reg_table(sn65dis83_init_table,
  343. sizeof(sn65dis83_init_table) / sizeof(sn65dsi8x_setting_table));
  344. #endif
  345. }
  346. /* --------------------------------------------------------------------------- */
  347. /* LCM Driver Implementations */
  348. /* --------------------------------------------------------------------------- */
  349. static void lcm_set_util_funcs(const LCM_UTIL_FUNCS *util)
  350. {
  351. memcpy(&lcm_util, util, sizeof(LCM_UTIL_FUNCS));
  352. }
  353. static void lcm_get_params(LCM_PARAMS *params)
  354. {
  355. memset(params, 0, sizeof(LCM_PARAMS));
  356. params->type = LCM_TYPE_DSI;
  357. params->width = FRAME_WIDTH;
  358. params->height = FRAME_HEIGHT;
  359. params->dsi.mode = SYNC_EVENT_VDO_MODE;
  360. /* DSI */
  361. /* Command mode setting */
  362. params->dsi.LANE_NUM = LCM_FOUR_LANE;
  363. /* The following defined the fomat for data coming from LCD engine. */
  364. #if defined(LVDS_PANEL_8BITS_SUPPORT)
  365. //params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888;
  366. params->dsi.data_format.format = LCM_DSI_FORMAT_RGB666;
  367. #else
  368. params->dsi.data_format.format = LCM_DSI_FORMAT_RGB666;
  369. #endif
  370. params->dsi.word_count=FRAME_WIDTH*3;
  371. params->dsi.vertical_sync_active = 2;
  372. params->dsi.vertical_backporch = 2;
  373. params->dsi.vertical_frontporch = 4;
  374. params->dsi.vertical_active_line = FRAME_HEIGHT;
  375. params->dsi.horizontal_sync_active =10;
  376. params->dsi.horizontal_backporch = 24;
  377. params->dsi.horizontal_frontporch = 30;
  378. params->dsi.horizontal_active_pixel = FRAME_WIDTH;
  379. #if defined(LVDS_PANEL_8BITS_SUPPORT)
  380. //params->dsi.PS=LCM_PACKED_PS_24BIT_RGB888;
  381. params->dsi.PS = LCM_PACKED_PS_18BIT_RGB666;
  382. #else
  383. params->dsi.PS=LCM_PACKED_PS_18BIT_RGB666;
  384. #endif
  385. params->dsi.pll_select = 0; /* 0: MIPI_PLL; 1: LVDS_PLL */
  386. params->dsi.PLL_CLOCK = 224;
  387. params->dsi.cont_clock = 1;
  388. }
  389. static void lcm_set_gpio_output(unsigned int GPIO, unsigned int output)
  390. {
  391. if (GPIO == 0xFFFFFFFF) {
  392. #ifdef BUILD_LK
  393. printf("[LK/LCM] GPIO_LCD_PWR_EN = 0x%x\n",GPIO_LCD_PWR_EN);
  394. printf("[LK/LCM] GPIO_LCD_PWR2_EN = 0x%x \n",GPIO_LCD_PWR2_EN);
  395. printf("[LK/LCM] GPIO_LCD_RST_EN = 0x%x \n",GPIO_LCD_RST_EN);
  396. printf("[LK/LCM] GPIO_LCD_STB_EN = 0x%x\n",GPIO_LCD_STB_EN);
  397. printf("[LK/LCM] GPIO_SHIFT_EN = 0x%x\n",GPIO_SHIFT_EN);
  398. printf("[LK/LCM] GPIO_LCD_BL_EN = 0x%x\n",GPIO_LCD_BL_EN);
  399. printf("[LK/LCM] GPIO_LCD_BRIDGE_EN = 0x%x \n",GPIO_LCD_BRIDGE_EN);
  400. #elif (defined BUILD_UBOOT) /* do nothing in uboot */
  401. #else
  402. #endif
  403. return;
  404. }
  405. mt_set_gpio_mode(GPIO, GPIO_MODE_00);
  406. mt_set_gpio_dir(GPIO, GPIO_DIR_OUT);
  407. mt_set_gpio_out(GPIO, (output>0)? GPIO_OUT_ONE: GPIO_OUT_ZERO);
  408. }
  409. static void lcm_init(void)
  410. {
  411. #ifdef BUILD_LK
  412. printf("[LK/LCM]lcm_init \n");
  413. /* step1: sn65dsi8x enbable and init */
  414. /* GPIO42 VDD18_LVDS for SN65DSI83 power */
  415. lcm_set_gpio_output(GPIO_LCD_PWR2_EN, GPIO_OUT_ONE);
  416. MDELAY(20);
  417. /* GPIO127 LVDS_EN_R for SN65DSI83 */
  418. lcm_set_gpio_output(GPIO_LCD_BRIDGE_EN, GPIO_OUT_ONE);
  419. MDELAY(5);
  420. lcm_set_gpio_output(GPIO_LCD_BRIDGE_EN, GPIO_OUT_ZERO);
  421. MDELAY(20);
  422. lcm_set_gpio_output(GPIO_LCD_BRIDGE_EN, GPIO_OUT_ONE);
  423. MDELAY(50);
  424. DSI_clk_HS_mode(0, NULL, 1);
  425. MDELAY(5);
  426. init_sn65dsi8x();
  427. MDELAY(10);
  428. /* step 2 :lvds lcd init */
  429. /* GPIO131 VDD33_LCD */
  430. lcm_set_gpio_output(GPIO_LCD_PWR_EN, GPIO_OUT_ONE);
  431. MDELAY(50);
  432. /* VGP6_PMU AVDDVGH/VGL/VCOM for panel power */
  433. upmu_set_rg_vgp6_vosel(0x7);
  434. upmu_set_rg_vgp6_sw_en(0x1);
  435. /* GPIO103 LCM_RST for panel */
  436. lcm_set_gpio_output(GPIO_LCD_RST_EN, GPIO_OUT_ZERO);
  437. MDELAY(50);
  438. /* GPIO102 LCM_STBY_2V8 for panel */
  439. lcm_set_gpio_output(GPIO_LCD_STB_EN,GPIO_OUT_ONE);
  440. MDELAY(20);
  441. /* GPIO87 DISP_PWM0 for backlight panel */
  442. lcm_set_gpio_output(GPIO_LCD_BL_EN, GPIO_OUT_ONE);
  443. #elif (defined BUILD_UBOOT)
  444. #else
  445. printk("[Kernel/LCM]lcm_init \n");
  446. DSI_clk_HS_mode(0, NULL, 1);
  447. #endif
  448. }
  449. static void lcm_suspend(void)
  450. {
  451. #ifdef BUILD_LK
  452. printf("[LK/LCM]lcm_suspend enter \n");
  453. #else
  454. unsigned char temp;
  455. printk("[Kernel/LCM]lcm_suspend enter \n");
  456. lcm_set_gpio_output(GPIO_LCD_BL_EN, GPIO_OUT_ZERO);
  457. MDELAY(20);
  458. lcm_set_gpio_output(GPIO_LCD_PWR2_EN, GPIO_OUT_ZERO);
  459. MDELAY(30); /* avoid LCD resume transint */
  460. /* step 1 power down lvds lcd */
  461. lcm_set_gpio_output(GPIO_LCD_BRIDGE_EN, GPIO_OUT_ZERO);
  462. MDELAY(10);
  463. hwPowerDown(MT65XX_POWER_LDO_VGP6, "LCM"); /* LCMBIASON :VGH VHL */
  464. MDELAY(20);
  465. lcm_set_gpio_output(GPIO_LCD_PWR_EN, GPIO_OUT_ZERO); /* LCM VCC :enable LCD VCC */
  466. MDELAY(20);
  467. lcm_set_gpio_output(GPIO_LCD_STB_EN,GPIO_OUT_ZERO);
  468. MDELAY(20);
  469. lcm_set_gpio_output(GPIO_LCD_RST_EN, GPIO_OUT_ZERO); /* LCM_STBY */
  470. MDELAY(50);
  471. /* step 2 suspend sn65dsi8x */
  472. sn65dsi83_read_byte(0x0a, &temp); /* for test wether ti lock the pll clok */
  473. printk("lcm_suspend 0x0a value=0x%x \n",temp);
  474. sn65dsi83_read_byte(0x0d,&temp);
  475. printk("lcm_suspend 0x0d value=0x%x \n",temp);
  476. sn65dsi83_write_byte(0x0d, (temp & 0xfe)); /* set bit0: 0 */
  477. /* step 3 set dsi LP mode */
  478. DSI_clk_HS_mode(0, NULL, 0);
  479. #endif
  480. }
  481. static void lcm_resume(void)
  482. {
  483. #ifdef BUILD_LK
  484. printf("[LK/LCM]lcm_resume enter\n");
  485. #else
  486. #ifdef SN65DSI_DEBUG
  487. unsigned char temp;
  488. #endif
  489. printk("[Kernel/LCM]lcm_resume enter \n");
  490. DSI_clk_HS_mode(0, NULL, 1);
  491. MDELAY(50);
  492. /* step 1 resume sn65dsi8x */
  493. lcm_set_gpio_output(GPIO_LCD_PWR2_EN, GPIO_OUT_ONE);
  494. MDELAY(10);
  495. lcm_set_gpio_output(GPIO_LCD_BRIDGE_EN, GPIO_OUT_ONE);
  496. MDELAY(5);
  497. lcm_set_gpio_output(GPIO_LCD_BRIDGE_EN, GPIO_OUT_ZERO);
  498. MDELAY(20);
  499. lcm_set_gpio_output(GPIO_LCD_BRIDGE_EN, GPIO_OUT_ONE);
  500. MDELAY(10);
  501. init_sn65dsi8x();
  502. MDELAY(10);
  503. #ifdef SN65DSI_DEBUG
  504. sn65dsi83_read_byte(0x0a,&temp);
  505. printk("lcm_resume cmd-- 0x0a=0x%x \n",temp);
  506. sn65dsi83_read_byte(0x0d,&temp);
  507. printk("lcm_resume cmd-- 0x0d=0x%x \n",temp);
  508. sn65dsi83_read_byte(0x09,&temp);
  509. printk("lcm_resume cmd-- 0x09=0x%x \n",temp);
  510. #endif
  511. /* step 2 resume lvds */
  512. lcm_set_gpio_output(GPIO_LCD_PWR_EN, GPIO_OUT_ONE);
  513. MDELAY(50);
  514. hwPowerOn(MT65XX_POWER_LDO_VGP6, VOL_3300, "LCM");
  515. MDELAY(30);
  516. lcm_set_gpio_output(GPIO_LCD_RST_EN, GPIO_OUT_ONE);
  517. MDELAY(5);
  518. lcm_set_gpio_output(GPIO_LCD_STB_EN, GPIO_OUT_ONE);
  519. MDELAY(5);
  520. lcm_set_gpio_output(GPIO_LCD_BL_EN, GPIO_OUT_ONE);
  521. #endif
  522. }
  523. static unsigned int lcm_compare_id(void)
  524. {
  525. #if defined(BUILD_LK)
  526. printf("Sn65dsi83 lcm_compare_id enter \n");
  527. #endif
  528. return 1;
  529. }
  530. LCM_DRIVER cpt_clap070wp03xg_sn65dsi83_lcm_drv = {
  531. .name = "cpt_clap070wp03xg_sn65dsi83",
  532. .set_util_funcs = lcm_set_util_funcs,
  533. .get_params = lcm_get_params,
  534. .init = lcm_init,
  535. .suspend = lcm_suspend,
  536. .resume = lcm_resume,
  537. .compare_id = lcm_compare_id,
  538. };