Xipeng Gu | 5affb81 | 2019-06-18 14:59:17 +0800 | [diff] [blame] | 1 | /* Copyright (c) 2015-2019, The Linux Foundation. All rights reserved. |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -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 <string.h> |
| 32 | #include <smem.h> |
| 33 | #include <err.h> |
| 34 | #include <msm_panel.h> |
| 35 | #include <mipi_dsi.h> |
| 36 | #include <pm8x41.h> |
| 37 | #include <pm8x41_wled.h> |
| 38 | #include <qpnp_wled.h> |
Umang Agrawal | d193994 | 2018-02-13 16:23:58 +0530 | [diff] [blame] | 39 | #include <qpnp_lcdb.h> |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 40 | #include <board.h> |
| 41 | #include <mdp5.h> |
| 42 | #include <scm.h> |
| 43 | #include <regulator.h> |
| 44 | #include <platform/clock.h> |
| 45 | #include <platform/gpio.h> |
| 46 | #include <platform/iomap.h> |
| 47 | #include <target/display.h> |
| 48 | #include <qtimer.h> |
Padmanabhan Komanduru | 3cb0766 | 2015-06-08 17:13:33 +0530 | [diff] [blame] | 49 | #include <platform.h> |
Umang Agrawal | d193994 | 2018-02-13 16:23:58 +0530 | [diff] [blame] | 50 | #include <target.h> |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 51 | |
| 52 | #include "include/panel.h" |
| 53 | #include "include/display_resource.h" |
| 54 | #include "gcdb_display.h" |
| 55 | |
Lei Chen | 2c11b46 | 2018-04-11 18:42:37 +0800 | [diff] [blame] | 56 | #define PWM_DUTY_US 13 |
| 57 | #define PWM_PERIOD_US 27 |
| 58 | |
Ashish Garg | 9cfd6ca | 2016-12-20 01:41:54 +0530 | [diff] [blame] | 59 | #define TRULY_720P_VID_PANEL "truly_720p_video" |
| 60 | #define TRULY_720P_CMD_PANEL "truly_720p_cmd" |
| 61 | |
| 62 | #define HDMI_ADV_PANEL_STRING "1:dsi:0:qcom,mdss_dsi_adv7533_1080p:1:none:cfg:single_dsi" |
| 63 | #define TRULY_VID_PANEL_STRING "1:dsi:0:qcom,mdss_dsi_truly_720p_video:1:none:cfg:single_dsi" |
| 64 | #define TRULY_CMD_PANEL_STRING "1:dsi:0:qcom,mdss_dsi_truly_720p_cmd:1:none:cfg:single_dsi" |
| 65 | |
Xipeng Gu | dd4f96d | 2019-07-17 16:44:09 +0800 | [diff] [blame] | 66 | #define VARIANT_MAJOR_MASK (0x00ff0000) |
| 67 | |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 68 | /*---------------------------------------------------------------------------*/ |
| 69 | /* GPIO configuration */ |
| 70 | /*---------------------------------------------------------------------------*/ |
| 71 | static struct gpio_pin reset_gpio = { |
| 72 | "msmgpio", 0, 3, 1, 0, 1 |
| 73 | }; |
| 74 | |
| 75 | static struct gpio_pin enable_gpio = { |
| 76 | "msmgpio", 90, 3, 1, 0, 1 |
| 77 | }; |
| 78 | |
| 79 | static struct gpio_pin bkl_gpio = { |
| 80 | "msmgpio", 91, 3, 1, 0, 1 |
| 81 | }; |
| 82 | |
Padmanabhan Komanduru | 3cb0766 | 2015-06-08 17:13:33 +0530 | [diff] [blame] | 83 | static struct gpio_pin lcd_mode_gpio = { |
| 84 | "msmgpio", 107, 3, 1, 0, 1 |
| 85 | }; |
| 86 | |
Padmanabhan Komanduru | 2ab03a6 | 2018-05-17 14:38:59 +0530 | [diff] [blame] | 87 | static struct gpio_pin bkl_en_gpio = { |
| 88 | "pm8953", 4, 3, 1, 0, 1 |
| 89 | }; |
| 90 | |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 91 | #define VCO_DELAY_USEC 1000 |
| 92 | #define GPIO_STATE_LOW 0 |
| 93 | #define GPIO_STATE_HIGH 2 |
| 94 | #define RESET_GPIO_SEQ_LEN 3 |
| 95 | #define PMIC_WLED_SLAVE_ID 3 |
| 96 | |
Padmanabhan Komanduru | b338193 | 2015-06-15 22:14:02 +0530 | [diff] [blame] | 97 | #define DSI0_BASE_ADJUST -0x4000 |
| 98 | #define DSI0_PHY_BASE_ADJUST -0x4100 |
| 99 | #define DSI0_PHY_PLL_BASE_ADJUST -0x3900 |
Padmanabhan Komanduru | 2ab03a6 | 2018-05-17 14:38:59 +0530 | [diff] [blame] | 100 | #define DSI0_12NM_PHY_PLL_BASE_ADJUST -0x3F00 |
Padmanabhan Komanduru | b338193 | 2015-06-15 22:14:02 +0530 | [diff] [blame] | 101 | #define DSI0_PHY_REGULATOR_BASE_ADJUST -0x3C00 |
Padmanabhan Komanduru | 2ab03a6 | 2018-05-17 14:38:59 +0530 | [diff] [blame] | 102 | #define DSI1_12NM_PHY_PLL_BASE_ADJUST -0x600 |
Padmanabhan Komanduru | b338193 | 2015-06-15 22:14:02 +0530 | [diff] [blame] | 103 | |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 104 | static void mdss_dsi_uniphy_pll_sw_reset_8952(uint32_t pll_base) |
| 105 | { |
| 106 | writel(0x01, pll_base + 0x0068); /* PLL TEST CFG */ |
| 107 | mdelay(1); |
| 108 | writel(0x00, pll_base + 0x0068); /* PLL TEST CFG */ |
| 109 | mdelay(1); |
| 110 | } |
| 111 | |
| 112 | static void dsi_pll_toggle_lock_detect_8952(uint32_t pll_base) |
| 113 | { |
| 114 | writel(0x04, pll_base + 0x0064); /* LKDetect CFG2 */ |
| 115 | udelay(1); |
| 116 | writel(0x05, pll_base + 0x0064); /* LKDetect CFG2 */ |
| 117 | udelay(512); |
| 118 | } |
| 119 | |
| 120 | static void dsi_pll_sw_reset_8952(uint32_t pll_base) |
| 121 | { |
| 122 | writel(0x01, pll_base + 0x0068); /* PLL TEST CFG */ |
| 123 | udelay(1); |
| 124 | writel(0x00, pll_base + 0x0068); /* PLL TEST CFG */ |
Padmanabhan Komanduru | 6cf6352 | 2015-06-08 14:48:00 +0530 | [diff] [blame] | 125 | udelay(1); |
| 126 | } |
| 127 | |
| 128 | static uint32_t dsi_pll_lock_status_8956(uint32_t pll_base) |
| 129 | { |
| 130 | uint32_t counter, status; |
| 131 | |
| 132 | status = readl(pll_base + 0x00c0) & 0x01; |
| 133 | for (counter = 0; counter < 5 && !status; counter++) { |
| 134 | udelay(100); |
| 135 | status = readl(pll_base + 0x00c0) & 0x01; |
| 136 | } |
| 137 | |
| 138 | return status; |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | static uint32_t gf_1_dsi_pll_enable_sequence_8952(uint32_t pll_base) |
| 142 | { |
| 143 | uint32_t rc; |
| 144 | |
| 145 | dsi_pll_sw_reset_8952(pll_base); |
| 146 | |
| 147 | /* |
| 148 | * Add hardware recommended delays between register writes for |
| 149 | * the updates to take effect. These delays are necessary for the |
| 150 | * PLL to successfully lock |
| 151 | */ |
| 152 | writel(0x14, pll_base + 0x0070); /* CAL CFG1*/ |
| 153 | writel(0x01, pll_base + 0x0020); /* GLB CFG */ |
| 154 | writel(0x05, pll_base + 0x0020); /* GLB CFG */ |
| 155 | udelay(3); |
| 156 | writel(0x0f, pll_base + 0x0020); /* GLB CFG */ |
| 157 | udelay(500); |
| 158 | |
| 159 | dsi_pll_toggle_lock_detect_8952(pll_base); |
| 160 | rc = readl(pll_base + 0x00c0) & 0x01; |
| 161 | |
| 162 | return rc; |
| 163 | } |
| 164 | |
| 165 | static uint32_t gf_2_dsi_pll_enable_sequence_8952(uint32_t pll_base) |
| 166 | { |
| 167 | uint32_t rc; |
| 168 | |
| 169 | dsi_pll_sw_reset_8952(pll_base); |
| 170 | |
| 171 | /* |
| 172 | * Add hardware recommended delays between register writes for |
| 173 | * the updates to take effect. These delays are necessary for the |
| 174 | * PLL to successfully lock |
| 175 | */ |
| 176 | writel(0x04, pll_base + 0x0070); /* CAL CFG1*/ |
| 177 | writel(0x01, pll_base + 0x0020); /* GLB CFG */ |
| 178 | writel(0x05, pll_base + 0x0020); /* GLB CFG */ |
| 179 | udelay(3); |
| 180 | writel(0x0f, pll_base + 0x0020); /* GLB CFG */ |
| 181 | udelay(500); |
| 182 | |
| 183 | dsi_pll_toggle_lock_detect_8952(pll_base); |
| 184 | rc = readl(pll_base + 0x00c0) & 0x01; |
| 185 | |
| 186 | return rc; |
| 187 | } |
| 188 | |
| 189 | static uint32_t tsmc_dsi_pll_enable_sequence_8952(uint32_t pll_base) |
| 190 | { |
| 191 | uint32_t rc; |
| 192 | |
| 193 | dsi_pll_sw_reset_8952(pll_base); |
| 194 | /* |
| 195 | * Add hardware recommended delays between register writes for |
| 196 | * the updates to take effect. These delays are necessary for the |
| 197 | * PLL to successfully lock |
| 198 | */ |
| 199 | |
| 200 | writel(0x34, pll_base + 0x0070); /* CAL CFG1*/ |
| 201 | writel(0x01, pll_base + 0x0020); /* GLB CFG */ |
| 202 | writel(0x05, pll_base + 0x0020); /* GLB CFG */ |
| 203 | writel(0x0f, pll_base + 0x0020); /* GLB CFG */ |
| 204 | udelay(500); |
| 205 | |
| 206 | dsi_pll_toggle_lock_detect_8952(pll_base); |
| 207 | rc = readl(pll_base + 0x00c0) & 0x01; |
| 208 | |
| 209 | return rc; |
| 210 | } |
| 211 | |
| 212 | |
| 213 | static uint32_t dsi_pll_enable_seq_8952(uint32_t pll_base) |
| 214 | { |
| 215 | uint32_t pll_locked = 0; |
| 216 | uint32_t counter = 0; |
| 217 | |
| 218 | do { |
| 219 | pll_locked = tsmc_dsi_pll_enable_sequence_8952(pll_base); |
| 220 | |
| 221 | dprintf(SPEW, "TSMC pll locked status is %d\n", pll_locked); |
| 222 | ++counter; |
| 223 | } while (!pll_locked && (counter < 3)); |
| 224 | |
| 225 | if(!pll_locked) { |
| 226 | counter = 0; |
| 227 | do { |
| 228 | pll_locked = gf_1_dsi_pll_enable_sequence_8952(pll_base); |
| 229 | |
| 230 | dprintf(SPEW, "GF P1 pll locked status is %d\n", pll_locked); |
| 231 | ++counter; |
| 232 | } while (!pll_locked && (counter < 3)); |
| 233 | } |
| 234 | |
| 235 | if(!pll_locked) { |
| 236 | counter = 0; |
| 237 | do { |
| 238 | pll_locked = gf_2_dsi_pll_enable_sequence_8952(pll_base); |
| 239 | |
| 240 | dprintf(SPEW, "GF P2 pll locked status is %d\n", pll_locked); |
| 241 | ++counter; |
| 242 | } while (!pll_locked && (counter < 3)); |
| 243 | } |
| 244 | |
| 245 | return pll_locked; |
| 246 | } |
| 247 | |
Padmanabhan Komanduru | 6cf6352 | 2015-06-08 14:48:00 +0530 | [diff] [blame] | 248 | static uint32_t dsi_pll_enable_seq_8956(uint32_t pll_base) |
| 249 | { |
| 250 | /* |
| 251 | * PLL power up sequence |
| 252 | * Add necessary delays recommended by h/w team |
| 253 | */ |
| 254 | |
| 255 | /* Lock Detect setting */ |
| 256 | writel(0x0d, pll_base + 0x0064); /* LKDetect CFG2 */ |
| 257 | writel(0x34, pll_base + 0x0070); /* PLL CAL_CFG1 */ |
| 258 | writel(0x10, pll_base + 0x005c); /* LKDetect CFG0 */ |
| 259 | writel(0x1a, pll_base + 0x0060); /* LKDetect CFG1 */ |
| 260 | |
| 261 | writel(0x01, pll_base + 0x0020); /* GLB CFG */ |
| 262 | udelay(300); |
| 263 | writel(0x05, pll_base + 0x0020); /* GLB CFG */ |
| 264 | udelay(300); |
| 265 | writel(0x0f, pll_base + 0x0020); /* GLB CFG */ |
| 266 | udelay(300); |
| 267 | writel(0x07, pll_base + 0x0020); /* GLB CFG */ |
| 268 | udelay(300); |
| 269 | writel(0x0f, pll_base + 0x0020); /* GLB CFG */ |
| 270 | udelay(1000); |
| 271 | |
| 272 | return dsi_pll_lock_status_8956(pll_base); |
| 273 | } |
| 274 | |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 275 | static int msm8952_wled_backlight_ctrl(uint8_t enable) |
| 276 | { |
| 277 | uint8_t slave_id = PMIC_WLED_SLAVE_ID; /* pmi */ |
Vishnuvardhan Prodduturi | a84a0e8 | 2018-10-25 12:55:55 +0530 | [diff] [blame] | 278 | uint32_t pmic_type = target_get_pmic(); |
| 279 | |
Umang Agrawal | dff10da | 2019-05-08 16:14:13 +0530 | [diff] [blame] | 280 | if(pmic_type == PMIC_IS_PM8916 || pmic_type == PMIC_IS_PM660) |
Vishnuvardhan Prodduturi | a84a0e8 | 2018-10-25 12:55:55 +0530 | [diff] [blame] | 281 | return NO_ERROR; |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 282 | |
| 283 | pm8x41_wled_config_slave_id(slave_id); |
Vishnuvardhan Prodduturi | a84a0e8 | 2018-10-25 12:55:55 +0530 | [diff] [blame] | 284 | if (pmic_type == PMIC_IS_PMI632) { |
Umang Agrawal | d193994 | 2018-02-13 16:23:58 +0530 | [diff] [blame] | 285 | qpnp_lcdb_enable(enable); |
Vishnuvardhan Prodduturi | a84a0e8 | 2018-10-25 12:55:55 +0530 | [diff] [blame] | 286 | } else { |
Umang Agrawal | d193994 | 2018-02-13 16:23:58 +0530 | [diff] [blame] | 287 | qpnp_wled_enable_backlight(enable); |
| 288 | qpnp_ibb_enable(enable); |
| 289 | } |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 290 | return NO_ERROR; |
| 291 | } |
| 292 | |
Lei Chen | 2c11b46 | 2018-04-11 18:42:37 +0800 | [diff] [blame] | 293 | static int pwm_backlight_ctrl(uint8_t enable) |
| 294 | { |
| 295 | if (enable) { |
| 296 | pm_pwm_enable(false); |
| 297 | pm_pwm_config(PWM_DUTY_US, PWM_PERIOD_US); |
| 298 | pm_pwm_enable(true); |
| 299 | } else { |
| 300 | pm_pwm_enable(false); |
| 301 | } |
| 302 | |
| 303 | return NO_ERROR; |
| 304 | } |
| 305 | |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 306 | int target_backlight_ctrl(struct backlight *bl, uint8_t enable) |
| 307 | { |
| 308 | uint32_t ret = NO_ERROR; |
Vishnuvardhan Prodduturi | a84a0e8 | 2018-10-25 12:55:55 +0530 | [diff] [blame] | 309 | uint32_t pmic_type = target_get_pmic(); |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 310 | |
| 311 | if (bl->bl_interface_type == BL_DCS) |
| 312 | return ret; |
| 313 | |
Vishnuvardhan Prodduturi | a84a0e8 | 2018-10-25 12:55:55 +0530 | [diff] [blame] | 314 | if ((pmic_type == PMIC_IS_PMI632) && |
Lei Chen | 2c11b46 | 2018-04-11 18:42:37 +0800 | [diff] [blame] | 315 | (bl->bl_interface_type == BL_PWM)) { |
| 316 | ret = pwm_backlight_ctrl(enable); |
Umang Agrawal | dff10da | 2019-05-08 16:14:13 +0530 | [diff] [blame] | 317 | } else if (pmic_type == PMIC_IS_PM8916 || pmic_type == PMIC_IS_PM660) { |
Vishnuvardhan Prodduturi | a84a0e8 | 2018-10-25 12:55:55 +0530 | [diff] [blame] | 318 | ret = pwm_backlight_ctrl(enable); |
Lei Chen | 2c11b46 | 2018-04-11 18:42:37 +0800 | [diff] [blame] | 319 | } else { |
| 320 | ret = msm8952_wled_backlight_ctrl(enable); |
| 321 | } |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 322 | return ret; |
| 323 | } |
| 324 | |
Padmanabhan Komanduru | 77a979a | 2015-06-15 15:03:23 +0530 | [diff] [blame] | 325 | static int32_t mdss_dsi_pll_config(uint32_t pll_base, uint32_t ctl_base, |
| 326 | struct mdss_dsi_pll_config *pll_data) |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 327 | { |
| 328 | int32_t ret = 0; |
Padmanabhan Komanduru | 77a979a | 2015-06-15 15:03:23 +0530 | [diff] [blame] | 329 | if (!platform_is_msm8956()) |
| 330 | mdss_dsi_uniphy_pll_sw_reset_8952(pll_base); |
| 331 | else |
| 332 | dsi_pll_sw_reset_8952(pll_base); |
| 333 | mdss_dsi_auto_pll_config(pll_base, ctl_base, pll_data); |
| 334 | if (platform_is_msm8956()) |
| 335 | ret = dsi_pll_enable_seq_8956(pll_base); |
| 336 | else |
| 337 | ret = dsi_pll_enable_seq_8952(pll_base); |
| 338 | |
| 339 | return ret; |
| 340 | } |
| 341 | |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 342 | int target_panel_clock(uint8_t enable, struct msm_panel_info *pinfo) |
| 343 | { |
Padmanabhan Komanduru | 82ae713 | 2015-06-08 15:46:33 +0530 | [diff] [blame] | 344 | int32_t ret = 0, flags; |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 345 | struct mdss_dsi_pll_config *pll_data; |
| 346 | dprintf(SPEW, "target_panel_clock\n"); |
| 347 | |
Padmanabhan Komanduru | 82ae713 | 2015-06-08 15:46:33 +0530 | [diff] [blame] | 348 | if (pinfo->dest == DISPLAY_2) { |
| 349 | flags = MMSS_DSI_CLKS_FLAG_DSI1; |
| 350 | if (pinfo->mipi.dual_dsi) |
| 351 | flags |= MMSS_DSI_CLKS_FLAG_DSI0; |
| 352 | } else { |
| 353 | flags = MMSS_DSI_CLKS_FLAG_DSI0; |
| 354 | if (pinfo->mipi.dual_dsi) |
| 355 | flags |= MMSS_DSI_CLKS_FLAG_DSI1; |
| 356 | } |
| 357 | |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 358 | pll_data = pinfo->mipi.dsi_pll_config; |
| 359 | pll_data->vco_delay = VCO_DELAY_USEC; |
| 360 | |
Padmanabhan Komanduru | f68f51b | 2015-12-21 18:32:12 +0530 | [diff] [blame] | 361 | /* SSC parameters */ |
Vishnuvardhan Prodduturi | a84a0e8 | 2018-10-25 12:55:55 +0530 | [diff] [blame] | 362 | if (platform_is_msm8937() || platform_is_msm8917() || platform_is_qm215()) { |
Padmanabhan Komanduru | f68f51b | 2015-12-21 18:32:12 +0530 | [diff] [blame] | 363 | pll_data->ssc_en = true; |
| 364 | pll_data->is_center_spread = false; |
| 365 | pll_data->ssc_freq = 30000; |
| 366 | pll_data->ssc_ppm = 5000; |
shaoxing | 0534f8b | 2019-07-08 19:56:02 +0800 | [diff] [blame] | 367 | } else if (platform_is_sdm439() || platform_is_sdm429() || platform_is_sdm429w()) { |
Padmanabhan Komanduru | e54f761 | 2018-05-03 09:29:50 +0530 | [diff] [blame] | 368 | pll_data->ssc_en = true; |
| 369 | pll_data->is_center_spread = false; |
| 370 | pll_data->ssc_freq = 31500; |
| 371 | pll_data->ssc_ppm = 5000; |
Padmanabhan Komanduru | f68f51b | 2015-12-21 18:32:12 +0530 | [diff] [blame] | 372 | } |
| 373 | |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 374 | if (enable) { |
| 375 | mdp_gdsc_ctrl(enable); |
| 376 | mdss_bus_clocks_enable(); |
| 377 | mdp_clock_enable(); |
| 378 | ret = restore_secure_cfg(SECURE_DEVICE_MDSS); |
| 379 | if (ret) { |
| 380 | dprintf(CRITICAL, |
| 381 | "%s: Failed to restore MDP security configs", |
| 382 | __func__); |
| 383 | mdp_clock_disable(); |
| 384 | mdss_bus_clocks_disable(); |
| 385 | mdp_gdsc_ctrl(0); |
| 386 | return ret; |
| 387 | } |
Padmanabhan Komanduru | 77a979a | 2015-06-15 15:03:23 +0530 | [diff] [blame] | 388 | |
Padmanabhan Komanduru | 62eec85 | 2018-05-14 12:27:30 +0530 | [diff] [blame] | 389 | gcc_dsi_lp_clock_enable(flags); |
| 390 | |
shaoxing | 0534f8b | 2019-07-08 19:56:02 +0800 | [diff] [blame] | 391 | if (platform_is_sdm439() || platform_is_sdm429() || platform_is_sdm429w()) { |
Padmanabhan Komanduru | 2ab03a6 | 2018-05-17 14:38:59 +0530 | [diff] [blame] | 392 | mdss_dsi_auto_pll_12nm_config(pinfo); |
| 393 | |
| 394 | /* |
| 395 | * enable clock/data lane in DSI controller |
| 396 | * before enabling DSI PLL for 12nm PHY |
| 397 | */ |
| 398 | if (pinfo->lane_config) |
| 399 | pinfo->lane_config(pinfo); |
| 400 | |
| 401 | ret = mdss_dsi_auto_pll_12nm_enable(pinfo); |
| 402 | if (!ret) |
| 403 | dprintf(CRITICAL, "unable to ON 12nm PLL\n"); |
| 404 | } else { |
| 405 | ret = mdss_dsi_pll_config(pinfo->mipi.pll_base, |
| 406 | pinfo->mipi.ctl_base, pll_data); |
| 407 | if (!ret) |
| 408 | dprintf(CRITICAL, "unable to ON master pll\n"); |
| 409 | } |
Padmanabhan Komanduru | 77a979a | 2015-06-15 15:03:23 +0530 | [diff] [blame] | 410 | |
Padmanabhan Komanduru | 2a6c345 | 2015-09-09 18:46:06 +0530 | [diff] [blame] | 411 | if (platform_is_msm8956() && pinfo->mipi.dual_dsi && |
| 412 | !platform_is_msm8976_v_1_1()) { |
Padmanabhan Komanduru | 77a979a | 2015-06-15 15:03:23 +0530 | [diff] [blame] | 413 | ret = mdss_dsi_pll_config(pinfo->mipi.spll_base, |
| 414 | pinfo->mipi.sctl_base, pll_data); |
| 415 | if (!ret) |
| 416 | dprintf(CRITICAL, "Not able to enable second pll\n"); |
| 417 | } |
| 418 | |
Padmanabhan Komanduru | 62eec85 | 2018-05-14 12:27:30 +0530 | [diff] [blame] | 419 | gcc_dsi_hs_clocks_enable(flags, pinfo->mipi.use_dsi1_pll, |
Padmanabhan Komanduru | 2a6c345 | 2015-09-09 18:46:06 +0530 | [diff] [blame] | 420 | pll_data->pclk_m, pll_data->pclk_n, pll_data->pclk_d); |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 421 | } else if(!target_cont_splash_screen()) { |
Padmanabhan Komanduru | 82ae713 | 2015-06-08 15:46:33 +0530 | [diff] [blame] | 422 | gcc_dsi_clocks_disable(flags); |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 423 | mdp_clock_disable(); |
| 424 | mdss_bus_clocks_disable(); |
| 425 | mdp_gdsc_ctrl(enable); |
| 426 | } |
| 427 | |
| 428 | return 0; |
| 429 | } |
| 430 | |
| 431 | int target_panel_reset(uint8_t enable, struct panel_reset_sequence *resetseq, |
| 432 | struct msm_panel_info *pinfo) |
| 433 | { |
| 434 | int ret = NO_ERROR; |
Sujeev Dias | 6bc9fa3 | 2015-08-03 23:13:44 -0700 | [diff] [blame] | 435 | uint32_t hw_id = board_hardware_id(); |
| 436 | uint32_t hw_subtype = board_hardware_subtype(); |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 437 | |
Padmanabhan Komanduru | 3cb0766 | 2015-06-08 17:13:33 +0530 | [diff] [blame] | 438 | if (platform_is_msm8956()) { |
| 439 | reset_gpio.pin_id = 25; |
| 440 | bkl_gpio.pin_id = 66; |
Padmanabhan Komanduru | b323132 | 2015-11-12 16:54:21 +0530 | [diff] [blame] | 441 | } else if (platform_is_msm8937()) { |
| 442 | reset_gpio.pin_id = 60; |
| 443 | bkl_gpio.pin_id = 98; |
| 444 | enable_gpio.pin_id = 99; |
Parth Dixit | 05f3c9f | 2016-03-18 17:14:57 +0530 | [diff] [blame] | 445 | } else if (platform_is_msm8917()) { |
Jayant Shekhar | 9c0533e | 2016-01-28 11:17:18 +0530 | [diff] [blame] | 446 | reset_gpio.pin_id = 60; |
| 447 | bkl_gpio.pin_id = 98; |
| 448 | pinfo->mipi.use_enable_gpio = 0; |
Vishnuvardhan Prodduturi | a84a0e8 | 2018-10-25 12:55:55 +0530 | [diff] [blame] | 449 | } else if (platform_is_qm215()) { |
| 450 | dprintf(CRITICAL,"vproddut: coming here \n"); |
| 451 | reset_gpio.pin_id = 60; |
| 452 | bkl_gpio.pin_id = 93; |
| 453 | enable_gpio.pin_id = 94; |
| 454 | pinfo->mipi.use_enable_gpio = 1; |
shaoxing | 0534f8b | 2019-07-08 19:56:02 +0800 | [diff] [blame] | 455 | } else if (platform_is_sdm439() || platform_is_sdm429() || platform_is_sdm429w()) { |
Padmanabhan Komanduru | 2ab03a6 | 2018-05-17 14:38:59 +0530 | [diff] [blame] | 456 | reset_gpio.pin_id = 60; |
shaoxing | 0534f8b | 2019-07-08 19:56:02 +0800 | [diff] [blame] | 457 | if ((platform_is_sdm429() || platform_is_sdm429w()) && hw_subtype |
Xipeng Gu | 5affb81 | 2019-06-18 14:59:17 +0800 | [diff] [blame] | 458 | == HW_PLATFORM_SUBTYPE_429W_PM660) { |
| 459 | reset_gpio.pin_id = 60; |
| 460 | pinfo->mipi.use_enable_gpio = 1; |
| 461 | enable_gpio.pin_id = 69; |
| 462 | } |
Sujeev Dias | 6bc9fa3 | 2015-08-03 23:13:44 -0700 | [diff] [blame] | 463 | } else if ((hw_id == HW_PLATFORM_QRD) && |
| 464 | (hw_subtype == HW_PLATFORM_SUBTYPE_POLARIS)) { |
| 465 | enable_gpio.pin_id = 19; |
Padmanabhan Komanduru | 3cb0766 | 2015-06-08 17:13:33 +0530 | [diff] [blame] | 466 | } |
| 467 | |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 468 | if (enable) { |
Padmanabhan Komanduru | 3cb0766 | 2015-06-08 17:13:33 +0530 | [diff] [blame] | 469 | if (pinfo->mipi.use_enable_gpio && !platform_is_msm8956()) { |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 470 | gpio_tlmm_config(enable_gpio.pin_id, 0, |
| 471 | enable_gpio.pin_direction, enable_gpio.pin_pull, |
| 472 | enable_gpio.pin_strength, |
| 473 | enable_gpio.pin_state); |
| 474 | |
| 475 | gpio_set_dir(enable_gpio.pin_id, 2); |
| 476 | } |
| 477 | |
shaoxing | 0534f8b | 2019-07-08 19:56:02 +0800 | [diff] [blame] | 478 | if (platform_is_sdm439() || platform_is_sdm429() || platform_is_sdm429w()) { |
Padmanabhan Komanduru | 2ab03a6 | 2018-05-17 14:38:59 +0530 | [diff] [blame] | 479 | /* enable PM GPIO-4 for backlight enable */ |
| 480 | struct pm8x41_gpio gpio_param = { |
| 481 | .direction = PM_GPIO_DIR_OUT, |
| 482 | .function = PM_GPIO_FUNC_HIGH, |
| 483 | .vin_sel = 0, /* VIN_0 */ |
| 484 | .pull = PM_GPIO_NO_PULL, |
| 485 | .output_buffer = PM_GPIO_OUT_CMOS, |
| 486 | .out_strength = PM_GPIO_OUT_DRIVE_HIGH, |
| 487 | }; |
| 488 | |
Xipeng Gu | dd4f96d | 2019-07-17 16:44:09 +0800 | [diff] [blame] | 489 | if (((board_target_id() & VARIANT_MAJOR_MASK)) && |
| 490 | platform_is_sdm429w()) { |
| 491 | /* enable PM660 GPIO-12 for backlight enable */ |
| 492 | bkl_en_gpio.pin_id = 12; |
| 493 | gpio_param.inv_int_pol = PM_GPIO_INVERT; |
| 494 | } |
| 495 | |
Padmanabhan Komanduru | 2ab03a6 | 2018-05-17 14:38:59 +0530 | [diff] [blame] | 496 | dprintf(SPEW, "%s: gpio=%d enable=%d\n", __func__, |
| 497 | bkl_en_gpio.pin_id, enable); |
| 498 | |
| 499 | pm8x41_gpio_config(bkl_en_gpio.pin_id, &gpio_param); |
| 500 | } else { |
| 501 | gpio_tlmm_config(bkl_gpio.pin_id, 0, |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 502 | bkl_gpio.pin_direction, bkl_gpio.pin_pull, |
| 503 | bkl_gpio.pin_strength, bkl_gpio.pin_state); |
| 504 | |
Padmanabhan Komanduru | 2ab03a6 | 2018-05-17 14:38:59 +0530 | [diff] [blame] | 505 | gpio_set_dir(bkl_gpio.pin_id, 2); |
| 506 | } |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 507 | |
| 508 | gpio_tlmm_config(reset_gpio.pin_id, 0, |
| 509 | reset_gpio.pin_direction, reset_gpio.pin_pull, |
| 510 | reset_gpio.pin_strength, reset_gpio.pin_state); |
| 511 | |
| 512 | gpio_set_dir(reset_gpio.pin_id, 2); |
| 513 | |
| 514 | /* reset */ |
| 515 | for (int i = 0; i < RESET_GPIO_SEQ_LEN; i++) { |
| 516 | if (resetseq->pin_state[i] == GPIO_STATE_LOW) |
| 517 | gpio_set_dir(reset_gpio.pin_id, GPIO_STATE_LOW); |
| 518 | else |
| 519 | gpio_set_dir(reset_gpio.pin_id, GPIO_STATE_HIGH); |
| 520 | mdelay(resetseq->sleep[i]); |
| 521 | } |
Padmanabhan Komanduru | 3cb0766 | 2015-06-08 17:13:33 +0530 | [diff] [blame] | 522 | |
| 523 | if (platform_is_msm8956()) { |
| 524 | gpio_tlmm_config(lcd_mode_gpio.pin_id, 0, |
| 525 | lcd_mode_gpio.pin_direction, lcd_mode_gpio.pin_pull, |
| 526 | lcd_mode_gpio.pin_strength, lcd_mode_gpio.pin_state); |
| 527 | |
| 528 | if (pinfo->lcdc.split_display || pinfo->lcdc.dst_split) |
| 529 | gpio_set_dir(lcd_mode_gpio.pin_id, GPIO_STATE_LOW); |
| 530 | else |
| 531 | gpio_set_dir(lcd_mode_gpio.pin_id, GPIO_STATE_HIGH); |
| 532 | } |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 533 | } else if(!target_cont_splash_screen()) { |
| 534 | gpio_set_dir(reset_gpio.pin_id, 0); |
Padmanabhan Komanduru | 3cb0766 | 2015-06-08 17:13:33 +0530 | [diff] [blame] | 535 | if (pinfo->mipi.use_enable_gpio && !platform_is_msm8956()) |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 536 | gpio_set_dir(enable_gpio.pin_id, 0); |
Padmanabhan Komanduru | 3cb0766 | 2015-06-08 17:13:33 +0530 | [diff] [blame] | 537 | if (platform_is_msm8956()) |
| 538 | gpio_set_dir(lcd_mode_gpio.pin_id, 0); |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 539 | } |
| 540 | |
| 541 | return ret; |
| 542 | } |
| 543 | |
Sandeep Panda | aa4ea2f | 2016-07-05 13:52:25 +0530 | [diff] [blame] | 544 | static int wled_init(struct msm_panel_info *pinfo) |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 545 | { |
| 546 | struct qpnp_wled_config_data config = {0}; |
| 547 | struct labibb_desc *labibb; |
| 548 | int display_type = 0; |
Vishnuvardhan Prodduturi | 4aa8dc4 | 2015-10-20 21:20:43 +0530 | [diff] [blame] | 549 | bool swire_control = 0; |
| 550 | bool wled_avdd_control = 0; |
Sandeep Panda | aa4ea2f | 2016-07-05 13:52:25 +0530 | [diff] [blame] | 551 | int rc = NO_ERROR; |
Vishnuvardhan Prodduturi | a84a0e8 | 2018-10-25 12:55:55 +0530 | [diff] [blame] | 552 | uint32_t pmic_type = target_get_pmic(); |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 553 | |
Umang Agrawal | dff10da | 2019-05-08 16:14:13 +0530 | [diff] [blame] | 554 | if(pmic_type == PMIC_IS_PM8916 || pmic_type == PMIC_IS_PM660) |
Vishnuvardhan Prodduturi | a84a0e8 | 2018-10-25 12:55:55 +0530 | [diff] [blame] | 555 | return NO_ERROR; |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 556 | labibb = pinfo->labibb; |
| 557 | |
| 558 | if (labibb) |
| 559 | display_type = labibb->amoled_panel; |
| 560 | |
Vishnuvardhan Prodduturi | 4aa8dc4 | 2015-10-20 21:20:43 +0530 | [diff] [blame] | 561 | if (display_type) { |
| 562 | swire_control = labibb->swire_control; |
| 563 | wled_avdd_control = true; |
| 564 | } else { |
| 565 | swire_control = false; |
| 566 | wled_avdd_control = false; |
| 567 | } |
| 568 | |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 569 | config.display_type = display_type; |
| 570 | config.lab_init_volt = 4600000; /* fixed, see pmi register */ |
| 571 | config.ibb_init_volt = 1400000; /* fixed, see pmi register */ |
Vishnuvardhan Prodduturi | 4aa8dc4 | 2015-10-20 21:20:43 +0530 | [diff] [blame] | 572 | config.lab_ibb_swire_control = swire_control; |
| 573 | config.wled_avdd_control = wled_avdd_control; |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 574 | |
Vishnuvardhan Prodduturi | 4aa8dc4 | 2015-10-20 21:20:43 +0530 | [diff] [blame] | 575 | if(!swire_control) { |
| 576 | if (labibb && labibb->force_config) { |
| 577 | config.lab_min_volt = labibb->lab_min_volt; |
| 578 | config.lab_max_volt = labibb->lab_max_volt; |
| 579 | config.ibb_min_volt = labibb->ibb_min_volt; |
| 580 | config.ibb_max_volt = labibb->ibb_max_volt; |
| 581 | config.pwr_up_delay = labibb->pwr_up_delay; |
| 582 | config.pwr_down_delay = labibb->pwr_down_delay; |
| 583 | config.ibb_discharge_en = labibb->ibb_discharge_en; |
| 584 | } else { |
| 585 | /* default */ |
| 586 | config.pwr_up_delay = 3; |
| 587 | config.pwr_down_delay = 3; |
| 588 | config.ibb_discharge_en = 1; |
| 589 | if (display_type) { /* amoled */ |
| 590 | config.lab_min_volt = 4600000; |
| 591 | config.lab_max_volt = 4600000; |
| 592 | config.ibb_min_volt = 4000000; |
| 593 | config.ibb_max_volt = 4000000; |
| 594 | } else { /* lcd */ |
| 595 | config.lab_min_volt = 5500000; |
| 596 | config.lab_max_volt = 5500000; |
| 597 | config.ibb_min_volt = 5500000; |
| 598 | config.ibb_max_volt = 5500000; |
| 599 | } |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 600 | } |
| 601 | } |
| 602 | |
Vishnuvardhan Prodduturi | a84a0e8 | 2018-10-25 12:55:55 +0530 | [diff] [blame] | 603 | if (pmic_type == PMIC_IS_PMI632) { |
Narender Ankam | bf2e2dd | 2018-05-30 17:48:11 +0530 | [diff] [blame] | 604 | config.pwr_up_delay = 1; |
| 605 | config.pwr_down_delay = 0; |
| 606 | } |
| 607 | |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 608 | dprintf(SPEW, "%s: %d %d %d %d %d %d %d %d %d %d\n", __func__, |
| 609 | config.display_type, |
| 610 | config.lab_min_volt, config.lab_max_volt, |
| 611 | config.ibb_min_volt, config.ibb_max_volt, |
| 612 | config.lab_init_volt, config.ibb_init_volt, |
| 613 | config.pwr_up_delay, config.pwr_down_delay, |
| 614 | config.ibb_discharge_en); |
| 615 | |
| 616 | /* QPNP WLED init for display backlight */ |
| 617 | pm8x41_wled_config_slave_id(PMIC_WLED_SLAVE_ID); |
| 618 | |
Vishnuvardhan Prodduturi | a84a0e8 | 2018-10-25 12:55:55 +0530 | [diff] [blame] | 619 | if (pmic_type == PMIC_IS_PMI632) |
Umang Agrawal | d193994 | 2018-02-13 16:23:58 +0530 | [diff] [blame] | 620 | rc = qpnp_lcdb_init(&config); |
| 621 | else |
| 622 | rc = qpnp_wled_init(&config); |
Sandeep Panda | aa4ea2f | 2016-07-05 13:52:25 +0530 | [diff] [blame] | 623 | |
| 624 | return rc; |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 625 | } |
| 626 | |
Dhaval Patel | 7709c41 | 2015-05-12 10:09:41 -0700 | [diff] [blame] | 627 | int target_dsi_phy_config(struct mdss_dsi_phy_ctrl *phy_db) |
| 628 | { |
| 629 | memcpy(phy_db->regulator, panel_regulator_settings, REGULATOR_SIZE); |
| 630 | memcpy(phy_db->ctrl, panel_physical_ctrl, PHYSICAL_SIZE); |
| 631 | memcpy(phy_db->strength, panel_strength_ctrl, STRENGTH_SIZE); |
| 632 | memcpy(phy_db->bistCtrl, panel_bist_ctrl, BIST_SIZE); |
| 633 | memcpy(phy_db->laneCfg, panel_lane_config, LANE_SIZE); |
| 634 | return NO_ERROR; |
| 635 | } |
| 636 | |
Padmanabhan Komanduru | b338193 | 2015-06-15 22:14:02 +0530 | [diff] [blame] | 637 | int target_display_get_base_offset(uint32_t base) |
| 638 | { |
shaoxing | 0534f8b | 2019-07-08 19:56:02 +0800 | [diff] [blame] | 639 | if (platform_is_sdm439() || platform_is_sdm429() || platform_is_sdm429w()) { |
Padmanabhan Komanduru | 2ab03a6 | 2018-05-17 14:38:59 +0530 | [diff] [blame] | 640 | if (base == MIPI_DSI0_BASE) |
| 641 | return DSI0_BASE_ADJUST; |
| 642 | else if (base == DSI0_PHY_BASE) |
| 643 | return DSI0_PHY_BASE_ADJUST; |
| 644 | else if (base == DSI0_PLL_BASE) |
| 645 | return DSI0_12NM_PHY_PLL_BASE_ADJUST; |
| 646 | else if (base == DSI1_PLL_BASE) |
| 647 | return DSI1_12NM_PHY_PLL_BASE_ADJUST; |
| 648 | } else if (platform_is_msm8956() || platform_is_msm8937() || |
Vishnuvardhan Prodduturi | a84a0e8 | 2018-10-25 12:55:55 +0530 | [diff] [blame] | 649 | platform_is_msm8917() || platform_is_qm215()) { |
Padmanabhan Komanduru | b338193 | 2015-06-15 22:14:02 +0530 | [diff] [blame] | 650 | if (base == MIPI_DSI0_BASE) |
| 651 | return DSI0_BASE_ADJUST; |
| 652 | else if (base == DSI0_PHY_BASE) |
| 653 | return DSI0_PHY_BASE_ADJUST; |
| 654 | else if (base == DSI0_PLL_BASE) |
| 655 | return DSI0_PHY_PLL_BASE_ADJUST; |
| 656 | else if (base == DSI0_REGULATOR_BASE) |
| 657 | return DSI0_PHY_REGULATOR_BASE_ADJUST; |
| 658 | } |
| 659 | |
| 660 | return 0; |
| 661 | } |
| 662 | |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 663 | int target_ldo_ctrl(uint8_t enable, struct msm_panel_info *pinfo) |
| 664 | { |
Sandeep Panda | aa4ea2f | 2016-07-05 13:52:25 +0530 | [diff] [blame] | 665 | int rc = 0; |
Padmanabhan Komanduru | 3cb0766 | 2015-06-08 17:13:33 +0530 | [diff] [blame] | 666 | uint32_t ldo_num = REG_LDO6 | REG_LDO17; |
Vishnuvardhan Prodduturi | a84a0e8 | 2018-10-25 12:55:55 +0530 | [diff] [blame] | 667 | uint32_t pmic_type = target_get_pmic(); |
Xipeng Gu | 5affb81 | 2019-06-18 14:59:17 +0800 | [diff] [blame] | 668 | uint32_t hw_subtype = board_hardware_subtype(); |
Padmanabhan Komanduru | 3cb0766 | 2015-06-08 17:13:33 +0530 | [diff] [blame] | 669 | |
| 670 | if (platform_is_msm8956()) |
| 671 | ldo_num |= REG_LDO1; |
shaoxing | 0534f8b | 2019-07-08 19:56:02 +0800 | [diff] [blame] | 672 | else if (platform_is_sdm439() || platform_is_sdm429() || platform_is_sdm429w()) |
Padmanabhan Komanduru | 2ab03a6 | 2018-05-17 14:38:59 +0530 | [diff] [blame] | 673 | ldo_num |= REG_LDO5; /* LDO23 is enable by default */ |
Padmanabhan Komanduru | 3cb0766 | 2015-06-08 17:13:33 +0530 | [diff] [blame] | 674 | else |
| 675 | ldo_num |= REG_LDO2; |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 676 | |
shaoxing | 0534f8b | 2019-07-08 19:56:02 +0800 | [diff] [blame] | 677 | if ((platform_is_sdm429() || platform_is_sdm429w()) && hw_subtype |
xiaolin | 6c9bbb8 | 2019-07-26 16:20:46 +0800 | [diff] [blame] | 678 | == HW_PLATFORM_SUBTYPE_429W_PM660) { |
| 679 | ldo_num &= ~(REG_LDO17 | REG_LDO5); |
| 680 | ldo_num |= REG_LDO13 | REG_LDO15; |
| 681 | } |
Xipeng Gu | 5affb81 | 2019-06-18 14:59:17 +0800 | [diff] [blame] | 682 | |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 683 | if (enable) { |
Padmanabhan Komanduru | 3cb0766 | 2015-06-08 17:13:33 +0530 | [diff] [blame] | 684 | regulator_enable(ldo_num); |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 685 | mdelay(10); |
Frank Yi | 2b7e2b9 | 2018-04-25 16:24:45 +0800 | [diff] [blame] | 686 | if(!pinfo->disable_wled_labibb) { |
| 687 | rc = wled_init(pinfo); |
| 688 | if (rc) { |
| 689 | dprintf(CRITICAL, "%s: wled init failed\n", __func__); |
| 690 | return rc; |
| 691 | } |
Vishnuvardhan Prodduturi | a84a0e8 | 2018-10-25 12:55:55 +0530 | [diff] [blame] | 692 | if (pmic_type == PMIC_IS_PMI632) |
Frank Yi | 2b7e2b9 | 2018-04-25 16:24:45 +0800 | [diff] [blame] | 693 | rc = qpnp_lcdb_enable(true); |
Umang Agrawal | dff10da | 2019-05-08 16:14:13 +0530 | [diff] [blame] | 694 | else if(pmic_type != PMIC_IS_PM8916 && pmic_type != PMIC_IS_PM660) |
Frank Yi | 2b7e2b9 | 2018-04-25 16:24:45 +0800 | [diff] [blame] | 695 | rc = qpnp_ibb_enable(true); /*5V boost*/ |
| 696 | if (rc) { |
| 697 | dprintf(CRITICAL, "%s: qpnp_ibb/lcdb failed\n", __func__); |
| 698 | return rc; |
| 699 | } |
| 700 | mdelay(50); |
Sandeep Panda | aa4ea2f | 2016-07-05 13:52:25 +0530 | [diff] [blame] | 701 | } |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 702 | } else { |
Padmanabhan Komanduru | fa2899b | 2015-06-30 16:25:33 +0530 | [diff] [blame] | 703 | /* |
Padmanabhan Komanduru | 2ab03a6 | 2018-05-17 14:38:59 +0530 | [diff] [blame] | 704 | * LDO1, LDO2, LDO5 and LDO6 are shared with other subsystems. |
Padmanabhan Komanduru | fa2899b | 2015-06-30 16:25:33 +0530 | [diff] [blame] | 705 | * Do not disable them. |
| 706 | */ |
| 707 | regulator_disable(REG_LDO17); |
Xipeng Gu | 5affb81 | 2019-06-18 14:59:17 +0800 | [diff] [blame] | 708 | |
shaoxing | 0534f8b | 2019-07-08 19:56:02 +0800 | [diff] [blame] | 709 | if ((platform_is_sdm429() || platform_is_sdm429w()) && hw_subtype |
Xipeng Gu | 5affb81 | 2019-06-18 14:59:17 +0800 | [diff] [blame] | 710 | == HW_PLATFORM_SUBTYPE_429W_PM660) |
| 711 | regulator_disable(REG_LDO13 | REG_LDO15); |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 712 | } |
| 713 | |
| 714 | return NO_ERROR; |
| 715 | } |
| 716 | |
Padmanabhan Komanduru | bccbcdc | 2015-06-30 16:19:24 +0530 | [diff] [blame] | 717 | bool target_display_panel_node(char *pbuf, uint16_t buf_size) |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 718 | { |
Ashish Garg | 9cfd6ca | 2016-12-20 01:41:54 +0530 | [diff] [blame] | 719 | int prefix_string_len = strlen(DISPLAY_CMDLINE_PREFIX); |
| 720 | bool ret = true; |
| 721 | struct oem_panel_data oem = mdss_dsi_get_oem_data(); |
| 722 | uint32_t platform_subtype = board_hardware_subtype(); |
Sachin Bhayare | 0ad7277 | 2018-03-22 19:11:29 +0530 | [diff] [blame] | 723 | uint32_t platform = board_platform_id(); |
Ashish Garg | 9cfd6ca | 2016-12-20 01:41:54 +0530 | [diff] [blame] | 724 | |
| 725 | /* default to hdmi for apq iot */ |
Sachin Bhayare | 0ad7277 | 2018-03-22 19:11:29 +0530 | [diff] [blame] | 726 | if ((APQ8017 == platform) && ((HW_PLATFORM_SUBTYPE_SAP == platform_subtype) || |
| 727 | (HW_PLATFORM_SUBTYPE_SAP_NOPMI == platform_subtype))) { |
Ashish Garg | 9cfd6ca | 2016-12-20 01:41:54 +0530 | [diff] [blame] | 728 | if (!strcmp(oem.panel, "")) { |
| 729 | if (buf_size < (prefix_string_len + |
| 730 | strlen(HDMI_ADV_PANEL_STRING))) { |
| 731 | dprintf(CRITICAL, "HDMI command line argument \ |
| 732 | is greater than buffer size\n"); |
| 733 | return false; |
| 734 | } |
| 735 | strlcpy(pbuf, DISPLAY_CMDLINE_PREFIX, buf_size); |
| 736 | buf_size -= prefix_string_len; |
| 737 | pbuf += prefix_string_len; |
| 738 | strlcpy(pbuf, HDMI_ADV_PANEL_STRING, buf_size); |
| 739 | } else if (!strcmp(oem.panel, TRULY_720P_VID_PANEL)) { |
| 740 | if (buf_size < (prefix_string_len + |
| 741 | strlen(TRULY_VID_PANEL_STRING))) { |
| 742 | dprintf(CRITICAL, "TRULY VIDEO command line \ |
| 743 | argument is greater than \ |
| 744 | buffer size\n"); |
| 745 | return false; |
| 746 | } |
| 747 | strlcpy(pbuf, DISPLAY_CMDLINE_PREFIX, buf_size); |
| 748 | buf_size -= prefix_string_len; |
| 749 | pbuf += prefix_string_len; |
| 750 | strlcpy(pbuf, TRULY_VID_PANEL_STRING, buf_size); |
| 751 | } else if (!strcmp(oem.panel, TRULY_720P_CMD_PANEL)) { |
| 752 | if (buf_size < (prefix_string_len + |
| 753 | strlen(TRULY_CMD_PANEL_STRING))) { |
| 754 | dprintf(CRITICAL, "TRULY CMD command line argument \ |
| 755 | argument is greater than \ |
| 756 | buffer size\n"); |
| 757 | return false; |
| 758 | } |
| 759 | strlcpy(pbuf, DISPLAY_CMDLINE_PREFIX, buf_size); |
| 760 | buf_size -= prefix_string_len; |
| 761 | pbuf += prefix_string_len; |
| 762 | strlcpy(pbuf, TRULY_CMD_PANEL_STRING, buf_size); |
| 763 | } |
| 764 | } else { |
| 765 | ret = gcdb_display_cmdline_arg(pbuf, buf_size); |
| 766 | } |
| 767 | |
| 768 | return ret; |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 769 | } |
| 770 | |
| 771 | void target_display_init(const char *panel_name) |
| 772 | { |
Padmanabhan Komanduru | bccbcdc | 2015-06-30 16:19:24 +0530 | [diff] [blame] | 773 | struct oem_panel_data oem; |
Ray Zhang | f95f5b9 | 2015-06-25 15:34:29 +0800 | [diff] [blame] | 774 | int32_t ret = 0; |
| 775 | uint32_t panel_loop = 0; |
Ashish Garg | 9cfd6ca | 2016-12-20 01:41:54 +0530 | [diff] [blame] | 776 | uint32_t platform_subtype = board_hardware_subtype(); |
Sachin Bhayare | 0ad7277 | 2018-03-22 19:11:29 +0530 | [diff] [blame] | 777 | uint32_t platform = board_platform_id(); |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 778 | |
Padmanabhan Komanduru | bccbcdc | 2015-06-30 16:19:24 +0530 | [diff] [blame] | 779 | set_panel_cmd_string(panel_name); |
| 780 | oem = mdss_dsi_get_oem_data(); |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 781 | |
Padmanabhan Komanduru | bccbcdc | 2015-06-30 16:19:24 +0530 | [diff] [blame] | 782 | if (!strcmp(oem.panel, NO_PANEL_CONFIG) |
| 783 | || !strcmp(oem.panel, SIM_VIDEO_PANEL) |
| 784 | || !strcmp(oem.panel, SIM_CMD_PANEL) |
| 785 | || oem.skip) { |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 786 | dprintf(INFO, "Selected panel: %s\nSkip panel configuration\n", |
Padmanabhan Komanduru | bccbcdc | 2015-06-30 16:19:24 +0530 | [diff] [blame] | 787 | oem.panel); |
Vishnuvardhan Prodduturi | 4cd5638 | 2017-08-22 21:46:38 +0530 | [diff] [blame] | 788 | oem.cont_splash = false; |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 789 | } |
| 790 | |
Sachin Bhayare | 0ad7277 | 2018-03-22 19:11:29 +0530 | [diff] [blame] | 791 | if ((APQ8017 == platform) && ((HW_PLATFORM_SUBTYPE_SAP == platform_subtype) || |
| 792 | (HW_PLATFORM_SUBTYPE_SAP_NOPMI == platform_subtype))) { |
Ashish Garg | 9cfd6ca | 2016-12-20 01:41:54 +0530 | [diff] [blame] | 793 | dprintf(INFO, "%s: Platform subtype %d\n", |
| 794 | __func__, platform_subtype); |
| 795 | return; |
| 796 | } |
| 797 | |
Ray Zhang | f95f5b9 | 2015-06-25 15:34:29 +0800 | [diff] [blame] | 798 | do { |
| 799 | target_force_cont_splash_disable(false); |
| 800 | ret = gcdb_display_init(oem.panel, MDP_REV_50, (void *)MIPI_FB_ADDR); |
| 801 | if (!ret || ret == ERR_NOT_SUPPORTED) { |
| 802 | break; |
| 803 | } else { |
| 804 | target_force_cont_splash_disable(true); |
| 805 | msm_display_off(); |
| 806 | } |
| 807 | } while (++panel_loop <= oem_panel_max_auto_detect_panels()); |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 808 | |
Padmanabhan Komanduru | bccbcdc | 2015-06-30 16:19:24 +0530 | [diff] [blame] | 809 | if (!oem.cont_splash) { |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 810 | dprintf(INFO, "Forcing continuous splash disable\n"); |
| 811 | target_force_cont_splash_disable(true); |
| 812 | } |
| 813 | } |
| 814 | |
| 815 | void target_display_shutdown(void) |
| 816 | { |
| 817 | gcdb_display_shutdown(); |
| 818 | } |