blob: bbda3142898aca248de8c8ac11a2ae99129ba6c9 [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
Terence Hampsoncc3345c2013-06-27 15:30:10 -0400124#if (DISPLAY_TYPE_MDSS == 1)
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700125 writel(0x03030303, MIPI_DSI0_BASE + INT_CTRL);
126 writel(0x1, MIPI_DSI0_BASE + CMD_MODE_DMA_SW_TRIGGER);
127 dsb();
128
129 writel(0x03030303, MIPI_DSI1_BASE + INT_CTRL);
130 writel(0x1, MIPI_DSI1_BASE + CMD_MODE_DMA_SW_TRIGGER);
131 dsb();
132
133 ReadValue = readl(MIPI_DSI1_BASE + INT_CTRL) & 0x00000001;
134 while (ReadValue != 0x00000001) {
135 ReadValue = readl(MIPI_DSI1_BASE + INT_CTRL) & 0x00000001;
136 count++;
137 if (count > 0xffff) {
138 status = FAIL;
139 dprintf(CRITICAL,
140 "Panel CMD: command mode dma test failed\n");
141 return status;
142 }
143 }
144
145 writel((readl(MIPI_DSI1_BASE + INT_CTRL) | 0x01000001),
146 MIPI_DSI1_BASE + INT_CTRL);
147 dprintf(SPEW, "Panel CMD: command mode dma tested successfully\n");
Terence Hampsoncc3345c2013-06-27 15:30:10 -0400148#endif
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700149 return status;
150}
151
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700152int dsi_cmd_dma_trigger_for_panel()
153{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800154 unsigned long ReadValue;
155 unsigned long count = 0;
156 int status = 0;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700157
Ajay Dudanib01e5062011-12-03 23:23:42 -0800158 writel(0x03030303, DSI_INT_CTRL);
159 writel(0x1, DSI_CMD_MODE_DMA_SW_TRIGGER);
160 dsb();
161 ReadValue = readl(DSI_INT_CTRL) & 0x00000001;
162 while (ReadValue != 0x00000001) {
163 ReadValue = readl(DSI_INT_CTRL) & 0x00000001;
164 count++;
165 if (count > 0xffff) {
166 status = FAIL;
167 dprintf(CRITICAL,
168 "Panel CMD: command mode dma test failed\n");
169 return status;
170 }
171 }
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700172
Ajay Dudanib01e5062011-12-03 23:23:42 -0800173 writel((readl(DSI_INT_CTRL) | 0x01000001), DSI_INT_CTRL);
174 dprintf(SPEW, "Panel CMD: command mode dma tested successfully\n");
175 return status;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700176}
177
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700178int mdss_dual_dsi_cmds_tx(struct mipi_dsi_cmd *cmds, int count)
179{
180 int ret = 0;
181 struct mipi_dsi_cmd *cm;
182 int i = 0;
183 char pload[256];
184 uint32_t off;
185
Terence Hampsoncc3345c2013-06-27 15:30:10 -0400186#if (DISPLAY_TYPE_MDSS == 1)
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700187 /* Align pload at 8 byte boundry */
188 off = pload;
189 off &= 0x07;
190 if (off)
191 off = 8 - off;
192 off += pload;
193
194 cm = cmds;
195 for (i = 0; i < count; i++) {
196 memcpy((void *)off, (cm->payload), cm->size);
197 writel(off, MIPI_DSI0_BASE + DMA_CMD_OFFSET);
198 writel(cm->size, MIPI_DSI0_BASE + DMA_CMD_LENGTH); // reg 0x48 for this build
199 writel(off, MIPI_DSI1_BASE + DMA_CMD_OFFSET);
200 writel(cm->size, MIPI_DSI1_BASE + DMA_CMD_LENGTH); // reg 0x48 for this build
201 dsb();
202 ret += mdss_dual_dsi_cmd_dma_trigger_for_panel();
203 udelay(80);
204 cm++;
205 }
Terence Hampsoncc3345c2013-06-27 15:30:10 -0400206#endif
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700207 return ret;
208}
209
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800210int mipi_dsi_cmds_tx(struct mipi_dsi_cmd *cmds, int count)
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700211{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800212 int ret = 0;
213 struct mipi_dsi_cmd *cm;
214 int i = 0;
215 char pload[256];
216 uint32_t off;
Deepa Dinamania080a402011-11-05 18:59:26 -0700217
Ajay Dudanib01e5062011-12-03 23:23:42 -0800218 /* Align pload at 8 byte boundry */
219 off = pload;
220 off &= 0x07;
221 if (off)
222 off = 8 - off;
223 off += pload;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700224
Ajay Dudanib01e5062011-12-03 23:23:42 -0800225 cm = cmds;
226 for (i = 0; i < count; i++) {
227 memcpy((void *)off, (cm->payload), cm->size);
228 writel(off, DSI_DMA_CMD_OFFSET);
229 writel(cm->size, DSI_DMA_CMD_LENGTH); // reg 0x48 for this build
230 dsb();
231 ret += dsi_cmd_dma_trigger_for_panel();
232 udelay(80);
233 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
Terence Hampsoncc3345c2013-06-27 15:30:10 -0400343#if (DISPLAY_TYPE_MDSS == 1)
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700344 switch (pinfo->num_of_lanes) {
345 default:
346 case 1:
347 DLNx_EN = 1; // 1 lane
348 break;
349 case 2:
350 DLNx_EN = 3; // 2 lane
351 break;
352 case 3:
353 DLNx_EN = 7; // 3 lane
354 break;
355 case 4:
356 DLNx_EN = 0x0F; /* 4 lanes */
357 break;
358 }
359
360 PACK_TYPE1 = pinfo->pack;
Siddhartha Agrawal2679a822013-05-31 19:15:12 -0700361 lane_swap = pinfo->lane_swap;
Siddhartha Agrawalb6c861f2013-05-31 19:36:44 -0700362 timing_ctl = ((pinfo->t_clk_post << 8) | pinfo->t_clk_pre);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700363
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700364 if (broadcast) {
365 writel(0x0001, MIPI_DSI1_BASE + SOFT_RESET);
366 writel(0x0000, MIPI_DSI1_BASE + SOFT_RESET);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700367
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700368 writel((0 << 16) | 0x3f, MIPI_DSI1_BASE + CLK_CTRL); /* Turn on all DSI Clks */
369 writel(DMA_STREAM1 << 8 | 0x04, MIPI_DSI1_BASE + TRIG_CTRL); // reg 0x80 dma trigger: sw
370 // trigger 0x4; dma stream1
371
372 writel(0 << 30 | DLNx_EN << 4 | 0x105, MIPI_DSI1_BASE + CTRL); // reg 0x00 for this
373 // build
374 writel(broadcast << 31 | EMBED_MODE1 << 28 | POWER_MODE2 << 26
375 | PACK_TYPE1 << 24 | VC1 << 22 | DT1 << 16 | WC1,
376 MIPI_DSI1_BASE + COMMAND_MODE_DMA_CTRL);
Siddhartha Agrawal2679a822013-05-31 19:15:12 -0700377
378 writel(lane_swap, MIPI_DSI1_BASE + LANE_SWAP_CTL);
Siddhartha Agrawalb6c861f2013-05-31 19:36:44 -0700379 writel(timing_ctl, MIPI_DSI1_BASE + TIMING_CTL);
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700380 }
381
382 writel(0x0001, MIPI_DSI0_BASE + SOFT_RESET);
383 writel(0x0000, MIPI_DSI0_BASE + SOFT_RESET);
384
385 writel((0 << 16) | 0x3f, MIPI_DSI0_BASE + CLK_CTRL); /* Turn on all DSI Clks */
386 writel(DMA_STREAM1 << 8 | 0x04, MIPI_DSI0_BASE + TRIG_CTRL); // reg 0x80 dma trigger: sw
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700387 // trigger 0x4; dma stream1
388
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700389 writel(0 << 30 | DLNx_EN << 4 | 0x105, MIPI_DSI0_BASE + CTRL); // reg 0x00 for this
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700390 // build
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700391 writel(broadcast << 31 | EMBED_MODE1 << 28 | POWER_MODE2 << 26
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700392 | PACK_TYPE1 << 24 | VC1 << 22 | DT1 << 16 | WC1,
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700393 MIPI_DSI0_BASE + COMMAND_MODE_DMA_CTRL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700394
Siddhartha Agrawal2679a822013-05-31 19:15:12 -0700395 writel(lane_swap, MIPI_DSI0_BASE + LANE_SWAP_CTL);
Siddhartha Agrawalb6c861f2013-05-31 19:36:44 -0700396 writel(timing_ctl, MIPI_DSI0_BASE + TIMING_CTL);
Siddhartha Agrawal2679a822013-05-31 19:15:12 -0700397
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700398 if (pinfo->panel_cmds) {
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700399
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700400 if (broadcast) {
401 status = mdss_dual_dsi_cmds_tx(pinfo->panel_cmds,
402 pinfo->num_of_panel_cmds);
403
404 } else {
405 status = mipi_dsi_cmds_tx(pinfo->panel_cmds,
406 pinfo->num_of_panel_cmds);
407 }
408 }
Terence Hampsoncc3345c2013-06-27 15:30:10 -0400409#endif
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700410 return status;
411}
412
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800413int mipi_dsi_panel_initialize(struct mipi_dsi_panel_config *pinfo)
414{
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800415 uint8_t DMA_STREAM1 = 0; // for mdp display processor path
416 uint8_t EMBED_MODE1 = 1; // from frame buffer
417 uint8_t POWER_MODE2 = 1; // from frame buffer
418 uint8_t PACK_TYPE1; // long packet
419 uint8_t VC1 = 0;
420 uint8_t DT1 = 0; // non embedded mode
421 uint8_t WC1 = 0; // for non embedded mode only
Ajay Dudanib01e5062011-12-03 23:23:42 -0800422 int status = 0;
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800423 uint8_t DLNx_EN;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700424
Ajay Dudanib01e5062011-12-03 23:23:42 -0800425 switch (pinfo->num_of_lanes) {
426 default:
427 case 1:
428 DLNx_EN = 1; // 1 lane
429 break;
430 case 2:
431 DLNx_EN = 3; // 2 lane
432 break;
433 case 3:
434 DLNx_EN = 7; // 3 lane
435 break;
Amir Samuelov2d4ba162012-07-22 11:53:14 +0300436 case 4:
437 DLNx_EN = 0x0F; /* 4 lanes */
438 break;
Ajay Dudanib01e5062011-12-03 23:23:42 -0800439 }
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800440
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800441 PACK_TYPE1 = pinfo->pack;
442
Ajay Dudanib01e5062011-12-03 23:23:42 -0800443 writel(0x0001, DSI_SOFT_RESET);
444 writel(0x0000, DSI_SOFT_RESET);
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800445
Ajay Dudanib01e5062011-12-03 23:23:42 -0800446 writel((0 << 16) | 0x3f, DSI_CLK_CTRL); /* Turn on all DSI Clks */
447 writel(DMA_STREAM1 << 8 | 0x04, DSI_TRIG_CTRL); // reg 0x80 dma trigger: sw
448 // trigger 0x4; dma stream1
Kinson Chike5c93432011-06-17 09:10:29 -0700449
Ajay Dudanib01e5062011-12-03 23:23:42 -0800450 writel(0 << 30 | DLNx_EN << 4 | 0x105, DSI_CTRL); // reg 0x00 for this
451 // build
452 writel(EMBED_MODE1 << 28 | POWER_MODE2 << 26
453 | PACK_TYPE1 << 24 | VC1 << 22 | DT1 << 16 | WC1,
454 DSI_COMMAND_MODE_DMA_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700455
Amir Samuelov2d4ba162012-07-22 11:53:14 +0300456 if (pinfo->panel_cmds)
457 status = mipi_dsi_cmds_tx(pinfo->panel_cmds,
458 pinfo->num_of_panel_cmds);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700459
Ajay Dudanib01e5062011-12-03 23:23:42 -0800460 return status;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700461}
462
Kinson Chike5c93432011-06-17 09:10:29 -0700463//TODO: Clean up arguments being passed in not being used
Ajay Dudanib01e5062011-12-03 23:23:42 -0800464int
465config_dsi_video_mode(unsigned short disp_width, unsigned short disp_height,
466 unsigned short img_width, unsigned short img_height,
467 unsigned short hsync_porch0_fp,
468 unsigned short hsync_porch0_bp,
469 unsigned short vsync_porch0_fp,
470 unsigned short vsync_porch0_bp,
471 unsigned short hsync_width,
472 unsigned short vsync_width, unsigned short dst_format,
473 unsigned short traffic_mode, unsigned short datalane_num)
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700474{
475
Ajay Dudanib01e5062011-12-03 23:23:42 -0800476 unsigned char DST_FORMAT;
477 unsigned char TRAFIC_MODE;
478 unsigned char DLNx_EN;
479 // video mode data ctrl
480 int status = 0;
481 unsigned long low_pwr_stop_mode = 0;
482 unsigned char eof_bllp_pwr = 0x9;
483 unsigned char interleav = 0;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700484
Ajay Dudanib01e5062011-12-03 23:23:42 -0800485 // disable mdp first
486 mdp_disable();
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700487
Ajay Dudanib01e5062011-12-03 23:23:42 -0800488 writel(0x00000000, DSI_CLK_CTRL);
489 writel(0x00000000, DSI_CLK_CTRL);
490 writel(0x00000000, DSI_CLK_CTRL);
491 writel(0x00000000, DSI_CLK_CTRL);
492 writel(0x00000002, DSI_CLK_CTRL);
493 writel(0x00000006, DSI_CLK_CTRL);
494 writel(0x0000000e, DSI_CLK_CTRL);
495 writel(0x0000001e, DSI_CLK_CTRL);
496 writel(0x0000003e, DSI_CLK_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700497
Ajay Dudanib01e5062011-12-03 23:23:42 -0800498 writel(0, DSI_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700499
Ajay Dudanib01e5062011-12-03 23:23:42 -0800500 writel(0, DSI_ERR_INT_MASK0);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700501
Ajay Dudanib01e5062011-12-03 23:23:42 -0800502 DST_FORMAT = 0; // RGB565
503 dprintf(SPEW, "DSI_Video_Mode - Dst Format: RGB565\n");
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700504
Ajay Dudanib01e5062011-12-03 23:23:42 -0800505 DLNx_EN = 1; // 1 lane with clk programming
506 dprintf(SPEW, "Data Lane: 1 lane\n");
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700507
Ajay Dudanib01e5062011-12-03 23:23:42 -0800508 TRAFIC_MODE = 0; // non burst mode with sync pulses
509 dprintf(SPEW, "Traffic mode: non burst mode with sync pulses\n");
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700510
Ajay Dudanib01e5062011-12-03 23:23:42 -0800511 writel(0x02020202, DSI_INT_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700512
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800513 writel(((hsync_width + img_width + hsync_porch0_bp) << 16)
514 | (hsync_width + hsync_porch0_bp),
Ajay Dudanib01e5062011-12-03 23:23:42 -0800515 DSI_VIDEO_MODE_ACTIVE_H);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700516
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800517 writel(((vsync_width + img_height + vsync_porch0_bp) << 16)
518 | (vsync_width + vsync_porch0_bp),
Ajay Dudanib01e5062011-12-03 23:23:42 -0800519 DSI_VIDEO_MODE_ACTIVE_V);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700520
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800521 writel(((vsync_width + img_height + vsync_porch0_fp + vsync_porch0_bp - 1) << 16)
522 | (hsync_width + img_width + hsync_porch0_fp + hsync_porch0_bp - 1),
Ajay Dudanib01e5062011-12-03 23:23:42 -0800523 DSI_VIDEO_MODE_TOTAL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700524
Ajay Dudanib01e5062011-12-03 23:23:42 -0800525 writel((hsync_width << 16) | 0, DSI_VIDEO_MODE_HSYNC);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700526
Ajay Dudanib01e5062011-12-03 23:23:42 -0800527 writel(0 << 16 | 0, DSI_VIDEO_MODE_VSYNC);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700528
Ajay Dudanib01e5062011-12-03 23:23:42 -0800529 writel(vsync_width << 16 | 0, DSI_VIDEO_MODE_VSYNC_VPOS);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700530
Ajay Dudanib01e5062011-12-03 23:23:42 -0800531 writel(1, DSI_EOT_PACKET_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700532
Ajay Dudanib01e5062011-12-03 23:23:42 -0800533 writel(0x00000100, DSI_MISR_VIDEO_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700534
Ajay Dudanib01e5062011-12-03 23:23:42 -0800535 writel(low_pwr_stop_mode << 16 | eof_bllp_pwr << 12 | TRAFIC_MODE << 8
536 | DST_FORMAT << 4 | 0x0, DSI_VIDEO_MODE_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700537
Ajay Dudanib01e5062011-12-03 23:23:42 -0800538 writel(0x67, DSI_CAL_STRENGTH_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700539
Ajay Dudanib01e5062011-12-03 23:23:42 -0800540 writel(0x80006711, DSI_CAL_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700541
Ajay Dudanib01e5062011-12-03 23:23:42 -0800542 writel(0x00010100, DSI_MISR_VIDEO_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700543
Ajay Dudanib01e5062011-12-03 23:23:42 -0800544 writel(0x00010100, DSI_INT_CTRL);
545 writel(0x02010202, DSI_INT_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700546
Ajay Dudanib01e5062011-12-03 23:23:42 -0800547 writel(0x02030303, DSI_INT_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700548
Ajay Dudanib01e5062011-12-03 23:23:42 -0800549 writel(interleav << 30 | 0 << 24 | 0 << 20 | DLNx_EN << 4
550 | 0x103, DSI_CTRL);
551 mdelay(10);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700552
Ajay Dudanib01e5062011-12-03 23:23:42 -0800553 return status;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700554}
555
Ajay Dudanib01e5062011-12-03 23:23:42 -0800556int
557config_dsi_cmd_mode(unsigned short disp_width, unsigned short disp_height,
558 unsigned short img_width, unsigned short img_height,
559 unsigned short dst_format,
560 unsigned short traffic_mode, unsigned short datalane_num)
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800561{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800562 unsigned char DST_FORMAT;
563 unsigned char TRAFIC_MODE;
564 unsigned char DLNx_EN;
565 // video mode data ctrl
566 int status = 0;
Greg Griscod6250552011-06-29 14:40:23 -0700567 unsigned char interleav = 0;
568 unsigned char ystride = 0x03;
Ajay Dudanib01e5062011-12-03 23:23:42 -0800569 // disable mdp first
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800570
Ajay Dudanib01e5062011-12-03 23:23:42 -0800571 writel(0x00000000, DSI_CLK_CTRL);
572 writel(0x00000000, DSI_CLK_CTRL);
573 writel(0x00000000, DSI_CLK_CTRL);
574 writel(0x00000000, DSI_CLK_CTRL);
575 writel(0x00000002, DSI_CLK_CTRL);
576 writel(0x00000006, DSI_CLK_CTRL);
577 writel(0x0000000e, DSI_CLK_CTRL);
578 writel(0x0000001e, DSI_CLK_CTRL);
579 writel(0x0000003e, DSI_CLK_CTRL);
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800580
Ajay Dudanib01e5062011-12-03 23:23:42 -0800581 writel(0x10000000, DSI_ERR_INT_MASK0);
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800582
Ajay Dudanib01e5062011-12-03 23:23:42 -0800583 // writel(0, DSI_CTRL);
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800584
Ajay Dudanib01e5062011-12-03 23:23:42 -0800585 // writel(0, DSI_ERR_INT_MASK0);
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800586
Ajay Dudanib01e5062011-12-03 23:23:42 -0800587 DST_FORMAT = 8; // RGB888
588 dprintf(SPEW, "DSI_Cmd_Mode - Dst Format: RGB888\n");
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800589
Ajay Dudanib01e5062011-12-03 23:23:42 -0800590 DLNx_EN = 3; // 2 lane with clk programming
591 dprintf(SPEW, "Data Lane: 2 lane\n");
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800592
Ajay Dudanib01e5062011-12-03 23:23:42 -0800593 TRAFIC_MODE = 0; // non burst mode with sync pulses
594 dprintf(SPEW, "Traffic mode: non burst mode with sync pulses\n");
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800595
Ajay Dudanib01e5062011-12-03 23:23:42 -0800596 writel(0x02020202, DSI_INT_CTRL);
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800597
Ajay Dudanib01e5062011-12-03 23:23:42 -0800598 writel(0x00100000 | DST_FORMAT, DSI_COMMAND_MODE_MDP_CTRL);
599 writel((img_width * ystride + 1) << 16 | 0x0039,
600 DSI_COMMAND_MODE_MDP_STREAM0_CTRL);
601 writel((img_width * ystride + 1) << 16 | 0x0039,
602 DSI_COMMAND_MODE_MDP_STREAM1_CTRL);
603 writel(img_height << 16 | img_width,
604 DSI_COMMAND_MODE_MDP_STREAM0_TOTAL);
605 writel(img_height << 16 | img_width,
606 DSI_COMMAND_MODE_MDP_STREAM1_TOTAL);
607 writel(0xEE, DSI_CAL_STRENGTH_CTRL);
608 writel(0x80000000, DSI_CAL_CTRL);
609 writel(0x40, DSI_TRIG_CTRL);
610 writel(0x13c2c, DSI_COMMAND_MODE_MDP_DCS_CMD_CTRL);
611 writel(interleav << 30 | 0 << 24 | 0 << 20 | DLNx_EN << 4 | 0x105,
612 DSI_CTRL);
613 mdelay(10);
614 writel(0x10000000, DSI_COMMAND_MODE_DMA_CTRL);
615 writel(0x10000000, DSI_MISR_CMD_CTRL);
616 writel(0x00000040, DSI_ERR_INT_MASK0);
617 writel(0x1, DSI_EOT_PACKET_CTRL);
618 // writel(0x0, MDP_OVERLAYPROC0_START);
619 mdp_start_dma();
620 mdelay(10);
621 writel(0x1, DSI_CMD_MODE_MDP_SW_TRIGGER);
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800622
Ajay Dudanib01e5062011-12-03 23:23:42 -0800623 status = 1;
624 return status;
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800625}
626
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800627int mipi_dsi_video_config(unsigned short num_of_lanes)
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700628{
629
Ajay Dudanib01e5062011-12-03 23:23:42 -0800630 int status = 0;
631 unsigned long ReadValue;
632 unsigned long count = 0;
633 unsigned long low_pwr_stop_mode = 0; // low power mode 0x1111 start from
634 // bit16, high spd mode 0x0
635 unsigned char eof_bllp_pwr = 0x9; // bit 12, 15, 1:low power stop mode or
636 // let cmd mode eng send packets in hs
637 // or lp mode
638 unsigned short image_wd = mipi_fb_cfg.width;
639 unsigned short image_ht = mipi_fb_cfg.height;
Ajay Dudanib01e5062011-12-03 23:23:42 -0800640 unsigned short display_wd = mipi_fb_cfg.width;
641 unsigned short display_ht = mipi_fb_cfg.height;
642 unsigned short hsync_porch_fp = MIPI_HSYNC_FRONT_PORCH_DCLK;
643 unsigned short hsync_porch_bp = MIPI_HSYNC_BACK_PORCH_DCLK;
644 unsigned short vsync_porch_fp = MIPI_VSYNC_FRONT_PORCH_LINES;
645 unsigned short vsync_porch_bp = MIPI_VSYNC_BACK_PORCH_LINES;
646 unsigned short hsync_width = MIPI_HSYNC_PULSE_WIDTH;
647 unsigned short vsync_width = MIPI_VSYNC_PULSE_WIDTH;
648 unsigned short dst_format = 0;
649 unsigned short traffic_mode = 0;
Ajay Dudanib01e5062011-12-03 23:23:42 -0800650 unsigned short pack_pattern = 0x12; //BGR
651 unsigned char ystride = 3;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700652
Ajay Dudanib01e5062011-12-03 23:23:42 -0800653 low_pwr_stop_mode = 0x1111; // low pwr mode bit16:HSA, bit20:HBA,
654 // bit24:HFP, bit28:PULSE MODE, need enough
655 // time for swithc from LP to HS
656 eof_bllp_pwr = 0x9; // low power stop mode or let cmd mode eng send
657 // packets in hs or lp mode
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700658
Ajay Dudanib01e5062011-12-03 23:23:42 -0800659 status +=
660 config_dsi_video_mode(display_wd, display_ht, image_wd, image_ht,
661 hsync_porch_fp, hsync_porch_bp,
662 vsync_porch_fp, vsync_porch_bp, hsync_width,
663 vsync_width, dst_format, traffic_mode,
664 num_of_lanes);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700665
Ajay Dudanib01e5062011-12-03 23:23:42 -0800666 status +=
667 mdp_setup_dma_p_video_mode(display_wd, display_ht, image_wd,
668 image_ht, hsync_porch_fp, hsync_porch_bp,
669 vsync_porch_fp, vsync_porch_bp,
670 hsync_width, vsync_width, MIPI_FB_ADDR,
671 image_wd, pack_pattern, ystride);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700672
Ajay Dudanib01e5062011-12-03 23:23:42 -0800673 ReadValue = readl(DSI_INT_CTRL) & 0x00010000;
674 while (ReadValue != 0x00010000) {
675 ReadValue = readl(DSI_INT_CTRL) & 0x00010000;
676 count++;
677 if (count > 0xffff) {
678 status = FAIL;
679 dprintf(CRITICAL, "Video lane test failed\n");
680 return status;
681 }
682 }
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700683
Ajay Dudanib01e5062011-12-03 23:23:42 -0800684 dprintf(SPEW, "Video lane tested successfully\n");
685 return status;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700686}
687
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800688int is_cmd_mode_enabled(void)
689{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800690 return cmd_mode_status;
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800691}
692
Kinson Chike5c93432011-06-17 09:10:29 -0700693#if DISPLAY_MIPI_PANEL_NOVATEK_BLUE
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800694void mipi_dsi_cmd_mode_trigger(void)
695{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800696 int status = 0;
697 unsigned short display_wd = mipi_fb_cfg.width;
698 unsigned short display_ht = mipi_fb_cfg.height;
699 unsigned short image_wd = mipi_fb_cfg.width;
700 unsigned short image_ht = mipi_fb_cfg.height;
701 unsigned short dst_format = 0;
702 unsigned short traffic_mode = 0;
703 struct mipi_dsi_panel_config *panel_info = &novatek_panel_info;
704 status += mipi_dsi_cmd_config(mipi_fb_cfg, panel_info->num_of_lanes);
705 mdelay(50);
706 config_dsi_cmd_mode(display_wd, display_ht, image_wd, image_ht,
707 dst_format, traffic_mode,
708 panel_info->num_of_lanes /* num_of_lanes */ );
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800709}
Kinson Chike5c93432011-06-17 09:10:29 -0700710#endif
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800711
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700712void mipi_dsi_shutdown(void)
713{
Amol Jadi6834f1a2012-06-29 14:42:59 -0700714 if(!target_cont_splash_screen())
715 {
716 mdp_shutdown();
717 writel(0x01010101, DSI_INT_CTRL);
718 writel(0x13FF3BFF, DSI_ERR_INT_MASK0);
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700719
720#if (DISPLAY_MIPI_PANEL_NOVATEK_BLUE \
Amol Jadi6834f1a2012-06-29 14:42:59 -0700721 || DISPLAY_MIPI_PANEL_TOSHIBA)
722 secure_writel(0x0, DSI_CC_REG);
723 secure_writel(0x0, DSI_PIXEL_CC_REG);
Kinson Chike5c93432011-06-17 09:10:29 -0700724#endif
Amol Jadi6834f1a2012-06-29 14:42:59 -0700725
726 writel(0, DSI_CLK_CTRL);
727 writel(0, DSI_CTRL);
728 writel(0, DSIPHY_PLL_CTRL(0));
729 }
730 else
731 {
Chandan Uddaraju4877d372011-07-21 12:51:51 -0700732 /* To keep the splash screen displayed till kernel driver takes
733 control, do not turn off the video mode engine and clocks.
734 Only disabling the MIPI DSI IRQs */
735 writel(0x01010101, DSI_INT_CTRL);
736 writel(0x13FF3BFF, DSI_ERR_INT_MASK0);
Amol Jadi6834f1a2012-06-29 14:42:59 -0700737 }
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700738}
739
740struct fbcon_config *mipi_init(void)
741{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800742 int status = 0;
743 struct mipi_dsi_panel_config *panel_info = get_panel_info();
Channagoud Kadabi539ef722012-03-29 16:02:50 +0530744
745 if (panel_info == NULL) {
746 dprintf(CRITICAL, "Panel info is null\n");
747 return NULL;
748 }
749
Ajay Dudanib01e5062011-12-03 23:23:42 -0800750 /* Enable MMSS_AHB_ARB_MATER_PORT_E for arbiter master0 and master 1 request */
Terence Hampsonf49ff4e2013-06-18 15:11:31 -0400751#if (!DISPLAY_MIPI_PANEL_RENESAS && !DISPLAY_TYPE_DSI6G && !DISPLAY_TYPE_8610)
Ajay Dudanib01e5062011-12-03 23:23:42 -0800752 writel(0x00001800, MMSS_SFPB_GPREG);
Aparna Mallavarapuf712f5e2011-08-04 21:11:00 +0530753#endif
Kinson Chike5c93432011-06-17 09:10:29 -0700754
755#if DISPLAY_MIPI_PANEL_TOSHIBA_MDT61
Ajay Dudanib01e5062011-12-03 23:23:42 -0800756 mipi_dsi_phy_init(panel_info);
Kinson Chike5c93432011-06-17 09:10:29 -0700757#else
Ajay Dudanib01e5062011-12-03 23:23:42 -0800758 mipi_dsi_phy_ctrl_config(panel_info);
Kinson Chike5c93432011-06-17 09:10:29 -0700759#endif
760
Ajay Dudanib01e5062011-12-03 23:23:42 -0800761 status += mipi_dsi_panel_initialize(panel_info);
Kinson Chike5c93432011-06-17 09:10:29 -0700762
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800763#if DISPLAY_MIPI_PANEL_NOVATEK_BLUE
Ajay Dudanib01e5062011-12-03 23:23:42 -0800764 mipi_dsi_cmd_bta_sw_trigger();
765 mipi_novatek_manufacture_id();
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800766#endif
Ajay Dudanib01e5062011-12-03 23:23:42 -0800767 mipi_fb_cfg.base = MIPI_FB_ADDR;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700768
Ajay Dudanib01e5062011-12-03 23:23:42 -0800769 if (panel_info->mode == MIPI_VIDEO_MODE)
770 status += mipi_dsi_video_config(panel_info->num_of_lanes);
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800771
Ajay Dudanib01e5062011-12-03 23:23:42 -0800772 if (panel_info->mode == MIPI_CMD_MODE)
773 cmd_mode_status = 1;
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800774
Ajay Dudanib01e5062011-12-03 23:23:42 -0800775 return &mipi_fb_cfg;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700776}
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700777
778int mipi_config(struct msm_fb_panel_data *panel)
779{
780 int ret = NO_ERROR;
781 struct msm_panel_info *pinfo;
782 struct mipi_dsi_panel_config mipi_pinfo;
783
784 if (!panel)
785 return ERR_INVALID_ARGS;
786
787 pinfo = &(panel->panel_info);
788 mipi_pinfo.mode = pinfo->mipi.mode;
789 mipi_pinfo.num_of_lanes = pinfo->mipi.num_of_lanes;
790 mipi_pinfo.dsi_phy_config = pinfo->mipi.dsi_phy_db;
791 mipi_pinfo.panel_cmds = pinfo->mipi.panel_cmds;
792 mipi_pinfo.num_of_panel_cmds = pinfo->mipi.num_of_panel_cmds;
Channagoud Kadabi539ef722012-03-29 16:02:50 +0530793 mipi_pinfo.lane_swap = pinfo->mipi.lane_swap;
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800794 mipi_pinfo.pack = 1;
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700795
796 /* Enable MMSS_AHB_ARB_MATER_PORT_E for
797 arbiter master0 and master 1 request */
Terence Hampsonf49ff4e2013-06-18 15:11:31 -0400798#if (!DISPLAY_MIPI_PANEL_RENESAS && !DISPLAY_TYPE_DSI6G && !DISPLAY_TYPE_8610)
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700799 writel(0x00001800, MMSS_SFPB_GPREG);
800#endif
801
802 mipi_dsi_phy_init(&mipi_pinfo);
803
804 ret += mipi_dsi_panel_initialize(&mipi_pinfo);
805
Channagoud Kadabi01c91822012-06-06 15:53:30 +0530806 if (pinfo->rotate && panel->rotate)
807 pinfo->rotate();
808
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700809 return ret;
810}
811
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700812int mdss_dsi_video_mode_config(uint16_t disp_width,
813 uint16_t disp_height,
814 uint16_t img_width,
815 uint16_t img_height,
816 uint16_t hsync_porch0_fp,
817 uint16_t hsync_porch0_bp,
818 uint16_t vsync_porch0_fp,
819 uint16_t vsync_porch0_bp,
820 uint16_t hsync_width,
821 uint16_t vsync_width,
822 uint16_t dst_format,
823 uint16_t traffic_mode,
824 uint8_t lane_en,
825 uint16_t low_pwr_stop_mode,
826 uint8_t eof_bllp_pwr,
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700827 uint8_t interleav,
828 uint32_t ctl_base)
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700829{
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700830 int status = 0;
831
Terence Hampsoncc3345c2013-06-27 15:30:10 -0400832#if (DISPLAY_TYPE_MDSS == 1)
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700833 /* disable mdp first */
834 mdp_disable();
835
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700836 writel(0x00000000, ctl_base + CLK_CTRL);
837 writel(0x00000002, ctl_base + CLK_CTRL);
838 writel(0x00000006, ctl_base + CLK_CTRL);
839 writel(0x0000000e, ctl_base + CLK_CTRL);
840 writel(0x0000001e, ctl_base + CLK_CTRL);
841 writel(0x0000023f, ctl_base + CLK_CTRL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700842
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700843 writel(0, ctl_base + CTRL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700844
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700845 writel(0, ctl_base + DSI_ERR_INT_MASK0);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700846
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700847 writel(0x02020202, ctl_base + INT_CTRL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700848
849 writel(((disp_width + hsync_porch0_bp) << 16) | hsync_porch0_bp,
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700850 ctl_base + VIDEO_MODE_ACTIVE_H);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700851
852 writel(((disp_height + vsync_porch0_bp) << 16) | (vsync_porch0_bp),
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700853 ctl_base + VIDEO_MODE_ACTIVE_V);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700854
855 if (mdp_get_revision() >= MDP_REV_41) {
856 writel(((disp_height + vsync_porch0_fp
857 + vsync_porch0_bp - 1) << 16)
858 | (disp_width + hsync_porch0_fp
859 + hsync_porch0_bp - 1),
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700860 ctl_base + VIDEO_MODE_TOTAL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700861 } else {
862 writel(((disp_height + vsync_porch0_fp
863 + vsync_porch0_bp) << 16)
864 | (disp_width + hsync_porch0_fp
865 + hsync_porch0_bp),
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700866 ctl_base + VIDEO_MODE_TOTAL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700867 }
868
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700869 writel((hsync_width << 16) | 0, ctl_base + VIDEO_MODE_HSYNC);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700870
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700871 writel(0 << 16 | 0, ctl_base + VIDEO_MODE_VSYNC);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700872
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700873 writel(vsync_width << 16 | 0, ctl_base + VIDEO_MODE_VSYNC_VPOS);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700874
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700875 writel(0x0, ctl_base + EOT_PACKET_CTRL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700876
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700877 writel(0x00000100, ctl_base + MISR_VIDEO_CTRL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700878
879 if (mdp_get_revision() >= MDP_REV_41) {
880 writel(low_pwr_stop_mode << 16 |
881 eof_bllp_pwr << 12 | traffic_mode << 8
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700882 | dst_format << 4 | 0x0, ctl_base + VIDEO_MODE_CTRL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700883 } else {
884 writel(1 << 28 | 1 << 24 | 1 << 20 | low_pwr_stop_mode << 16 |
885 eof_bllp_pwr << 12 | traffic_mode << 8
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700886 | dst_format << 4 | 0x0, ctl_base + VIDEO_MODE_CTRL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700887 }
888
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700889 writel(0x3fd08, ctl_base + HS_TIMER_CTRL);
890 writel(0x00010100, ctl_base + MISR_VIDEO_CTRL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700891
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700892 writel(0x00010100, ctl_base + INT_CTRL);
893 writel(0x02010202, ctl_base + INT_CTRL);
894 writel(0x02030303, ctl_base + INT_CTRL);
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700895
896 writel(interleav << 30 | 0 << 24 | 0 << 20 | lane_en << 4
Siddhartha Agrawal6e760042013-05-30 21:10:18 -0700897 | 0x103, ctl_base + CTRL);
Terence Hampsoncc3345c2013-06-27 15:30:10 -0400898#endif
Siddhartha Agrawal06bb82f2013-05-24 12:32:33 -0700899
900 return status;
901}
902
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800903int mdss_dsi_config(struct msm_fb_panel_data *panel)
904{
905 int ret = NO_ERROR;
906 struct msm_panel_info *pinfo;
907 struct mipi_dsi_panel_config mipi_pinfo;
908
Terence Hampsoncc3345c2013-06-27 15:30:10 -0400909#if (DISPLAY_TYPE_MDSS == 1)
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800910 if (!panel)
911 return ERR_INVALID_ARGS;
912
913 pinfo = &(panel->panel_info);
914 mipi_pinfo.mode = pinfo->mipi.mode;
915 mipi_pinfo.num_of_lanes = pinfo->mipi.num_of_lanes;
916 mipi_pinfo.mdss_dsi_phy_config = pinfo->mipi.mdss_dsi_phy_db;
917 mipi_pinfo.panel_cmds = pinfo->mipi.panel_cmds;
918 mipi_pinfo.num_of_panel_cmds = pinfo->mipi.num_of_panel_cmds;
919 mipi_pinfo.lane_swap = pinfo->mipi.lane_swap;
920 mipi_pinfo.pack = 0;
Siddhartha Agrawalb6c861f2013-05-31 19:36:44 -0700921 mipi_pinfo.t_clk_pre = pinfo->mipi.t_clk_pre;
922 mipi_pinfo.t_clk_post = pinfo->mipi.t_clk_post;
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800923
Siddhartha Agrawal1b2ed842013-05-29 18:02:28 -0700924 mdss_dsi_phy_init(&mipi_pinfo, MIPI_DSI0_BASE);
925 if (pinfo->mipi.dual_dsi)
926 mdss_dsi_phy_init(&mipi_pinfo, MIPI_DSI1_BASE);
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800927
Siddhartha Agrawal980b5ee2013-05-30 12:17:50 -0700928 ret += mdss_dsi_panel_initialize(&mipi_pinfo, pinfo->mipi.broadcast);
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800929
930 if (pinfo->rotate && panel->rotate)
931 pinfo->rotate();
Terence Hampsoncc3345c2013-06-27 15:30:10 -0400932#endif
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800933
934 return ret;
935}
936
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700937int mipi_dsi_video_mode_config(unsigned short disp_width,
938 unsigned short disp_height,
939 unsigned short img_width,
940 unsigned short img_height,
941 unsigned short hsync_porch0_fp,
942 unsigned short hsync_porch0_bp,
943 unsigned short vsync_porch0_fp,
944 unsigned short vsync_porch0_bp,
945 unsigned short hsync_width,
946 unsigned short vsync_width,
947 unsigned short dst_format,
948 unsigned short traffic_mode,
949 unsigned char lane_en,
950 unsigned low_pwr_stop_mode,
951 unsigned char eof_bllp_pwr,
952 unsigned char interleav)
953{
954
955 int status = 0;
956
957 /* disable mdp first */
958 mdp_disable();
959
960 writel(0x00000000, DSI_CLK_CTRL);
961 writel(0x00000000, DSI_CLK_CTRL);
962 writel(0x00000000, DSI_CLK_CTRL);
963 writel(0x00000000, DSI_CLK_CTRL);
964 writel(0x00000002, DSI_CLK_CTRL);
965 writel(0x00000006, DSI_CLK_CTRL);
966 writel(0x0000000e, DSI_CLK_CTRL);
967 writel(0x0000001e, DSI_CLK_CTRL);
Chandan Uddarajueb1decb2013-04-23 14:27:49 -0700968 writel(0x0000023f, DSI_CLK_CTRL);
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700969
970 writel(0, DSI_CTRL);
971
972 writel(0, DSI_ERR_INT_MASK0);
973
974 writel(0x02020202, DSI_INT_CTRL);
975
976 writel(((disp_width + hsync_porch0_bp) << 16) | hsync_porch0_bp,
977 DSI_VIDEO_MODE_ACTIVE_H);
978
979 writel(((disp_height + vsync_porch0_bp) << 16) | (vsync_porch0_bp),
980 DSI_VIDEO_MODE_ACTIVE_V);
981
982 if (mdp_get_revision() >= MDP_REV_41) {
983 writel(((disp_height + vsync_porch0_fp
984 + vsync_porch0_bp - 1) << 16)
985 | (disp_width + hsync_porch0_fp
986 + hsync_porch0_bp - 1),
987 DSI_VIDEO_MODE_TOTAL);
988 } else {
989 writel(((disp_height + vsync_porch0_fp
990 + vsync_porch0_bp) << 16)
991 | (disp_width + hsync_porch0_fp
992 + hsync_porch0_bp),
993 DSI_VIDEO_MODE_TOTAL);
994 }
995
996 writel((hsync_width << 16) | 0, DSI_VIDEO_MODE_HSYNC);
997
998 writel(0 << 16 | 0, DSI_VIDEO_MODE_VSYNC);
999
1000 writel(vsync_width << 16 | 0, DSI_VIDEO_MODE_VSYNC_VPOS);
1001
Chandan Uddarajueb1decb2013-04-23 14:27:49 -07001002 writel(0x0, DSI_EOT_PACKET_CTRL);
Shashank Mittal4bfb2e32012-04-16 10:56:27 -07001003
1004 writel(0x00000100, DSI_MISR_VIDEO_CTRL);
1005
Channagoud Kadabi539ef722012-03-29 16:02:50 +05301006 if (mdp_get_revision() >= MDP_REV_41) {
1007 writel(low_pwr_stop_mode << 16 |
1008 eof_bllp_pwr << 12 | traffic_mode << 8
1009 | dst_format << 4 | 0x0, DSI_VIDEO_MODE_CTRL);
1010 } else {
1011 writel(1 << 28 | 1 << 24 | 1 << 20 | low_pwr_stop_mode << 16 |
1012 eof_bllp_pwr << 12 | traffic_mode << 8
1013 | dst_format << 4 | 0x0, DSI_VIDEO_MODE_CTRL);
1014 }
Shashank Mittal4bfb2e32012-04-16 10:56:27 -07001015
Chandan Uddarajueb1decb2013-04-23 14:27:49 -07001016 writel(0x3fd08, DSI_HS_TIMER_CTRL);
Shashank Mittal4bfb2e32012-04-16 10:56:27 -07001017 writel(0x67, DSI_CAL_STRENGTH_CTRL);
1018 writel(0x80006711, DSI_CAL_CTRL);
1019 writel(0x00010100, DSI_MISR_VIDEO_CTRL);
1020
1021 writel(0x00010100, DSI_INT_CTRL);
1022 writel(0x02010202, DSI_INT_CTRL);
1023 writel(0x02030303, DSI_INT_CTRL);
1024
1025 writel(interleav << 30 | 0 << 24 | 0 << 20 | lane_en << 4
1026 | 0x103, DSI_CTRL);
1027
1028 return status;
1029}
1030
Siddhartha Agrawal7317e482013-04-21 16:16:57 -07001031int mdss_dsi_cmd_mode_config(uint16_t disp_width,
1032 uint16_t disp_height,
1033 uint16_t img_width,
1034 uint16_t img_height,
1035 uint16_t dst_format,
1036 uint16_t traffic_mode)
1037{
1038 uint8_t DST_FORMAT;
1039 uint8_t TRAFIC_MODE;
1040 uint8_t DLNx_EN;
1041 // video mode data ctrl
1042 int status = 0;
1043 uint8_t interleav = 0;
1044 uint8_t ystride = 0x03;
1045 // disable mdp first
1046
Terence Hampsoncc3345c2013-06-27 15:30:10 -04001047#if (DISPLAY_TYPE_MDSS == 1)
Siddhartha Agrawal7317e482013-04-21 16:16:57 -07001048 writel(0x00000000, DSI_CLK_CTRL);
1049 writel(0x00000000, DSI_CLK_CTRL);
1050 writel(0x00000000, DSI_CLK_CTRL);
1051 writel(0x00000000, DSI_CLK_CTRL);
1052 writel(0x00000002, DSI_CLK_CTRL);
1053 writel(0x00000006, DSI_CLK_CTRL);
1054 writel(0x0000000e, DSI_CLK_CTRL);
1055 writel(0x0000001e, DSI_CLK_CTRL);
1056 writel(0x0000023f, DSI_CLK_CTRL);
1057
1058 writel(0, DSI_CTRL);
1059
1060 writel(0, DSI_ERR_INT_MASK0);
1061
1062 writel(0x02020202, DSI_INT_CTRL);
1063
1064 DST_FORMAT = 8; // RGB888
1065 dprintf(SPEW, "DSI_Cmd_Mode - Dst Format: RGB888\n");
1066
1067 DLNx_EN = 0xf; // 4 lane with clk programming
1068 dprintf(SPEW, "Data Lane: 4 lane\n");
1069
1070 TRAFIC_MODE = 0; // non burst mode with sync pulses
1071 dprintf(SPEW, "Traffic mode: non burst mode with sync pulses\n");
1072
1073 writel(DST_FORMAT, DSI_COMMAND_MODE_MDP_CTRL);
1074 writel((img_width * ystride + 1) << 16 | 0x0039,
1075 DSI_COMMAND_MODE_MDP_STREAM0_CTRL);
1076 writel((img_width * ystride + 1) << 16 | 0x0039,
1077 DSI_COMMAND_MODE_MDP_STREAM1_CTRL);
1078 writel(img_height << 16 | img_width,
1079 DSI_COMMAND_MODE_MDP_STREAM0_TOTAL);
1080 writel(img_height << 16 | img_width,
1081 DSI_COMMAND_MODE_MDP_STREAM1_TOTAL);
1082 writel(0x13c2c, DSI_COMMAND_MODE_MDP_DCS_CMD_CTRL);
1083 writel(interleav << 30 | 0 << 24 | 0 << 20 | DLNx_EN << 4 | 0x105,
1084 DSI_CTRL);
1085 writel(0x10000000, DSI_COMMAND_MODE_DMA_CTRL);
1086 writel(0x10000000, DSI_MISR_CMD_CTRL);
Terence Hampsoncc3345c2013-06-27 15:30:10 -04001087#endif
Siddhartha Agrawal7317e482013-04-21 16:16:57 -07001088
1089 return NO_ERROR;
1090}
1091
Channagoud Kadabi10189fd2012-05-25 13:33:39 +05301092int mipi_dsi_cmd_mode_config(unsigned short disp_width,
1093 unsigned short disp_height,
1094 unsigned short img_width,
1095 unsigned short img_height,
1096 unsigned short dst_format,
1097 unsigned short traffic_mode)
1098{
1099 unsigned char DST_FORMAT;
1100 unsigned char TRAFIC_MODE;
1101 unsigned char DLNx_EN;
1102 // video mode data ctrl
1103 int status = 0;
1104 unsigned char interleav = 0;
1105 unsigned char ystride = 0x03;
1106 // disable mdp first
1107
1108 writel(0x00000000, DSI_CLK_CTRL);
1109 writel(0x00000000, DSI_CLK_CTRL);
1110 writel(0x00000000, DSI_CLK_CTRL);
1111 writel(0x00000000, DSI_CLK_CTRL);
1112 writel(0x00000002, DSI_CLK_CTRL);
1113 writel(0x00000006, DSI_CLK_CTRL);
1114 writel(0x0000000e, DSI_CLK_CTRL);
1115 writel(0x0000001e, DSI_CLK_CTRL);
1116 writel(0x0000003e, DSI_CLK_CTRL);
1117
1118 writel(0x10000000, DSI_ERR_INT_MASK0);
1119
1120
1121 DST_FORMAT = 8; // RGB888
1122 dprintf(SPEW, "DSI_Cmd_Mode - Dst Format: RGB888\n");
1123
1124 DLNx_EN = 3; // 2 lane with clk programming
1125 dprintf(SPEW, "Data Lane: 2 lane\n");
1126
1127 TRAFIC_MODE = 0; // non burst mode with sync pulses
1128 dprintf(SPEW, "Traffic mode: non burst mode with sync pulses\n");
1129
1130 writel(0x02020202, DSI_INT_CTRL);
1131
1132 writel(0x00100000 | DST_FORMAT, DSI_COMMAND_MODE_MDP_CTRL);
1133 writel((img_width * ystride + 1) << 16 | 0x0039,
1134 DSI_COMMAND_MODE_MDP_STREAM0_CTRL);
1135 writel((img_width * ystride + 1) << 16 | 0x0039,
1136 DSI_COMMAND_MODE_MDP_STREAM1_CTRL);
1137 writel(img_height << 16 | img_width,
1138 DSI_COMMAND_MODE_MDP_STREAM0_TOTAL);
1139 writel(img_height << 16 | img_width,
1140 DSI_COMMAND_MODE_MDP_STREAM1_TOTAL);
1141 writel(0xEE, DSI_CAL_STRENGTH_CTRL);
1142 writel(0x80000000, DSI_CAL_CTRL);
1143 writel(0x40, DSI_TRIG_CTRL);
1144 writel(0x13c2c, DSI_COMMAND_MODE_MDP_DCS_CMD_CTRL);
1145 writel(interleav << 30 | 0 << 24 | 0 << 20 | DLNx_EN << 4 | 0x105,
1146 DSI_CTRL);
1147 writel(0x10000000, DSI_COMMAND_MODE_DMA_CTRL);
1148 writel(0x10000000, DSI_MISR_CMD_CTRL);
1149 writel(0x00000040, DSI_ERR_INT_MASK0);
1150 writel(0x1, DSI_EOT_PACKET_CTRL);
1151
1152 return NO_ERROR;
1153}
1154
Shashank Mittal4bfb2e32012-04-16 10:56:27 -07001155int mipi_dsi_on()
1156{
1157 int ret = NO_ERROR;
1158 unsigned long ReadValue;
1159 unsigned long count = 0;
1160
1161 ReadValue = readl(DSI_INT_CTRL) & 0x00010000;
1162
1163 mdelay(10);
1164
1165 while (ReadValue != 0x00010000) {
1166 ReadValue = readl(DSI_INT_CTRL) & 0x00010000;
1167 count++;
1168 if (count > 0xffff) {
1169 dprintf(CRITICAL, "Video lane test failed\n");
1170 return ERROR;
1171 }
1172 }
1173
Amir Samuelov2d4ba162012-07-22 11:53:14 +03001174 dprintf(INFO, "Video lane tested successfully\n");
Shashank Mittal4bfb2e32012-04-16 10:56:27 -07001175 return ret;
1176}
1177
1178int mipi_dsi_off()
1179{
Amol Jadi6834f1a2012-06-29 14:42:59 -07001180 if(!target_cont_splash_screen())
1181 {
1182 writel(0, DSI_CLK_CTRL);
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -08001183 writel(0x1F1, DSI_CTRL);
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -08001184 mdelay(10);
1185 writel(0x0001, DSI_SOFT_RESET);
1186 writel(0x0000, DSI_SOFT_RESET);
Siddhartha Agrawale0033a12013-02-23 15:37:42 -08001187 writel(0x1115501, DSI_INT_CTRL);
Amol Jadi6834f1a2012-06-29 14:42:59 -07001188 writel(0, DSI_CTRL);
Siddhartha Agrawale0033a12013-02-23 15:37:42 -08001189 }
1190
1191 writel(0x1115501, DSI_INT_CTRL);
Shashank Mittal4bfb2e32012-04-16 10:56:27 -07001192
1193 return NO_ERROR;
1194}
Channagoud Kadabi10189fd2012-05-25 13:33:39 +05301195
1196int mipi_cmd_trigger()
1197{
1198 writel(0x1, DSI_CMD_MODE_MDP_SW_TRIGGER);
1199
1200 return NO_ERROR;
1201}