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