blob: 3b095106764177595dfa3f0d8453b05d54102e83 [file] [log] [blame]
Shashank Mittal30262902012-02-21 15:37:24 -08001/* Copyright (c) 2010-2012, Code Aurora Forum. 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.
12 * * Neither the name of Code Aurora Forum, Inc. nor the names of its
13 * 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>
Kinson Chikfe931032011-07-21 10:01:34 -070041
42extern void mdp_disable(void);
Ajay Dudanib01e5062011-12-03 23:23:42 -080043extern int mipi_dsi_cmd_config(struct fbcon_config mipi_fb_cfg,
44 unsigned short num_of_lanes);
Kinson Chikfe931032011-07-21 10:01:34 -070045extern void mdp_shutdown(void);
46extern void mdp_start_dma(void);
Deepa Dinamania080a402011-11-05 18:59:26 -070047extern void dsb(void);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -070048
Chandan Uddarajufe93e822010-11-21 20:44:47 -080049#if DISPLAY_MIPI_PANEL_TOSHIBA
Chandan Uddaraju78ae6752010-10-19 12:57:10 -070050static struct fbcon_config mipi_fb_cfg = {
Ajay Dudanib01e5062011-12-03 23:23:42 -080051 .height = TSH_MIPI_FB_HEIGHT,
52 .width = TSH_MIPI_FB_WIDTH,
53 .stride = TSH_MIPI_FB_WIDTH,
54 .format = FB_FORMAT_RGB888,
55 .bpp = 24,
56 .update_start = NULL,
57 .update_done = NULL,
Chandan Uddaraju78ae6752010-10-19 12:57:10 -070058};
Ajay Dudanib01e5062011-12-03 23:23:42 -080059
Kinson Chike5c93432011-06-17 09:10:29 -070060struct mipi_dsi_panel_config toshiba_panel_info = {
Ajay Dudanib01e5062011-12-03 23:23:42 -080061 .mode = MIPI_VIDEO_MODE,
62 .num_of_lanes = 1,
63 .dsi_phy_config = &mipi_dsi_toshiba_panel_phy_ctrl,
64 .panel_cmds = toshiba_panel_video_mode_cmds,
65 .num_of_panel_cmds = ARRAY_SIZE(toshiba_panel_video_mode_cmds),
Kinson Chike5c93432011-06-17 09:10:29 -070066};
Chandan Uddarajufe93e822010-11-21 20:44:47 -080067#elif DISPLAY_MIPI_PANEL_NOVATEK_BLUE
68static struct fbcon_config mipi_fb_cfg = {
Ajay Dudanib01e5062011-12-03 23:23:42 -080069 .height = NOV_MIPI_FB_HEIGHT,
70 .width = NOV_MIPI_FB_WIDTH,
71 .stride = NOV_MIPI_FB_WIDTH,
72 .format = FB_FORMAT_RGB888,
73 .bpp = 24,
74 .update_start = NULL,
75 .update_done = NULL,
Chandan Uddarajufe93e822010-11-21 20:44:47 -080076};
Ajay Dudanib01e5062011-12-03 23:23:42 -080077
Kinson Chike5c93432011-06-17 09:10:29 -070078struct mipi_dsi_panel_config novatek_panel_info = {
Ajay Dudanib01e5062011-12-03 23:23:42 -080079 .mode = MIPI_CMD_MODE,
80 .num_of_lanes = 2,
81 .dsi_phy_config = &mipi_dsi_novatek_panel_phy_ctrl,
82 .panel_cmds = novatek_panel_cmd_mode_cmds,
83 .num_of_panel_cmds = ARRAY_SIZE(novatek_panel_cmd_mode_cmds),
Kinson Chike5c93432011-06-17 09:10:29 -070084};
85#elif DISPLAY_MIPI_PANEL_TOSHIBA_MDT61
86static struct fbcon_config mipi_fb_cfg = {
Ajay Dudanib01e5062011-12-03 23:23:42 -080087 .height = TSH_MDT61_MIPI_FB_HEIGHT,
88 .width = TSH_MDT61_MIPI_FB_WIDTH,
89 .stride = TSH_MDT61_MIPI_FB_WIDTH,
90 .format = FB_FORMAT_RGB888,
91 .bpp = 24,
92 .update_start = NULL,
93 .update_done = NULL,
Kinson Chike5c93432011-06-17 09:10:29 -070094};
Ajay Dudanib01e5062011-12-03 23:23:42 -080095
Kinson Chike5c93432011-06-17 09:10:29 -070096struct mipi_dsi_panel_config toshiba_mdt61_panel_info = {
Ajay Dudanib01e5062011-12-03 23:23:42 -080097 .mode = MIPI_VIDEO_MODE,
98 .num_of_lanes = 3,
99 .dsi_phy_config = &mipi_dsi_toshiba_mdt61_panel_phy_ctrl,
100 .panel_cmds = toshiba_mdt61_video_mode_cmds,
101 .num_of_panel_cmds = ARRAY_SIZE(toshiba_mdt61_video_mode_cmds),
Kinson Chike5c93432011-06-17 09:10:29 -0700102};
Aparna Mallavarapuf712f5e2011-08-04 21:11:00 +0530103#elif DISPLAY_MIPI_PANEL_RENESAS
104static struct fbcon_config mipi_fb_cfg = {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800105 .height = REN_MIPI_FB_HEIGHT,
106 .width = REN_MIPI_FB_WIDTH,
107 .stride = REN_MIPI_FB_WIDTH,
108 .format = FB_FORMAT_RGB888,
109 .bpp = 24,
110 .update_start = NULL,
111 .update_done = NULL,
Aparna Mallavarapuf712f5e2011-08-04 21:11:00 +0530112};
Ajay Dudanib01e5062011-12-03 23:23:42 -0800113
Aparna Mallavarapuf712f5e2011-08-04 21:11:00 +0530114struct mipi_dsi_panel_config renesas_panel_info = {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800115 .mode = MIPI_VIDEO_MODE,
116 .num_of_lanes = 2,
117 .dsi_phy_config = &mipi_dsi_renesas_panel_phy_ctrl,
118 .panel_cmds = renesas_panel_video_mode_cmds,
119 .num_of_panel_cmds = ARRAY_SIZE(renesas_panel_video_mode_cmds),
120 .lane_swap = 1,
Aparna Mallavarapuf712f5e2011-08-04 21:11:00 +0530121};
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800122#else
123static struct fbcon_config mipi_fb_cfg = {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800124 .height = 0,
125 .width = 0,
126 .stride = 0,
127 .format = 0,
128 .bpp = 0,
129 .update_start = NULL,
130 .update_done = NULL,
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800131};
132#endif
133
134static int cmd_mode_status = 0;
Greg Griscod6250552011-06-29 14:40:23 -0700135void secure_writel(uint32_t, uint32_t);
136uint32_t secure_readl(uint32_t);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700137
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800138int mipi_dsi_phy_ctrl_config(struct mipi_dsi_panel_config *pinfo)
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700139{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800140 unsigned i;
141 unsigned off = 0;
142 struct mipi_dsi_phy_ctrl *pd;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700143
Ajay Dudanib01e5062011-12-03 23:23:42 -0800144 writel(0x00000001, DSIPHY_SW_RESET);
145 writel(0x00000000, DSIPHY_SW_RESET);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700146
Ajay Dudanib01e5062011-12-03 23:23:42 -0800147 pd = (pinfo->dsi_phy_config);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700148
Ajay Dudanib01e5062011-12-03 23:23:42 -0800149 off = 0x02cc; /* regulator ctrl 0 */
150 for (i = 0; i < 4; i++) {
151 writel(pd->regulator[i], MIPI_DSI_BASE + off);
152 off += 4;
153 }
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800154
Ajay Dudanib01e5062011-12-03 23:23:42 -0800155 off = 0x0260; /* phy timig ctrl 0 */
156 for (i = 0; i < 11; i++) {
157 writel(pd->timing[i], MIPI_DSI_BASE + off);
158 off += 4;
159 }
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700160
Ajay Dudanib01e5062011-12-03 23:23:42 -0800161 // T_CLK_POST, T_CLK_PRE for CLK lane P/N HS 200 mV timing length should >
162 // data lane HS timing length
163 writel(0xa1e, DSI_CLKOUT_TIMING_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700164
Ajay Dudanib01e5062011-12-03 23:23:42 -0800165 off = 0x0290; /* ctrl 0 */
166 for (i = 0; i < 4; i++) {
167 writel(pd->ctrl[i], MIPI_DSI_BASE + off);
168 off += 4;
169 }
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700170
Ajay Dudanib01e5062011-12-03 23:23:42 -0800171 off = 0x02a0; /* strength 0 */
172 for (i = 0; i < 4; i++) {
173 writel(pd->strength[i], MIPI_DSI_BASE + off);
174 off += 4;
175 }
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800176
Kinson Chik1eaeab52011-10-05 16:32:02 -0700177#if DISPLAY_MIPI_PANEL_RENESAS
Ajay Dudanib01e5062011-12-03 23:23:42 -0800178 if (machine_is_7x25a()) {
179 pd->pll[10] |= 0x8;
180 }
Kinson Chik1eaeab52011-10-05 16:32:02 -0700181#endif
Ajay Dudanib01e5062011-12-03 23:23:42 -0800182 off = 0x0204; /* pll ctrl 1, skip 0 */
183 for (i = 1; i < 21; i++) {
184 writel(pd->pll[i], MIPI_DSI_BASE + off);
185 off += 4;
186 }
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800187
Ajay Dudanib01e5062011-12-03 23:23:42 -0800188 /* pll ctrl 0 */
189 writel(pd->pll[0], MIPI_DSI_BASE + 0x200);
190 writel((pd->pll[0] | 0x01), MIPI_DSI_BASE + 0x200);
191 /* lane swp ctrol */
192 if (pinfo->lane_swap)
193 writel(pinfo->lane_swap, MIPI_DSI_BASE + 0xac);
194 return (0);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700195}
196
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800197struct mipi_dsi_panel_config *get_panel_info(void)
198{
199#if DISPLAY_MIPI_PANEL_TOSHIBA
Ajay Dudanib01e5062011-12-03 23:23:42 -0800200 return &toshiba_panel_info;
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800201#elif DISPLAY_MIPI_PANEL_NOVATEK_BLUE
Ajay Dudanib01e5062011-12-03 23:23:42 -0800202 return &novatek_panel_info;
Kinson Chike5c93432011-06-17 09:10:29 -0700203#elif DISPLAY_MIPI_PANEL_TOSHIBA_MDT61
Ajay Dudanib01e5062011-12-03 23:23:42 -0800204 return &toshiba_mdt61_panel_info;
Aparna Mallavarapuf712f5e2011-08-04 21:11:00 +0530205#elif DISPLAY_MIPI_PANEL_RENESAS
Ajay Dudanib01e5062011-12-03 23:23:42 -0800206 if (machine_is_7x25a()) {
207 renesas_panel_info.num_of_lanes = 1;
208 mipi_fb_cfg.height = REN_MIPI_FB_HEIGHT_HVGA;
209 }
210 return &renesas_panel_info;
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800211#endif
Ajay Dudanib01e5062011-12-03 23:23:42 -0800212 return NULL;
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800213}
214
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700215int dsi_cmd_dma_trigger_for_panel()
216{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800217 unsigned long ReadValue;
218 unsigned long count = 0;
219 int status = 0;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700220
Ajay Dudanib01e5062011-12-03 23:23:42 -0800221 writel(0x03030303, DSI_INT_CTRL);
222 writel(0x1, DSI_CMD_MODE_DMA_SW_TRIGGER);
223 dsb();
224 ReadValue = readl(DSI_INT_CTRL) & 0x00000001;
225 while (ReadValue != 0x00000001) {
226 ReadValue = readl(DSI_INT_CTRL) & 0x00000001;
227 count++;
228 if (count > 0xffff) {
229 status = FAIL;
230 dprintf(CRITICAL,
231 "Panel CMD: command mode dma test failed\n");
232 return status;
233 }
234 }
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700235
Ajay Dudanib01e5062011-12-03 23:23:42 -0800236 writel((readl(DSI_INT_CTRL) | 0x01000001), DSI_INT_CTRL);
237 dprintf(SPEW, "Panel CMD: command mode dma tested successfully\n");
238 return status;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700239}
240
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800241int mipi_dsi_cmds_tx(struct mipi_dsi_cmd *cmds, int count)
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700242{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800243 int ret = 0;
244 struct mipi_dsi_cmd *cm;
245 int i = 0;
246 char pload[256];
247 uint32_t off;
Deepa Dinamania080a402011-11-05 18:59:26 -0700248
Ajay Dudanib01e5062011-12-03 23:23:42 -0800249 /* Align pload at 8 byte boundry */
250 off = pload;
251 off &= 0x07;
252 if (off)
253 off = 8 - off;
254 off += pload;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700255
Ajay Dudanib01e5062011-12-03 23:23:42 -0800256 cm = cmds;
257 for (i = 0; i < count; i++) {
258 memcpy((void *)off, (cm->payload), cm->size);
259 writel(off, DSI_DMA_CMD_OFFSET);
260 writel(cm->size, DSI_DMA_CMD_LENGTH); // reg 0x48 for this build
261 dsb();
262 ret += dsi_cmd_dma_trigger_for_panel();
263 udelay(80);
264 cm++;
265 }
266 return ret;
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800267}
268
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800269/*
270 * mipi_dsi_cmd_rx: can receive at most 16 bytes
271 * per transaction since it only have 4 32bits reigsters
272 * to hold data.
273 * therefore Maximum Return Packet Size need to be set to 16.
274 * any return data more than MRPS need to be break down
275 * to multiple transactions.
276 */
277int mipi_dsi_cmds_rx(char **rp, int len)
278{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800279 uint32_t *lp, data;
280 char *dp;
281 int i, off, cnt;
282 int rlen, res;
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800283
Ajay Dudanib01e5062011-12-03 23:23:42 -0800284 if (len <= 2)
285 rlen = 4; /* short read */
286 else
287 rlen = MIPI_DSI_MRPS + 6; /* 4 bytes header + 2 bytes crc */
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800288
Ajay Dudanib01e5062011-12-03 23:23:42 -0800289 if (rlen > MIPI_DSI_REG_LEN) {
290 return 0;
291 }
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800292
Ajay Dudanib01e5062011-12-03 23:23:42 -0800293 res = rlen & 0x03;
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800294
Ajay Dudanib01e5062011-12-03 23:23:42 -0800295 rlen += res; /* 4 byte align */
296 lp = (uint32_t *) (*rp);
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800297
Ajay Dudanib01e5062011-12-03 23:23:42 -0800298 cnt = rlen;
299 cnt += 3;
300 cnt >>= 2;
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800301
Ajay Dudanib01e5062011-12-03 23:23:42 -0800302 if (cnt > 4)
303 cnt = 4; /* 4 x 32 bits registers only */
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800304
Ajay Dudanib01e5062011-12-03 23:23:42 -0800305 off = 0x068; /* DSI_RDBK_DATA0 */
306 off += ((cnt - 1) * 4);
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800307
Ajay Dudanib01e5062011-12-03 23:23:42 -0800308 for (i = 0; i < cnt; i++) {
309 data = (uint32_t) readl(MIPI_DSI_BASE + off);
310 *lp++ = ntohl(data); /* to network byte order */
311 off -= 4;
312 }
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800313
Ajay Dudanib01e5062011-12-03 23:23:42 -0800314 if (len > 2) {
315 /*First 4 bytes + paded bytes will be header next len bytes would be payload */
316 for (i = 0; i < len; i++) {
317 dp = *rp;
318 dp[i] = dp[4 + res + i];
319 }
320 }
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800321
Ajay Dudanib01e5062011-12-03 23:23:42 -0800322 return len;
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800323}
324
325static int mipi_dsi_cmd_bta_sw_trigger(void)
326{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800327 uint32_t data;
328 int cnt = 0;
329 int err = 0;
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800330
Ajay Dudanib01e5062011-12-03 23:23:42 -0800331 writel(0x01, MIPI_DSI_BASE + 0x094); /* trigger */
332 while (cnt < 10000) {
333 data = readl(MIPI_DSI_BASE + 0x0004); /*DSI_STATUS */
334 if ((data & 0x0010) == 0)
335 break;
336 cnt++;
337 }
338 if (cnt == 10000)
339 err = 1;
340 return err;
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800341}
342
343static uint32_t mipi_novatek_manufacture_id(void)
344{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800345 char rec_buf[24];
346 char *rp = rec_buf;
347 uint32_t *lp, data;
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800348
Ajay Dudanib01e5062011-12-03 23:23:42 -0800349 mipi_dsi_cmds_tx(&novatek_panel_manufacture_id_cmd, 1);
350 mipi_dsi_cmds_rx(&rp, 3);
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800351
Ajay Dudanib01e5062011-12-03 23:23:42 -0800352 lp = (uint32_t *) rp;
353 data = (uint32_t) * lp;
354 data = ntohl(data);
355 data = data >> 8;
356 return data;
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800357}
358
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800359int mipi_dsi_panel_initialize(struct mipi_dsi_panel_config *pinfo)
360{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800361 unsigned char DMA_STREAM1 = 0; // for mdp display processor path
362 unsigned char EMBED_MODE1 = 1; // from frame buffer
363 unsigned char POWER_MODE2 = 1; // from frame buffer
364 unsigned char PACK_TYPE1 = 1; // long packet
365 unsigned char VC1 = 0;
366 unsigned char DT1 = 0; // non embedded mode
367 unsigned short WC1 = 0; // for non embedded mode only
368 int status = 0;
369 unsigned char DLNx_EN;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700370
Ajay Dudanib01e5062011-12-03 23:23:42 -0800371 switch (pinfo->num_of_lanes) {
372 default:
373 case 1:
374 DLNx_EN = 1; // 1 lane
375 break;
376 case 2:
377 DLNx_EN = 3; // 2 lane
378 break;
379 case 3:
380 DLNx_EN = 7; // 3 lane
381 break;
382 }
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800383
Ajay Dudanib01e5062011-12-03 23:23:42 -0800384 writel(0x0001, DSI_SOFT_RESET);
385 writel(0x0000, DSI_SOFT_RESET);
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800386
Ajay Dudanib01e5062011-12-03 23:23:42 -0800387 writel((0 << 16) | 0x3f, DSI_CLK_CTRL); /* Turn on all DSI Clks */
388 writel(DMA_STREAM1 << 8 | 0x04, DSI_TRIG_CTRL); // reg 0x80 dma trigger: sw
389 // trigger 0x4; dma stream1
Kinson Chike5c93432011-06-17 09:10:29 -0700390
Ajay Dudanib01e5062011-12-03 23:23:42 -0800391 writel(0 << 30 | DLNx_EN << 4 | 0x105, DSI_CTRL); // reg 0x00 for this
392 // build
393 writel(EMBED_MODE1 << 28 | POWER_MODE2 << 26
394 | PACK_TYPE1 << 24 | VC1 << 22 | DT1 << 16 | WC1,
395 DSI_COMMAND_MODE_DMA_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700396
Ajay Dudanib01e5062011-12-03 23:23:42 -0800397 status = mipi_dsi_cmds_tx(pinfo->panel_cmds, pinfo->num_of_panel_cmds);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700398
Ajay Dudanib01e5062011-12-03 23:23:42 -0800399 return status;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700400}
401
Kinson Chike5c93432011-06-17 09:10:29 -0700402//TODO: Clean up arguments being passed in not being used
Ajay Dudanib01e5062011-12-03 23:23:42 -0800403int
404config_dsi_video_mode(unsigned short disp_width, unsigned short disp_height,
405 unsigned short img_width, unsigned short img_height,
406 unsigned short hsync_porch0_fp,
407 unsigned short hsync_porch0_bp,
408 unsigned short vsync_porch0_fp,
409 unsigned short vsync_porch0_bp,
410 unsigned short hsync_width,
411 unsigned short vsync_width, unsigned short dst_format,
412 unsigned short traffic_mode, unsigned short datalane_num)
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700413{
414
Ajay Dudanib01e5062011-12-03 23:23:42 -0800415 unsigned char DST_FORMAT;
416 unsigned char TRAFIC_MODE;
417 unsigned char DLNx_EN;
418 // video mode data ctrl
419 int status = 0;
420 unsigned long low_pwr_stop_mode = 0;
421 unsigned char eof_bllp_pwr = 0x9;
422 unsigned char interleav = 0;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700423
Ajay Dudanib01e5062011-12-03 23:23:42 -0800424 // disable mdp first
425 mdp_disable();
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700426
Ajay Dudanib01e5062011-12-03 23:23:42 -0800427 writel(0x00000000, DSI_CLK_CTRL);
428 writel(0x00000000, DSI_CLK_CTRL);
429 writel(0x00000000, DSI_CLK_CTRL);
430 writel(0x00000000, DSI_CLK_CTRL);
431 writel(0x00000002, DSI_CLK_CTRL);
432 writel(0x00000006, DSI_CLK_CTRL);
433 writel(0x0000000e, DSI_CLK_CTRL);
434 writel(0x0000001e, DSI_CLK_CTRL);
435 writel(0x0000003e, DSI_CLK_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700436
Ajay Dudanib01e5062011-12-03 23:23:42 -0800437 writel(0, DSI_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700438
Ajay Dudanib01e5062011-12-03 23:23:42 -0800439 writel(0, DSI_ERR_INT_MASK0);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700440
Ajay Dudanib01e5062011-12-03 23:23:42 -0800441 DST_FORMAT = 0; // RGB565
442 dprintf(SPEW, "DSI_Video_Mode - Dst Format: RGB565\n");
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700443
Ajay Dudanib01e5062011-12-03 23:23:42 -0800444 DLNx_EN = 1; // 1 lane with clk programming
445 dprintf(SPEW, "Data Lane: 1 lane\n");
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700446
Ajay Dudanib01e5062011-12-03 23:23:42 -0800447 TRAFIC_MODE = 0; // non burst mode with sync pulses
448 dprintf(SPEW, "Traffic mode: non burst mode with sync pulses\n");
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700449
Ajay Dudanib01e5062011-12-03 23:23:42 -0800450 writel(0x02020202, DSI_INT_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700451
Ajay Dudanib01e5062011-12-03 23:23:42 -0800452 writel(((img_width + hsync_porch0_bp) << 16) | hsync_porch0_bp,
453 DSI_VIDEO_MODE_ACTIVE_H);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700454
Ajay Dudanib01e5062011-12-03 23:23:42 -0800455 writel(((img_height + vsync_porch0_bp) << 16) | (vsync_porch0_bp),
456 DSI_VIDEO_MODE_ACTIVE_V);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700457
Ajay Dudanib01e5062011-12-03 23:23:42 -0800458 writel(((img_height + vsync_porch0_fp + vsync_porch0_bp) << 16)
459 | img_width + hsync_porch0_fp + hsync_porch0_bp,
460 DSI_VIDEO_MODE_TOTAL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700461
Ajay Dudanib01e5062011-12-03 23:23:42 -0800462 writel((hsync_width << 16) | 0, DSI_VIDEO_MODE_HSYNC);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700463
Ajay Dudanib01e5062011-12-03 23:23:42 -0800464 writel(0 << 16 | 0, DSI_VIDEO_MODE_VSYNC);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700465
Ajay Dudanib01e5062011-12-03 23:23:42 -0800466 writel(vsync_width << 16 | 0, DSI_VIDEO_MODE_VSYNC_VPOS);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700467
Ajay Dudanib01e5062011-12-03 23:23:42 -0800468 writel(1, DSI_EOT_PACKET_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700469
Ajay Dudanib01e5062011-12-03 23:23:42 -0800470 writel(0x00000100, DSI_MISR_VIDEO_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700471
Ajay Dudanib01e5062011-12-03 23:23:42 -0800472 writel(low_pwr_stop_mode << 16 | eof_bllp_pwr << 12 | TRAFIC_MODE << 8
473 | DST_FORMAT << 4 | 0x0, DSI_VIDEO_MODE_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700474
Ajay Dudanib01e5062011-12-03 23:23:42 -0800475 writel(0x67, DSI_CAL_STRENGTH_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700476
Ajay Dudanib01e5062011-12-03 23:23:42 -0800477 writel(0x80006711, DSI_CAL_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700478
Ajay Dudanib01e5062011-12-03 23:23:42 -0800479 writel(0x00010100, DSI_MISR_VIDEO_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700480
Ajay Dudanib01e5062011-12-03 23:23:42 -0800481 writel(0x00010100, DSI_INT_CTRL);
482 writel(0x02010202, DSI_INT_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700483
Ajay Dudanib01e5062011-12-03 23:23:42 -0800484 writel(0x02030303, DSI_INT_CTRL);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700485
Ajay Dudanib01e5062011-12-03 23:23:42 -0800486 writel(interleav << 30 | 0 << 24 | 0 << 20 | DLNx_EN << 4
487 | 0x103, DSI_CTRL);
488 mdelay(10);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700489
Ajay Dudanib01e5062011-12-03 23:23:42 -0800490 return status;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700491}
492
Ajay Dudanib01e5062011-12-03 23:23:42 -0800493int
494config_dsi_cmd_mode(unsigned short disp_width, unsigned short disp_height,
495 unsigned short img_width, unsigned short img_height,
496 unsigned short dst_format,
497 unsigned short traffic_mode, unsigned short datalane_num)
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800498{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800499 unsigned char DST_FORMAT;
500 unsigned char TRAFIC_MODE;
501 unsigned char DLNx_EN;
502 // video mode data ctrl
503 int status = 0;
Greg Griscod6250552011-06-29 14:40:23 -0700504 unsigned char interleav = 0;
505 unsigned char ystride = 0x03;
Ajay Dudanib01e5062011-12-03 23:23:42 -0800506 // disable mdp first
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800507
Ajay Dudanib01e5062011-12-03 23:23:42 -0800508 writel(0x00000000, DSI_CLK_CTRL);
509 writel(0x00000000, DSI_CLK_CTRL);
510 writel(0x00000000, DSI_CLK_CTRL);
511 writel(0x00000000, DSI_CLK_CTRL);
512 writel(0x00000002, DSI_CLK_CTRL);
513 writel(0x00000006, DSI_CLK_CTRL);
514 writel(0x0000000e, DSI_CLK_CTRL);
515 writel(0x0000001e, DSI_CLK_CTRL);
516 writel(0x0000003e, DSI_CLK_CTRL);
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800517
Ajay Dudanib01e5062011-12-03 23:23:42 -0800518 writel(0x10000000, DSI_ERR_INT_MASK0);
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800519
Ajay Dudanib01e5062011-12-03 23:23:42 -0800520 // writel(0, DSI_CTRL);
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800521
Ajay Dudanib01e5062011-12-03 23:23:42 -0800522 // writel(0, DSI_ERR_INT_MASK0);
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800523
Ajay Dudanib01e5062011-12-03 23:23:42 -0800524 DST_FORMAT = 8; // RGB888
525 dprintf(SPEW, "DSI_Cmd_Mode - Dst Format: RGB888\n");
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800526
Ajay Dudanib01e5062011-12-03 23:23:42 -0800527 DLNx_EN = 3; // 2 lane with clk programming
528 dprintf(SPEW, "Data Lane: 2 lane\n");
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800529
Ajay Dudanib01e5062011-12-03 23:23:42 -0800530 TRAFIC_MODE = 0; // non burst mode with sync pulses
531 dprintf(SPEW, "Traffic mode: non burst mode with sync pulses\n");
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800532
Ajay Dudanib01e5062011-12-03 23:23:42 -0800533 writel(0x02020202, DSI_INT_CTRL);
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800534
Ajay Dudanib01e5062011-12-03 23:23:42 -0800535 writel(0x00100000 | DST_FORMAT, DSI_COMMAND_MODE_MDP_CTRL);
536 writel((img_width * ystride + 1) << 16 | 0x0039,
537 DSI_COMMAND_MODE_MDP_STREAM0_CTRL);
538 writel((img_width * ystride + 1) << 16 | 0x0039,
539 DSI_COMMAND_MODE_MDP_STREAM1_CTRL);
540 writel(img_height << 16 | img_width,
541 DSI_COMMAND_MODE_MDP_STREAM0_TOTAL);
542 writel(img_height << 16 | img_width,
543 DSI_COMMAND_MODE_MDP_STREAM1_TOTAL);
544 writel(0xEE, DSI_CAL_STRENGTH_CTRL);
545 writel(0x80000000, DSI_CAL_CTRL);
546 writel(0x40, DSI_TRIG_CTRL);
547 writel(0x13c2c, DSI_COMMAND_MODE_MDP_DCS_CMD_CTRL);
548 writel(interleav << 30 | 0 << 24 | 0 << 20 | DLNx_EN << 4 | 0x105,
549 DSI_CTRL);
550 mdelay(10);
551 writel(0x10000000, DSI_COMMAND_MODE_DMA_CTRL);
552 writel(0x10000000, DSI_MISR_CMD_CTRL);
553 writel(0x00000040, DSI_ERR_INT_MASK0);
554 writel(0x1, DSI_EOT_PACKET_CTRL);
555 // writel(0x0, MDP_OVERLAYPROC0_START);
556 mdp_start_dma();
557 mdelay(10);
558 writel(0x1, DSI_CMD_MODE_MDP_SW_TRIGGER);
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800559
Ajay Dudanib01e5062011-12-03 23:23:42 -0800560 status = 1;
561 return status;
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800562}
563
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800564int mipi_dsi_video_config(unsigned short num_of_lanes)
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700565{
566
Ajay Dudanib01e5062011-12-03 23:23:42 -0800567 int status = 0;
568 unsigned long ReadValue;
569 unsigned long count = 0;
570 unsigned long low_pwr_stop_mode = 0; // low power mode 0x1111 start from
571 // bit16, high spd mode 0x0
572 unsigned char eof_bllp_pwr = 0x9; // bit 12, 15, 1:low power stop mode or
573 // let cmd mode eng send packets in hs
574 // or lp mode
575 unsigned short image_wd = mipi_fb_cfg.width;
576 unsigned short image_ht = mipi_fb_cfg.height;
Greg Grisco1073a5e2011-07-28 18:59:18 -0700577#if !DISPLAY_MIPI_PANEL_TOSHIBA_MDT61
Ajay Dudanib01e5062011-12-03 23:23:42 -0800578 unsigned short display_wd = mipi_fb_cfg.width;
579 unsigned short display_ht = mipi_fb_cfg.height;
580 unsigned short hsync_porch_fp = MIPI_HSYNC_FRONT_PORCH_DCLK;
581 unsigned short hsync_porch_bp = MIPI_HSYNC_BACK_PORCH_DCLK;
582 unsigned short vsync_porch_fp = MIPI_VSYNC_FRONT_PORCH_LINES;
583 unsigned short vsync_porch_bp = MIPI_VSYNC_BACK_PORCH_LINES;
584 unsigned short hsync_width = MIPI_HSYNC_PULSE_WIDTH;
585 unsigned short vsync_width = MIPI_VSYNC_PULSE_WIDTH;
586 unsigned short dst_format = 0;
587 unsigned short traffic_mode = 0;
Greg Grisco1073a5e2011-07-28 18:59:18 -0700588#endif
Ajay Dudanib01e5062011-12-03 23:23:42 -0800589 unsigned short pack_pattern = 0x12; //BGR
590 unsigned char ystride = 3;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700591
Ajay Dudanib01e5062011-12-03 23:23:42 -0800592 low_pwr_stop_mode = 0x1111; // low pwr mode bit16:HSA, bit20:HBA,
593 // bit24:HFP, bit28:PULSE MODE, need enough
594 // time for swithc from LP to HS
595 eof_bllp_pwr = 0x9; // low power stop mode or let cmd mode eng send
596 // packets in hs or lp mode
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700597
Kinson Chike5c93432011-06-17 09:10:29 -0700598#if DISPLAY_MIPI_PANEL_TOSHIBA_MDT61
Ajay Dudanib01e5062011-12-03 23:23:42 -0800599 pack_pattern = 0x21; //RGB
600 config_mdt61_dsi_video_mode();
Kinson Chike5c93432011-06-17 09:10:29 -0700601
Ajay Dudanib01e5062011-12-03 23:23:42 -0800602 /* Two functions make up mdp_setup_dma_p_video_mode with mdt61 panel functions */
603 mdp_setup_dma_p_video_config(pack_pattern, image_wd, image_ht,
604 MIPI_FB_ADDR, image_wd, ystride);
605 mdp_setup_mdt61_video_dsi_config();
Aparna Mallavarapuf712f5e2011-08-04 21:11:00 +0530606#elif DISPLAY_MIPI_PANEL_RENESAS
Ajay Dudanib01e5062011-12-03 23:23:42 -0800607 if (machine_is_7x25a()) {
608 display_wd = REN_MIPI_FB_WIDTH_HVGA;
609 display_ht = REN_MIPI_FB_HEIGHT_HVGA;
610 image_wd = REN_MIPI_FB_WIDTH_HVGA;
611 image_ht = REN_MIPI_FB_HEIGHT_HVGA;
612 hsync_porch_fp = MIPI_HSYNC_FRONT_PORCH_DCLK_HVGA;
613 hsync_porch_bp = MIPI_HSYNC_BACK_PORCH_DCLK_HVGA;
614 vsync_porch_fp = MIPI_VSYNC_FRONT_PORCH_LINES_HVGA;
615 vsync_porch_bp = MIPI_VSYNC_BACK_PORCH_LINES_HVGA;
616 hsync_width = MIPI_HSYNC_PULSE_WIDTH_HVGA;
617 vsync_width = MIPI_VSYNC_PULSE_WIDTH_HVGA;
618 }
Aparna Mallavarapu45869c32011-08-05 13:22:35 +0530619
Ajay Dudanib01e5062011-12-03 23:23:42 -0800620 pack_pattern = 0x21; //RGB
621 config_renesas_dsi_video_mode();
Aparna Mallavarapuf712f5e2011-08-04 21:11:00 +0530622
Ajay Dudanib01e5062011-12-03 23:23:42 -0800623 status +=
624 mdp_setup_dma_p_video_mode(display_wd, display_ht, image_wd,
625 image_ht, hsync_porch_fp, hsync_porch_bp,
626 vsync_porch_fp, vsync_porch_bp,
627 hsync_width, vsync_width, MIPI_FB_ADDR,
628 image_wd, pack_pattern, ystride);
Kinson Chike5c93432011-06-17 09:10:29 -0700629#else
Ajay Dudanib01e5062011-12-03 23:23:42 -0800630 status +=
631 config_dsi_video_mode(display_wd, display_ht, image_wd, image_ht,
632 hsync_porch_fp, hsync_porch_bp,
633 vsync_porch_fp, vsync_porch_bp, hsync_width,
634 vsync_width, dst_format, traffic_mode,
635 num_of_lanes);
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700636
Ajay Dudanib01e5062011-12-03 23:23:42 -0800637 status +=
638 mdp_setup_dma_p_video_mode(display_wd, display_ht, image_wd,
639 image_ht, hsync_porch_fp, hsync_porch_bp,
640 vsync_porch_fp, vsync_porch_bp,
641 hsync_width, vsync_width, MIPI_FB_ADDR,
642 image_wd, pack_pattern, ystride);
Kinson Chike5c93432011-06-17 09:10:29 -0700643#endif
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700644
Ajay Dudanib01e5062011-12-03 23:23:42 -0800645 ReadValue = readl(DSI_INT_CTRL) & 0x00010000;
646 while (ReadValue != 0x00010000) {
647 ReadValue = readl(DSI_INT_CTRL) & 0x00010000;
648 count++;
649 if (count > 0xffff) {
650 status = FAIL;
651 dprintf(CRITICAL, "Video lane test failed\n");
652 return status;
653 }
654 }
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700655
Ajay Dudanib01e5062011-12-03 23:23:42 -0800656 dprintf(SPEW, "Video lane tested successfully\n");
657 return status;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700658}
659
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800660int is_cmd_mode_enabled(void)
661{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800662 return cmd_mode_status;
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800663}
664
Kinson Chike5c93432011-06-17 09:10:29 -0700665#if DISPLAY_MIPI_PANEL_NOVATEK_BLUE
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800666void mipi_dsi_cmd_mode_trigger(void)
667{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800668 int status = 0;
669 unsigned short display_wd = mipi_fb_cfg.width;
670 unsigned short display_ht = mipi_fb_cfg.height;
671 unsigned short image_wd = mipi_fb_cfg.width;
672 unsigned short image_ht = mipi_fb_cfg.height;
673 unsigned short dst_format = 0;
674 unsigned short traffic_mode = 0;
675 struct mipi_dsi_panel_config *panel_info = &novatek_panel_info;
676 status += mipi_dsi_cmd_config(mipi_fb_cfg, panel_info->num_of_lanes);
677 mdelay(50);
678 config_dsi_cmd_mode(display_wd, display_ht, image_wd, image_ht,
679 dst_format, traffic_mode,
680 panel_info->num_of_lanes /* num_of_lanes */ );
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800681}
Kinson Chike5c93432011-06-17 09:10:29 -0700682#endif
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800683
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700684void mipi_dsi_shutdown(void)
685{
Chandan Uddaraju4877d372011-07-21 12:51:51 -0700686#if (!CONT_SPLASH_SCREEN)
Ajay Dudanib01e5062011-12-03 23:23:42 -0800687 mdp_shutdown();
688 writel(0x01010101, DSI_INT_CTRL);
689 writel(0x13FF3BFF, DSI_ERR_INT_MASK0);
Kinson Chike5c93432011-06-17 09:10:29 -0700690#if DISPLAY_MIPI_PANEL_TOSHIBA_MDT61
Ajay Dudanib01e5062011-12-03 23:23:42 -0800691 /* Disable branch clocks */
Shashank Mittal30262902012-02-21 15:37:24 -0800692 writel(0x0, DSI1_BYTE_CC_REG);
693 writel(0x0, DSI_PIXEL_CC_REG);
694 writel(0x0, DSI1_ESC_CC_REG);
Ajay Dudanib01e5062011-12-03 23:23:42 -0800695 /* Disable root clock */
696 writel(0x0, DSI_CC_REG);
Aparna Mallavarapuf712f5e2011-08-04 21:11:00 +0530697#elif (!DISPLAY_MIPI_PANEL_RENESAS)
Ajay Dudanib01e5062011-12-03 23:23:42 -0800698 secure_writel(0x0, DSI_CC_REG);
Shashank Mittal30262902012-02-21 15:37:24 -0800699 secure_writel(0x0, DSI_PIXEL_CC_REG);
Kinson Chike5c93432011-06-17 09:10:29 -0700700#endif
Ajay Dudanib01e5062011-12-03 23:23:42 -0800701 writel(0, DSI_CLK_CTRL);
702 writel(0, DSI_CTRL);
703 writel(0, DSIPHY_PLL_CTRL(0));
Chandan Uddaraju4877d372011-07-21 12:51:51 -0700704#else
705 /* To keep the splash screen displayed till kernel driver takes
706 control, do not turn off the video mode engine and clocks.
707 Only disabling the MIPI DSI IRQs */
708 writel(0x01010101, DSI_INT_CTRL);
709 writel(0x13FF3BFF, DSI_ERR_INT_MASK0);
710#endif
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700711}
712
713struct fbcon_config *mipi_init(void)
714{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800715 int status = 0;
716 struct mipi_dsi_panel_config *panel_info = get_panel_info();
717 /* Enable MMSS_AHB_ARB_MATER_PORT_E for arbiter master0 and master 1 request */
Aparna Mallavarapuf712f5e2011-08-04 21:11:00 +0530718#if (!DISPLAY_MIPI_PANEL_RENESAS)
Ajay Dudanib01e5062011-12-03 23:23:42 -0800719 writel(0x00001800, MMSS_SFPB_GPREG);
Aparna Mallavarapuf712f5e2011-08-04 21:11:00 +0530720#endif
Kinson Chike5c93432011-06-17 09:10:29 -0700721
722#if DISPLAY_MIPI_PANEL_TOSHIBA_MDT61
Ajay Dudanib01e5062011-12-03 23:23:42 -0800723 mipi_dsi_phy_init(panel_info);
Kinson Chike5c93432011-06-17 09:10:29 -0700724#else
Ajay Dudanib01e5062011-12-03 23:23:42 -0800725 mipi_dsi_phy_ctrl_config(panel_info);
Kinson Chike5c93432011-06-17 09:10:29 -0700726#endif
727
Ajay Dudanib01e5062011-12-03 23:23:42 -0800728 status += mipi_dsi_panel_initialize(panel_info);
Kinson Chike5c93432011-06-17 09:10:29 -0700729
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800730#if DISPLAY_MIPI_PANEL_NOVATEK_BLUE
Ajay Dudanib01e5062011-12-03 23:23:42 -0800731 mipi_dsi_cmd_bta_sw_trigger();
732 mipi_novatek_manufacture_id();
Shashank Mittalcbd271d2011-01-14 15:18:33 -0800733#endif
Ajay Dudanib01e5062011-12-03 23:23:42 -0800734 mipi_fb_cfg.base = MIPI_FB_ADDR;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700735
Ajay Dudanib01e5062011-12-03 23:23:42 -0800736 if (panel_info->mode == MIPI_VIDEO_MODE)
737 status += mipi_dsi_video_config(panel_info->num_of_lanes);
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800738
Ajay Dudanib01e5062011-12-03 23:23:42 -0800739 if (panel_info->mode == MIPI_CMD_MODE)
740 cmd_mode_status = 1;
Chandan Uddarajufe93e822010-11-21 20:44:47 -0800741
Ajay Dudanib01e5062011-12-03 23:23:42 -0800742 return &mipi_fb_cfg;
Chandan Uddaraju78ae6752010-10-19 12:57:10 -0700743}