Shashank Mittal | 3026290 | 2012-02-21 15:37:24 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2010-2012, Code Aurora Forum. 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. |
| 12 | * * Neither the name of Code Aurora Forum, Inc. nor the names of its |
| 13 | * contributors may be used to endorse or promote products derived |
| 14 | * from this software without specific prior written permission. |
| 15 | * |
| 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED |
| 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | * |
| 28 | */ |
| 29 | |
| 30 | #include <reg.h> |
Shashank 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 | |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 51 | #if DISPLAY_MIPI_PANEL_TOSHIBA |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 52 | static struct fbcon_config mipi_fb_cfg = { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 53 | .height = TSH_MIPI_FB_HEIGHT, |
| 54 | .width = TSH_MIPI_FB_WIDTH, |
| 55 | .stride = TSH_MIPI_FB_WIDTH, |
| 56 | .format = FB_FORMAT_RGB888, |
| 57 | .bpp = 24, |
| 58 | .update_start = NULL, |
| 59 | .update_done = NULL, |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 60 | }; |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 61 | |
Kinson Chik | e5c9343 | 2011-06-17 09:10:29 -0700 | [diff] [blame] | 62 | struct mipi_dsi_panel_config toshiba_panel_info = { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 63 | .mode = MIPI_VIDEO_MODE, |
| 64 | .num_of_lanes = 1, |
| 65 | .dsi_phy_config = &mipi_dsi_toshiba_panel_phy_ctrl, |
| 66 | .panel_cmds = toshiba_panel_video_mode_cmds, |
| 67 | .num_of_panel_cmds = ARRAY_SIZE(toshiba_panel_video_mode_cmds), |
Kinson Chik | e5c9343 | 2011-06-17 09:10:29 -0700 | [diff] [blame] | 68 | }; |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 69 | #elif DISPLAY_MIPI_PANEL_NOVATEK_BLUE |
| 70 | static struct fbcon_config mipi_fb_cfg = { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 71 | .height = NOV_MIPI_FB_HEIGHT, |
| 72 | .width = NOV_MIPI_FB_WIDTH, |
| 73 | .stride = NOV_MIPI_FB_WIDTH, |
| 74 | .format = FB_FORMAT_RGB888, |
| 75 | .bpp = 24, |
| 76 | .update_start = NULL, |
| 77 | .update_done = NULL, |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 78 | }; |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 79 | |
Kinson Chik | e5c9343 | 2011-06-17 09:10:29 -0700 | [diff] [blame] | 80 | struct mipi_dsi_panel_config novatek_panel_info = { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 81 | .mode = MIPI_CMD_MODE, |
| 82 | .num_of_lanes = 2, |
| 83 | .dsi_phy_config = &mipi_dsi_novatek_panel_phy_ctrl, |
| 84 | .panel_cmds = novatek_panel_cmd_mode_cmds, |
| 85 | .num_of_panel_cmds = ARRAY_SIZE(novatek_panel_cmd_mode_cmds), |
Kinson Chik | e5c9343 | 2011-06-17 09:10:29 -0700 | [diff] [blame] | 86 | }; |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 87 | #else |
| 88 | static struct fbcon_config mipi_fb_cfg = { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 89 | .height = 0, |
| 90 | .width = 0, |
| 91 | .stride = 0, |
| 92 | .format = 0, |
| 93 | .bpp = 0, |
| 94 | .update_start = NULL, |
| 95 | .update_done = NULL, |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 96 | }; |
| 97 | #endif |
| 98 | |
| 99 | static int cmd_mode_status = 0; |
Greg Grisco | d625055 | 2011-06-29 14:40:23 -0700 | [diff] [blame] | 100 | void secure_writel(uint32_t, uint32_t); |
| 101 | uint32_t secure_readl(uint32_t); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 102 | |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 103 | struct mipi_dsi_panel_config *get_panel_info(void) |
| 104 | { |
| 105 | #if DISPLAY_MIPI_PANEL_TOSHIBA |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 106 | return &toshiba_panel_info; |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 107 | #elif DISPLAY_MIPI_PANEL_NOVATEK_BLUE |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 108 | return &novatek_panel_info; |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 109 | #endif |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 110 | return NULL; |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 111 | } |
| 112 | |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 113 | int dsi_cmd_dma_trigger_for_panel() |
| 114 | { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 115 | unsigned long ReadValue; |
| 116 | unsigned long count = 0; |
| 117 | int status = 0; |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 118 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 119 | writel(0x03030303, DSI_INT_CTRL); |
| 120 | writel(0x1, DSI_CMD_MODE_DMA_SW_TRIGGER); |
| 121 | dsb(); |
| 122 | ReadValue = readl(DSI_INT_CTRL) & 0x00000001; |
| 123 | while (ReadValue != 0x00000001) { |
| 124 | ReadValue = readl(DSI_INT_CTRL) & 0x00000001; |
| 125 | count++; |
| 126 | if (count > 0xffff) { |
| 127 | status = FAIL; |
| 128 | dprintf(CRITICAL, |
| 129 | "Panel CMD: command mode dma test failed\n"); |
| 130 | return status; |
| 131 | } |
| 132 | } |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 133 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 134 | writel((readl(DSI_INT_CTRL) | 0x01000001), DSI_INT_CTRL); |
| 135 | dprintf(SPEW, "Panel CMD: command mode dma tested successfully\n"); |
| 136 | return status; |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 137 | } |
| 138 | |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 139 | int mipi_dsi_cmds_tx(struct mipi_dsi_cmd *cmds, int count) |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 140 | { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 141 | int ret = 0; |
| 142 | struct mipi_dsi_cmd *cm; |
| 143 | int i = 0; |
| 144 | char pload[256]; |
| 145 | uint32_t off; |
Deepa Dinamani | a080a40 | 2011-11-05 18:59:26 -0700 | [diff] [blame] | 146 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 147 | /* Align pload at 8 byte boundry */ |
| 148 | off = pload; |
| 149 | off &= 0x07; |
| 150 | if (off) |
| 151 | off = 8 - off; |
| 152 | off += pload; |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 153 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 154 | cm = cmds; |
| 155 | for (i = 0; i < count; i++) { |
| 156 | memcpy((void *)off, (cm->payload), cm->size); |
| 157 | writel(off, DSI_DMA_CMD_OFFSET); |
| 158 | writel(cm->size, DSI_DMA_CMD_LENGTH); // reg 0x48 for this build |
| 159 | dsb(); |
| 160 | ret += dsi_cmd_dma_trigger_for_panel(); |
| 161 | udelay(80); |
| 162 | cm++; |
| 163 | } |
| 164 | return ret; |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 165 | } |
| 166 | |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 167 | /* |
| 168 | * mipi_dsi_cmd_rx: can receive at most 16 bytes |
| 169 | * per transaction since it only have 4 32bits reigsters |
| 170 | * to hold data. |
| 171 | * therefore Maximum Return Packet Size need to be set to 16. |
| 172 | * any return data more than MRPS need to be break down |
| 173 | * to multiple transactions. |
| 174 | */ |
| 175 | int mipi_dsi_cmds_rx(char **rp, int len) |
| 176 | { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 177 | uint32_t *lp, data; |
| 178 | char *dp; |
| 179 | int i, off, cnt; |
| 180 | int rlen, res; |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 181 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 182 | if (len <= 2) |
| 183 | rlen = 4; /* short read */ |
| 184 | else |
| 185 | rlen = MIPI_DSI_MRPS + 6; /* 4 bytes header + 2 bytes crc */ |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 186 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 187 | if (rlen > MIPI_DSI_REG_LEN) { |
| 188 | return 0; |
| 189 | } |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 190 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 191 | res = rlen & 0x03; |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 192 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 193 | rlen += res; /* 4 byte align */ |
| 194 | lp = (uint32_t *) (*rp); |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 195 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 196 | cnt = rlen; |
| 197 | cnt += 3; |
| 198 | cnt >>= 2; |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 199 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 200 | if (cnt > 4) |
| 201 | cnt = 4; /* 4 x 32 bits registers only */ |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 202 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 203 | off = 0x068; /* DSI_RDBK_DATA0 */ |
| 204 | off += ((cnt - 1) * 4); |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 205 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 206 | for (i = 0; i < cnt; i++) { |
| 207 | data = (uint32_t) readl(MIPI_DSI_BASE + off); |
| 208 | *lp++ = ntohl(data); /* to network byte order */ |
| 209 | off -= 4; |
| 210 | } |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 211 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 212 | if (len > 2) { |
| 213 | /*First 4 bytes + paded bytes will be header next len bytes would be payload */ |
| 214 | for (i = 0; i < len; i++) { |
| 215 | dp = *rp; |
| 216 | dp[i] = dp[4 + res + i]; |
| 217 | } |
| 218 | } |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 219 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 220 | return len; |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | static int mipi_dsi_cmd_bta_sw_trigger(void) |
| 224 | { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 225 | uint32_t data; |
| 226 | int cnt = 0; |
| 227 | int err = 0; |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 228 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 229 | writel(0x01, MIPI_DSI_BASE + 0x094); /* trigger */ |
| 230 | while (cnt < 10000) { |
| 231 | data = readl(MIPI_DSI_BASE + 0x0004); /*DSI_STATUS */ |
| 232 | if ((data & 0x0010) == 0) |
| 233 | break; |
| 234 | cnt++; |
| 235 | } |
| 236 | if (cnt == 10000) |
| 237 | err = 1; |
| 238 | return err; |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | static uint32_t mipi_novatek_manufacture_id(void) |
| 242 | { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 243 | char rec_buf[24]; |
| 244 | char *rp = rec_buf; |
| 245 | uint32_t *lp, data; |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 246 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 247 | mipi_dsi_cmds_tx(&novatek_panel_manufacture_id_cmd, 1); |
| 248 | mipi_dsi_cmds_rx(&rp, 3); |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 249 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 250 | lp = (uint32_t *) rp; |
| 251 | data = (uint32_t) * lp; |
| 252 | data = ntohl(data); |
| 253 | data = data >> 8; |
| 254 | return data; |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 255 | } |
| 256 | |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 257 | int mipi_dsi_panel_initialize(struct mipi_dsi_panel_config *pinfo) |
| 258 | { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 259 | unsigned char DMA_STREAM1 = 0; // for mdp display processor path |
| 260 | unsigned char EMBED_MODE1 = 1; // from frame buffer |
| 261 | unsigned char POWER_MODE2 = 1; // from frame buffer |
| 262 | unsigned char PACK_TYPE1 = 1; // long packet |
| 263 | unsigned char VC1 = 0; |
| 264 | unsigned char DT1 = 0; // non embedded mode |
| 265 | unsigned short WC1 = 0; // for non embedded mode only |
| 266 | int status = 0; |
| 267 | unsigned char DLNx_EN; |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 268 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 269 | switch (pinfo->num_of_lanes) { |
| 270 | default: |
| 271 | case 1: |
| 272 | DLNx_EN = 1; // 1 lane |
| 273 | break; |
| 274 | case 2: |
| 275 | DLNx_EN = 3; // 2 lane |
| 276 | break; |
| 277 | case 3: |
| 278 | DLNx_EN = 7; // 3 lane |
| 279 | break; |
| 280 | } |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 281 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 282 | writel(0x0001, DSI_SOFT_RESET); |
| 283 | writel(0x0000, DSI_SOFT_RESET); |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 284 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 285 | writel((0 << 16) | 0x3f, DSI_CLK_CTRL); /* Turn on all DSI Clks */ |
| 286 | writel(DMA_STREAM1 << 8 | 0x04, DSI_TRIG_CTRL); // reg 0x80 dma trigger: sw |
| 287 | // trigger 0x4; dma stream1 |
Kinson Chik | e5c9343 | 2011-06-17 09:10:29 -0700 | [diff] [blame] | 288 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 289 | writel(0 << 30 | DLNx_EN << 4 | 0x105, DSI_CTRL); // reg 0x00 for this |
| 290 | // build |
| 291 | writel(EMBED_MODE1 << 28 | POWER_MODE2 << 26 |
| 292 | | PACK_TYPE1 << 24 | VC1 << 22 | DT1 << 16 | WC1, |
| 293 | DSI_COMMAND_MODE_DMA_CTRL); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 294 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 295 | status = mipi_dsi_cmds_tx(pinfo->panel_cmds, pinfo->num_of_panel_cmds); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 296 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 297 | return status; |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 298 | } |
| 299 | |
Kinson Chik | e5c9343 | 2011-06-17 09:10:29 -0700 | [diff] [blame] | 300 | //TODO: Clean up arguments being passed in not being used |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 301 | int |
| 302 | config_dsi_video_mode(unsigned short disp_width, unsigned short disp_height, |
| 303 | unsigned short img_width, unsigned short img_height, |
| 304 | unsigned short hsync_porch0_fp, |
| 305 | unsigned short hsync_porch0_bp, |
| 306 | unsigned short vsync_porch0_fp, |
| 307 | unsigned short vsync_porch0_bp, |
| 308 | unsigned short hsync_width, |
| 309 | unsigned short vsync_width, unsigned short dst_format, |
| 310 | unsigned short traffic_mode, unsigned short datalane_num) |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 311 | { |
| 312 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 313 | unsigned char DST_FORMAT; |
| 314 | unsigned char TRAFIC_MODE; |
| 315 | unsigned char DLNx_EN; |
| 316 | // video mode data ctrl |
| 317 | int status = 0; |
| 318 | unsigned long low_pwr_stop_mode = 0; |
| 319 | unsigned char eof_bllp_pwr = 0x9; |
| 320 | unsigned char interleav = 0; |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 321 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 322 | // disable mdp first |
| 323 | mdp_disable(); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 324 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 325 | writel(0x00000000, DSI_CLK_CTRL); |
| 326 | writel(0x00000000, DSI_CLK_CTRL); |
| 327 | writel(0x00000000, DSI_CLK_CTRL); |
| 328 | writel(0x00000000, DSI_CLK_CTRL); |
| 329 | writel(0x00000002, DSI_CLK_CTRL); |
| 330 | writel(0x00000006, DSI_CLK_CTRL); |
| 331 | writel(0x0000000e, DSI_CLK_CTRL); |
| 332 | writel(0x0000001e, DSI_CLK_CTRL); |
| 333 | writel(0x0000003e, DSI_CLK_CTRL); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 334 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 335 | writel(0, DSI_CTRL); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 336 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 337 | writel(0, DSI_ERR_INT_MASK0); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 338 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 339 | DST_FORMAT = 0; // RGB565 |
| 340 | dprintf(SPEW, "DSI_Video_Mode - Dst Format: RGB565\n"); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 341 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 342 | DLNx_EN = 1; // 1 lane with clk programming |
| 343 | dprintf(SPEW, "Data Lane: 1 lane\n"); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 344 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 345 | TRAFIC_MODE = 0; // non burst mode with sync pulses |
| 346 | dprintf(SPEW, "Traffic mode: non burst mode with sync pulses\n"); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 347 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 348 | writel(0x02020202, DSI_INT_CTRL); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 349 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 350 | writel(((img_width + hsync_porch0_bp) << 16) | hsync_porch0_bp, |
| 351 | DSI_VIDEO_MODE_ACTIVE_H); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 352 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 353 | writel(((img_height + vsync_porch0_bp) << 16) | (vsync_porch0_bp), |
| 354 | DSI_VIDEO_MODE_ACTIVE_V); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 355 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 356 | writel(((img_height + vsync_porch0_fp + vsync_porch0_bp) << 16) |
| 357 | | img_width + hsync_porch0_fp + hsync_porch0_bp, |
| 358 | DSI_VIDEO_MODE_TOTAL); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 359 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 360 | writel((hsync_width << 16) | 0, DSI_VIDEO_MODE_HSYNC); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 361 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 362 | writel(0 << 16 | 0, DSI_VIDEO_MODE_VSYNC); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 363 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 364 | writel(vsync_width << 16 | 0, DSI_VIDEO_MODE_VSYNC_VPOS); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 365 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 366 | writel(1, DSI_EOT_PACKET_CTRL); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 367 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 368 | writel(0x00000100, DSI_MISR_VIDEO_CTRL); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 369 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 370 | writel(low_pwr_stop_mode << 16 | eof_bllp_pwr << 12 | TRAFIC_MODE << 8 |
| 371 | | DST_FORMAT << 4 | 0x0, DSI_VIDEO_MODE_CTRL); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 372 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 373 | writel(0x67, DSI_CAL_STRENGTH_CTRL); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 374 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 375 | writel(0x80006711, DSI_CAL_CTRL); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 376 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 377 | writel(0x00010100, DSI_MISR_VIDEO_CTRL); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 378 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 379 | writel(0x00010100, DSI_INT_CTRL); |
| 380 | writel(0x02010202, DSI_INT_CTRL); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 381 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 382 | writel(0x02030303, DSI_INT_CTRL); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 383 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 384 | writel(interleav << 30 | 0 << 24 | 0 << 20 | DLNx_EN << 4 |
| 385 | | 0x103, DSI_CTRL); |
| 386 | mdelay(10); |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 387 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 388 | return status; |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 389 | } |
| 390 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 391 | int |
| 392 | config_dsi_cmd_mode(unsigned short disp_width, unsigned short disp_height, |
| 393 | unsigned short img_width, unsigned short img_height, |
| 394 | unsigned short dst_format, |
| 395 | unsigned short traffic_mode, unsigned short datalane_num) |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 396 | { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 397 | unsigned char DST_FORMAT; |
| 398 | unsigned char TRAFIC_MODE; |
| 399 | unsigned char DLNx_EN; |
| 400 | // video mode data ctrl |
| 401 | int status = 0; |
Greg Grisco | d625055 | 2011-06-29 14:40:23 -0700 | [diff] [blame] | 402 | unsigned char interleav = 0; |
| 403 | unsigned char ystride = 0x03; |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 404 | // disable mdp first |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 405 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 406 | writel(0x00000000, DSI_CLK_CTRL); |
| 407 | writel(0x00000000, DSI_CLK_CTRL); |
| 408 | writel(0x00000000, DSI_CLK_CTRL); |
| 409 | writel(0x00000000, DSI_CLK_CTRL); |
| 410 | writel(0x00000002, DSI_CLK_CTRL); |
| 411 | writel(0x00000006, DSI_CLK_CTRL); |
| 412 | writel(0x0000000e, DSI_CLK_CTRL); |
| 413 | writel(0x0000001e, DSI_CLK_CTRL); |
| 414 | writel(0x0000003e, DSI_CLK_CTRL); |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 415 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 416 | writel(0x10000000, DSI_ERR_INT_MASK0); |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 417 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 418 | // writel(0, DSI_CTRL); |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 419 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 420 | // writel(0, DSI_ERR_INT_MASK0); |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 421 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 422 | DST_FORMAT = 8; // RGB888 |
| 423 | dprintf(SPEW, "DSI_Cmd_Mode - Dst Format: RGB888\n"); |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 424 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 425 | DLNx_EN = 3; // 2 lane with clk programming |
| 426 | dprintf(SPEW, "Data Lane: 2 lane\n"); |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 427 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 428 | TRAFIC_MODE = 0; // non burst mode with sync pulses |
| 429 | dprintf(SPEW, "Traffic mode: non burst mode with sync pulses\n"); |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 430 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 431 | writel(0x02020202, DSI_INT_CTRL); |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 432 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 433 | writel(0x00100000 | DST_FORMAT, DSI_COMMAND_MODE_MDP_CTRL); |
| 434 | writel((img_width * ystride + 1) << 16 | 0x0039, |
| 435 | DSI_COMMAND_MODE_MDP_STREAM0_CTRL); |
| 436 | writel((img_width * ystride + 1) << 16 | 0x0039, |
| 437 | DSI_COMMAND_MODE_MDP_STREAM1_CTRL); |
| 438 | writel(img_height << 16 | img_width, |
| 439 | DSI_COMMAND_MODE_MDP_STREAM0_TOTAL); |
| 440 | writel(img_height << 16 | img_width, |
| 441 | DSI_COMMAND_MODE_MDP_STREAM1_TOTAL); |
| 442 | writel(0xEE, DSI_CAL_STRENGTH_CTRL); |
| 443 | writel(0x80000000, DSI_CAL_CTRL); |
| 444 | writel(0x40, DSI_TRIG_CTRL); |
| 445 | writel(0x13c2c, DSI_COMMAND_MODE_MDP_DCS_CMD_CTRL); |
| 446 | writel(interleav << 30 | 0 << 24 | 0 << 20 | DLNx_EN << 4 | 0x105, |
| 447 | DSI_CTRL); |
| 448 | mdelay(10); |
| 449 | writel(0x10000000, DSI_COMMAND_MODE_DMA_CTRL); |
| 450 | writel(0x10000000, DSI_MISR_CMD_CTRL); |
| 451 | writel(0x00000040, DSI_ERR_INT_MASK0); |
| 452 | writel(0x1, DSI_EOT_PACKET_CTRL); |
| 453 | // writel(0x0, MDP_OVERLAYPROC0_START); |
| 454 | mdp_start_dma(); |
| 455 | mdelay(10); |
| 456 | writel(0x1, DSI_CMD_MODE_MDP_SW_TRIGGER); |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 457 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 458 | status = 1; |
| 459 | return status; |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 460 | } |
| 461 | |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 462 | int mipi_dsi_video_config(unsigned short num_of_lanes) |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 463 | { |
| 464 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 465 | int status = 0; |
| 466 | unsigned long ReadValue; |
| 467 | unsigned long count = 0; |
| 468 | unsigned long low_pwr_stop_mode = 0; // low power mode 0x1111 start from |
| 469 | // bit16, high spd mode 0x0 |
| 470 | unsigned char eof_bllp_pwr = 0x9; // bit 12, 15, 1:low power stop mode or |
| 471 | // let cmd mode eng send packets in hs |
| 472 | // or lp mode |
| 473 | unsigned short image_wd = mipi_fb_cfg.width; |
| 474 | unsigned short image_ht = mipi_fb_cfg.height; |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 475 | unsigned short display_wd = mipi_fb_cfg.width; |
| 476 | unsigned short display_ht = mipi_fb_cfg.height; |
| 477 | unsigned short hsync_porch_fp = MIPI_HSYNC_FRONT_PORCH_DCLK; |
| 478 | unsigned short hsync_porch_bp = MIPI_HSYNC_BACK_PORCH_DCLK; |
| 479 | unsigned short vsync_porch_fp = MIPI_VSYNC_FRONT_PORCH_LINES; |
| 480 | unsigned short vsync_porch_bp = MIPI_VSYNC_BACK_PORCH_LINES; |
| 481 | unsigned short hsync_width = MIPI_HSYNC_PULSE_WIDTH; |
| 482 | unsigned short vsync_width = MIPI_VSYNC_PULSE_WIDTH; |
| 483 | unsigned short dst_format = 0; |
| 484 | unsigned short traffic_mode = 0; |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 485 | unsigned short pack_pattern = 0x12; //BGR |
| 486 | unsigned char ystride = 3; |
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 | low_pwr_stop_mode = 0x1111; // low pwr mode bit16:HSA, bit20:HBA, |
| 489 | // bit24:HFP, bit28:PULSE MODE, need enough |
| 490 | // time for swithc from LP to HS |
| 491 | eof_bllp_pwr = 0x9; // low power stop mode or let cmd mode eng send |
| 492 | // packets in hs or lp mode |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 493 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 494 | status += |
| 495 | config_dsi_video_mode(display_wd, display_ht, image_wd, image_ht, |
| 496 | hsync_porch_fp, hsync_porch_bp, |
| 497 | vsync_porch_fp, vsync_porch_bp, hsync_width, |
| 498 | vsync_width, dst_format, traffic_mode, |
| 499 | num_of_lanes); |
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 | status += |
| 502 | mdp_setup_dma_p_video_mode(display_wd, display_ht, image_wd, |
| 503 | image_ht, hsync_porch_fp, hsync_porch_bp, |
| 504 | vsync_porch_fp, vsync_porch_bp, |
| 505 | hsync_width, vsync_width, MIPI_FB_ADDR, |
| 506 | image_wd, pack_pattern, ystride); |
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 | ReadValue = readl(DSI_INT_CTRL) & 0x00010000; |
| 509 | while (ReadValue != 0x00010000) { |
| 510 | ReadValue = readl(DSI_INT_CTRL) & 0x00010000; |
| 511 | count++; |
| 512 | if (count > 0xffff) { |
| 513 | status = FAIL; |
| 514 | dprintf(CRITICAL, "Video lane test failed\n"); |
| 515 | return status; |
| 516 | } |
| 517 | } |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 518 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 519 | dprintf(SPEW, "Video lane tested successfully\n"); |
| 520 | return status; |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 521 | } |
| 522 | |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 523 | int is_cmd_mode_enabled(void) |
| 524 | { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 525 | return cmd_mode_status; |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 526 | } |
| 527 | |
Kinson Chik | e5c9343 | 2011-06-17 09:10:29 -0700 | [diff] [blame] | 528 | #if DISPLAY_MIPI_PANEL_NOVATEK_BLUE |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 529 | void mipi_dsi_cmd_mode_trigger(void) |
| 530 | { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 531 | int status = 0; |
| 532 | unsigned short display_wd = mipi_fb_cfg.width; |
| 533 | unsigned short display_ht = mipi_fb_cfg.height; |
| 534 | unsigned short image_wd = mipi_fb_cfg.width; |
| 535 | unsigned short image_ht = mipi_fb_cfg.height; |
| 536 | unsigned short dst_format = 0; |
| 537 | unsigned short traffic_mode = 0; |
| 538 | struct mipi_dsi_panel_config *panel_info = &novatek_panel_info; |
| 539 | status += mipi_dsi_cmd_config(mipi_fb_cfg, panel_info->num_of_lanes); |
| 540 | mdelay(50); |
| 541 | config_dsi_cmd_mode(display_wd, display_ht, image_wd, image_ht, |
| 542 | dst_format, traffic_mode, |
| 543 | panel_info->num_of_lanes /* num_of_lanes */ ); |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 544 | } |
Kinson Chik | e5c9343 | 2011-06-17 09:10:29 -0700 | [diff] [blame] | 545 | #endif |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 546 | |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 547 | void mipi_dsi_shutdown(void) |
| 548 | { |
Chandan Uddaraju | 4877d37 | 2011-07-21 12:51:51 -0700 | [diff] [blame] | 549 | #if (!CONT_SPLASH_SCREEN) |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 550 | mdp_shutdown(); |
| 551 | writel(0x01010101, DSI_INT_CTRL); |
| 552 | writel(0x13FF3BFF, DSI_ERR_INT_MASK0); |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 553 | |
| 554 | #if (DISPLAY_MIPI_PANEL_NOVATEK_BLUE \ |
| 555 | || DISPLAY_MIPI_PANEL_TOSHIBA) |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 556 | secure_writel(0x0, DSI_CC_REG); |
Shashank Mittal | 3026290 | 2012-02-21 15:37:24 -0800 | [diff] [blame] | 557 | secure_writel(0x0, DSI_PIXEL_CC_REG); |
Kinson Chik | e5c9343 | 2011-06-17 09:10:29 -0700 | [diff] [blame] | 558 | #endif |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 559 | writel(0, DSI_CLK_CTRL); |
| 560 | writel(0, DSI_CTRL); |
| 561 | writel(0, DSIPHY_PLL_CTRL(0)); |
Chandan Uddaraju | 4877d37 | 2011-07-21 12:51:51 -0700 | [diff] [blame] | 562 | #else |
| 563 | /* To keep the splash screen displayed till kernel driver takes |
| 564 | control, do not turn off the video mode engine and clocks. |
| 565 | Only disabling the MIPI DSI IRQs */ |
| 566 | writel(0x01010101, DSI_INT_CTRL); |
| 567 | writel(0x13FF3BFF, DSI_ERR_INT_MASK0); |
| 568 | #endif |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 569 | } |
| 570 | |
| 571 | struct fbcon_config *mipi_init(void) |
| 572 | { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 573 | int status = 0; |
| 574 | struct mipi_dsi_panel_config *panel_info = get_panel_info(); |
Channagoud Kadabi | 539ef72 | 2012-03-29 16:02:50 +0530 | [diff] [blame] | 575 | |
| 576 | if (panel_info == NULL) { |
| 577 | dprintf(CRITICAL, "Panel info is null\n"); |
| 578 | return NULL; |
| 579 | } |
| 580 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 581 | /* Enable MMSS_AHB_ARB_MATER_PORT_E for arbiter master0 and master 1 request */ |
Aparna Mallavarapu | f712f5e | 2011-08-04 21:11:00 +0530 | [diff] [blame] | 582 | #if (!DISPLAY_MIPI_PANEL_RENESAS) |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 583 | writel(0x00001800, MMSS_SFPB_GPREG); |
Aparna Mallavarapu | f712f5e | 2011-08-04 21:11:00 +0530 | [diff] [blame] | 584 | #endif |
Kinson Chik | e5c9343 | 2011-06-17 09:10:29 -0700 | [diff] [blame] | 585 | |
| 586 | #if DISPLAY_MIPI_PANEL_TOSHIBA_MDT61 |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 587 | mipi_dsi_phy_init(panel_info); |
Kinson Chik | e5c9343 | 2011-06-17 09:10:29 -0700 | [diff] [blame] | 588 | #else |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 589 | mipi_dsi_phy_ctrl_config(panel_info); |
Kinson Chik | e5c9343 | 2011-06-17 09:10:29 -0700 | [diff] [blame] | 590 | #endif |
| 591 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 592 | status += mipi_dsi_panel_initialize(panel_info); |
Kinson Chik | e5c9343 | 2011-06-17 09:10:29 -0700 | [diff] [blame] | 593 | |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 594 | #if DISPLAY_MIPI_PANEL_NOVATEK_BLUE |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 595 | mipi_dsi_cmd_bta_sw_trigger(); |
| 596 | mipi_novatek_manufacture_id(); |
Shashank Mittal | cbd271d | 2011-01-14 15:18:33 -0800 | [diff] [blame] | 597 | #endif |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 598 | mipi_fb_cfg.base = MIPI_FB_ADDR; |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 599 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 600 | if (panel_info->mode == MIPI_VIDEO_MODE) |
| 601 | status += mipi_dsi_video_config(panel_info->num_of_lanes); |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 602 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 603 | if (panel_info->mode == MIPI_CMD_MODE) |
| 604 | cmd_mode_status = 1; |
Chandan Uddaraju | fe93e82 | 2010-11-21 20:44:47 -0800 | [diff] [blame] | 605 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 606 | return &mipi_fb_cfg; |
Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame] | 607 | } |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 608 | |
| 609 | int mipi_config(struct msm_fb_panel_data *panel) |
| 610 | { |
| 611 | int ret = NO_ERROR; |
| 612 | struct msm_panel_info *pinfo; |
| 613 | struct mipi_dsi_panel_config mipi_pinfo; |
| 614 | |
| 615 | if (!panel) |
| 616 | return ERR_INVALID_ARGS; |
| 617 | |
| 618 | pinfo = &(panel->panel_info); |
| 619 | mipi_pinfo.mode = pinfo->mipi.mode; |
| 620 | mipi_pinfo.num_of_lanes = pinfo->mipi.num_of_lanes; |
| 621 | mipi_pinfo.dsi_phy_config = pinfo->mipi.dsi_phy_db; |
| 622 | mipi_pinfo.panel_cmds = pinfo->mipi.panel_cmds; |
| 623 | mipi_pinfo.num_of_panel_cmds = pinfo->mipi.num_of_panel_cmds; |
Channagoud Kadabi | 539ef72 | 2012-03-29 16:02:50 +0530 | [diff] [blame] | 624 | mipi_pinfo.lane_swap = pinfo->mipi.lane_swap; |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 625 | |
| 626 | /* Enable MMSS_AHB_ARB_MATER_PORT_E for |
| 627 | arbiter master0 and master 1 request */ |
| 628 | #if (!DISPLAY_MIPI_PANEL_RENESAS) |
| 629 | writel(0x00001800, MMSS_SFPB_GPREG); |
| 630 | #endif |
| 631 | |
| 632 | mipi_dsi_phy_init(&mipi_pinfo); |
| 633 | |
| 634 | ret += mipi_dsi_panel_initialize(&mipi_pinfo); |
| 635 | |
Channagoud Kadabi | 01c9182 | 2012-06-06 15:53:30 +0530 | [diff] [blame^] | 636 | if (pinfo->rotate && panel->rotate) |
| 637 | pinfo->rotate(); |
| 638 | |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 639 | return ret; |
| 640 | } |
| 641 | |
| 642 | int mipi_dsi_video_mode_config(unsigned short disp_width, |
| 643 | unsigned short disp_height, |
| 644 | unsigned short img_width, |
| 645 | unsigned short img_height, |
| 646 | unsigned short hsync_porch0_fp, |
| 647 | unsigned short hsync_porch0_bp, |
| 648 | unsigned short vsync_porch0_fp, |
| 649 | unsigned short vsync_porch0_bp, |
| 650 | unsigned short hsync_width, |
| 651 | unsigned short vsync_width, |
| 652 | unsigned short dst_format, |
| 653 | unsigned short traffic_mode, |
| 654 | unsigned char lane_en, |
| 655 | unsigned low_pwr_stop_mode, |
| 656 | unsigned char eof_bllp_pwr, |
| 657 | unsigned char interleav) |
| 658 | { |
| 659 | |
| 660 | int status = 0; |
| 661 | |
| 662 | /* disable mdp first */ |
| 663 | mdp_disable(); |
| 664 | |
| 665 | writel(0x00000000, DSI_CLK_CTRL); |
| 666 | writel(0x00000000, DSI_CLK_CTRL); |
| 667 | writel(0x00000000, DSI_CLK_CTRL); |
| 668 | writel(0x00000000, DSI_CLK_CTRL); |
| 669 | writel(0x00000002, DSI_CLK_CTRL); |
| 670 | writel(0x00000006, DSI_CLK_CTRL); |
| 671 | writel(0x0000000e, DSI_CLK_CTRL); |
| 672 | writel(0x0000001e, DSI_CLK_CTRL); |
| 673 | writel(0x0000003e, DSI_CLK_CTRL); |
| 674 | |
| 675 | writel(0, DSI_CTRL); |
| 676 | |
| 677 | writel(0, DSI_ERR_INT_MASK0); |
| 678 | |
| 679 | writel(0x02020202, DSI_INT_CTRL); |
| 680 | |
| 681 | writel(((disp_width + hsync_porch0_bp) << 16) | hsync_porch0_bp, |
| 682 | DSI_VIDEO_MODE_ACTIVE_H); |
| 683 | |
| 684 | writel(((disp_height + vsync_porch0_bp) << 16) | (vsync_porch0_bp), |
| 685 | DSI_VIDEO_MODE_ACTIVE_V); |
| 686 | |
| 687 | if (mdp_get_revision() >= MDP_REV_41) { |
| 688 | writel(((disp_height + vsync_porch0_fp |
| 689 | + vsync_porch0_bp - 1) << 16) |
| 690 | | (disp_width + hsync_porch0_fp |
| 691 | + hsync_porch0_bp - 1), |
| 692 | DSI_VIDEO_MODE_TOTAL); |
| 693 | } else { |
| 694 | writel(((disp_height + vsync_porch0_fp |
| 695 | + vsync_porch0_bp) << 16) |
| 696 | | (disp_width + hsync_porch0_fp |
| 697 | + hsync_porch0_bp), |
| 698 | DSI_VIDEO_MODE_TOTAL); |
| 699 | } |
| 700 | |
| 701 | writel((hsync_width << 16) | 0, DSI_VIDEO_MODE_HSYNC); |
| 702 | |
| 703 | writel(0 << 16 | 0, DSI_VIDEO_MODE_VSYNC); |
| 704 | |
| 705 | writel(vsync_width << 16 | 0, DSI_VIDEO_MODE_VSYNC_VPOS); |
| 706 | |
| 707 | writel(1, DSI_EOT_PACKET_CTRL); |
| 708 | |
| 709 | writel(0x00000100, DSI_MISR_VIDEO_CTRL); |
| 710 | |
Channagoud Kadabi | 539ef72 | 2012-03-29 16:02:50 +0530 | [diff] [blame] | 711 | if (mdp_get_revision() >= MDP_REV_41) { |
| 712 | writel(low_pwr_stop_mode << 16 | |
| 713 | eof_bllp_pwr << 12 | traffic_mode << 8 |
| 714 | | dst_format << 4 | 0x0, DSI_VIDEO_MODE_CTRL); |
| 715 | } else { |
| 716 | writel(1 << 28 | 1 << 24 | 1 << 20 | low_pwr_stop_mode << 16 | |
| 717 | eof_bllp_pwr << 12 | traffic_mode << 8 |
| 718 | | dst_format << 4 | 0x0, DSI_VIDEO_MODE_CTRL); |
| 719 | } |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 720 | |
| 721 | writel(0x67, DSI_CAL_STRENGTH_CTRL); |
| 722 | writel(0x80006711, DSI_CAL_CTRL); |
| 723 | writel(0x00010100, DSI_MISR_VIDEO_CTRL); |
| 724 | |
| 725 | writel(0x00010100, DSI_INT_CTRL); |
| 726 | writel(0x02010202, DSI_INT_CTRL); |
| 727 | writel(0x02030303, DSI_INT_CTRL); |
| 728 | |
| 729 | writel(interleav << 30 | 0 << 24 | 0 << 20 | lane_en << 4 |
| 730 | | 0x103, DSI_CTRL); |
| 731 | |
| 732 | return status; |
| 733 | } |
| 734 | |
Channagoud Kadabi | 10189fd | 2012-05-25 13:33:39 +0530 | [diff] [blame] | 735 | int mipi_dsi_cmd_mode_config(unsigned short disp_width, |
| 736 | unsigned short disp_height, |
| 737 | unsigned short img_width, |
| 738 | unsigned short img_height, |
| 739 | unsigned short dst_format, |
| 740 | unsigned short traffic_mode) |
| 741 | { |
| 742 | unsigned char DST_FORMAT; |
| 743 | unsigned char TRAFIC_MODE; |
| 744 | unsigned char DLNx_EN; |
| 745 | // video mode data ctrl |
| 746 | int status = 0; |
| 747 | unsigned char interleav = 0; |
| 748 | unsigned char ystride = 0x03; |
| 749 | // disable mdp first |
| 750 | |
| 751 | writel(0x00000000, DSI_CLK_CTRL); |
| 752 | writel(0x00000000, DSI_CLK_CTRL); |
| 753 | writel(0x00000000, DSI_CLK_CTRL); |
| 754 | writel(0x00000000, DSI_CLK_CTRL); |
| 755 | writel(0x00000002, DSI_CLK_CTRL); |
| 756 | writel(0x00000006, DSI_CLK_CTRL); |
| 757 | writel(0x0000000e, DSI_CLK_CTRL); |
| 758 | writel(0x0000001e, DSI_CLK_CTRL); |
| 759 | writel(0x0000003e, DSI_CLK_CTRL); |
| 760 | |
| 761 | writel(0x10000000, DSI_ERR_INT_MASK0); |
| 762 | |
| 763 | |
| 764 | DST_FORMAT = 8; // RGB888 |
| 765 | dprintf(SPEW, "DSI_Cmd_Mode - Dst Format: RGB888\n"); |
| 766 | |
| 767 | DLNx_EN = 3; // 2 lane with clk programming |
| 768 | dprintf(SPEW, "Data Lane: 2 lane\n"); |
| 769 | |
| 770 | TRAFIC_MODE = 0; // non burst mode with sync pulses |
| 771 | dprintf(SPEW, "Traffic mode: non burst mode with sync pulses\n"); |
| 772 | |
| 773 | writel(0x02020202, DSI_INT_CTRL); |
| 774 | |
| 775 | writel(0x00100000 | DST_FORMAT, DSI_COMMAND_MODE_MDP_CTRL); |
| 776 | writel((img_width * ystride + 1) << 16 | 0x0039, |
| 777 | DSI_COMMAND_MODE_MDP_STREAM0_CTRL); |
| 778 | writel((img_width * ystride + 1) << 16 | 0x0039, |
| 779 | DSI_COMMAND_MODE_MDP_STREAM1_CTRL); |
| 780 | writel(img_height << 16 | img_width, |
| 781 | DSI_COMMAND_MODE_MDP_STREAM0_TOTAL); |
| 782 | writel(img_height << 16 | img_width, |
| 783 | DSI_COMMAND_MODE_MDP_STREAM1_TOTAL); |
| 784 | writel(0xEE, DSI_CAL_STRENGTH_CTRL); |
| 785 | writel(0x80000000, DSI_CAL_CTRL); |
| 786 | writel(0x40, DSI_TRIG_CTRL); |
| 787 | writel(0x13c2c, DSI_COMMAND_MODE_MDP_DCS_CMD_CTRL); |
| 788 | writel(interleav << 30 | 0 << 24 | 0 << 20 | DLNx_EN << 4 | 0x105, |
| 789 | DSI_CTRL); |
| 790 | writel(0x10000000, DSI_COMMAND_MODE_DMA_CTRL); |
| 791 | writel(0x10000000, DSI_MISR_CMD_CTRL); |
| 792 | writel(0x00000040, DSI_ERR_INT_MASK0); |
| 793 | writel(0x1, DSI_EOT_PACKET_CTRL); |
| 794 | |
| 795 | return NO_ERROR; |
| 796 | } |
| 797 | |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 798 | int mipi_dsi_on() |
| 799 | { |
| 800 | int ret = NO_ERROR; |
| 801 | unsigned long ReadValue; |
| 802 | unsigned long count = 0; |
| 803 | |
| 804 | ReadValue = readl(DSI_INT_CTRL) & 0x00010000; |
| 805 | |
| 806 | mdelay(10); |
| 807 | |
| 808 | while (ReadValue != 0x00010000) { |
| 809 | ReadValue = readl(DSI_INT_CTRL) & 0x00010000; |
| 810 | count++; |
| 811 | if (count > 0xffff) { |
| 812 | dprintf(CRITICAL, "Video lane test failed\n"); |
| 813 | return ERROR; |
| 814 | } |
| 815 | } |
| 816 | |
| 817 | dprintf(SPEW, "Video lane tested successfully\n"); |
| 818 | return ret; |
| 819 | } |
| 820 | |
| 821 | int mipi_dsi_off() |
| 822 | { |
| 823 | writel(0x01010101, DSI_INT_CTRL); |
| 824 | writel(0x13FF3BFF, DSI_ERR_INT_MASK0); |
| 825 | |
| 826 | #if (!CONT_SPLASH_SCREEN) |
| 827 | writel(0, DSI_CLK_CTRL); |
| 828 | writel(0, DSI_CTRL); |
| 829 | writel(0, DSIPHY_PLL_CTRL(0)); |
| 830 | #endif |
| 831 | |
| 832 | return NO_ERROR; |
| 833 | } |
Channagoud Kadabi | 10189fd | 2012-05-25 13:33:39 +0530 | [diff] [blame] | 834 | |
| 835 | int mipi_cmd_trigger() |
| 836 | { |
| 837 | writel(0x1, DSI_CMD_MODE_MDP_SW_TRIGGER); |
| 838 | |
| 839 | return NO_ERROR; |
| 840 | } |