Jeevan Shriram | 2d3500b | 2014-12-29 16:25:06 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved. |
Dhaval Patel | 019057a | 2014-08-12 13:52:25 -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> |
Veera Sundaram Sankaran | 089f70d | 2014-12-09 14:17:05 -0800 | [diff] [blame] | 31 | #include <string.h> |
Dhaval Patel | 019057a | 2014-08-12 13:52:25 -0700 | [diff] [blame] | 32 | #include <smem.h> |
| 33 | #include <err.h> |
| 34 | #include <msm_panel.h> |
| 35 | #include <mipi_dsi.h> |
Casey Piper | 6c2f113 | 2015-03-24 11:37:19 -0700 | [diff] [blame^] | 36 | #include <mdss_hdmi.h> |
Dhaval Patel | 019057a | 2014-08-12 13:52:25 -0700 | [diff] [blame] | 37 | #include <pm8x41.h> |
| 38 | #include <pm8x41_wled.h> |
| 39 | #include <qpnp_wled.h> |
| 40 | #include <board.h> |
| 41 | #include <mdp5.h> |
| 42 | #include <scm.h> |
| 43 | #include <endian.h> |
Veera Sundaram Sankaran | 089f70d | 2014-12-09 14:17:05 -0800 | [diff] [blame] | 44 | #include <regulator.h> |
| 45 | #include <qtimer.h> |
| 46 | #include <arch/defines.h> |
Dhaval Patel | 019057a | 2014-08-12 13:52:25 -0700 | [diff] [blame] | 47 | #include <platform/gpio.h> |
| 48 | #include <platform/clock.h> |
| 49 | #include <platform/iomap.h> |
| 50 | #include <target/display.h> |
| 51 | #include "include/panel.h" |
| 52 | #include "include/display_resource.h" |
Veera Sundaram Sankaran | 089f70d | 2014-12-09 14:17:05 -0800 | [diff] [blame] | 53 | #include "gcdb_display.h" |
Dhaval Patel | 019057a | 2014-08-12 13:52:25 -0700 | [diff] [blame] | 54 | |
| 55 | #define HFPLL_LDO_ID 12 |
| 56 | |
| 57 | #define GPIO_STATE_LOW 0 |
| 58 | #define GPIO_STATE_HIGH 2 |
| 59 | #define RESET_GPIO_SEQ_LEN 3 |
| 60 | |
| 61 | #define PWM_DUTY_US 13 |
| 62 | #define PWM_PERIOD_US 27 |
| 63 | #define PMIC_WLED_SLAVE_ID 3 |
| 64 | #define PMIC_MPP_SLAVE_ID 2 |
| 65 | |
Jeevan Shriram | 7aacc32 | 2014-12-29 16:02:25 -0800 | [diff] [blame] | 66 | #define DSI0_BASE_ADJUST -0x4000 |
| 67 | #define DSI1_BASE_ADJUST -0xA000 |
| 68 | |
Veera Sundaram Sankaran | 089f70d | 2014-12-09 14:17:05 -0800 | [diff] [blame] | 69 | /*---------------------------------------------------------------------------*/ |
| 70 | /* GPIO configuration */ |
| 71 | /*---------------------------------------------------------------------------*/ |
| 72 | static struct gpio_pin reset_gpio = { |
| 73 | "msmgpio", 78, 3, 1, 0, 1 |
| 74 | }; |
| 75 | |
| 76 | static struct gpio_pin lcd_reg_en = { /* boost regulator */ |
| 77 | "pm8994_gpios", 14, 3, 1, 0, 1 |
| 78 | }; |
| 79 | |
| 80 | static struct gpio_pin bklt_gpio = { /* lcd_bklt_reg_en */ |
| 81 | "pmi8994_gpios", 2, 3, 1, 0, 1 |
| 82 | }; |
| 83 | |
Dhaval Patel | 019057a | 2014-08-12 13:52:25 -0700 | [diff] [blame] | 84 | static uint32_t dsi_pll_20nm_enable_seq(uint32_t pll_base) |
| 85 | { |
| 86 | uint32_t pll_locked; |
Jeevan Shriram | 5a9f8f4 | 2014-12-14 14:56:14 -0800 | [diff] [blame] | 87 | /* MDSS_DSI_0_PHY_DSIPHY_CTRL_1 */ |
| 88 | writel(0x00, pll_base + 0x374); |
Dhaval Patel | 019057a | 2014-08-12 13:52:25 -0700 | [diff] [blame] | 89 | dmb(); |
Jeevan Shriram | 5a9f8f4 | 2014-12-14 14:56:14 -0800 | [diff] [blame] | 90 | /* MDSS_DSI_0_PHY_DSIPHY_CTRL_0 */ |
| 91 | writel(0x7f, pll_base + 0x370); |
| 92 | dmb(); |
| 93 | pll_locked = mdss_dsi_pll_20nm_lock_status(pll_base); |
| 94 | if (!pll_locked) |
| 95 | dprintf(INFO, "%s: DSI PLL lock failed\n", __func__); |
| 96 | else |
| 97 | dprintf(INFO, "%s: DSI PLL lock Success\n", __func__); |
Dhaval Patel | 019057a | 2014-08-12 13:52:25 -0700 | [diff] [blame] | 98 | |
| 99 | return pll_locked; |
| 100 | } |
| 101 | |
| 102 | static int msm8994_wled_backlight_ctrl(uint8_t enable) |
| 103 | { |
Kuogee Hsieh | 911866e | 2014-09-02 16:41:18 -0700 | [diff] [blame] | 104 | uint8_t slave_id = 3; /* pmi */ |
Dhaval Patel | 019057a | 2014-08-12 13:52:25 -0700 | [diff] [blame] | 105 | |
Veera Sundaram Sankaran | f9ddd6c | 2014-12-02 11:04:52 -0800 | [diff] [blame] | 106 | pm8x41_wled_config_slave_id(slave_id); |
| 107 | qpnp_wled_enable_backlight(enable); |
Dhaval Patel | 019057a | 2014-08-12 13:52:25 -0700 | [diff] [blame] | 108 | qpnp_ibb_enable(enable); |
| 109 | return NO_ERROR; |
| 110 | } |
| 111 | |
| 112 | static int msm8994_pwm_backlight_ctrl(uint8_t enable) |
| 113 | { |
Kuogee Hsieh | 911866e | 2014-09-02 16:41:18 -0700 | [diff] [blame] | 114 | uint8_t slave_id = 3; /* lpg at pmi */ |
| 115 | |
| 116 | if (enable) { |
| 117 | /* mpp-1 had been configured already */ |
| 118 | /* lpg channel 4 */ |
| 119 | |
| 120 | /* LPG_ENABLE_CONTROL */ |
| 121 | pm8x41_lpg_write_sid(slave_id, PWM_BL_LPG_CHAN_ID, 0x46, 0x0); |
| 122 | mdelay(100); |
| 123 | |
| 124 | /* LPG_VALUE_LSB, duty cycle = 0x80/0x200 = 1/4 */ |
| 125 | pm8x41_lpg_write_sid(slave_id, PWM_BL_LPG_CHAN_ID, 0x44, 0x80); |
| 126 | /* LPG_VALUE_MSB */ |
| 127 | pm8x41_lpg_write_sid(slave_id, PWM_BL_LPG_CHAN_ID, 0x45, 0x00); |
| 128 | /* LPG_PWM_SYNC */ |
| 129 | pm8x41_lpg_write_sid(slave_id, PWM_BL_LPG_CHAN_ID, 0x47, 0x01); |
| 130 | |
| 131 | /* LPG_PWM_SIZE_CLK, */ |
| 132 | pm8x41_lpg_write_sid(slave_id, PWM_BL_LPG_CHAN_ID, 0x41, 0x13); |
| 133 | /* LPG_PWM_FREQ_PREDIV */ |
| 134 | pm8x41_lpg_write_sid(slave_id, PWM_BL_LPG_CHAN_ID, 0x42, 0x02); |
| 135 | /* LPG_PWM_TYPE_CONFIG */ |
| 136 | pm8x41_lpg_write_sid(slave_id, PWM_BL_LPG_CHAN_ID, 0x43, 0x20); |
| 137 | /* LPG_ENABLE_CONTROL */ |
| 138 | pm8x41_lpg_write_sid(slave_id, PWM_BL_LPG_CHAN_ID, 0x46, 0x04); |
| 139 | |
| 140 | /* SEC_ACCESS */ |
| 141 | pm8x41_lpg_write_sid(slave_id, PWM_BL_LPG_CHAN_ID, 0xD0, 0xA5); |
| 142 | /* DTEST4, OUT_HI */ |
| 143 | pm8x41_lpg_write_sid(slave_id, PWM_BL_LPG_CHAN_ID, 0xE5, 0x01); |
| 144 | /* LPG_ENABLE_CONTROL */ |
| 145 | pm8x41_lpg_write_sid(slave_id, PWM_BL_LPG_CHAN_ID, 0x46, 0xA4); |
| 146 | } else { |
| 147 | /* LPG_ENABLE_CONTROL */ |
| 148 | pm8x41_lpg_write_sid(slave_id, PWM_BL_LPG_CHAN_ID, 0x46, 0x0); |
| 149 | } |
| 150 | |
| 151 | return NO_ERROR; |
| 152 | } |
| 153 | |
| 154 | void lcd_bklt_reg_enable(void) |
| 155 | { |
| 156 | uint8_t slave_id = 2; /* gpio at pmi */ |
| 157 | |
| 158 | struct pm8x41_gpio gpio = { |
| 159 | .direction = PM_GPIO_DIR_OUT, |
| 160 | .function = PM_GPIO_FUNC_HIGH, |
| 161 | .vin_sel = 2, /* VIN_2 */ |
| 162 | .output_buffer = PM_GPIO_OUT_CMOS, |
| 163 | .out_strength = PM_GPIO_OUT_DRIVE_LOW, |
| 164 | }; |
| 165 | |
| 166 | pm8x41_gpio_config_sid(slave_id, bklt_gpio.pin_id, &gpio); |
| 167 | pm8x41_gpio_set_sid(slave_id, bklt_gpio.pin_id, 1); |
| 168 | } |
| 169 | |
| 170 | void lcd_bklt_reg_disable(void) |
| 171 | { |
| 172 | uint8_t slave_id = 2; /* gpio at pmi */ |
| 173 | |
| 174 | pm8x41_gpio_set_sid(slave_id, bklt_gpio.pin_id, 0); |
Dhaval Patel | 019057a | 2014-08-12 13:52:25 -0700 | [diff] [blame] | 175 | } |
| 176 | |
Kuogee Hsieh | 208736d | 2014-08-22 14:16:55 -0700 | [diff] [blame] | 177 | void lcd_reg_enable(void) |
Dhaval Patel | 019057a | 2014-08-12 13:52:25 -0700 | [diff] [blame] | 178 | { |
| 179 | struct pm8x41_gpio gpio = { |
| 180 | .direction = PM_GPIO_DIR_OUT, |
| 181 | .function = PM_GPIO_FUNC_HIGH, |
| 182 | .vin_sel = 2, /* VIN_2 */ |
| 183 | .output_buffer = PM_GPIO_OUT_CMOS, |
| 184 | .out_strength = PM_GPIO_OUT_DRIVE_MED, |
| 185 | }; |
| 186 | |
Kuogee Hsieh | 208736d | 2014-08-22 14:16:55 -0700 | [diff] [blame] | 187 | pm8x41_gpio_config(lcd_reg_en.pin_id, &gpio); |
| 188 | pm8x41_gpio_set(lcd_reg_en.pin_id, 1); |
| 189 | } |
| 190 | |
| 191 | void lcd_reg_disable(void) |
| 192 | { |
| 193 | pm8x41_gpio_set(lcd_reg_en.pin_id, 0); |
Dhaval Patel | 019057a | 2014-08-12 13:52:25 -0700 | [diff] [blame] | 194 | } |
| 195 | |
| 196 | int target_backlight_ctrl(struct backlight *bl, uint8_t enable) |
| 197 | { |
| 198 | uint32_t ret = NO_ERROR; |
| 199 | struct pm8x41_mpp mpp; |
| 200 | int rc; |
| 201 | |
| 202 | if (!bl) { |
| 203 | dprintf(CRITICAL, "backlight structure is not available\n"); |
| 204 | return ERR_INVALID_ARGS; |
| 205 | } |
| 206 | |
| 207 | switch (bl->bl_interface_type) { |
| 208 | case BL_WLED: |
| 209 | /* Enable MPP4 */ |
| 210 | pmi8994_config_mpp_slave_id(PMIC_MPP_SLAVE_ID); |
| 211 | mpp.base = PM8x41_MMP4_BASE; |
| 212 | mpp.vin = MPP_VIN2; |
| 213 | if (enable) { |
| 214 | pm_pwm_enable(false); |
| 215 | rc = pm_pwm_config(PWM_DUTY_US, PWM_PERIOD_US); |
| 216 | if (rc < 0) { |
| 217 | mpp.mode = MPP_HIGH; |
| 218 | } else { |
| 219 | mpp.mode = MPP_DTEST1; |
| 220 | pm_pwm_enable(true); |
| 221 | } |
| 222 | pm8x41_config_output_mpp(&mpp); |
| 223 | pm8x41_enable_mpp(&mpp, MPP_ENABLE); |
| 224 | } else { |
| 225 | pm_pwm_enable(false); |
| 226 | pm8x41_enable_mpp(&mpp, MPP_DISABLE); |
| 227 | } |
| 228 | /* Need delay before power on regulators */ |
| 229 | mdelay(20); |
| 230 | /* Enable WLED backlight control */ |
| 231 | ret = msm8994_wled_backlight_ctrl(enable); |
| 232 | break; |
| 233 | case BL_PWM: |
Kuogee Hsieh | 911866e | 2014-09-02 16:41:18 -0700 | [diff] [blame] | 234 | /* Enable MPP1 */ |
| 235 | pmi8994_config_mpp_slave_id(PMIC_MPP_SLAVE_ID); |
| 236 | mpp.base = PM8x41_MMP1_BASE; |
| 237 | mpp.vin = MPP_VIN2; |
| 238 | mpp.mode = MPP_DTEST4; |
| 239 | if (enable) { |
| 240 | pm8x41_config_output_mpp(&mpp); |
| 241 | pm8x41_enable_mpp(&mpp, MPP_ENABLE); |
| 242 | } else { |
| 243 | pm8x41_enable_mpp(&mpp, MPP_DISABLE); |
| 244 | } |
| 245 | /* Need delay before power on regulators */ |
| 246 | mdelay(20); |
Dhaval Patel | 019057a | 2014-08-12 13:52:25 -0700 | [diff] [blame] | 247 | ret = msm8994_pwm_backlight_ctrl(enable); |
| 248 | break; |
| 249 | default: |
| 250 | dprintf(CRITICAL, "backlight type:%d not supported\n", |
| 251 | bl->bl_interface_type); |
| 252 | return ERR_NOT_SUPPORTED; |
| 253 | } |
| 254 | |
| 255 | return ret; |
| 256 | } |
| 257 | |
Casey Piper | 6c2f113 | 2015-03-24 11:37:19 -0700 | [diff] [blame^] | 258 | int target_hdmi_pll_clock(uint8_t enable, struct msm_panel_info *pinfo) |
| 259 | { |
| 260 | if (enable) { |
| 261 | hdmi_phy_reset(); |
| 262 | hdmi_pll_config(pinfo->clk_rate); |
| 263 | hdmi_vco_enable(); |
| 264 | hdmi_pixel_clk_enable(pinfo->clk_rate); |
| 265 | } else if(!target_cont_splash_screen()) { |
| 266 | /* Disable clocks if continuous splash off */ |
| 267 | hdmi_pixel_clk_disable(); |
| 268 | hdmi_vco_disable(); |
| 269 | } |
| 270 | |
| 271 | return NO_ERROR; |
| 272 | } |
| 273 | |
Dhaval Patel | 019057a | 2014-08-12 13:52:25 -0700 | [diff] [blame] | 274 | int target_panel_clock(uint8_t enable, struct msm_panel_info *pinfo) |
| 275 | { |
Huaibin Yang | 928201b | 2015-01-15 10:40:21 -0800 | [diff] [blame] | 276 | uint32_t ret = NO_ERROR; |
Dhaval Patel | 019057a | 2014-08-12 13:52:25 -0700 | [diff] [blame] | 277 | struct mdss_dsi_pll_config *pll_data; |
Aravind Venkateswaran | f355432 | 2014-12-08 12:03:48 -0800 | [diff] [blame] | 278 | uint32_t flags; |
Huaibin Yang | 928201b | 2015-01-15 10:40:21 -0800 | [diff] [blame] | 279 | struct dfps_pll_codes *pll_codes = &pinfo->mipi.pll_codes; |
Aravind Venkateswaran | f355432 | 2014-12-08 12:03:48 -0800 | [diff] [blame] | 280 | |
| 281 | if (pinfo->dest == DISPLAY_2) { |
| 282 | flags = MMSS_DSI_CLKS_FLAG_DSI1; |
| 283 | if (pinfo->mipi.dual_dsi) |
| 284 | flags |= MMSS_DSI_CLKS_FLAG_DSI0; |
| 285 | } else { |
| 286 | flags = MMSS_DSI_CLKS_FLAG_DSI0; |
| 287 | if (pinfo->mipi.dual_dsi) |
| 288 | flags |= MMSS_DSI_CLKS_FLAG_DSI1; |
| 289 | } |
Dhaval Patel | 019057a | 2014-08-12 13:52:25 -0700 | [diff] [blame] | 290 | |
| 291 | pll_data = pinfo->mipi.dsi_pll_config; |
Huaibin Yang | 928201b | 2015-01-15 10:40:21 -0800 | [diff] [blame] | 292 | |
| 293 | if (!enable) { |
Aravind Venkateswaran | f355432 | 2014-12-08 12:03:48 -0800 | [diff] [blame] | 294 | mmss_dsi_clock_disable(flags); |
Huaibin Yang | 928201b | 2015-01-15 10:40:21 -0800 | [diff] [blame] | 295 | goto clks_disable; |
Dhaval Patel | 019057a | 2014-08-12 13:52:25 -0700 | [diff] [blame] | 296 | } |
| 297 | |
Huaibin Yang | 928201b | 2015-01-15 10:40:21 -0800 | [diff] [blame] | 298 | mdp_gdsc_ctrl(enable); |
| 299 | mmss_bus_clock_enable(); |
| 300 | mdp_clock_enable(); |
| 301 | |
| 302 | ret = restore_secure_cfg(SECURE_DEVICE_MDSS); |
| 303 | if (ret) { |
| 304 | dprintf(CRITICAL, |
| 305 | "%s: Failed to restore MDP security configs", |
| 306 | __func__); |
| 307 | goto clks_disable; |
| 308 | } |
| 309 | |
| 310 | mdss_dsi_auto_pll_20nm_config(pinfo->mipi.pll_0_base, |
| 311 | pinfo->mipi.pll_1_base, pll_data); |
| 312 | |
| 313 | if (!dsi_pll_20nm_enable_seq(pinfo->mipi.pll_0_base)) { |
| 314 | ret = ERROR; |
| 315 | dprintf(CRITICAL, "PLL failed to lock!\n"); |
| 316 | goto clks_disable; |
| 317 | } |
| 318 | |
| 319 | pll_codes->codes[0] = readl_relaxed(pinfo->mipi.pll_0_base + |
| 320 | MMSS_DSI_PHY_PLL_CORE_KVCO_CODE); |
| 321 | pll_codes->codes[1] = readl_relaxed(pinfo->mipi.pll_0_base + |
| 322 | MMSS_DSI_PHY_PLL_CORE_VCO_TUNE); |
| 323 | dprintf(SPEW, "codes %d %d\n", pll_codes->codes[0], |
| 324 | pll_codes->codes[1]); |
| 325 | |
| 326 | mmss_dsi_clock_enable(DSI0_PHY_PLL_OUT, flags, |
| 327 | pll_data->pclk_m, |
| 328 | pll_data->pclk_n, |
| 329 | pll_data->pclk_d); |
| 330 | |
Dhaval Patel | 019057a | 2014-08-12 13:52:25 -0700 | [diff] [blame] | 331 | return NO_ERROR; |
Huaibin Yang | 928201b | 2015-01-15 10:40:21 -0800 | [diff] [blame] | 332 | |
| 333 | clks_disable: |
| 334 | mdp_clock_disable(); |
| 335 | mmss_bus_clock_disable(); |
| 336 | mdp_gdsc_ctrl(0); |
| 337 | |
| 338 | return ret; |
Dhaval Patel | 019057a | 2014-08-12 13:52:25 -0700 | [diff] [blame] | 339 | } |
| 340 | |
| 341 | int target_panel_reset(uint8_t enable, struct panel_reset_sequence *resetseq, |
| 342 | struct msm_panel_info *pinfo) |
| 343 | { |
| 344 | uint32_t i = 0; |
| 345 | |
| 346 | if (enable) { |
| 347 | gpio_tlmm_config(reset_gpio.pin_id, 0, |
| 348 | reset_gpio.pin_direction, reset_gpio.pin_pull, |
| 349 | reset_gpio.pin_strength, reset_gpio.pin_state); |
| 350 | /* reset */ |
| 351 | for (i = 0; i < RESET_GPIO_SEQ_LEN; i++) { |
| 352 | if (resetseq->pin_state[i] == GPIO_STATE_LOW) |
| 353 | gpio_set(reset_gpio.pin_id, GPIO_STATE_LOW); |
| 354 | else |
| 355 | gpio_set(reset_gpio.pin_id, GPIO_STATE_HIGH); |
| 356 | mdelay(resetseq->sleep[i]); |
| 357 | } |
Kuogee Hsieh | 911866e | 2014-09-02 16:41:18 -0700 | [diff] [blame] | 358 | lcd_bklt_reg_enable(); |
Dhaval Patel | 019057a | 2014-08-12 13:52:25 -0700 | [diff] [blame] | 359 | } else { |
Kuogee Hsieh | 911866e | 2014-09-02 16:41:18 -0700 | [diff] [blame] | 360 | lcd_bklt_reg_disable(); |
Dhaval Patel | 019057a | 2014-08-12 13:52:25 -0700 | [diff] [blame] | 361 | gpio_set(reset_gpio.pin_id, 0); |
| 362 | } |
| 363 | |
| 364 | return NO_ERROR; |
| 365 | } |
| 366 | |
Kuogee Hsieh | 099022f | 2014-12-05 15:43:40 -0800 | [diff] [blame] | 367 | static void wled_init(struct msm_panel_info *pinfo) |
| 368 | { |
| 369 | struct qpnp_wled_config_data config = {0}; |
| 370 | struct labibb_desc *labibb; |
| 371 | int display_type = 0; |
| 372 | |
| 373 | labibb = pinfo->labibb; |
| 374 | |
| 375 | if (labibb) |
| 376 | display_type = labibb->amoled_panel; |
| 377 | |
| 378 | config.display_type = display_type; |
| 379 | config.lab_init_volt = 4600000; /* fixed, see pmi register */ |
| 380 | config.ibb_init_volt = 1400000; /* fixed, see pmi register */ |
| 381 | |
| 382 | if (labibb && labibb->force_config) { |
| 383 | config.lab_min_volt = labibb->lab_min_volt; |
| 384 | config.lab_max_volt = labibb->lab_max_volt; |
| 385 | config.ibb_min_volt = labibb->ibb_min_volt; |
| 386 | config.ibb_max_volt = labibb->ibb_max_volt; |
| 387 | config.pwr_up_delay = labibb->pwr_up_delay; |
| 388 | config.pwr_down_delay = labibb->pwr_down_delay; |
| 389 | config.ibb_discharge_en = labibb->ibb_discharge_en; |
| 390 | } else { |
| 391 | /* default */ |
| 392 | config.pwr_up_delay = 3; |
| 393 | config.pwr_down_delay = 3; |
| 394 | config.ibb_discharge_en = 1; |
| 395 | if (display_type) { /* amoled */ |
| 396 | config.lab_min_volt = 4600000; |
| 397 | config.lab_max_volt = 4600000; |
| 398 | config.ibb_min_volt = 4000000; |
| 399 | config.ibb_max_volt = 4000000; |
| 400 | } else { /* lcd */ |
| 401 | config.lab_min_volt = 5500000; |
| 402 | config.lab_max_volt = 5500000; |
| 403 | config.ibb_min_volt = 5500000; |
| 404 | config.ibb_max_volt = 5500000; |
| 405 | } |
| 406 | } |
| 407 | |
| 408 | dprintf(SPEW, "%s: %d %d %d %d %d %d %d %d %d %d\n", __func__, |
| 409 | config.display_type, |
| 410 | config.lab_min_volt, config.lab_max_volt, |
| 411 | config.ibb_min_volt, config.ibb_max_volt, |
| 412 | config.lab_init_volt, config.ibb_init_volt, |
| 413 | config.pwr_up_delay, config.pwr_down_delay, |
| 414 | config.ibb_discharge_en); |
| 415 | |
| 416 | |
| 417 | /* QPNP WLED init for display backlight */ |
| 418 | pm8x41_wled_config_slave_id(PMIC_WLED_SLAVE_ID); |
| 419 | |
| 420 | qpnp_wled_init(&config); |
| 421 | } |
| 422 | |
Kuogee Hsieh | 93bcff6 | 2014-08-22 14:02:08 -0700 | [diff] [blame] | 423 | int target_ldo_ctrl(uint8_t enable, struct msm_panel_info *pinfo) |
Dhaval Patel | 019057a | 2014-08-12 13:52:25 -0700 | [diff] [blame] | 424 | { |
| 425 | if (enable) { |
| 426 | regulator_enable(); /* L2, L12, L14, and L28 */ |
| 427 | mdelay(10); |
Kuogee Hsieh | 099022f | 2014-12-05 15:43:40 -0800 | [diff] [blame] | 428 | wled_init(pinfo); |
Dhaval Patel | 019057a | 2014-08-12 13:52:25 -0700 | [diff] [blame] | 429 | qpnp_ibb_enable(true); /* +5V and -5V */ |
| 430 | mdelay(50); |
Kuogee Hsieh | 208736d | 2014-08-22 14:16:55 -0700 | [diff] [blame] | 431 | |
| 432 | if (pinfo->lcd_reg_en) |
| 433 | lcd_reg_enable(); |
Dhaval Patel | 019057a | 2014-08-12 13:52:25 -0700 | [diff] [blame] | 434 | } else { |
Kuogee Hsieh | 208736d | 2014-08-22 14:16:55 -0700 | [diff] [blame] | 435 | if (pinfo->lcd_reg_en) |
| 436 | lcd_reg_disable(); |
| 437 | |
Dhaval Patel | 019057a | 2014-08-12 13:52:25 -0700 | [diff] [blame] | 438 | regulator_disable(); |
| 439 | } |
| 440 | |
| 441 | return NO_ERROR; |
| 442 | } |
| 443 | |
| 444 | int target_display_pre_on() |
| 445 | { |
Ingrid Gallardo | c9776bd | 2014-09-04 14:13:28 -0700 | [diff] [blame] | 446 | writel(0xC0000CCC, MDP_CLK_CTRL0); |
| 447 | writel(0xC0000CCC, MDP_CLK_CTRL1); |
Dhaval Patel | 019057a | 2014-08-12 13:52:25 -0700 | [diff] [blame] | 448 | writel(0x00CCCCCC, MDP_CLK_CTRL2); |
| 449 | writel(0x000000CC, MDP_CLK_CTRL6); |
| 450 | writel(0x0CCCC0C0, MDP_CLK_CTRL3); |
| 451 | writel(0xCCCCC0C0, MDP_CLK_CTRL4); |
| 452 | writel(0xCCCCC0C0, MDP_CLK_CTRL5); |
| 453 | writel(0x00CCC000, MDP_CLK_CTRL7); |
| 454 | |
Dhaval Patel | 019057a | 2014-08-12 13:52:25 -0700 | [diff] [blame] | 455 | return NO_ERROR; |
| 456 | } |
| 457 | |
Jeevan Shriram | 7aacc32 | 2014-12-29 16:02:25 -0800 | [diff] [blame] | 458 | int target_display_get_base_offset(uint32_t base) |
| 459 | { |
| 460 | if(platform_is_msm8992()) { |
| 461 | if (base == MIPI_DSI0_BASE) |
| 462 | return DSI0_BASE_ADJUST; |
| 463 | else if (base == MIPI_DSI1_BASE) |
| 464 | return DSI1_BASE_ADJUST; |
| 465 | } |
| 466 | |
| 467 | return 0; |
| 468 | } |
| 469 | |
Dhaval Patel | 019057a | 2014-08-12 13:52:25 -0700 | [diff] [blame] | 470 | bool target_display_panel_node(char *panel_name, char *pbuf, uint16_t buf_size) |
| 471 | { |
Ajay Singh Parmar | cc6477b | 2014-11-14 16:59:44 -0800 | [diff] [blame] | 472 | int prefix_string_len = strlen(DISPLAY_CMDLINE_PREFIX); |
| 473 | bool ret = true; |
Dhaval Patel | 019057a | 2014-08-12 13:52:25 -0700 | [diff] [blame] | 474 | |
Ajay Singh Parmar | cc6477b | 2014-11-14 16:59:44 -0800 | [diff] [blame] | 475 | panel_name += strspn(panel_name, " "); |
| 476 | |
| 477 | if (!strcmp(panel_name, HDMI_PANEL_NAME)) { |
| 478 | if (buf_size < (prefix_string_len + LK_OVERRIDE_PANEL_LEN + |
| 479 | strlen(HDMI_CONTROLLER_STRING))) { |
| 480 | dprintf(CRITICAL, "command line argument is greater than buffer size\n"); |
| 481 | return false; |
| 482 | } |
| 483 | |
| 484 | strlcpy(pbuf, DISPLAY_CMDLINE_PREFIX, buf_size); |
| 485 | buf_size -= prefix_string_len; |
| 486 | strlcat(pbuf, LK_OVERRIDE_PANEL, buf_size); |
| 487 | buf_size -= LK_OVERRIDE_PANEL_LEN; |
| 488 | strlcat(pbuf, HDMI_CONTROLLER_STRING, buf_size); |
| 489 | } else { |
| 490 | ret = gcdb_display_cmdline_arg(panel_name, pbuf, buf_size); |
| 491 | } |
| 492 | |
| 493 | return ret; |
Dhaval Patel | 019057a | 2014-08-12 13:52:25 -0700 | [diff] [blame] | 494 | } |
| 495 | |
| 496 | void target_display_init(const char *panel_name) |
| 497 | { |
Veera Sundaram Sankaran | 7868d54 | 2015-01-02 14:48:47 -0800 | [diff] [blame] | 498 | char cont_splash = '\0'; |
Veera Sundaram Sankaran | 3b75882 | 2014-10-17 12:15:39 -0700 | [diff] [blame] | 499 | |
Veera Sundaram Sankaran | 7868d54 | 2015-01-02 14:48:47 -0800 | [diff] [blame] | 500 | set_panel_cmd_string(panel_name, &cont_splash); |
| 501 | panel_name += strspn(panel_name, " "); |
Veera Sundaram Sankaran | 3b75882 | 2014-10-17 12:15:39 -0700 | [diff] [blame] | 502 | if (!strcmp(panel_name, NO_PANEL_CONFIG) |
| 503 | || !strcmp(panel_name, SIM_VIDEO_PANEL) |
| 504 | || !strcmp(panel_name, SIM_DUALDSI_VIDEO_PANEL) |
| 505 | || !strcmp(panel_name, SIM_CMD_PANEL) |
| 506 | || !strcmp(panel_name, SIM_DUALDSI_CMD_PANEL)) { |
Veera Sundaram Sankaran | b620f23 | 2014-09-03 22:43:53 -0700 | [diff] [blame] | 507 | dprintf(INFO, "Selected panel: %s\nSkip panel configuration\n", |
Veera Sundaram Sankaran | 3b75882 | 2014-10-17 12:15:39 -0700 | [diff] [blame] | 508 | panel_name); |
Veera Sundaram Sankaran | b620f23 | 2014-09-03 22:43:53 -0700 | [diff] [blame] | 509 | return; |
Ajay Singh Parmar | cc6477b | 2014-11-14 16:59:44 -0800 | [diff] [blame] | 510 | } else if (!strcmp(panel_name, HDMI_PANEL_NAME)) { |
| 511 | return; |
Veera Sundaram Sankaran | b620f23 | 2014-09-03 22:43:53 -0700 | [diff] [blame] | 512 | } |
Veera Sundaram Sankaran | 7868d54 | 2015-01-02 14:48:47 -0800 | [diff] [blame] | 513 | |
Veera Sundaram Sankaran | 089f70d | 2014-12-09 14:17:05 -0800 | [diff] [blame] | 514 | if (gcdb_display_init(panel_name, MDP_REV_50, (void *)MIPI_FB_ADDR)) { |
Justin Philip | be9de5c | 2014-09-17 12:26:49 +0530 | [diff] [blame] | 515 | target_force_cont_splash_disable(true); |
Dhaval Patel | 019057a | 2014-08-12 13:52:25 -0700 | [diff] [blame] | 516 | msm_display_off(); |
Justin Philip | be9de5c | 2014-09-17 12:26:49 +0530 | [diff] [blame] | 517 | } |
Veera Sundaram Sankaran | 7868d54 | 2015-01-02 14:48:47 -0800 | [diff] [blame] | 518 | |
| 519 | if (cont_splash == '0') { |
| 520 | dprintf(INFO, "Forcing continuous splash disable\n"); |
| 521 | target_force_cont_splash_disable(true); |
| 522 | } |
Dhaval Patel | 019057a | 2014-08-12 13:52:25 -0700 | [diff] [blame] | 523 | } |
| 524 | |
| 525 | void target_display_shutdown(void) |
| 526 | { |
| 527 | gcdb_display_shutdown(); |
| 528 | } |