1 /* linux/drivers/video/exynos/exynos_mipi_dsi_common.c
3 * Samsung SoC MIPI-DSI common driver.
5 * Copyright (c) 2012 Samsung Electronics Co., Ltd
7 * InKi Dae, <inki.dae@samsung.com>
8 * Donghwa Lee, <dh09.lee@samsung.com>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
15 #include <linux/module.h>
16 #include <linux/kernel.h>
17 #include <linux/errno.h>
18 #include <linux/mutex.h>
19 #include <linux/wait.h>
23 #include <linux/ctype.h>
24 #include <linux/platform_device.h>
26 #include <linux/memory.h>
27 #include <linux/delay.h>
28 #include <linux/irqreturn.h>
29 #include <linux/kthread.h>
31 #include <video/mipi_display.h>
32 #include <video/exynos_mipi_dsim.h>
36 #include "exynos_mipi_dsi_regs.h"
37 #include "exynos_mipi_dsi_lowlevel.h"
38 #include "exynos_mipi_dsi_common.h"
40 #define MIPI_FIFO_TIMEOUT msecs_to_jiffies(250)
41 #define MIPI_RX_FIFO_READ_DONE 0x30800002
42 #define MIPI_MAX_RX_FIFO 20
43 #define MHZ (1000 * 1000)
44 #define FIN_HZ (24 * MHZ)
46 #define DFIN_PLL_MIN_HZ (6 * MHZ)
47 #define DFIN_PLL_MAX_HZ (12 * MHZ)
49 #define DFVCO_MIN_HZ (500 * MHZ)
50 #define DFVCO_MAX_HZ (1000 * MHZ)
52 #define TRY_GET_FIFO_TIMEOUT (5000 * 2)
53 #define TRY_FIFO_CLEAR (10)
55 /* MIPI-DSIM status types. */
57 DSIM_STATE_INIT, /* should be initialized. */
58 DSIM_STATE_STOP, /* CPU and LCDC are LP mode. */
59 DSIM_STATE_HSCLKEN, /* HS clock was enabled. */
63 /* define DSI lane types. */
65 DSIM_LANE_CLOCK = (1 << 0),
66 DSIM_LANE_DATA0 = (1 << 1),
67 DSIM_LANE_DATA1 = (1 << 2),
68 DSIM_LANE_DATA2 = (1 << 3),
69 DSIM_LANE_DATA3 = (1 << 4)
72 static unsigned int dpll_table[15] = {
73 100, 120, 170, 220, 270,
74 320, 390, 450, 510, 560,
75 640, 690, 770, 870, 950
78 irqreturn_t exynos_mipi_dsi_interrupt_handler(int irq, void *dev_id)
80 struct mipi_dsim_device *dsim = dev_id;
81 unsigned int intsrc, intmsk;
83 intsrc = exynos_mipi_dsi_read_interrupt(dsim);
84 intmsk = exynos_mipi_dsi_read_interrupt_mask(dsim);
85 intmsk = ~intmsk & intsrc;
87 if (intsrc & INTMSK_RX_DONE) {
88 complete(&dsim_rd_comp);
89 dev_dbg(dsim->dev, "MIPI INTMSK_RX_DONE\n");
91 if (intsrc & INTMSK_FIFO_EMPTY) {
92 complete(&dsim_wr_comp);
93 dev_dbg(dsim->dev, "MIPI INTMSK_FIFO_EMPTY\n");
96 exynos_mipi_dsi_clear_interrupt(dsim, intmsk);
102 * write long packet to mipi dsi slave
103 * @dsim: mipi dsim device structure.
104 * @data0: packet data to send.
105 * @data1: size of packet data
107 static void exynos_mipi_dsi_long_data_wr(struct mipi_dsim_device *dsim,
108 const unsigned char *data0, unsigned int data_size)
110 unsigned int data_cnt = 0, payload = 0;
112 /* in case that data count is more then 4 */
113 for (data_cnt = 0; data_cnt < data_size; data_cnt += 4) {
115 * after sending 4bytes per one time,
116 * send remainder data less then 4.
118 if ((data_size - data_cnt) < 4) {
119 if ((data_size - data_cnt) == 3) {
120 payload = data0[data_cnt] |
121 data0[data_cnt + 1] << 8 |
122 data0[data_cnt + 2] << 16;
123 dev_dbg(dsim->dev, "count = 3 payload = %x, %x %x %x\n",
124 payload, data0[data_cnt],
126 data0[data_cnt + 2]);
127 } else if ((data_size - data_cnt) == 2) {
128 payload = data0[data_cnt] |
129 data0[data_cnt + 1] << 8;
131 "count = 2 payload = %x, %x %x\n", payload,
133 data0[data_cnt + 1]);
134 } else if ((data_size - data_cnt) == 1) {
135 payload = data0[data_cnt];
138 exynos_mipi_dsi_wr_tx_data(dsim, payload);
139 /* send 4bytes per one time. */
141 payload = data0[data_cnt] |
142 data0[data_cnt + 1] << 8 |
143 data0[data_cnt + 2] << 16 |
144 data0[data_cnt + 3] << 24;
147 "count = 4 payload = %x, %x %x %x %x\n",
148 payload, *(u8 *)(data0 + data_cnt),
151 data0[data_cnt + 3]);
153 exynos_mipi_dsi_wr_tx_data(dsim, payload);
158 int exynos_mipi_dsi_wr_data(struct mipi_dsim_device *dsim, unsigned int data_id,
159 const unsigned char *data0, unsigned int data_size)
161 unsigned int check_rx_ack = 0;
163 if (dsim->state == DSIM_STATE_ULPS) {
164 dev_err(dsim->dev, "state is ULPS.\n");
169 /* FIXME!!! why does it need this delay? */
172 mutex_lock(&dsim->lock);
175 /* short packet types of packet types for command. */
176 case MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM:
177 case MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM:
178 case MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM:
179 case MIPI_DSI_DCS_SHORT_WRITE:
180 case MIPI_DSI_DCS_SHORT_WRITE_PARAM:
181 case MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE:
182 exynos_mipi_dsi_wr_tx_header(dsim, data_id, data0[0], data0[1]);
184 /* process response func should be implemented */
185 mutex_unlock(&dsim->lock);
188 mutex_unlock(&dsim->lock);
192 /* general command */
193 case MIPI_DSI_COLOR_MODE_OFF:
194 case MIPI_DSI_COLOR_MODE_ON:
195 case MIPI_DSI_SHUTDOWN_PERIPHERAL:
196 case MIPI_DSI_TURN_ON_PERIPHERAL:
197 exynos_mipi_dsi_wr_tx_header(dsim, data_id, data0[0], data0[1]);
199 /* process response func should be implemented. */
200 mutex_unlock(&dsim->lock);
203 mutex_unlock(&dsim->lock);
207 /* packet types for video data */
208 case MIPI_DSI_V_SYNC_START:
209 case MIPI_DSI_V_SYNC_END:
210 case MIPI_DSI_H_SYNC_START:
211 case MIPI_DSI_H_SYNC_END:
212 case MIPI_DSI_END_OF_TRANSMISSION:
213 mutex_unlock(&dsim->lock);
216 /* long packet type and null packet */
217 case MIPI_DSI_NULL_PACKET:
218 case MIPI_DSI_BLANKING_PACKET:
219 mutex_unlock(&dsim->lock);
221 case MIPI_DSI_GENERIC_LONG_WRITE:
222 case MIPI_DSI_DCS_LONG_WRITE:
224 unsigned int size, payload = 0;
225 INIT_COMPLETION(dsim_wr_comp);
227 size = data_size * 4;
229 /* if data count is less then 4, then send 3bytes data. */
235 exynos_mipi_dsi_wr_tx_data(dsim, payload);
237 dev_dbg(dsim->dev, "count = %d payload = %x,%x %x %x\n",
238 data_size, payload, data0[0],
241 /* in case that data count is more then 4 */
243 exynos_mipi_dsi_long_data_wr(dsim, data0, data_size);
245 /* put data into header fifo */
246 exynos_mipi_dsi_wr_tx_header(dsim, data_id, data_size & 0xff,
247 (data_size & 0xff00) >> 8);
249 if (!wait_for_completion_interruptible_timeout(&dsim_wr_comp,
250 MIPI_FIFO_TIMEOUT)) {
251 dev_warn(dsim->dev, "command write timeout.\n");
252 mutex_unlock(&dsim->lock);
257 /* process response func should be implemented. */
258 mutex_unlock(&dsim->lock);
261 mutex_unlock(&dsim->lock);
266 /* packet typo for video data */
267 case MIPI_DSI_PACKED_PIXEL_STREAM_16:
268 case MIPI_DSI_PACKED_PIXEL_STREAM_18:
269 case MIPI_DSI_PIXEL_STREAM_3BYTE_18:
270 case MIPI_DSI_PACKED_PIXEL_STREAM_24:
272 /* process response func should be implemented. */
273 mutex_unlock(&dsim->lock);
276 mutex_unlock(&dsim->lock);
281 "data id %x is not supported current DSI spec.\n",
284 mutex_unlock(&dsim->lock);
289 static unsigned int exynos_mipi_dsi_long_data_rd(struct mipi_dsim_device *dsim,
290 unsigned int req_size, unsigned int rx_data, u8 *rx_buf)
292 unsigned int rcv_pkt, i, j;
295 /* for long packet */
296 rxsize = (u16)((rx_data & 0x00ffff00) >> 8);
297 dev_dbg(dsim->dev, "mipi dsi rx size : %d\n", rxsize);
298 if (rxsize != req_size) {
300 "received size mismatch received: %d, requested: %d\n",
305 for (i = 0; i < (rxsize >> 2); i++) {
306 rcv_pkt = exynos_mipi_dsi_rd_rx_fifo(dsim);
307 dev_dbg(dsim->dev, "received pkt : %08x\n", rcv_pkt);
308 for (j = 0; j < 4; j++) {
309 rx_buf[(i * 4) + j] =
310 (u8)(rcv_pkt >> (j * 8)) & 0xff;
311 dev_dbg(dsim->dev, "received value : %02x\n",
312 (rcv_pkt >> (j * 8)) & 0xff);
316 rcv_pkt = exynos_mipi_dsi_rd_rx_fifo(dsim);
317 dev_dbg(dsim->dev, "received pkt : %08x\n", rcv_pkt);
318 for (j = 0; j < (rxsize % 4); j++) {
319 rx_buf[(i * 4) + j] =
320 (u8)(rcv_pkt >> (j * 8)) & 0xff;
321 dev_dbg(dsim->dev, "received value : %02x\n",
322 (rcv_pkt >> (j * 8)) & 0xff);
332 static unsigned int exynos_mipi_dsi_response_size(unsigned int req_size)
336 return MIPI_DSI_RX_GENERIC_SHORT_READ_RESPONSE_1BYTE;
338 return MIPI_DSI_RX_GENERIC_SHORT_READ_RESPONSE_2BYTE;
340 return MIPI_DSI_RX_GENERIC_LONG_READ_RESPONSE;
344 int exynos_mipi_dsi_rd_data(struct mipi_dsim_device *dsim, unsigned int data_id,
345 unsigned int data0, unsigned int req_size, u8 *rx_buf)
347 unsigned int rx_data, rcv_pkt, i;
351 if (dsim->state == DSIM_STATE_ULPS) {
352 dev_err(dsim->dev, "state is ULPS.\n");
360 mutex_lock(&dsim->lock);
361 INIT_COMPLETION(dsim_rd_comp);
362 exynos_mipi_dsi_rd_tx_header(dsim,
363 MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE, req_size);
365 response = exynos_mipi_dsi_response_size(req_size);
368 case MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM:
369 case MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM:
370 case MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM:
371 case MIPI_DSI_DCS_READ:
372 exynos_mipi_dsi_rd_tx_header(dsim,
374 /* process response func should be implemented. */
378 "data id %x is not supported current DSI spec.\n",
384 if (!wait_for_completion_interruptible_timeout(&dsim_rd_comp,
385 MIPI_FIFO_TIMEOUT)) {
386 pr_err("RX done interrupt timeout\n");
387 mutex_unlock(&dsim->lock);
393 rx_data = exynos_mipi_dsi_rd_rx_fifo(dsim);
395 if ((u8)(rx_data & 0xff) != response) {
397 "mipi dsi wrong response rx_data : %x, response:%x\n",
403 /* for short packet */
404 for (i = 0; i < req_size; i++)
405 rx_buf[i] = (rx_data >> (8 + (i * 8))) & 0xff;
408 /* for long packet */
409 rxsize = exynos_mipi_dsi_long_data_rd(dsim, req_size, rx_data,
411 if (rxsize != req_size)
415 rcv_pkt = exynos_mipi_dsi_rd_rx_fifo(dsim);
419 if (rcv_pkt != MIPI_RX_FIFO_READ_DONE) {
421 "Can't found RX FIFO READ DONE FLAG : %x\n", rcv_pkt);
425 mutex_unlock(&dsim->lock);
432 rcv_pkt = exynos_mipi_dsi_rd_rx_fifo(dsim);
433 if ((rcv_pkt == MIPI_RX_FIFO_READ_DONE)
434 || (i > MIPI_MAX_RX_FIFO))
437 "mipi dsi clear rx fifo : %08x\n", rcv_pkt);
441 "mipi dsi rx done count : %d, rcv_pkt : %08x\n", i, rcv_pkt);
443 mutex_unlock(&dsim->lock);
448 static int exynos_mipi_dsi_pll_on(struct mipi_dsim_device *dsim,
456 exynos_mipi_dsi_enable_pll(dsim, 1);
459 if (exynos_mipi_dsi_is_pll_stable(dsim))
465 exynos_mipi_dsi_enable_pll(dsim, 0);
470 static unsigned long exynos_mipi_dsi_change_pll(struct mipi_dsim_device *dsim,
471 unsigned int pre_divider, unsigned int main_divider,
474 unsigned long dfin_pll, dfvco, dpll_out;
475 unsigned int i, freq_band = 0xf;
477 dfin_pll = (FIN_HZ / pre_divider);
479 /******************************************************
480 * Serial Clock(=ByteClk X 8) FreqBand[3:0] *
481 ******************************************************
483 * 100 ~ 119.99 MHz 0001
484 * 120 ~ 159.99 MHz 0010
485 * 160 ~ 199.99 MHz 0011
486 * 200 ~ 239.99 MHz 0100
487 * 140 ~ 319.99 MHz 0101
488 * 320 ~ 389.99 MHz 0110
489 * 390 ~ 449.99 MHz 0111
490 * 450 ~ 509.99 MHz 1000
491 * 510 ~ 559.99 MHz 1001
492 * 560 ~ 639.99 MHz 1010
493 * 640 ~ 689.99 MHz 1011
494 * 690 ~ 769.99 MHz 1100
495 * 770 ~ 869.99 MHz 1101
496 * 870 ~ 949.99 MHz 1110
497 * 950 ~ 1000 MHz 1111
498 ******************************************************/
499 if (dfin_pll < DFIN_PLL_MIN_HZ || dfin_pll > DFIN_PLL_MAX_HZ) {
500 dev_warn(dsim->dev, "fin_pll range should be 6MHz ~ 12MHz\n");
501 exynos_mipi_dsi_enable_afc(dsim, 0, 0);
503 if (dfin_pll < 7 * MHZ)
504 exynos_mipi_dsi_enable_afc(dsim, 1, 0x1);
505 else if (dfin_pll < 8 * MHZ)
506 exynos_mipi_dsi_enable_afc(dsim, 1, 0x0);
507 else if (dfin_pll < 9 * MHZ)
508 exynos_mipi_dsi_enable_afc(dsim, 1, 0x3);
509 else if (dfin_pll < 10 * MHZ)
510 exynos_mipi_dsi_enable_afc(dsim, 1, 0x2);
511 else if (dfin_pll < 11 * MHZ)
512 exynos_mipi_dsi_enable_afc(dsim, 1, 0x5);
514 exynos_mipi_dsi_enable_afc(dsim, 1, 0x4);
517 dfvco = dfin_pll * main_divider;
518 dev_dbg(dsim->dev, "dfvco = %lu, dfin_pll = %lu, main_divider = %d\n",
519 dfvco, dfin_pll, main_divider);
520 if (dfvco < DFVCO_MIN_HZ || dfvco > DFVCO_MAX_HZ)
521 dev_warn(dsim->dev, "fvco range should be 500MHz ~ 1000MHz\n");
523 dpll_out = dfvco / (1 << scaler);
524 dev_dbg(dsim->dev, "dpll_out = %lu, dfvco = %lu, scaler = %d\n",
525 dpll_out, dfvco, scaler);
527 for (i = 0; i < ARRAY_SIZE(dpll_table); i++) {
528 if (dpll_out < dpll_table[i] * MHZ) {
534 dev_dbg(dsim->dev, "freq_band = %d\n", freq_band);
536 exynos_mipi_dsi_pll_freq(dsim, pre_divider, main_divider, scaler);
538 exynos_mipi_dsi_hs_zero_ctrl(dsim, 0);
539 exynos_mipi_dsi_prep_ctrl(dsim, 0);
542 exynos_mipi_dsi_pll_freq_band(dsim, freq_band);
545 exynos_mipi_dsi_pll_stable_time(dsim, dsim->dsim_config->pll_stable_time);
548 dev_dbg(dsim->dev, "FOUT of mipi dphy pll is %luMHz\n",
554 static int exynos_mipi_dsi_set_clock(struct mipi_dsim_device *dsim,
555 unsigned int byte_clk_sel, unsigned int enable)
557 unsigned int esc_div;
558 unsigned long esc_clk_error_rate;
559 unsigned long hs_clk = 0, byte_clk = 0, escape_clk = 0;
562 dsim->e_clk_src = byte_clk_sel;
564 /* Escape mode clock and byte clock source */
565 exynos_mipi_dsi_set_byte_clock_src(dsim, byte_clk_sel);
567 /* DPHY, DSIM Link : D-PHY clock out */
568 if (byte_clk_sel == DSIM_PLL_OUT_DIV8) {
569 hs_clk = exynos_mipi_dsi_change_pll(dsim,
570 dsim->dsim_config->p, dsim->dsim_config->m,
571 dsim->dsim_config->s);
574 "failed to get hs clock.\n");
578 byte_clk = hs_clk / 8;
579 exynos_mipi_dsi_enable_pll_bypass(dsim, 0);
580 exynos_mipi_dsi_pll_on(dsim, 1);
581 /* DPHY : D-PHY clock out, DSIM link : external clock out */
582 } else if (byte_clk_sel == DSIM_EXT_CLK_DIV8) {
583 dev_warn(dsim->dev, "this project is not support\n");
585 "external clock source for MIPI DSIM.\n");
586 } else if (byte_clk_sel == DSIM_EXT_CLK_BYPASS) {
587 dev_warn(dsim->dev, "this project is not support\n");
589 "external clock source for MIPI DSIM\n");
592 /* escape clock divider */
593 esc_div = byte_clk / (dsim->dsim_config->esc_clk);
595 "esc_div = %d, byte_clk = %lu, esc_clk = %lu\n",
596 esc_div, byte_clk, dsim->dsim_config->esc_clk);
597 if ((byte_clk / esc_div) >= (20 * MHZ) ||
598 (byte_clk / esc_div) >
599 dsim->dsim_config->esc_clk)
602 escape_clk = byte_clk / esc_div;
604 "escape_clk = %lu, byte_clk = %lu, esc_div = %d\n",
605 escape_clk, byte_clk, esc_div);
607 /* enable escape clock. */
608 exynos_mipi_dsi_enable_byte_clock(dsim, 1);
610 /* enable byte clk and escape clock */
611 exynos_mipi_dsi_set_esc_clk_prs(dsim, 1, esc_div);
612 /* escape clock on lane */
613 exynos_mipi_dsi_enable_esc_clk_on_lane(dsim,
614 (DSIM_LANE_CLOCK | dsim->data_lane), 1);
616 dev_dbg(dsim->dev, "byte clock is %luMHz\n",
618 dev_dbg(dsim->dev, "escape clock that user's need is %lu\n",
619 (dsim->dsim_config->esc_clk / MHZ));
620 dev_dbg(dsim->dev, "escape clock divider is %x\n", esc_div);
621 dev_dbg(dsim->dev, "escape clock is %luMHz\n",
622 ((byte_clk / esc_div) / MHZ));
624 if ((byte_clk / esc_div) > escape_clk) {
625 esc_clk_error_rate = escape_clk /
626 (byte_clk / esc_div);
627 dev_warn(dsim->dev, "error rate is %lu over.\n",
628 (esc_clk_error_rate / 100));
629 } else if ((byte_clk / esc_div) < (escape_clk)) {
630 esc_clk_error_rate = (byte_clk / esc_div) /
632 dev_warn(dsim->dev, "error rate is %lu under.\n",
633 (esc_clk_error_rate / 100));
636 exynos_mipi_dsi_enable_esc_clk_on_lane(dsim,
637 (DSIM_LANE_CLOCK | dsim->data_lane), 0);
638 exynos_mipi_dsi_set_esc_clk_prs(dsim, 0, 0);
640 /* disable escape clock. */
641 exynos_mipi_dsi_enable_byte_clock(dsim, 0);
643 if (byte_clk_sel == DSIM_PLL_OUT_DIV8)
644 exynos_mipi_dsi_pll_on(dsim, 0);
650 int exynos_mipi_dsi_init_dsim(struct mipi_dsim_device *dsim)
652 dsim->state = DSIM_STATE_INIT;
654 switch (dsim->dsim_config->e_no_data_lane) {
655 case DSIM_DATA_LANE_1:
656 dsim->data_lane = DSIM_LANE_DATA0;
658 case DSIM_DATA_LANE_2:
659 dsim->data_lane = DSIM_LANE_DATA0 | DSIM_LANE_DATA1;
661 case DSIM_DATA_LANE_3:
662 dsim->data_lane = DSIM_LANE_DATA0 | DSIM_LANE_DATA1 |
665 case DSIM_DATA_LANE_4:
666 dsim->data_lane = DSIM_LANE_DATA0 | DSIM_LANE_DATA1 |
667 DSIM_LANE_DATA2 | DSIM_LANE_DATA3;
670 dev_info(dsim->dev, "data lane is invalid.\n");
674 exynos_mipi_dsi_sw_reset(dsim);
675 exynos_mipi_dsi_func_reset(dsim);
677 exynos_mipi_dsi_dp_dn_swap(dsim, 0);
682 void exynos_mipi_dsi_init_interrupt(struct mipi_dsim_device *dsim)
684 unsigned int src = 0;
686 src = (INTSRC_SFR_FIFO_EMPTY | INTSRC_RX_DATA_DONE);
687 exynos_mipi_dsi_set_interrupt(dsim, src, 1);
690 src = ~(INTMSK_RX_DONE | INTMSK_FIFO_EMPTY);
691 exynos_mipi_dsi_set_interrupt_mask(dsim, src, 1);
694 int exynos_mipi_dsi_enable_frame_done_int(struct mipi_dsim_device *dsim,
697 /* enable only frame done interrupt */
698 exynos_mipi_dsi_set_interrupt_mask(dsim, INTMSK_FRAME_DONE, enable);
703 void exynos_mipi_dsi_stand_by(struct mipi_dsim_device *dsim,
707 /* consider Main display and Sub display. */
709 exynos_mipi_dsi_set_main_stand_by(dsim, enable);
712 int exynos_mipi_dsi_set_display_mode(struct mipi_dsim_device *dsim,
713 struct mipi_dsim_config *dsim_config)
715 struct mipi_dsim_platform_data *dsim_pd;
716 struct fb_videomode *timing;
718 dsim_pd = (struct mipi_dsim_platform_data *)dsim->pd;
719 timing = (struct fb_videomode *)dsim_pd->lcd_panel_info;
721 /* in case of VIDEO MODE (RGB INTERFACE), it sets polarities. */
722 if (dsim_config->e_interface == (u32) DSIM_VIDEO) {
723 if (dsim_config->auto_vertical_cnt == 0) {
724 exynos_mipi_dsi_set_main_disp_vporch(dsim,
725 dsim_config->cmd_allow,
726 timing->lower_margin,
727 timing->upper_margin);
728 exynos_mipi_dsi_set_main_disp_hporch(dsim,
729 timing->right_margin,
730 timing->left_margin);
731 exynos_mipi_dsi_set_main_disp_sync_area(dsim,
737 exynos_mipi_dsi_set_main_disp_resol(dsim, timing->xres,
740 exynos_mipi_dsi_display_config(dsim, dsim_config);
742 dev_info(dsim->dev, "lcd panel ==> width = %d, height = %d\n",
743 timing->xres, timing->yres);
748 int exynos_mipi_dsi_init_link(struct mipi_dsim_device *dsim)
750 unsigned int time_out = 100;
752 switch (dsim->state) {
753 case DSIM_STATE_INIT:
754 exynos_mipi_dsi_init_fifo_pointer(dsim, 0x1f);
756 /* dsi configuration */
757 exynos_mipi_dsi_init_config(dsim);
758 exynos_mipi_dsi_enable_lane(dsim, DSIM_LANE_CLOCK, 1);
759 exynos_mipi_dsi_enable_lane(dsim, dsim->data_lane, 1);
761 /* set clock configuration */
762 exynos_mipi_dsi_set_clock(dsim, dsim->dsim_config->e_byte_clk, 1);
764 /* check clock and data lane state are stop state */
765 while (!(exynos_mipi_dsi_is_lane_state(dsim))) {
769 "DSI Master is not stop state.\n");
771 "Check initialization process\n");
778 "DSI Master driver has been completed.\n");
779 dev_info(dsim->dev, "DSI Master state is stop state\n");
782 dsim->state = DSIM_STATE_STOP;
784 /* BTA sequence counters */
785 exynos_mipi_dsi_set_stop_state_counter(dsim,
786 dsim->dsim_config->stop_holding_cnt);
787 exynos_mipi_dsi_set_bta_timeout(dsim,
788 dsim->dsim_config->bta_timeout);
789 exynos_mipi_dsi_set_lpdr_timeout(dsim,
790 dsim->dsim_config->rx_timeout);
794 dev_info(dsim->dev, "DSI Master is already init.\n");
801 int exynos_mipi_dsi_set_hs_enable(struct mipi_dsim_device *dsim)
803 if (dsim->state != DSIM_STATE_STOP) {
804 dev_warn(dsim->dev, "DSIM is not in stop state.\n");
808 if (dsim->e_clk_src == DSIM_EXT_CLK_BYPASS) {
809 dev_warn(dsim->dev, "clock source is external bypass.\n");
813 dsim->state = DSIM_STATE_HSCLKEN;
815 /* set LCDC and CPU transfer mode to HS. */
816 exynos_mipi_dsi_set_lcdc_transfer_mode(dsim, 0);
817 exynos_mipi_dsi_set_cpu_transfer_mode(dsim, 0);
818 exynos_mipi_dsi_enable_hs_clock(dsim, 1);
823 int exynos_mipi_dsi_set_data_transfer_mode(struct mipi_dsim_device *dsim,
827 if (dsim->state != DSIM_STATE_HSCLKEN) {
828 dev_err(dsim->dev, "HS Clock lane is not enabled.\n");
832 exynos_mipi_dsi_set_lcdc_transfer_mode(dsim, 0);
834 if (dsim->state == DSIM_STATE_INIT || dsim->state ==
837 "DSI Master is not STOP or HSDT state.\n");
841 exynos_mipi_dsi_set_cpu_transfer_mode(dsim, 0);
847 int exynos_mipi_dsi_get_frame_done_status(struct mipi_dsim_device *dsim)
849 return _exynos_mipi_dsi_get_frame_done_status(dsim);
852 int exynos_mipi_dsi_clear_frame_done(struct mipi_dsim_device *dsim)
854 _exynos_mipi_dsi_clear_frame_done(dsim);
859 int exynos_mipi_dsi_fifo_clear(struct mipi_dsim_device *dsim,
862 int try = TRY_FIFO_CLEAR;
864 exynos_mipi_dsi_sw_reset_release(dsim);
865 exynos_mipi_dsi_func_reset(dsim);
868 if (exynos_mipi_dsi_get_sw_reset_release(dsim)) {
869 exynos_mipi_dsi_init_interrupt(dsim);
870 dev_dbg(dsim->dev, "reset release done.\n");
875 dev_err(dsim->dev, "failed to clear dsim fifo.\n");
879 MODULE_AUTHOR("InKi Dae <inki.dae@samsung.com>");
880 MODULE_DESCRIPTION("Samusung SoC MIPI-DSI common driver");
881 MODULE_LICENSE("GPL");