Chandan Uddaraju | 78ae675 | 2010-10-19 12:57:10 -0700 | [diff] [blame^] | 1 | /* Copyright (c) 2010, Code Aurora Forum. All rights reserved. |
| 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> |
| 31 | #include <mipi_dsi.h> |
| 32 | #include <dev/fbcon.h> |
| 33 | #include <target/display.h> |
| 34 | |
| 35 | #define MIPI_FB_ADDR 0x43E00000 |
| 36 | |
| 37 | static struct fbcon_config mipi_fb_cfg = { |
| 38 | .height = TSH_MIPI_FB_HEIGHT, |
| 39 | .width = TSH_MIPI_FB_WIDTH, |
| 40 | .stride = TSH_MIPI_FB_WIDTH, |
| 41 | .format = FB_FORMAT_RGB888, |
| 42 | .bpp = 24, |
| 43 | .update_start = NULL, |
| 44 | .update_done = NULL, |
| 45 | }; |
| 46 | |
| 47 | void configure_dsicore_dsiclk() |
| 48 | { |
| 49 | unsigned char mnd_mode, root_en, clk_en; |
| 50 | unsigned long src_sel = 0x3; //dsi_phy_pll0_src |
| 51 | unsigned long pre_div_func = 0x00; // predivide by 1 |
| 52 | unsigned long pmxo_sel; |
| 53 | |
| 54 | writel(pre_div_func << 14 | src_sel, MMSS_DSI_NS); |
| 55 | mnd_mode = 0; //Bypass MND |
| 56 | root_en = 1; |
| 57 | clk_en = 1; |
| 58 | pmxo_sel = 0; |
| 59 | |
| 60 | writel((pmxo_sel << 8) | (mnd_mode << 6), MMSS_DSI_CC); |
| 61 | writel(readl(MMSS_DSI_CC) | root_en << 2, MMSS_DSI_CC); |
| 62 | writel(readl(MMSS_DSI_CC) | clk_en, MMSS_DSI_CC); |
| 63 | } |
| 64 | |
| 65 | void configure_dsicore_byteclk(void) |
| 66 | { |
| 67 | writel(0x00400401, MMSS_MISC_CC2); // select pxo |
| 68 | } |
| 69 | |
| 70 | void configure_dsicore_pclk(void) |
| 71 | { |
| 72 | |
| 73 | unsigned char mnd_mode, root_en, clk_en; |
| 74 | unsigned long src_sel = 0x3; // dsi_phy_pll0_src |
| 75 | unsigned long pre_div_func = 0x01; // predivide by 2 |
| 76 | |
| 77 | writel(pre_div_func << 12 | src_sel, MMSS_DSI_PIXEL_NS); |
| 78 | |
| 79 | mnd_mode = 0; // Bypass MND |
| 80 | root_en = 1; |
| 81 | clk_en = 1; |
| 82 | writel(mnd_mode << 6, MMSS_DSI_PIXEL_CC); |
| 83 | writel(readl(MMSS_DSI_PIXEL_CC) | root_en << 2, MMSS_DSI_PIXEL_CC); |
| 84 | writel(readl(MMSS_DSI_PIXEL_CC) | clk_en, MMSS_DSI_PIXEL_CC); |
| 85 | |
| 86 | } |
| 87 | |
| 88 | int dsi_dsiphy_reg_bitclk_200MHz_toshiba_rgb888(unsigned char lane_num_hs) |
| 89 | { |
| 90 | |
| 91 | unsigned char lane_1 = 1; |
| 92 | unsigned char lane_2 = 2; |
| 93 | |
| 94 | writel(0x00000001, DSI_PHY_SW_RESET); |
| 95 | mdelay(100); |
| 96 | writel(0x00000000, DSI_PHY_SW_RESET); |
| 97 | |
| 98 | writel(0x00000003, DSIPHY_REGULATOR_CTRL_0); |
| 99 | writel(0x00000001, DSIPHY_REGULATOR_CTRL_1); |
| 100 | writel(0x00000001, DSIPHY_REGULATOR_CTRL_2); |
| 101 | writel(0x00000000, DSIPHY_REGULATOR_CTRL_3); |
| 102 | |
| 103 | writel(0x50, DSIPHY_TIMING_CTRL_0); |
| 104 | writel(0x0f, DSIPHY_TIMING_CTRL_1); |
| 105 | writel(0x14, DSIPHY_TIMING_CTRL_2); |
| 106 | writel(0x19, DSIPHY_TIMING_CTRL_4); |
| 107 | writel(0x23, DSIPHY_TIMING_CTRL_5); |
| 108 | writel(0x0e, DSIPHY_TIMING_CTRL_6); |
| 109 | writel(0x12, DSIPHY_TIMING_CTRL_7); |
| 110 | writel(0x16, DSIPHY_TIMING_CTRL_8); |
| 111 | writel(0x1b, DSIPHY_TIMING_CTRL_9); |
| 112 | writel(0x1c, DSIPHY_TIMING_CTRL_10); |
| 113 | |
| 114 | // T_CLK_POST, T_CLK_PRE for CLK lane P/N HS 200 mV timing length should > |
| 115 | // data lane HS timing length |
| 116 | writel(0x90f, DSI_CLKOUT_TIMING_CTRL); |
| 117 | |
| 118 | writel(0x7f, DSIPHY_CTRL_0); |
| 119 | writel(0x00, DSIPHY_CTRL_1); |
| 120 | writel(0x00, DSIPHY_CTRL_2); |
| 121 | writel(0x00, DSIPHY_CTRL_3); |
| 122 | |
| 123 | writel(0xEE, DSIPHY_STRENGTH_CTRL_0); |
| 124 | writel(0x86, DSIPHY_STRENGTH_CTRL_0); |
| 125 | |
| 126 | writel(0x8f, DSIPHY_PLL_CTRL_1); // vco=400*2=800Mhz |
| 127 | |
| 128 | writel(0xb1, DSIPHY_PLL_CTRL_2); |
| 129 | writel(0xda, DSIPHY_PLL_CTRL_3); |
| 130 | writel(0x00, DSIPHY_PLL_CTRL_4); |
| 131 | writel(0x50, DSIPHY_PLL_CTRL_5); |
| 132 | writel(0x48, DSIPHY_PLL_CTRL_6); |
| 133 | writel(0x63, DSIPHY_PLL_CTRL_7); |
| 134 | |
| 135 | writel(0x33, DSIPHY_PLL_CTRL_8); // bit clk 800/4=200mhz |
| 136 | writel(0x1f, DSIPHY_PLL_CTRL_9); // byte clk 800/32=25mhz (200/8=25) |
| 137 | |
| 138 | if (lane_num_hs == lane_1) { |
| 139 | printf("\nData Lane: 1 lane"); |
| 140 | writel(0x1f, DSIPHY_PLL_CTRL_10); // 1 lane dsi clk 800/32=25mhz |
| 141 | } else if (lane_num_hs == lane_2) { |
| 142 | printf("\nData Lane: 2 lane"); |
| 143 | writel(0x0f, DSIPHY_PLL_CTRL_10); // 2 lane dsi clk 800/16=50mhz |
| 144 | } |
| 145 | |
| 146 | writel(0x05, DSIPHY_PLL_CTRL_11); |
| 147 | writel(0x14, DSIPHY_PLL_CTRL_12); |
| 148 | writel(0x03, DSIPHY_PLL_CTRL_13); |
| 149 | writel(0x54, DSIPHY_PLL_CTRL_16); |
| 150 | writel(0x06, DSIPHY_PLL_CTRL_17); |
| 151 | writel(0x10, DSIPHY_PLL_CTRL_18); |
| 152 | writel(0x04, DSIPHY_PLL_CTRL_19); |
| 153 | writel(0x00000040, DSIPHY_PLL_CTRL_0); |
| 154 | writel(0x00000041, DSIPHY_PLL_CTRL_0); // dsipll en |
| 155 | |
| 156 | return (0); |
| 157 | } |
| 158 | |
| 159 | int dsi_cmd_dma_trigger_for_panel() |
| 160 | { |
| 161 | unsigned long ReadValue; |
| 162 | unsigned long count = 0; |
| 163 | int status = 0; |
| 164 | |
| 165 | writel(0x03030303, DSI_INT_CTRL); |
| 166 | mdelay(1); |
| 167 | writel(0x1, DSI_CMD_MODE_DMA_SW_TRIGGER); |
| 168 | ReadValue = readl(DSI_INT_CTRL) & 0x00000001; |
| 169 | while (ReadValue != 0x00000001) { |
| 170 | ReadValue = readl(DSI_INT_CTRL) & 0x00000001; |
| 171 | count++; |
| 172 | if (count > 0xffff) { |
| 173 | status = FAIL; |
| 174 | printf("\n\nThis command mode dma test is failed"); |
| 175 | return status; |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | writel((readl(DSI_INT_CTRL) | 0x01000001), DSI_INT_CTRL); |
| 180 | printf |
| 181 | ("\n\nThis command mode is tested successfully, continue on next command mode test"); |
| 182 | return status; |
| 183 | } |
| 184 | |
| 185 | int dsi_toshiba_panel_config_video_mode_wvga(unsigned char lane_num) |
| 186 | { |
| 187 | |
| 188 | unsigned char DMA_STREAM1 = 0; // for mdp display processor path |
| 189 | unsigned char EMBED_MODE1 = 1; // from frame buffer |
| 190 | unsigned char POWER_MODE2 = 1; // from frame buffer |
| 191 | unsigned char PACK_TYPE1 = 1; // long packet |
| 192 | unsigned char VC1 = 0; |
| 193 | unsigned char DT1 = 0; // non embedded mode |
| 194 | unsigned short WC1 = 0; // for non embedded mode only |
| 195 | int status = 0; |
| 196 | unsigned char DLNx_EN = 1; |
| 197 | unsigned char lane_1 = 1; |
| 198 | unsigned char lane_2 = 2; |
| 199 | |
| 200 | writel((0 << 16) | 0x3f, DSI_CLK_CTRL); // reg:0x118 |
| 201 | writel(DMA_STREAM1 << 8 | 0x04, DSI_TRIG_CTRL); // reg 0x80 dma trigger: sw |
| 202 | // trigger 0x4; dma stream1 |
| 203 | writel(0 << 30 | DLNx_EN << 4 | 0x105, DSI_CTRL); // reg 0x00 for this |
| 204 | // build |
| 205 | writel(EMBED_MODE1 << 28 | POWER_MODE2 << 26 |
| 206 | | PACK_TYPE1 << 24 | VC1 << 22 | DT1 << 16 | WC1, |
| 207 | DSI_COMMAND_MODE_DMA_CTRL); |
| 208 | writel(0x15000000, DSI_COMMAND_MODE_DMA_CTRL); // reg 0x38 wc=4; DT=09; |
| 209 | // embedded mode=0 from the |
| 210 | // reg. |
| 211 | |
| 212 | memcpy(DSI_CMD_DMA_MEM_START_ADDR_PANEL, |
| 213 | &dsi_toshiba_display_config_MCAP_off, 8); |
| 214 | writel(DSI_CMD_DMA_MEM_START_ADDR_PANEL, DSI_DMA_CMD_OFFSET); |
| 215 | writel(8, DSI_DMA_CMD_LENGTH); // reg 0x48 for this build |
| 216 | status += dsi_cmd_dma_trigger_for_panel(); |
| 217 | |
| 218 | memcpy(DSI_CMD_DMA_MEM_START_ADDR_PANEL, |
| 219 | &dsi_toshiba_display_config_ena_test_reg, 8); |
| 220 | writel(DSI_CMD_DMA_MEM_START_ADDR_PANEL, DSI_DMA_CMD_OFFSET); |
| 221 | writel(8, DSI_DMA_CMD_LENGTH); // reg 0x48 for this build |
| 222 | status += dsi_cmd_dma_trigger_for_panel(); |
| 223 | |
| 224 | if (lane_num == lane_1) { |
| 225 | memcpy(DSI_CMD_DMA_MEM_START_ADDR_PANEL, |
| 226 | &dsi_toshiba_display_config_num_of_1lane, 8); |
| 227 | } else if (lane_num == lane_2) { |
| 228 | |
| 229 | memcpy(DSI_CMD_DMA_MEM_START_ADDR_PANEL, |
| 230 | &dsi_toshiba_display_config_num_of_2lane, 8); |
| 231 | } |
| 232 | |
| 233 | writel(DSI_CMD_DMA_MEM_START_ADDR_PANEL, DSI_DMA_CMD_OFFSET); |
| 234 | writel(8, DSI_DMA_CMD_LENGTH); // reg 0x48 for this build |
| 235 | status += dsi_cmd_dma_trigger_for_panel(); |
| 236 | |
| 237 | memcpy(DSI_CMD_DMA_MEM_START_ADDR_PANEL, |
| 238 | &dsi_toshiba_display_config_non_burst_sync_pulse, 8); |
| 239 | writel(DSI_CMD_DMA_MEM_START_ADDR_PANEL, DSI_DMA_CMD_OFFSET); |
| 240 | writel(8, DSI_DMA_CMD_LENGTH); // reg 0x48 for this build |
| 241 | status += dsi_cmd_dma_trigger_for_panel(); |
| 242 | |
| 243 | memcpy(DSI_CMD_DMA_MEM_START_ADDR_PANEL, |
| 244 | &dsi_toshiba_display_config_set_DMODE_WVGA, 8); |
| 245 | writel(DSI_CMD_DMA_MEM_START_ADDR_PANEL, DSI_DMA_CMD_OFFSET); |
| 246 | writel(8, DSI_DMA_CMD_LENGTH); // reg 0x48 for this build |
| 247 | status += dsi_cmd_dma_trigger_for_panel(); |
| 248 | |
| 249 | memcpy(DSI_CMD_DMA_MEM_START_ADDR_PANEL, |
| 250 | &dsi_toshiba_display_config_set_intern_WR_clk1_wvga, 8); |
| 251 | writel(DSI_CMD_DMA_MEM_START_ADDR_PANEL, DSI_DMA_CMD_OFFSET); |
| 252 | writel(8, DSI_DMA_CMD_LENGTH); // reg 0x48 for this build |
| 253 | status += dsi_cmd_dma_trigger_for_panel(); |
| 254 | |
| 255 | memcpy(DSI_CMD_DMA_MEM_START_ADDR_PANEL, |
| 256 | &dsi_toshiba_display_config_set_intern_WR_clk2_wvga, 8); |
| 257 | writel(DSI_CMD_DMA_MEM_START_ADDR_PANEL, DSI_DMA_CMD_OFFSET); |
| 258 | writel(8, DSI_DMA_CMD_LENGTH); // reg 0x48 for this build |
| 259 | status += dsi_cmd_dma_trigger_for_panel(); |
| 260 | |
| 261 | memcpy(DSI_CMD_DMA_MEM_START_ADDR_PANEL, |
| 262 | &dsi_toshiba_display_config_set_hor_addr_2A_wvga, 12); |
| 263 | writel(DSI_CMD_DMA_MEM_START_ADDR_PANEL, DSI_DMA_CMD_OFFSET); |
| 264 | writel(12, DSI_DMA_CMD_LENGTH); // reg 0x48 for this build |
| 265 | status += dsi_cmd_dma_trigger_for_panel(); |
| 266 | |
| 267 | memcpy(DSI_CMD_DMA_MEM_START_ADDR_PANEL, |
| 268 | &dsi_toshiba_display_config_set_hor_addr_2B_wvga, 12); |
| 269 | writel(DSI_CMD_DMA_MEM_START_ADDR_PANEL, DSI_DMA_CMD_OFFSET); |
| 270 | writel(12, DSI_DMA_CMD_LENGTH); // reg 0x48 for this build |
| 271 | status += dsi_cmd_dma_trigger_for_panel(); |
| 272 | |
| 273 | memcpy(DSI_CMD_DMA_MEM_START_ADDR_PANEL, &dsi_toshiba_display_config_IFSEL, |
| 274 | 8); |
| 275 | writel(DSI_CMD_DMA_MEM_START_ADDR_PANEL, DSI_DMA_CMD_OFFSET); |
| 276 | writel(8, DSI_DMA_CMD_LENGTH); // reg 0x48 for this build |
| 277 | status += dsi_cmd_dma_trigger_for_panel(); |
| 278 | |
| 279 | memcpy(DSI_CMD_DMA_MEM_START_ADDR_PANEL, |
| 280 | &dsi_toshiba_display_config_exit_sleep, 4); |
| 281 | writel(DSI_CMD_DMA_MEM_START_ADDR_PANEL, DSI_DMA_CMD_OFFSET); |
| 282 | writel(4, DSI_DMA_CMD_LENGTH); // reg 0x48 for this build |
| 283 | writel(0x14000000, DSI_COMMAND_MODE_DMA_CTRL); |
| 284 | status += dsi_cmd_dma_trigger_for_panel(); |
| 285 | |
| 286 | memcpy(DSI_CMD_DMA_MEM_START_ADDR_PANEL, |
| 287 | &dsi_toshiba_display_config_display_on, 4); |
| 288 | writel(DSI_CMD_DMA_MEM_START_ADDR_PANEL, DSI_DMA_CMD_OFFSET); |
| 289 | writel(4, DSI_DMA_CMD_LENGTH); // reg 0x48 for this build |
| 290 | status += dsi_cmd_dma_trigger_for_panel(); |
| 291 | |
| 292 | // dsi_display_config_color_mode_on - low power |
| 293 | memcpy(DSI_CMD_DMA_MEM_START_ADDR_PANEL, &dsi_display_config_color_mode_on, |
| 294 | 4); |
| 295 | writel(DSI_CMD_DMA_MEM_START_ADDR_PANEL, DSI_DMA_CMD_OFFSET); |
| 296 | writel(4, DSI_DMA_CMD_LENGTH); // reg 0x48 for this build |
| 297 | status += dsi_cmd_dma_trigger_for_panel(); |
| 298 | |
| 299 | // dsi_display_config_color_mode_off - back to normal |
| 300 | memcpy(DSI_CMD_DMA_MEM_START_ADDR_PANEL, &dsi_display_config_color_mode_off, |
| 301 | 4); |
| 302 | writel(DSI_CMD_DMA_MEM_START_ADDR_PANEL, DSI_DMA_CMD_OFFSET); |
| 303 | writel(4, DSI_DMA_CMD_LENGTH); // reg 0x48 for this build |
| 304 | status += dsi_cmd_dma_trigger_for_panel(); |
| 305 | |
| 306 | writel(0x0000, DSI_CTRL); |
| 307 | writel(0x0001, DSI_SOFT_RESET); |
| 308 | writel(0x0000, DSI_SOFT_RESET); |
| 309 | |
| 310 | return status; |
| 311 | } |
| 312 | |
| 313 | int config_dsi_video_mode(unsigned short disp_width, unsigned short disp_height, |
| 314 | unsigned short img_width, unsigned short img_height, |
| 315 | unsigned short hsync_porch0_fp, |
| 316 | unsigned short hsync_porch0_bp, |
| 317 | unsigned short vsync_porch0_fp, |
| 318 | unsigned short vsync_porch0_bp, |
| 319 | unsigned short hsync_width, |
| 320 | unsigned short vsync_width, unsigned short dst_format, |
| 321 | unsigned short traffic_mode, |
| 322 | unsigned short datalane_num) |
| 323 | { |
| 324 | |
| 325 | unsigned char DST_FORMAT; |
| 326 | unsigned char TRAFIC_MODE; |
| 327 | unsigned char DLNx_EN; |
| 328 | // video mode data ctrl |
| 329 | int status = 0; |
| 330 | unsigned long low_pwr_stop_mode = 0; |
| 331 | unsigned char eof_bllp_pwr = 0x9; |
| 332 | unsigned char interleav = 0; |
| 333 | |
| 334 | // disable mdp first |
| 335 | writel(0x00000000, MDP_DSI_VIDEO_EN); |
| 336 | |
| 337 | writel(0x00000000, DSI_CLK_CTRL); |
| 338 | writel(0x00000000, DSI_CLK_CTRL); |
| 339 | writel(0x00000000, DSI_CLK_CTRL); |
| 340 | writel(0x00000000, DSI_CLK_CTRL); |
| 341 | writel(0x00000002, DSI_CLK_CTRL); |
| 342 | writel(0x00000006, DSI_CLK_CTRL); |
| 343 | writel(0x0000000e, DSI_CLK_CTRL); |
| 344 | writel(0x0000001e, DSI_CLK_CTRL); |
| 345 | writel(0x0000003e, DSI_CLK_CTRL); |
| 346 | |
| 347 | writel(0, DSI_CTRL); |
| 348 | |
| 349 | writel(0, DSI_ERR_INT_MASK0); |
| 350 | |
| 351 | DST_FORMAT = 0; // RGB565 |
| 352 | printf("\nDSI_Video_Mode - Dst Format: RGB565"); |
| 353 | |
| 354 | DLNx_EN = 1; // 1 lane with clk programming |
| 355 | printf("\nData Lane: 1 lane\n"); |
| 356 | |
| 357 | TRAFIC_MODE = 0; // non burst mode with sync pulses |
| 358 | printf("\nTraffic mode: non burst mode with sync pulses\n"); |
| 359 | |
| 360 | writel(0x02020202, DSI_INT_CTRL); |
| 361 | |
| 362 | writel(((img_width + hsync_porch0_bp) << 16) | hsync_porch0_bp, |
| 363 | DSI_VIDEO_MODE_ACTIVE_H); |
| 364 | |
| 365 | writel(((img_height + vsync_porch0_bp) << 16) | (vsync_porch0_bp), |
| 366 | DSI_VIDEO_MODE_ACTIVE_V); |
| 367 | |
| 368 | writel(((img_height + vsync_porch0_fp + vsync_porch0_bp) << 16) |
| 369 | | img_width + hsync_porch0_fp + hsync_porch0_bp, |
| 370 | DSI_VIDEO_MODE_TOTAL); |
| 371 | |
| 372 | writel((hsync_width << 16) | 0, DSI_VIDEO_MODE_HSYNC); |
| 373 | |
| 374 | writel(0 << 16 | 0, DSI_VIDEO_MODE_VSYNC); |
| 375 | |
| 376 | writel(vsync_width << 16 | 0, DSI_VIDEO_MODE_VSYNC_VPOS); |
| 377 | |
| 378 | writel(1, DSI_EOT_PACKET_CTRL); |
| 379 | |
| 380 | writel(0x00000100, DSI_MISR_VIDEO_CTRL); |
| 381 | |
| 382 | writel(low_pwr_stop_mode << 16 | eof_bllp_pwr << 12 | TRAFIC_MODE << 8 |
| 383 | | DST_FORMAT << 4 | 0x0, DSI_VIDEO_MODE_CTRL); |
| 384 | |
| 385 | writel(0x67, DSI_CAL_STRENGTH_CTRL); |
| 386 | |
| 387 | writel(0x80006711, DSI_CAL_CTRL); |
| 388 | |
| 389 | writel(0x00010100, DSI_MISR_VIDEO_CTRL); |
| 390 | |
| 391 | writel(0x00010100, DSI_INT_CTRL); |
| 392 | writel(0x02010202, DSI_INT_CTRL); |
| 393 | |
| 394 | writel(0x02030303, DSI_INT_CTRL); |
| 395 | |
| 396 | writel(interleav << 30 | 0 << 24 | 0 << 20 | DLNx_EN << 4 |
| 397 | | 0x103, DSI_CTRL); |
| 398 | mdelay(1); |
| 399 | |
| 400 | return status; |
| 401 | } |
| 402 | |
| 403 | int mdp_setup_dma_p_video_mode(unsigned short disp_width, |
| 404 | unsigned short disp_height, |
| 405 | unsigned short img_width, |
| 406 | unsigned short img_height, |
| 407 | unsigned short hsync_porch0_fp, |
| 408 | unsigned short hsync_porch0_bp, |
| 409 | unsigned short vsync_porch0_fp, |
| 410 | unsigned short vsync_porch0_bp, |
| 411 | unsigned short hsync_width, |
| 412 | unsigned short vsync_width, |
| 413 | unsigned long input_img_addr, |
| 414 | unsigned short img_width_full_size, |
| 415 | unsigned short pack_pattern, |
| 416 | unsigned char ystride) |
| 417 | { |
| 418 | |
| 419 | // unsigned long mdp_intr_status; |
| 420 | int status = FAIL; |
| 421 | unsigned long hsync_period; |
| 422 | unsigned long vsync_period; |
| 423 | unsigned long vsync_period_intmd; |
| 424 | |
| 425 | printf("\nHi setup MDP4.1 for DSI Video Mode\n"); |
| 426 | |
| 427 | hsync_period = img_width + hsync_porch0_fp + hsync_porch0_bp + 1; |
| 428 | vsync_period_intmd = img_height + vsync_porch0_fp + vsync_porch0_bp + 1; |
| 429 | vsync_period = vsync_period_intmd * hsync_period; |
| 430 | |
| 431 | // ----- programming MDP_AXI_RDMASTER_CONFIG -------- |
| 432 | /* MDP_AXI_RDMASTER_CONFIG set all master to read from AXI port 0, that's |
| 433 | the only port connected */ |
| 434 | writel(0x00290000, MDP_AXI_RDMASTER_CONFIG); |
| 435 | writel(0x00000004, MDP_AXI_WRMASTER_CONFIG); |
| 436 | writel(0x00007777, MDP_MAX_RD_PENDING_CMD_CONFIG); |
| 437 | writel(0x00000049, MDP_DISP_INTF_SEL); |
| 438 | writel(0x0000000b, MDP_OVERLAYPROC0_CFG); |
| 439 | |
| 440 | // ------------- programming MDP_DMA_P_CONFIG --------------------- |
| 441 | writel(pack_pattern << 8 | 0xbf | (0 << 25), MDP_DMA_P_CONFIG); // rgb888 |
| 442 | |
| 443 | writel(0x00000000, MDP_DMA_P_OUT_XY); |
| 444 | writel(img_height << 16 | img_width, MDP_DMA_P_SIZE); |
| 445 | writel(input_img_addr, MDP_DMA_P_BUF_ADDR); |
| 446 | writel(img_width_full_size * ystride, MDP_DMA_P_BUF_Y_STRIDE); |
| 447 | writel(0x00ff0000, MDP_DMA_P_OP_MODE); |
| 448 | writel(hsync_period << 16 | hsync_width, MDP_DSI_VIDEO_HSYNC_CTL); |
| 449 | writel(vsync_period, MDP_DSI_VIDEO_VSYNC_PERIOD); |
| 450 | writel(vsync_width * hsync_period, MDP_DSI_VIDEO_VSYNC_PULSE_WIDTH); |
| 451 | writel((img_width + hsync_porch0_bp - 1) << 16 | hsync_porch0_bp, |
| 452 | MDP_DSI_VIDEO_DISPLAY_HCTL); |
| 453 | writel(vsync_porch0_bp * hsync_period, MDP_DSI_VIDEO_DISPLAY_V_START); |
| 454 | writel((img_height + vsync_porch0_bp) * hsync_period, |
| 455 | MDP_DSI_VIDEO_DISPLAY_V_END); |
| 456 | writel(0x00ABCDEF, MDP_DSI_VIDEO_BORDER_CLR); |
| 457 | writel(0x00000000, MDP_DSI_VIDEO_HSYNC_SKEW); |
| 458 | writel(0x00000000, MDP_DSI_VIDEO_CTL_POLARITY); |
| 459 | // end of cmd mdp |
| 460 | |
| 461 | writel(0x00000001, MDP_DSI_VIDEO_EN); // MDP_DSI_EN ENABLE |
| 462 | |
| 463 | status = PASS; |
| 464 | return status; |
| 465 | } |
| 466 | |
| 467 | int mipi_dsi_config(unsigned short num_of_lanes) |
| 468 | { |
| 469 | |
| 470 | int status = 0; |
| 471 | unsigned long ReadValue; |
| 472 | unsigned long count = 0; |
| 473 | unsigned long low_pwr_stop_mode = 0; // low power mode 0x1111 start from |
| 474 | // bit16, high spd mode 0x0 |
| 475 | unsigned char eof_bllp_pwr = 0x9; // bit 12, 15, 1:low power stop mode or |
| 476 | // let cmd mode eng send packets in hs |
| 477 | // or lp mode |
| 478 | unsigned short display_wd = mipi_fb_cfg.width; |
| 479 | unsigned short display_ht = mipi_fb_cfg.height; |
| 480 | unsigned short image_wd = mipi_fb_cfg.width; |
| 481 | unsigned short image_ht = mipi_fb_cfg.height; |
| 482 | unsigned short hsync_porch_fp = MIPI_HSYNC_FRONT_PORCH_DCLK; |
| 483 | unsigned short hsync_porch_bp = MIPI_HSYNC_BACK_PORCH_DCLK; |
| 484 | unsigned short vsync_porch_fp = MIPI_VSYNC_FRONT_PORCH_LINES; |
| 485 | unsigned short vsync_porch_bp = MIPI_VSYNC_BACK_PORCH_LINES; |
| 486 | unsigned short hsync_width = MIPI_HSYNC_PULSE_WIDTH; |
| 487 | unsigned short vsync_width = MIPI_VSYNC_PULSE_WIDTH; |
| 488 | unsigned short dst_format = 0; |
| 489 | unsigned short traffic_mode = 0; |
| 490 | unsigned short pack_pattern = 0x12; |
| 491 | unsigned char ystride = 3; |
| 492 | |
| 493 | low_pwr_stop_mode = 0x1111; // low pwr mode bit16:HSA, bit20:HBA, |
| 494 | // bit24:HFP, bit28:PULSE MODE, need enough |
| 495 | // time for swithc from LP to HS |
| 496 | eof_bllp_pwr = 0x9; // low power stop mode or let cmd mode eng send |
| 497 | // packets in hs or lp mode |
| 498 | |
| 499 | status += config_dsi_video_mode(display_wd, display_ht, image_wd, image_ht, |
| 500 | hsync_porch_fp, hsync_porch_bp, |
| 501 | vsync_porch_fp, vsync_porch_bp, hsync_width, |
| 502 | vsync_width, dst_format, traffic_mode, |
| 503 | num_of_lanes); |
| 504 | |
| 505 | status += |
| 506 | mdp_setup_dma_p_video_mode(display_wd, display_ht, image_wd, image_ht, |
| 507 | hsync_porch_fp, hsync_porch_bp, |
| 508 | vsync_porch_fp, vsync_porch_bp, hsync_width, |
| 509 | vsync_width, MIPI_FB_ADDR, image_wd, |
| 510 | pack_pattern, ystride); |
| 511 | |
| 512 | ReadValue = readl(DSI_INT_CTRL) & 0x00010000; |
| 513 | while (ReadValue != 0x00010000) { |
| 514 | ReadValue = readl(DSI_INT_CTRL) & 0x00010000; |
| 515 | count++; |
| 516 | if (count > 0xffff) { |
| 517 | status = FAIL; |
| 518 | printf("\nToshiba Video 565 pulse 1 lane test is failed\n"); |
| 519 | return status; |
| 520 | } |
| 521 | } |
| 522 | |
| 523 | printf("\nToshiba Video 565 pulse 1 lane is tested successfully \n"); |
| 524 | return status; |
| 525 | } |
| 526 | |
| 527 | void mipi_dsi_shutdown(void) |
| 528 | { |
| 529 | writel(0, DSI_CTRL); |
| 530 | writel(0x00000001, DSI_PHY_SW_RESET); |
| 531 | writel(0x0, DSI_INT_CTRL); |
| 532 | writel(0x00000000, MDP_DSI_VIDEO_EN); |
| 533 | } |
| 534 | |
| 535 | struct fbcon_config *mipi_init(void) |
| 536 | { |
| 537 | int status = 0; |
| 538 | unsigned char num_of_lanes = 1; |
| 539 | writel(0x00001800, MMSS_SFPB_GPREG); |
| 540 | configure_dsicore_dsiclk(); |
| 541 | configure_dsicore_byteclk(); |
| 542 | configure_dsicore_pclk(); |
| 543 | dsi_dsiphy_reg_bitclk_200MHz_toshiba_rgb888(num_of_lanes); |
| 544 | status += dsi_toshiba_panel_config_video_mode_wvga(num_of_lanes); |
| 545 | mipi_fb_cfg.base = MIPI_FB_ADDR; |
| 546 | |
| 547 | status += mipi_dsi_config(num_of_lanes); |
| 548 | return &mipi_fb_cfg; |
| 549 | } |