Dhaval Patel | 5b22fe7 | 2014-01-02 16:28:38 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2010-2014, The Linux Foundation. All rights reserved. |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 2 | * |
| 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 Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 12 | * * Neither the name of The Linux Foundation nor the names of its |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 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 Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 31 | #include <endian.h> |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 32 | #include <mipi_dsi.h> |
| 33 | #include <dev/fbcon.h> |
Greg Grisco | d625055 | 2011-06-29 14:40:23 -0700 | [diff] [blame] | 34 | #include <stdlib.h> |
Greg Grisco | 1073a5e | 2011-07-28 18:59:18 -0700 | [diff] [blame] | 35 | #include <string.h> |
Kinson Chik | e5c9343 | 2011-06-17 09:10:29 -0700 | [diff] [blame] | 36 | #include <debug.h> |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -0700 | [diff] [blame] | 37 | #include <target/display.h> |
| 38 | #include <platform/iomap.h> |
| 39 | #include <platform/clock.h> |
Greg Grisco | 1073a5e | 2011-07-28 18:59:18 -0700 | [diff] [blame] | 40 | #include <platform/timer.h> |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 41 | #include <err.h> |
| 42 | #include <msm_panel.h> |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -0700 | [diff] [blame] | 43 | |
| 44 | extern void mdp_disable(void); |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 45 | extern int mipi_dsi_cmd_config(struct fbcon_config mipi_fb_cfg, |
| 46 | unsigned short num_of_lanes); |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -0700 | [diff] [blame] | 47 | extern void mdp_shutdown(void); |
| 48 | extern void mdp_start_dma(void); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 49 | |
Siddhartha Agrawal | 1b2ed84 | 2013-05-29 18:02:28 -0700 | [diff] [blame] | 50 | #if (DISPLAY_TYPE_MDSS == 0) |
| 51 | #define MIPI_DSI0_BASE MIPI_DSI_BASE |
| 52 | #define MIPI_DSI1_BASE MIPI_DSI_BASE |
| 53 | #endif |
| 54 | |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 55 | static struct fbcon_config mipi_fb_cfg = { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 56 | .height = 0, |
| 57 | .width = 0, |
| 58 | .stride = 0, |
| 59 | .format = 0, |
| 60 | .bpp = 0, |
| 61 | .update_start = NULL, |
| 62 | .update_done = NULL, |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 63 | }; |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 64 | |
| 65 | static int cmd_mode_status = 0; |
Greg Grisco | d625055 | 2011-06-29 14:40:23 -0700 | [diff] [blame] | 66 | void secure_writel(uint32_t, uint32_t); |
| 67 | uint32_t secure_readl(uint32_t); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 68 | |
Shivaraj Shetty | 6460403 | 2013-11-14 16:44:10 +0530 | [diff] [blame] | 69 | static uint32_t response_value = 0; |
| 70 | |
| 71 | uint32_t mdss_dsi_read_panel_signature(uint32_t panel_signature) |
| 72 | { |
| 73 | uint32_t rec_buf[1]; |
| 74 | uint32_t *lp = rec_buf, data; |
| 75 | int ret = response_value; |
| 76 | |
| 77 | #if (DISPLAY_TYPE_MDSS == 1) |
| 78 | if (ret && ret != panel_signature) |
| 79 | goto exit_read_signature; |
| 80 | |
| 81 | ret = mipi_dsi_cmds_tx(&read_ddb_start_cmd, 1); |
| 82 | if (ret) |
| 83 | goto exit_read_signature; |
| 84 | if (!mdss_dsi_cmds_rx(&lp, 1, 1)) |
| 85 | goto exit_read_signature; |
| 86 | |
| 87 | data = ntohl(*lp); |
| 88 | data = data >> 8; |
| 89 | response_value = data; |
| 90 | if (response_value != panel_signature) |
| 91 | ret = response_value; |
| 92 | |
| 93 | exit_read_signature: |
| 94 | /* Keep the non detectable panel at the end and set panel signature 0xFFFF */ |
| 95 | if (panel_signature == 0xFFFF) |
| 96 | ret = 0; |
| 97 | #endif |
| 98 | return ret; |
| 99 | } |
| 100 | |
Siddhartha Agrawal | 980b5ee | 2013-05-30 12:17:50 -0700 | [diff] [blame] | 101 | int mdss_dual_dsi_cmd_dma_trigger_for_panel() |
| 102 | { |
| 103 | uint32_t ReadValue; |
| 104 | uint32_t count = 0; |
| 105 | int status = 0; |
| 106 | |
Terence Hampson | cc3345c | 2013-06-27 15:30:10 -0400 | [diff] [blame] | 107 | #if (DISPLAY_TYPE_MDSS == 1) |
Siddhartha Agrawal | 980b5ee | 2013-05-30 12:17:50 -0700 | [diff] [blame] | 108 | writel(0x03030303, MIPI_DSI0_BASE + INT_CTRL); |
| 109 | writel(0x1, MIPI_DSI0_BASE + CMD_MODE_DMA_SW_TRIGGER); |
| 110 | dsb(); |
| 111 | |
| 112 | writel(0x03030303, MIPI_DSI1_BASE + INT_CTRL); |
| 113 | writel(0x1, MIPI_DSI1_BASE + CMD_MODE_DMA_SW_TRIGGER); |
| 114 | dsb(); |
| 115 | |
| 116 | ReadValue = readl(MIPI_DSI1_BASE + INT_CTRL) & 0x00000001; |
| 117 | while (ReadValue != 0x00000001) { |
| 118 | ReadValue = readl(MIPI_DSI1_BASE + INT_CTRL) & 0x00000001; |
| 119 | count++; |
| 120 | if (count > 0xffff) { |
| 121 | status = FAIL; |
| 122 | dprintf(CRITICAL, |
| 123 | "Panel CMD: command mode dma test failed\n"); |
| 124 | return status; |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | writel((readl(MIPI_DSI1_BASE + INT_CTRL) | 0x01000001), |
| 129 | MIPI_DSI1_BASE + INT_CTRL); |
| 130 | dprintf(SPEW, "Panel CMD: command mode dma tested successfully\n"); |
Terence Hampson | cc3345c | 2013-06-27 15:30:10 -0400 | [diff] [blame] | 131 | #endif |
Siddhartha Agrawal | 980b5ee | 2013-05-30 12:17:50 -0700 | [diff] [blame] | 132 | return status; |
| 133 | } |
| 134 | |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 135 | int dsi_cmd_dma_trigger_for_panel() |
| 136 | { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 137 | unsigned long ReadValue; |
| 138 | unsigned long count = 0; |
| 139 | int status = 0; |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 140 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 141 | writel(0x03030303, DSI_INT_CTRL); |
| 142 | writel(0x1, DSI_CMD_MODE_DMA_SW_TRIGGER); |
| 143 | dsb(); |
| 144 | ReadValue = readl(DSI_INT_CTRL) & 0x00000001; |
| 145 | while (ReadValue != 0x00000001) { |
| 146 | ReadValue = readl(DSI_INT_CTRL) & 0x00000001; |
| 147 | count++; |
| 148 | if (count > 0xffff) { |
| 149 | status = FAIL; |
| 150 | dprintf(CRITICAL, |
| 151 | "Panel CMD: command mode dma test failed\n"); |
| 152 | return status; |
| 153 | } |
| 154 | } |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 155 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 156 | writel((readl(DSI_INT_CTRL) | 0x01000001), DSI_INT_CTRL); |
| 157 | dprintf(SPEW, "Panel CMD: command mode dma tested successfully\n"); |
| 158 | return status; |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 159 | } |
| 160 | |
Siddhartha Agrawal | 007ea9e | 2014-10-14 15:02:48 -0700 | [diff] [blame] | 161 | int mdss_dsi_wait4_video_done() |
| 162 | { |
| 163 | unsigned long read; |
| 164 | unsigned long count = 0; |
| 165 | int status = 0; |
| 166 | |
Padmanabhan Komanduru | 66459a9 | 2014-11-04 00:05:08 +0530 | [diff] [blame] | 167 | /* If video mode is not enabled, return here */ |
| 168 | if ((readl(DSI_CTRL) & BIT(1)) == 0) |
| 169 | return 0; |
| 170 | |
Siddhartha Agrawal | 007ea9e | 2014-10-14 15:02:48 -0700 | [diff] [blame] | 171 | read = readl(DSI_INT_CTRL); |
| 172 | /* Enable VIDEO MODE DONE MASK and clear the interrupt */ |
| 173 | read = read | DSI_VIDEO_MODE_DONE_MASK | DSI_VIDEO_MODE_DONE_AK; |
| 174 | writel(read, DSI_INT_CTRL); |
| 175 | dsb(); |
| 176 | read = readl(DSI_INT_CTRL) & DSI_VIDEO_MODE_DONE_STAT; |
| 177 | while (!read) { |
| 178 | read = readl(DSI_INT_CTRL) & DSI_VIDEO_MODE_DONE_STAT; |
| 179 | count++; |
| 180 | if (count > 0xffff) { |
| 181 | status = FAIL; |
| 182 | dprintf(CRITICAL, |
| 183 | "Panel CMD: Did not recieve video mode done interrupt\n"); |
| 184 | return status; |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | writel((readl(DSI_INT_CTRL) | 0x01000001), DSI_INT_CTRL); |
| 189 | dprintf(SPEW, "Panel wait_4_video_done: Recieved video mode done ack\n"); |
Padmanabhan Komanduru | 66459a9 | 2014-11-04 00:05:08 +0530 | [diff] [blame] | 190 | |
| 191 | /* Skip BLLP 4ms */ |
| 192 | mdelay(4); |
| 193 | |
Siddhartha Agrawal | 007ea9e | 2014-10-14 15:02:48 -0700 | [diff] [blame] | 194 | return status; |
| 195 | |
| 196 | } |
| 197 | |
Siddhartha Agrawal | 980b5ee | 2013-05-30 12:17:50 -0700 | [diff] [blame] | 198 | int mdss_dual_dsi_cmds_tx(struct mipi_dsi_cmd *cmds, int count) |
| 199 | { |
| 200 | int ret = 0; |
| 201 | struct mipi_dsi_cmd *cm; |
| 202 | int i = 0; |
| 203 | char pload[256]; |
| 204 | uint32_t off; |
| 205 | |
Terence Hampson | cc3345c | 2013-06-27 15:30:10 -0400 | [diff] [blame] | 206 | #if (DISPLAY_TYPE_MDSS == 1) |
Siddhartha Agrawal | 980b5ee | 2013-05-30 12:17:50 -0700 | [diff] [blame] | 207 | /* Align pload at 8 byte boundry */ |
| 208 | off = pload; |
| 209 | off &= 0x07; |
| 210 | if (off) |
| 211 | off = 8 - off; |
| 212 | off += pload; |
| 213 | |
| 214 | cm = cmds; |
| 215 | for (i = 0; i < count; i++) { |
Padmanabhan Komanduru | 66459a9 | 2014-11-04 00:05:08 +0530 | [diff] [blame] | 216 | /* Wait for VIDEO_MODE_DONE */ |
| 217 | ret = mdss_dsi_wait4_video_done(); |
| 218 | if (ret) |
| 219 | goto wait4video_error; |
Siddhartha Agrawal | 007ea9e | 2014-10-14 15:02:48 -0700 | [diff] [blame] | 220 | |
Siddhartha Agrawal | 980b5ee | 2013-05-30 12:17:50 -0700 | [diff] [blame] | 221 | memcpy((void *)off, (cm->payload), cm->size); |
| 222 | writel(off, MIPI_DSI0_BASE + DMA_CMD_OFFSET); |
| 223 | writel(cm->size, MIPI_DSI0_BASE + DMA_CMD_LENGTH); // reg 0x48 for this build |
| 224 | writel(off, MIPI_DSI1_BASE + DMA_CMD_OFFSET); |
| 225 | writel(cm->size, MIPI_DSI1_BASE + DMA_CMD_LENGTH); // reg 0x48 for this build |
| 226 | dsb(); |
| 227 | ret += mdss_dual_dsi_cmd_dma_trigger_for_panel(); |
Dhaval Patel | 607a624 | 2013-10-29 12:37:24 -0700 | [diff] [blame] | 228 | if (cm->wait) |
| 229 | mdelay(cm->wait); |
| 230 | else |
| 231 | udelay(80); |
Siddhartha Agrawal | 980b5ee | 2013-05-30 12:17:50 -0700 | [diff] [blame] | 232 | cm++; |
| 233 | } |
Siddhartha Agrawal | 007ea9e | 2014-10-14 15:02:48 -0700 | [diff] [blame] | 234 | wait4video_error: |
Padmanabhan Komanduru | 66459a9 | 2014-11-04 00:05:08 +0530 | [diff] [blame] | 235 | #endif |
Siddhartha Agrawal | 980b5ee | 2013-05-30 12:17:50 -0700 | [diff] [blame] | 236 | return ret; |
| 237 | } |
| 238 | |
Casey Piper | 8403675 | 2013-09-05 14:56:37 -0700 | [diff] [blame] | 239 | int mdss_dsi_cmds_rx(uint32_t **rp, int rp_len, int rdbk_len) |
| 240 | { |
| 241 | uint32_t *lp, data; |
| 242 | char *dp; |
| 243 | int i, off; |
| 244 | int rlen, res; |
| 245 | |
| 246 | if (rdbk_len > rp_len) { |
| 247 | return 0; |
| 248 | } |
| 249 | |
| 250 | if (rdbk_len <= 2) |
| 251 | rlen = 4; /* short read */ |
| 252 | else |
| 253 | rlen = MIPI_DSI_MRPS + 6; /* 4 bytes header + 2 bytes crc */ |
| 254 | |
| 255 | if (rlen > MIPI_DSI_REG_LEN) { |
| 256 | return 0; |
| 257 | } |
| 258 | |
| 259 | res = rlen & 0x03; |
| 260 | |
| 261 | rlen += res; /* 4 byte align */ |
| 262 | lp = *rp; |
| 263 | |
| 264 | rlen += 3; |
| 265 | rlen >>= 2; |
| 266 | |
| 267 | if (rlen > 4) |
| 268 | rlen = 4; /* 4 x 32 bits registers only */ |
| 269 | |
Shivaraj Shetty | 3c77da6 | 2013-12-09 15:58:16 +0530 | [diff] [blame] | 270 | off = RDBK_DATA0; |
Casey Piper | 8403675 | 2013-09-05 14:56:37 -0700 | [diff] [blame] | 271 | off += ((rlen - 1) * 4); |
| 272 | |
| 273 | for (i = 0; i < rlen; i++) { |
| 274 | data = readl(MIPI_DSI_BASE + off); |
| 275 | *lp = ntohl(data); /* to network byte order */ |
| 276 | lp++; |
| 277 | |
| 278 | off -= 4; |
| 279 | } |
| 280 | |
| 281 | if (rdbk_len > 2) { |
| 282 | /*First 4 bytes + paded bytes will be header next len bytes would be payload */ |
| 283 | for (i = 0; i < rdbk_len; i++) { |
| 284 | dp = *rp; |
| 285 | dp[i] = dp[(res + i) >> 2]; |
| 286 | } |
| 287 | } |
| 288 | return rdbk_len; |
| 289 | } |
| 290 | |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 291 | int mipi_dsi_cmds_tx(struct mipi_dsi_cmd *cmds, int count) |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 292 | { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 293 | int ret = 0; |
| 294 | struct mipi_dsi_cmd *cm; |
| 295 | int i = 0; |
| 296 | char pload[256]; |
| 297 | uint32_t off; |
Deepa Dinamani | a080a40 | 2011-11-05 18:59:26 -0700 | [diff] [blame] | 298 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 299 | /* Align pload at 8 byte boundry */ |
| 300 | off = pload; |
| 301 | off &= 0x07; |
| 302 | if (off) |
| 303 | off = 8 - off; |
| 304 | off += pload; |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 305 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 306 | cm = cmds; |
| 307 | for (i = 0; i < count; i++) { |
Padmanabhan Komanduru | 66459a9 | 2014-11-04 00:05:08 +0530 | [diff] [blame] | 308 | /* Wait for VIDEO_MODE_DONE */ |
| 309 | ret = mdss_dsi_wait4_video_done(); |
| 310 | if (ret) |
| 311 | goto mipi_cmds_error; |
Siddhartha Agrawal | 007ea9e | 2014-10-14 15:02:48 -0700 | [diff] [blame] | 312 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 313 | memcpy((void *)off, (cm->payload), cm->size); |
| 314 | writel(off, DSI_DMA_CMD_OFFSET); |
| 315 | writel(cm->size, DSI_DMA_CMD_LENGTH); // reg 0x48 for this build |
| 316 | dsb(); |
| 317 | ret += dsi_cmd_dma_trigger_for_panel(); |
Sangani Suryanarayana Raju | 769f9ac | 2013-04-30 19:05:06 +0530 | [diff] [blame] | 318 | dsb(); |
| 319 | if (cm->wait) |
| 320 | mdelay(cm->wait); |
| 321 | else |
| 322 | udelay(80); |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 323 | cm++; |
| 324 | } |
Siddhartha Agrawal | 007ea9e | 2014-10-14 15:02:48 -0700 | [diff] [blame] | 325 | mipi_cmds_error: |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 326 | return ret; |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 327 | } |
| 328 | |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 329 | /* |
| 330 | * mipi_dsi_cmd_rx: can receive at most 16 bytes |
| 331 | * per transaction since it only have 4 32bits reigsters |
| 332 | * to hold data. |
| 333 | * therefore Maximum Return Packet Size need to be set to 16. |
| 334 | * any return data more than MRPS need to be break down |
| 335 | * to multiple transactions. |
| 336 | */ |
| 337 | int mipi_dsi_cmds_rx(char **rp, int len) |
| 338 | { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 339 | uint32_t *lp, data; |
| 340 | char *dp; |
| 341 | int i, off, cnt; |
| 342 | int rlen, res; |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 343 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 344 | if (len <= 2) |
| 345 | rlen = 4; /* short read */ |
| 346 | else |
| 347 | rlen = MIPI_DSI_MRPS + 6; /* 4 bytes header + 2 bytes crc */ |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 348 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 349 | if (rlen > MIPI_DSI_REG_LEN) { |
| 350 | return 0; |
| 351 | } |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 352 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 353 | res = rlen & 0x03; |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 354 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 355 | rlen += res; /* 4 byte align */ |
| 356 | lp = (uint32_t *) (*rp); |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 357 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 358 | cnt = rlen; |
| 359 | cnt += 3; |
| 360 | cnt >>= 2; |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 361 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 362 | if (cnt > 4) |
| 363 | cnt = 4; /* 4 x 32 bits registers only */ |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 364 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 365 | off = 0x068; /* DSI_RDBK_DATA0 */ |
| 366 | off += ((cnt - 1) * 4); |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 367 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 368 | for (i = 0; i < cnt; i++) { |
| 369 | data = (uint32_t) readl(MIPI_DSI_BASE + off); |
| 370 | *lp++ = ntohl(data); /* to network byte order */ |
| 371 | off -= 4; |
| 372 | } |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 373 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 374 | if (len > 2) { |
| 375 | /*First 4 bytes + paded bytes will be header next len bytes would be payload */ |
| 376 | for (i = 0; i < len; i++) { |
| 377 | dp = *rp; |
| 378 | dp[i] = dp[4 + res + i]; |
| 379 | } |
| 380 | } |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 381 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 382 | return len; |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 383 | } |
| 384 | |
| 385 | static int mipi_dsi_cmd_bta_sw_trigger(void) |
| 386 | { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 387 | uint32_t data; |
| 388 | int cnt = 0; |
| 389 | int err = 0; |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 390 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 391 | writel(0x01, MIPI_DSI_BASE + 0x094); /* trigger */ |
| 392 | while (cnt < 10000) { |
| 393 | data = readl(MIPI_DSI_BASE + 0x0004); /*DSI_STATUS */ |
| 394 | if ((data & 0x0010) == 0) |
| 395 | break; |
| 396 | cnt++; |
| 397 | } |
| 398 | if (cnt == 10000) |
| 399 | err = 1; |
| 400 | return err; |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 401 | } |
| 402 | |
Ray Zhang | 4c7e37f | 2013-12-03 17:04:55 +0800 | [diff] [blame] | 403 | int mdss_dsi_host_init(struct mipi_dsi_panel_config *pinfo, uint32_t |
Dhaval Patel | 9207dec | 2014-04-16 10:45:32 -0700 | [diff] [blame] | 404 | dual_dsi, uint32_t broadcast) |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 405 | { |
| 406 | uint8_t DMA_STREAM1 = 0; // for mdp display processor path |
| 407 | uint8_t EMBED_MODE1 = 1; // from frame buffer |
| 408 | uint8_t POWER_MODE2 = 1; // from frame buffer |
| 409 | uint8_t PACK_TYPE1; // long packet |
| 410 | uint8_t VC1 = 0; |
| 411 | uint8_t DT1 = 0; // non embedded mode |
| 412 | uint8_t WC1 = 0; // for non embedded mode only |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 413 | uint8_t DLNx_EN; |
Siddhartha Agrawal | 2679a82 | 2013-05-31 19:15:12 -0700 | [diff] [blame] | 414 | uint8_t lane_swap = 0; |
Siddhartha Agrawal | b6c861f | 2013-05-31 19:36:44 -0700 | [diff] [blame] | 415 | uint32_t timing_ctl = 0; |
Vineet Bajaj | 2f08a36 | 2014-07-24 20:50:42 +0530 | [diff] [blame] | 416 | uint32_t lane_swap_dsi1 = 0; |
Siddhartha Agrawal | 007ea9e | 2014-10-14 15:02:48 -0700 | [diff] [blame] | 417 | uint32_t ctrl_mode = 0x105; //Default is command mode to send cmds. |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 418 | |
Terence Hampson | cc3345c | 2013-06-27 15:30:10 -0400 | [diff] [blame] | 419 | #if (DISPLAY_TYPE_MDSS == 1) |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 420 | switch (pinfo->num_of_lanes) { |
| 421 | default: |
| 422 | case 1: |
| 423 | DLNx_EN = 1; // 1 lane |
| 424 | break; |
| 425 | case 2: |
| 426 | DLNx_EN = 3; // 2 lane |
| 427 | break; |
| 428 | case 3: |
| 429 | DLNx_EN = 7; // 3 lane |
| 430 | break; |
| 431 | case 4: |
| 432 | DLNx_EN = 0x0F; /* 4 lanes */ |
| 433 | break; |
| 434 | } |
| 435 | |
| 436 | PACK_TYPE1 = pinfo->pack; |
Siddhartha Agrawal | 2679a82 | 2013-05-31 19:15:12 -0700 | [diff] [blame] | 437 | lane_swap = pinfo->lane_swap; |
Siddhartha Agrawal | b6c861f | 2013-05-31 19:36:44 -0700 | [diff] [blame] | 438 | timing_ctl = ((pinfo->t_clk_post << 8) | pinfo->t_clk_pre); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 439 | |
Siddhartha Agrawal | 007ea9e | 2014-10-14 15:02:48 -0700 | [diff] [blame] | 440 | if (pinfo->cmds_post_tg) { |
| 441 | /* |
| 442 | * Need to send pixel data before sending the ON commands |
| 443 | * so need to configure controller to VIDEO MODE. |
| 444 | */ |
| 445 | ctrl_mode = 0x103; |
| 446 | } |
| 447 | |
Dhaval Patel | 9207dec | 2014-04-16 10:45:32 -0700 | [diff] [blame] | 448 | if (dual_dsi) { |
Siddhartha Agrawal | 980b5ee | 2013-05-30 12:17:50 -0700 | [diff] [blame] | 449 | writel(0x0001, MIPI_DSI1_BASE + SOFT_RESET); |
| 450 | writel(0x0000, MIPI_DSI1_BASE + SOFT_RESET); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 451 | |
Siddhartha Agrawal | 980b5ee | 2013-05-30 12:17:50 -0700 | [diff] [blame] | 452 | writel((0 << 16) | 0x3f, MIPI_DSI1_BASE + CLK_CTRL); /* Turn on all DSI Clks */ |
| 453 | writel(DMA_STREAM1 << 8 | 0x04, MIPI_DSI1_BASE + TRIG_CTRL); // reg 0x80 dma trigger: sw |
| 454 | // trigger 0x4; dma stream1 |
| 455 | |
Siddhartha Agrawal | 007ea9e | 2014-10-14 15:02:48 -0700 | [diff] [blame] | 456 | writel(0 << 30 | DLNx_EN << 4 | ctrl_mode, MIPI_DSI1_BASE + CTRL); // reg 0x00 for this |
Siddhartha Agrawal | 980b5ee | 2013-05-30 12:17:50 -0700 | [diff] [blame] | 457 | // build |
| 458 | writel(broadcast << 31 | EMBED_MODE1 << 28 | POWER_MODE2 << 26 |
| 459 | | PACK_TYPE1 << 24 | VC1 << 22 | DT1 << 16 | WC1, |
| 460 | MIPI_DSI1_BASE + COMMAND_MODE_DMA_CTRL); |
Siddhartha Agrawal | 2679a82 | 2013-05-31 19:15:12 -0700 | [diff] [blame] | 461 | |
Vineet Bajaj | 2f08a36 | 2014-07-24 20:50:42 +0530 | [diff] [blame] | 462 | if (readl(MIPI_DSI_BASE) == DSI_HW_REV_103_1) /*for 8939 hw dsi1 has Lane_map as 3210*/ |
| 463 | lane_swap_dsi1 = 0x7; |
| 464 | else |
| 465 | lane_swap_dsi1 = lane_swap; |
| 466 | writel(lane_swap_dsi1, MIPI_DSI1_BASE + LANE_SWAP_CTL); |
Siddhartha Agrawal | b6c861f | 2013-05-31 19:36:44 -0700 | [diff] [blame] | 467 | writel(timing_ctl, MIPI_DSI1_BASE + TIMING_CTL); |
Siddhartha Agrawal | 980b5ee | 2013-05-30 12:17:50 -0700 | [diff] [blame] | 468 | } |
| 469 | |
| 470 | writel(0x0001, MIPI_DSI0_BASE + SOFT_RESET); |
| 471 | writel(0x0000, MIPI_DSI0_BASE + SOFT_RESET); |
| 472 | |
| 473 | writel((0 << 16) | 0x3f, MIPI_DSI0_BASE + CLK_CTRL); /* Turn on all DSI Clks */ |
| 474 | writel(DMA_STREAM1 << 8 | 0x04, MIPI_DSI0_BASE + TRIG_CTRL); // reg 0x80 dma trigger: sw |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 475 | // trigger 0x4; dma stream1 |
| 476 | |
Siddhartha Agrawal | 007ea9e | 2014-10-14 15:02:48 -0700 | [diff] [blame] | 477 | writel(0 << 30 | DLNx_EN << 4 | ctrl_mode, MIPI_DSI0_BASE + CTRL); // reg 0x00 for this |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 478 | // build |
Siddhartha Agrawal | 980b5ee | 2013-05-30 12:17:50 -0700 | [diff] [blame] | 479 | writel(broadcast << 31 | EMBED_MODE1 << 28 | POWER_MODE2 << 26 |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 480 | | PACK_TYPE1 << 24 | VC1 << 22 | DT1 << 16 | WC1, |
Siddhartha Agrawal | 980b5ee | 2013-05-30 12:17:50 -0700 | [diff] [blame] | 481 | MIPI_DSI0_BASE + COMMAND_MODE_DMA_CTRL); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 482 | |
Siddhartha Agrawal | 2679a82 | 2013-05-31 19:15:12 -0700 | [diff] [blame] | 483 | writel(lane_swap, MIPI_DSI0_BASE + LANE_SWAP_CTL); |
Siddhartha Agrawal | b6c861f | 2013-05-31 19:36:44 -0700 | [diff] [blame] | 484 | writel(timing_ctl, MIPI_DSI0_BASE + TIMING_CTL); |
Ray Zhang | 4c7e37f | 2013-12-03 17:04:55 +0800 | [diff] [blame] | 485 | #endif |
Siddhartha Agrawal | 2679a82 | 2013-05-31 19:15:12 -0700 | [diff] [blame] | 486 | |
Ray Zhang | 4c7e37f | 2013-12-03 17:04:55 +0800 | [diff] [blame] | 487 | return 0; |
| 488 | } |
| 489 | |
Padmanabhan Komanduru | f8986be | 2014-11-04 15:57:19 +0530 | [diff] [blame^] | 490 | void mdss_dsi_panel_shutdown(struct msm_panel_info *pinfo) |
| 491 | { |
| 492 | #if (DISPLAY_TYPE_MDSS == 1) |
| 493 | unsigned long read_val = 0; |
| 494 | if (pinfo->mipi.panel_off_cmds) { |
| 495 | /* |
| 496 | * Once MDP TG is disabled, reset of DSI controller is |
| 497 | * needed before we send panel OFF commands. |
| 498 | */ |
| 499 | if (pinfo->type == MIPI_VIDEO_PANEL) { |
| 500 | read_val = readl(MIPI_DSI0_BASE + CTRL); |
| 501 | writel((read_val & ~BIT(0)), MIPI_DSI0_BASE + CTRL); |
| 502 | writel(0x0001, MIPI_DSI0_BASE + SOFT_RESET); |
| 503 | dsb(); |
| 504 | writel(0x0000, MIPI_DSI0_BASE + SOFT_RESET); |
| 505 | dsb(); |
| 506 | /* Enable cmd mode only */ |
| 507 | writel(((read_val & ~BIT(1)) | BIT(2)), |
| 508 | MIPI_DSI0_BASE + CTRL); |
| 509 | } |
| 510 | |
| 511 | if (pinfo->mipi.broadcast) { |
| 512 | if (pinfo->type == MIPI_VIDEO_PANEL) { |
| 513 | read_val = readl(MIPI_DSI1_BASE + CTRL); |
| 514 | writel((read_val & ~BIT(0)), |
| 515 | MIPI_DSI1_BASE + CTRL); |
| 516 | |
| 517 | writel(0x0001, MIPI_DSI1_BASE + SOFT_RESET); |
| 518 | dsb(); |
| 519 | writel(0x0000, MIPI_DSI1_BASE + SOFT_RESET); |
| 520 | dsb(); |
| 521 | |
| 522 | writel(((read_val & ~BIT(1)) | BIT(2)), |
| 523 | MIPI_DSI1_BASE + CTRL); |
| 524 | } |
| 525 | mdss_dual_dsi_cmds_tx(pinfo->mipi.panel_off_cmds, |
| 526 | pinfo->mipi.num_of_panel_off_cmds); |
| 527 | } else { |
| 528 | mipi_dsi_cmds_tx(pinfo->mipi.panel_off_cmds, |
| 529 | pinfo->mipi.num_of_panel_off_cmds); |
| 530 | } |
| 531 | } |
| 532 | #endif |
| 533 | } |
| 534 | |
Ray Zhang | 4c7e37f | 2013-12-03 17:04:55 +0800 | [diff] [blame] | 535 | int mdss_dsi_panel_initialize(struct mipi_dsi_panel_config *pinfo, uint32_t |
| 536 | broadcast) |
| 537 | { |
| 538 | int status = 0; |
Siddhartha Agrawal | 007ea9e | 2014-10-14 15:02:48 -0700 | [diff] [blame] | 539 | uint32_t ctrl_mode = 0; |
Ray Zhang | 4c7e37f | 2013-12-03 17:04:55 +0800 | [diff] [blame] | 540 | |
| 541 | #if (DISPLAY_TYPE_MDSS == 1) |
Padmanabhan Komanduru | b3d3184 | 2014-11-04 15:47:53 +0530 | [diff] [blame] | 542 | if (pinfo->panel_on_cmds) { |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 543 | |
Siddhartha Agrawal | 007ea9e | 2014-10-14 15:02:48 -0700 | [diff] [blame] | 544 | ctrl_mode = readl(MIPI_DSI0_BASE + CTRL); |
Siddhartha Agrawal | 980b5ee | 2013-05-30 12:17:50 -0700 | [diff] [blame] | 545 | if (broadcast) { |
Siddhartha Agrawal | 007ea9e | 2014-10-14 15:02:48 -0700 | [diff] [blame] | 546 | /* Enable command mode before sending the commands. */ |
| 547 | writel(ctrl_mode | 0x04, MIPI_DSI0_BASE + CTRL); |
| 548 | writel(ctrl_mode | 0x04, MIPI_DSI1_BASE + CTRL); |
Padmanabhan Komanduru | b3d3184 | 2014-11-04 15:47:53 +0530 | [diff] [blame] | 549 | status = mdss_dual_dsi_cmds_tx(pinfo->panel_on_cmds, |
| 550 | pinfo->num_of_panel_on_cmds); |
Siddhartha Agrawal | 007ea9e | 2014-10-14 15:02:48 -0700 | [diff] [blame] | 551 | writel(ctrl_mode, MIPI_DSI0_BASE + CTRL); |
| 552 | writel(ctrl_mode, MIPI_DSI1_BASE + CTRL); |
Siddhartha Agrawal | 980b5ee | 2013-05-30 12:17:50 -0700 | [diff] [blame] | 553 | |
| 554 | } else { |
Siddhartha Agrawal | 007ea9e | 2014-10-14 15:02:48 -0700 | [diff] [blame] | 555 | /* Enable command mode before sending the commands. */ |
| 556 | writel(ctrl_mode | 0x04, MIPI_DSI0_BASE + CTRL); |
Padmanabhan Komanduru | b3d3184 | 2014-11-04 15:47:53 +0530 | [diff] [blame] | 557 | status = mipi_dsi_cmds_tx(pinfo->panel_on_cmds, |
| 558 | pinfo->num_of_panel_on_cmds); |
Siddhartha Agrawal | 007ea9e | 2014-10-14 15:02:48 -0700 | [diff] [blame] | 559 | writel(ctrl_mode, MIPI_DSI0_BASE + CTRL); |
Casey Piper | 8403675 | 2013-09-05 14:56:37 -0700 | [diff] [blame] | 560 | if (!status && target_panel_auto_detect_enabled()) |
| 561 | status = |
Shivaraj Shetty | 6460403 | 2013-11-14 16:44:10 +0530 | [diff] [blame] | 562 | mdss_dsi_read_panel_signature(pinfo->signature); |
Siddhartha Agrawal | 980b5ee | 2013-05-30 12:17:50 -0700 | [diff] [blame] | 563 | } |
| 564 | } |
Terence Hampson | cc3345c | 2013-06-27 15:30:10 -0400 | [diff] [blame] | 565 | #endif |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 566 | return status; |
| 567 | } |
| 568 | |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 569 | int mipi_dsi_panel_initialize(struct mipi_dsi_panel_config *pinfo) |
| 570 | { |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 571 | uint8_t DMA_STREAM1 = 0; // for mdp display processor path |
| 572 | uint8_t EMBED_MODE1 = 1; // from frame buffer |
| 573 | uint8_t POWER_MODE2 = 1; // from frame buffer |
| 574 | uint8_t PACK_TYPE1; // long packet |
| 575 | uint8_t VC1 = 0; |
| 576 | uint8_t DT1 = 0; // non embedded mode |
| 577 | uint8_t WC1 = 0; // for non embedded mode only |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 578 | int status = 0; |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 579 | uint8_t DLNx_EN; |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 580 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 581 | switch (pinfo->num_of_lanes) { |
| 582 | default: |
| 583 | case 1: |
| 584 | DLNx_EN = 1; // 1 lane |
| 585 | break; |
| 586 | case 2: |
| 587 | DLNx_EN = 3; // 2 lane |
| 588 | break; |
| 589 | case 3: |
| 590 | DLNx_EN = 7; // 3 lane |
| 591 | break; |
Amir Samuelov | 2d4ba16 | 2012-07-22 11:53:14 +0300 | [diff] [blame] | 592 | case 4: |
| 593 | DLNx_EN = 0x0F; /* 4 lanes */ |
| 594 | break; |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 595 | } |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 596 | |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 597 | PACK_TYPE1 = pinfo->pack; |
| 598 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 599 | writel(0x0001, DSI_SOFT_RESET); |
| 600 | writel(0x0000, DSI_SOFT_RESET); |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 601 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 602 | writel((0 << 16) | 0x3f, DSI_CLK_CTRL); /* Turn on all DSI Clks */ |
| 603 | writel(DMA_STREAM1 << 8 | 0x04, DSI_TRIG_CTRL); // reg 0x80 dma trigger: sw |
| 604 | // trigger 0x4; dma stream1 |
Kinson Chik | e5c9343 | 2011-06-17 09:10:29 -0700 | [diff] [blame] | 605 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 606 | writel(0 << 30 | DLNx_EN << 4 | 0x105, DSI_CTRL); // reg 0x00 for this |
| 607 | // build |
| 608 | writel(EMBED_MODE1 << 28 | POWER_MODE2 << 26 |
| 609 | | PACK_TYPE1 << 24 | VC1 << 22 | DT1 << 16 | WC1, |
| 610 | DSI_COMMAND_MODE_DMA_CTRL); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 611 | |
Padmanabhan Komanduru | b3d3184 | 2014-11-04 15:47:53 +0530 | [diff] [blame] | 612 | if (pinfo->panel_on_cmds) |
| 613 | status = mipi_dsi_cmds_tx(pinfo->panel_on_cmds, |
| 614 | pinfo->num_of_panel_on_cmds); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 615 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 616 | return status; |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 617 | } |
| 618 | |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 619 | void mipi_dsi_shutdown(void) |
| 620 | { |
Amol Jadi | 6834f1a | 2012-06-29 14:42:59 -0700 | [diff] [blame] | 621 | if(!target_cont_splash_screen()) |
| 622 | { |
| 623 | mdp_shutdown(); |
| 624 | writel(0x01010101, DSI_INT_CTRL); |
| 625 | writel(0x13FF3BFF, DSI_ERR_INT_MASK0); |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 626 | |
Amol Jadi | 6834f1a | 2012-06-29 14:42:59 -0700 | [diff] [blame] | 627 | writel(0, DSI_CLK_CTRL); |
| 628 | writel(0, DSI_CTRL); |
| 629 | writel(0, DSIPHY_PLL_CTRL(0)); |
| 630 | } |
| 631 | else |
| 632 | { |
Chandan Uddaraju | 4877d37 | 2011-07-21 12:51:51 -0700 | [diff] [blame] | 633 | /* To keep the splash screen displayed till kernel driver takes |
| 634 | control, do not turn off the video mode engine and clocks. |
| 635 | Only disabling the MIPI DSI IRQs */ |
| 636 | writel(0x01010101, DSI_INT_CTRL); |
| 637 | writel(0x13FF3BFF, DSI_ERR_INT_MASK0); |
Amol Jadi | 6834f1a | 2012-06-29 14:42:59 -0700 | [diff] [blame] | 638 | } |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 639 | } |
| 640 | |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 641 | int mipi_config(struct msm_fb_panel_data *panel) |
| 642 | { |
| 643 | int ret = NO_ERROR; |
| 644 | struct msm_panel_info *pinfo; |
| 645 | struct mipi_dsi_panel_config mipi_pinfo; |
| 646 | |
| 647 | if (!panel) |
| 648 | return ERR_INVALID_ARGS; |
| 649 | |
| 650 | pinfo = &(panel->panel_info); |
| 651 | mipi_pinfo.mode = pinfo->mipi.mode; |
| 652 | mipi_pinfo.num_of_lanes = pinfo->mipi.num_of_lanes; |
| 653 | mipi_pinfo.dsi_phy_config = pinfo->mipi.dsi_phy_db; |
Padmanabhan Komanduru | b3d3184 | 2014-11-04 15:47:53 +0530 | [diff] [blame] | 654 | mipi_pinfo.panel_on_cmds = pinfo->mipi.panel_on_cmds; |
| 655 | mipi_pinfo.num_of_panel_on_cmds = pinfo->mipi.num_of_panel_on_cmds; |
Channagoud Kadabi | 539ef72 | 2012-03-29 16:02:50 +0530 | [diff] [blame] | 656 | mipi_pinfo.lane_swap = pinfo->mipi.lane_swap; |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 657 | mipi_pinfo.pack = 1; |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 658 | |
| 659 | /* Enable MMSS_AHB_ARB_MATER_PORT_E for |
| 660 | arbiter master0 and master 1 request */ |
Terence Hampson | f49ff4e | 2013-06-18 15:11:31 -0400 | [diff] [blame] | 661 | #if (!DISPLAY_MIPI_PANEL_RENESAS && !DISPLAY_TYPE_DSI6G && !DISPLAY_TYPE_8610) |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 662 | writel(0x00001800, MMSS_SFPB_GPREG); |
| 663 | #endif |
| 664 | |
| 665 | mipi_dsi_phy_init(&mipi_pinfo); |
| 666 | |
| 667 | ret += mipi_dsi_panel_initialize(&mipi_pinfo); |
| 668 | |
Channagoud Kadabi | 01c9182 | 2012-06-06 15:53:30 +0530 | [diff] [blame] | 669 | if (pinfo->rotate && panel->rotate) |
| 670 | pinfo->rotate(); |
| 671 | |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 672 | return ret; |
| 673 | } |
| 674 | |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 675 | int mdss_dsi_video_mode_config(uint16_t disp_width, |
| 676 | uint16_t disp_height, |
| 677 | uint16_t img_width, |
| 678 | uint16_t img_height, |
| 679 | uint16_t hsync_porch0_fp, |
| 680 | uint16_t hsync_porch0_bp, |
| 681 | uint16_t vsync_porch0_fp, |
| 682 | uint16_t vsync_porch0_bp, |
| 683 | uint16_t hsync_width, |
| 684 | uint16_t vsync_width, |
| 685 | uint16_t dst_format, |
| 686 | uint16_t traffic_mode, |
| 687 | uint8_t lane_en, |
| 688 | uint16_t low_pwr_stop_mode, |
| 689 | uint8_t eof_bllp_pwr, |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 690 | uint8_t interleav, |
| 691 | uint32_t ctl_base) |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 692 | { |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 693 | int status = 0; |
| 694 | |
Terence Hampson | cc3345c | 2013-06-27 15:30:10 -0400 | [diff] [blame] | 695 | #if (DISPLAY_TYPE_MDSS == 1) |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 696 | /* disable mdp first */ |
| 697 | mdp_disable(); |
| 698 | |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 699 | writel(0x00000000, ctl_base + CLK_CTRL); |
| 700 | writel(0x00000002, ctl_base + CLK_CTRL); |
| 701 | writel(0x00000006, ctl_base + CLK_CTRL); |
| 702 | writel(0x0000000e, ctl_base + CLK_CTRL); |
| 703 | writel(0x0000001e, ctl_base + CLK_CTRL); |
| 704 | writel(0x0000023f, ctl_base + CLK_CTRL); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 705 | |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 706 | writel(0, ctl_base + CTRL); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 707 | |
Padmanabhan Komanduru | 7860be5 | 2014-03-18 19:07:36 +0530 | [diff] [blame] | 708 | writel(0x13ff3fe0, ctl_base + ERR_INT_MASK0); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 709 | |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 710 | writel(0x02020202, ctl_base + INT_CTRL); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 711 | |
Padmanabhan Komanduru | daebf6b | 2014-08-20 20:39:40 +0530 | [diff] [blame] | 712 | /* For 8916/8939, enable DSI timing double buffering */ |
Shivaraj Shetty | 41d2d48 | 2014-11-04 16:07:32 +0530 | [diff] [blame] | 713 | if (readl(ctl_base) == DSI_HW_REV_103_1 && |
| 714 | mdp_get_revision() != MDP_REV_305) |
Padmanabhan Komanduru | daebf6b | 2014-08-20 20:39:40 +0530 | [diff] [blame] | 715 | writel(0x1, ctl_base + TIMING_DB_MODE); |
| 716 | |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 717 | writel(((disp_width + hsync_porch0_bp) << 16) | hsync_porch0_bp, |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 718 | ctl_base + VIDEO_MODE_ACTIVE_H); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 719 | |
| 720 | writel(((disp_height + vsync_porch0_bp) << 16) | (vsync_porch0_bp), |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 721 | ctl_base + VIDEO_MODE_ACTIVE_V); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 722 | |
Terence Hampson | 7385f6a | 2013-08-16 15:31:25 -0400 | [diff] [blame] | 723 | if (mdp_get_revision() >= MDP_REV_41 || |
Shivaraj Shetty | f9e10c4 | 2014-09-17 04:21:15 +0530 | [diff] [blame] | 724 | mdp_get_revision() == MDP_REV_304 || |
| 725 | mdp_get_revision() == MDP_REV_305) { |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 726 | writel(((disp_height + vsync_porch0_fp |
| 727 | + vsync_porch0_bp - 1) << 16) |
| 728 | | (disp_width + hsync_porch0_fp |
| 729 | + hsync_porch0_bp - 1), |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 730 | ctl_base + VIDEO_MODE_TOTAL); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 731 | } else { |
| 732 | writel(((disp_height + vsync_porch0_fp |
| 733 | + vsync_porch0_bp) << 16) |
| 734 | | (disp_width + hsync_porch0_fp |
| 735 | + hsync_porch0_bp), |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 736 | ctl_base + VIDEO_MODE_TOTAL); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 737 | } |
| 738 | |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 739 | writel((hsync_width << 16) | 0, ctl_base + VIDEO_MODE_HSYNC); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 740 | |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 741 | writel(0 << 16 | 0, ctl_base + VIDEO_MODE_VSYNC); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 742 | |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 743 | writel(vsync_width << 16 | 0, ctl_base + VIDEO_MODE_VSYNC_VPOS); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 744 | |
Padmanabhan Komanduru | daebf6b | 2014-08-20 20:39:40 +0530 | [diff] [blame] | 745 | /* For 8916/8939, flush the DSI timing registers */ |
Shivaraj Shetty | 41d2d48 | 2014-11-04 16:07:32 +0530 | [diff] [blame] | 746 | if (readl(ctl_base) == DSI_HW_REV_103_1 && |
| 747 | mdp_get_revision() != MDP_REV_305) |
Padmanabhan Komanduru | daebf6b | 2014-08-20 20:39:40 +0530 | [diff] [blame] | 748 | writel(0x1, ctl_base + TIMING_FLUSH); |
| 749 | |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 750 | writel(0x0, ctl_base + EOT_PACKET_CTRL); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 751 | |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 752 | writel(0x00000100, ctl_base + MISR_VIDEO_CTRL); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 753 | |
Shivaraj Shetty | 41d2d48 | 2014-11-04 16:07:32 +0530 | [diff] [blame] | 754 | if (mdp_get_revision() >= MDP_REV_41 || mdp_get_revision() == MDP_REV_305) { |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 755 | writel(low_pwr_stop_mode << 16 | |
| 756 | eof_bllp_pwr << 12 | traffic_mode << 8 |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 757 | | dst_format << 4 | 0x0, ctl_base + VIDEO_MODE_CTRL); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 758 | } else { |
| 759 | writel(1 << 28 | 1 << 24 | 1 << 20 | low_pwr_stop_mode << 16 | |
| 760 | eof_bllp_pwr << 12 | traffic_mode << 8 |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 761 | | dst_format << 4 | 0x0, ctl_base + VIDEO_MODE_CTRL); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 762 | } |
| 763 | |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 764 | writel(0x3fd08, ctl_base + HS_TIMER_CTRL); |
| 765 | writel(0x00010100, ctl_base + MISR_VIDEO_CTRL); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 766 | |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 767 | writel(0x00010100, ctl_base + INT_CTRL); |
| 768 | writel(0x02010202, ctl_base + INT_CTRL); |
| 769 | writel(0x02030303, ctl_base + INT_CTRL); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 770 | |
| 771 | writel(interleav << 30 | 0 << 24 | 0 << 20 | lane_en << 4 |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 772 | | 0x103, ctl_base + CTRL); |
Terence Hampson | cc3345c | 2013-06-27 15:30:10 -0400 | [diff] [blame] | 773 | #endif |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 774 | |
| 775 | return status; |
| 776 | } |
| 777 | |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 778 | int mdss_dsi_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 | |
Terence Hampson | cc3345c | 2013-06-27 15:30:10 -0400 | [diff] [blame] | 784 | #if (DISPLAY_TYPE_MDSS == 1) |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 785 | if (!panel) |
| 786 | return ERR_INVALID_ARGS; |
| 787 | |
| 788 | pinfo = &(panel->panel_info); |
| 789 | mipi_pinfo.mode = pinfo->mipi.mode; |
| 790 | mipi_pinfo.num_of_lanes = pinfo->mipi.num_of_lanes; |
| 791 | mipi_pinfo.mdss_dsi_phy_config = pinfo->mipi.mdss_dsi_phy_db; |
Padmanabhan Komanduru | b3d3184 | 2014-11-04 15:47:53 +0530 | [diff] [blame] | 792 | mipi_pinfo.panel_on_cmds = pinfo->mipi.panel_on_cmds; |
| 793 | mipi_pinfo.num_of_panel_on_cmds = pinfo->mipi.num_of_panel_on_cmds; |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 794 | mipi_pinfo.lane_swap = pinfo->mipi.lane_swap; |
| 795 | mipi_pinfo.pack = 0; |
Siddhartha Agrawal | b6c861f | 2013-05-31 19:36:44 -0700 | [diff] [blame] | 796 | mipi_pinfo.t_clk_pre = pinfo->mipi.t_clk_pre; |
| 797 | mipi_pinfo.t_clk_post = pinfo->mipi.t_clk_post; |
Casey Piper | 8403675 | 2013-09-05 14:56:37 -0700 | [diff] [blame] | 798 | mipi_pinfo.signature = pinfo->mipi.signature; |
Siddhartha Agrawal | 007ea9e | 2014-10-14 15:02:48 -0700 | [diff] [blame] | 799 | mipi_pinfo.cmds_post_tg = pinfo->mipi.cmds_post_tg; |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 800 | |
Padmanabhan Komanduru | cdc651e | 2014-03-25 20:25:55 +0530 | [diff] [blame] | 801 | mdss_dsi_phy_init(&mipi_pinfo, MIPI_DSI0_BASE, DSI0_PHY_BASE); |
Siddhartha Agrawal | 1b2ed84 | 2013-05-29 18:02:28 -0700 | [diff] [blame] | 802 | if (pinfo->mipi.dual_dsi) |
Padmanabhan Komanduru | cdc651e | 2014-03-25 20:25:55 +0530 | [diff] [blame] | 803 | mdss_dsi_phy_init(&mipi_pinfo, MIPI_DSI1_BASE, DSI1_PHY_BASE); |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 804 | |
Dhaval Patel | 9207dec | 2014-04-16 10:45:32 -0700 | [diff] [blame] | 805 | ret = mdss_dsi_host_init(&mipi_pinfo, pinfo->mipi.dual_dsi, |
| 806 | pinfo->mipi.broadcast); |
Ray Zhang | 4c7e37f | 2013-12-03 17:04:55 +0800 | [diff] [blame] | 807 | if (ret) { |
| 808 | dprintf(CRITICAL, "dsi host init error\n"); |
| 809 | goto error; |
| 810 | } |
| 811 | |
Xiaoming Zhou | 03fd48b | 2014-07-31 15:24:41 -0400 | [diff] [blame] | 812 | mdss_dsi_phy_contention_detection(&mipi_pinfo, DSI0_PHY_BASE); |
| 813 | |
Ray Zhang | 4c7e37f | 2013-12-03 17:04:55 +0800 | [diff] [blame] | 814 | if (panel->pre_init_func) { |
| 815 | ret = panel->pre_init_func(); |
| 816 | if (ret) { |
| 817 | dprintf(CRITICAL, "pre_init_func error\n"); |
| 818 | goto error; |
| 819 | } |
| 820 | } |
| 821 | |
Siddhartha Agrawal | 007ea9e | 2014-10-14 15:02:48 -0700 | [diff] [blame] | 822 | if (!mipi_pinfo.cmds_post_tg) { |
| 823 | ret = mdss_dsi_panel_initialize(&mipi_pinfo, pinfo->mipi.broadcast); |
| 824 | if (ret) { |
| 825 | dprintf(CRITICAL, "dsi panel init error\n"); |
| 826 | goto error; |
| 827 | } |
Ray Zhang | 4c7e37f | 2013-12-03 17:04:55 +0800 | [diff] [blame] | 828 | } |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 829 | |
| 830 | if (pinfo->rotate && panel->rotate) |
| 831 | pinfo->rotate(); |
Terence Hampson | cc3345c | 2013-06-27 15:30:10 -0400 | [diff] [blame] | 832 | #endif |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 833 | |
Ray Zhang | 4c7e37f | 2013-12-03 17:04:55 +0800 | [diff] [blame] | 834 | error: |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 835 | return ret; |
| 836 | } |
| 837 | |
Siddhartha Agrawal | 007ea9e | 2014-10-14 15:02:48 -0700 | [diff] [blame] | 838 | int mdss_dsi_post_on(struct msm_fb_panel_data *panel) |
| 839 | { |
| 840 | int ret = 0; |
| 841 | struct msm_panel_info *pinfo = &(panel->panel_info); |
| 842 | struct mipi_dsi_panel_config mipi_pinfo; |
| 843 | |
| 844 | if (pinfo->mipi.cmds_post_tg) { |
Padmanabhan Komanduru | b3d3184 | 2014-11-04 15:47:53 +0530 | [diff] [blame] | 845 | mipi_pinfo.panel_on_cmds = pinfo->mipi.panel_on_cmds; |
| 846 | mipi_pinfo.num_of_panel_on_cmds = |
| 847 | pinfo->mipi.num_of_panel_on_cmds; |
Siddhartha Agrawal | 007ea9e | 2014-10-14 15:02:48 -0700 | [diff] [blame] | 848 | mipi_pinfo.signature = pinfo->mipi.signature; |
| 849 | |
| 850 | ret = mdss_dsi_panel_initialize(&mipi_pinfo, pinfo->mipi.broadcast); |
| 851 | if (ret) { |
| 852 | dprintf(CRITICAL, "dsi panel init error\n"); |
| 853 | } |
| 854 | } |
| 855 | return ret; |
| 856 | } |
| 857 | |
Siddhartha Agrawal | 7317e48 | 2013-04-21 16:16:57 -0700 | [diff] [blame] | 858 | int mdss_dsi_cmd_mode_config(uint16_t disp_width, |
| 859 | uint16_t disp_height, |
| 860 | uint16_t img_width, |
| 861 | uint16_t img_height, |
| 862 | uint16_t dst_format, |
Xiaoming Zhou | 8d534dd | 2013-07-29 15:49:19 -0400 | [diff] [blame] | 863 | uint8_t ystride, |
| 864 | uint8_t lane_en, |
Dhaval Patel | 5b22fe7 | 2014-01-02 16:28:38 -0800 | [diff] [blame] | 865 | uint8_t interleav, |
| 866 | uint32_t ctl_base) |
Siddhartha Agrawal | 7317e48 | 2013-04-21 16:16:57 -0700 | [diff] [blame] | 867 | { |
Xiaoming Zhou | 8d534dd | 2013-07-29 15:49:19 -0400 | [diff] [blame] | 868 | uint16_t dst_fmt = 0; |
| 869 | |
| 870 | switch (dst_format) { |
| 871 | case DSI_VIDEO_DST_FORMAT_RGB565: |
| 872 | dst_fmt = DSI_CMD_DST_FORMAT_RGB565; |
| 873 | break; |
| 874 | case DSI_VIDEO_DST_FORMAT_RGB666: |
| 875 | case DSI_VIDEO_DST_FORMAT_RGB666_LOOSE: |
| 876 | dst_fmt = DSI_CMD_DST_FORMAT_RGB666; |
| 877 | break; |
| 878 | case DSI_VIDEO_DST_FORMAT_RGB888: |
| 879 | dst_fmt = DSI_CMD_DST_FORMAT_RGB888; |
| 880 | break; |
| 881 | default: |
| 882 | dprintf(CRITICAL, "unsupported dst format\n"); |
| 883 | return ERROR; |
| 884 | } |
Siddhartha Agrawal | 7317e48 | 2013-04-21 16:16:57 -0700 | [diff] [blame] | 885 | |
Terence Hampson | cc3345c | 2013-06-27 15:30:10 -0400 | [diff] [blame] | 886 | #if (DISPLAY_TYPE_MDSS == 1) |
Dhaval Patel | 5b22fe7 | 2014-01-02 16:28:38 -0800 | [diff] [blame] | 887 | writel(0x00000000, ctl_base + CLK_CTRL); |
| 888 | writel(0x00000000, ctl_base + CLK_CTRL); |
| 889 | writel(0x00000000, ctl_base + CLK_CTRL); |
| 890 | writel(0x00000000, ctl_base + CLK_CTRL); |
| 891 | writel(0x00000002, ctl_base + CLK_CTRL); |
| 892 | writel(0x00000006, ctl_base + CLK_CTRL); |
| 893 | writel(0x0000000e, ctl_base + CLK_CTRL); |
| 894 | writel(0x0000001e, ctl_base + CLK_CTRL); |
| 895 | writel(0x0000023f, ctl_base + CLK_CTRL); |
Siddhartha Agrawal | 7317e48 | 2013-04-21 16:16:57 -0700 | [diff] [blame] | 896 | |
Dhaval Patel | 5b22fe7 | 2014-01-02 16:28:38 -0800 | [diff] [blame] | 897 | writel(0, ctl_base + CTRL); |
Siddhartha Agrawal | 7317e48 | 2013-04-21 16:16:57 -0700 | [diff] [blame] | 898 | |
Padmanabhan Komanduru | 7860be5 | 2014-03-18 19:07:36 +0530 | [diff] [blame] | 899 | writel(0x13ff3fe0, ctl_base + ERR_INT_MASK0); |
Siddhartha Agrawal | 7317e48 | 2013-04-21 16:16:57 -0700 | [diff] [blame] | 900 | |
Dhaval Patel | 5b22fe7 | 2014-01-02 16:28:38 -0800 | [diff] [blame] | 901 | writel(0x02020202, ctl_base + INT_CTRL); |
Siddhartha Agrawal | 7317e48 | 2013-04-21 16:16:57 -0700 | [diff] [blame] | 902 | |
Dhaval Patel | 5b22fe7 | 2014-01-02 16:28:38 -0800 | [diff] [blame] | 903 | writel(dst_fmt, ctl_base + COMMAND_MODE_MDP_CTRL); |
Siddhartha Agrawal | 7317e48 | 2013-04-21 16:16:57 -0700 | [diff] [blame] | 904 | writel((img_width * ystride + 1) << 16 | 0x0039, |
Dhaval Patel | 5b22fe7 | 2014-01-02 16:28:38 -0800 | [diff] [blame] | 905 | ctl_base + COMMAND_MODE_MDP_STREAM0_CTRL); |
Siddhartha Agrawal | 7317e48 | 2013-04-21 16:16:57 -0700 | [diff] [blame] | 906 | writel((img_width * ystride + 1) << 16 | 0x0039, |
Dhaval Patel | 5b22fe7 | 2014-01-02 16:28:38 -0800 | [diff] [blame] | 907 | ctl_base + COMMAND_MODE_MDP_STREAM1_CTRL); |
Siddhartha Agrawal | 7317e48 | 2013-04-21 16:16:57 -0700 | [diff] [blame] | 908 | writel(img_height << 16 | img_width, |
Dhaval Patel | 5b22fe7 | 2014-01-02 16:28:38 -0800 | [diff] [blame] | 909 | ctl_base + COMMAND_MODE_MDP_STREAM0_TOTAL); |
Siddhartha Agrawal | 7317e48 | 2013-04-21 16:16:57 -0700 | [diff] [blame] | 910 | writel(img_height << 16 | img_width, |
Dhaval Patel | 5b22fe7 | 2014-01-02 16:28:38 -0800 | [diff] [blame] | 911 | ctl_base + COMMAND_MODE_MDP_STREAM1_TOTAL); |
| 912 | writel(0x13c2c, ctl_base + COMMAND_MODE_MDP_DCS_CMD_CTRL); |
Xiaoming Zhou | 8d534dd | 2013-07-29 15:49:19 -0400 | [diff] [blame] | 913 | writel(interleav << 30 | 0 << 24 | 0 << 20 | lane_en << 4 | 0x105, |
Dhaval Patel | 5b22fe7 | 2014-01-02 16:28:38 -0800 | [diff] [blame] | 914 | ctl_base + CTRL); |
Padmanabhan Komanduru | 7860be5 | 2014-03-18 19:07:36 +0530 | [diff] [blame] | 915 | writel(0x14000000, ctl_base + COMMAND_MODE_DMA_CTRL); |
Dhaval Patel | 5b22fe7 | 2014-01-02 16:28:38 -0800 | [diff] [blame] | 916 | writel(0x10000000, ctl_base + MISR_CMD_CTRL); |
Xiaoming Zhou | a046933 | 2014-03-04 18:34:24 -0500 | [diff] [blame] | 917 | writel(0x1, ctl_base + EOT_PACKET_CTRL); |
Terence Hampson | cc3345c | 2013-06-27 15:30:10 -0400 | [diff] [blame] | 918 | #endif |
Xiaoming Zhou | 8d534dd | 2013-07-29 15:49:19 -0400 | [diff] [blame] | 919 | return 0; |
Siddhartha Agrawal | 7317e48 | 2013-04-21 16:16:57 -0700 | [diff] [blame] | 920 | } |
| 921 | |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 922 | int mipi_dsi_on() |
| 923 | { |
| 924 | int ret = NO_ERROR; |
| 925 | unsigned long ReadValue; |
| 926 | unsigned long count = 0; |
| 927 | |
| 928 | ReadValue = readl(DSI_INT_CTRL) & 0x00010000; |
| 929 | |
| 930 | mdelay(10); |
| 931 | |
| 932 | while (ReadValue != 0x00010000) { |
| 933 | ReadValue = readl(DSI_INT_CTRL) & 0x00010000; |
| 934 | count++; |
| 935 | if (count > 0xffff) { |
| 936 | dprintf(CRITICAL, "Video lane test failed\n"); |
| 937 | return ERROR; |
| 938 | } |
| 939 | } |
| 940 | |
Amir Samuelov | 2d4ba16 | 2012-07-22 11:53:14 +0300 | [diff] [blame] | 941 | dprintf(INFO, "Video lane tested successfully\n"); |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 942 | return ret; |
| 943 | } |
| 944 | |
Siddhartha Agrawal | 24d81b5 | 2013-07-01 11:13:32 -0700 | [diff] [blame] | 945 | int mipi_dsi_off(struct msm_panel_info *pinfo) |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 946 | { |
Amol Jadi | 6834f1a | 2012-06-29 14:42:59 -0700 | [diff] [blame] | 947 | if(!target_cont_splash_screen()) |
| 948 | { |
Padmanabhan Komanduru | f8986be | 2014-11-04 15:57:19 +0530 | [diff] [blame^] | 949 | mdss_dsi_panel_shutdown(pinfo); |
Amol Jadi | 6834f1a | 2012-06-29 14:42:59 -0700 | [diff] [blame] | 950 | writel(0, DSI_CLK_CTRL); |
| 951 | writel(0, DSI_CTRL); |
Siddhartha Agrawal | e0033a1 | 2013-02-23 15:37:42 -0800 | [diff] [blame] | 952 | } |
| 953 | |
Dhaval Patel | ddde45a | 2014-08-13 19:07:59 -0700 | [diff] [blame] | 954 | writel(0x1115501, MIPI_DSI0_BASE + INT_CTRL); |
Siddhartha Agrawal | 24d81b5 | 2013-07-01 11:13:32 -0700 | [diff] [blame] | 955 | if (pinfo->mipi.broadcast) |
Dhaval Patel | ddde45a | 2014-08-13 19:07:59 -0700 | [diff] [blame] | 956 | writel(0x1115501, MIPI_DSI1_BASE + INT_CTRL); |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 957 | |
| 958 | return NO_ERROR; |
| 959 | } |
Channagoud Kadabi | 10189fd | 2012-05-25 13:33:39 +0530 | [diff] [blame] | 960 | |
| 961 | int mipi_cmd_trigger() |
| 962 | { |
| 963 | writel(0x1, DSI_CMD_MODE_MDP_SW_TRIGGER); |
| 964 | |
| 965 | return NO_ERROR; |
| 966 | } |