Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2010-2013, 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 | #if DISPLAY_MIPI_PANEL_TOSHIBA |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 56 | static struct fbcon_config mipi_fb_cfg = { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 57 | .height = TSH_MIPI_FB_HEIGHT, |
| 58 | .width = TSH_MIPI_FB_WIDTH, |
| 59 | .stride = TSH_MIPI_FB_WIDTH, |
| 60 | .format = FB_FORMAT_RGB888, |
| 61 | .bpp = 24, |
| 62 | .update_start = NULL, |
| 63 | .update_done = NULL, |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 64 | }; |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 65 | |
Kinson Chik | e5c9343 | 2011-06-17 09:10:29 -0700 | [diff] [blame] | 66 | struct mipi_dsi_panel_config toshiba_panel_info = { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 67 | .mode = MIPI_VIDEO_MODE, |
| 68 | .num_of_lanes = 1, |
| 69 | .dsi_phy_config = &mipi_dsi_toshiba_panel_phy_ctrl, |
| 70 | .panel_cmds = toshiba_panel_video_mode_cmds, |
| 71 | .num_of_panel_cmds = ARRAY_SIZE(toshiba_panel_video_mode_cmds), |
Kinson Chik | e5c9343 | 2011-06-17 09:10:29 -0700 | [diff] [blame] | 72 | }; |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 73 | #elif DISPLAY_MIPI_PANEL_NOVATEK_BLUE |
| 74 | static struct fbcon_config mipi_fb_cfg = { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 75 | .height = NOV_MIPI_FB_HEIGHT, |
| 76 | .width = NOV_MIPI_FB_WIDTH, |
| 77 | .stride = NOV_MIPI_FB_WIDTH, |
| 78 | .format = FB_FORMAT_RGB888, |
| 79 | .bpp = 24, |
| 80 | .update_start = NULL, |
| 81 | .update_done = NULL, |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 82 | }; |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 83 | |
Kinson Chik | e5c9343 | 2011-06-17 09:10:29 -0700 | [diff] [blame] | 84 | struct mipi_dsi_panel_config novatek_panel_info = { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 85 | .mode = MIPI_CMD_MODE, |
| 86 | .num_of_lanes = 2, |
| 87 | .dsi_phy_config = &mipi_dsi_novatek_panel_phy_ctrl, |
| 88 | .panel_cmds = novatek_panel_cmd_mode_cmds, |
| 89 | .num_of_panel_cmds = ARRAY_SIZE(novatek_panel_cmd_mode_cmds), |
Kinson Chik | e5c9343 | 2011-06-17 09:10:29 -0700 | [diff] [blame] | 90 | }; |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 91 | #else |
| 92 | static struct fbcon_config mipi_fb_cfg = { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 93 | .height = 0, |
| 94 | .width = 0, |
| 95 | .stride = 0, |
| 96 | .format = 0, |
| 97 | .bpp = 0, |
| 98 | .update_start = NULL, |
| 99 | .update_done = NULL, |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 100 | }; |
| 101 | #endif |
| 102 | |
| 103 | static int cmd_mode_status = 0; |
Greg Grisco | d625055 | 2011-06-29 14:40:23 -0700 | [diff] [blame] | 104 | void secure_writel(uint32_t, uint32_t); |
| 105 | uint32_t secure_readl(uint32_t); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 106 | |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 107 | struct mipi_dsi_panel_config *get_panel_info(void) |
| 108 | { |
| 109 | #if DISPLAY_MIPI_PANEL_TOSHIBA |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 110 | return &toshiba_panel_info; |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 111 | #elif DISPLAY_MIPI_PANEL_NOVATEK_BLUE |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 112 | return &novatek_panel_info; |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 113 | #endif |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 114 | return NULL; |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 115 | } |
| 116 | |
Siddhartha Agrawal | 980b5ee | 2013-05-30 12:17:50 -0700 | [diff] [blame] | 117 | int mdss_dual_dsi_cmd_dma_trigger_for_panel() |
| 118 | { |
| 119 | uint32_t ReadValue; |
| 120 | uint32_t count = 0; |
| 121 | int status = 0; |
| 122 | |
Terence Hampson | cc3345c | 2013-06-27 15:30:10 -0400 | [diff] [blame] | 123 | #if (DISPLAY_TYPE_MDSS == 1) |
Siddhartha Agrawal | 980b5ee | 2013-05-30 12:17:50 -0700 | [diff] [blame] | 124 | writel(0x03030303, MIPI_DSI0_BASE + INT_CTRL); |
| 125 | writel(0x1, MIPI_DSI0_BASE + CMD_MODE_DMA_SW_TRIGGER); |
| 126 | dsb(); |
| 127 | |
| 128 | writel(0x03030303, MIPI_DSI1_BASE + INT_CTRL); |
| 129 | writel(0x1, MIPI_DSI1_BASE + CMD_MODE_DMA_SW_TRIGGER); |
| 130 | dsb(); |
| 131 | |
| 132 | ReadValue = readl(MIPI_DSI1_BASE + INT_CTRL) & 0x00000001; |
| 133 | while (ReadValue != 0x00000001) { |
| 134 | ReadValue = readl(MIPI_DSI1_BASE + INT_CTRL) & 0x00000001; |
| 135 | count++; |
| 136 | if (count > 0xffff) { |
| 137 | status = FAIL; |
| 138 | dprintf(CRITICAL, |
| 139 | "Panel CMD: command mode dma test failed\n"); |
| 140 | return status; |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | writel((readl(MIPI_DSI1_BASE + INT_CTRL) | 0x01000001), |
| 145 | MIPI_DSI1_BASE + INT_CTRL); |
| 146 | dprintf(SPEW, "Panel CMD: command mode dma tested successfully\n"); |
Terence Hampson | cc3345c | 2013-06-27 15:30:10 -0400 | [diff] [blame] | 147 | #endif |
Siddhartha Agrawal | 980b5ee | 2013-05-30 12:17:50 -0700 | [diff] [blame] | 148 | return status; |
| 149 | } |
| 150 | |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 151 | int dsi_cmd_dma_trigger_for_panel() |
| 152 | { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 153 | unsigned long ReadValue; |
| 154 | unsigned long count = 0; |
| 155 | int status = 0; |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 156 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 157 | writel(0x03030303, DSI_INT_CTRL); |
| 158 | writel(0x1, DSI_CMD_MODE_DMA_SW_TRIGGER); |
| 159 | dsb(); |
| 160 | ReadValue = readl(DSI_INT_CTRL) & 0x00000001; |
| 161 | while (ReadValue != 0x00000001) { |
| 162 | ReadValue = readl(DSI_INT_CTRL) & 0x00000001; |
| 163 | count++; |
| 164 | if (count > 0xffff) { |
| 165 | status = FAIL; |
| 166 | dprintf(CRITICAL, |
| 167 | "Panel CMD: command mode dma test failed\n"); |
| 168 | return status; |
| 169 | } |
| 170 | } |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 171 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 172 | writel((readl(DSI_INT_CTRL) | 0x01000001), DSI_INT_CTRL); |
| 173 | dprintf(SPEW, "Panel CMD: command mode dma tested successfully\n"); |
| 174 | return status; |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 175 | } |
| 176 | |
Siddhartha Agrawal | 980b5ee | 2013-05-30 12:17:50 -0700 | [diff] [blame] | 177 | int mdss_dual_dsi_cmds_tx(struct mipi_dsi_cmd *cmds, int count) |
| 178 | { |
| 179 | int ret = 0; |
| 180 | struct mipi_dsi_cmd *cm; |
| 181 | int i = 0; |
| 182 | char pload[256]; |
| 183 | uint32_t off; |
| 184 | |
Terence Hampson | cc3345c | 2013-06-27 15:30:10 -0400 | [diff] [blame] | 185 | #if (DISPLAY_TYPE_MDSS == 1) |
Siddhartha Agrawal | 980b5ee | 2013-05-30 12:17:50 -0700 | [diff] [blame] | 186 | /* Align pload at 8 byte boundry */ |
| 187 | off = pload; |
| 188 | off &= 0x07; |
| 189 | if (off) |
| 190 | off = 8 - off; |
| 191 | off += pload; |
| 192 | |
| 193 | cm = cmds; |
| 194 | for (i = 0; i < count; i++) { |
| 195 | memcpy((void *)off, (cm->payload), cm->size); |
| 196 | writel(off, MIPI_DSI0_BASE + DMA_CMD_OFFSET); |
| 197 | writel(cm->size, MIPI_DSI0_BASE + DMA_CMD_LENGTH); // reg 0x48 for this build |
| 198 | writel(off, MIPI_DSI1_BASE + DMA_CMD_OFFSET); |
| 199 | writel(cm->size, MIPI_DSI1_BASE + DMA_CMD_LENGTH); // reg 0x48 for this build |
| 200 | dsb(); |
| 201 | ret += mdss_dual_dsi_cmd_dma_trigger_for_panel(); |
Dhaval Patel | 607a624 | 2013-10-29 12:37:24 -0700 | [diff] [blame^] | 202 | if (cm->wait) |
| 203 | mdelay(cm->wait); |
| 204 | else |
| 205 | udelay(80); |
Siddhartha Agrawal | 980b5ee | 2013-05-30 12:17:50 -0700 | [diff] [blame] | 206 | cm++; |
| 207 | } |
Terence Hampson | cc3345c | 2013-06-27 15:30:10 -0400 | [diff] [blame] | 208 | #endif |
Siddhartha Agrawal | 980b5ee | 2013-05-30 12:17:50 -0700 | [diff] [blame] | 209 | return ret; |
| 210 | } |
| 211 | |
Casey Piper | 8403675 | 2013-09-05 14:56:37 -0700 | [diff] [blame] | 212 | int mdss_dsi_cmds_rx(uint32_t **rp, int rp_len, int rdbk_len) |
| 213 | { |
| 214 | uint32_t *lp, data; |
| 215 | char *dp; |
| 216 | int i, off; |
| 217 | int rlen, res; |
| 218 | |
| 219 | if (rdbk_len > rp_len) { |
| 220 | return 0; |
| 221 | } |
| 222 | |
| 223 | if (rdbk_len <= 2) |
| 224 | rlen = 4; /* short read */ |
| 225 | else |
| 226 | rlen = MIPI_DSI_MRPS + 6; /* 4 bytes header + 2 bytes crc */ |
| 227 | |
| 228 | if (rlen > MIPI_DSI_REG_LEN) { |
| 229 | return 0; |
| 230 | } |
| 231 | |
| 232 | res = rlen & 0x03; |
| 233 | |
| 234 | rlen += res; /* 4 byte align */ |
| 235 | lp = *rp; |
| 236 | |
| 237 | rlen += 3; |
| 238 | rlen >>= 2; |
| 239 | |
| 240 | if (rlen > 4) |
| 241 | rlen = 4; /* 4 x 32 bits registers only */ |
| 242 | |
| 243 | off = DSI_RDBK_DATA0; |
| 244 | off += ((rlen - 1) * 4); |
| 245 | |
| 246 | for (i = 0; i < rlen; i++) { |
| 247 | data = readl(MIPI_DSI_BASE + off); |
| 248 | *lp = ntohl(data); /* to network byte order */ |
| 249 | lp++; |
| 250 | |
| 251 | off -= 4; |
| 252 | } |
| 253 | |
| 254 | if (rdbk_len > 2) { |
| 255 | /*First 4 bytes + paded bytes will be header next len bytes would be payload */ |
| 256 | for (i = 0; i < rdbk_len; i++) { |
| 257 | dp = *rp; |
| 258 | dp[i] = dp[(res + i) >> 2]; |
| 259 | } |
| 260 | } |
| 261 | return rdbk_len; |
| 262 | } |
| 263 | |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 264 | int mipi_dsi_cmds_tx(struct mipi_dsi_cmd *cmds, int count) |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 265 | { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 266 | int ret = 0; |
| 267 | struct mipi_dsi_cmd *cm; |
| 268 | int i = 0; |
| 269 | char pload[256]; |
| 270 | uint32_t off; |
Deepa Dinamani | a080a40 | 2011-11-05 18:59:26 -0700 | [diff] [blame] | 271 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 272 | /* Align pload at 8 byte boundry */ |
| 273 | off = pload; |
| 274 | off &= 0x07; |
| 275 | if (off) |
| 276 | off = 8 - off; |
| 277 | off += pload; |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 278 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 279 | cm = cmds; |
| 280 | for (i = 0; i < count; i++) { |
| 281 | memcpy((void *)off, (cm->payload), cm->size); |
| 282 | writel(off, DSI_DMA_CMD_OFFSET); |
| 283 | writel(cm->size, DSI_DMA_CMD_LENGTH); // reg 0x48 for this build |
| 284 | dsb(); |
| 285 | ret += dsi_cmd_dma_trigger_for_panel(); |
Sangani Suryanarayana Raju | 769f9ac | 2013-04-30 19:05:06 +0530 | [diff] [blame] | 286 | dsb(); |
| 287 | if (cm->wait) |
| 288 | mdelay(cm->wait); |
| 289 | else |
| 290 | udelay(80); |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 291 | cm++; |
| 292 | } |
| 293 | return ret; |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 294 | } |
| 295 | |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 296 | /* |
| 297 | * mipi_dsi_cmd_rx: can receive at most 16 bytes |
| 298 | * per transaction since it only have 4 32bits reigsters |
| 299 | * to hold data. |
| 300 | * therefore Maximum Return Packet Size need to be set to 16. |
| 301 | * any return data more than MRPS need to be break down |
| 302 | * to multiple transactions. |
| 303 | */ |
| 304 | int mipi_dsi_cmds_rx(char **rp, int len) |
| 305 | { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 306 | uint32_t *lp, data; |
| 307 | char *dp; |
| 308 | int i, off, cnt; |
| 309 | int rlen, res; |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 310 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 311 | if (len <= 2) |
| 312 | rlen = 4; /* short read */ |
| 313 | else |
| 314 | rlen = MIPI_DSI_MRPS + 6; /* 4 bytes header + 2 bytes crc */ |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 315 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 316 | if (rlen > MIPI_DSI_REG_LEN) { |
| 317 | return 0; |
| 318 | } |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 319 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 320 | res = rlen & 0x03; |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 321 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 322 | rlen += res; /* 4 byte align */ |
| 323 | lp = (uint32_t *) (*rp); |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 324 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 325 | cnt = rlen; |
| 326 | cnt += 3; |
| 327 | cnt >>= 2; |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 328 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 329 | if (cnt > 4) |
| 330 | cnt = 4; /* 4 x 32 bits registers only */ |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 331 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 332 | off = 0x068; /* DSI_RDBK_DATA0 */ |
| 333 | off += ((cnt - 1) * 4); |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 334 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 335 | for (i = 0; i < cnt; i++) { |
| 336 | data = (uint32_t) readl(MIPI_DSI_BASE + off); |
| 337 | *lp++ = ntohl(data); /* to network byte order */ |
| 338 | off -= 4; |
| 339 | } |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 340 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 341 | if (len > 2) { |
| 342 | /*First 4 bytes + paded bytes will be header next len bytes would be payload */ |
| 343 | for (i = 0; i < len; i++) { |
| 344 | dp = *rp; |
| 345 | dp[i] = dp[4 + res + i]; |
| 346 | } |
| 347 | } |
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 | return len; |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 350 | } |
| 351 | |
| 352 | static int mipi_dsi_cmd_bta_sw_trigger(void) |
| 353 | { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 354 | uint32_t data; |
| 355 | int cnt = 0; |
| 356 | int err = 0; |
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 | writel(0x01, MIPI_DSI_BASE + 0x094); /* trigger */ |
| 359 | while (cnt < 10000) { |
| 360 | data = readl(MIPI_DSI_BASE + 0x0004); /*DSI_STATUS */ |
| 361 | if ((data & 0x0010) == 0) |
| 362 | break; |
| 363 | cnt++; |
| 364 | } |
| 365 | if (cnt == 10000) |
| 366 | err = 1; |
| 367 | return err; |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 368 | } |
| 369 | |
| 370 | static uint32_t mipi_novatek_manufacture_id(void) |
| 371 | { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 372 | char rec_buf[24]; |
| 373 | char *rp = rec_buf; |
| 374 | uint32_t *lp, data; |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 375 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 376 | mipi_dsi_cmds_tx(&novatek_panel_manufacture_id_cmd, 1); |
| 377 | mipi_dsi_cmds_rx(&rp, 3); |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 378 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 379 | lp = (uint32_t *) rp; |
| 380 | data = (uint32_t) * lp; |
| 381 | data = ntohl(data); |
| 382 | data = data >> 8; |
| 383 | return data; |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 384 | } |
| 385 | |
Siddhartha Agrawal | 980b5ee | 2013-05-30 12:17:50 -0700 | [diff] [blame] | 386 | int mdss_dsi_panel_initialize(struct mipi_dsi_panel_config *pinfo, uint32_t |
| 387 | broadcast) |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 388 | { |
| 389 | uint8_t DMA_STREAM1 = 0; // for mdp display processor path |
| 390 | uint8_t EMBED_MODE1 = 1; // from frame buffer |
| 391 | uint8_t POWER_MODE2 = 1; // from frame buffer |
| 392 | uint8_t PACK_TYPE1; // long packet |
| 393 | uint8_t VC1 = 0; |
| 394 | uint8_t DT1 = 0; // non embedded mode |
| 395 | uint8_t WC1 = 0; // for non embedded mode only |
| 396 | int status = 0; |
| 397 | uint8_t DLNx_EN; |
Siddhartha Agrawal | 2679a82 | 2013-05-31 19:15:12 -0700 | [diff] [blame] | 398 | uint8_t lane_swap = 0; |
Siddhartha Agrawal | b6c861f | 2013-05-31 19:36:44 -0700 | [diff] [blame] | 399 | uint32_t timing_ctl = 0; |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 400 | |
Terence Hampson | cc3345c | 2013-06-27 15:30:10 -0400 | [diff] [blame] | 401 | #if (DISPLAY_TYPE_MDSS == 1) |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 402 | switch (pinfo->num_of_lanes) { |
| 403 | default: |
| 404 | case 1: |
| 405 | DLNx_EN = 1; // 1 lane |
| 406 | break; |
| 407 | case 2: |
| 408 | DLNx_EN = 3; // 2 lane |
| 409 | break; |
| 410 | case 3: |
| 411 | DLNx_EN = 7; // 3 lane |
| 412 | break; |
| 413 | case 4: |
| 414 | DLNx_EN = 0x0F; /* 4 lanes */ |
| 415 | break; |
| 416 | } |
| 417 | |
| 418 | PACK_TYPE1 = pinfo->pack; |
Siddhartha Agrawal | 2679a82 | 2013-05-31 19:15:12 -0700 | [diff] [blame] | 419 | lane_swap = pinfo->lane_swap; |
Siddhartha Agrawal | b6c861f | 2013-05-31 19:36:44 -0700 | [diff] [blame] | 420 | timing_ctl = ((pinfo->t_clk_post << 8) | pinfo->t_clk_pre); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 421 | |
Siddhartha Agrawal | 980b5ee | 2013-05-30 12:17:50 -0700 | [diff] [blame] | 422 | if (broadcast) { |
| 423 | writel(0x0001, MIPI_DSI1_BASE + SOFT_RESET); |
| 424 | writel(0x0000, MIPI_DSI1_BASE + SOFT_RESET); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 425 | |
Siddhartha Agrawal | 980b5ee | 2013-05-30 12:17:50 -0700 | [diff] [blame] | 426 | writel((0 << 16) | 0x3f, MIPI_DSI1_BASE + CLK_CTRL); /* Turn on all DSI Clks */ |
| 427 | writel(DMA_STREAM1 << 8 | 0x04, MIPI_DSI1_BASE + TRIG_CTRL); // reg 0x80 dma trigger: sw |
| 428 | // trigger 0x4; dma stream1 |
| 429 | |
| 430 | writel(0 << 30 | DLNx_EN << 4 | 0x105, MIPI_DSI1_BASE + CTRL); // reg 0x00 for this |
| 431 | // build |
| 432 | writel(broadcast << 31 | EMBED_MODE1 << 28 | POWER_MODE2 << 26 |
| 433 | | PACK_TYPE1 << 24 | VC1 << 22 | DT1 << 16 | WC1, |
| 434 | MIPI_DSI1_BASE + COMMAND_MODE_DMA_CTRL); |
Siddhartha Agrawal | 2679a82 | 2013-05-31 19:15:12 -0700 | [diff] [blame] | 435 | |
| 436 | writel(lane_swap, MIPI_DSI1_BASE + LANE_SWAP_CTL); |
Siddhartha Agrawal | b6c861f | 2013-05-31 19:36:44 -0700 | [diff] [blame] | 437 | writel(timing_ctl, MIPI_DSI1_BASE + TIMING_CTL); |
Siddhartha Agrawal | 980b5ee | 2013-05-30 12:17:50 -0700 | [diff] [blame] | 438 | } |
| 439 | |
| 440 | writel(0x0001, MIPI_DSI0_BASE + SOFT_RESET); |
| 441 | writel(0x0000, MIPI_DSI0_BASE + SOFT_RESET); |
| 442 | |
| 443 | writel((0 << 16) | 0x3f, MIPI_DSI0_BASE + CLK_CTRL); /* Turn on all DSI Clks */ |
| 444 | 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] | 445 | // trigger 0x4; dma stream1 |
| 446 | |
Siddhartha Agrawal | 980b5ee | 2013-05-30 12:17:50 -0700 | [diff] [blame] | 447 | writel(0 << 30 | DLNx_EN << 4 | 0x105, MIPI_DSI0_BASE + CTRL); // reg 0x00 for this |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 448 | // build |
Siddhartha Agrawal | 980b5ee | 2013-05-30 12:17:50 -0700 | [diff] [blame] | 449 | writel(broadcast << 31 | EMBED_MODE1 << 28 | POWER_MODE2 << 26 |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 450 | | PACK_TYPE1 << 24 | VC1 << 22 | DT1 << 16 | WC1, |
Siddhartha Agrawal | 980b5ee | 2013-05-30 12:17:50 -0700 | [diff] [blame] | 451 | MIPI_DSI0_BASE + COMMAND_MODE_DMA_CTRL); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 452 | |
Siddhartha Agrawal | 2679a82 | 2013-05-31 19:15:12 -0700 | [diff] [blame] | 453 | writel(lane_swap, MIPI_DSI0_BASE + LANE_SWAP_CTL); |
Siddhartha Agrawal | b6c861f | 2013-05-31 19:36:44 -0700 | [diff] [blame] | 454 | writel(timing_ctl, MIPI_DSI0_BASE + TIMING_CTL); |
Siddhartha Agrawal | 2679a82 | 2013-05-31 19:15:12 -0700 | [diff] [blame] | 455 | |
Siddhartha Agrawal | 980b5ee | 2013-05-30 12:17:50 -0700 | [diff] [blame] | 456 | if (pinfo->panel_cmds) { |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 457 | |
Siddhartha Agrawal | 980b5ee | 2013-05-30 12:17:50 -0700 | [diff] [blame] | 458 | if (broadcast) { |
| 459 | status = mdss_dual_dsi_cmds_tx(pinfo->panel_cmds, |
| 460 | pinfo->num_of_panel_cmds); |
| 461 | |
| 462 | } else { |
| 463 | status = mipi_dsi_cmds_tx(pinfo->panel_cmds, |
| 464 | pinfo->num_of_panel_cmds); |
Casey Piper | 8403675 | 2013-09-05 14:56:37 -0700 | [diff] [blame] | 465 | if (!status && target_panel_auto_detect_enabled()) |
| 466 | status = |
| 467 | target_read_panel_signature(pinfo->signature); |
Siddhartha Agrawal | 980b5ee | 2013-05-30 12:17:50 -0700 | [diff] [blame] | 468 | } |
| 469 | } |
Terence Hampson | cc3345c | 2013-06-27 15:30:10 -0400 | [diff] [blame] | 470 | #endif |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 471 | return status; |
| 472 | } |
| 473 | |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 474 | int mipi_dsi_panel_initialize(struct mipi_dsi_panel_config *pinfo) |
| 475 | { |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 476 | uint8_t DMA_STREAM1 = 0; // for mdp display processor path |
| 477 | uint8_t EMBED_MODE1 = 1; // from frame buffer |
| 478 | uint8_t POWER_MODE2 = 1; // from frame buffer |
| 479 | uint8_t PACK_TYPE1; // long packet |
| 480 | uint8_t VC1 = 0; |
| 481 | uint8_t DT1 = 0; // non embedded mode |
| 482 | uint8_t WC1 = 0; // for non embedded mode only |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 483 | int status = 0; |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 484 | uint8_t DLNx_EN; |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 485 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 486 | switch (pinfo->num_of_lanes) { |
| 487 | default: |
| 488 | case 1: |
| 489 | DLNx_EN = 1; // 1 lane |
| 490 | break; |
| 491 | case 2: |
| 492 | DLNx_EN = 3; // 2 lane |
| 493 | break; |
| 494 | case 3: |
| 495 | DLNx_EN = 7; // 3 lane |
| 496 | break; |
Amir Samuelov | 2d4ba16 | 2012-07-22 11:53:14 +0300 | [diff] [blame] | 497 | case 4: |
| 498 | DLNx_EN = 0x0F; /* 4 lanes */ |
| 499 | break; |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 500 | } |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 501 | |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 502 | PACK_TYPE1 = pinfo->pack; |
| 503 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 504 | writel(0x0001, DSI_SOFT_RESET); |
| 505 | writel(0x0000, DSI_SOFT_RESET); |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 506 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 507 | writel((0 << 16) | 0x3f, DSI_CLK_CTRL); /* Turn on all DSI Clks */ |
| 508 | writel(DMA_STREAM1 << 8 | 0x04, DSI_TRIG_CTRL); // reg 0x80 dma trigger: sw |
| 509 | // trigger 0x4; dma stream1 |
Kinson Chik | e5c9343 | 2011-06-17 09:10:29 -0700 | [diff] [blame] | 510 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 511 | writel(0 << 30 | DLNx_EN << 4 | 0x105, DSI_CTRL); // reg 0x00 for this |
| 512 | // build |
| 513 | writel(EMBED_MODE1 << 28 | POWER_MODE2 << 26 |
| 514 | | PACK_TYPE1 << 24 | VC1 << 22 | DT1 << 16 | WC1, |
| 515 | DSI_COMMAND_MODE_DMA_CTRL); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 516 | |
Amir Samuelov | 2d4ba16 | 2012-07-22 11:53:14 +0300 | [diff] [blame] | 517 | if (pinfo->panel_cmds) |
| 518 | status = mipi_dsi_cmds_tx(pinfo->panel_cmds, |
| 519 | pinfo->num_of_panel_cmds); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 520 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 521 | return status; |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 522 | } |
| 523 | |
Kinson Chik | e5c9343 | 2011-06-17 09:10:29 -0700 | [diff] [blame] | 524 | //TODO: Clean up arguments being passed in not being used |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 525 | int |
| 526 | config_dsi_video_mode(unsigned short disp_width, unsigned short disp_height, |
| 527 | unsigned short img_width, unsigned short img_height, |
| 528 | unsigned short hsync_porch0_fp, |
| 529 | unsigned short hsync_porch0_bp, |
| 530 | unsigned short vsync_porch0_fp, |
| 531 | unsigned short vsync_porch0_bp, |
| 532 | unsigned short hsync_width, |
| 533 | unsigned short vsync_width, unsigned short dst_format, |
| 534 | unsigned short traffic_mode, unsigned short datalane_num) |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 535 | { |
| 536 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 537 | unsigned char DST_FORMAT; |
| 538 | unsigned char TRAFIC_MODE; |
| 539 | unsigned char DLNx_EN; |
| 540 | // video mode data ctrl |
| 541 | int status = 0; |
| 542 | unsigned long low_pwr_stop_mode = 0; |
| 543 | unsigned char eof_bllp_pwr = 0x9; |
| 544 | unsigned char interleav = 0; |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 545 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 546 | // disable mdp first |
| 547 | mdp_disable(); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 548 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 549 | writel(0x00000000, DSI_CLK_CTRL); |
| 550 | writel(0x00000000, DSI_CLK_CTRL); |
| 551 | writel(0x00000000, DSI_CLK_CTRL); |
| 552 | writel(0x00000000, DSI_CLK_CTRL); |
| 553 | writel(0x00000002, DSI_CLK_CTRL); |
| 554 | writel(0x00000006, DSI_CLK_CTRL); |
| 555 | writel(0x0000000e, DSI_CLK_CTRL); |
| 556 | writel(0x0000001e, DSI_CLK_CTRL); |
| 557 | writel(0x0000003e, DSI_CLK_CTRL); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 558 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 559 | writel(0, DSI_CTRL); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 560 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 561 | writel(0, DSI_ERR_INT_MASK0); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 562 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 563 | DST_FORMAT = 0; // RGB565 |
| 564 | dprintf(SPEW, "DSI_Video_Mode - Dst Format: RGB565\n"); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 565 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 566 | DLNx_EN = 1; // 1 lane with clk programming |
| 567 | dprintf(SPEW, "Data Lane: 1 lane\n"); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 568 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 569 | TRAFIC_MODE = 0; // non burst mode with sync pulses |
| 570 | dprintf(SPEW, "Traffic mode: non burst mode with sync pulses\n"); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 571 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 572 | writel(0x02020202, DSI_INT_CTRL); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 573 | |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 574 | writel(((hsync_width + img_width + hsync_porch0_bp) << 16) |
| 575 | | (hsync_width + hsync_porch0_bp), |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 576 | DSI_VIDEO_MODE_ACTIVE_H); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 577 | |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 578 | writel(((vsync_width + img_height + vsync_porch0_bp) << 16) |
| 579 | | (vsync_width + vsync_porch0_bp), |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 580 | DSI_VIDEO_MODE_ACTIVE_V); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 581 | |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 582 | writel(((vsync_width + img_height + vsync_porch0_fp + vsync_porch0_bp - 1) << 16) |
| 583 | | (hsync_width + img_width + hsync_porch0_fp + hsync_porch0_bp - 1), |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 584 | DSI_VIDEO_MODE_TOTAL); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 585 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 586 | writel((hsync_width << 16) | 0, DSI_VIDEO_MODE_HSYNC); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 587 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 588 | writel(0 << 16 | 0, DSI_VIDEO_MODE_VSYNC); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 589 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 590 | writel(vsync_width << 16 | 0, DSI_VIDEO_MODE_VSYNC_VPOS); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 591 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 592 | writel(1, DSI_EOT_PACKET_CTRL); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 593 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 594 | writel(0x00000100, DSI_MISR_VIDEO_CTRL); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 595 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 596 | writel(low_pwr_stop_mode << 16 | eof_bllp_pwr << 12 | TRAFIC_MODE << 8 |
| 597 | | DST_FORMAT << 4 | 0x0, DSI_VIDEO_MODE_CTRL); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 598 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 599 | writel(0x67, DSI_CAL_STRENGTH_CTRL); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 600 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 601 | writel(0x80006711, DSI_CAL_CTRL); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 602 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 603 | writel(0x00010100, DSI_MISR_VIDEO_CTRL); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 604 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 605 | writel(0x00010100, DSI_INT_CTRL); |
| 606 | writel(0x02010202, DSI_INT_CTRL); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 607 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 608 | writel(0x02030303, DSI_INT_CTRL); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 609 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 610 | writel(interleav << 30 | 0 << 24 | 0 << 20 | DLNx_EN << 4 |
| 611 | | 0x103, DSI_CTRL); |
| 612 | mdelay(10); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 613 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 614 | return status; |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 615 | } |
| 616 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 617 | int |
| 618 | config_dsi_cmd_mode(unsigned short disp_width, unsigned short disp_height, |
| 619 | unsigned short img_width, unsigned short img_height, |
| 620 | unsigned short dst_format, |
| 621 | unsigned short traffic_mode, unsigned short datalane_num) |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 622 | { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 623 | unsigned char DST_FORMAT; |
| 624 | unsigned char TRAFIC_MODE; |
| 625 | unsigned char DLNx_EN; |
| 626 | // video mode data ctrl |
| 627 | int status = 0; |
Greg Grisco | d625055 | 2011-06-29 14:40:23 -0700 | [diff] [blame] | 628 | unsigned char interleav = 0; |
| 629 | unsigned char ystride = 0x03; |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 630 | // disable mdp first |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 631 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 632 | writel(0x00000000, DSI_CLK_CTRL); |
| 633 | writel(0x00000000, DSI_CLK_CTRL); |
| 634 | writel(0x00000000, DSI_CLK_CTRL); |
| 635 | writel(0x00000000, DSI_CLK_CTRL); |
| 636 | writel(0x00000002, DSI_CLK_CTRL); |
| 637 | writel(0x00000006, DSI_CLK_CTRL); |
| 638 | writel(0x0000000e, DSI_CLK_CTRL); |
| 639 | writel(0x0000001e, DSI_CLK_CTRL); |
| 640 | writel(0x0000003e, DSI_CLK_CTRL); |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 641 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 642 | writel(0x10000000, DSI_ERR_INT_MASK0); |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 643 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 644 | // writel(0, DSI_CTRL); |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 645 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 646 | // writel(0, DSI_ERR_INT_MASK0); |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 647 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 648 | DST_FORMAT = 8; // RGB888 |
| 649 | dprintf(SPEW, "DSI_Cmd_Mode - Dst Format: RGB888\n"); |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 650 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 651 | DLNx_EN = 3; // 2 lane with clk programming |
| 652 | dprintf(SPEW, "Data Lane: 2 lane\n"); |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 653 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 654 | TRAFIC_MODE = 0; // non burst mode with sync pulses |
| 655 | dprintf(SPEW, "Traffic mode: non burst mode with sync pulses\n"); |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 656 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 657 | writel(0x02020202, DSI_INT_CTRL); |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 658 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 659 | writel(0x00100000 | DST_FORMAT, DSI_COMMAND_MODE_MDP_CTRL); |
| 660 | writel((img_width * ystride + 1) << 16 | 0x0039, |
| 661 | DSI_COMMAND_MODE_MDP_STREAM0_CTRL); |
| 662 | writel((img_width * ystride + 1) << 16 | 0x0039, |
| 663 | DSI_COMMAND_MODE_MDP_STREAM1_CTRL); |
| 664 | writel(img_height << 16 | img_width, |
| 665 | DSI_COMMAND_MODE_MDP_STREAM0_TOTAL); |
| 666 | writel(img_height << 16 | img_width, |
| 667 | DSI_COMMAND_MODE_MDP_STREAM1_TOTAL); |
| 668 | writel(0xEE, DSI_CAL_STRENGTH_CTRL); |
| 669 | writel(0x80000000, DSI_CAL_CTRL); |
| 670 | writel(0x40, DSI_TRIG_CTRL); |
| 671 | writel(0x13c2c, DSI_COMMAND_MODE_MDP_DCS_CMD_CTRL); |
| 672 | writel(interleav << 30 | 0 << 24 | 0 << 20 | DLNx_EN << 4 | 0x105, |
| 673 | DSI_CTRL); |
| 674 | mdelay(10); |
| 675 | writel(0x10000000, DSI_COMMAND_MODE_DMA_CTRL); |
| 676 | writel(0x10000000, DSI_MISR_CMD_CTRL); |
| 677 | writel(0x00000040, DSI_ERR_INT_MASK0); |
| 678 | writel(0x1, DSI_EOT_PACKET_CTRL); |
| 679 | // writel(0x0, MDP_OVERLAYPROC0_START); |
| 680 | mdp_start_dma(); |
| 681 | mdelay(10); |
| 682 | writel(0x1, DSI_CMD_MODE_MDP_SW_TRIGGER); |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 683 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 684 | status = 1; |
| 685 | return status; |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 686 | } |
| 687 | |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 688 | int mipi_dsi_video_config(unsigned short num_of_lanes) |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 689 | { |
| 690 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 691 | int status = 0; |
| 692 | unsigned long ReadValue; |
| 693 | unsigned long count = 0; |
| 694 | unsigned long low_pwr_stop_mode = 0; // low power mode 0x1111 start from |
| 695 | // bit16, high spd mode 0x0 |
| 696 | unsigned char eof_bllp_pwr = 0x9; // bit 12, 15, 1:low power stop mode or |
| 697 | // let cmd mode eng send packets in hs |
| 698 | // or lp mode |
| 699 | unsigned short image_wd = mipi_fb_cfg.width; |
| 700 | unsigned short image_ht = mipi_fb_cfg.height; |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 701 | unsigned short display_wd = mipi_fb_cfg.width; |
| 702 | unsigned short display_ht = mipi_fb_cfg.height; |
| 703 | unsigned short hsync_porch_fp = MIPI_HSYNC_FRONT_PORCH_DCLK; |
| 704 | unsigned short hsync_porch_bp = MIPI_HSYNC_BACK_PORCH_DCLK; |
| 705 | unsigned short vsync_porch_fp = MIPI_VSYNC_FRONT_PORCH_LINES; |
| 706 | unsigned short vsync_porch_bp = MIPI_VSYNC_BACK_PORCH_LINES; |
| 707 | unsigned short hsync_width = MIPI_HSYNC_PULSE_WIDTH; |
| 708 | unsigned short vsync_width = MIPI_VSYNC_PULSE_WIDTH; |
| 709 | unsigned short dst_format = 0; |
| 710 | unsigned short traffic_mode = 0; |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 711 | unsigned short pack_pattern = 0x12; //BGR |
| 712 | unsigned char ystride = 3; |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 713 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 714 | low_pwr_stop_mode = 0x1111; // low pwr mode bit16:HSA, bit20:HBA, |
| 715 | // bit24:HFP, bit28:PULSE MODE, need enough |
| 716 | // time for swithc from LP to HS |
| 717 | eof_bllp_pwr = 0x9; // low power stop mode or let cmd mode eng send |
| 718 | // packets in hs or lp mode |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 719 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 720 | status += |
| 721 | config_dsi_video_mode(display_wd, display_ht, image_wd, image_ht, |
| 722 | hsync_porch_fp, hsync_porch_bp, |
| 723 | vsync_porch_fp, vsync_porch_bp, hsync_width, |
| 724 | vsync_width, dst_format, traffic_mode, |
| 725 | num_of_lanes); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 726 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 727 | status += |
| 728 | mdp_setup_dma_p_video_mode(display_wd, display_ht, image_wd, |
| 729 | image_ht, hsync_porch_fp, hsync_porch_bp, |
| 730 | vsync_porch_fp, vsync_porch_bp, |
| 731 | hsync_width, vsync_width, MIPI_FB_ADDR, |
| 732 | image_wd, pack_pattern, ystride); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 733 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 734 | ReadValue = readl(DSI_INT_CTRL) & 0x00010000; |
| 735 | while (ReadValue != 0x00010000) { |
| 736 | ReadValue = readl(DSI_INT_CTRL) & 0x00010000; |
| 737 | count++; |
| 738 | if (count > 0xffff) { |
| 739 | status = FAIL; |
| 740 | dprintf(CRITICAL, "Video lane test failed\n"); |
| 741 | return status; |
| 742 | } |
| 743 | } |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 744 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 745 | dprintf(SPEW, "Video lane tested successfully\n"); |
| 746 | return status; |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 747 | } |
| 748 | |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 749 | int is_cmd_mode_enabled(void) |
| 750 | { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 751 | return cmd_mode_status; |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 752 | } |
| 753 | |
Kinson Chik | e5c9343 | 2011-06-17 09:10:29 -0700 | [diff] [blame] | 754 | #if DISPLAY_MIPI_PANEL_NOVATEK_BLUE |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 755 | void mipi_dsi_cmd_mode_trigger(void) |
| 756 | { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 757 | int status = 0; |
| 758 | unsigned short display_wd = mipi_fb_cfg.width; |
| 759 | unsigned short display_ht = mipi_fb_cfg.height; |
| 760 | unsigned short image_wd = mipi_fb_cfg.width; |
| 761 | unsigned short image_ht = mipi_fb_cfg.height; |
| 762 | unsigned short dst_format = 0; |
| 763 | unsigned short traffic_mode = 0; |
| 764 | struct mipi_dsi_panel_config *panel_info = &novatek_panel_info; |
| 765 | status += mipi_dsi_cmd_config(mipi_fb_cfg, panel_info->num_of_lanes); |
| 766 | mdelay(50); |
| 767 | config_dsi_cmd_mode(display_wd, display_ht, image_wd, image_ht, |
| 768 | dst_format, traffic_mode, |
| 769 | panel_info->num_of_lanes /* num_of_lanes */ ); |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 770 | } |
Kinson Chik | e5c9343 | 2011-06-17 09:10:29 -0700 | [diff] [blame] | 771 | #endif |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 772 | |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 773 | void mipi_dsi_shutdown(void) |
| 774 | { |
Amol Jadi | 6834f1a | 2012-06-29 14:42:59 -0700 | [diff] [blame] | 775 | if(!target_cont_splash_screen()) |
| 776 | { |
| 777 | mdp_shutdown(); |
| 778 | writel(0x01010101, DSI_INT_CTRL); |
| 779 | writel(0x13FF3BFF, DSI_ERR_INT_MASK0); |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 780 | |
| 781 | #if (DISPLAY_MIPI_PANEL_NOVATEK_BLUE \ |
Amol Jadi | 6834f1a | 2012-06-29 14:42:59 -0700 | [diff] [blame] | 782 | || DISPLAY_MIPI_PANEL_TOSHIBA) |
| 783 | secure_writel(0x0, DSI_CC_REG); |
| 784 | secure_writel(0x0, DSI_PIXEL_CC_REG); |
Kinson Chik | e5c9343 | 2011-06-17 09:10:29 -0700 | [diff] [blame] | 785 | #endif |
Amol Jadi | 6834f1a | 2012-06-29 14:42:59 -0700 | [diff] [blame] | 786 | |
| 787 | writel(0, DSI_CLK_CTRL); |
| 788 | writel(0, DSI_CTRL); |
| 789 | writel(0, DSIPHY_PLL_CTRL(0)); |
| 790 | } |
| 791 | else |
| 792 | { |
Chandan Uddaraju | 4877d37 | 2011-07-21 12:51:51 -0700 | [diff] [blame] | 793 | /* To keep the splash screen displayed till kernel driver takes |
| 794 | control, do not turn off the video mode engine and clocks. |
| 795 | Only disabling the MIPI DSI IRQs */ |
| 796 | writel(0x01010101, DSI_INT_CTRL); |
| 797 | writel(0x13FF3BFF, DSI_ERR_INT_MASK0); |
Amol Jadi | 6834f1a | 2012-06-29 14:42:59 -0700 | [diff] [blame] | 798 | } |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 799 | } |
| 800 | |
| 801 | struct fbcon_config *mipi_init(void) |
| 802 | { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 803 | int status = 0; |
| 804 | struct mipi_dsi_panel_config *panel_info = get_panel_info(); |
Channagoud Kadabi | 539ef72 | 2012-03-29 16:02:50 +0530 | [diff] [blame] | 805 | |
| 806 | if (panel_info == NULL) { |
| 807 | dprintf(CRITICAL, "Panel info is null\n"); |
| 808 | return NULL; |
| 809 | } |
| 810 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 811 | /* Enable MMSS_AHB_ARB_MATER_PORT_E for arbiter master0 and master 1 request */ |
Terence Hampson | f49ff4e | 2013-06-18 15:11:31 -0400 | [diff] [blame] | 812 | #if (!DISPLAY_MIPI_PANEL_RENESAS && !DISPLAY_TYPE_DSI6G && !DISPLAY_TYPE_8610) |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 813 | writel(0x00001800, MMSS_SFPB_GPREG); |
Aparna Mallavarapu | f712f5e | 2011-08-04 21:11:00 +0530 | [diff] [blame] | 814 | #endif |
Kinson Chik | e5c9343 | 2011-06-17 09:10:29 -0700 | [diff] [blame] | 815 | |
| 816 | #if DISPLAY_MIPI_PANEL_TOSHIBA_MDT61 |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 817 | mipi_dsi_phy_init(panel_info); |
Kinson Chik | e5c9343 | 2011-06-17 09:10:29 -0700 | [diff] [blame] | 818 | #else |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 819 | mipi_dsi_phy_ctrl_config(panel_info); |
Kinson Chik | e5c9343 | 2011-06-17 09:10:29 -0700 | [diff] [blame] | 820 | #endif |
| 821 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 822 | status += mipi_dsi_panel_initialize(panel_info); |
Kinson Chik | e5c9343 | 2011-06-17 09:10:29 -0700 | [diff] [blame] | 823 | |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 824 | #if DISPLAY_MIPI_PANEL_NOVATEK_BLUE |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 825 | mipi_dsi_cmd_bta_sw_trigger(); |
| 826 | mipi_novatek_manufacture_id(); |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 827 | #endif |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 828 | mipi_fb_cfg.base = MIPI_FB_ADDR; |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 829 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 830 | if (panel_info->mode == MIPI_VIDEO_MODE) |
| 831 | status += mipi_dsi_video_config(panel_info->num_of_lanes); |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 832 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 833 | if (panel_info->mode == MIPI_CMD_MODE) |
| 834 | cmd_mode_status = 1; |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 835 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 836 | return &mipi_fb_cfg; |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 837 | } |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 838 | |
| 839 | int mipi_config(struct msm_fb_panel_data *panel) |
| 840 | { |
| 841 | int ret = NO_ERROR; |
| 842 | struct msm_panel_info *pinfo; |
| 843 | struct mipi_dsi_panel_config mipi_pinfo; |
| 844 | |
| 845 | if (!panel) |
| 846 | return ERR_INVALID_ARGS; |
| 847 | |
| 848 | pinfo = &(panel->panel_info); |
| 849 | mipi_pinfo.mode = pinfo->mipi.mode; |
| 850 | mipi_pinfo.num_of_lanes = pinfo->mipi.num_of_lanes; |
| 851 | mipi_pinfo.dsi_phy_config = pinfo->mipi.dsi_phy_db; |
| 852 | mipi_pinfo.panel_cmds = pinfo->mipi.panel_cmds; |
| 853 | mipi_pinfo.num_of_panel_cmds = pinfo->mipi.num_of_panel_cmds; |
Channagoud Kadabi | 539ef72 | 2012-03-29 16:02:50 +0530 | [diff] [blame] | 854 | mipi_pinfo.lane_swap = pinfo->mipi.lane_swap; |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 855 | mipi_pinfo.pack = 1; |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 856 | |
| 857 | /* Enable MMSS_AHB_ARB_MATER_PORT_E for |
| 858 | arbiter master0 and master 1 request */ |
Terence Hampson | f49ff4e | 2013-06-18 15:11:31 -0400 | [diff] [blame] | 859 | #if (!DISPLAY_MIPI_PANEL_RENESAS && !DISPLAY_TYPE_DSI6G && !DISPLAY_TYPE_8610) |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 860 | writel(0x00001800, MMSS_SFPB_GPREG); |
| 861 | #endif |
| 862 | |
| 863 | mipi_dsi_phy_init(&mipi_pinfo); |
| 864 | |
| 865 | ret += mipi_dsi_panel_initialize(&mipi_pinfo); |
| 866 | |
Channagoud Kadabi | 01c9182 | 2012-06-06 15:53:30 +0530 | [diff] [blame] | 867 | if (pinfo->rotate && panel->rotate) |
| 868 | pinfo->rotate(); |
| 869 | |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 870 | return ret; |
| 871 | } |
| 872 | |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 873 | int mdss_dsi_video_mode_config(uint16_t disp_width, |
| 874 | uint16_t disp_height, |
| 875 | uint16_t img_width, |
| 876 | uint16_t img_height, |
| 877 | uint16_t hsync_porch0_fp, |
| 878 | uint16_t hsync_porch0_bp, |
| 879 | uint16_t vsync_porch0_fp, |
| 880 | uint16_t vsync_porch0_bp, |
| 881 | uint16_t hsync_width, |
| 882 | uint16_t vsync_width, |
| 883 | uint16_t dst_format, |
| 884 | uint16_t traffic_mode, |
| 885 | uint8_t lane_en, |
| 886 | uint16_t low_pwr_stop_mode, |
| 887 | uint8_t eof_bllp_pwr, |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 888 | uint8_t interleav, |
| 889 | uint32_t ctl_base) |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 890 | { |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 891 | int status = 0; |
| 892 | |
Terence Hampson | cc3345c | 2013-06-27 15:30:10 -0400 | [diff] [blame] | 893 | #if (DISPLAY_TYPE_MDSS == 1) |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 894 | /* disable mdp first */ |
| 895 | mdp_disable(); |
| 896 | |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 897 | writel(0x00000000, ctl_base + CLK_CTRL); |
| 898 | writel(0x00000002, ctl_base + CLK_CTRL); |
| 899 | writel(0x00000006, ctl_base + CLK_CTRL); |
| 900 | writel(0x0000000e, ctl_base + CLK_CTRL); |
| 901 | writel(0x0000001e, ctl_base + CLK_CTRL); |
| 902 | writel(0x0000023f, ctl_base + CLK_CTRL); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 903 | |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 904 | writel(0, ctl_base + CTRL); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 905 | |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 906 | writel(0, ctl_base + DSI_ERR_INT_MASK0); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 907 | |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 908 | writel(0x02020202, ctl_base + INT_CTRL); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 909 | |
| 910 | writel(((disp_width + hsync_porch0_bp) << 16) | hsync_porch0_bp, |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 911 | ctl_base + VIDEO_MODE_ACTIVE_H); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 912 | |
| 913 | writel(((disp_height + vsync_porch0_bp) << 16) | (vsync_porch0_bp), |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 914 | ctl_base + VIDEO_MODE_ACTIVE_V); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 915 | |
Terence Hampson | 7385f6a | 2013-08-16 15:31:25 -0400 | [diff] [blame] | 916 | if (mdp_get_revision() >= MDP_REV_41 || |
| 917 | mdp_get_revision() == MDP_REV_304) { |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 918 | writel(((disp_height + vsync_porch0_fp |
| 919 | + vsync_porch0_bp - 1) << 16) |
| 920 | | (disp_width + hsync_porch0_fp |
| 921 | + hsync_porch0_bp - 1), |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 922 | ctl_base + VIDEO_MODE_TOTAL); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 923 | } else { |
| 924 | writel(((disp_height + vsync_porch0_fp |
| 925 | + vsync_porch0_bp) << 16) |
| 926 | | (disp_width + hsync_porch0_fp |
| 927 | + hsync_porch0_bp), |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 928 | ctl_base + VIDEO_MODE_TOTAL); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 929 | } |
| 930 | |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 931 | writel((hsync_width << 16) | 0, ctl_base + VIDEO_MODE_HSYNC); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 932 | |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 933 | writel(0 << 16 | 0, ctl_base + VIDEO_MODE_VSYNC); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 934 | |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 935 | writel(vsync_width << 16 | 0, ctl_base + VIDEO_MODE_VSYNC_VPOS); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 936 | |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 937 | writel(0x0, ctl_base + EOT_PACKET_CTRL); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 938 | |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 939 | writel(0x00000100, ctl_base + MISR_VIDEO_CTRL); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 940 | |
| 941 | if (mdp_get_revision() >= MDP_REV_41) { |
| 942 | writel(low_pwr_stop_mode << 16 | |
| 943 | eof_bllp_pwr << 12 | traffic_mode << 8 |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 944 | | dst_format << 4 | 0x0, ctl_base + VIDEO_MODE_CTRL); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 945 | } else { |
| 946 | writel(1 << 28 | 1 << 24 | 1 << 20 | low_pwr_stop_mode << 16 | |
| 947 | eof_bllp_pwr << 12 | traffic_mode << 8 |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 948 | | dst_format << 4 | 0x0, ctl_base + VIDEO_MODE_CTRL); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 949 | } |
| 950 | |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 951 | writel(0x3fd08, ctl_base + HS_TIMER_CTRL); |
| 952 | writel(0x00010100, ctl_base + MISR_VIDEO_CTRL); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 953 | |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 954 | writel(0x00010100, ctl_base + INT_CTRL); |
| 955 | writel(0x02010202, ctl_base + INT_CTRL); |
| 956 | writel(0x02030303, ctl_base + INT_CTRL); |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 957 | |
| 958 | writel(interleav << 30 | 0 << 24 | 0 << 20 | lane_en << 4 |
Siddhartha Agrawal | 6e76004 | 2013-05-30 21:10:18 -0700 | [diff] [blame] | 959 | | 0x103, ctl_base + CTRL); |
Terence Hampson | cc3345c | 2013-06-27 15:30:10 -0400 | [diff] [blame] | 960 | #endif |
Siddhartha Agrawal | 06bb82f | 2013-05-24 12:32:33 -0700 | [diff] [blame] | 961 | |
| 962 | return status; |
| 963 | } |
| 964 | |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 965 | int mdss_dsi_config(struct msm_fb_panel_data *panel) |
| 966 | { |
| 967 | int ret = NO_ERROR; |
| 968 | struct msm_panel_info *pinfo; |
| 969 | struct mipi_dsi_panel_config mipi_pinfo; |
| 970 | |
Terence Hampson | cc3345c | 2013-06-27 15:30:10 -0400 | [diff] [blame] | 971 | #if (DISPLAY_TYPE_MDSS == 1) |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 972 | if (!panel) |
| 973 | return ERR_INVALID_ARGS; |
| 974 | |
| 975 | pinfo = &(panel->panel_info); |
| 976 | mipi_pinfo.mode = pinfo->mipi.mode; |
| 977 | mipi_pinfo.num_of_lanes = pinfo->mipi.num_of_lanes; |
| 978 | mipi_pinfo.mdss_dsi_phy_config = pinfo->mipi.mdss_dsi_phy_db; |
| 979 | mipi_pinfo.panel_cmds = pinfo->mipi.panel_cmds; |
| 980 | mipi_pinfo.num_of_panel_cmds = pinfo->mipi.num_of_panel_cmds; |
| 981 | mipi_pinfo.lane_swap = pinfo->mipi.lane_swap; |
| 982 | mipi_pinfo.pack = 0; |
Siddhartha Agrawal | b6c861f | 2013-05-31 19:36:44 -0700 | [diff] [blame] | 983 | mipi_pinfo.t_clk_pre = pinfo->mipi.t_clk_pre; |
| 984 | mipi_pinfo.t_clk_post = pinfo->mipi.t_clk_post; |
Casey Piper | 8403675 | 2013-09-05 14:56:37 -0700 | [diff] [blame] | 985 | mipi_pinfo.signature = pinfo->mipi.signature; |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 986 | |
Siddhartha Agrawal | 1b2ed84 | 2013-05-29 18:02:28 -0700 | [diff] [blame] | 987 | mdss_dsi_phy_init(&mipi_pinfo, MIPI_DSI0_BASE); |
| 988 | if (pinfo->mipi.dual_dsi) |
| 989 | mdss_dsi_phy_init(&mipi_pinfo, MIPI_DSI1_BASE); |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 990 | |
Siddhartha Agrawal | 980b5ee | 2013-05-30 12:17:50 -0700 | [diff] [blame] | 991 | ret += mdss_dsi_panel_initialize(&mipi_pinfo, pinfo->mipi.broadcast); |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 992 | |
| 993 | if (pinfo->rotate && panel->rotate) |
| 994 | pinfo->rotate(); |
Terence Hampson | cc3345c | 2013-06-27 15:30:10 -0400 | [diff] [blame] | 995 | #endif |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 996 | |
| 997 | return ret; |
| 998 | } |
| 999 | |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 1000 | int mipi_dsi_video_mode_config(unsigned short disp_width, |
| 1001 | unsigned short disp_height, |
| 1002 | unsigned short img_width, |
| 1003 | unsigned short img_height, |
| 1004 | unsigned short hsync_porch0_fp, |
| 1005 | unsigned short hsync_porch0_bp, |
| 1006 | unsigned short vsync_porch0_fp, |
| 1007 | unsigned short vsync_porch0_bp, |
| 1008 | unsigned short hsync_width, |
| 1009 | unsigned short vsync_width, |
| 1010 | unsigned short dst_format, |
| 1011 | unsigned short traffic_mode, |
| 1012 | unsigned char lane_en, |
| 1013 | unsigned low_pwr_stop_mode, |
| 1014 | unsigned char eof_bllp_pwr, |
| 1015 | unsigned char interleav) |
| 1016 | { |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 1017 | int status = 0; |
| 1018 | |
| 1019 | /* disable mdp first */ |
| 1020 | mdp_disable(); |
| 1021 | |
| 1022 | writel(0x00000000, DSI_CLK_CTRL); |
| 1023 | writel(0x00000000, DSI_CLK_CTRL); |
| 1024 | writel(0x00000000, DSI_CLK_CTRL); |
| 1025 | writel(0x00000000, DSI_CLK_CTRL); |
| 1026 | writel(0x00000002, DSI_CLK_CTRL); |
| 1027 | writel(0x00000006, DSI_CLK_CTRL); |
| 1028 | writel(0x0000000e, DSI_CLK_CTRL); |
| 1029 | writel(0x0000001e, DSI_CLK_CTRL); |
Chandan Uddaraju | eb1decb | 2013-04-23 14:27:49 -0700 | [diff] [blame] | 1030 | writel(0x0000023f, DSI_CLK_CTRL); |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 1031 | |
| 1032 | writel(0, DSI_CTRL); |
| 1033 | |
| 1034 | writel(0, DSI_ERR_INT_MASK0); |
| 1035 | |
| 1036 | writel(0x02020202, DSI_INT_CTRL); |
| 1037 | |
| 1038 | writel(((disp_width + hsync_porch0_bp) << 16) | hsync_porch0_bp, |
| 1039 | DSI_VIDEO_MODE_ACTIVE_H); |
| 1040 | |
| 1041 | writel(((disp_height + vsync_porch0_bp) << 16) | (vsync_porch0_bp), |
| 1042 | DSI_VIDEO_MODE_ACTIVE_V); |
| 1043 | |
| 1044 | if (mdp_get_revision() >= MDP_REV_41) { |
| 1045 | writel(((disp_height + vsync_porch0_fp |
| 1046 | + vsync_porch0_bp - 1) << 16) |
| 1047 | | (disp_width + hsync_porch0_fp |
| 1048 | + hsync_porch0_bp - 1), |
| 1049 | DSI_VIDEO_MODE_TOTAL); |
| 1050 | } else { |
| 1051 | writel(((disp_height + vsync_porch0_fp |
| 1052 | + vsync_porch0_bp) << 16) |
| 1053 | | (disp_width + hsync_porch0_fp |
| 1054 | + hsync_porch0_bp), |
| 1055 | DSI_VIDEO_MODE_TOTAL); |
| 1056 | } |
| 1057 | |
| 1058 | writel((hsync_width << 16) | 0, DSI_VIDEO_MODE_HSYNC); |
| 1059 | |
| 1060 | writel(0 << 16 | 0, DSI_VIDEO_MODE_VSYNC); |
| 1061 | |
| 1062 | writel(vsync_width << 16 | 0, DSI_VIDEO_MODE_VSYNC_VPOS); |
| 1063 | |
Chandan Uddaraju | eb1decb | 2013-04-23 14:27:49 -0700 | [diff] [blame] | 1064 | writel(0x0, DSI_EOT_PACKET_CTRL); |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 1065 | |
| 1066 | writel(0x00000100, DSI_MISR_VIDEO_CTRL); |
| 1067 | |
Channagoud Kadabi | 539ef72 | 2012-03-29 16:02:50 +0530 | [diff] [blame] | 1068 | if (mdp_get_revision() >= MDP_REV_41) { |
| 1069 | writel(low_pwr_stop_mode << 16 | |
| 1070 | eof_bllp_pwr << 12 | traffic_mode << 8 |
| 1071 | | dst_format << 4 | 0x0, DSI_VIDEO_MODE_CTRL); |
| 1072 | } else { |
| 1073 | writel(1 << 28 | 1 << 24 | 1 << 20 | low_pwr_stop_mode << 16 | |
| 1074 | eof_bllp_pwr << 12 | traffic_mode << 8 |
| 1075 | | dst_format << 4 | 0x0, DSI_VIDEO_MODE_CTRL); |
| 1076 | } |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 1077 | |
Chandan Uddaraju | eb1decb | 2013-04-23 14:27:49 -0700 | [diff] [blame] | 1078 | writel(0x3fd08, DSI_HS_TIMER_CTRL); |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 1079 | writel(0x67, DSI_CAL_STRENGTH_CTRL); |
| 1080 | writel(0x80006711, DSI_CAL_CTRL); |
| 1081 | writel(0x00010100, DSI_MISR_VIDEO_CTRL); |
| 1082 | |
| 1083 | writel(0x00010100, DSI_INT_CTRL); |
| 1084 | writel(0x02010202, DSI_INT_CTRL); |
| 1085 | writel(0x02030303, DSI_INT_CTRL); |
| 1086 | |
| 1087 | writel(interleav << 30 | 0 << 24 | 0 << 20 | lane_en << 4 |
| 1088 | | 0x103, DSI_CTRL); |
| 1089 | |
| 1090 | return status; |
| 1091 | } |
| 1092 | |
Siddhartha Agrawal | 7317e48 | 2013-04-21 16:16:57 -0700 | [diff] [blame] | 1093 | int mdss_dsi_cmd_mode_config(uint16_t disp_width, |
| 1094 | uint16_t disp_height, |
| 1095 | uint16_t img_width, |
| 1096 | uint16_t img_height, |
| 1097 | uint16_t dst_format, |
Xiaoming Zhou | 8d534dd | 2013-07-29 15:49:19 -0400 | [diff] [blame] | 1098 | uint8_t ystride, |
| 1099 | uint8_t lane_en, |
| 1100 | uint8_t interleav) |
Siddhartha Agrawal | 7317e48 | 2013-04-21 16:16:57 -0700 | [diff] [blame] | 1101 | { |
Xiaoming Zhou | 8d534dd | 2013-07-29 15:49:19 -0400 | [diff] [blame] | 1102 | uint16_t dst_fmt = 0; |
| 1103 | |
| 1104 | switch (dst_format) { |
| 1105 | case DSI_VIDEO_DST_FORMAT_RGB565: |
| 1106 | dst_fmt = DSI_CMD_DST_FORMAT_RGB565; |
| 1107 | break; |
| 1108 | case DSI_VIDEO_DST_FORMAT_RGB666: |
| 1109 | case DSI_VIDEO_DST_FORMAT_RGB666_LOOSE: |
| 1110 | dst_fmt = DSI_CMD_DST_FORMAT_RGB666; |
| 1111 | break; |
| 1112 | case DSI_VIDEO_DST_FORMAT_RGB888: |
| 1113 | dst_fmt = DSI_CMD_DST_FORMAT_RGB888; |
| 1114 | break; |
| 1115 | default: |
| 1116 | dprintf(CRITICAL, "unsupported dst format\n"); |
| 1117 | return ERROR; |
| 1118 | } |
Siddhartha Agrawal | 7317e48 | 2013-04-21 16:16:57 -0700 | [diff] [blame] | 1119 | |
Terence Hampson | cc3345c | 2013-06-27 15:30:10 -0400 | [diff] [blame] | 1120 | #if (DISPLAY_TYPE_MDSS == 1) |
Siddhartha Agrawal | 7317e48 | 2013-04-21 16:16:57 -0700 | [diff] [blame] | 1121 | writel(0x00000000, DSI_CLK_CTRL); |
| 1122 | writel(0x00000000, DSI_CLK_CTRL); |
| 1123 | writel(0x00000000, DSI_CLK_CTRL); |
| 1124 | writel(0x00000000, DSI_CLK_CTRL); |
| 1125 | writel(0x00000002, DSI_CLK_CTRL); |
| 1126 | writel(0x00000006, DSI_CLK_CTRL); |
| 1127 | writel(0x0000000e, DSI_CLK_CTRL); |
| 1128 | writel(0x0000001e, DSI_CLK_CTRL); |
| 1129 | writel(0x0000023f, DSI_CLK_CTRL); |
| 1130 | |
| 1131 | writel(0, DSI_CTRL); |
| 1132 | |
| 1133 | writel(0, DSI_ERR_INT_MASK0); |
| 1134 | |
| 1135 | writel(0x02020202, DSI_INT_CTRL); |
| 1136 | |
Xiaoming Zhou | 8d534dd | 2013-07-29 15:49:19 -0400 | [diff] [blame] | 1137 | writel(dst_fmt, DSI_COMMAND_MODE_MDP_CTRL); |
Siddhartha Agrawal | 7317e48 | 2013-04-21 16:16:57 -0700 | [diff] [blame] | 1138 | writel((img_width * ystride + 1) << 16 | 0x0039, |
| 1139 | DSI_COMMAND_MODE_MDP_STREAM0_CTRL); |
| 1140 | writel((img_width * ystride + 1) << 16 | 0x0039, |
| 1141 | DSI_COMMAND_MODE_MDP_STREAM1_CTRL); |
| 1142 | writel(img_height << 16 | img_width, |
| 1143 | DSI_COMMAND_MODE_MDP_STREAM0_TOTAL); |
| 1144 | writel(img_height << 16 | img_width, |
| 1145 | DSI_COMMAND_MODE_MDP_STREAM1_TOTAL); |
| 1146 | writel(0x13c2c, DSI_COMMAND_MODE_MDP_DCS_CMD_CTRL); |
Xiaoming Zhou | 8d534dd | 2013-07-29 15:49:19 -0400 | [diff] [blame] | 1147 | writel(interleav << 30 | 0 << 24 | 0 << 20 | lane_en << 4 | 0x105, |
Siddhartha Agrawal | 7317e48 | 2013-04-21 16:16:57 -0700 | [diff] [blame] | 1148 | DSI_CTRL); |
| 1149 | writel(0x10000000, DSI_COMMAND_MODE_DMA_CTRL); |
| 1150 | writel(0x10000000, DSI_MISR_CMD_CTRL); |
Terence Hampson | cc3345c | 2013-06-27 15:30:10 -0400 | [diff] [blame] | 1151 | #endif |
Siddhartha Agrawal | 7317e48 | 2013-04-21 16:16:57 -0700 | [diff] [blame] | 1152 | |
Xiaoming Zhou | 8d534dd | 2013-07-29 15:49:19 -0400 | [diff] [blame] | 1153 | return 0; |
Siddhartha Agrawal | 7317e48 | 2013-04-21 16:16:57 -0700 | [diff] [blame] | 1154 | } |
| 1155 | |
Channagoud Kadabi | 10189fd | 2012-05-25 13:33:39 +0530 | [diff] [blame] | 1156 | int mipi_dsi_cmd_mode_config(unsigned short disp_width, |
| 1157 | unsigned short disp_height, |
| 1158 | unsigned short img_width, |
| 1159 | unsigned short img_height, |
| 1160 | unsigned short dst_format, |
| 1161 | unsigned short traffic_mode) |
| 1162 | { |
| 1163 | unsigned char DST_FORMAT; |
| 1164 | unsigned char TRAFIC_MODE; |
| 1165 | unsigned char DLNx_EN; |
| 1166 | // video mode data ctrl |
| 1167 | int status = 0; |
| 1168 | unsigned char interleav = 0; |
| 1169 | unsigned char ystride = 0x03; |
| 1170 | // disable mdp first |
| 1171 | |
| 1172 | writel(0x00000000, DSI_CLK_CTRL); |
| 1173 | writel(0x00000000, DSI_CLK_CTRL); |
| 1174 | writel(0x00000000, DSI_CLK_CTRL); |
| 1175 | writel(0x00000000, DSI_CLK_CTRL); |
| 1176 | writel(0x00000002, DSI_CLK_CTRL); |
| 1177 | writel(0x00000006, DSI_CLK_CTRL); |
| 1178 | writel(0x0000000e, DSI_CLK_CTRL); |
| 1179 | writel(0x0000001e, DSI_CLK_CTRL); |
| 1180 | writel(0x0000003e, DSI_CLK_CTRL); |
| 1181 | |
| 1182 | writel(0x10000000, DSI_ERR_INT_MASK0); |
| 1183 | |
| 1184 | |
| 1185 | DST_FORMAT = 8; // RGB888 |
| 1186 | dprintf(SPEW, "DSI_Cmd_Mode - Dst Format: RGB888\n"); |
| 1187 | |
| 1188 | DLNx_EN = 3; // 2 lane with clk programming |
| 1189 | dprintf(SPEW, "Data Lane: 2 lane\n"); |
| 1190 | |
| 1191 | TRAFIC_MODE = 0; // non burst mode with sync pulses |
| 1192 | dprintf(SPEW, "Traffic mode: non burst mode with sync pulses\n"); |
| 1193 | |
| 1194 | writel(0x02020202, DSI_INT_CTRL); |
| 1195 | |
| 1196 | writel(0x00100000 | DST_FORMAT, DSI_COMMAND_MODE_MDP_CTRL); |
| 1197 | writel((img_width * ystride + 1) << 16 | 0x0039, |
| 1198 | DSI_COMMAND_MODE_MDP_STREAM0_CTRL); |
| 1199 | writel((img_width * ystride + 1) << 16 | 0x0039, |
| 1200 | DSI_COMMAND_MODE_MDP_STREAM1_CTRL); |
| 1201 | writel(img_height << 16 | img_width, |
| 1202 | DSI_COMMAND_MODE_MDP_STREAM0_TOTAL); |
| 1203 | writel(img_height << 16 | img_width, |
| 1204 | DSI_COMMAND_MODE_MDP_STREAM1_TOTAL); |
| 1205 | writel(0xEE, DSI_CAL_STRENGTH_CTRL); |
| 1206 | writel(0x80000000, DSI_CAL_CTRL); |
| 1207 | writel(0x40, DSI_TRIG_CTRL); |
| 1208 | writel(0x13c2c, DSI_COMMAND_MODE_MDP_DCS_CMD_CTRL); |
| 1209 | writel(interleav << 30 | 0 << 24 | 0 << 20 | DLNx_EN << 4 | 0x105, |
| 1210 | DSI_CTRL); |
| 1211 | writel(0x10000000, DSI_COMMAND_MODE_DMA_CTRL); |
| 1212 | writel(0x10000000, DSI_MISR_CMD_CTRL); |
| 1213 | writel(0x00000040, DSI_ERR_INT_MASK0); |
| 1214 | writel(0x1, DSI_EOT_PACKET_CTRL); |
| 1215 | |
| 1216 | return NO_ERROR; |
| 1217 | } |
| 1218 | |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 1219 | int mipi_dsi_on() |
| 1220 | { |
| 1221 | int ret = NO_ERROR; |
| 1222 | unsigned long ReadValue; |
| 1223 | unsigned long count = 0; |
| 1224 | |
| 1225 | ReadValue = readl(DSI_INT_CTRL) & 0x00010000; |
| 1226 | |
| 1227 | mdelay(10); |
| 1228 | |
| 1229 | while (ReadValue != 0x00010000) { |
| 1230 | ReadValue = readl(DSI_INT_CTRL) & 0x00010000; |
| 1231 | count++; |
| 1232 | if (count > 0xffff) { |
| 1233 | dprintf(CRITICAL, "Video lane test failed\n"); |
| 1234 | return ERROR; |
| 1235 | } |
| 1236 | } |
| 1237 | |
Amir Samuelov | 2d4ba16 | 2012-07-22 11:53:14 +0300 | [diff] [blame] | 1238 | dprintf(INFO, "Video lane tested successfully\n"); |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 1239 | return ret; |
| 1240 | } |
| 1241 | |
Siddhartha Agrawal | 24d81b5 | 2013-07-01 11:13:32 -0700 | [diff] [blame] | 1242 | int mipi_dsi_off(struct msm_panel_info *pinfo) |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 1243 | { |
Amol Jadi | 6834f1a | 2012-06-29 14:42:59 -0700 | [diff] [blame] | 1244 | if(!target_cont_splash_screen()) |
| 1245 | { |
| 1246 | writel(0, DSI_CLK_CTRL); |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 1247 | writel(0x1F1, DSI_CTRL); |
Siddhartha Agrawal | 3e694ea | 2013-01-23 17:01:31 -0800 | [diff] [blame] | 1248 | mdelay(10); |
| 1249 | writel(0x0001, DSI_SOFT_RESET); |
| 1250 | writel(0x0000, DSI_SOFT_RESET); |
Siddhartha Agrawal | e0033a1 | 2013-02-23 15:37:42 -0800 | [diff] [blame] | 1251 | writel(0x1115501, DSI_INT_CTRL); |
Amol Jadi | 6834f1a | 2012-06-29 14:42:59 -0700 | [diff] [blame] | 1252 | writel(0, DSI_CTRL); |
Siddhartha Agrawal | e0033a1 | 2013-02-23 15:37:42 -0800 | [diff] [blame] | 1253 | } |
| 1254 | |
| 1255 | writel(0x1115501, DSI_INT_CTRL); |
Siddhartha Agrawal | 24d81b5 | 2013-07-01 11:13:32 -0700 | [diff] [blame] | 1256 | if (pinfo->mipi.broadcast) |
| 1257 | writel(0x1115501, DSI_INT_CTRL + 0x600); |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 1258 | |
| 1259 | return NO_ERROR; |
| 1260 | } |
Channagoud Kadabi | 10189fd | 2012-05-25 13:33:39 +0530 | [diff] [blame] | 1261 | |
| 1262 | int mipi_cmd_trigger() |
| 1263 | { |
| 1264 | writel(0x1, DSI_CMD_MODE_MDP_SW_TRIGGER); |
| 1265 | |
| 1266 | return NO_ERROR; |
| 1267 | } |