Huaibin Yang | cbec39b | 2014-11-07 13:54:38 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved. |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -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 |
| 5 | * are 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 copyright |
| 9 | * notice, this list of conditions and the following disclaimer in |
| 10 | * the documentation and/or other materials provided with the |
| 11 | * distribution. |
| 12 | * * Neither the name of The Linux Foundation 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 19 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 20 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS |
| 23 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
| 24 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 25 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
| 26 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 27 | * SUCH DAMAGE. |
| 28 | */ |
| 29 | |
| 30 | #include <debug.h> |
| 31 | #include <err.h> |
| 32 | #include <smem.h> |
Veera Sundaram Sankaran | 824e6fa | 2014-12-09 11:32:58 -0800 | [diff] [blame] | 33 | #include <clock.h> |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 34 | #include <msm_panel.h> |
Dhaval Patel | 9f61f13 | 2013-07-18 14:45:11 -0700 | [diff] [blame] | 35 | #include <string.h> |
| 36 | #include <stdlib.h> |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 37 | #include <board.h> |
| 38 | #include <mdp5.h> |
Veera Sundaram Sankaran | 824e6fa | 2014-12-09 11:32:58 -0800 | [diff] [blame] | 39 | #include <qtimer.h> |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 40 | #include <platform/gpio.h> |
| 41 | #include <mipi_dsi.h> |
Huaibin Yang | b6fa92b | 2015-01-28 16:21:37 -0800 | [diff] [blame] | 42 | #include <partition_parser.h> |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 43 | |
| 44 | #include "include/display_resource.h" |
| 45 | #include "include/panel.h" |
| 46 | #include "panel_display.h" |
| 47 | #include "gcdb_display.h" |
| 48 | #include "target/display.h" |
Arpita Banerjee | da0c39a | 2013-05-24 16:12:45 -0700 | [diff] [blame] | 49 | #include "gcdb_autopll.h" |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 50 | |
| 51 | /*---------------------------------------------------------------------------*/ |
| 52 | /* static */ |
| 53 | /*---------------------------------------------------------------------------*/ |
| 54 | static struct msm_fb_panel_data panel; |
| 55 | struct panel_struct panelstruct; |
| 56 | static uint8_t display_enable; |
| 57 | static struct mdss_dsi_phy_ctrl dsi_video_mode_phy_db; |
| 58 | |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 59 | /*---------------------------------------------------------------------------*/ |
| 60 | /* Extern */ |
| 61 | /*---------------------------------------------------------------------------*/ |
| 62 | extern int msm_display_init(struct msm_fb_panel_data *pdata); |
| 63 | extern int msm_display_off(); |
| 64 | |
| 65 | static uint32_t panel_backlight_ctrl(uint8_t enable) |
| 66 | { |
Vineet Bajaj | 2244234 | 2015-04-29 16:55:18 +0530 | [diff] [blame] | 67 | uint32_t ret = NO_ERROR; |
| 68 | if (panelstruct.backlightinfo) |
| 69 | ret = target_backlight_ctrl(panelstruct.backlightinfo, enable); |
| 70 | return ret; |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | static uint32_t mdss_dsi_panel_reset(uint8_t enable) |
| 74 | { |
| 75 | uint32_t ret = NO_ERROR; |
Vineet Bajaj | 2244234 | 2015-04-29 16:55:18 +0530 | [diff] [blame] | 76 | if (panelstruct.panelresetseq) |
| 77 | ret = target_panel_reset(enable, panelstruct.panelresetseq, |
| 78 | &panel.panel_info); |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 79 | return ret; |
| 80 | } |
| 81 | |
Arpita Banerjee | da0c39a | 2013-05-24 16:12:45 -0700 | [diff] [blame] | 82 | static uint32_t mdss_dsi_panel_clock(uint8_t enable, |
| 83 | struct msm_panel_info *pinfo) |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 84 | { |
| 85 | uint32_t ret = NO_ERROR; |
| 86 | |
Arpita Banerjee | da0c39a | 2013-05-24 16:12:45 -0700 | [diff] [blame] | 87 | ret = calculate_clock_config(pinfo); |
Huaibin Yang | cbec39b | 2014-11-07 13:54:38 -0800 | [diff] [blame] | 88 | if (ret) |
| 89 | dprintf(CRITICAL, "Clock calculation failed\n"); |
| 90 | else |
| 91 | ret = target_panel_clock(enable, pinfo); |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 92 | |
| 93 | return ret; |
| 94 | } |
| 95 | |
Kuogee Hsieh | 93bcff6 | 2014-08-22 14:02:08 -0700 | [diff] [blame] | 96 | static int mdss_dsi_panel_power(uint8_t enable, |
| 97 | struct msm_panel_info *pinfo) |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 98 | { |
| 99 | int ret = NO_ERROR; |
| 100 | |
| 101 | if (enable) { |
Kuogee Hsieh | 93bcff6 | 2014-08-22 14:02:08 -0700 | [diff] [blame] | 102 | ret = target_ldo_ctrl(enable, pinfo); |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 103 | if (ret) { |
Jayant Shekhar | c9611a9 | 2013-11-20 16:59:27 +0530 | [diff] [blame] | 104 | dprintf(CRITICAL, "LDO control enable failed\n"); |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 105 | return ret; |
| 106 | } |
| 107 | |
| 108 | /* Panel Reset */ |
Jayant Shekhar | c9611a9 | 2013-11-20 16:59:27 +0530 | [diff] [blame] | 109 | if (!panelstruct.paneldata->panel_lp11_init) { |
| 110 | ret = mdss_dsi_panel_reset(enable); |
| 111 | if (ret) { |
| 112 | dprintf(CRITICAL, "panel reset failed\n"); |
| 113 | return ret; |
| 114 | } |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 115 | } |
| 116 | dprintf(SPEW, "Panel power on done\n"); |
| 117 | } else { |
Casey Piper | 1bbd157 | 2013-09-11 16:23:18 -0700 | [diff] [blame] | 118 | /* Disable panel and ldo */ |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 119 | ret = mdss_dsi_panel_reset(enable); |
| 120 | if (ret) { |
Jayant Shekhar | c9611a9 | 2013-11-20 16:59:27 +0530 | [diff] [blame] | 121 | dprintf(CRITICAL, "panel reset disable failed\n"); |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 122 | return ret; |
| 123 | } |
| 124 | |
Kuogee Hsieh | 93bcff6 | 2014-08-22 14:02:08 -0700 | [diff] [blame] | 125 | ret = target_ldo_ctrl(enable, pinfo); |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 126 | if (ret) { |
Jayant Shekhar | c9611a9 | 2013-11-20 16:59:27 +0530 | [diff] [blame] | 127 | dprintf(CRITICAL, "ldo control disable failed\n"); |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 128 | return ret; |
| 129 | } |
| 130 | dprintf(SPEW, "Panel power off done\n"); |
| 131 | } |
| 132 | |
| 133 | return ret; |
| 134 | } |
| 135 | |
Ray Zhang | eb462f6 | 2013-12-03 17:16:08 +0800 | [diff] [blame] | 136 | static int mdss_dsi_panel_pre_init(void) |
Jayant Shekhar | c9611a9 | 2013-11-20 16:59:27 +0530 | [diff] [blame] | 137 | { |
| 138 | int ret = NO_ERROR; |
| 139 | |
Ray Zhang | eb462f6 | 2013-12-03 17:16:08 +0800 | [diff] [blame] | 140 | if (panelstruct.paneldata->panel_lp11_init) { |
| 141 | ret = mdss_dsi_panel_reset(1); |
| 142 | if (ret) { |
| 143 | dprintf(CRITICAL, "panel reset failed\n"); |
| 144 | return ret; |
Jayant Shekhar | c9611a9 | 2013-11-20 16:59:27 +0530 | [diff] [blame] | 145 | } |
Jayant Shekhar | c9611a9 | 2013-11-20 16:59:27 +0530 | [diff] [blame] | 146 | } |
| 147 | |
Ray Zhang | eb462f6 | 2013-12-03 17:16:08 +0800 | [diff] [blame] | 148 | if(panelstruct.paneldata->panel_init_delay) |
| 149 | udelay(panelstruct.paneldata->panel_init_delay); |
| 150 | |
| 151 | dprintf(SPEW, "Panel pre init done\n"); |
Jayant Shekhar | c9611a9 | 2013-11-20 16:59:27 +0530 | [diff] [blame] | 152 | return ret; |
| 153 | } |
| 154 | |
Huaibin Yang | b6fa92b | 2015-01-28 16:21:37 -0800 | [diff] [blame] | 155 | static int mdss_dsi_dfps_get_pll_codes_cal(struct msm_panel_info *pinfo) |
Huaibin Yang | cbec39b | 2014-11-07 13:54:38 -0800 | [diff] [blame] | 156 | { |
| 157 | int ret = NO_ERROR; |
| 158 | uint32_t fps_bak; |
| 159 | uint32_t i; |
| 160 | |
| 161 | fps_bak = pinfo->mipi.frame_rate; |
| 162 | |
| 163 | for (i = 0; i < pinfo->dfps.panel_dfps.frame_rate_cnt; i++) { |
| 164 | int err; |
| 165 | pinfo->mipi.frame_rate = pinfo->dfps.panel_dfps.frame_rate[i]; |
| 166 | |
| 167 | err = mdss_dsi_panel_clock(1, pinfo); |
| 168 | if (!err) { |
Jeevan Shriram | e201466 | 2015-08-03 15:11:27 -0700 | [diff] [blame] | 169 | dprintf(SPEW, "frame_rate=%d, vcorate=%d success!\n", |
| 170 | pinfo->mipi.frame_rate, |
| 171 | pinfo->mipi.dsi_pll_config->vco_clock); |
Huaibin Yang | cbec39b | 2014-11-07 13:54:38 -0800 | [diff] [blame] | 172 | pinfo->dfps.codes_dfps[i].is_valid = 1; |
| 173 | pinfo->dfps.codes_dfps[i].frame_rate = |
| 174 | pinfo->mipi.frame_rate; |
Huaibin Yang | cbec39b | 2014-11-07 13:54:38 -0800 | [diff] [blame] | 175 | pinfo->dfps.codes_dfps[i].clk_rate = |
| 176 | pinfo->mipi.dsi_pll_config->vco_clock; |
| 177 | pinfo->dfps.codes_dfps[i].pll_codes = |
| 178 | pinfo->mipi.pll_codes; |
| 179 | |
| 180 | mdss_dsi_panel_clock(0, pinfo); |
| 181 | } else { |
| 182 | ret = err; |
| 183 | pinfo->dfps.codes_dfps[i].is_valid = 0; |
| 184 | dprintf(CRITICAL, "frame_rate=%d failed!\n", |
| 185 | pinfo->mipi.frame_rate); |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | pinfo->mipi.frame_rate = fps_bak; |
| 190 | |
| 191 | return ret; |
| 192 | } |
| 193 | |
Huaibin Yang | b6fa92b | 2015-01-28 16:21:37 -0800 | [diff] [blame] | 194 | static int mdss_dsi_dfps_get_stored_pll_codes(struct msm_panel_info *pinfo) |
| 195 | { |
| 196 | int ret = NO_ERROR; |
| 197 | int index; |
| 198 | unsigned long long ptn; |
| 199 | uint32_t blocksize; |
| 200 | struct dfps_info *dfps; |
| 201 | |
| 202 | index = partition_get_index("splash"); |
Casey Piper | 69f9568 | 2015-03-30 16:19:45 -0700 | [diff] [blame] | 203 | if (index == INVALID_PTN) { |
| 204 | dprintf(INFO, "%s: splash partition table not found\n", __func__); |
Jeevan Shriram | e201466 | 2015-08-03 15:11:27 -0700 | [diff] [blame] | 205 | ret = ERROR; |
Huaibin Yang | b6fa92b | 2015-01-28 16:21:37 -0800 | [diff] [blame] | 206 | goto splash_err; |
| 207 | } |
| 208 | |
| 209 | ptn = partition_get_offset(index); |
| 210 | if (ptn == 0) { |
| 211 | dprintf(CRITICAL, "ERROR: splash Partition invalid offset\n"); |
| 212 | ret = ERROR; |
| 213 | goto splash_err; |
| 214 | } |
| 215 | |
Channagoud Kadabi | 7f66637 | 2015-02-24 14:37:32 -0800 | [diff] [blame] | 216 | mmc_set_lun(partition_get_lun(index)); |
| 217 | |
Huaibin Yang | b6fa92b | 2015-01-28 16:21:37 -0800 | [diff] [blame] | 218 | blocksize = mmc_get_device_blocksize(); |
| 219 | if (blocksize == 0) { |
| 220 | dprintf(CRITICAL, "ERROR:splash Partition invalid blocksize\n"); |
| 221 | ret = ERROR; |
| 222 | goto splash_err; |
| 223 | } |
| 224 | |
| 225 | dfps = (struct dfps_info *)memalign(CACHE_LINE, ROUNDUP(PAGE_SIZE, |
| 226 | CACHE_LINE)); |
| 227 | if (!dfps) { |
| 228 | dprintf(CRITICAL, "ERROR:splash Partition invalid memory\n"); |
| 229 | ret = ERROR; |
| 230 | goto splash_err; |
| 231 | } |
| 232 | |
| 233 | if (mmc_read(ptn, (uint32_t *) dfps, blocksize)) { |
| 234 | dprintf(CRITICAL, "mmc read splash failure%d\n", PAGE_SIZE); |
| 235 | ret = ERROR; |
| 236 | free(dfps); |
| 237 | goto splash_err; |
| 238 | } |
| 239 | |
| 240 | dprintf(SPEW, "enable=%d cnt=%d\n", dfps->panel_dfps.enabled, |
| 241 | dfps->panel_dfps.frame_rate_cnt); |
| 242 | |
| 243 | if (!dfps->panel_dfps.enabled || dfps->panel_dfps.frame_rate_cnt > |
| 244 | DFPS_MAX_FRAME_RATE) { |
| 245 | ret = ERROR; |
| 246 | free(dfps); |
| 247 | goto splash_err; |
| 248 | } |
| 249 | |
| 250 | pinfo->dfps = *dfps; |
| 251 | free(dfps); |
| 252 | |
| 253 | splash_err: |
| 254 | return ret; |
| 255 | } |
| 256 | |
| 257 | static int mdss_dsi_dfps_store_pll_codes(struct msm_panel_info *pinfo) |
| 258 | { |
| 259 | int ret = NO_ERROR; |
| 260 | int index; |
| 261 | unsigned long long ptn; |
| 262 | |
| 263 | index = partition_get_index("splash"); |
Casey Piper | 69f9568 | 2015-03-30 16:19:45 -0700 | [diff] [blame] | 264 | if (index == INVALID_PTN) { |
| 265 | dprintf(INFO, "%s: splash partition table not found\n", __func__); |
Jeevan Shriram | e201466 | 2015-08-03 15:11:27 -0700 | [diff] [blame] | 266 | ret = ERROR; |
Huaibin Yang | b6fa92b | 2015-01-28 16:21:37 -0800 | [diff] [blame] | 267 | goto store_err; |
| 268 | } |
| 269 | |
| 270 | ptn = partition_get_offset(index); |
| 271 | if (ptn == 0) { |
| 272 | dprintf(CRITICAL, "ERROR: splash Partition invalid offset\n"); |
| 273 | ret = ERROR; |
| 274 | goto store_err; |
| 275 | } |
| 276 | |
Channagoud Kadabi | 7f66637 | 2015-02-24 14:37:32 -0800 | [diff] [blame] | 277 | mmc_set_lun(partition_get_lun(index)); |
| 278 | |
Huaibin Yang | b6fa92b | 2015-01-28 16:21:37 -0800 | [diff] [blame] | 279 | ret = mmc_write(ptn, sizeof(uint32_t), &pinfo->dfps); |
| 280 | if (ret) |
| 281 | dprintf(CRITICAL, "mmc write failed!\n"); |
| 282 | |
| 283 | store_err: |
| 284 | return ret; |
| 285 | } |
| 286 | |
Huaibin Yang | cbec39b | 2014-11-07 13:54:38 -0800 | [diff] [blame] | 287 | static int mdss_dsi_mipi_dfps_config(struct msm_panel_info *pinfo) |
| 288 | { |
| 289 | int ret = NO_ERROR; |
| 290 | |
| 291 | if (!pinfo) |
| 292 | return ERROR; |
| 293 | |
| 294 | if (!pinfo->dfps.panel_dfps.enabled) |
| 295 | goto dfps_done; |
| 296 | |
Huaibin Yang | b6fa92b | 2015-01-28 16:21:37 -0800 | [diff] [blame] | 297 | if (!mdss_dsi_dfps_get_stored_pll_codes(pinfo)) { |
| 298 | dprintf(SPEW, "Found stored PLL codes!\n"); |
| 299 | goto dfps_cal_done; |
| 300 | } |
Huaibin Yang | cbec39b | 2014-11-07 13:54:38 -0800 | [diff] [blame] | 301 | |
Huaibin Yang | b6fa92b | 2015-01-28 16:21:37 -0800 | [diff] [blame] | 302 | ret = mdss_dsi_dfps_get_pll_codes_cal(pinfo); |
| 303 | if (ret) { |
| 304 | dprintf(CRITICAL, "Cannot cal pll codes!\n"); |
| 305 | goto dfps_done; |
| 306 | } else { |
| 307 | dprintf(SPEW, "Calibrate all pll codes!\n"); |
| 308 | } |
| 309 | |
| 310 | ret = mdss_dsi_dfps_store_pll_codes(pinfo); |
| 311 | if (ret) |
| 312 | dprintf(CRITICAL, "Cannot store pll codes!\n"); |
| 313 | |
| 314 | dfps_cal_done: |
Huaibin Yang | b9f15e5 | 2015-01-22 10:34:47 -0800 | [diff] [blame] | 315 | if (pinfo->dfps.dfps_fb_base) |
| 316 | memcpy(pinfo->dfps.dfps_fb_base, &pinfo->dfps, |
| 317 | sizeof(struct dfps_info)); |
Huaibin Yang | cbec39b | 2014-11-07 13:54:38 -0800 | [diff] [blame] | 318 | dfps_done: |
| 319 | return ret; |
| 320 | } |
| 321 | |
Casey Piper | 1bbd157 | 2013-09-11 16:23:18 -0700 | [diff] [blame] | 322 | static int mdss_dsi_bl_enable(uint8_t enable) |
| 323 | { |
| 324 | int ret = NO_ERROR; |
| 325 | |
| 326 | ret = panel_backlight_ctrl(enable); |
| 327 | if (ret) |
| 328 | dprintf(CRITICAL, "Backlight %s failed\n", enable ? "enable" : |
| 329 | "disable"); |
| 330 | return ret; |
| 331 | } |
| 332 | |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 333 | static void mdss_edp_panel_init(struct msm_panel_info *pinfo) |
| 334 | { |
| 335 | return target_edp_panel_init(pinfo); |
| 336 | } |
| 337 | |
| 338 | static uint32_t mdss_edp_panel_clock(uint8_t enable, |
| 339 | struct msm_panel_info *pinfo) |
| 340 | { |
| 341 | return target_edp_panel_clock(enable, pinfo); |
| 342 | } |
| 343 | |
| 344 | static uint32_t mdss_edp_panel_enable(void) |
| 345 | { |
| 346 | return target_edp_panel_enable(); |
| 347 | } |
| 348 | |
| 349 | static uint32_t mdss_edp_panel_disable(void) |
| 350 | { |
| 351 | return target_edp_panel_disable(); |
| 352 | } |
| 353 | |
Kuogee Hsieh | 93bcff6 | 2014-08-22 14:02:08 -0700 | [diff] [blame] | 354 | static int mdss_edp_panel_power(uint8_t enable, |
| 355 | struct msm_panel_info *pinfo) |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 356 | { |
Casey Piper | c574e08 | 2013-09-05 14:54:42 -0700 | [diff] [blame] | 357 | int ret = NO_ERROR; |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 358 | |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 359 | if (enable) { |
Kuogee Hsieh | 93bcff6 | 2014-08-22 14:02:08 -0700 | [diff] [blame] | 360 | ret = target_ldo_ctrl(enable, pinfo); |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 361 | if (ret) { |
| 362 | dprintf(CRITICAL, "LDO control enable failed\n"); |
| 363 | return ret; |
| 364 | } |
| 365 | |
| 366 | ret = mdss_edp_panel_enable(); |
| 367 | if (ret) { |
| 368 | dprintf(CRITICAL, "%s: panel enable failed\n", __func__); |
| 369 | return ret; |
| 370 | } |
| 371 | dprintf(SPEW, "EDP Panel power on done\n"); |
| 372 | } else { |
| 373 | /* Disable panel and ldo */ |
| 374 | ret = mdss_edp_panel_disable(); |
| 375 | if (ret) { |
| 376 | dprintf(CRITICAL, "%s: panel disable failed\n", __func__); |
| 377 | return ret; |
| 378 | } |
| 379 | |
Kuogee Hsieh | 93bcff6 | 2014-08-22 14:02:08 -0700 | [diff] [blame] | 380 | ret = target_ldo_ctrl(enable, pinfo); |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 381 | if (ret) { |
| 382 | dprintf(CRITICAL, "%s: ldo control disable failed\n", __func__); |
| 383 | return ret; |
| 384 | } |
| 385 | dprintf(SPEW, "EDP Panel power off done\n"); |
| 386 | } |
| 387 | |
| 388 | return ret; |
| 389 | } |
| 390 | |
| 391 | static int mdss_edp_bl_enable(uint8_t enable) |
| 392 | { |
| 393 | int ret = NO_ERROR; |
| 394 | |
| 395 | ret = target_edp_bl_ctrl(enable); |
| 396 | if (ret) |
| 397 | dprintf(CRITICAL, "Backlight %s failed\n", enable ? "enable" : |
| 398 | "disable"); |
| 399 | return ret; |
| 400 | } |
| 401 | |
Vineet Bajaj | c227246 | 2015-05-07 17:35:03 +0530 | [diff] [blame] | 402 | static int mdss_dsi2HDMI_config (struct msm_panel_info *pinfo) |
| 403 | { |
| 404 | return target_display_dsi2hdmi_config(pinfo); |
| 405 | } |
| 406 | |
Padmanabhan Komanduru | bccbcdc | 2015-06-30 16:19:24 +0530 | [diff] [blame] | 407 | struct panel_struct mdss_dsi_get_panel_data(void) |
| 408 | { |
| 409 | return panelstruct; |
| 410 | } |
| 411 | |
Padmanabhan Komanduru | dc0eaca | 2015-08-28 16:29:59 +0530 | [diff] [blame] | 412 | static void mdss_dsi_check_swap_status(void) |
| 413 | { |
| 414 | char *panel_dest, *dsi_controller; |
| 415 | struct oem_panel_data *oem_data = mdss_dsi_get_oem_data_ptr(); |
| 416 | |
| 417 | if (!oem_data->swap_dsi_ctrl) |
| 418 | return; |
| 419 | |
| 420 | if (panelstruct.paneldata->panel_operating_mode & |
| 421 | (SPLIT_DISPLAY_FLAG | DUAL_DSI_FLAG)) { |
| 422 | dprintf(CRITICAL, "DSI swap invalid for split DSI panel!\n"); |
| 423 | return; |
| 424 | } |
| 425 | |
| 426 | /* Swap the panel destination and use appropriate PLL */ |
| 427 | if (!strcmp(panelstruct.paneldata->panel_destination, "DISPLAY_1")) { |
| 428 | panel_dest = "DISPLAY_2"; |
| 429 | dsi_controller = "dsi:1:"; |
| 430 | panelstruct.paneldata->panel_operating_mode |= USE_DSI1_PLL_FLAG; |
| 431 | } else { |
| 432 | panel_dest = "DISPLAY_1"; |
| 433 | dsi_controller = "dsi:0:"; |
| 434 | panelstruct.paneldata->panel_operating_mode &= ~USE_DSI1_PLL_FLAG; |
| 435 | } |
| 436 | panelstruct.paneldata->panel_destination = panel_dest; |
| 437 | panelstruct.paneldata->panel_controller = dsi_controller; |
| 438 | } |
| 439 | |
Padmanabhan Komanduru | 75f5b3b | 2015-07-06 18:28:51 +0530 | [diff] [blame] | 440 | static void mdss_dsi_set_pll_src(void) |
| 441 | { |
| 442 | struct oem_panel_data *oem_data = mdss_dsi_get_oem_data_ptr(); |
| 443 | |
Padmanabhan Komanduru | aa1e683 | 2015-08-28 14:55:24 +0530 | [diff] [blame] | 444 | /* Set PLL_SRC to PLL1 for non dual-DSI cases only */ |
| 445 | if (!is_dsi_config_dual() && |
| 446 | (panelstruct.paneldata->panel_operating_mode & |
| 447 | USE_DSI1_PLL_FLAG)) |
Padmanabhan Komanduru | 75f5b3b | 2015-07-06 18:28:51 +0530 | [diff] [blame] | 448 | oem_data->dsi_pll_src = DSI_PLL1; |
| 449 | |
Padmanabhan Komanduru | aa1e683 | 2015-08-28 14:55:24 +0530 | [diff] [blame] | 450 | if (is_dsi_config_dual()) { |
Padmanabhan Komanduru | 75f5b3b | 2015-07-06 18:28:51 +0530 | [diff] [blame] | 451 | if (oem_data->dsi_pll_src != DSI_PLL_DEFAULT) { |
| 452 | dprintf(CRITICAL, "Dual DSI config detected!" |
| 453 | "Use default PLL\n"); |
| 454 | oem_data->dsi_pll_src = DSI_PLL_DEFAULT; |
| 455 | } |
Padmanabhan Komanduru | aa1e683 | 2015-08-28 14:55:24 +0530 | [diff] [blame] | 456 | } else if (is_dsi_config_split()) { |
Padmanabhan Komanduru | 75f5b3b | 2015-07-06 18:28:51 +0530 | [diff] [blame] | 457 | if((dsi_video_mode_phy_db.pll_type != DSI_PLL_TYPE_THULIUM) |
| 458 | && (oem_data->dsi_pll_src == DSI_PLL1)) { |
| 459 | dprintf(CRITICAL, "Split DSI on 28nm/20nm!" |
| 460 | "Use DSI PLL0\n"); |
| 461 | oem_data->dsi_pll_src = DSI_PLL0; |
| 462 | } |
| 463 | } else { |
| 464 | if ((dsi_video_mode_phy_db.pll_type != DSI_PLL_TYPE_THULIUM) |
| 465 | && !strcmp(panelstruct.paneldata->panel_destination, |
| 466 | "DISPLAY_1") && (oem_data->dsi_pll_src == DSI_PLL1)) { |
| 467 | dprintf(CRITICAL, "Single DSI with DSI-0 on 28nm/20nm!" |
| 468 | "Use DSI PLL0\n"); |
| 469 | oem_data->dsi_pll_src = DSI_PLL0; |
| 470 | } |
| 471 | } |
| 472 | |
| 473 | if (oem_data->dsi_pll_src == DSI_PLL1) |
| 474 | panelstruct.paneldata->panel_operating_mode |= |
| 475 | USE_DSI1_PLL_FLAG; |
Padmanabhan Komanduru | aa1e683 | 2015-08-28 14:55:24 +0530 | [diff] [blame] | 476 | else if (oem_data->dsi_pll_src == DSI_PLL0) |
Padmanabhan Komanduru | 75f5b3b | 2015-07-06 18:28:51 +0530 | [diff] [blame] | 477 | panelstruct.paneldata->panel_operating_mode &= |
| 478 | ~USE_DSI1_PLL_FLAG; |
Padmanabhan Komanduru | 75f5b3b | 2015-07-06 18:28:51 +0530 | [diff] [blame] | 479 | } |
| 480 | |
Dhaval Patel | d96d092 | 2015-10-20 16:06:21 -0700 | [diff] [blame] | 481 | static int update_dsi_display_config() |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 482 | { |
| 483 | int ret = NO_ERROR; |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 484 | |
Ujwal Patel | 41a665a | 2015-07-17 13:51:30 -0700 | [diff] [blame] | 485 | if ((panel.panel_info.lm_split[0] > 0) && |
| 486 | (panel.panel_info.lm_split[1] > 0)) |
| 487 | panelstruct.paneldata->panel_operating_mode |= DUAL_PIPE_FLAG; |
| 488 | |
| 489 | if (panelstruct.paneldata->panel_operating_mode & DUAL_PIPE_FLAG) { |
| 490 | if ((panel.panel_info.lm_split[0] <= 0) || |
| 491 | (panel.panel_info.lm_split[1] <= 0)) { |
| 492 | panel.panel_info.lm_split[0] = |
| 493 | panelstruct.panelres->panel_width / 2; |
| 494 | panel.panel_info.lm_split[1] = |
| 495 | panel.panel_info.lm_split[0]; |
| 496 | } |
| 497 | } |
| 498 | |
Ujwal Patel | 5c3227b | 2015-08-12 14:48:02 -0700 | [diff] [blame] | 499 | if (panelstruct.config && panelstruct.config->use_pingpong_split) |
| 500 | panelstruct.paneldata->panel_operating_mode |= DST_SPLIT_FLAG; |
| 501 | |
| 502 | if ((panelstruct.paneldata->panel_operating_mode & DUAL_PIPE_FLAG) && |
| 503 | (panelstruct.paneldata->panel_operating_mode & DST_SPLIT_FLAG)) { |
| 504 | dprintf(CRITICAL, "DUAL_PIPE_FLAG and DST_SPLIT_FLAG cannot be selected togather\n"); |
| 505 | ret = ERROR; |
Ujwal Patel | 5c3227b | 2015-08-12 14:48:02 -0700 | [diff] [blame] | 506 | } |
| 507 | |
Dhaval Patel | d96d092 | 2015-10-20 16:06:21 -0700 | [diff] [blame] | 508 | return ret; |
| 509 | } |
| 510 | |
| 511 | int gcdb_display_init(const char *panel_name, uint32_t rev, void *base) |
| 512 | { |
| 513 | int ret = NO_ERROR; |
| 514 | int pan_type; |
| 515 | |
| 516 | dsi_video_mode_phy_db.pll_type = DSI_PLL_TYPE_28NM; |
| 517 | pan_type = oem_panel_select(panel_name, &panelstruct, &(panel.panel_info), |
| 518 | &dsi_video_mode_phy_db); |
| 519 | |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 520 | if (pan_type == PANEL_TYPE_DSI) { |
Dhaval Patel | d96d092 | 2015-10-20 16:06:21 -0700 | [diff] [blame] | 521 | if (update_dsi_display_config()) |
| 522 | goto error_gcdb_display_init; |
Dhaval Patel | 7709c41 | 2015-05-12 10:09:41 -0700 | [diff] [blame] | 523 | target_dsi_phy_config(&dsi_video_mode_phy_db); |
Padmanabhan Komanduru | dc0eaca | 2015-08-28 16:29:59 +0530 | [diff] [blame] | 524 | mdss_dsi_check_swap_status(); |
Padmanabhan Komanduru | 75f5b3b | 2015-07-06 18:28:51 +0530 | [diff] [blame] | 525 | mdss_dsi_set_pll_src(); |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 526 | if (dsi_panel_init(&(panel.panel_info), &panelstruct)) { |
| 527 | dprintf(CRITICAL, "DSI panel init failed!\n"); |
| 528 | ret = ERROR; |
| 529 | goto error_gcdb_display_init; |
| 530 | } |
| 531 | |
| 532 | panel.panel_info.mipi.mdss_dsi_phy_db = &dsi_video_mode_phy_db; |
| 533 | panel.pll_clk_func = mdss_dsi_panel_clock; |
Huaibin Yang | cbec39b | 2014-11-07 13:54:38 -0800 | [diff] [blame] | 534 | panel.dfps_func = mdss_dsi_mipi_dfps_config; |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 535 | panel.power_func = mdss_dsi_panel_power; |
| 536 | panel.pre_init_func = mdss_dsi_panel_pre_init; |
| 537 | panel.bl_func = mdss_dsi_bl_enable; |
Vineet Bajaj | c227246 | 2015-05-07 17:35:03 +0530 | [diff] [blame] | 538 | panel.dsi2HDMI_config = mdss_dsi2HDMI_config; |
Huaibin Yang | b9f15e5 | 2015-01-22 10:34:47 -0800 | [diff] [blame] | 539 | /* |
| 540 | * If dfps enabled, reserve fb memory to store pll |
| 541 | * codes and pass pll codes values to kernel. |
| 542 | */ |
| 543 | if (panel.panel_info.dfps.panel_dfps.enabled) { |
| 544 | panel.panel_info.dfps.dfps_fb_base = base; |
| 545 | base += DFPS_PLL_CODES_SIZE; |
Jeevan Shriram | e201466 | 2015-08-03 15:11:27 -0700 | [diff] [blame] | 546 | dprintf(SPEW, "dfps base=0x%p,d, fb_base=0x%p!\n", |
| 547 | panel.panel_info.dfps.dfps_fb_base, base); |
Huaibin Yang | b9f15e5 | 2015-01-22 10:34:47 -0800 | [diff] [blame] | 548 | } |
| 549 | |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 550 | panel.fb.base = base; |
| 551 | panel.fb.width = panel.panel_info.xres; |
| 552 | panel.fb.height = panel.panel_info.yres; |
| 553 | panel.fb.stride = panel.panel_info.xres; |
| 554 | panel.fb.bpp = panel.panel_info.bpp; |
| 555 | panel.fb.format = panel.panel_info.mipi.dst_format; |
| 556 | } else if (pan_type == PANEL_TYPE_EDP) { |
| 557 | mdss_edp_panel_init(&(panel.panel_info)); |
| 558 | /* prepare func is set up at edp_panel_init */ |
| 559 | panel.clk_func = mdss_edp_panel_clock; |
| 560 | panel.power_func = mdss_edp_panel_power; |
| 561 | panel.bl_func = mdss_edp_bl_enable; |
| 562 | panel.fb.format = FB_FORMAT_RGB888; |
| 563 | } else { |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 564 | dprintf(CRITICAL, "Target panel init not found!\n"); |
Casey Piper | c574e08 | 2013-09-05 14:54:42 -0700 | [diff] [blame] | 565 | ret = ERR_NOT_SUPPORTED; |
| 566 | goto error_gcdb_display_init; |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 567 | } |
| 568 | |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 569 | panel.fb.base = base; |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 570 | panel.mdp_rev = rev; |
| 571 | |
Casey Piper | c574e08 | 2013-09-05 14:54:42 -0700 | [diff] [blame] | 572 | ret = msm_display_init(&panel); |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 573 | |
Casey Piper | c574e08 | 2013-09-05 14:54:42 -0700 | [diff] [blame] | 574 | error_gcdb_display_init: |
| 575 | display_enable = ret ? 0 : 1; |
| 576 | return ret; |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 577 | } |
| 578 | |
| 579 | void gcdb_display_shutdown(void) |
| 580 | { |
| 581 | if (display_enable) |
| 582 | msm_display_off(); |
| 583 | } |