Jayant Shekhar | 32397f9 | 2014-03-27 13:30:41 +0530 | [diff] [blame] | 1 | /* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. |
Aparna Mallavarapu | f712f5e | 2011-08-04 21:11:00 +0530 | [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. |
Padmanabhan Komanduru | fa4be75 | 2012-10-08 16:51:56 +0530 | [diff] [blame] | 12 | * * Neither the name of The Linux Foundation, Inc. nor the names of its |
Aparna Mallavarapu | f712f5e | 2011-08-04 21:11:00 +0530 | [diff] [blame] | 13 | * contributors may be used to endorse or promote products derived |
| 14 | * from this software without specific prior written permission. |
| 15 | * |
| 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED |
| 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | * |
| 28 | */ |
| 29 | #include <mdp3.h> |
| 30 | #include <debug.h> |
| 31 | #include <reg.h> |
Channagoud Kadabi | 539ef72 | 2012-03-29 16:02:50 +0530 | [diff] [blame] | 32 | #include <msm_panel.h> |
| 33 | #include <err.h> |
Aparna Mallavarapu | f712f5e | 2011-08-04 21:11:00 +0530 | [diff] [blame] | 34 | #include <target/display.h> |
| 35 | #include <platform/timer.h> |
| 36 | #include <platform/iomap.h> |
| 37 | |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 38 | static int mdp_rev; |
| 39 | |
Channagoud Kadabi | 539ef72 | 2012-03-29 16:02:50 +0530 | [diff] [blame] | 40 | int mdp_dsi_video_config(struct msm_panel_info *pinfo, |
| 41 | struct fbcon_config *fb) |
Aparna Mallavarapu | f712f5e | 2011-08-04 21:11:00 +0530 | [diff] [blame] | 42 | { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 43 | unsigned long hsync_period; |
| 44 | unsigned long vsync_period; |
| 45 | unsigned long vsync_period_intmd; |
Channagoud Kadabi | 539ef72 | 2012-03-29 16:02:50 +0530 | [diff] [blame] | 46 | struct lcdc_panel_info *lcdc = NULL; |
| 47 | int ystride = 3; |
Terence Hampson | 7385f6a | 2013-08-16 15:31:25 -0400 | [diff] [blame] | 48 | int mdp_rev = mdp_get_revision(); |
Channagoud Kadabi | 539ef72 | 2012-03-29 16:02:50 +0530 | [diff] [blame] | 49 | |
| 50 | if (pinfo == NULL) |
| 51 | return ERR_INVALID_ARGS; |
| 52 | |
| 53 | lcdc = &(pinfo->lcdc); |
| 54 | if (lcdc == NULL) |
| 55 | return ERR_INVALID_ARGS; |
Aparna Mallavarapu | f712f5e | 2011-08-04 21:11:00 +0530 | [diff] [blame] | 56 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 57 | dprintf(SPEW, "MDP3.0.3 for DSI Video Mode\n"); |
Aparna Mallavarapu | f712f5e | 2011-08-04 21:11:00 +0530 | [diff] [blame] | 58 | |
Channagoud Kadabi | 539ef72 | 2012-03-29 16:02:50 +0530 | [diff] [blame] | 59 | hsync_period = pinfo->xres + lcdc->h_front_porch + \ |
| 60 | lcdc->h_back_porch + 1; |
| 61 | vsync_period_intmd = pinfo->yres + lcdc->v_front_porch + \ |
| 62 | lcdc->v_back_porch + 1; |
Shivaraj Shetty | f9e10c4 | 2014-09-17 04:21:15 +0530 | [diff] [blame] | 63 | if (mdp_rev == MDP_REV_304 || mdp_rev == MDP_REV_305) { |
Terence Hampson | 7385f6a | 2013-08-16 15:31:25 -0400 | [diff] [blame] | 64 | hsync_period += lcdc->h_pulse_width - 1; |
| 65 | vsync_period_intmd += lcdc->v_pulse_width - 1; |
| 66 | } |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 67 | vsync_period = vsync_period_intmd * hsync_period; |
Aparna Mallavarapu | f712f5e | 2011-08-04 21:11:00 +0530 | [diff] [blame] | 68 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 69 | // ------------- programming MDP_DMA_P_CONFIG --------------------- |
| 70 | writel(0x1800bf, MDP_DMA_P_CONFIG); // rgb888 |
Aparna Mallavarapu | f712f5e | 2011-08-04 21:11:00 +0530 | [diff] [blame] | 71 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 72 | writel(0x00000000, MDP_DMA_P_OUT_XY); |
Channagoud Kadabi | 539ef72 | 2012-03-29 16:02:50 +0530 | [diff] [blame] | 73 | writel(pinfo->yres << 16 | pinfo->xres, MDP_DMA_P_SIZE); |
| 74 | writel(MIPI_FB_ADDR, MDP_DMA_P_BUF_ADDR); |
| 75 | writel(pinfo->xres * ystride, MDP_DMA_P_BUF_Y_STRIDE); |
| 76 | writel(hsync_period << 16 | lcdc->h_pulse_width, \ |
| 77 | MDP_DSI_VIDEO_HSYNC_CTL); |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 78 | writel(vsync_period, MDP_DSI_VIDEO_VSYNC_PERIOD); |
Channagoud Kadabi | 539ef72 | 2012-03-29 16:02:50 +0530 | [diff] [blame] | 79 | writel(lcdc->v_pulse_width * hsync_period, \ |
| 80 | MDP_DSI_VIDEO_VSYNC_PULSE_WIDTH); |
Shivaraj Shetty | f9e10c4 | 2014-09-17 04:21:15 +0530 | [diff] [blame] | 81 | if (mdp_rev == MDP_REV_304 || mdp_rev == MDP_REV_305) { |
Terence Hampson | 7385f6a | 2013-08-16 15:31:25 -0400 | [diff] [blame] | 82 | writel((pinfo->xres + lcdc->h_back_porch + \ |
| 83 | lcdc->h_pulse_width - 1) << 16 | \ |
| 84 | lcdc->h_back_porch + lcdc->h_pulse_width, \ |
| 85 | MDP_DSI_VIDEO_DISPLAY_HCTL); |
| 86 | writel((lcdc->v_back_porch + lcdc->v_pulse_width) \ |
| 87 | * hsync_period, MDP_DSI_VIDEO_DISPLAY_V_START); |
| 88 | writel(vsync_period - lcdc->v_front_porch * hsync_period - 1, |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 89 | MDP_DSI_VIDEO_DISPLAY_V_END); |
Terence Hampson | 7385f6a | 2013-08-16 15:31:25 -0400 | [diff] [blame] | 90 | } else { |
| 91 | writel((pinfo->xres + lcdc->h_back_porch - 1) << 16 | \ |
| 92 | lcdc->h_back_porch, MDP_DSI_VIDEO_DISPLAY_HCTL); |
| 93 | writel(lcdc->v_back_porch * hsync_period, \ |
| 94 | MDP_DSI_VIDEO_DISPLAY_V_START); |
| 95 | writel((pinfo->yres + lcdc->v_back_porch) * hsync_period, |
| 96 | MDP_DSI_VIDEO_DISPLAY_V_END); |
| 97 | } |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 98 | writel(0x00ABCDEF, MDP_DSI_VIDEO_BORDER_CLR); |
| 99 | writel(0x00000000, MDP_DSI_VIDEO_HSYNC_SKEW); |
| 100 | writel(0x00000000, MDP_DSI_VIDEO_CTL_POLARITY); |
| 101 | // end of cmd mdp |
Aparna Mallavarapu | f712f5e | 2011-08-04 21:11:00 +0530 | [diff] [blame] | 102 | |
Channagoud Kadabi | 539ef72 | 2012-03-29 16:02:50 +0530 | [diff] [blame] | 103 | return 0; |
Aparna Mallavarapu | f712f5e | 2011-08-04 21:11:00 +0530 | [diff] [blame] | 104 | } |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 105 | |
Channagoud Kadabi | 10189fd | 2012-05-25 13:33:39 +0530 | [diff] [blame] | 106 | int mdp_dsi_cmd_config(struct msm_panel_info *pinfo, |
| 107 | struct fbcon_config *fb) |
| 108 | { |
| 109 | int ret = 0; |
| 110 | unsigned short pack_pattern = 0x21; |
| 111 | unsigned char ystride = 3; |
| 112 | |
| 113 | writel(0x03ffffff, MDP_INTR_ENABLE); |
| 114 | |
| 115 | // ------------- programming MDP_DMA_P_CONFIG --------------------- |
| 116 | writel(pack_pattern << 8 | 0x3f | (0 << 25)| (1 << 19) | (1 << 7) , MDP_DMA_P_CONFIG); // rgb888 |
| 117 | writel(0x00000000, MDP_DMA_P_OUT_XY); |
| 118 | writel(pinfo->yres << 16 | pinfo->xres, MDP_DMA_P_SIZE); |
| 119 | writel(MIPI_FB_ADDR, MDP_DMA_P_BUF_ADDR); |
| 120 | |
| 121 | writel(pinfo->xres * ystride, MDP_DMA_P_BUF_Y_STRIDE); |
| 122 | |
| 123 | writel(0x10, MDP_DSI_CMD_MODE_ID_MAP); |
| 124 | writel(0x11, MDP_DSI_CMD_MODE_TRIGGER_EN); |
| 125 | mdelay(10); |
| 126 | |
| 127 | return ret; |
| 128 | } |
| 129 | |
Aparna Mallavarapu | f712f5e | 2011-08-04 21:11:00 +0530 | [diff] [blame] | 130 | void mdp_disable(void) |
| 131 | { |
Channagoud Kadabi | f248846 | 2012-06-12 15:22:48 +0530 | [diff] [blame] | 132 | if (!target_cont_splash_screen()) |
| 133 | writel(0x00000000, MDP_DSI_VIDEO_EN); |
Aparna Mallavarapu | f712f5e | 2011-08-04 21:11:00 +0530 | [diff] [blame] | 134 | } |
| 135 | |
Channagoud Kadabi | 539ef72 | 2012-03-29 16:02:50 +0530 | [diff] [blame] | 136 | int mdp_dsi_video_off(void) |
Aparna Mallavarapu | f712f5e | 2011-08-04 21:11:00 +0530 | [diff] [blame] | 137 | { |
Channagoud Kadabi | f248846 | 2012-06-12 15:22:48 +0530 | [diff] [blame] | 138 | if (!target_cont_splash_screen()) { |
| 139 | mdp_disable(); |
| 140 | mdelay(60); |
Channagoud Kadabi | f248846 | 2012-06-12 15:22:48 +0530 | [diff] [blame] | 141 | } |
Padmanabhan Komanduru | fa4be75 | 2012-10-08 16:51:56 +0530 | [diff] [blame] | 142 | writel(0x00000000, MDP_INTR_ENABLE); |
| 143 | writel(0x01ffffff, MDP_INTR_CLEAR); |
Channagoud Kadabi | 539ef72 | 2012-03-29 16:02:50 +0530 | [diff] [blame] | 144 | return NO_ERROR; |
Aparna Mallavarapu | f712f5e | 2011-08-04 21:11:00 +0530 | [diff] [blame] | 145 | } |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 146 | |
Channagoud Kadabi | 10189fd | 2012-05-25 13:33:39 +0530 | [diff] [blame] | 147 | int mdp_dsi_cmd_off(void) |
| 148 | { |
Channagoud Kadabi | f248846 | 2012-06-12 15:22:48 +0530 | [diff] [blame] | 149 | if (!target_cont_splash_screen()) { |
| 150 | mdp_dma_off(); |
| 151 | /* |
| 152 | * Allow sometime for the DMA channel to |
| 153 | * stop the data transfer |
| 154 | */ |
| 155 | mdelay(10); |
Channagoud Kadabi | f248846 | 2012-06-12 15:22:48 +0530 | [diff] [blame] | 156 | } |
Padmanabhan Komanduru | fa4be75 | 2012-10-08 16:51:56 +0530 | [diff] [blame] | 157 | writel(0x00000000, MDP_INTR_ENABLE); |
| 158 | writel(0x01ffffff, MDP_INTR_CLEAR); |
Channagoud Kadabi | 10189fd | 2012-05-25 13:33:39 +0530 | [diff] [blame] | 159 | return NO_ERROR; |
| 160 | } |
| 161 | |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 162 | void mdp_set_revision(int rev) |
| 163 | { |
| 164 | mdp_rev = rev; |
| 165 | } |
| 166 | |
| 167 | int mdp_get_revision(void) |
| 168 | { |
| 169 | return mdp_rev; |
| 170 | } |
Channagoud Kadabi | 539ef72 | 2012-03-29 16:02:50 +0530 | [diff] [blame] | 171 | |
Jayant Shekhar | 32397f9 | 2014-03-27 13:30:41 +0530 | [diff] [blame] | 172 | int mdp_dsi_video_on(struct msm_panel_info *pinfo) |
Channagoud Kadabi | 539ef72 | 2012-03-29 16:02:50 +0530 | [diff] [blame] | 173 | { |
| 174 | int ret = 0; |
| 175 | |
| 176 | writel(0x00000001, MDP_DSI_VIDEO_EN); |
| 177 | |
| 178 | return ret; |
| 179 | } |
Channagoud Kadabi | 10189fd | 2012-05-25 13:33:39 +0530 | [diff] [blame] | 180 | |
Jayant Shekhar | 32397f9 | 2014-03-27 13:30:41 +0530 | [diff] [blame] | 181 | int mdp_dma_on(struct msm_panel_info *pinfo) |
Channagoud Kadabi | 10189fd | 2012-05-25 13:33:39 +0530 | [diff] [blame] | 182 | { |
| 183 | int ret = 0; |
Xiaoming Zhou | 8d534dd | 2013-07-29 15:49:19 -0400 | [diff] [blame] | 184 | mdelay(100); |
Channagoud Kadabi | 10189fd | 2012-05-25 13:33:39 +0530 | [diff] [blame] | 185 | writel(0x00000001, MDP_DMA_P_START); |
| 186 | |
| 187 | return ret; |
| 188 | } |
| 189 | |
| 190 | int mdp_dma_off() |
| 191 | { |
| 192 | int ret = 0; |
| 193 | |
Channagoud Kadabi | f248846 | 2012-06-12 15:22:48 +0530 | [diff] [blame] | 194 | if (!target_cont_splash_screen()) |
| 195 | writel(0x00000000, MDP_DMA_P_START); |
Channagoud Kadabi | 10189fd | 2012-05-25 13:33:39 +0530 | [diff] [blame] | 196 | |
| 197 | return ret; |
| 198 | } |
Asaf Penso | 6c58a6b | 2013-07-14 19:57:29 +0300 | [diff] [blame] | 199 | |
| 200 | int mdp_edp_config(struct msm_panel_info *pinfo, struct fbcon_config *fb) |
| 201 | { |
| 202 | return NO_ERROR; |
| 203 | } |
| 204 | |
Jayant Shekhar | 32397f9 | 2014-03-27 13:30:41 +0530 | [diff] [blame] | 205 | int mdp_edp_on(struct msm_panel_info *pinfo) |
Asaf Penso | 6c58a6b | 2013-07-14 19:57:29 +0300 | [diff] [blame] | 206 | { |
| 207 | return NO_ERROR; |
| 208 | } |
| 209 | |
| 210 | int mdp_edp_off(void) |
| 211 | { |
| 212 | return NO_ERROR; |
| 213 | } |
Ajay Singh Parmar | 63c1850 | 2014-07-23 23:37:19 -0700 | [diff] [blame] | 214 | |
Ajay Singh Parmar | 243d82b | 2014-07-23 23:01:44 -0700 | [diff] [blame] | 215 | int mdss_hdmi_config(struct msm_panel_info *pinfo, struct fbcon_config *fb) |
Ajay Singh Parmar | 63c1850 | 2014-07-23 23:37:19 -0700 | [diff] [blame] | 216 | { |
| 217 | return NO_ERROR; |
| 218 | } |
| 219 | |
Ajay Singh Parmar | 243d82b | 2014-07-23 23:01:44 -0700 | [diff] [blame] | 220 | int mdss_hdmi_on(void) |
Ajay Singh Parmar | 63c1850 | 2014-07-23 23:37:19 -0700 | [diff] [blame] | 221 | { |
| 222 | return NO_ERROR; |
| 223 | } |
| 224 | |
Ajay Singh Parmar | 243d82b | 2014-07-23 23:01:44 -0700 | [diff] [blame] | 225 | int mdss_hdmi_off(void) |
Ajay Singh Parmar | 63c1850 | 2014-07-23 23:37:19 -0700 | [diff] [blame] | 226 | { |
| 227 | return NO_ERROR; |
| 228 | } |