blob: 912fe8e8e27d9f17ac0fd4c20aabaa93c1e60345 [file] [log] [blame]
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -08001/* Copyright (c) 2010-2013, 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);
Deepa Dinamania080a402011-11-05 18:59:26 -070049extern void dsb(void);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -070050
Siddhartha Agrawal1b2ed842013-05-29 18:02:28 -070051#if (DISPLAY_TYPE_MDSS == 0)
52#define MIPI_DSI0_BASE MIPI_DSI_BASE
53#define MIPI_DSI1_BASE MIPI_DSI_BASE
54#endif
55
Chandan Uddarajufe93e822010-11-21 20:44:47 -080056#if DISPLAY_MIPI_PANEL_TOSHIBA
Chandan Uddaraju78ae6752010-10-19 12:57:10 -070057static struct fbcon_config mipi_fb_cfg = {
Ajay Dudanib01e5062011-12-03 23:23:42 -080058 .height = TSH_MIPI_FB_HEIGHT,
59 .width = TSH_MIPI_FB_WIDTH,
60 .stride = TSH_MIPI_FB_WIDTH,
61 .format = FB_FORMAT_RGB888,
62 .bpp = 24,
63 .update_start = NULL,
64 .update_done = NULL,
Chandan Uddaraju78ae6752010-10-19 12:57:10 -070065};
Ajay Dudanib01e5062011-12-03 23:23:42 -080066
Kinson Chike5c93432011-06-17 09:10:29 -070067struct mipi_dsi_panel_config toshiba_panel_info = {
Ajay Dudanib01e5062011-12-03 23:23:42 -080068 .mode = MIPI_VIDEO_MODE,
69 .num_of_lanes = 1,
70 .dsi_phy_config = &mipi_dsi_toshiba_panel_phy_ctrl,
71 .panel_cmds = toshiba_panel_video_mode_cmds,
72 .num_of_panel_cmds = ARRAY_SIZE(toshiba_panel_video_mode_cmds),
Kinson Chike5c93432011-06-17 09:10:29 -070073};
Chandan Uddarajufe93e822010-11-21 20:44:47 -080074#elif DISPLAY_MIPI_PANEL_NOVATEK_BLUE
75static struct fbcon_config mipi_fb_cfg = {
Ajay Dudanib01e5062011-12-03 23:23:42 -080076 .height = NOV_MIPI_FB_HEIGHT,
77 .width = NOV_MIPI_FB_WIDTH,
78 .stride = NOV_MIPI_FB_WIDTH,
79 .format = FB_FORMAT_RGB888,
80 .bpp = 24,
81 .update_start = NULL,
82 .update_done = NULL,
Chandan Uddarajufe93e822010-11-21 20:44:47 -080083};
Ajay Dudanib01e5062011-12-03 23:23:42 -080084
Kinson Chike5c93432011-06-17 09:10:29 -070085struct mipi_dsi_panel_config novatek_panel_info = {
Ajay Dudanib01e5062011-12-03 23:23:42 -080086 .mode = MIPI_CMD_MODE,
87 .num_of_lanes = 2,
88 .dsi_phy_config = &mipi_dsi_novatek_panel_phy_ctrl,
89 .panel_cmds = novatek_panel_cmd_mode_cmds,
90 .num_of_panel_cmds = ARRAY_SIZE(novatek_panel_cmd_mode_cmds),
Kinson Chike5c93432011-06-17 09:10:29 -070091};
Chandan Uddarajufe93e822010-11-21 20:44:47 -080092#else
93static struct fbcon_config mipi_fb_cfg = {
Ajay Dudanib01e5062011-12-03 23:23:42 -080094 .height = 0,
95 .width = 0,
96 .stride = 0,
97 .format = 0,
98 .bpp = 0,
99 .update_start = NULL,
100 .update_done = NULL,
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800101};
102#endif
103
104static int cmd_mode_status = 0;
Greg Griscod6250552011-06-29 14:40:23 -0700105void secure_writel(uint32_t, uint32_t);
106uint32_t secure_readl(uint32_t);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700107
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800108struct mipi_dsi_panel_config *get_panel_info(void)
109{
110#if DISPLAY_MIPI_PANEL_TOSHIBA
Ajay Dudanib01e5062011-12-03 23:23:42 -0800111 return &toshiba_panel_info;
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800112#elif DISPLAY_MIPI_PANEL_NOVATEK_BLUE
Ajay Dudanib01e5062011-12-03 23:23:42 -0800113 return &novatek_panel_info;
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800114#endif
Ajay Dudanib01e5062011-12-03 23:23:42 -0800115 return NULL;
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800116}
117
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700118int mdss_dual_dsi_cmd_dma_trigger_for_panel()
119{
120 uint32_t ReadValue;
121 uint32_t count = 0;
122 int status = 0;
123
124 writel(0x03030303, MIPI_DSI0_BASE + INT_CTRL);
125 writel(0x1, MIPI_DSI0_BASE + CMD_MODE_DMA_SW_TRIGGER);
126 dsb();
127
128 writel(0x03030303, MIPI_DSI1_BASE + INT_CTRL);
129 writel(0x1, MIPI_DSI1_BASE + CMD_MODE_DMA_SW_TRIGGER);
130 dsb();
131
132 ReadValue = readl(MIPI_DSI1_BASE + INT_CTRL) & 0x00000001;
133 while (ReadValue != 0x00000001) {
134 ReadValue = readl(MIPI_DSI1_BASE + INT_CTRL) & 0x00000001;
135 count++;
136 if (count > 0xffff) {
137 status = FAIL;
138 dprintf(CRITICAL,
139 "Panel CMD: command mode dma test failed\n");
140 return status;
141 }
142 }
143
144 writel((readl(MIPI_DSI1_BASE + INT_CTRL) | 0x01000001),
145 MIPI_DSI1_BASE + INT_CTRL);
146 dprintf(SPEW, "Panel CMD: command mode dma tested successfully\n");
147 return status;
148}
149
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700150int dsi_cmd_dma_trigger_for_panel()
151{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800152 unsigned long ReadValue;
153 unsigned long count = 0;
154 int status = 0;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700155
Ajay Dudanib01e5062011-12-03 23:23:42 -0800156 writel(0x03030303, DSI_INT_CTRL);
157 writel(0x1, DSI_CMD_MODE_DMA_SW_TRIGGER);
158 dsb();
159 ReadValue = readl(DSI_INT_CTRL) & 0x00000001;
160 while (ReadValue != 0x00000001) {
161 ReadValue = readl(DSI_INT_CTRL) & 0x00000001;
162 count++;
163 if (count > 0xffff) {
164 status = FAIL;
165 dprintf(CRITICAL,
166 "Panel CMD: command mode dma test failed\n");
167 return status;
168 }
169 }
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700170
Ajay Dudanib01e5062011-12-03 23:23:42 -0800171 writel((readl(DSI_INT_CTRL) | 0x01000001), DSI_INT_CTRL);
172 dprintf(SPEW, "Panel CMD: command mode dma tested successfully\n");
173 return status;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700174}
175
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700176int mdss_dual_dsi_cmds_tx(struct mipi_dsi_cmd *cmds, int count)
177{
178 int ret = 0;
179 struct mipi_dsi_cmd *cm;
180 int i = 0;
181 char pload[256];
182 uint32_t off;
183
184 /* Align pload at 8 byte boundry */
185 off = pload;
186 off &= 0x07;
187 if (off)
188 off = 8 - off;
189 off += pload;
190
191 cm = cmds;
192 for (i = 0; i < count; i++) {
193 memcpy((void *)off, (cm->payload), cm->size);
194 writel(off, MIPI_DSI0_BASE + DMA_CMD_OFFSET);
195 writel(cm->size, MIPI_DSI0_BASE + DMA_CMD_LENGTH); // reg 0x48 for this build
196 writel(off, MIPI_DSI1_BASE + DMA_CMD_OFFSET);
197 writel(cm->size, MIPI_DSI1_BASE + DMA_CMD_LENGTH); // reg 0x48 for this build
198 dsb();
199 ret += mdss_dual_dsi_cmd_dma_trigger_for_panel();
200 udelay(80);
201 cm++;
202 }
203 return ret;
204}
205
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800206int mipi_dsi_cmds_tx(struct mipi_dsi_cmd *cmds, int count)
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700207{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800208 int ret = 0;
209 struct mipi_dsi_cmd *cm;
210 int i = 0;
211 char pload[256];
212 uint32_t off;
Deepa Dinamania080a402011-11-05 18:59:26 -0700213
Ajay Dudanib01e5062011-12-03 23:23:42 -0800214 /* Align pload at 8 byte boundry */
215 off = pload;
216 off &= 0x07;
217 if (off)
218 off = 8 - off;
219 off += pload;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700220
Ajay Dudanib01e5062011-12-03 23:23:42 -0800221 cm = cmds;
222 for (i = 0; i < count; i++) {
223 memcpy((void *)off, (cm->payload), cm->size);
224 writel(off, DSI_DMA_CMD_OFFSET);
225 writel(cm->size, DSI_DMA_CMD_LENGTH); // reg 0x48 for this build
226 dsb();
227 ret += dsi_cmd_dma_trigger_for_panel();
Sangani Suryanarayana Raju769f9ac2013-04-30 19:05:06 +0530228 dsb();
229 if (cm->wait)
230 mdelay(cm->wait);
231 else
232 udelay(80);
Ajay Dudanib01e5062011-12-03 23:23:42 -0800233 cm++;
234 }
235 return ret;
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800236}
237
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800238/*
239 * mipi_dsi_cmd_rx: can receive at most 16 bytes
240 * per transaction since it only have 4 32bits reigsters
241 * to hold data.
242 * therefore Maximum Return Packet Size need to be set to 16.
243 * any return data more than MRPS need to be break down
244 * to multiple transactions.
245 */
246int mipi_dsi_cmds_rx(char **rp, int len)
247{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800248 uint32_t *lp, data;
249 char *dp;
250 int i, off, cnt;
251 int rlen, res;
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800252
Ajay Dudanib01e5062011-12-03 23:23:42 -0800253 if (len <= 2)
254 rlen = 4; /* short read */
255 else
256 rlen = MIPI_DSI_MRPS + 6; /* 4 bytes header + 2 bytes crc */
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800257
Ajay Dudanib01e5062011-12-03 23:23:42 -0800258 if (rlen > MIPI_DSI_REG_LEN) {
259 return 0;
260 }
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800261
Ajay Dudanib01e5062011-12-03 23:23:42 -0800262 res = rlen & 0x03;
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800263
Ajay Dudanib01e5062011-12-03 23:23:42 -0800264 rlen += res; /* 4 byte align */
265 lp = (uint32_t *) (*rp);
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800266
Ajay Dudanib01e5062011-12-03 23:23:42 -0800267 cnt = rlen;
268 cnt += 3;
269 cnt >>= 2;
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800270
Ajay Dudanib01e5062011-12-03 23:23:42 -0800271 if (cnt > 4)
272 cnt = 4; /* 4 x 32 bits registers only */
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800273
Ajay Dudanib01e5062011-12-03 23:23:42 -0800274 off = 0x068; /* DSI_RDBK_DATA0 */
275 off += ((cnt - 1) * 4);
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800276
Ajay Dudanib01e5062011-12-03 23:23:42 -0800277 for (i = 0; i < cnt; i++) {
278 data = (uint32_t) readl(MIPI_DSI_BASE + off);
279 *lp++ = ntohl(data); /* to network byte order */
280 off -= 4;
281 }
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800282
Ajay Dudanib01e5062011-12-03 23:23:42 -0800283 if (len > 2) {
284 /*First 4 bytes + paded bytes will be header next len bytes would be payload */
285 for (i = 0; i < len; i++) {
286 dp = *rp;
287 dp[i] = dp[4 + res + i];
288 }
289 }
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800290
Ajay Dudanib01e5062011-12-03 23:23:42 -0800291 return len;
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800292}
293
294static int mipi_dsi_cmd_bta_sw_trigger(void)
295{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800296 uint32_t data;
297 int cnt = 0;
298 int err = 0;
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800299
Ajay Dudanib01e5062011-12-03 23:23:42 -0800300 writel(0x01, MIPI_DSI_BASE + 0x094); /* trigger */
301 while (cnt < 10000) {
302 data = readl(MIPI_DSI_BASE + 0x0004); /*DSI_STATUS */
303 if ((data & 0x0010) == 0)
304 break;
305 cnt++;
306 }
307 if (cnt == 10000)
308 err = 1;
309 return err;
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800310}
311
312static uint32_t mipi_novatek_manufacture_id(void)
313{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800314 char rec_buf[24];
315 char *rp = rec_buf;
316 uint32_t *lp, data;
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800317
Ajay Dudanib01e5062011-12-03 23:23:42 -0800318 mipi_dsi_cmds_tx(&novatek_panel_manufacture_id_cmd, 1);
319 mipi_dsi_cmds_rx(&rp, 3);
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800320
Ajay Dudanib01e5062011-12-03 23:23:42 -0800321 lp = (uint32_t *) rp;
322 data = (uint32_t) * lp;
323 data = ntohl(data);
324 data = data >> 8;
325 return data;
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800326}
327
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700328int mdss_dsi_panel_initialize(struct mipi_dsi_panel_config *pinfo, uint32_t
329 broadcast)
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700330{
331 uint8_t DMA_STREAM1 = 0; // for mdp display processor path
332 uint8_t EMBED_MODE1 = 1; // from frame buffer
333 uint8_t POWER_MODE2 = 1; // from frame buffer
334 uint8_t PACK_TYPE1; // long packet
335 uint8_t VC1 = 0;
336 uint8_t DT1 = 0; // non embedded mode
337 uint8_t WC1 = 0; // for non embedded mode only
338 int status = 0;
339 uint8_t DLNx_EN;
Siddhartha Agrawal2679a822013-05-31 19:15:12 -0700340 uint8_t lane_swap = 0;
Siddhartha Agrawalb6c861f2013-05-31 19:36:44 -0700341 uint32_t timing_ctl = 0;
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700342
343 switch (pinfo->num_of_lanes) {
344 default:
345 case 1:
346 DLNx_EN = 1; // 1 lane
347 break;
348 case 2:
349 DLNx_EN = 3; // 2 lane
350 break;
351 case 3:
352 DLNx_EN = 7; // 3 lane
353 break;
354 case 4:
355 DLNx_EN = 0x0F; /* 4 lanes */
356 break;
357 }
358
359 PACK_TYPE1 = pinfo->pack;
Siddhartha Agrawal2679a822013-05-31 19:15:12 -0700360 lane_swap = pinfo->lane_swap;
Siddhartha Agrawalb6c861f2013-05-31 19:36:44 -0700361 timing_ctl = ((pinfo->t_clk_post << 8) | pinfo->t_clk_pre);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700362
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700363 if (broadcast) {
364 writel(0x0001, MIPI_DSI1_BASE + SOFT_RESET);
365 writel(0x0000, MIPI_DSI1_BASE + SOFT_RESET);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700366
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700367 writel((0 << 16) | 0x3f, MIPI_DSI1_BASE + CLK_CTRL); /* Turn on all DSI Clks */
368 writel(DMA_STREAM1 << 8 | 0x04, MIPI_DSI1_BASE + TRIG_CTRL); // reg 0x80 dma trigger: sw
369 // trigger 0x4; dma stream1
370
371 writel(0 << 30 | DLNx_EN << 4 | 0x105, MIPI_DSI1_BASE + CTRL); // reg 0x00 for this
372 // build
373 writel(broadcast << 31 | EMBED_MODE1 << 28 | POWER_MODE2 << 26
374 | PACK_TYPE1 << 24 | VC1 << 22 | DT1 << 16 | WC1,
375 MIPI_DSI1_BASE + COMMAND_MODE_DMA_CTRL);
Siddhartha Agrawal2679a822013-05-31 19:15:12 -0700376
377 writel(lane_swap, MIPI_DSI1_BASE + LANE_SWAP_CTL);
Siddhartha Agrawalb6c861f2013-05-31 19:36:44 -0700378 writel(timing_ctl, MIPI_DSI1_BASE + TIMING_CTL);
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700379 }
380
381 writel(0x0001, MIPI_DSI0_BASE + SOFT_RESET);
382 writel(0x0000, MIPI_DSI0_BASE + SOFT_RESET);
383
384 writel((0 << 16) | 0x3f, MIPI_DSI0_BASE + CLK_CTRL); /* Turn on all DSI Clks */
385 writel(DMA_STREAM1 << 8 | 0x04, MIPI_DSI0_BASE + TRIG_CTRL); // reg 0x80 dma trigger: sw
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700386 // trigger 0x4; dma stream1
387
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700388 writel(0 << 30 | DLNx_EN << 4 | 0x105, MIPI_DSI0_BASE + CTRL); // reg 0x00 for this
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700389 // build
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700390 writel(broadcast << 31 | EMBED_MODE1 << 28 | POWER_MODE2 << 26
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700391 | PACK_TYPE1 << 24 | VC1 << 22 | DT1 << 16 | WC1,
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700392 MIPI_DSI0_BASE + COMMAND_MODE_DMA_CTRL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700393
Siddhartha Agrawal2679a822013-05-31 19:15:12 -0700394 writel(lane_swap, MIPI_DSI0_BASE + LANE_SWAP_CTL);
Siddhartha Agrawalb6c861f2013-05-31 19:36:44 -0700395 writel(timing_ctl, MIPI_DSI0_BASE + TIMING_CTL);
Siddhartha Agrawal2679a822013-05-31 19:15:12 -0700396
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700397 if (pinfo->panel_cmds) {
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700398
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700399 if (broadcast) {
400 status = mdss_dual_dsi_cmds_tx(pinfo->panel_cmds,
401 pinfo->num_of_panel_cmds);
402
403 } else {
404 status = mipi_dsi_cmds_tx(pinfo->panel_cmds,
405 pinfo->num_of_panel_cmds);
406 }
407 }
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700408 return status;
409}
410
411
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800412int mipi_dsi_panel_initialize(struct mipi_dsi_panel_config *pinfo)
413{
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800414 uint8_t DMA_STREAM1 = 0; // for mdp display processor path
415 uint8_t EMBED_MODE1 = 1; // from frame buffer
416 uint8_t POWER_MODE2 = 1; // from frame buffer
417 uint8_t PACK_TYPE1; // long packet
418 uint8_t VC1 = 0;
419 uint8_t DT1 = 0; // non embedded mode
420 uint8_t WC1 = 0; // for non embedded mode only
Ajay Dudanib01e5062011-12-03 23:23:42 -0800421 int status = 0;
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800422 uint8_t DLNx_EN;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700423
Ajay Dudanib01e5062011-12-03 23:23:42 -0800424 switch (pinfo->num_of_lanes) {
425 default:
426 case 1:
427 DLNx_EN = 1; // 1 lane
428 break;
429 case 2:
430 DLNx_EN = 3; // 2 lane
431 break;
432 case 3:
433 DLNx_EN = 7; // 3 lane
434 break;
Amir Samuelov2d4ba162012-07-22 11:53:14 +0300435 case 4:
436 DLNx_EN = 0x0F; /* 4 lanes */
437 break;
Ajay Dudanib01e5062011-12-03 23:23:42 -0800438 }
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800439
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800440 PACK_TYPE1 = pinfo->pack;
441
Ajay Dudanib01e5062011-12-03 23:23:42 -0800442 writel(0x0001, DSI_SOFT_RESET);
443 writel(0x0000, DSI_SOFT_RESET);
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800444
Ajay Dudanib01e5062011-12-03 23:23:42 -0800445 writel((0 << 16) | 0x3f, DSI_CLK_CTRL); /* Turn on all DSI Clks */
446 writel(DMA_STREAM1 << 8 | 0x04, DSI_TRIG_CTRL); // reg 0x80 dma trigger: sw
447 // trigger 0x4; dma stream1
Kinson Chike5c93432011-06-17 09:10:29 -0700448
Ajay Dudanib01e5062011-12-03 23:23:42 -0800449 writel(0 << 30 | DLNx_EN << 4 | 0x105, DSI_CTRL); // reg 0x00 for this
450 // build
451 writel(EMBED_MODE1 << 28 | POWER_MODE2 << 26
452 | PACK_TYPE1 << 24 | VC1 << 22 | DT1 << 16 | WC1,
453 DSI_COMMAND_MODE_DMA_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700454
Amir Samuelov2d4ba162012-07-22 11:53:14 +0300455 if (pinfo->panel_cmds)
456 status = mipi_dsi_cmds_tx(pinfo->panel_cmds,
457 pinfo->num_of_panel_cmds);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700458
Ajay Dudanib01e5062011-12-03 23:23:42 -0800459 return status;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700460}
461
Kinson Chike5c93432011-06-17 09:10:29 -0700462//TODO: Clean up arguments being passed in not being used
Ajay Dudanib01e5062011-12-03 23:23:42 -0800463int
464config_dsi_video_mode(unsigned short disp_width, unsigned short disp_height,
465 unsigned short img_width, unsigned short img_height,
466 unsigned short hsync_porch0_fp,
467 unsigned short hsync_porch0_bp,
468 unsigned short vsync_porch0_fp,
469 unsigned short vsync_porch0_bp,
470 unsigned short hsync_width,
471 unsigned short vsync_width, unsigned short dst_format,
472 unsigned short traffic_mode, unsigned short datalane_num)
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700473{
474
Ajay Dudanib01e5062011-12-03 23:23:42 -0800475 unsigned char DST_FORMAT;
476 unsigned char TRAFIC_MODE;
477 unsigned char DLNx_EN;
478 // video mode data ctrl
479 int status = 0;
480 unsigned long low_pwr_stop_mode = 0;
481 unsigned char eof_bllp_pwr = 0x9;
482 unsigned char interleav = 0;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700483
Ajay Dudanib01e5062011-12-03 23:23:42 -0800484 // disable mdp first
485 mdp_disable();
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700486
Ajay Dudanib01e5062011-12-03 23:23:42 -0800487 writel(0x00000000, DSI_CLK_CTRL);
488 writel(0x00000000, DSI_CLK_CTRL);
489 writel(0x00000000, DSI_CLK_CTRL);
490 writel(0x00000000, DSI_CLK_CTRL);
491 writel(0x00000002, DSI_CLK_CTRL);
492 writel(0x00000006, DSI_CLK_CTRL);
493 writel(0x0000000e, DSI_CLK_CTRL);
494 writel(0x0000001e, DSI_CLK_CTRL);
495 writel(0x0000003e, DSI_CLK_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700496
Ajay Dudanib01e5062011-12-03 23:23:42 -0800497 writel(0, DSI_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700498
Ajay Dudanib01e5062011-12-03 23:23:42 -0800499 writel(0, DSI_ERR_INT_MASK0);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700500
Ajay Dudanib01e5062011-12-03 23:23:42 -0800501 DST_FORMAT = 0; // RGB565
502 dprintf(SPEW, "DSI_Video_Mode - Dst Format: RGB565\n");
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700503
Ajay Dudanib01e5062011-12-03 23:23:42 -0800504 DLNx_EN = 1; // 1 lane with clk programming
505 dprintf(SPEW, "Data Lane: 1 lane\n");
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700506
Ajay Dudanib01e5062011-12-03 23:23:42 -0800507 TRAFIC_MODE = 0; // non burst mode with sync pulses
508 dprintf(SPEW, "Traffic mode: non burst mode with sync pulses\n");
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700509
Ajay Dudanib01e5062011-12-03 23:23:42 -0800510 writel(0x02020202, DSI_INT_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700511
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800512 writel(((hsync_width + img_width + hsync_porch0_bp) << 16)
513 | (hsync_width + hsync_porch0_bp),
Ajay Dudanib01e5062011-12-03 23:23:42 -0800514 DSI_VIDEO_MODE_ACTIVE_H);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700515
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800516 writel(((vsync_width + img_height + vsync_porch0_bp) << 16)
517 | (vsync_width + vsync_porch0_bp),
Ajay Dudanib01e5062011-12-03 23:23:42 -0800518 DSI_VIDEO_MODE_ACTIVE_V);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700519
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800520 writel(((vsync_width + img_height + vsync_porch0_fp + vsync_porch0_bp - 1) << 16)
521 | (hsync_width + img_width + hsync_porch0_fp + hsync_porch0_bp - 1),
Ajay Dudanib01e5062011-12-03 23:23:42 -0800522 DSI_VIDEO_MODE_TOTAL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700523
Ajay Dudanib01e5062011-12-03 23:23:42 -0800524 writel((hsync_width << 16) | 0, DSI_VIDEO_MODE_HSYNC);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700525
Ajay Dudanib01e5062011-12-03 23:23:42 -0800526 writel(0 << 16 | 0, DSI_VIDEO_MODE_VSYNC);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700527
Ajay Dudanib01e5062011-12-03 23:23:42 -0800528 writel(vsync_width << 16 | 0, DSI_VIDEO_MODE_VSYNC_VPOS);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700529
Ajay Dudanib01e5062011-12-03 23:23:42 -0800530 writel(1, DSI_EOT_PACKET_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700531
Ajay Dudanib01e5062011-12-03 23:23:42 -0800532 writel(0x00000100, DSI_MISR_VIDEO_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700533
Ajay Dudanib01e5062011-12-03 23:23:42 -0800534 writel(low_pwr_stop_mode << 16 | eof_bllp_pwr << 12 | TRAFIC_MODE << 8
535 | DST_FORMAT << 4 | 0x0, DSI_VIDEO_MODE_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700536
Ajay Dudanib01e5062011-12-03 23:23:42 -0800537 writel(0x67, DSI_CAL_STRENGTH_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700538
Ajay Dudanib01e5062011-12-03 23:23:42 -0800539 writel(0x80006711, DSI_CAL_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700540
Ajay Dudanib01e5062011-12-03 23:23:42 -0800541 writel(0x00010100, DSI_MISR_VIDEO_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700542
Ajay Dudanib01e5062011-12-03 23:23:42 -0800543 writel(0x00010100, DSI_INT_CTRL);
544 writel(0x02010202, DSI_INT_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700545
Ajay Dudanib01e5062011-12-03 23:23:42 -0800546 writel(0x02030303, DSI_INT_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700547
Ajay Dudanib01e5062011-12-03 23:23:42 -0800548 writel(interleav << 30 | 0 << 24 | 0 << 20 | DLNx_EN << 4
549 | 0x103, DSI_CTRL);
550 mdelay(10);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700551
Ajay Dudanib01e5062011-12-03 23:23:42 -0800552 return status;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700553}
554
Ajay Dudanib01e5062011-12-03 23:23:42 -0800555int
556config_dsi_cmd_mode(unsigned short disp_width, unsigned short disp_height,
557 unsigned short img_width, unsigned short img_height,
558 unsigned short dst_format,
559 unsigned short traffic_mode, unsigned short datalane_num)
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800560{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800561 unsigned char DST_FORMAT;
562 unsigned char TRAFIC_MODE;
563 unsigned char DLNx_EN;
564 // video mode data ctrl
565 int status = 0;
Greg Griscod6250552011-06-29 14:40:23 -0700566 unsigned char interleav = 0;
567 unsigned char ystride = 0x03;
Ajay Dudanib01e5062011-12-03 23:23:42 -0800568 // disable mdp first
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800569
Ajay Dudanib01e5062011-12-03 23:23:42 -0800570 writel(0x00000000, DSI_CLK_CTRL);
571 writel(0x00000000, DSI_CLK_CTRL);
572 writel(0x00000000, DSI_CLK_CTRL);
573 writel(0x00000000, DSI_CLK_CTRL);
574 writel(0x00000002, DSI_CLK_CTRL);
575 writel(0x00000006, DSI_CLK_CTRL);
576 writel(0x0000000e, DSI_CLK_CTRL);
577 writel(0x0000001e, DSI_CLK_CTRL);
578 writel(0x0000003e, DSI_CLK_CTRL);
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800579
Ajay Dudanib01e5062011-12-03 23:23:42 -0800580 writel(0x10000000, DSI_ERR_INT_MASK0);
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800581
Ajay Dudanib01e5062011-12-03 23:23:42 -0800582 // writel(0, DSI_CTRL);
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800583
Ajay Dudanib01e5062011-12-03 23:23:42 -0800584 // writel(0, DSI_ERR_INT_MASK0);
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800585
Ajay Dudanib01e5062011-12-03 23:23:42 -0800586 DST_FORMAT = 8; // RGB888
587 dprintf(SPEW, "DSI_Cmd_Mode - Dst Format: RGB888\n");
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800588
Ajay Dudanib01e5062011-12-03 23:23:42 -0800589 DLNx_EN = 3; // 2 lane with clk programming
590 dprintf(SPEW, "Data Lane: 2 lane\n");
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800591
Ajay Dudanib01e5062011-12-03 23:23:42 -0800592 TRAFIC_MODE = 0; // non burst mode with sync pulses
593 dprintf(SPEW, "Traffic mode: non burst mode with sync pulses\n");
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800594
Ajay Dudanib01e5062011-12-03 23:23:42 -0800595 writel(0x02020202, DSI_INT_CTRL);
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800596
Ajay Dudanib01e5062011-12-03 23:23:42 -0800597 writel(0x00100000 | DST_FORMAT, DSI_COMMAND_MODE_MDP_CTRL);
598 writel((img_width * ystride + 1) << 16 | 0x0039,
599 DSI_COMMAND_MODE_MDP_STREAM0_CTRL);
600 writel((img_width * ystride + 1) << 16 | 0x0039,
601 DSI_COMMAND_MODE_MDP_STREAM1_CTRL);
602 writel(img_height << 16 | img_width,
603 DSI_COMMAND_MODE_MDP_STREAM0_TOTAL);
604 writel(img_height << 16 | img_width,
605 DSI_COMMAND_MODE_MDP_STREAM1_TOTAL);
606 writel(0xEE, DSI_CAL_STRENGTH_CTRL);
607 writel(0x80000000, DSI_CAL_CTRL);
608 writel(0x40, DSI_TRIG_CTRL);
609 writel(0x13c2c, DSI_COMMAND_MODE_MDP_DCS_CMD_CTRL);
610 writel(interleav << 30 | 0 << 24 | 0 << 20 | DLNx_EN << 4 | 0x105,
611 DSI_CTRL);
612 mdelay(10);
613 writel(0x10000000, DSI_COMMAND_MODE_DMA_CTRL);
614 writel(0x10000000, DSI_MISR_CMD_CTRL);
615 writel(0x00000040, DSI_ERR_INT_MASK0);
616 writel(0x1, DSI_EOT_PACKET_CTRL);
617 // writel(0x0, MDP_OVERLAYPROC0_START);
618 mdp_start_dma();
619 mdelay(10);
620 writel(0x1, DSI_CMD_MODE_MDP_SW_TRIGGER);
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800621
Ajay Dudanib01e5062011-12-03 23:23:42 -0800622 status = 1;
623 return status;
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800624}
625
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800626int mipi_dsi_video_config(unsigned short num_of_lanes)
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700627{
628
Ajay Dudanib01e5062011-12-03 23:23:42 -0800629 int status = 0;
630 unsigned long ReadValue;
631 unsigned long count = 0;
632 unsigned long low_pwr_stop_mode = 0; // low power mode 0x1111 start from
633 // bit16, high spd mode 0x0
634 unsigned char eof_bllp_pwr = 0x9; // bit 12, 15, 1:low power stop mode or
635 // let cmd mode eng send packets in hs
636 // or lp mode
637 unsigned short image_wd = mipi_fb_cfg.width;
638 unsigned short image_ht = mipi_fb_cfg.height;
Ajay Dudanib01e5062011-12-03 23:23:42 -0800639 unsigned short display_wd = mipi_fb_cfg.width;
640 unsigned short display_ht = mipi_fb_cfg.height;
641 unsigned short hsync_porch_fp = MIPI_HSYNC_FRONT_PORCH_DCLK;
642 unsigned short hsync_porch_bp = MIPI_HSYNC_BACK_PORCH_DCLK;
643 unsigned short vsync_porch_fp = MIPI_VSYNC_FRONT_PORCH_LINES;
644 unsigned short vsync_porch_bp = MIPI_VSYNC_BACK_PORCH_LINES;
645 unsigned short hsync_width = MIPI_HSYNC_PULSE_WIDTH;
646 unsigned short vsync_width = MIPI_VSYNC_PULSE_WIDTH;
647 unsigned short dst_format = 0;
648 unsigned short traffic_mode = 0;
Ajay Dudanib01e5062011-12-03 23:23:42 -0800649 unsigned short pack_pattern = 0x12; //BGR
650 unsigned char ystride = 3;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700651
Ajay Dudanib01e5062011-12-03 23:23:42 -0800652 low_pwr_stop_mode = 0x1111; // low pwr mode bit16:HSA, bit20:HBA,
653 // bit24:HFP, bit28:PULSE MODE, need enough
654 // time for swithc from LP to HS
655 eof_bllp_pwr = 0x9; // low power stop mode or let cmd mode eng send
656 // packets in hs or lp mode
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700657
Ajay Dudanib01e5062011-12-03 23:23:42 -0800658 status +=
659 config_dsi_video_mode(display_wd, display_ht, image_wd, image_ht,
660 hsync_porch_fp, hsync_porch_bp,
661 vsync_porch_fp, vsync_porch_bp, hsync_width,
662 vsync_width, dst_format, traffic_mode,
663 num_of_lanes);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700664
Ajay Dudanib01e5062011-12-03 23:23:42 -0800665 status +=
666 mdp_setup_dma_p_video_mode(display_wd, display_ht, image_wd,
667 image_ht, hsync_porch_fp, hsync_porch_bp,
668 vsync_porch_fp, vsync_porch_bp,
669 hsync_width, vsync_width, MIPI_FB_ADDR,
670 image_wd, pack_pattern, ystride);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700671
Ajay Dudanib01e5062011-12-03 23:23:42 -0800672 ReadValue = readl(DSI_INT_CTRL) & 0x00010000;
673 while (ReadValue != 0x00010000) {
674 ReadValue = readl(DSI_INT_CTRL) & 0x00010000;
675 count++;
676 if (count > 0xffff) {
677 status = FAIL;
678 dprintf(CRITICAL, "Video lane test failed\n");
679 return status;
680 }
681 }
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700682
Ajay Dudanib01e5062011-12-03 23:23:42 -0800683 dprintf(SPEW, "Video lane tested successfully\n");
684 return status;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700685}
686
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800687int is_cmd_mode_enabled(void)
688{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800689 return cmd_mode_status;
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800690}
691
Kinson Chike5c93432011-06-17 09:10:29 -0700692#if DISPLAY_MIPI_PANEL_NOVATEK_BLUE
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800693void mipi_dsi_cmd_mode_trigger(void)
694{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800695 int status = 0;
696 unsigned short display_wd = mipi_fb_cfg.width;
697 unsigned short display_ht = mipi_fb_cfg.height;
698 unsigned short image_wd = mipi_fb_cfg.width;
699 unsigned short image_ht = mipi_fb_cfg.height;
700 unsigned short dst_format = 0;
701 unsigned short traffic_mode = 0;
702 struct mipi_dsi_panel_config *panel_info = &novatek_panel_info;
703 status += mipi_dsi_cmd_config(mipi_fb_cfg, panel_info->num_of_lanes);
704 mdelay(50);
705 config_dsi_cmd_mode(display_wd, display_ht, image_wd, image_ht,
706 dst_format, traffic_mode,
707 panel_info->num_of_lanes /* num_of_lanes */ );
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800708}
Kinson Chike5c93432011-06-17 09:10:29 -0700709#endif
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800710
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700711void mipi_dsi_shutdown(void)
712{
Amol Jadi6834f1a2012-06-29 14:42:59 -0700713 if(!target_cont_splash_screen())
714 {
715 mdp_shutdown();
716 writel(0x01010101, DSI_INT_CTRL);
717 writel(0x13FF3BFF, DSI_ERR_INT_MASK0);
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700718
719#if (DISPLAY_MIPI_PANEL_NOVATEK_BLUE \
Amol Jadi6834f1a2012-06-29 14:42:59 -0700720 || DISPLAY_MIPI_PANEL_TOSHIBA)
721 secure_writel(0x0, DSI_CC_REG);
722 secure_writel(0x0, DSI_PIXEL_CC_REG);
Kinson Chike5c93432011-06-17 09:10:29 -0700723#endif
Amol Jadi6834f1a2012-06-29 14:42:59 -0700724
725 writel(0, DSI_CLK_CTRL);
726 writel(0, DSI_CTRL);
727 writel(0, DSIPHY_PLL_CTRL(0));
728 }
729 else
730 {
Chandan Uddaraju4877d372011-07-21 12:51:51 -0700731 /* To keep the splash screen displayed till kernel driver takes
732 control, do not turn off the video mode engine and clocks.
733 Only disabling the MIPI DSI IRQs */
734 writel(0x01010101, DSI_INT_CTRL);
735 writel(0x13FF3BFF, DSI_ERR_INT_MASK0);
Amol Jadi6834f1a2012-06-29 14:42:59 -0700736 }
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700737}
738
739struct fbcon_config *mipi_init(void)
740{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800741 int status = 0;
742 struct mipi_dsi_panel_config *panel_info = get_panel_info();
Channagoud Kadabi539ef722012-03-29 16:02:50 +0530743
744 if (panel_info == NULL) {
745 dprintf(CRITICAL, "Panel info is null\n");
746 return NULL;
747 }
748
Ajay Dudanib01e5062011-12-03 23:23:42 -0800749 /* Enable MMSS_AHB_ARB_MATER_PORT_E for arbiter master0 and master 1 request */
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800750#if (!DISPLAY_MIPI_PANEL_RENESAS && !DISPLAY_TYPE_DSI6G)
Ajay Dudanib01e5062011-12-03 23:23:42 -0800751 writel(0x00001800, MMSS_SFPB_GPREG);
Aparna Mallavarapuf712f5e2011-08-04 21:11:00 +0530752#endif
Kinson Chike5c93432011-06-17 09:10:29 -0700753
754#if DISPLAY_MIPI_PANEL_TOSHIBA_MDT61
Ajay Dudanib01e5062011-12-03 23:23:42 -0800755 mipi_dsi_phy_init(panel_info);
Kinson Chike5c93432011-06-17 09:10:29 -0700756#else
Ajay Dudanib01e5062011-12-03 23:23:42 -0800757 mipi_dsi_phy_ctrl_config(panel_info);
Kinson Chike5c93432011-06-17 09:10:29 -0700758#endif
759
Ajay Dudanib01e5062011-12-03 23:23:42 -0800760 status += mipi_dsi_panel_initialize(panel_info);
Kinson Chike5c93432011-06-17 09:10:29 -0700761
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800762#if DISPLAY_MIPI_PANEL_NOVATEK_BLUE
Ajay Dudanib01e5062011-12-03 23:23:42 -0800763 mipi_dsi_cmd_bta_sw_trigger();
764 mipi_novatek_manufacture_id();
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800765#endif
Ajay Dudanib01e5062011-12-03 23:23:42 -0800766 mipi_fb_cfg.base = MIPI_FB_ADDR;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700767
Ajay Dudanib01e5062011-12-03 23:23:42 -0800768 if (panel_info->mode == MIPI_VIDEO_MODE)
769 status += mipi_dsi_video_config(panel_info->num_of_lanes);
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800770
Ajay Dudanib01e5062011-12-03 23:23:42 -0800771 if (panel_info->mode == MIPI_CMD_MODE)
772 cmd_mode_status = 1;
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800773
Ajay Dudanib01e5062011-12-03 23:23:42 -0800774 return &mipi_fb_cfg;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700775}
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700776
777int mipi_config(struct msm_fb_panel_data *panel)
778{
779 int ret = NO_ERROR;
780 struct msm_panel_info *pinfo;
781 struct mipi_dsi_panel_config mipi_pinfo;
782
783 if (!panel)
784 return ERR_INVALID_ARGS;
785
786 pinfo = &(panel->panel_info);
787 mipi_pinfo.mode = pinfo->mipi.mode;
788 mipi_pinfo.num_of_lanes = pinfo->mipi.num_of_lanes;
789 mipi_pinfo.dsi_phy_config = pinfo->mipi.dsi_phy_db;
790 mipi_pinfo.panel_cmds = pinfo->mipi.panel_cmds;
791 mipi_pinfo.num_of_panel_cmds = pinfo->mipi.num_of_panel_cmds;
Channagoud Kadabi539ef722012-03-29 16:02:50 +0530792 mipi_pinfo.lane_swap = pinfo->mipi.lane_swap;
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800793 mipi_pinfo.pack = 1;
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700794
795 /* Enable MMSS_AHB_ARB_MATER_PORT_E for
796 arbiter master0 and master 1 request */
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800797#if (!DISPLAY_MIPI_PANEL_RENESAS && !DISPLAY_TYPE_DSI6G)
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700798 writel(0x00001800, MMSS_SFPB_GPREG);
799#endif
800
801 mipi_dsi_phy_init(&mipi_pinfo);
802
803 ret += mipi_dsi_panel_initialize(&mipi_pinfo);
804
Channagoud Kadabi01c91822012-06-06 15:53:30 +0530805 if (pinfo->rotate && panel->rotate)
806 pinfo->rotate();
807
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700808 return ret;
809}
810
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700811int mdss_dsi_video_mode_config(uint16_t disp_width,
812 uint16_t disp_height,
813 uint16_t img_width,
814 uint16_t img_height,
815 uint16_t hsync_porch0_fp,
816 uint16_t hsync_porch0_bp,
817 uint16_t vsync_porch0_fp,
818 uint16_t vsync_porch0_bp,
819 uint16_t hsync_width,
820 uint16_t vsync_width,
821 uint16_t dst_format,
822 uint16_t traffic_mode,
823 uint8_t lane_en,
824 uint16_t low_pwr_stop_mode,
825 uint8_t eof_bllp_pwr,
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700826 uint8_t interleav,
827 uint32_t ctl_base)
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700828{
829
830 int status = 0;
831
832 /* disable mdp first */
833 mdp_disable();
834
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700835 writel(0x00000000, ctl_base + CLK_CTRL);
836 writel(0x00000002, ctl_base + CLK_CTRL);
837 writel(0x00000006, ctl_base + CLK_CTRL);
838 writel(0x0000000e, ctl_base + CLK_CTRL);
839 writel(0x0000001e, ctl_base + CLK_CTRL);
840 writel(0x0000023f, ctl_base + CLK_CTRL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700841
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700842 writel(0, ctl_base + CTRL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700843
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700844 writel(0, ctl_base + DSI_ERR_INT_MASK0);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700845
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700846 writel(0x02020202, ctl_base + INT_CTRL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700847
848 writel(((disp_width + hsync_porch0_bp) << 16) | hsync_porch0_bp,
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700849 ctl_base + VIDEO_MODE_ACTIVE_H);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700850
851 writel(((disp_height + vsync_porch0_bp) << 16) | (vsync_porch0_bp),
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700852 ctl_base + VIDEO_MODE_ACTIVE_V);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700853
854 if (mdp_get_revision() >= MDP_REV_41) {
855 writel(((disp_height + vsync_porch0_fp
856 + vsync_porch0_bp - 1) << 16)
857 | (disp_width + hsync_porch0_fp
858 + hsync_porch0_bp - 1),
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700859 ctl_base + VIDEO_MODE_TOTAL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700860 } else {
861 writel(((disp_height + vsync_porch0_fp
862 + vsync_porch0_bp) << 16)
863 | (disp_width + hsync_porch0_fp
864 + hsync_porch0_bp),
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700865 ctl_base + VIDEO_MODE_TOTAL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700866 }
867
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700868 writel((hsync_width << 16) | 0, ctl_base + VIDEO_MODE_HSYNC);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700869
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700870 writel(0 << 16 | 0, ctl_base + VIDEO_MODE_VSYNC);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700871
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700872 writel(vsync_width << 16 | 0, ctl_base + VIDEO_MODE_VSYNC_VPOS);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700873
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700874 writel(0x0, ctl_base + EOT_PACKET_CTRL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700875
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700876 writel(0x00000100, ctl_base + MISR_VIDEO_CTRL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700877
878 if (mdp_get_revision() >= MDP_REV_41) {
879 writel(low_pwr_stop_mode << 16 |
880 eof_bllp_pwr << 12 | traffic_mode << 8
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700881 | dst_format << 4 | 0x0, ctl_base + VIDEO_MODE_CTRL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700882 } else {
883 writel(1 << 28 | 1 << 24 | 1 << 20 | low_pwr_stop_mode << 16 |
884 eof_bllp_pwr << 12 | traffic_mode << 8
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700885 | dst_format << 4 | 0x0, ctl_base + VIDEO_MODE_CTRL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700886 }
887
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700888 writel(0x3fd08, ctl_base + HS_TIMER_CTRL);
889 writel(0x00010100, ctl_base + MISR_VIDEO_CTRL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700890
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700891 writel(0x00010100, ctl_base + INT_CTRL);
892 writel(0x02010202, ctl_base + INT_CTRL);
893 writel(0x02030303, ctl_base + INT_CTRL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700894
895 writel(interleav << 30 | 0 << 24 | 0 << 20 | lane_en << 4
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700896 | 0x103, ctl_base + CTRL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700897
898 return status;
899}
900
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800901int mdss_dsi_config(struct msm_fb_panel_data *panel)
902{
903 int ret = NO_ERROR;
904 struct msm_panel_info *pinfo;
905 struct mipi_dsi_panel_config mipi_pinfo;
906
907 if (!panel)
908 return ERR_INVALID_ARGS;
909
910 pinfo = &(panel->panel_info);
911 mipi_pinfo.mode = pinfo->mipi.mode;
912 mipi_pinfo.num_of_lanes = pinfo->mipi.num_of_lanes;
913 mipi_pinfo.mdss_dsi_phy_config = pinfo->mipi.mdss_dsi_phy_db;
914 mipi_pinfo.panel_cmds = pinfo->mipi.panel_cmds;
915 mipi_pinfo.num_of_panel_cmds = pinfo->mipi.num_of_panel_cmds;
916 mipi_pinfo.lane_swap = pinfo->mipi.lane_swap;
917 mipi_pinfo.pack = 0;
Siddhartha Agrawalb6c861f2013-05-31 19:36:44 -0700918 mipi_pinfo.t_clk_pre = pinfo->mipi.t_clk_pre;
919 mipi_pinfo.t_clk_post = pinfo->mipi.t_clk_post;
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800920
Siddhartha Agrawal1b2ed842013-05-29 18:02:28 -0700921 mdss_dsi_phy_init(&mipi_pinfo, MIPI_DSI0_BASE);
922 if (pinfo->mipi.dual_dsi)
923 mdss_dsi_phy_init(&mipi_pinfo, MIPI_DSI1_BASE);
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800924
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700925 ret += mdss_dsi_panel_initialize(&mipi_pinfo, pinfo->mipi.broadcast);
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800926
927 if (pinfo->rotate && panel->rotate)
928 pinfo->rotate();
929
930 return ret;
931}
932
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700933int mipi_dsi_video_mode_config(unsigned short disp_width,
934 unsigned short disp_height,
935 unsigned short img_width,
936 unsigned short img_height,
937 unsigned short hsync_porch0_fp,
938 unsigned short hsync_porch0_bp,
939 unsigned short vsync_porch0_fp,
940 unsigned short vsync_porch0_bp,
941 unsigned short hsync_width,
942 unsigned short vsync_width,
943 unsigned short dst_format,
944 unsigned short traffic_mode,
945 unsigned char lane_en,
946 unsigned low_pwr_stop_mode,
947 unsigned char eof_bllp_pwr,
948 unsigned char interleav)
949{
950
951 int status = 0;
952
953 /* disable mdp first */
954 mdp_disable();
955
956 writel(0x00000000, DSI_CLK_CTRL);
957 writel(0x00000000, DSI_CLK_CTRL);
958 writel(0x00000000, DSI_CLK_CTRL);
959 writel(0x00000000, DSI_CLK_CTRL);
960 writel(0x00000002, DSI_CLK_CTRL);
961 writel(0x00000006, DSI_CLK_CTRL);
962 writel(0x0000000e, DSI_CLK_CTRL);
963 writel(0x0000001e, DSI_CLK_CTRL);
Chandan Uddarajueb1decb2013-04-23 14:27:49 -0700964 writel(0x0000023f, DSI_CLK_CTRL);
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700965
966 writel(0, DSI_CTRL);
967
968 writel(0, DSI_ERR_INT_MASK0);
969
970 writel(0x02020202, DSI_INT_CTRL);
971
972 writel(((disp_width + hsync_porch0_bp) << 16) | hsync_porch0_bp,
973 DSI_VIDEO_MODE_ACTIVE_H);
974
975 writel(((disp_height + vsync_porch0_bp) << 16) | (vsync_porch0_bp),
976 DSI_VIDEO_MODE_ACTIVE_V);
977
978 if (mdp_get_revision() >= MDP_REV_41) {
979 writel(((disp_height + vsync_porch0_fp
980 + vsync_porch0_bp - 1) << 16)
981 | (disp_width + hsync_porch0_fp
982 + hsync_porch0_bp - 1),
983 DSI_VIDEO_MODE_TOTAL);
984 } else {
985 writel(((disp_height + vsync_porch0_fp
986 + vsync_porch0_bp) << 16)
987 | (disp_width + hsync_porch0_fp
988 + hsync_porch0_bp),
989 DSI_VIDEO_MODE_TOTAL);
990 }
991
992 writel((hsync_width << 16) | 0, DSI_VIDEO_MODE_HSYNC);
993
994 writel(0 << 16 | 0, DSI_VIDEO_MODE_VSYNC);
995
996 writel(vsync_width << 16 | 0, DSI_VIDEO_MODE_VSYNC_VPOS);
997
Chandan Uddarajueb1decb2013-04-23 14:27:49 -0700998 writel(0x0, DSI_EOT_PACKET_CTRL);
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700999
1000 writel(0x00000100, DSI_MISR_VIDEO_CTRL);
1001
Channagoud Kadabi539ef722012-03-29 16:02:50 +05301002 if (mdp_get_revision() >= MDP_REV_41) {
1003 writel(low_pwr_stop_mode << 16 |
1004 eof_bllp_pwr << 12 | traffic_mode << 8
1005 | dst_format << 4 | 0x0, DSI_VIDEO_MODE_CTRL);
1006 } else {
1007 writel(1 << 28 | 1 << 24 | 1 << 20 | low_pwr_stop_mode << 16 |
1008 eof_bllp_pwr << 12 | traffic_mode << 8
1009 | dst_format << 4 | 0x0, DSI_VIDEO_MODE_CTRL);
1010 }
Shashank Mittal4bfb2e32012-04-16 10:56:27 -07001011
Chandan Uddarajueb1decb2013-04-23 14:27:49 -07001012 writel(0x3fd08, DSI_HS_TIMER_CTRL);
Shashank Mittal4bfb2e32012-04-16 10:56:27 -07001013 writel(0x67, DSI_CAL_STRENGTH_CTRL);
1014 writel(0x80006711, DSI_CAL_CTRL);
1015 writel(0x00010100, DSI_MISR_VIDEO_CTRL);
1016
1017 writel(0x00010100, DSI_INT_CTRL);
1018 writel(0x02010202, DSI_INT_CTRL);
1019 writel(0x02030303, DSI_INT_CTRL);
1020
1021 writel(interleav << 30 | 0 << 24 | 0 << 20 | lane_en << 4
1022 | 0x103, DSI_CTRL);
1023
1024 return status;
1025}
1026
Siddhartha Agrawal7317e482013-04-21 16:16:57 -07001027int mdss_dsi_cmd_mode_config(uint16_t disp_width,
1028 uint16_t disp_height,
1029 uint16_t img_width,
1030 uint16_t img_height,
1031 uint16_t dst_format,
1032 uint16_t traffic_mode)
1033{
1034 uint8_t DST_FORMAT;
1035 uint8_t TRAFIC_MODE;
1036 uint8_t DLNx_EN;
1037 // video mode data ctrl
1038 int status = 0;
1039 uint8_t interleav = 0;
1040 uint8_t ystride = 0x03;
1041 // disable mdp first
1042
1043 writel(0x00000000, DSI_CLK_CTRL);
1044 writel(0x00000000, DSI_CLK_CTRL);
1045 writel(0x00000000, DSI_CLK_CTRL);
1046 writel(0x00000000, DSI_CLK_CTRL);
1047 writel(0x00000002, DSI_CLK_CTRL);
1048 writel(0x00000006, DSI_CLK_CTRL);
1049 writel(0x0000000e, DSI_CLK_CTRL);
1050 writel(0x0000001e, DSI_CLK_CTRL);
1051 writel(0x0000023f, DSI_CLK_CTRL);
1052
1053 writel(0, DSI_CTRL);
1054
1055 writel(0, DSI_ERR_INT_MASK0);
1056
1057 writel(0x02020202, DSI_INT_CTRL);
1058
1059 DST_FORMAT = 8; // RGB888
1060 dprintf(SPEW, "DSI_Cmd_Mode - Dst Format: RGB888\n");
1061
1062 DLNx_EN = 0xf; // 4 lane with clk programming
1063 dprintf(SPEW, "Data Lane: 4 lane\n");
1064
1065 TRAFIC_MODE = 0; // non burst mode with sync pulses
1066 dprintf(SPEW, "Traffic mode: non burst mode with sync pulses\n");
1067
1068 writel(DST_FORMAT, DSI_COMMAND_MODE_MDP_CTRL);
1069 writel((img_width * ystride + 1) << 16 | 0x0039,
1070 DSI_COMMAND_MODE_MDP_STREAM0_CTRL);
1071 writel((img_width * ystride + 1) << 16 | 0x0039,
1072 DSI_COMMAND_MODE_MDP_STREAM1_CTRL);
1073 writel(img_height << 16 | img_width,
1074 DSI_COMMAND_MODE_MDP_STREAM0_TOTAL);
1075 writel(img_height << 16 | img_width,
1076 DSI_COMMAND_MODE_MDP_STREAM1_TOTAL);
1077 writel(0x13c2c, DSI_COMMAND_MODE_MDP_DCS_CMD_CTRL);
1078 writel(interleav << 30 | 0 << 24 | 0 << 20 | DLNx_EN << 4 | 0x105,
1079 DSI_CTRL);
1080 writel(0x10000000, DSI_COMMAND_MODE_DMA_CTRL);
1081 writel(0x10000000, DSI_MISR_CMD_CTRL);
1082
1083 return NO_ERROR;
1084}
1085
Channagoud Kadabi10189fd2012-05-25 13:33:39 +05301086int mipi_dsi_cmd_mode_config(unsigned short disp_width,
1087 unsigned short disp_height,
1088 unsigned short img_width,
1089 unsigned short img_height,
1090 unsigned short dst_format,
1091 unsigned short traffic_mode)
1092{
1093 unsigned char DST_FORMAT;
1094 unsigned char TRAFIC_MODE;
1095 unsigned char DLNx_EN;
1096 // video mode data ctrl
1097 int status = 0;
1098 unsigned char interleav = 0;
1099 unsigned char ystride = 0x03;
1100 // disable mdp first
1101
1102 writel(0x00000000, DSI_CLK_CTRL);
1103 writel(0x00000000, DSI_CLK_CTRL);
1104 writel(0x00000000, DSI_CLK_CTRL);
1105 writel(0x00000000, DSI_CLK_CTRL);
1106 writel(0x00000002, DSI_CLK_CTRL);
1107 writel(0x00000006, DSI_CLK_CTRL);
1108 writel(0x0000000e, DSI_CLK_CTRL);
1109 writel(0x0000001e, DSI_CLK_CTRL);
1110 writel(0x0000003e, DSI_CLK_CTRL);
1111
1112 writel(0x10000000, DSI_ERR_INT_MASK0);
1113
1114
1115 DST_FORMAT = 8; // RGB888
1116 dprintf(SPEW, "DSI_Cmd_Mode - Dst Format: RGB888\n");
1117
1118 DLNx_EN = 3; // 2 lane with clk programming
1119 dprintf(SPEW, "Data Lane: 2 lane\n");
1120
1121 TRAFIC_MODE = 0; // non burst mode with sync pulses
1122 dprintf(SPEW, "Traffic mode: non burst mode with sync pulses\n");
1123
1124 writel(0x02020202, DSI_INT_CTRL);
1125
1126 writel(0x00100000 | DST_FORMAT, DSI_COMMAND_MODE_MDP_CTRL);
1127 writel((img_width * ystride + 1) << 16 | 0x0039,
1128 DSI_COMMAND_MODE_MDP_STREAM0_CTRL);
1129 writel((img_width * ystride + 1) << 16 | 0x0039,
1130 DSI_COMMAND_MODE_MDP_STREAM1_CTRL);
1131 writel(img_height << 16 | img_width,
1132 DSI_COMMAND_MODE_MDP_STREAM0_TOTAL);
1133 writel(img_height << 16 | img_width,
1134 DSI_COMMAND_MODE_MDP_STREAM1_TOTAL);
1135 writel(0xEE, DSI_CAL_STRENGTH_CTRL);
1136 writel(0x80000000, DSI_CAL_CTRL);
1137 writel(0x40, DSI_TRIG_CTRL);
1138 writel(0x13c2c, DSI_COMMAND_MODE_MDP_DCS_CMD_CTRL);
1139 writel(interleav << 30 | 0 << 24 | 0 << 20 | DLNx_EN << 4 | 0x105,
1140 DSI_CTRL);
1141 writel(0x10000000, DSI_COMMAND_MODE_DMA_CTRL);
1142 writel(0x10000000, DSI_MISR_CMD_CTRL);
1143 writel(0x00000040, DSI_ERR_INT_MASK0);
1144 writel(0x1, DSI_EOT_PACKET_CTRL);
1145
1146 return NO_ERROR;
1147}
1148
Shashank Mittal4bfb2e32012-04-16 10:56:27 -07001149int mipi_dsi_on()
1150{
1151 int ret = NO_ERROR;
1152 unsigned long ReadValue;
1153 unsigned long count = 0;
1154
1155 ReadValue = readl(DSI_INT_CTRL) & 0x00010000;
1156
1157 mdelay(10);
1158
1159 while (ReadValue != 0x00010000) {
1160 ReadValue = readl(DSI_INT_CTRL) & 0x00010000;
1161 count++;
1162 if (count > 0xffff) {
1163 dprintf(CRITICAL, "Video lane test failed\n");
1164 return ERROR;
1165 }
1166 }
1167
Amir Samuelov2d4ba162012-07-22 11:53:14 +03001168 dprintf(INFO, "Video lane tested successfully\n");
Shashank Mittal4bfb2e32012-04-16 10:56:27 -07001169 return ret;
1170}
1171
1172int mipi_dsi_off()
1173{
Amol Jadi6834f1a2012-06-29 14:42:59 -07001174 if(!target_cont_splash_screen())
1175 {
1176 writel(0, DSI_CLK_CTRL);
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -08001177 writel(0x1F1, DSI_CTRL);
1178 writel(0x00000001, DSIPHY_SW_RESET);
1179 writel(0x00000000, DSIPHY_SW_RESET);
1180 mdelay(10);
1181 writel(0x0001, DSI_SOFT_RESET);
1182 writel(0x0000, DSI_SOFT_RESET);
Siddhartha Agrawale0033a12013-02-23 15:37:42 -08001183 writel(0x1115501, DSI_INT_CTRL);
Amol Jadi6834f1a2012-06-29 14:42:59 -07001184 writel(0, DSI_CTRL);
Siddhartha Agrawale0033a12013-02-23 15:37:42 -08001185 }
1186
1187 writel(0x1115501, DSI_INT_CTRL);
Shashank Mittal4bfb2e32012-04-16 10:56:27 -07001188
1189 return NO_ERROR;
1190}
Channagoud Kadabi10189fd2012-05-25 13:33:39 +05301191
1192int mipi_cmd_trigger()
1193{
1194 writel(0x1, DSI_CMD_MODE_MDP_SW_TRIGGER);
1195
1196 return NO_ERROR;
1197}