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