exynos_mipi_dsi_common.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2012 Samsung Electronics
  4. *
  5. * Author: InKi Dae <inki.dae@samsung.com>
  6. * Author: Donghwa Lee <dh09.lee@samsung.com>
  7. */
  8. #include <common.h>
  9. #include <lcd.h>
  10. #include <linux/err.h>
  11. #include <asm/arch/dsim.h>
  12. #include <asm/arch/mipi_dsim.h>
  13. #include "exynos_mipi_dsi_lowlevel.h"
  14. #define MHZ (1000 * 1000)
  15. #define FIN_HZ (24 * MHZ)
  16. #define DFIN_PLL_MIN_HZ (6 * MHZ)
  17. #define DFIN_PLL_MAX_HZ (12 * MHZ)
  18. #define DFVCO_MIN_HZ (500 * MHZ)
  19. #define DFVCO_MAX_HZ (1000 * MHZ)
  20. #define TRY_GET_FIFO_TIMEOUT (5000 * 2)
  21. /* MIPI-DSIM status types. */
  22. enum {
  23. DSIM_STATE_INIT, /* should be initialized. */
  24. DSIM_STATE_STOP, /* CPU and LCDC are LP mode. */
  25. DSIM_STATE_HSCLKEN, /* HS clock was enabled. */
  26. DSIM_STATE_ULPS
  27. };
  28. /* define DSI lane types. */
  29. enum {
  30. DSIM_LANE_CLOCK = (1 << 0),
  31. DSIM_LANE_DATA0 = (1 << 1),
  32. DSIM_LANE_DATA1 = (1 << 2),
  33. DSIM_LANE_DATA2 = (1 << 3),
  34. DSIM_LANE_DATA3 = (1 << 4)
  35. };
  36. static unsigned int dpll_table[15] = {
  37. 100, 120, 170, 220, 270,
  38. 320, 390, 450, 510, 560,
  39. 640, 690, 770, 870, 950
  40. };
  41. static void exynos_mipi_dsi_long_data_wr(struct mipi_dsim_device *dsim,
  42. const unsigned char *data0, unsigned int data1)
  43. {
  44. unsigned int data_cnt = 0, payload = 0;
  45. /* in case that data count is more then 4 */
  46. for (data_cnt = 0; data_cnt < data1; data_cnt += 4) {
  47. /*
  48. * after sending 4bytes per one time,
  49. * send remainder data less then 4.
  50. */
  51. if ((data1 - data_cnt) < 4) {
  52. if ((data1 - data_cnt) == 3) {
  53. payload = data0[data_cnt] |
  54. data0[data_cnt + 1] << 8 |
  55. data0[data_cnt + 2] << 16;
  56. debug("count = 3 payload = %x, %x %x %x\n",
  57. payload, data0[data_cnt],
  58. data0[data_cnt + 1],
  59. data0[data_cnt + 2]);
  60. } else if ((data1 - data_cnt) == 2) {
  61. payload = data0[data_cnt] |
  62. data0[data_cnt + 1] << 8;
  63. debug("count = 2 payload = %x, %x %x\n", payload,
  64. data0[data_cnt], data0[data_cnt + 1]);
  65. } else if ((data1 - data_cnt) == 1) {
  66. payload = data0[data_cnt];
  67. }
  68. } else {
  69. /* send 4bytes per one time. */
  70. payload = data0[data_cnt] |
  71. data0[data_cnt + 1] << 8 |
  72. data0[data_cnt + 2] << 16 |
  73. data0[data_cnt + 3] << 24;
  74. debug("count = 4 payload = %x, %x %x %x %x\n",
  75. payload, *(u8 *)(data0 + data_cnt),
  76. data0[data_cnt + 1],
  77. data0[data_cnt + 2],
  78. data0[data_cnt + 3]);
  79. }
  80. exynos_mipi_dsi_wr_tx_data(dsim, payload);
  81. }
  82. }
  83. int exynos_mipi_dsi_wr_data(struct mipi_dsim_device *dsim, unsigned int data_id,
  84. const unsigned char *data0, unsigned int data1)
  85. {
  86. unsigned int timeout = TRY_GET_FIFO_TIMEOUT;
  87. unsigned long delay_val, delay;
  88. unsigned int check_rx_ack = 0;
  89. if (dsim->state == DSIM_STATE_ULPS) {
  90. debug("state is ULPS.\n");
  91. return -EINVAL;
  92. }
  93. delay_val = MHZ / dsim->dsim_config->esc_clk;
  94. delay = 10 * delay_val;
  95. mdelay(delay);
  96. /* only if transfer mode is LPDT, wait SFR becomes empty. */
  97. if (dsim->state == DSIM_STATE_STOP) {
  98. while (!(exynos_mipi_dsi_get_fifo_state(dsim) &
  99. SFR_HEADER_EMPTY)) {
  100. if ((timeout--) > 0)
  101. mdelay(1);
  102. else {
  103. debug("SRF header fifo is not empty.\n");
  104. return -EINVAL;
  105. }
  106. }
  107. }
  108. switch (data_id) {
  109. /* short packet types of packet types for command. */
  110. case MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM:
  111. case MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM:
  112. case MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM:
  113. case MIPI_DSI_DCS_SHORT_WRITE:
  114. case MIPI_DSI_DCS_SHORT_WRITE_PARAM:
  115. case MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE:
  116. debug("data0 = %x data1 = %x\n",
  117. data0[0], data0[1]);
  118. exynos_mipi_dsi_wr_tx_header(dsim, data_id, data0[0], data0[1]);
  119. if (check_rx_ack) {
  120. /* process response func should be implemented */
  121. return 0;
  122. } else {
  123. return -EINVAL;
  124. }
  125. /* general command */
  126. case MIPI_DSI_COLOR_MODE_OFF:
  127. case MIPI_DSI_COLOR_MODE_ON:
  128. case MIPI_DSI_SHUTDOWN_PERIPHERAL:
  129. case MIPI_DSI_TURN_ON_PERIPHERAL:
  130. exynos_mipi_dsi_wr_tx_header(dsim, data_id, data0[0], data0[1]);
  131. if (check_rx_ack) {
  132. /* process response func should be implemented. */
  133. return 0;
  134. } else {
  135. return -EINVAL;
  136. }
  137. /* packet types for video data */
  138. case MIPI_DSI_V_SYNC_START:
  139. case MIPI_DSI_V_SYNC_END:
  140. case MIPI_DSI_H_SYNC_START:
  141. case MIPI_DSI_H_SYNC_END:
  142. case MIPI_DSI_END_OF_TRANSMISSION:
  143. return 0;
  144. /* short and response packet types for command */
  145. case MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM:
  146. case MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM:
  147. case MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM:
  148. case MIPI_DSI_DCS_READ:
  149. exynos_mipi_dsi_clear_all_interrupt(dsim);
  150. exynos_mipi_dsi_wr_tx_header(dsim, data_id, data0[0], data0[1]);
  151. /* process response func should be implemented. */
  152. return 0;
  153. /* long packet type and null packet */
  154. case MIPI_DSI_NULL_PACKET:
  155. case MIPI_DSI_BLANKING_PACKET:
  156. return 0;
  157. case MIPI_DSI_GENERIC_LONG_WRITE:
  158. case MIPI_DSI_DCS_LONG_WRITE:
  159. {
  160. unsigned int payload = 0;
  161. /* if data count is less then 4, then send 3bytes data. */
  162. if (data1 < 4) {
  163. payload = data0[0] |
  164. data0[1] << 8 |
  165. data0[2] << 16;
  166. exynos_mipi_dsi_wr_tx_data(dsim, payload);
  167. debug("count = %d payload = %x,%x %x %x\n",
  168. data1, payload, data0[0],
  169. data0[1], data0[2]);
  170. } else {
  171. /* in case that data count is more then 4 */
  172. exynos_mipi_dsi_long_data_wr(dsim, data0, data1);
  173. }
  174. /* put data into header fifo */
  175. exynos_mipi_dsi_wr_tx_header(dsim, data_id, data1 & 0xff,
  176. (data1 & 0xff00) >> 8);
  177. }
  178. if (check_rx_ack)
  179. /* process response func should be implemented. */
  180. return 0;
  181. else
  182. return -EINVAL;
  183. /* packet typo for video data */
  184. case MIPI_DSI_PACKED_PIXEL_STREAM_16:
  185. case MIPI_DSI_PACKED_PIXEL_STREAM_18:
  186. case MIPI_DSI_PIXEL_STREAM_3BYTE_18:
  187. case MIPI_DSI_PACKED_PIXEL_STREAM_24:
  188. if (check_rx_ack) {
  189. /* process response func should be implemented. */
  190. return 0;
  191. } else {
  192. return -EINVAL;
  193. }
  194. default:
  195. debug("data id %x is not supported current DSI spec.\n",
  196. data_id);
  197. return -EINVAL;
  198. }
  199. return 0;
  200. }
  201. int exynos_mipi_dsi_pll_on(struct mipi_dsim_device *dsim, unsigned int enable)
  202. {
  203. int sw_timeout;
  204. if (enable) {
  205. sw_timeout = 1000;
  206. exynos_mipi_dsi_clear_interrupt(dsim);
  207. exynos_mipi_dsi_enable_pll(dsim, 1);
  208. while (1) {
  209. sw_timeout--;
  210. if (exynos_mipi_dsi_is_pll_stable(dsim))
  211. return 0;
  212. if (sw_timeout == 0)
  213. return -EINVAL;
  214. }
  215. } else
  216. exynos_mipi_dsi_enable_pll(dsim, 0);
  217. return 0;
  218. }
  219. unsigned long exynos_mipi_dsi_change_pll(struct mipi_dsim_device *dsim,
  220. unsigned int pre_divider, unsigned int main_divider,
  221. unsigned int scaler)
  222. {
  223. unsigned long dfin_pll, dfvco, dpll_out;
  224. unsigned int i, freq_band = 0xf;
  225. dfin_pll = (FIN_HZ / pre_divider);
  226. /******************************************************
  227. * Serial Clock(=ByteClk X 8) FreqBand[3:0] *
  228. ******************************************************
  229. * ~ 99.99 MHz 0000
  230. * 100 ~ 119.99 MHz 0001
  231. * 120 ~ 159.99 MHz 0010
  232. * 160 ~ 199.99 MHz 0011
  233. * 200 ~ 239.99 MHz 0100
  234. * 140 ~ 319.99 MHz 0101
  235. * 320 ~ 389.99 MHz 0110
  236. * 390 ~ 449.99 MHz 0111
  237. * 450 ~ 509.99 MHz 1000
  238. * 510 ~ 559.99 MHz 1001
  239. * 560 ~ 639.99 MHz 1010
  240. * 640 ~ 689.99 MHz 1011
  241. * 690 ~ 769.99 MHz 1100
  242. * 770 ~ 869.99 MHz 1101
  243. * 870 ~ 949.99 MHz 1110
  244. * 950 ~ 1000 MHz 1111
  245. ******************************************************/
  246. if (dfin_pll < DFIN_PLL_MIN_HZ || dfin_pll > DFIN_PLL_MAX_HZ) {
  247. debug("fin_pll range should be 6MHz ~ 12MHz\n");
  248. exynos_mipi_dsi_enable_afc(dsim, 0, 0);
  249. } else {
  250. if (dfin_pll < 7 * MHZ)
  251. exynos_mipi_dsi_enable_afc(dsim, 1, 0x1);
  252. else if (dfin_pll < 8 * MHZ)
  253. exynos_mipi_dsi_enable_afc(dsim, 1, 0x0);
  254. else if (dfin_pll < 9 * MHZ)
  255. exynos_mipi_dsi_enable_afc(dsim, 1, 0x3);
  256. else if (dfin_pll < 10 * MHZ)
  257. exynos_mipi_dsi_enable_afc(dsim, 1, 0x2);
  258. else if (dfin_pll < 11 * MHZ)
  259. exynos_mipi_dsi_enable_afc(dsim, 1, 0x5);
  260. else
  261. exynos_mipi_dsi_enable_afc(dsim, 1, 0x4);
  262. }
  263. dfvco = dfin_pll * main_divider;
  264. debug("dfvco = %lu, dfin_pll = %lu, main_divider = %d\n",
  265. dfvco, dfin_pll, main_divider);
  266. if (dfvco < DFVCO_MIN_HZ || dfvco > DFVCO_MAX_HZ)
  267. debug("fvco range should be 500MHz ~ 1000MHz\n");
  268. dpll_out = dfvco / (1 << scaler);
  269. debug("dpll_out = %lu, dfvco = %lu, scaler = %d\n",
  270. dpll_out, dfvco, scaler);
  271. for (i = 0; i < ARRAY_SIZE(dpll_table); i++) {
  272. if (dpll_out < dpll_table[i] * MHZ) {
  273. freq_band = i;
  274. break;
  275. }
  276. }
  277. debug("freq_band = %d\n", freq_band);
  278. exynos_mipi_dsi_pll_freq(dsim, pre_divider, main_divider, scaler);
  279. exynos_mipi_dsi_hs_zero_ctrl(dsim, 0);
  280. exynos_mipi_dsi_prep_ctrl(dsim, 0);
  281. /* Freq Band */
  282. exynos_mipi_dsi_pll_freq_band(dsim, freq_band);
  283. /* Stable time */
  284. exynos_mipi_dsi_pll_stable_time(dsim,
  285. dsim->dsim_config->pll_stable_time);
  286. /* Enable PLL */
  287. debug("FOUT of mipi dphy pll is %luMHz\n",
  288. (dpll_out / MHZ));
  289. return dpll_out;
  290. }
  291. int exynos_mipi_dsi_set_clock(struct mipi_dsim_device *dsim,
  292. unsigned int byte_clk_sel, unsigned int enable)
  293. {
  294. unsigned int esc_div;
  295. unsigned long esc_clk_error_rate;
  296. unsigned long hs_clk = 0, byte_clk = 0, escape_clk = 0;
  297. if (enable) {
  298. dsim->e_clk_src = byte_clk_sel;
  299. /* Escape mode clock and byte clock source */
  300. exynos_mipi_dsi_set_byte_clock_src(dsim, byte_clk_sel);
  301. /* DPHY, DSIM Link : D-PHY clock out */
  302. if (byte_clk_sel == DSIM_PLL_OUT_DIV8) {
  303. hs_clk = exynos_mipi_dsi_change_pll(dsim,
  304. dsim->dsim_config->p, dsim->dsim_config->m,
  305. dsim->dsim_config->s);
  306. if (hs_clk == 0) {
  307. debug("failed to get hs clock.\n");
  308. return -EINVAL;
  309. }
  310. byte_clk = hs_clk / 8;
  311. exynos_mipi_dsi_enable_pll_bypass(dsim, 0);
  312. exynos_mipi_dsi_pll_on(dsim, 1);
  313. /* DPHY : D-PHY clock out, DSIM link : external clock out */
  314. } else if (byte_clk_sel == DSIM_EXT_CLK_DIV8)
  315. debug("not support EXT CLK source for MIPI DSIM\n");
  316. else if (byte_clk_sel == DSIM_EXT_CLK_BYPASS)
  317. debug("not support EXT CLK source for MIPI DSIM\n");
  318. /* escape clock divider */
  319. esc_div = byte_clk / (dsim->dsim_config->esc_clk);
  320. debug("esc_div = %d, byte_clk = %lu, esc_clk = %lu\n",
  321. esc_div, byte_clk, dsim->dsim_config->esc_clk);
  322. if ((byte_clk / esc_div) >= (20 * MHZ) ||
  323. (byte_clk / esc_div) > dsim->dsim_config->esc_clk)
  324. esc_div += 1;
  325. escape_clk = byte_clk / esc_div;
  326. debug("escape_clk = %lu, byte_clk = %lu, esc_div = %d\n",
  327. escape_clk, byte_clk, esc_div);
  328. /* enable escape clock. */
  329. exynos_mipi_dsi_enable_byte_clock(dsim, 1);
  330. /* enable byte clk and escape clock */
  331. exynos_mipi_dsi_set_esc_clk_prs(dsim, 1, esc_div);
  332. /* escape clock on lane */
  333. exynos_mipi_dsi_enable_esc_clk_on_lane(dsim,
  334. (DSIM_LANE_CLOCK | dsim->data_lane), 1);
  335. debug("byte clock is %luMHz\n",
  336. (byte_clk / MHZ));
  337. debug("escape clock that user's need is %lu\n",
  338. (dsim->dsim_config->esc_clk / MHZ));
  339. debug("escape clock divider is %x\n", esc_div);
  340. debug("escape clock is %luMHz\n",
  341. ((byte_clk / esc_div) / MHZ));
  342. if ((byte_clk / esc_div) > escape_clk) {
  343. esc_clk_error_rate = escape_clk /
  344. (byte_clk / esc_div);
  345. debug("error rate is %lu over.\n",
  346. (esc_clk_error_rate / 100));
  347. } else if ((byte_clk / esc_div) < (escape_clk)) {
  348. esc_clk_error_rate = (byte_clk / esc_div) /
  349. escape_clk;
  350. debug("error rate is %lu under.\n",
  351. (esc_clk_error_rate / 100));
  352. }
  353. } else {
  354. exynos_mipi_dsi_enable_esc_clk_on_lane(dsim,
  355. (DSIM_LANE_CLOCK | dsim->data_lane), 0);
  356. exynos_mipi_dsi_set_esc_clk_prs(dsim, 0, 0);
  357. /* disable escape clock. */
  358. exynos_mipi_dsi_enable_byte_clock(dsim, 0);
  359. if (byte_clk_sel == DSIM_PLL_OUT_DIV8)
  360. exynos_mipi_dsi_pll_on(dsim, 0);
  361. }
  362. return 0;
  363. }
  364. int exynos_mipi_dsi_init_dsim(struct mipi_dsim_device *dsim)
  365. {
  366. dsim->state = DSIM_STATE_INIT;
  367. switch (dsim->dsim_config->e_no_data_lane) {
  368. case DSIM_DATA_LANE_1:
  369. dsim->data_lane = DSIM_LANE_DATA0;
  370. break;
  371. case DSIM_DATA_LANE_2:
  372. dsim->data_lane = DSIM_LANE_DATA0 | DSIM_LANE_DATA1;
  373. break;
  374. case DSIM_DATA_LANE_3:
  375. dsim->data_lane = DSIM_LANE_DATA0 | DSIM_LANE_DATA1 |
  376. DSIM_LANE_DATA2;
  377. break;
  378. case DSIM_DATA_LANE_4:
  379. dsim->data_lane = DSIM_LANE_DATA0 | DSIM_LANE_DATA1 |
  380. DSIM_LANE_DATA2 | DSIM_LANE_DATA3;
  381. break;
  382. default:
  383. debug("data lane is invalid.\n");
  384. return -EINVAL;
  385. };
  386. exynos_mipi_dsi_sw_reset(dsim);
  387. exynos_mipi_dsi_dp_dn_swap(dsim, 0);
  388. return 0;
  389. }
  390. int exynos_mipi_dsi_enable_frame_done_int(struct mipi_dsim_device *dsim,
  391. unsigned int enable)
  392. {
  393. /* enable only frame done interrupt */
  394. exynos_mipi_dsi_set_interrupt_mask(dsim, INTMSK_FRAME_DONE, enable);
  395. return 0;
  396. }
  397. static void convert_to_fb_videomode(struct fb_videomode *mode1,
  398. struct vidinfo *mode2)
  399. {
  400. mode1->xres = mode2->vl_width;
  401. mode1->yres = mode2->vl_height;
  402. mode1->upper_margin = mode2->vl_vfpd;
  403. mode1->lower_margin = mode2->vl_vbpd;
  404. mode1->left_margin = mode2->vl_hfpd;
  405. mode1->right_margin = mode2->vl_hbpd;
  406. mode1->vsync_len = mode2->vl_vspw;
  407. mode1->hsync_len = mode2->vl_hspw;
  408. }
  409. int exynos_mipi_dsi_set_display_mode(struct mipi_dsim_device *dsim,
  410. struct mipi_dsim_config *dsim_config)
  411. {
  412. struct exynos_platform_mipi_dsim *dsim_pd;
  413. struct fb_videomode lcd_video;
  414. struct vidinfo *vid;
  415. dsim_pd = (struct exynos_platform_mipi_dsim *)dsim->pd;
  416. vid = (struct vidinfo *)dsim_pd->lcd_panel_info;
  417. convert_to_fb_videomode(&lcd_video, vid);
  418. /* in case of VIDEO MODE (RGB INTERFACE), it sets polarities. */
  419. if (dsim->dsim_config->e_interface == (u32) DSIM_VIDEO) {
  420. if (dsim->dsim_config->auto_vertical_cnt == 0) {
  421. exynos_mipi_dsi_set_main_disp_vporch(dsim,
  422. vid->vl_cmd_allow_len,
  423. lcd_video.upper_margin,
  424. lcd_video.lower_margin);
  425. exynos_mipi_dsi_set_main_disp_hporch(dsim,
  426. lcd_video.left_margin,
  427. lcd_video.right_margin);
  428. exynos_mipi_dsi_set_main_disp_sync_area(dsim,
  429. lcd_video.vsync_len,
  430. lcd_video.hsync_len);
  431. }
  432. }
  433. exynos_mipi_dsi_set_main_disp_resol(dsim, lcd_video.xres,
  434. lcd_video.yres);
  435. exynos_mipi_dsi_display_config(dsim, dsim->dsim_config);
  436. debug("lcd panel ==> width = %d, height = %d\n",
  437. lcd_video.xres, lcd_video.yres);
  438. return 0;
  439. }
  440. int exynos_mipi_dsi_init_link(struct mipi_dsim_device *dsim)
  441. {
  442. unsigned int time_out = 100;
  443. switch (dsim->state) {
  444. case DSIM_STATE_INIT:
  445. exynos_mipi_dsi_init_fifo_pointer(dsim, 0x1f);
  446. /* dsi configuration */
  447. exynos_mipi_dsi_init_config(dsim);
  448. exynos_mipi_dsi_enable_lane(dsim, DSIM_LANE_CLOCK, 1);
  449. exynos_mipi_dsi_enable_lane(dsim, dsim->data_lane, 1);
  450. /* set clock configuration */
  451. exynos_mipi_dsi_set_clock(dsim,
  452. dsim->dsim_config->e_byte_clk, 1);
  453. /* check clock and data lane state are stop state */
  454. while (!(exynos_mipi_dsi_is_lane_state(dsim))) {
  455. time_out--;
  456. if (time_out == 0) {
  457. debug("DSI Master is not stop state.\n");
  458. debug("Check initialization process\n");
  459. return -EINVAL;
  460. }
  461. }
  462. dsim->state = DSIM_STATE_STOP;
  463. /* BTA sequence counters */
  464. exynos_mipi_dsi_set_stop_state_counter(dsim,
  465. dsim->dsim_config->stop_holding_cnt);
  466. exynos_mipi_dsi_set_bta_timeout(dsim,
  467. dsim->dsim_config->bta_timeout);
  468. exynos_mipi_dsi_set_lpdr_timeout(dsim,
  469. dsim->dsim_config->rx_timeout);
  470. return 0;
  471. default:
  472. debug("DSI Master is already init.\n");
  473. return 0;
  474. }
  475. return 0;
  476. }
  477. int exynos_mipi_dsi_set_hs_enable(struct mipi_dsim_device *dsim)
  478. {
  479. if (dsim->state == DSIM_STATE_STOP) {
  480. if (dsim->e_clk_src != DSIM_EXT_CLK_BYPASS) {
  481. dsim->state = DSIM_STATE_HSCLKEN;
  482. /* set LCDC and CPU transfer mode to HS. */
  483. exynos_mipi_dsi_set_lcdc_transfer_mode(dsim, 0);
  484. exynos_mipi_dsi_set_cpu_transfer_mode(dsim, 0);
  485. exynos_mipi_dsi_enable_hs_clock(dsim, 1);
  486. return 0;
  487. } else
  488. debug("clock source is external bypass.\n");
  489. } else
  490. debug("DSIM is not stop state.\n");
  491. return 0;
  492. }
  493. int exynos_mipi_dsi_set_data_transfer_mode(struct mipi_dsim_device *dsim,
  494. unsigned int mode)
  495. {
  496. if (mode) {
  497. if (dsim->state != DSIM_STATE_HSCLKEN) {
  498. debug("HS Clock lane is not enabled.\n");
  499. return -EINVAL;
  500. }
  501. exynos_mipi_dsi_set_lcdc_transfer_mode(dsim, 0);
  502. } else {
  503. if (dsim->state == DSIM_STATE_INIT || dsim->state ==
  504. DSIM_STATE_ULPS) {
  505. debug("DSI Master is not STOP or HSDT state.\n");
  506. return -EINVAL;
  507. }
  508. exynos_mipi_dsi_set_cpu_transfer_mode(dsim, 0);
  509. }
  510. return 0;
  511. }
  512. int exynos_mipi_dsi_get_frame_done_status(struct mipi_dsim_device *dsim)
  513. {
  514. return _exynos_mipi_dsi_get_frame_done_status(dsim);
  515. }
  516. int exynos_mipi_dsi_clear_frame_done(struct mipi_dsim_device *dsim)
  517. {
  518. _exynos_mipi_dsi_clear_frame_done(dsim);
  519. return 0;
  520. }