Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved. |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -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 | #include <mdp4.h> |
| 30 | #include <debug.h> |
| 31 | #include <reg.h> |
| 32 | #include <target/display.h> |
| 33 | #include <platform/timer.h> |
| 34 | #include <platform/iomap.h> |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 35 | #include <dev/lcdc.h> |
| 36 | #include <dev/fbcon.h> |
| 37 | #include <bits.h> |
| 38 | #include <msm_panel.h> |
| 39 | #include <mipi_dsi.h> |
| 40 | #include <err.h> |
| 41 | |
| 42 | static int mdp_rev; |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -0700 | [diff] [blame] | 43 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 44 | void |
| 45 | mdp_setup_dma_p_video_config(unsigned short pack_pattern, |
| 46 | unsigned short img_width, |
| 47 | unsigned short img_height, |
| 48 | unsigned long input_img_addr, |
| 49 | unsigned short img_width_full_size, |
| 50 | unsigned char ystride) |
| 51 | { |
| 52 | dprintf(SPEW, "MDP4.2 Setup for DSI Video Mode\n"); |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -0700 | [diff] [blame] | 53 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 54 | // ----- programming MDP_AXI_RDMASTER_CONFIG -------- |
| 55 | /* MDP_AXI_RDMASTER_CONFIG set all master to read from AXI port 0, that's |
| 56 | the only port connected */ |
| 57 | //TODO: Seems to still work without this |
| 58 | writel(0x00290000, MDP_AXI_RDMASTER_CONFIG); |
| 59 | writel(0x00000004, MDP_AXI_WRMASTER_CONFIG); |
| 60 | writel(0x00007777, MDP_MAX_RD_PENDING_CMD_CONFIG); |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -0700 | [diff] [blame] | 61 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 62 | /* Set up CMD_INTF_SEL, VIDEO_INTF_SEL, EXT_INTF_SEL, SEC_INTF_SEL, PRIM_INTF_SEL */ |
| 63 | writel(0x00000049, MDP_DISP_INTF_SEL); |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -0700 | [diff] [blame] | 64 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 65 | /* DMA P */ |
| 66 | writel(0x0000000b, MDP_OVERLAYPROC0_CFG); |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -0700 | [diff] [blame] | 67 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 68 | /* RGB 888 */ |
| 69 | writel(pack_pattern << 8 | 0xbf | (0 << 25), MDP_DMA_P_CONFIG); |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -0700 | [diff] [blame] | 70 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 71 | writel(0x0, MDP_DMA_P_OUT_XY); |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -0700 | [diff] [blame] | 72 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 73 | writel(img_height << 16 | img_width, MDP_DMA_P_SIZE); |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -0700 | [diff] [blame] | 74 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 75 | writel(input_img_addr, MDP_DMA_P_BUF_ADDR); |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -0700 | [diff] [blame] | 76 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 77 | writel(img_width_full_size * ystride, MDP_DMA_P_BUF_Y_STRIDE); |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -0700 | [diff] [blame] | 78 | } |
| 79 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 80 | int |
| 81 | mdp_setup_dma_p_video_mode(unsigned short disp_width, |
| 82 | unsigned short disp_height, |
| 83 | unsigned short img_width, |
| 84 | unsigned short img_height, |
| 85 | unsigned short hsync_porch0_fp, |
| 86 | unsigned short hsync_porch0_bp, |
| 87 | unsigned short vsync_porch0_fp, |
| 88 | unsigned short vsync_porch0_bp, |
| 89 | unsigned short hsync_width, |
| 90 | unsigned short vsync_width, |
| 91 | unsigned long input_img_addr, |
| 92 | unsigned short img_width_full_size, |
| 93 | unsigned short pack_pattern, unsigned char ystride) |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -0700 | [diff] [blame] | 94 | { |
| 95 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 96 | // unsigned long mdp_intr_status; |
| 97 | int status = FAIL; |
| 98 | unsigned long hsync_period; |
| 99 | unsigned long vsync_period; |
| 100 | unsigned long vsync_period_intmd; |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -0700 | [diff] [blame] | 101 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 102 | dprintf(SPEW, "MDP4.1 for DSI Video Mode\n"); |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -0700 | [diff] [blame] | 103 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 104 | hsync_period = img_width + hsync_porch0_fp + hsync_porch0_bp + 1; |
| 105 | vsync_period_intmd = img_height + vsync_porch0_fp + vsync_porch0_bp + 1; |
| 106 | vsync_period = vsync_period_intmd * hsync_period; |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -0700 | [diff] [blame] | 107 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 108 | // ----- programming MDP_AXI_RDMASTER_CONFIG -------- |
| 109 | /* MDP_AXI_RDMASTER_CONFIG set all master to read from AXI port 0, that's |
| 110 | the only port connected */ |
| 111 | writel(0x00290000, MDP_AXI_RDMASTER_CONFIG); |
| 112 | writel(0x00000004, MDP_AXI_WRMASTER_CONFIG); |
| 113 | writel(0x00007777, MDP_MAX_RD_PENDING_CMD_CONFIG); |
| 114 | /* sets PRIM_INTF_SEL to 0x1 and SEC_INTF_SEL to 0x2 and DSI_VIDEO_INTF_SEL */ |
| 115 | writel(0x00000049, MDP_DISP_INTF_SEL); |
| 116 | writel(0x0000000b, MDP_OVERLAYPROC0_CFG); |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -0700 | [diff] [blame] | 117 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 118 | // ------------- programming MDP_DMA_P_CONFIG --------------------- |
| 119 | writel(pack_pattern << 8 | 0xbf | (0 << 25), MDP_DMA_P_CONFIG); // rgb888 |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -0700 | [diff] [blame] | 120 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 121 | writel(0x00000000, MDP_DMA_P_OUT_XY); |
| 122 | writel(img_height << 16 | img_width, MDP_DMA_P_SIZE); |
| 123 | writel(input_img_addr, MDP_DMA_P_BUF_ADDR); |
| 124 | writel(img_width_full_size * ystride, MDP_DMA_P_BUF_Y_STRIDE); |
| 125 | writel(0x00ff0000, MDP_DMA_P_OP_MODE); |
| 126 | writel(hsync_period << 16 | hsync_width, MDP_DSI_VIDEO_HSYNC_CTL); |
| 127 | writel(vsync_period, MDP_DSI_VIDEO_VSYNC_PERIOD); |
| 128 | writel(vsync_width * hsync_period, MDP_DSI_VIDEO_VSYNC_PULSE_WIDTH); |
| 129 | writel((img_width + hsync_porch0_bp - 1) << 16 | hsync_porch0_bp, |
| 130 | MDP_DSI_VIDEO_DISPLAY_HCTL); |
| 131 | writel(vsync_porch0_bp * hsync_period, MDP_DSI_VIDEO_DISPLAY_V_START); |
| 132 | writel((img_height + vsync_porch0_bp) * hsync_period, |
| 133 | MDP_DSI_VIDEO_DISPLAY_V_END); |
| 134 | writel(0x00ABCDEF, MDP_DSI_VIDEO_BORDER_CLR); |
| 135 | writel(0x00000000, MDP_DSI_VIDEO_HSYNC_SKEW); |
| 136 | writel(0x00000000, MDP_DSI_VIDEO_CTL_POLARITY); |
| 137 | // end of cmd mdp |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -0700 | [diff] [blame] | 138 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 139 | writel(0x00000001, MDP_DSI_VIDEO_EN); // MDP_DSI_EN ENABLE |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -0700 | [diff] [blame] | 140 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 141 | status = PASS; |
| 142 | return status; |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -0700 | [diff] [blame] | 143 | } |
| 144 | |
Channagoud Kadabi | 10189fd | 2012-05-25 13:33:39 +0530 | [diff] [blame] | 145 | int mdp_dsi_cmd_config(struct msm_panel_info *pinfo, |
| 146 | struct fbcon_config *fb) |
| 147 | { |
| 148 | |
| 149 | int ret = 0; |
| 150 | unsigned long input_img_addr = MIPI_FB_ADDR; |
| 151 | unsigned short image_wd = pinfo->xres; |
| 152 | unsigned short image_ht = pinfo->yres; |
| 153 | unsigned short pack_pattern = 0x12; |
| 154 | unsigned char ystride = 3; |
| 155 | |
| 156 | writel(0x03ffffff, MDP_INTR_ENABLE); |
| 157 | writel(0x0000000b, MDP_OVERLAYPROC0_CFG); |
| 158 | |
| 159 | // ------------- programming MDP_DMA_P_CONFIG --------------------- |
| 160 | writel(pack_pattern << 8 | 0x3f | (0 << 25), MDP_DMA_P_CONFIG); // rgb888 |
| 161 | |
| 162 | writel(0x00000000, MDP_DMA_P_OUT_XY); |
| 163 | writel(image_ht << 16 | image_wd, MDP_DMA_P_SIZE); |
| 164 | writel(input_img_addr, MDP_DMA_P_BUF_ADDR); |
| 165 | |
| 166 | writel(image_wd * ystride, MDP_DMA_P_BUF_Y_STRIDE); |
| 167 | |
| 168 | writel(0x00000000, MDP_DMA_P_OP_MODE); |
| 169 | |
| 170 | writel(0x10, MDP_DSI_CMD_MODE_ID_MAP); |
| 171 | writel(0x01, MDP_DSI_CMD_MODE_TRIGGER_EN); |
| 172 | |
| 173 | writel(0x0001a000, MDP_AXI_RDMASTER_CONFIG); |
| 174 | writel(0x00000004, MDP_AXI_WRMASTER_CONFIG); |
| 175 | writel(0x00007777, MDP_MAX_RD_PENDING_CMD_CONFIG); |
| 176 | writel(0x8a, MDP_DISP_INTF_SEL); |
| 177 | |
| 178 | return ret; |
| 179 | } |
| 180 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 181 | int |
| 182 | mipi_dsi_cmd_config(struct fbcon_config mipi_fb_cfg, |
| 183 | unsigned short num_of_lanes) |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -0700 | [diff] [blame] | 184 | { |
| 185 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 186 | int status = 0; |
| 187 | unsigned long input_img_addr = MIPI_FB_ADDR; |
| 188 | unsigned short image_wd = mipi_fb_cfg.width; |
| 189 | unsigned short image_ht = mipi_fb_cfg.height; |
| 190 | unsigned short pack_pattern = 0x12; |
| 191 | unsigned char ystride = 3; |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -0700 | [diff] [blame] | 192 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 193 | writel(0x03ffffff, MDP_INTR_ENABLE); |
| 194 | writel(0x0000000b, MDP_OVERLAYPROC0_CFG); |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -0700 | [diff] [blame] | 195 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 196 | // ------------- programming MDP_DMA_P_CONFIG --------------------- |
| 197 | writel(pack_pattern << 8 | 0x3f | (0 << 25), MDP_DMA_P_CONFIG); // rgb888 |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -0700 | [diff] [blame] | 198 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 199 | writel(0x00000000, MDP_DMA_P_OUT_XY); |
| 200 | writel(image_ht << 16 | image_wd, MDP_DMA_P_SIZE); |
| 201 | writel(input_img_addr, MDP_DMA_P_BUF_ADDR); |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -0700 | [diff] [blame] | 202 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 203 | writel(image_wd * ystride, MDP_DMA_P_BUF_Y_STRIDE); |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -0700 | [diff] [blame] | 204 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 205 | writel(0x00000000, MDP_DMA_P_OP_MODE); |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -0700 | [diff] [blame] | 206 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 207 | writel(0x10, MDP_DSI_CMD_MODE_ID_MAP); |
| 208 | writel(0x01, MDP_DSI_CMD_MODE_TRIGGER_EN); |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -0700 | [diff] [blame] | 209 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 210 | writel(0x0001a000, MDP_AXI_RDMASTER_CONFIG); |
| 211 | writel(0x00000004, MDP_AXI_WRMASTER_CONFIG); |
| 212 | writel(0x00007777, MDP_MAX_RD_PENDING_CMD_CONFIG); |
| 213 | writel(0x8a, MDP_DISP_INTF_SEL); |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -0700 | [diff] [blame] | 214 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 215 | return status; |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -0700 | [diff] [blame] | 216 | } |
| 217 | |
| 218 | void mdp_disable(void) |
| 219 | { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 220 | writel(0x00000000, MDP_DSI_VIDEO_EN); |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -0700 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | void mdp_shutdown(void) |
| 224 | { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 225 | mdp_disable(); |
| 226 | mdelay(60); |
| 227 | writel(0x00000000, MDP_INTR_ENABLE); |
| 228 | writel(0x00000003, MDP_OVERLAYPROC0_CFG); |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -0700 | [diff] [blame] | 229 | } |
| 230 | |
Channagoud Kadabi | 10189fd | 2012-05-25 13:33:39 +0530 | [diff] [blame] | 231 | int mdp_dma_on(void) |
| 232 | { |
| 233 | int ret = 0; |
| 234 | |
| 235 | writel(0x00000001, MDP_DMA_P_START); |
| 236 | |
| 237 | return ret; |
| 238 | } |
| 239 | |
| 240 | int mdp_dma_off(void) |
| 241 | { |
| 242 | int ret = 0; |
| 243 | |
| 244 | writel(0x00000000, MDP_DMA_P_START); |
| 245 | |
| 246 | return ret; |
| 247 | } |
| 248 | |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -0700 | [diff] [blame] | 249 | void mdp_start_dma(void) |
| 250 | { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 251 | writel(0x00000001, MDP_DMA_P_START); |
Kinson Chik | fe93103 | 2011-07-21 10:01:34 -0700 | [diff] [blame] | 252 | } |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 253 | |
| 254 | int mdp_lcdc_config(struct msm_panel_info *pinfo, |
| 255 | struct fbcon_config *fb) |
| 256 | { |
| 257 | unsigned mdp_rgb_size; |
| 258 | unsigned mdp_rgb_size_src; |
| 259 | int hsync_period, vsync_period; |
| 260 | int hsync_start_x, hsync_end_x; |
| 261 | int display_hctl, display_vstart, display_vend; |
| 262 | unsigned mdp_rgb_format = 0; |
| 263 | |
| 264 | int active_x, active_y; |
| 265 | int active_hstart_x, active_hend_x; |
| 266 | int active_vstart, active_vend; |
| 267 | |
| 268 | struct lcdc_panel_info *lcdc = NULL; |
| 269 | |
| 270 | if (pinfo == NULL) |
| 271 | return; |
| 272 | |
| 273 | lcdc = &(pinfo->lcdc); |
| 274 | if (lcdc == NULL) |
| 275 | return; |
| 276 | |
| 277 | mdp_rgb_size = (pinfo->yres << 16) + pinfo->xres; |
| 278 | mdp_rgb_size_src = (fb->height << 16) + fb->width; |
| 279 | |
| 280 | dprintf(INFO, "Panel is %d x %d\n", |
| 281 | pinfo->xres + lcdc->xres_pad, |
| 282 | pinfo->yres + lcdc->yres_pad); |
| 283 | |
| 284 | /* write fb addr in MDP_DMA_P_BUF_ADDR */ |
| 285 | writel(fb->base, MDP_DMA_P_BUF_ADDR); |
| 286 | |
| 287 | /* write active region size*/ |
| 288 | writel(mdp_rgb_size, MDP_DMA_P_SIZE); |
| 289 | |
| 290 | /* set Y-stride value in bytes */ |
| 291 | /* Y-stride is defined as the number of bytes |
| 292 | in a line. |
| 293 | */ |
| 294 | writel((pinfo->xres * pinfo->bpp/8), MDP_DMA_P_BUF_Y_STRIDE); |
| 295 | |
| 296 | /* Start XY coordinates */ |
| 297 | writel(0, MDP_DMA_P_OUT_XY); |
| 298 | |
| 299 | if (fb->bpp == 16) { |
| 300 | writel(DMA_PACK_ALIGN_LSB | DMA_PACK_PATTERN_RGB | |
| 301 | DMA_DITHER_EN | DMA_OUT_SEL_LCDC | |
| 302 | DMA_IBUF_FORMAT_RGB565 | DMA_DSTC0G_8BITS | |
| 303 | DMA_DSTC1B_8BITS | DMA_DSTC2R_8BITS, |
| 304 | MDP_DMA_P_CONFIG); |
| 305 | mdp_rgb_format = MDP_RGB_565_FORMAT; |
| 306 | } else if (fb->bpp == 24) { |
| 307 | writel(DMA_PACK_ALIGN_LSB | DMA_PACK_PATTERN_RGB | |
| 308 | DMA_DITHER_EN | DMA_OUT_SEL_LCDC | |
| 309 | DMA_IBUF_FORMAT_RGB888 | DMA_DSTC0G_8BITS | |
| 310 | DMA_DSTC1B_8BITS | DMA_DSTC2R_8BITS, |
| 311 | MDP_DMA_P_CONFIG); |
| 312 | mdp_rgb_format = MDP_RGB_888_FORMAT; |
| 313 | } else { |
| 314 | dprintf(CRITICAL, "Unsupported bpp detected!\n"); |
| 315 | return ERR_INVALID_ARGS; |
| 316 | } |
| 317 | |
| 318 | hsync_period = lcdc->h_pulse_width + |
| 319 | lcdc->h_back_porch + |
| 320 | pinfo->xres + lcdc->h_front_porch; |
| 321 | vsync_period = (lcdc->v_pulse_width + |
| 322 | lcdc->v_back_porch + |
| 323 | pinfo->yres + |
| 324 | lcdc->v_front_porch) * |
| 325 | hsync_period; |
| 326 | hsync_start_x = |
| 327 | lcdc->h_pulse_width + |
| 328 | lcdc->h_back_porch; |
| 329 | hsync_end_x = |
| 330 | hsync_period - lcdc->h_front_porch - 1; |
| 331 | display_hctl = (hsync_end_x << 16) | hsync_start_x; |
| 332 | display_vstart = (lcdc->v_pulse_width + |
| 333 | lcdc->v_back_porch) |
| 334 | * hsync_period + lcdc->hsync_skew; |
| 335 | display_vend = vsync_period - |
| 336 | (lcdc->v_front_porch * hsync_period) |
| 337 | +lcdc->hsync_skew - 1; |
| 338 | |
| 339 | active_x = (pinfo->xres - fb->width)/2; |
| 340 | active_y = (pinfo->yres - fb->height)/2; |
| 341 | |
| 342 | active_hstart_x = lcdc->h_pulse_width + lcdc->h_back_porch |
| 343 | + active_x; |
| 344 | active_hend_x = active_hstart_x + fb->width - 1; |
| 345 | |
| 346 | active_vstart = (lcdc->v_pulse_width + lcdc->v_back_porch |
| 347 | + active_y) * hsync_period |
| 348 | + lcdc->hsync_skew; |
| 349 | active_vend = active_vstart + (fb->height * hsync_period) - 1; |
| 350 | |
| 351 | |
| 352 | /* LCDC specific initalizations */ |
| 353 | writel((hsync_period << 16) | lcdc->h_pulse_width, |
| 354 | MDP_LCDC_HSYNC_CTL); |
| 355 | writel(vsync_period, MDP_LCDC_VSYNC_PERIOD); |
| 356 | writel(lcdc->v_pulse_width * hsync_period, |
| 357 | MDP_LCDC_VSYNC_PULSE_WIDTH); |
| 358 | writel(display_hctl, MDP_LCDC_DISPLAY_HCTL); |
| 359 | writel(display_vstart, MDP_LCDC_DISPLAY_V_START); |
| 360 | writel(display_vend, MDP_LCDC_DISPLAY_V_END); |
| 361 | |
| 362 | writel(BIT(31) | (active_hend_x << 16) | active_hstart_x, |
| 363 | MDP_LCDC_ACTIVE_HCTL); |
| 364 | |
| 365 | writel(BIT(31) | active_vstart, MDP_LCDC_ACTIVE_V_START); |
| 366 | writel(active_vend, MDP_LCDC_ACTIVE_V_END); |
| 367 | |
| 368 | writel(0xf, MDP_LCDC_BORDER_CLR); |
| 369 | writel(0xff, MDP_LCDC_UNDERFLOW_CTL); |
| 370 | writel(lcdc->hsync_skew, |
| 371 | MDP_LCDC_HSYNC_SKEW); |
| 372 | writel(0x3, MDP_LCDC_CTL_POLARITY); |
| 373 | writel(0, MDP_LCDC_ACTIVE_HCTL); |
| 374 | writel(0, MDP_LCDC_ACTIVE_V_START); |
| 375 | writel(0, MDP_LCDC_ACTIVE_V_END); |
| 376 | |
| 377 | /* setting for single layer direct out mode for rgb565 source */ |
| 378 | writel(0x100, MDP_LAYERMIXER_IN_CFG); |
| 379 | writel(mdp_rgb_size_src, MDP_RGB1_SRC_SIZE); |
| 380 | writel(mdp_rgb_size, MDP_RGB1_OUT_SIZE); |
| 381 | writel((int)fb->base, MDP_RGB1_SRCP0_ADDR); |
| 382 | writel((fb->stride * fb->bpp / 8), MDP_RGB1_SRC_YSTRIDE1); |
| 383 | writel(0x00, MDP_RGB1_CONSTANT_COLOR); |
| 384 | writel(mdp_rgb_format, MDP_RGB1_SRC_FORMAT); |
| 385 | writel(0x1, MDP_OVERLAYPROC0_CFG); |
| 386 | if (fb->bpp == 16) |
| 387 | writel(0x1, MDP_OVERLAYPROC0_OPMODE); |
| 388 | else if (fb->bpp == 24) |
| 389 | writel(0x0, MDP_OVERLAYPROC0_OPMODE); |
| 390 | |
| 391 | /* register flush and enable LCDC */ |
| 392 | writel(0x11, MDP_OVERLAY_REG_FLUSH); |
| 393 | return NO_ERROR; |
| 394 | } |
| 395 | |
| 396 | int mdp_lcdc_on() |
| 397 | { |
| 398 | writel(0x1, MDP_LCDC_EN); |
| 399 | return NO_ERROR; |
| 400 | } |
| 401 | |
| 402 | int mdp_lcdc_off() |
| 403 | { |
| 404 | writel(0x0, MDP_LCDC_EN); |
| 405 | return NO_ERROR; |
| 406 | } |
| 407 | |
| 408 | int mdp_dsi_video_config(struct msm_panel_info *pinfo, |
| 409 | struct fbcon_config *fb) |
| 410 | { |
| 411 | int ret = NO_ERROR; |
| 412 | int hsync_period, vsync_period; |
| 413 | int hsync_start_x, hsync_end_x; |
| 414 | int display_hctl, display_vstart, display_vend; |
| 415 | struct lcdc_panel_info *lcdc = NULL; |
| 416 | unsigned mdp_rgb_size; |
| 417 | |
| 418 | if (pinfo == NULL) |
| 419 | return ERR_INVALID_ARGS; |
| 420 | |
| 421 | lcdc = &(pinfo->lcdc); |
| 422 | if (lcdc == NULL) |
| 423 | return ERR_INVALID_ARGS; |
| 424 | |
| 425 | hsync_period = lcdc->h_pulse_width + |
| 426 | lcdc->h_back_porch + |
| 427 | pinfo->xres + lcdc->xres_pad + lcdc->h_front_porch; |
| 428 | vsync_period = (lcdc->v_pulse_width + |
| 429 | lcdc->v_back_porch + |
| 430 | pinfo->yres + lcdc->yres_pad + |
| 431 | lcdc->v_front_porch) * hsync_period; |
| 432 | hsync_start_x = |
| 433 | lcdc->h_pulse_width + |
| 434 | lcdc->h_back_porch; |
| 435 | hsync_end_x = |
| 436 | hsync_period - lcdc->h_front_porch - 1; |
| 437 | display_hctl = (hsync_end_x << 16) | hsync_start_x; |
| 438 | display_vstart = (lcdc->v_pulse_width + |
| 439 | lcdc->v_back_porch) |
| 440 | * hsync_period + lcdc->hsync_skew; |
| 441 | display_vend = vsync_period - |
| 442 | (lcdc->v_front_porch * hsync_period) |
| 443 | +lcdc->hsync_skew - 1; |
| 444 | |
| 445 | /* MDP_AXI_RDMASTER_CONFIG set all master to read from |
| 446 | AXI port 0, that's the only port connected */ |
| 447 | writel(0x00290000, MDP_AXI_RDMASTER_CONFIG); |
| 448 | writel(0x00000004, MDP_AXI_WRMASTER_CONFIG); |
| 449 | writel(0x00007777, MDP_MAX_RD_PENDING_CMD_CONFIG); |
| 450 | |
| 451 | /* Set up CMD_INTF_SEL, VIDEO_INTF_SEL, |
| 452 | EXT_INTF_SEL, SEC_INTF_SEL, PRIM_INTF_SEL */ |
| 453 | writel(0x00000049, MDP_DISP_INTF_SEL); |
| 454 | |
| 455 | /* DMA P */ |
| 456 | writel(0x0000000b, MDP_OVERLAYPROC0_CFG); |
| 457 | |
| 458 | /* write fb addr in MDP_DMA_P_BUF_ADDR */ |
| 459 | writel(fb->base, MDP_DMA_P_BUF_ADDR); |
| 460 | |
| 461 | /* write active region size*/ |
| 462 | mdp_rgb_size = (fb->height << 16) + fb->width; |
| 463 | writel(mdp_rgb_size, MDP_DMA_P_SIZE); |
| 464 | |
| 465 | /* set Y-stride value in bytes */ |
| 466 | /* Y-stride is defined as the number of bytes |
| 467 | in a line. |
| 468 | */ |
| 469 | writel((fb->stride * fb->bpp/8), MDP_DMA_P_BUF_Y_STRIDE); |
| 470 | |
| 471 | /* Start XY coordinates */ |
| 472 | writel(0, MDP_DMA_P_OUT_XY); |
| 473 | |
| 474 | if (fb->bpp == 16) { |
| 475 | writel(DMA_PACK_ALIGN_LSB | DMA_PACK_PATTERN_RGB | |
| 476 | DMA_DITHER_EN | DMA_OUT_SEL_LCDC | |
| 477 | DMA_IBUF_FORMAT_RGB565 | DMA_DSTC0G_8BITS | |
| 478 | DMA_DSTC1B_8BITS | DMA_DSTC2R_8BITS, |
| 479 | MDP_DMA_P_CONFIG); |
| 480 | } else if (fb->bpp == 24) { |
| 481 | writel(DMA_PACK_ALIGN_LSB | DMA_PACK_PATTERN_RGB | |
| 482 | DMA_DITHER_EN | DMA_OUT_SEL_LCDC | |
| 483 | DMA_IBUF_FORMAT_RGB888 | DMA_DSTC0G_8BITS | |
| 484 | DMA_DSTC1B_8BITS | DMA_DSTC2R_8BITS, |
| 485 | MDP_DMA_P_CONFIG); |
| 486 | } else { |
| 487 | dprintf(CRITICAL, "Unsupported bpp detected!\n"); |
| 488 | return ERR_INVALID_ARGS; |
| 489 | } |
| 490 | |
| 491 | writel(hsync_period << 16 | lcdc->h_pulse_width, |
| 492 | MDP_DSI_VIDEO_HSYNC_CTL); |
| 493 | writel(vsync_period, MDP_DSI_VIDEO_VSYNC_PERIOD); |
| 494 | writel(lcdc->v_pulse_width * hsync_period, |
| 495 | MDP_DSI_VIDEO_VSYNC_PULSE_WIDTH); |
| 496 | writel(display_hctl, |
| 497 | MDP_DSI_VIDEO_DISPLAY_HCTL); |
| 498 | writel(display_vstart, MDP_DSI_VIDEO_DISPLAY_V_START); |
| 499 | writel(display_vend, MDP_DSI_VIDEO_DISPLAY_V_END); |
| 500 | |
| 501 | if (lcdc->xres_pad) { |
| 502 | writel((1 << 31) | |
| 503 | (lcdc->h_back_porch + lcdc->h_pulse_width + |
| 504 | fb->width - 1) << 16 | lcdc->h_pulse_width + |
| 505 | lcdc->h_back_porch, MDP_DSI_VIDEO_ACTIVE_HCTL); |
| 506 | } |
| 507 | |
| 508 | return ret; |
| 509 | } |
| 510 | |
| 511 | int mdp_dsi_video_on() |
| 512 | { |
| 513 | int ret = NO_ERROR; |
| 514 | |
| 515 | writel(0x00000001, MDP_DSI_VIDEO_EN); |
| 516 | |
| 517 | return ret; |
| 518 | } |
| 519 | |
| 520 | int mdp_dsi_video_off() |
| 521 | { |
Amol Jadi | 6834f1a | 2012-06-29 14:42:59 -0700 | [diff] [blame^] | 522 | if(!target_cont_splash_screen()) |
| 523 | { |
| 524 | writel(0x00000000, MDP_DSI_VIDEO_EN); |
| 525 | mdelay(60); |
| 526 | writel(0x00000000, MDP_INTR_ENABLE); |
| 527 | writel(0x00000003, MDP_OVERLAYPROC0_CFG); |
| 528 | } |
| 529 | |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 530 | return NO_ERROR; |
| 531 | } |
| 532 | |
Channagoud Kadabi | 10189fd | 2012-05-25 13:33:39 +0530 | [diff] [blame] | 533 | int mdp_dsi_cmd_off() |
| 534 | { |
| 535 | mdp_dma_off(); |
| 536 | /* |
| 537 | * Allow sometime for the DMA channel to |
| 538 | * stop the data transfer |
| 539 | */ |
| 540 | mdelay(10); |
| 541 | writel(0x00000000, MDP_INTR_ENABLE); |
| 542 | writel(0x00000003, MDP_OVERLAYPROC0_CFG); |
| 543 | return NO_ERROR; |
| 544 | } |
| 545 | |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 546 | void mdp_set_revision(int rev) |
| 547 | { |
| 548 | mdp_rev = rev; |
| 549 | } |
| 550 | |
| 551 | int mdp_get_revision() |
| 552 | { |
| 553 | return mdp_rev; |
| 554 | } |