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) { |
| 169 | pinfo->dfps.codes_dfps[i].is_valid = 1; |
| 170 | pinfo->dfps.codes_dfps[i].frame_rate = |
| 171 | pinfo->mipi.frame_rate; |
| 172 | pinfo->dfps.codes_dfps[i].frame_rate = |
| 173 | pinfo->mipi.frame_rate; |
| 174 | pinfo->dfps.codes_dfps[i].clk_rate = |
| 175 | pinfo->mipi.dsi_pll_config->vco_clock; |
| 176 | pinfo->dfps.codes_dfps[i].pll_codes = |
| 177 | pinfo->mipi.pll_codes; |
| 178 | |
| 179 | mdss_dsi_panel_clock(0, pinfo); |
| 180 | } else { |
| 181 | ret = err; |
| 182 | pinfo->dfps.codes_dfps[i].is_valid = 0; |
| 183 | dprintf(CRITICAL, "frame_rate=%d failed!\n", |
| 184 | pinfo->mipi.frame_rate); |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | pinfo->mipi.frame_rate = fps_bak; |
| 189 | |
| 190 | return ret; |
| 191 | } |
| 192 | |
Huaibin Yang | b6fa92b | 2015-01-28 16:21:37 -0800 | [diff] [blame] | 193 | static int mdss_dsi_dfps_get_stored_pll_codes(struct msm_panel_info *pinfo) |
| 194 | { |
| 195 | int ret = NO_ERROR; |
| 196 | int index; |
| 197 | unsigned long long ptn; |
| 198 | uint32_t blocksize; |
| 199 | struct dfps_info *dfps; |
| 200 | |
| 201 | index = partition_get_index("splash"); |
Casey Piper | 69f9568 | 2015-03-30 16:19:45 -0700 | [diff] [blame] | 202 | if (index == INVALID_PTN) { |
| 203 | dprintf(INFO, "%s: splash partition table not found\n", __func__); |
| 204 | ret = NO_ERROR; |
Huaibin Yang | b6fa92b | 2015-01-28 16:21:37 -0800 | [diff] [blame] | 205 | goto splash_err; |
| 206 | } |
| 207 | |
| 208 | ptn = partition_get_offset(index); |
| 209 | if (ptn == 0) { |
| 210 | dprintf(CRITICAL, "ERROR: splash Partition invalid offset\n"); |
| 211 | ret = ERROR; |
| 212 | goto splash_err; |
| 213 | } |
| 214 | |
Channagoud Kadabi | 7f66637 | 2015-02-24 14:37:32 -0800 | [diff] [blame] | 215 | mmc_set_lun(partition_get_lun(index)); |
| 216 | |
Huaibin Yang | b6fa92b | 2015-01-28 16:21:37 -0800 | [diff] [blame] | 217 | blocksize = mmc_get_device_blocksize(); |
| 218 | if (blocksize == 0) { |
| 219 | dprintf(CRITICAL, "ERROR:splash Partition invalid blocksize\n"); |
| 220 | ret = ERROR; |
| 221 | goto splash_err; |
| 222 | } |
| 223 | |
| 224 | dfps = (struct dfps_info *)memalign(CACHE_LINE, ROUNDUP(PAGE_SIZE, |
| 225 | CACHE_LINE)); |
| 226 | if (!dfps) { |
| 227 | dprintf(CRITICAL, "ERROR:splash Partition invalid memory\n"); |
| 228 | ret = ERROR; |
| 229 | goto splash_err; |
| 230 | } |
| 231 | |
| 232 | if (mmc_read(ptn, (uint32_t *) dfps, blocksize)) { |
| 233 | dprintf(CRITICAL, "mmc read splash failure%d\n", PAGE_SIZE); |
| 234 | ret = ERROR; |
| 235 | free(dfps); |
| 236 | goto splash_err; |
| 237 | } |
| 238 | |
| 239 | dprintf(SPEW, "enable=%d cnt=%d\n", dfps->panel_dfps.enabled, |
| 240 | dfps->panel_dfps.frame_rate_cnt); |
| 241 | |
| 242 | if (!dfps->panel_dfps.enabled || dfps->panel_dfps.frame_rate_cnt > |
| 243 | DFPS_MAX_FRAME_RATE) { |
| 244 | ret = ERROR; |
| 245 | free(dfps); |
| 246 | goto splash_err; |
| 247 | } |
| 248 | |
| 249 | pinfo->dfps = *dfps; |
| 250 | free(dfps); |
| 251 | |
| 252 | splash_err: |
| 253 | return ret; |
| 254 | } |
| 255 | |
| 256 | static int mdss_dsi_dfps_store_pll_codes(struct msm_panel_info *pinfo) |
| 257 | { |
| 258 | int ret = NO_ERROR; |
| 259 | int index; |
| 260 | unsigned long long ptn; |
| 261 | |
| 262 | index = partition_get_index("splash"); |
Casey Piper | 69f9568 | 2015-03-30 16:19:45 -0700 | [diff] [blame] | 263 | if (index == INVALID_PTN) { |
| 264 | dprintf(INFO, "%s: splash partition table not found\n", __func__); |
| 265 | ret = NO_ERROR; |
Huaibin Yang | b6fa92b | 2015-01-28 16:21:37 -0800 | [diff] [blame] | 266 | goto store_err; |
| 267 | } |
| 268 | |
| 269 | ptn = partition_get_offset(index); |
| 270 | if (ptn == 0) { |
| 271 | dprintf(CRITICAL, "ERROR: splash Partition invalid offset\n"); |
| 272 | ret = ERROR; |
| 273 | goto store_err; |
| 274 | } |
| 275 | |
Channagoud Kadabi | 7f66637 | 2015-02-24 14:37:32 -0800 | [diff] [blame] | 276 | mmc_set_lun(partition_get_lun(index)); |
| 277 | |
Huaibin Yang | b6fa92b | 2015-01-28 16:21:37 -0800 | [diff] [blame] | 278 | ret = mmc_write(ptn, sizeof(uint32_t), &pinfo->dfps); |
| 279 | if (ret) |
| 280 | dprintf(CRITICAL, "mmc write failed!\n"); |
| 281 | |
| 282 | store_err: |
| 283 | return ret; |
| 284 | } |
| 285 | |
Huaibin Yang | cbec39b | 2014-11-07 13:54:38 -0800 | [diff] [blame] | 286 | static int mdss_dsi_mipi_dfps_config(struct msm_panel_info *pinfo) |
| 287 | { |
| 288 | int ret = NO_ERROR; |
| 289 | |
| 290 | if (!pinfo) |
| 291 | return ERROR; |
| 292 | |
| 293 | if (!pinfo->dfps.panel_dfps.enabled) |
| 294 | goto dfps_done; |
| 295 | |
Huaibin Yang | b6fa92b | 2015-01-28 16:21:37 -0800 | [diff] [blame] | 296 | if (!mdss_dsi_dfps_get_stored_pll_codes(pinfo)) { |
| 297 | dprintf(SPEW, "Found stored PLL codes!\n"); |
| 298 | goto dfps_cal_done; |
| 299 | } |
Huaibin Yang | cbec39b | 2014-11-07 13:54:38 -0800 | [diff] [blame] | 300 | |
Huaibin Yang | b6fa92b | 2015-01-28 16:21:37 -0800 | [diff] [blame] | 301 | ret = mdss_dsi_dfps_get_pll_codes_cal(pinfo); |
| 302 | if (ret) { |
| 303 | dprintf(CRITICAL, "Cannot cal pll codes!\n"); |
| 304 | goto dfps_done; |
| 305 | } else { |
| 306 | dprintf(SPEW, "Calibrate all pll codes!\n"); |
| 307 | } |
| 308 | |
| 309 | ret = mdss_dsi_dfps_store_pll_codes(pinfo); |
| 310 | if (ret) |
| 311 | dprintf(CRITICAL, "Cannot store pll codes!\n"); |
| 312 | |
| 313 | dfps_cal_done: |
Huaibin Yang | b9f15e5 | 2015-01-22 10:34:47 -0800 | [diff] [blame] | 314 | if (pinfo->dfps.dfps_fb_base) |
| 315 | memcpy(pinfo->dfps.dfps_fb_base, &pinfo->dfps, |
| 316 | sizeof(struct dfps_info)); |
Huaibin Yang | cbec39b | 2014-11-07 13:54:38 -0800 | [diff] [blame] | 317 | dfps_done: |
| 318 | return ret; |
| 319 | } |
| 320 | |
Casey Piper | 1bbd157 | 2013-09-11 16:23:18 -0700 | [diff] [blame] | 321 | static int mdss_dsi_bl_enable(uint8_t enable) |
| 322 | { |
| 323 | int ret = NO_ERROR; |
| 324 | |
| 325 | ret = panel_backlight_ctrl(enable); |
| 326 | if (ret) |
| 327 | dprintf(CRITICAL, "Backlight %s failed\n", enable ? "enable" : |
| 328 | "disable"); |
| 329 | return ret; |
| 330 | } |
| 331 | |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 332 | static void mdss_edp_panel_init(struct msm_panel_info *pinfo) |
| 333 | { |
| 334 | return target_edp_panel_init(pinfo); |
| 335 | } |
| 336 | |
| 337 | static uint32_t mdss_edp_panel_clock(uint8_t enable, |
| 338 | struct msm_panel_info *pinfo) |
| 339 | { |
| 340 | return target_edp_panel_clock(enable, pinfo); |
| 341 | } |
| 342 | |
| 343 | static uint32_t mdss_edp_panel_enable(void) |
| 344 | { |
| 345 | return target_edp_panel_enable(); |
| 346 | } |
| 347 | |
| 348 | static uint32_t mdss_edp_panel_disable(void) |
| 349 | { |
| 350 | return target_edp_panel_disable(); |
| 351 | } |
| 352 | |
Kuogee Hsieh | 93bcff6 | 2014-08-22 14:02:08 -0700 | [diff] [blame] | 353 | static int mdss_edp_panel_power(uint8_t enable, |
| 354 | struct msm_panel_info *pinfo) |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 355 | { |
Casey Piper | c574e08 | 2013-09-05 14:54:42 -0700 | [diff] [blame] | 356 | int ret = NO_ERROR; |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 357 | |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 358 | if (enable) { |
Kuogee Hsieh | 93bcff6 | 2014-08-22 14:02:08 -0700 | [diff] [blame] | 359 | ret = target_ldo_ctrl(enable, pinfo); |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 360 | if (ret) { |
| 361 | dprintf(CRITICAL, "LDO control enable failed\n"); |
| 362 | return ret; |
| 363 | } |
| 364 | |
| 365 | ret = mdss_edp_panel_enable(); |
| 366 | if (ret) { |
| 367 | dprintf(CRITICAL, "%s: panel enable failed\n", __func__); |
| 368 | return ret; |
| 369 | } |
| 370 | dprintf(SPEW, "EDP Panel power on done\n"); |
| 371 | } else { |
| 372 | /* Disable panel and ldo */ |
| 373 | ret = mdss_edp_panel_disable(); |
| 374 | if (ret) { |
| 375 | dprintf(CRITICAL, "%s: panel disable failed\n", __func__); |
| 376 | return ret; |
| 377 | } |
| 378 | |
Kuogee Hsieh | 93bcff6 | 2014-08-22 14:02:08 -0700 | [diff] [blame] | 379 | ret = target_ldo_ctrl(enable, pinfo); |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 380 | if (ret) { |
| 381 | dprintf(CRITICAL, "%s: ldo control disable failed\n", __func__); |
| 382 | return ret; |
| 383 | } |
| 384 | dprintf(SPEW, "EDP Panel power off done\n"); |
| 385 | } |
| 386 | |
| 387 | return ret; |
| 388 | } |
| 389 | |
| 390 | static int mdss_edp_bl_enable(uint8_t enable) |
| 391 | { |
| 392 | int ret = NO_ERROR; |
| 393 | |
| 394 | ret = target_edp_bl_ctrl(enable); |
| 395 | if (ret) |
| 396 | dprintf(CRITICAL, "Backlight %s failed\n", enable ? "enable" : |
| 397 | "disable"); |
| 398 | return ret; |
| 399 | } |
| 400 | |
Vineet Bajaj | c227246 | 2015-05-07 17:35:03 +0530 | [diff] [blame] | 401 | static int mdss_dsi2HDMI_config (struct msm_panel_info *pinfo) |
| 402 | { |
| 403 | return target_display_dsi2hdmi_config(pinfo); |
| 404 | } |
| 405 | |
Padmanabhan Komanduru | bccbcdc | 2015-06-30 16:19:24 +0530 | [diff] [blame] | 406 | struct panel_struct mdss_dsi_get_panel_data(void) |
| 407 | { |
| 408 | return panelstruct; |
| 409 | } |
| 410 | |
Padmanabhan Komanduru | 75f5b3b | 2015-07-06 18:28:51 +0530 | [diff] [blame^] | 411 | static void mdss_dsi_set_pll_src(void) |
| 412 | { |
| 413 | struct oem_panel_data *oem_data = mdss_dsi_get_oem_data_ptr(); |
| 414 | |
| 415 | if (panelstruct.paneldata->panel_operating_mode & USE_DSI1_PLL_FLAG) |
| 416 | oem_data->dsi_pll_src = DSI_PLL1; |
| 417 | |
| 418 | if (strcmp(oem_data->sec_panel, "")) { |
| 419 | if (oem_data->dsi_pll_src != DSI_PLL_DEFAULT) { |
| 420 | dprintf(CRITICAL, "Dual DSI config detected!" |
| 421 | "Use default PLL\n"); |
| 422 | oem_data->dsi_pll_src = DSI_PLL_DEFAULT; |
| 423 | } |
| 424 | } else if (panelstruct.paneldata->slave_panel_node_id) { |
| 425 | if((dsi_video_mode_phy_db.pll_type != DSI_PLL_TYPE_THULIUM) |
| 426 | && (oem_data->dsi_pll_src == DSI_PLL1)) { |
| 427 | dprintf(CRITICAL, "Split DSI on 28nm/20nm!" |
| 428 | "Use DSI PLL0\n"); |
| 429 | oem_data->dsi_pll_src = DSI_PLL0; |
| 430 | } |
| 431 | } else { |
| 432 | if ((dsi_video_mode_phy_db.pll_type != DSI_PLL_TYPE_THULIUM) |
| 433 | && !strcmp(panelstruct.paneldata->panel_destination, |
| 434 | "DISPLAY_1") && (oem_data->dsi_pll_src == DSI_PLL1)) { |
| 435 | dprintf(CRITICAL, "Single DSI with DSI-0 on 28nm/20nm!" |
| 436 | "Use DSI PLL0\n"); |
| 437 | oem_data->dsi_pll_src = DSI_PLL0; |
| 438 | } |
| 439 | } |
| 440 | |
| 441 | if (oem_data->dsi_pll_src == DSI_PLL1) |
| 442 | panelstruct.paneldata->panel_operating_mode |= |
| 443 | USE_DSI1_PLL_FLAG; |
| 444 | else |
| 445 | panelstruct.paneldata->panel_operating_mode &= |
| 446 | ~USE_DSI1_PLL_FLAG; |
| 447 | |
| 448 | } |
| 449 | |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 450 | int gcdb_display_init(const char *panel_name, uint32_t rev, void *base) |
| 451 | { |
| 452 | int ret = NO_ERROR; |
| 453 | int pan_type; |
| 454 | |
Dhaval Patel | 8b9a582 | 2015-03-16 13:01:26 -0700 | [diff] [blame] | 455 | dsi_video_mode_phy_db.pll_type = DSI_PLL_TYPE_28NM; |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 456 | pan_type = oem_panel_select(panel_name, &panelstruct, &(panel.panel_info), |
| 457 | &dsi_video_mode_phy_db); |
| 458 | |
| 459 | if (pan_type == PANEL_TYPE_DSI) { |
Dhaval Patel | 7709c41 | 2015-05-12 10:09:41 -0700 | [diff] [blame] | 460 | target_dsi_phy_config(&dsi_video_mode_phy_db); |
Padmanabhan Komanduru | 75f5b3b | 2015-07-06 18:28:51 +0530 | [diff] [blame^] | 461 | mdss_dsi_set_pll_src(); |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 462 | if (dsi_panel_init(&(panel.panel_info), &panelstruct)) { |
| 463 | dprintf(CRITICAL, "DSI panel init failed!\n"); |
| 464 | ret = ERROR; |
| 465 | goto error_gcdb_display_init; |
| 466 | } |
| 467 | |
| 468 | panel.panel_info.mipi.mdss_dsi_phy_db = &dsi_video_mode_phy_db; |
| 469 | panel.pll_clk_func = mdss_dsi_panel_clock; |
Huaibin Yang | cbec39b | 2014-11-07 13:54:38 -0800 | [diff] [blame] | 470 | panel.dfps_func = mdss_dsi_mipi_dfps_config; |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 471 | panel.power_func = mdss_dsi_panel_power; |
| 472 | panel.pre_init_func = mdss_dsi_panel_pre_init; |
| 473 | panel.bl_func = mdss_dsi_bl_enable; |
Vineet Bajaj | c227246 | 2015-05-07 17:35:03 +0530 | [diff] [blame] | 474 | panel.dsi2HDMI_config = mdss_dsi2HDMI_config; |
Huaibin Yang | b9f15e5 | 2015-01-22 10:34:47 -0800 | [diff] [blame] | 475 | /* |
| 476 | * If dfps enabled, reserve fb memory to store pll |
| 477 | * codes and pass pll codes values to kernel. |
| 478 | */ |
| 479 | if (panel.panel_info.dfps.panel_dfps.enabled) { |
| 480 | panel.panel_info.dfps.dfps_fb_base = base; |
| 481 | base += DFPS_PLL_CODES_SIZE; |
| 482 | dprintf(SPEW, "fb_base=0x%p!\n", base); |
| 483 | } |
| 484 | |
Kuogee Hsieh | 80b8a6c | 2014-06-09 17:25:38 -0700 | [diff] [blame] | 485 | panel.fb.base = base; |
| 486 | panel.fb.width = panel.panel_info.xres; |
| 487 | panel.fb.height = panel.panel_info.yres; |
| 488 | panel.fb.stride = panel.panel_info.xres; |
| 489 | panel.fb.bpp = panel.panel_info.bpp; |
| 490 | panel.fb.format = panel.panel_info.mipi.dst_format; |
| 491 | } else if (pan_type == PANEL_TYPE_EDP) { |
| 492 | mdss_edp_panel_init(&(panel.panel_info)); |
| 493 | /* prepare func is set up at edp_panel_init */ |
| 494 | panel.clk_func = mdss_edp_panel_clock; |
| 495 | panel.power_func = mdss_edp_panel_power; |
| 496 | panel.bl_func = mdss_edp_bl_enable; |
| 497 | panel.fb.format = FB_FORMAT_RGB888; |
| 498 | } else { |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 499 | dprintf(CRITICAL, "Target panel init not found!\n"); |
Casey Piper | c574e08 | 2013-09-05 14:54:42 -0700 | [diff] [blame] | 500 | ret = ERR_NOT_SUPPORTED; |
| 501 | goto error_gcdb_display_init; |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 502 | |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 503 | } |
| 504 | |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 505 | panel.fb.base = base; |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 506 | panel.mdp_rev = rev; |
| 507 | |
Casey Piper | c574e08 | 2013-09-05 14:54:42 -0700 | [diff] [blame] | 508 | ret = msm_display_init(&panel); |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 509 | |
Casey Piper | c574e08 | 2013-09-05 14:54:42 -0700 | [diff] [blame] | 510 | error_gcdb_display_init: |
| 511 | display_enable = ret ? 0 : 1; |
| 512 | return ret; |
Arpita Banerjee | 841fa06 | 2013-05-24 14:59:51 -0700 | [diff] [blame] | 513 | } |
| 514 | |
| 515 | void gcdb_display_shutdown(void) |
| 516 | { |
| 517 | if (display_enable) |
| 518 | msm_display_off(); |
| 519 | } |