blob: 2a29a7fc1ef3897fe8d56324f2fe60982b16d65c [file] [log] [blame]
Dhaval Patel5b22fe72014-01-02 16:28:38 -08001/* Copyright (c) 2010-2014, The Linux Foundation. All rights reserved.
Chandan Uddaraju78ae6752010-10-19 12:57:10 -07002 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are
5 * met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above
9 * copyright notice, this list of conditions and the following
10 * disclaimer in the documentation and/or other materials provided
11 * with the distribution.
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -080012 * * Neither the name of The Linux Foundation nor the names of its
Chandan Uddaraju78ae6752010-10-19 12:57:10 -070013 * contributors may be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 */
29
30#include <reg.h>
Shashank Mittalcbd271d2011-01-14 15:18:33 -080031#include <endian.h>
Chandan Uddaraju78ae6752010-10-19 12:57:10 -070032#include <mipi_dsi.h>
33#include <dev/fbcon.h>
Greg Griscod6250552011-06-29 14:40:23 -070034#include <stdlib.h>
Greg Grisco1073a5e2011-07-28 18:59:18 -070035#include <string.h>
Kinson Chike5c93432011-06-17 09:10:29 -070036#include <debug.h>
Kinson Chikfe931032011-07-21 10:01:34 -070037#include <target/display.h>
38#include <platform/iomap.h>
39#include <platform/clock.h>
Greg Grisco1073a5e2011-07-28 18:59:18 -070040#include <platform/timer.h>
Shashank Mittal4bfb2e32012-04-16 10:56:27 -070041#include <err.h>
42#include <msm_panel.h>
Kinson Chikfe931032011-07-21 10:01:34 -070043
44extern void mdp_disable(void);
Ajay Dudanib01e5062011-12-03 23:23:42 -080045extern int mipi_dsi_cmd_config(struct fbcon_config mipi_fb_cfg,
46 unsigned short num_of_lanes);
Kinson Chikfe931032011-07-21 10:01:34 -070047extern void mdp_shutdown(void);
48extern void mdp_start_dma(void);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -070049
Siddhartha Agrawal1b2ed842013-05-29 18:02:28 -070050#if (DISPLAY_TYPE_MDSS == 0)
51#define MIPI_DSI0_BASE MIPI_DSI_BASE
52#define MIPI_DSI1_BASE MIPI_DSI_BASE
53#endif
54
Chandan Uddarajufe93e822010-11-21 20:44:47 -080055static struct fbcon_config mipi_fb_cfg = {
Ajay Dudanib01e5062011-12-03 23:23:42 -080056 .height = 0,
57 .width = 0,
58 .stride = 0,
59 .format = 0,
60 .bpp = 0,
61 .update_start = NULL,
62 .update_done = NULL,
Chandan Uddarajufe93e822010-11-21 20:44:47 -080063};
Chandan Uddarajufe93e822010-11-21 20:44:47 -080064
65static int cmd_mode_status = 0;
Greg Griscod6250552011-06-29 14:40:23 -070066void secure_writel(uint32_t, uint32_t);
67uint32_t secure_readl(uint32_t);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -070068
Shivaraj Shetty64604032013-11-14 16:44:10 +053069static uint32_t response_value = 0;
70
71uint32_t mdss_dsi_read_panel_signature(uint32_t panel_signature)
72{
73 uint32_t rec_buf[1];
74 uint32_t *lp = rec_buf, data;
75 int ret = response_value;
76
77#if (DISPLAY_TYPE_MDSS == 1)
78 if (ret && ret != panel_signature)
79 goto exit_read_signature;
80
81 ret = mipi_dsi_cmds_tx(&read_ddb_start_cmd, 1);
82 if (ret)
83 goto exit_read_signature;
84 if (!mdss_dsi_cmds_rx(&lp, 1, 1))
85 goto exit_read_signature;
86
87 data = ntohl(*lp);
88 data = data >> 8;
89 response_value = data;
90 if (response_value != panel_signature)
91 ret = response_value;
92
93exit_read_signature:
94 /* Keep the non detectable panel at the end and set panel signature 0xFFFF */
95 if (panel_signature == 0xFFFF)
96 ret = 0;
97#endif
98 return ret;
99}
100
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700101int mdss_dual_dsi_cmd_dma_trigger_for_panel()
102{
103 uint32_t ReadValue;
104 uint32_t count = 0;
105 int status = 0;
106
Terence Hampsoncc3345c2013-06-27 15:30:10 -0400107#if (DISPLAY_TYPE_MDSS == 1)
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700108 writel(0x03030303, MIPI_DSI0_BASE + INT_CTRL);
109 writel(0x1, MIPI_DSI0_BASE + CMD_MODE_DMA_SW_TRIGGER);
110 dsb();
111
112 writel(0x03030303, MIPI_DSI1_BASE + INT_CTRL);
113 writel(0x1, MIPI_DSI1_BASE + CMD_MODE_DMA_SW_TRIGGER);
114 dsb();
115
116 ReadValue = readl(MIPI_DSI1_BASE + INT_CTRL) & 0x00000001;
117 while (ReadValue != 0x00000001) {
118 ReadValue = readl(MIPI_DSI1_BASE + INT_CTRL) & 0x00000001;
119 count++;
120 if (count > 0xffff) {
121 status = FAIL;
122 dprintf(CRITICAL,
123 "Panel CMD: command mode dma test failed\n");
124 return status;
125 }
126 }
127
128 writel((readl(MIPI_DSI1_BASE + INT_CTRL) | 0x01000001),
129 MIPI_DSI1_BASE + INT_CTRL);
130 dprintf(SPEW, "Panel CMD: command mode dma tested successfully\n");
Terence Hampsoncc3345c2013-06-27 15:30:10 -0400131#endif
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700132 return status;
133}
134
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700135int dsi_cmd_dma_trigger_for_panel()
136{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800137 unsigned long ReadValue;
138 unsigned long count = 0;
139 int status = 0;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700140
Ajay Dudanib01e5062011-12-03 23:23:42 -0800141 writel(0x03030303, DSI_INT_CTRL);
142 writel(0x1, DSI_CMD_MODE_DMA_SW_TRIGGER);
143 dsb();
144 ReadValue = readl(DSI_INT_CTRL) & 0x00000001;
145 while (ReadValue != 0x00000001) {
146 ReadValue = readl(DSI_INT_CTRL) & 0x00000001;
147 count++;
148 if (count > 0xffff) {
149 status = FAIL;
150 dprintf(CRITICAL,
151 "Panel CMD: command mode dma test failed\n");
152 return status;
153 }
154 }
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700155
Ajay Dudanib01e5062011-12-03 23:23:42 -0800156 writel((readl(DSI_INT_CTRL) | 0x01000001), DSI_INT_CTRL);
157 dprintf(SPEW, "Panel CMD: command mode dma tested successfully\n");
158 return status;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700159}
160
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700161int mdss_dual_dsi_cmds_tx(struct mipi_dsi_cmd *cmds, int count)
162{
163 int ret = 0;
164 struct mipi_dsi_cmd *cm;
165 int i = 0;
166 char pload[256];
167 uint32_t off;
168
Terence Hampsoncc3345c2013-06-27 15:30:10 -0400169#if (DISPLAY_TYPE_MDSS == 1)
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700170 /* Align pload at 8 byte boundry */
171 off = pload;
172 off &= 0x07;
173 if (off)
174 off = 8 - off;
175 off += pload;
176
177 cm = cmds;
178 for (i = 0; i < count; i++) {
179 memcpy((void *)off, (cm->payload), cm->size);
180 writel(off, MIPI_DSI0_BASE + DMA_CMD_OFFSET);
181 writel(cm->size, MIPI_DSI0_BASE + DMA_CMD_LENGTH); // reg 0x48 for this build
182 writel(off, MIPI_DSI1_BASE + DMA_CMD_OFFSET);
183 writel(cm->size, MIPI_DSI1_BASE + DMA_CMD_LENGTH); // reg 0x48 for this build
184 dsb();
185 ret += mdss_dual_dsi_cmd_dma_trigger_for_panel();
Dhaval Patel607a6242013-10-29 12:37:24 -0700186 if (cm->wait)
187 mdelay(cm->wait);
188 else
189 udelay(80);
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700190 cm++;
191 }
Terence Hampsoncc3345c2013-06-27 15:30:10 -0400192#endif
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700193 return ret;
194}
195
Casey Piper84036752013-09-05 14:56:37 -0700196int mdss_dsi_cmds_rx(uint32_t **rp, int rp_len, int rdbk_len)
197{
198 uint32_t *lp, data;
199 char *dp;
200 int i, off;
201 int rlen, res;
202
203 if (rdbk_len > rp_len) {
204 return 0;
205 }
206
207 if (rdbk_len <= 2)
208 rlen = 4; /* short read */
209 else
210 rlen = MIPI_DSI_MRPS + 6; /* 4 bytes header + 2 bytes crc */
211
212 if (rlen > MIPI_DSI_REG_LEN) {
213 return 0;
214 }
215
216 res = rlen & 0x03;
217
218 rlen += res; /* 4 byte align */
219 lp = *rp;
220
221 rlen += 3;
222 rlen >>= 2;
223
224 if (rlen > 4)
225 rlen = 4; /* 4 x 32 bits registers only */
226
Shivaraj Shetty3c77da62013-12-09 15:58:16 +0530227 off = RDBK_DATA0;
Casey Piper84036752013-09-05 14:56:37 -0700228 off += ((rlen - 1) * 4);
229
230 for (i = 0; i < rlen; i++) {
231 data = readl(MIPI_DSI_BASE + off);
232 *lp = ntohl(data); /* to network byte order */
233 lp++;
234
235 off -= 4;
236 }
237
238 if (rdbk_len > 2) {
239 /*First 4 bytes + paded bytes will be header next len bytes would be payload */
240 for (i = 0; i < rdbk_len; i++) {
241 dp = *rp;
242 dp[i] = dp[(res + i) >> 2];
243 }
244 }
245 return rdbk_len;
246}
247
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800248int mipi_dsi_cmds_tx(struct mipi_dsi_cmd *cmds, int count)
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700249{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800250 int ret = 0;
251 struct mipi_dsi_cmd *cm;
252 int i = 0;
253 char pload[256];
254 uint32_t off;
Deepa Dinamania080a402011-11-05 18:59:26 -0700255
Ajay Dudanib01e5062011-12-03 23:23:42 -0800256 /* Align pload at 8 byte boundry */
257 off = pload;
258 off &= 0x07;
259 if (off)
260 off = 8 - off;
261 off += pload;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700262
Ajay Dudanib01e5062011-12-03 23:23:42 -0800263 cm = cmds;
264 for (i = 0; i < count; i++) {
265 memcpy((void *)off, (cm->payload), cm->size);
266 writel(off, DSI_DMA_CMD_OFFSET);
267 writel(cm->size, DSI_DMA_CMD_LENGTH); // reg 0x48 for this build
268 dsb();
269 ret += dsi_cmd_dma_trigger_for_panel();
Sangani Suryanarayana Raju769f9ac2013-04-30 19:05:06 +0530270 dsb();
271 if (cm->wait)
272 mdelay(cm->wait);
273 else
274 udelay(80);
Ajay Dudanib01e5062011-12-03 23:23:42 -0800275 cm++;
276 }
277 return ret;
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800278}
279
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800280/*
281 * mipi_dsi_cmd_rx: can receive at most 16 bytes
282 * per transaction since it only have 4 32bits reigsters
283 * to hold data.
284 * therefore Maximum Return Packet Size need to be set to 16.
285 * any return data more than MRPS need to be break down
286 * to multiple transactions.
287 */
288int mipi_dsi_cmds_rx(char **rp, int len)
289{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800290 uint32_t *lp, data;
291 char *dp;
292 int i, off, cnt;
293 int rlen, res;
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800294
Ajay Dudanib01e5062011-12-03 23:23:42 -0800295 if (len <= 2)
296 rlen = 4; /* short read */
297 else
298 rlen = MIPI_DSI_MRPS + 6; /* 4 bytes header + 2 bytes crc */
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800299
Ajay Dudanib01e5062011-12-03 23:23:42 -0800300 if (rlen > MIPI_DSI_REG_LEN) {
301 return 0;
302 }
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800303
Ajay Dudanib01e5062011-12-03 23:23:42 -0800304 res = rlen & 0x03;
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800305
Ajay Dudanib01e5062011-12-03 23:23:42 -0800306 rlen += res; /* 4 byte align */
307 lp = (uint32_t *) (*rp);
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800308
Ajay Dudanib01e5062011-12-03 23:23:42 -0800309 cnt = rlen;
310 cnt += 3;
311 cnt >>= 2;
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800312
Ajay Dudanib01e5062011-12-03 23:23:42 -0800313 if (cnt > 4)
314 cnt = 4; /* 4 x 32 bits registers only */
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800315
Ajay Dudanib01e5062011-12-03 23:23:42 -0800316 off = 0x068; /* DSI_RDBK_DATA0 */
317 off += ((cnt - 1) * 4);
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800318
Ajay Dudanib01e5062011-12-03 23:23:42 -0800319 for (i = 0; i < cnt; i++) {
320 data = (uint32_t) readl(MIPI_DSI_BASE + off);
321 *lp++ = ntohl(data); /* to network byte order */
322 off -= 4;
323 }
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800324
Ajay Dudanib01e5062011-12-03 23:23:42 -0800325 if (len > 2) {
326 /*First 4 bytes + paded bytes will be header next len bytes would be payload */
327 for (i = 0; i < len; i++) {
328 dp = *rp;
329 dp[i] = dp[4 + res + i];
330 }
331 }
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800332
Ajay Dudanib01e5062011-12-03 23:23:42 -0800333 return len;
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800334}
335
336static int mipi_dsi_cmd_bta_sw_trigger(void)
337{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800338 uint32_t data;
339 int cnt = 0;
340 int err = 0;
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800341
Ajay Dudanib01e5062011-12-03 23:23:42 -0800342 writel(0x01, MIPI_DSI_BASE + 0x094); /* trigger */
343 while (cnt < 10000) {
344 data = readl(MIPI_DSI_BASE + 0x0004); /*DSI_STATUS */
345 if ((data & 0x0010) == 0)
346 break;
347 cnt++;
348 }
349 if (cnt == 10000)
350 err = 1;
351 return err;
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800352}
353
Ray Zhang4c7e37f2013-12-03 17:04:55 +0800354int mdss_dsi_host_init(struct mipi_dsi_panel_config *pinfo, uint32_t
Dhaval Patel9207dec2014-04-16 10:45:32 -0700355 dual_dsi, uint32_t broadcast)
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700356{
357 uint8_t DMA_STREAM1 = 0; // for mdp display processor path
358 uint8_t EMBED_MODE1 = 1; // from frame buffer
359 uint8_t POWER_MODE2 = 1; // from frame buffer
360 uint8_t PACK_TYPE1; // long packet
361 uint8_t VC1 = 0;
362 uint8_t DT1 = 0; // non embedded mode
363 uint8_t WC1 = 0; // for non embedded mode only
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700364 uint8_t DLNx_EN;
Siddhartha Agrawal2679a822013-05-31 19:15:12 -0700365 uint8_t lane_swap = 0;
Siddhartha Agrawalb6c861f2013-05-31 19:36:44 -0700366 uint32_t timing_ctl = 0;
Vineet Bajaj2f08a362014-07-24 20:50:42 +0530367 uint32_t lane_swap_dsi1 = 0;
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700368
Terence Hampsoncc3345c2013-06-27 15:30:10 -0400369#if (DISPLAY_TYPE_MDSS == 1)
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700370 switch (pinfo->num_of_lanes) {
371 default:
372 case 1:
373 DLNx_EN = 1; // 1 lane
374 break;
375 case 2:
376 DLNx_EN = 3; // 2 lane
377 break;
378 case 3:
379 DLNx_EN = 7; // 3 lane
380 break;
381 case 4:
382 DLNx_EN = 0x0F; /* 4 lanes */
383 break;
384 }
385
386 PACK_TYPE1 = pinfo->pack;
Siddhartha Agrawal2679a822013-05-31 19:15:12 -0700387 lane_swap = pinfo->lane_swap;
Siddhartha Agrawalb6c861f2013-05-31 19:36:44 -0700388 timing_ctl = ((pinfo->t_clk_post << 8) | pinfo->t_clk_pre);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700389
Dhaval Patel9207dec2014-04-16 10:45:32 -0700390 if (dual_dsi) {
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700391 writel(0x0001, MIPI_DSI1_BASE + SOFT_RESET);
392 writel(0x0000, MIPI_DSI1_BASE + SOFT_RESET);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700393
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700394 writel((0 << 16) | 0x3f, MIPI_DSI1_BASE + CLK_CTRL); /* Turn on all DSI Clks */
395 writel(DMA_STREAM1 << 8 | 0x04, MIPI_DSI1_BASE + TRIG_CTRL); // reg 0x80 dma trigger: sw
396 // trigger 0x4; dma stream1
397
398 writel(0 << 30 | DLNx_EN << 4 | 0x105, MIPI_DSI1_BASE + CTRL); // reg 0x00 for this
399 // build
400 writel(broadcast << 31 | EMBED_MODE1 << 28 | POWER_MODE2 << 26
401 | PACK_TYPE1 << 24 | VC1 << 22 | DT1 << 16 | WC1,
402 MIPI_DSI1_BASE + COMMAND_MODE_DMA_CTRL);
Siddhartha Agrawal2679a822013-05-31 19:15:12 -0700403
Vineet Bajaj2f08a362014-07-24 20:50:42 +0530404 if (readl(MIPI_DSI_BASE) == DSI_HW_REV_103_1) /*for 8939 hw dsi1 has Lane_map as 3210*/
405 lane_swap_dsi1 = 0x7;
406 else
407 lane_swap_dsi1 = lane_swap;
408 writel(lane_swap_dsi1, MIPI_DSI1_BASE + LANE_SWAP_CTL);
Siddhartha Agrawalb6c861f2013-05-31 19:36:44 -0700409 writel(timing_ctl, MIPI_DSI1_BASE + TIMING_CTL);
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700410 }
411
412 writel(0x0001, MIPI_DSI0_BASE + SOFT_RESET);
413 writel(0x0000, MIPI_DSI0_BASE + SOFT_RESET);
414
415 writel((0 << 16) | 0x3f, MIPI_DSI0_BASE + CLK_CTRL); /* Turn on all DSI Clks */
416 writel(DMA_STREAM1 << 8 | 0x04, MIPI_DSI0_BASE + TRIG_CTRL); // reg 0x80 dma trigger: sw
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700417 // trigger 0x4; dma stream1
418
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700419 writel(0 << 30 | DLNx_EN << 4 | 0x105, MIPI_DSI0_BASE + CTRL); // reg 0x00 for this
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700420 // build
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700421 writel(broadcast << 31 | EMBED_MODE1 << 28 | POWER_MODE2 << 26
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700422 | PACK_TYPE1 << 24 | VC1 << 22 | DT1 << 16 | WC1,
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700423 MIPI_DSI0_BASE + COMMAND_MODE_DMA_CTRL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700424
Siddhartha Agrawal2679a822013-05-31 19:15:12 -0700425 writel(lane_swap, MIPI_DSI0_BASE + LANE_SWAP_CTL);
Siddhartha Agrawalb6c861f2013-05-31 19:36:44 -0700426 writel(timing_ctl, MIPI_DSI0_BASE + TIMING_CTL);
Ray Zhang4c7e37f2013-12-03 17:04:55 +0800427#endif
Siddhartha Agrawal2679a822013-05-31 19:15:12 -0700428
Ray Zhang4c7e37f2013-12-03 17:04:55 +0800429 return 0;
430}
431
432int mdss_dsi_panel_initialize(struct mipi_dsi_panel_config *pinfo, uint32_t
433 broadcast)
434{
435 int status = 0;
436
437#if (DISPLAY_TYPE_MDSS == 1)
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700438 if (pinfo->panel_cmds) {
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700439
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700440 if (broadcast) {
441 status = mdss_dual_dsi_cmds_tx(pinfo->panel_cmds,
442 pinfo->num_of_panel_cmds);
443
444 } else {
445 status = mipi_dsi_cmds_tx(pinfo->panel_cmds,
446 pinfo->num_of_panel_cmds);
Casey Piper84036752013-09-05 14:56:37 -0700447 if (!status && target_panel_auto_detect_enabled())
448 status =
Shivaraj Shetty64604032013-11-14 16:44:10 +0530449 mdss_dsi_read_panel_signature(pinfo->signature);
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700450 }
451 }
Terence Hampsoncc3345c2013-06-27 15:30:10 -0400452#endif
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700453 return status;
454}
455
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800456int mipi_dsi_panel_initialize(struct mipi_dsi_panel_config *pinfo)
457{
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800458 uint8_t DMA_STREAM1 = 0; // for mdp display processor path
459 uint8_t EMBED_MODE1 = 1; // from frame buffer
460 uint8_t POWER_MODE2 = 1; // from frame buffer
461 uint8_t PACK_TYPE1; // long packet
462 uint8_t VC1 = 0;
463 uint8_t DT1 = 0; // non embedded mode
464 uint8_t WC1 = 0; // for non embedded mode only
Ajay Dudanib01e5062011-12-03 23:23:42 -0800465 int status = 0;
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800466 uint8_t DLNx_EN;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700467
Ajay Dudanib01e5062011-12-03 23:23:42 -0800468 switch (pinfo->num_of_lanes) {
469 default:
470 case 1:
471 DLNx_EN = 1; // 1 lane
472 break;
473 case 2:
474 DLNx_EN = 3; // 2 lane
475 break;
476 case 3:
477 DLNx_EN = 7; // 3 lane
478 break;
Amir Samuelov2d4ba162012-07-22 11:53:14 +0300479 case 4:
480 DLNx_EN = 0x0F; /* 4 lanes */
481 break;
Ajay Dudanib01e5062011-12-03 23:23:42 -0800482 }
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800483
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800484 PACK_TYPE1 = pinfo->pack;
485
Ajay Dudanib01e5062011-12-03 23:23:42 -0800486 writel(0x0001, DSI_SOFT_RESET);
487 writel(0x0000, DSI_SOFT_RESET);
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800488
Ajay Dudanib01e5062011-12-03 23:23:42 -0800489 writel((0 << 16) | 0x3f, DSI_CLK_CTRL); /* Turn on all DSI Clks */
490 writel(DMA_STREAM1 << 8 | 0x04, DSI_TRIG_CTRL); // reg 0x80 dma trigger: sw
491 // trigger 0x4; dma stream1
Kinson Chike5c93432011-06-17 09:10:29 -0700492
Ajay Dudanib01e5062011-12-03 23:23:42 -0800493 writel(0 << 30 | DLNx_EN << 4 | 0x105, DSI_CTRL); // reg 0x00 for this
494 // build
495 writel(EMBED_MODE1 << 28 | POWER_MODE2 << 26
496 | PACK_TYPE1 << 24 | VC1 << 22 | DT1 << 16 | WC1,
497 DSI_COMMAND_MODE_DMA_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700498
Amir Samuelov2d4ba162012-07-22 11:53:14 +0300499 if (pinfo->panel_cmds)
500 status = mipi_dsi_cmds_tx(pinfo->panel_cmds,
501 pinfo->num_of_panel_cmds);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700502
Ajay Dudanib01e5062011-12-03 23:23:42 -0800503 return status;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700504}
505
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700506void mipi_dsi_shutdown(void)
507{
Amol Jadi6834f1a2012-06-29 14:42:59 -0700508 if(!target_cont_splash_screen())
509 {
510 mdp_shutdown();
511 writel(0x01010101, DSI_INT_CTRL);
512 writel(0x13FF3BFF, DSI_ERR_INT_MASK0);
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700513
Amol Jadi6834f1a2012-06-29 14:42:59 -0700514 writel(0, DSI_CLK_CTRL);
515 writel(0, DSI_CTRL);
516 writel(0, DSIPHY_PLL_CTRL(0));
517 }
518 else
519 {
Chandan Uddaraju4877d372011-07-21 12:51:51 -0700520 /* To keep the splash screen displayed till kernel driver takes
521 control, do not turn off the video mode engine and clocks.
522 Only disabling the MIPI DSI IRQs */
523 writel(0x01010101, DSI_INT_CTRL);
524 writel(0x13FF3BFF, DSI_ERR_INT_MASK0);
Amol Jadi6834f1a2012-06-29 14:42:59 -0700525 }
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700526}
527
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700528int mipi_config(struct msm_fb_panel_data *panel)
529{
530 int ret = NO_ERROR;
531 struct msm_panel_info *pinfo;
532 struct mipi_dsi_panel_config mipi_pinfo;
533
534 if (!panel)
535 return ERR_INVALID_ARGS;
536
537 pinfo = &(panel->panel_info);
538 mipi_pinfo.mode = pinfo->mipi.mode;
539 mipi_pinfo.num_of_lanes = pinfo->mipi.num_of_lanes;
540 mipi_pinfo.dsi_phy_config = pinfo->mipi.dsi_phy_db;
541 mipi_pinfo.panel_cmds = pinfo->mipi.panel_cmds;
542 mipi_pinfo.num_of_panel_cmds = pinfo->mipi.num_of_panel_cmds;
Channagoud Kadabi539ef722012-03-29 16:02:50 +0530543 mipi_pinfo.lane_swap = pinfo->mipi.lane_swap;
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800544 mipi_pinfo.pack = 1;
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700545
546 /* Enable MMSS_AHB_ARB_MATER_PORT_E for
547 arbiter master0 and master 1 request */
Terence Hampsonf49ff4e2013-06-18 15:11:31 -0400548#if (!DISPLAY_MIPI_PANEL_RENESAS && !DISPLAY_TYPE_DSI6G && !DISPLAY_TYPE_8610)
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700549 writel(0x00001800, MMSS_SFPB_GPREG);
550#endif
551
552 mipi_dsi_phy_init(&mipi_pinfo);
553
554 ret += mipi_dsi_panel_initialize(&mipi_pinfo);
555
Channagoud Kadabi01c91822012-06-06 15:53:30 +0530556 if (pinfo->rotate && panel->rotate)
557 pinfo->rotate();
558
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700559 return ret;
560}
561
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700562int mdss_dsi_video_mode_config(uint16_t disp_width,
563 uint16_t disp_height,
564 uint16_t img_width,
565 uint16_t img_height,
566 uint16_t hsync_porch0_fp,
567 uint16_t hsync_porch0_bp,
568 uint16_t vsync_porch0_fp,
569 uint16_t vsync_porch0_bp,
570 uint16_t hsync_width,
571 uint16_t vsync_width,
572 uint16_t dst_format,
573 uint16_t traffic_mode,
574 uint8_t lane_en,
575 uint16_t low_pwr_stop_mode,
576 uint8_t eof_bllp_pwr,
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700577 uint8_t interleav,
578 uint32_t ctl_base)
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700579{
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700580 int status = 0;
581
Terence Hampsoncc3345c2013-06-27 15:30:10 -0400582#if (DISPLAY_TYPE_MDSS == 1)
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700583 /* disable mdp first */
584 mdp_disable();
585
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700586 writel(0x00000000, ctl_base + CLK_CTRL);
587 writel(0x00000002, ctl_base + CLK_CTRL);
588 writel(0x00000006, ctl_base + CLK_CTRL);
589 writel(0x0000000e, ctl_base + CLK_CTRL);
590 writel(0x0000001e, ctl_base + CLK_CTRL);
591 writel(0x0000023f, ctl_base + CLK_CTRL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700592
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700593 writel(0, ctl_base + CTRL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700594
Padmanabhan Komanduru7860be52014-03-18 19:07:36 +0530595 writel(0x13ff3fe0, ctl_base + ERR_INT_MASK0);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700596
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700597 writel(0x02020202, ctl_base + INT_CTRL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700598
Padmanabhan Komandurudaebf6b2014-08-20 20:39:40 +0530599 /* For 8916/8939, enable DSI timing double buffering */
600 if (readl(ctl_base) == DSI_HW_REV_103_1)
601 writel(0x1, ctl_base + TIMING_DB_MODE);
602
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700603 writel(((disp_width + hsync_porch0_bp) << 16) | hsync_porch0_bp,
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700604 ctl_base + VIDEO_MODE_ACTIVE_H);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700605
606 writel(((disp_height + vsync_porch0_bp) << 16) | (vsync_porch0_bp),
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700607 ctl_base + VIDEO_MODE_ACTIVE_V);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700608
Terence Hampson7385f6a2013-08-16 15:31:25 -0400609 if (mdp_get_revision() >= MDP_REV_41 ||
Shivaraj Shettyf9e10c42014-09-17 04:21:15 +0530610 mdp_get_revision() == MDP_REV_304 ||
611 mdp_get_revision() == MDP_REV_305) {
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700612 writel(((disp_height + vsync_porch0_fp
613 + vsync_porch0_bp - 1) << 16)
614 | (disp_width + hsync_porch0_fp
615 + hsync_porch0_bp - 1),
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700616 ctl_base + VIDEO_MODE_TOTAL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700617 } else {
618 writel(((disp_height + vsync_porch0_fp
619 + vsync_porch0_bp) << 16)
620 | (disp_width + hsync_porch0_fp
621 + hsync_porch0_bp),
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700622 ctl_base + VIDEO_MODE_TOTAL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700623 }
624
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700625 writel((hsync_width << 16) | 0, ctl_base + VIDEO_MODE_HSYNC);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700626
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700627 writel(0 << 16 | 0, ctl_base + VIDEO_MODE_VSYNC);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700628
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700629 writel(vsync_width << 16 | 0, ctl_base + VIDEO_MODE_VSYNC_VPOS);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700630
Padmanabhan Komandurudaebf6b2014-08-20 20:39:40 +0530631 /* For 8916/8939, flush the DSI timing registers */
632 if (readl(ctl_base) == DSI_HW_REV_103_1)
633 writel(0x1, ctl_base + TIMING_FLUSH);
634
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700635 writel(0x0, ctl_base + EOT_PACKET_CTRL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700636
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700637 writel(0x00000100, ctl_base + MISR_VIDEO_CTRL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700638
639 if (mdp_get_revision() >= MDP_REV_41) {
640 writel(low_pwr_stop_mode << 16 |
641 eof_bllp_pwr << 12 | traffic_mode << 8
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700642 | dst_format << 4 | 0x0, ctl_base + VIDEO_MODE_CTRL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700643 } else {
644 writel(1 << 28 | 1 << 24 | 1 << 20 | low_pwr_stop_mode << 16 |
645 eof_bllp_pwr << 12 | traffic_mode << 8
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700646 | dst_format << 4 | 0x0, ctl_base + VIDEO_MODE_CTRL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700647 }
648
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700649 writel(0x3fd08, ctl_base + HS_TIMER_CTRL);
650 writel(0x00010100, ctl_base + MISR_VIDEO_CTRL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700651
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700652 writel(0x00010100, ctl_base + INT_CTRL);
653 writel(0x02010202, ctl_base + INT_CTRL);
654 writel(0x02030303, ctl_base + INT_CTRL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700655
656 writel(interleav << 30 | 0 << 24 | 0 << 20 | lane_en << 4
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700657 | 0x103, ctl_base + CTRL);
Terence Hampsoncc3345c2013-06-27 15:30:10 -0400658#endif
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700659
660 return status;
661}
662
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800663int mdss_dsi_config(struct msm_fb_panel_data *panel)
664{
665 int ret = NO_ERROR;
666 struct msm_panel_info *pinfo;
667 struct mipi_dsi_panel_config mipi_pinfo;
668
Terence Hampsoncc3345c2013-06-27 15:30:10 -0400669#if (DISPLAY_TYPE_MDSS == 1)
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800670 if (!panel)
671 return ERR_INVALID_ARGS;
672
673 pinfo = &(panel->panel_info);
674 mipi_pinfo.mode = pinfo->mipi.mode;
675 mipi_pinfo.num_of_lanes = pinfo->mipi.num_of_lanes;
676 mipi_pinfo.mdss_dsi_phy_config = pinfo->mipi.mdss_dsi_phy_db;
677 mipi_pinfo.panel_cmds = pinfo->mipi.panel_cmds;
678 mipi_pinfo.num_of_panel_cmds = pinfo->mipi.num_of_panel_cmds;
679 mipi_pinfo.lane_swap = pinfo->mipi.lane_swap;
680 mipi_pinfo.pack = 0;
Siddhartha Agrawalb6c861f2013-05-31 19:36:44 -0700681 mipi_pinfo.t_clk_pre = pinfo->mipi.t_clk_pre;
682 mipi_pinfo.t_clk_post = pinfo->mipi.t_clk_post;
Casey Piper84036752013-09-05 14:56:37 -0700683 mipi_pinfo.signature = pinfo->mipi.signature;
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800684
Padmanabhan Komandurucdc651e2014-03-25 20:25:55 +0530685 mdss_dsi_phy_init(&mipi_pinfo, MIPI_DSI0_BASE, DSI0_PHY_BASE);
Siddhartha Agrawal1b2ed842013-05-29 18:02:28 -0700686 if (pinfo->mipi.dual_dsi)
Padmanabhan Komandurucdc651e2014-03-25 20:25:55 +0530687 mdss_dsi_phy_init(&mipi_pinfo, MIPI_DSI1_BASE, DSI1_PHY_BASE);
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800688
Dhaval Patel9207dec2014-04-16 10:45:32 -0700689 ret = mdss_dsi_host_init(&mipi_pinfo, pinfo->mipi.dual_dsi,
690 pinfo->mipi.broadcast);
Ray Zhang4c7e37f2013-12-03 17:04:55 +0800691 if (ret) {
692 dprintf(CRITICAL, "dsi host init error\n");
693 goto error;
694 }
695
Xiaoming Zhou03fd48b2014-07-31 15:24:41 -0400696 mdss_dsi_phy_contention_detection(&mipi_pinfo, DSI0_PHY_BASE);
697
Ray Zhang4c7e37f2013-12-03 17:04:55 +0800698 if (panel->pre_init_func) {
699 ret = panel->pre_init_func();
700 if (ret) {
701 dprintf(CRITICAL, "pre_init_func error\n");
702 goto error;
703 }
704 }
705
706 ret = mdss_dsi_panel_initialize(&mipi_pinfo, pinfo->mipi.broadcast);
707 if (ret) {
708 dprintf(CRITICAL, "dsi panel init error\n");
709 goto error;
710 }
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800711
712 if (pinfo->rotate && panel->rotate)
713 pinfo->rotate();
Terence Hampsoncc3345c2013-06-27 15:30:10 -0400714#endif
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800715
Ray Zhang4c7e37f2013-12-03 17:04:55 +0800716error:
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800717 return ret;
718}
719
Siddhartha Agrawal7317e482013-04-21 16:16:57 -0700720int mdss_dsi_cmd_mode_config(uint16_t disp_width,
721 uint16_t disp_height,
722 uint16_t img_width,
723 uint16_t img_height,
724 uint16_t dst_format,
Xiaoming Zhou8d534dd2013-07-29 15:49:19 -0400725 uint8_t ystride,
726 uint8_t lane_en,
Dhaval Patel5b22fe72014-01-02 16:28:38 -0800727 uint8_t interleav,
728 uint32_t ctl_base)
Siddhartha Agrawal7317e482013-04-21 16:16:57 -0700729{
Xiaoming Zhou8d534dd2013-07-29 15:49:19 -0400730 uint16_t dst_fmt = 0;
731
732 switch (dst_format) {
733 case DSI_VIDEO_DST_FORMAT_RGB565:
734 dst_fmt = DSI_CMD_DST_FORMAT_RGB565;
735 break;
736 case DSI_VIDEO_DST_FORMAT_RGB666:
737 case DSI_VIDEO_DST_FORMAT_RGB666_LOOSE:
738 dst_fmt = DSI_CMD_DST_FORMAT_RGB666;
739 break;
740 case DSI_VIDEO_DST_FORMAT_RGB888:
741 dst_fmt = DSI_CMD_DST_FORMAT_RGB888;
742 break;
743 default:
744 dprintf(CRITICAL, "unsupported dst format\n");
745 return ERROR;
746 }
Siddhartha Agrawal7317e482013-04-21 16:16:57 -0700747
Terence Hampsoncc3345c2013-06-27 15:30:10 -0400748#if (DISPLAY_TYPE_MDSS == 1)
Dhaval Patel5b22fe72014-01-02 16:28:38 -0800749 writel(0x00000000, ctl_base + CLK_CTRL);
750 writel(0x00000000, ctl_base + CLK_CTRL);
751 writel(0x00000000, ctl_base + CLK_CTRL);
752 writel(0x00000000, ctl_base + CLK_CTRL);
753 writel(0x00000002, ctl_base + CLK_CTRL);
754 writel(0x00000006, ctl_base + CLK_CTRL);
755 writel(0x0000000e, ctl_base + CLK_CTRL);
756 writel(0x0000001e, ctl_base + CLK_CTRL);
757 writel(0x0000023f, ctl_base + CLK_CTRL);
Siddhartha Agrawal7317e482013-04-21 16:16:57 -0700758
Dhaval Patel5b22fe72014-01-02 16:28:38 -0800759 writel(0, ctl_base + CTRL);
Siddhartha Agrawal7317e482013-04-21 16:16:57 -0700760
Padmanabhan Komanduru7860be52014-03-18 19:07:36 +0530761 writel(0x13ff3fe0, ctl_base + ERR_INT_MASK0);
Siddhartha Agrawal7317e482013-04-21 16:16:57 -0700762
Dhaval Patel5b22fe72014-01-02 16:28:38 -0800763 writel(0x02020202, ctl_base + INT_CTRL);
Siddhartha Agrawal7317e482013-04-21 16:16:57 -0700764
Dhaval Patel5b22fe72014-01-02 16:28:38 -0800765 writel(dst_fmt, ctl_base + COMMAND_MODE_MDP_CTRL);
Siddhartha Agrawal7317e482013-04-21 16:16:57 -0700766 writel((img_width * ystride + 1) << 16 | 0x0039,
Dhaval Patel5b22fe72014-01-02 16:28:38 -0800767 ctl_base + COMMAND_MODE_MDP_STREAM0_CTRL);
Siddhartha Agrawal7317e482013-04-21 16:16:57 -0700768 writel((img_width * ystride + 1) << 16 | 0x0039,
Dhaval Patel5b22fe72014-01-02 16:28:38 -0800769 ctl_base + COMMAND_MODE_MDP_STREAM1_CTRL);
Siddhartha Agrawal7317e482013-04-21 16:16:57 -0700770 writel(img_height << 16 | img_width,
Dhaval Patel5b22fe72014-01-02 16:28:38 -0800771 ctl_base + COMMAND_MODE_MDP_STREAM0_TOTAL);
Siddhartha Agrawal7317e482013-04-21 16:16:57 -0700772 writel(img_height << 16 | img_width,
Dhaval Patel5b22fe72014-01-02 16:28:38 -0800773 ctl_base + COMMAND_MODE_MDP_STREAM1_TOTAL);
774 writel(0x13c2c, ctl_base + COMMAND_MODE_MDP_DCS_CMD_CTRL);
Xiaoming Zhou8d534dd2013-07-29 15:49:19 -0400775 writel(interleav << 30 | 0 << 24 | 0 << 20 | lane_en << 4 | 0x105,
Dhaval Patel5b22fe72014-01-02 16:28:38 -0800776 ctl_base + CTRL);
Padmanabhan Komanduru7860be52014-03-18 19:07:36 +0530777 writel(0x14000000, ctl_base + COMMAND_MODE_DMA_CTRL);
Dhaval Patel5b22fe72014-01-02 16:28:38 -0800778 writel(0x10000000, ctl_base + MISR_CMD_CTRL);
Xiaoming Zhoua0469332014-03-04 18:34:24 -0500779 writel(0x1, ctl_base + EOT_PACKET_CTRL);
Terence Hampsoncc3345c2013-06-27 15:30:10 -0400780#endif
Xiaoming Zhou8d534dd2013-07-29 15:49:19 -0400781 return 0;
Siddhartha Agrawal7317e482013-04-21 16:16:57 -0700782}
783
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700784int mipi_dsi_on()
785{
786 int ret = NO_ERROR;
787 unsigned long ReadValue;
788 unsigned long count = 0;
789
790 ReadValue = readl(DSI_INT_CTRL) & 0x00010000;
791
792 mdelay(10);
793
794 while (ReadValue != 0x00010000) {
795 ReadValue = readl(DSI_INT_CTRL) & 0x00010000;
796 count++;
797 if (count > 0xffff) {
798 dprintf(CRITICAL, "Video lane test failed\n");
799 return ERROR;
800 }
801 }
802
Amir Samuelov2d4ba162012-07-22 11:53:14 +0300803 dprintf(INFO, "Video lane tested successfully\n");
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700804 return ret;
805}
806
Siddhartha Agrawal24d81b52013-07-01 11:13:32 -0700807int mipi_dsi_off(struct msm_panel_info *pinfo)
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700808{
Amol Jadi6834f1a2012-06-29 14:42:59 -0700809 if(!target_cont_splash_screen())
810 {
811 writel(0, DSI_CLK_CTRL);
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800812 writel(0x1F1, DSI_CTRL);
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800813 mdelay(10);
814 writel(0x0001, DSI_SOFT_RESET);
815 writel(0x0000, DSI_SOFT_RESET);
Amol Jadi6834f1a2012-06-29 14:42:59 -0700816 writel(0, DSI_CTRL);
Siddhartha Agrawale0033a12013-02-23 15:37:42 -0800817 }
818
Dhaval Patelddde45a2014-08-13 19:07:59 -0700819 writel(0x1115501, MIPI_DSI0_BASE + INT_CTRL);
Siddhartha Agrawal24d81b52013-07-01 11:13:32 -0700820 if (pinfo->mipi.broadcast)
Dhaval Patelddde45a2014-08-13 19:07:59 -0700821 writel(0x1115501, MIPI_DSI1_BASE + INT_CTRL);
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700822
823 return NO_ERROR;
824}
Channagoud Kadabi10189fd2012-05-25 13:33:39 +0530825
826int mipi_cmd_trigger()
827{
828 writel(0x1, DSI_CMD_MODE_MDP_SW_TRIGGER);
829
830 return NO_ERROR;
831}