Jeevan Shriram | 2d3500b | 2014-12-29 16:25:06 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved. |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 2 | * |
| 3 | * Redistribution and use in source and binary forms, with or without |
| 4 | * modification, are permitted provided that the following conditions |
| 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 <smem.h> |
| 32 | #include <err.h> |
| 33 | #include <msm_panel.h> |
| 34 | #include <mipi_dsi.h> |
| 35 | #include <pm8x41.h> |
| 36 | #include <pm8x41_wled.h> |
| 37 | #include <board.h> |
| 38 | #include <mdp5.h> |
| 39 | #include <scm.h> |
| 40 | #include <platform/gpio.h> |
| 41 | #include <platform/iomap.h> |
| 42 | #include <target/display.h> |
Aparna Mallavarapu | 430797d | 2014-05-15 11:52:56 +0530 | [diff] [blame] | 43 | #include <i2c_qup.h> |
| 44 | #include <blsp_qup.h> |
Vineet Bajaj | a83cf80 | 2015-05-07 17:31:33 +0530 | [diff] [blame^] | 45 | #include <mipi_dsi_i2c.h> |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 46 | |
| 47 | #include "include/panel.h" |
| 48 | #include "include/display_resource.h" |
Veera Sundaram Sankaran | 87f8813 | 2015-01-28 11:32:44 -0800 | [diff] [blame] | 49 | #include "gcdb_display.h" |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 50 | |
Padmanabhan Komanduru | 18aa507 | 2014-04-17 16:52:53 +0530 | [diff] [blame] | 51 | #define VCO_DELAY_USEC 1000 |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 52 | #define GPIO_STATE_LOW 0 |
| 53 | #define GPIO_STATE_HIGH 2 |
| 54 | #define RESET_GPIO_SEQ_LEN 3 |
| 55 | #define PWM_DUTY_US 13 |
| 56 | #define PWM_PERIOD_US 27 |
| 57 | |
Padmanabhan Komanduru | 0a5db94 | 2014-04-17 16:56:04 +0530 | [diff] [blame] | 58 | static void mdss_dsi_uniphy_pll_sw_reset_8916(uint32_t pll_base) |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 59 | { |
Padmanabhan Komanduru | 0a5db94 | 2014-04-17 16:56:04 +0530 | [diff] [blame] | 60 | writel(0x01, pll_base + 0x0068); /* PLL TEST CFG */ |
| 61 | mdelay(1); |
| 62 | writel(0x00, pll_base + 0x0068); /* PLL TEST CFG */ |
| 63 | mdelay(1); |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 64 | } |
| 65 | |
Shuo Yan | d954f18 | 2015-02-11 10:08:49 +0800 | [diff] [blame] | 66 | static void dsi_pll_toggle_lock_detect_8916(uint32_t pll_base) |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 67 | { |
Shuo Yan | d954f18 | 2015-02-11 10:08:49 +0800 | [diff] [blame] | 68 | writel(0x04, pll_base + 0x0064); /* LKDetect CFG2 */ |
| 69 | udelay(1); |
| 70 | writel(0x05, pll_base + 0x0064); /* LKDetect CFG2 */ |
| 71 | udelay(512); |
| 72 | } |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 73 | |
Shuo Yan | d954f18 | 2015-02-11 10:08:49 +0800 | [diff] [blame] | 74 | static void dsi_pll_sw_reset_8916(uint32_t pll_base) |
| 75 | { |
Padmanabhan Komanduru | 0a5db94 | 2014-04-17 16:56:04 +0530 | [diff] [blame] | 76 | writel(0x01, pll_base + 0x0068); /* PLL TEST CFG */ |
| 77 | udelay(1); |
| 78 | writel(0x00, pll_base + 0x0068); /* PLL TEST CFG */ |
Shuo Yan | d954f18 | 2015-02-11 10:08:49 +0800 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | static uint32_t gf_1_dsi_pll_enable_sequence_8916(uint32_t pll_base) |
| 82 | { |
| 83 | uint32_t rc; |
| 84 | |
| 85 | dsi_pll_sw_reset_8916(pll_base); |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 86 | |
| 87 | /* |
| 88 | * Add hardware recommended delays between register writes for |
| 89 | * the updates to take effect. These delays are necessary for the |
| 90 | * PLL to successfully lock |
| 91 | */ |
Shuo Yan | d954f18 | 2015-02-11 10:08:49 +0800 | [diff] [blame] | 92 | writel(0x14, pll_base + 0x0070); /* CAL CFG1*/ |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 93 | writel(0x01, pll_base + 0x0020); /* GLB CFG */ |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 94 | writel(0x05, pll_base + 0x0020); /* GLB CFG */ |
Shuo Yan | d954f18 | 2015-02-11 10:08:49 +0800 | [diff] [blame] | 95 | udelay(3); |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 96 | writel(0x0f, pll_base + 0x0020); /* GLB CFG */ |
Shuo Yan | d954f18 | 2015-02-11 10:08:49 +0800 | [diff] [blame] | 97 | udelay(500); |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 98 | |
Shuo Yan | d954f18 | 2015-02-11 10:08:49 +0800 | [diff] [blame] | 99 | dsi_pll_toggle_lock_detect_8916(pll_base); |
| 100 | rc = readl(pll_base + 0x00c0) & 0x01; |
| 101 | |
| 102 | return rc; |
| 103 | } |
| 104 | |
| 105 | static uint32_t gf_2_dsi_pll_enable_sequence_8916(uint32_t pll_base) |
| 106 | { |
| 107 | uint32_t rc; |
| 108 | |
| 109 | dsi_pll_sw_reset_8916(pll_base); |
| 110 | |
| 111 | /* |
| 112 | * Add hardware recommended delays between register writes for |
| 113 | * the updates to take effect. These delays are necessary for the |
| 114 | * PLL to successfully lock |
| 115 | */ |
| 116 | writel(0x04, pll_base + 0x0070); /* CAL CFG1*/ |
| 117 | writel(0x01, pll_base + 0x0020); /* GLB CFG */ |
| 118 | writel(0x05, pll_base + 0x0020); /* GLB CFG */ |
| 119 | udelay(3); |
| 120 | writel(0x0f, pll_base + 0x0020); /* GLB CFG */ |
| 121 | udelay(500); |
| 122 | |
| 123 | dsi_pll_toggle_lock_detect_8916(pll_base); |
| 124 | rc = readl(pll_base + 0x00c0) & 0x01; |
| 125 | |
| 126 | return rc; |
| 127 | } |
| 128 | |
| 129 | static uint32_t tsmc_dsi_pll_enable_sequence_8916(uint32_t pll_base) |
| 130 | { |
| 131 | uint32_t rc; |
| 132 | |
| 133 | dsi_pll_sw_reset_8916(pll_base); |
| 134 | /* |
| 135 | * Add hardware recommended delays between register writes for |
| 136 | * the updates to take effect. These delays are necessary for the |
| 137 | * PLL to successfully lock |
| 138 | */ |
| 139 | |
| 140 | writel(0x34, pll_base + 0x0070); /* CAL CFG1*/ |
| 141 | writel(0x01, pll_base + 0x0020); /* GLB CFG */ |
| 142 | writel(0x05, pll_base + 0x0020); /* GLB CFG */ |
| 143 | writel(0x0f, pll_base + 0x0020); /* GLB CFG */ |
| 144 | udelay(500); |
| 145 | |
| 146 | dsi_pll_toggle_lock_detect_8916(pll_base); |
| 147 | rc = readl(pll_base + 0x00c0) & 0x01; |
| 148 | |
| 149 | return rc; |
| 150 | } |
| 151 | |
| 152 | |
| 153 | static uint32_t dsi_pll_enable_seq_8916(uint32_t pll_base) |
| 154 | { |
| 155 | uint32_t pll_locked = 0; |
| 156 | uint32_t counter = 0; |
| 157 | |
| 158 | do { |
| 159 | pll_locked = tsmc_dsi_pll_enable_sequence_8916(pll_base); |
| 160 | |
| 161 | dprintf(SPEW, "TSMC pll locked status is %d\n", pll_locked); |
| 162 | ++counter; |
| 163 | } while (!pll_locked && (counter < 3)); |
| 164 | |
| 165 | if(!pll_locked) { |
| 166 | counter = 0; |
| 167 | do { |
| 168 | pll_locked = gf_1_dsi_pll_enable_sequence_8916(pll_base); |
| 169 | |
| 170 | dprintf(SPEW, "GF P1 pll locked status is %d\n", pll_locked); |
| 171 | ++counter; |
| 172 | } while (!pll_locked && (counter < 3)); |
| 173 | } |
| 174 | |
| 175 | if(!pll_locked) { |
| 176 | counter = 0; |
| 177 | do { |
| 178 | pll_locked = gf_2_dsi_pll_enable_sequence_8916(pll_base); |
| 179 | |
| 180 | dprintf(SPEW, "GF P2 pll locked status is %d\n", pll_locked); |
| 181 | ++counter; |
| 182 | } while (!pll_locked && (counter < 3)); |
| 183 | } |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 184 | |
| 185 | return pll_locked; |
| 186 | } |
| 187 | |
| 188 | int target_backlight_ctrl(struct backlight *bl, uint8_t enable) |
| 189 | { |
| 190 | struct pm8x41_mpp mpp; |
| 191 | int rc; |
| 192 | |
Shuo Yan | 123546b | 2014-05-19 19:35:41 +0800 | [diff] [blame] | 193 | if (bl->bl_interface_type == BL_DCS) |
| 194 | return 0; |
| 195 | |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 196 | mpp.base = PM8x41_MMP4_BASE; |
| 197 | mpp.vin = MPP_VIN0; |
| 198 | if (enable) { |
| 199 | pm_pwm_enable(false); |
| 200 | rc = pm_pwm_config(PWM_DUTY_US, PWM_PERIOD_US); |
| 201 | if (rc < 0) |
| 202 | mpp.mode = MPP_HIGH; |
| 203 | else { |
| 204 | mpp.mode = MPP_DTEST1; |
| 205 | pm_pwm_enable(true); |
| 206 | } |
| 207 | pm8x41_config_output_mpp(&mpp); |
| 208 | pm8x41_enable_mpp(&mpp, MPP_ENABLE); |
| 209 | } else { |
| 210 | pm_pwm_enable(false); |
| 211 | pm8x41_enable_mpp(&mpp, MPP_DISABLE); |
| 212 | } |
| 213 | mdelay(20); |
| 214 | return 0; |
| 215 | } |
| 216 | |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 217 | int target_panel_clock(uint8_t enable, struct msm_panel_info *pinfo) |
| 218 | { |
| 219 | int32_t ret = 0; |
| 220 | struct mdss_dsi_pll_config *pll_data; |
| 221 | dprintf(SPEW, "target_panel_clock\n"); |
| 222 | |
| 223 | pll_data = pinfo->mipi.dsi_pll_config; |
Padmanabhan Komanduru | 18aa507 | 2014-04-17 16:52:53 +0530 | [diff] [blame] | 224 | pll_data->vco_delay = VCO_DELAY_USEC; |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 225 | |
| 226 | if (enable) { |
| 227 | mdp_gdsc_ctrl(enable); |
| 228 | mdss_bus_clocks_enable(); |
| 229 | mdp_clock_enable(); |
| 230 | ret = restore_secure_cfg(SECURE_DEVICE_MDSS); |
| 231 | if (ret) { |
| 232 | dprintf(CRITICAL, |
| 233 | "%s: Failed to restore MDP security configs", |
| 234 | __func__); |
| 235 | mdp_clock_disable(); |
| 236 | mdss_bus_clocks_disable(); |
| 237 | mdp_gdsc_ctrl(0); |
| 238 | return ret; |
| 239 | } |
Padmanabhan Komanduru | c0766c8 | 2015-04-27 16:39:15 -0700 | [diff] [blame] | 240 | mdss_dsi_uniphy_pll_sw_reset_8916(pinfo->mipi.pll_base); |
| 241 | mdss_dsi_auto_pll_config(pinfo->mipi.pll_base, |
Jeevan Shriram | 2d3500b | 2014-12-29 16:25:06 -0800 | [diff] [blame] | 242 | pinfo->mipi.ctl_base, pll_data); |
Padmanabhan Komanduru | c0766c8 | 2015-04-27 16:39:15 -0700 | [diff] [blame] | 243 | if (!dsi_pll_enable_seq_8916(pinfo->mipi.pll_base)) |
Padmanabhan Komanduru | 0a5db94 | 2014-04-17 16:56:04 +0530 | [diff] [blame] | 244 | dprintf(CRITICAL, "Not able to enable the pll\n"); |
Vineet Bajaj | e022da6 | 2014-07-24 19:13:34 +0530 | [diff] [blame] | 245 | gcc_dsi_clocks_enable(pinfo->mipi.dual_dsi, pll_data->pclk_m, |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 246 | pll_data->pclk_n, |
| 247 | pll_data->pclk_d); |
| 248 | } else if(!target_cont_splash_screen()) { |
Vineet Bajaj | e022da6 | 2014-07-24 19:13:34 +0530 | [diff] [blame] | 249 | gcc_dsi_clocks_disable(pinfo->mipi.dual_dsi); |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 250 | mdp_clock_disable(); |
| 251 | mdss_bus_clocks_disable(); |
| 252 | mdp_gdsc_ctrl(enable); |
| 253 | } |
| 254 | |
| 255 | return 0; |
| 256 | } |
| 257 | |
Aparna Mallavarapu | 430797d | 2014-05-15 11:52:56 +0530 | [diff] [blame] | 258 | #define QRD_LCD_I2C_ADDRESS 0x3E |
| 259 | #define QRD_LCD_VPOS_ADDRESS 0x00 |
| 260 | #define QRD_LCD_VNEG_ADDRESS 0x01 |
| 261 | #define QRD_LCD_DIS_ADDRESS 0x03 |
| 262 | #define QRD_LCD_CONTROL_ADDRESS 0xFF |
| 263 | |
| 264 | static struct qup_i2c_dev *i2c_dev; |
| 265 | static int qrd_lcd_i2c_read(uint8_t addr) |
| 266 | { |
| 267 | int ret = 0; |
| 268 | /* Create a i2c_msg buffer, that is used to put the controller into read |
| 269 | mode and then to read some data. */ |
| 270 | struct i2c_msg msg_buf[] = { |
| 271 | {QRD_LCD_I2C_ADDRESS, I2C_M_WR, 1, &addr}, |
| 272 | {QRD_LCD_I2C_ADDRESS, I2C_M_RD, 1, &ret} |
| 273 | }; |
| 274 | |
| 275 | ret = qup_i2c_xfer(i2c_dev, msg_buf, 2); |
| 276 | if(ret < 0) { |
| 277 | dprintf(CRITICAL, "qup_i2c_xfer error %d\n", ret); |
| 278 | return ret; |
| 279 | } |
| 280 | return 0; |
| 281 | } |
| 282 | |
| 283 | static int qrd_lcd_i2c_write(uint8_t addr, uint8_t val) |
| 284 | { |
| 285 | int ret = 0; |
| 286 | uint8_t data_buf[] = { addr, val }; |
| 287 | |
| 288 | /* Create a i2c_msg buffer, that is used to put the controller into write |
| 289 | mode and then to write some data. */ |
| 290 | struct i2c_msg msg_buf[] = { {QRD_LCD_I2C_ADDRESS, |
| 291 | I2C_M_WR, 2, data_buf} |
| 292 | }; |
| 293 | |
| 294 | ret = qup_i2c_xfer(i2c_dev, msg_buf, 1); |
| 295 | if(ret < 0) { |
| 296 | dprintf(CRITICAL, "qup_i2c_xfer error %d\n", ret); |
| 297 | return ret; |
| 298 | } |
| 299 | return 0; |
| 300 | } |
| 301 | |
Vineet Bajaj | a83cf80 | 2015-05-07 17:31:33 +0530 | [diff] [blame^] | 302 | static int dsi2HDMI_i2c_write_regs(struct mipi_dsi_i2c_cmd *cfg, int size) |
| 303 | { |
| 304 | int ret = NO_ERROR; |
| 305 | int i; |
| 306 | |
| 307 | if (!cfg) |
| 308 | return ERR_INVALID_ARGS; |
| 309 | |
| 310 | for (i = 0; i < size; i++) { |
| 311 | ret = mipi_dsi_i2c_write_byte(cfg[i].i2c_addr, cfg[i].reg, |
| 312 | cfg[i].val); |
| 313 | if (ret) { |
| 314 | dprintf(CRITICAL, "mipi_dsi reg writes failed\n"); |
| 315 | goto w_regs_fail; |
| 316 | } |
| 317 | if (cfg[i].sleep_in_ms) { |
| 318 | udelay(cfg[i].sleep_in_ms*1000); |
| 319 | } |
| 320 | } |
| 321 | w_regs_fail: |
| 322 | return ret; |
| 323 | } |
| 324 | |
| 325 | int target_display_dsi2hdmi_config(struct msm_panel_info *pinfo) |
| 326 | { |
| 327 | int ret = NO_ERROR; |
| 328 | |
| 329 | if (!pinfo) |
| 330 | return ERR_INVALID_ARGS; |
| 331 | |
| 332 | /* |
| 333 | * If dsi to HDMI bridge chip connected then |
| 334 | * send I2c commands to the chip |
| 335 | */ |
| 336 | if (pinfo->adv7533.dsi_setup_cfg_i2c_cmd) |
| 337 | ret = dsi2HDMI_i2c_write_regs(pinfo->adv7533.dsi_setup_cfg_i2c_cmd, |
| 338 | pinfo->adv7533.num_of_cfg_i2c_cmds); |
| 339 | |
| 340 | if (pinfo->adv7533.dsi_tg_i2c_cmd) |
| 341 | ret = dsi2HDMI_i2c_write_regs(pinfo->adv7533.dsi_tg_i2c_cmd, |
| 342 | pinfo->adv7533.num_of_tg_i2c_cmds); |
| 343 | |
| 344 | return ret; |
| 345 | } |
| 346 | |
Mao Flynn | 732e3c2 | 2014-07-02 17:39:02 +0800 | [diff] [blame] | 347 | static int target_panel_reset_skuh(uint8_t enable) |
| 348 | { |
| 349 | int ret = NO_ERROR; |
| 350 | if (enable) { |
| 351 | /* for tps65132 ENP pin */ |
| 352 | gpio_tlmm_config(enp_gpio.pin_id, 0, |
| 353 | enp_gpio.pin_direction, enp_gpio.pin_pull, |
| 354 | enp_gpio.pin_strength, |
| 355 | enp_gpio.pin_state); |
| 356 | gpio_set_dir(enp_gpio.pin_id, 2); |
| 357 | |
| 358 | /* for tps65132 ENN pin*/ |
| 359 | gpio_tlmm_config(enn_gpio.pin_id, 0, |
| 360 | enn_gpio.pin_direction, enn_gpio.pin_pull, |
| 361 | enn_gpio.pin_strength, |
| 362 | enn_gpio.pin_state); |
| 363 | gpio_set_dir(enn_gpio.pin_id, 2); |
| 364 | |
| 365 | i2c_dev = qup_blsp_i2c_init(BLSP_ID_1, QUP_ID_1, 100000, 19200000); |
| 366 | if(!i2c_dev) { |
| 367 | dprintf(CRITICAL, "qup_blsp_i2c_init failed \n"); |
| 368 | ASSERT(0); |
| 369 | } |
| 370 | |
| 371 | ret = qrd_lcd_i2c_write(QRD_LCD_VPOS_ADDRESS, 0x0E); /* 5.4V */ |
| 372 | if (ret) { |
| 373 | dprintf(CRITICAL, "VPOS Register: I2C Write failure\n"); |
| 374 | } |
| 375 | |
| 376 | ret = qrd_lcd_i2c_write(QRD_LCD_VNEG_ADDRESS, 0x0E); /* -5.4V */ |
| 377 | if (ret) { |
| 378 | dprintf(CRITICAL, "VNEG Register: I2C write failure\n"); |
| 379 | } |
| 380 | |
| 381 | ret = qrd_lcd_i2c_write(QRD_LCD_DIS_ADDRESS, 0x0F); |
| 382 | if (ret) { |
| 383 | dprintf(CRITICAL, "Apps freq DIS Register: I2C write failure\n"); |
| 384 | } |
| 385 | |
| 386 | ret = qrd_lcd_i2c_write(QRD_LCD_CONTROL_ADDRESS, 0xF0); |
| 387 | if (ret) { |
| 388 | dprintf(CRITICAL, "Control Register: I2C write failure\n"); |
| 389 | } |
| 390 | } else { |
| 391 | gpio_set_dir(enp_gpio.pin_id, 0); /* ENP */ |
| 392 | gpio_set_dir(enn_gpio.pin_id, 0); /* ENN */ |
| 393 | } |
| 394 | return 0; |
| 395 | } |
| 396 | |
| 397 | static int target_panel_reset_skuk(uint8_t enable) |
| 398 | { |
| 399 | if (enable) { |
| 400 | /* for tps65132 ENP pin*/ |
| 401 | gpio_tlmm_config(enp_gpio_skuk.pin_id, 0, |
| 402 | enp_gpio_skuk.pin_direction, enp_gpio_skuk.pin_pull, |
| 403 | enp_gpio_skuk.pin_strength, enp_gpio_skuk.pin_state); |
| 404 | gpio_set_dir(enp_gpio_skuk.pin_id, 2); |
| 405 | |
| 406 | /* for tps65132 ENN pin*/ |
| 407 | gpio_tlmm_config(enn_gpio_skuk.pin_id, 0, |
| 408 | enn_gpio_skuk.pin_direction, enn_gpio_skuk.pin_pull, |
| 409 | enn_gpio_skuk.pin_strength, enn_gpio_skuk.pin_state); |
| 410 | gpio_set_dir(enn_gpio_skuk.pin_id, 2); |
| 411 | |
| 412 | /* configure backlight gpio for SKUK */ |
| 413 | gpio_tlmm_config(bkl_gpio_skuk.pin_id, 0, |
| 414 | bkl_gpio_skuk.pin_direction, bkl_gpio_skuk.pin_pull, |
| 415 | bkl_gpio_skuk.pin_strength, bkl_gpio_skuk.pin_state); |
| 416 | gpio_set_dir(bkl_gpio_skuk.pin_id, 2); |
| 417 | } else { |
| 418 | gpio_set_dir(bkl_gpio_skuk.pin_id, 0); |
| 419 | gpio_set_dir(enp_gpio_skuk.pin_id, 0); /* ENP */ |
| 420 | gpio_set_dir(enn_gpio_skuk.pin_id, 0); /* ENN */ |
| 421 | } |
| 422 | return 0; |
| 423 | } |
| 424 | |
Vineet Bajaj | 3acf94f | 2014-12-04 19:55:03 +0530 | [diff] [blame] | 425 | int target_panel_reset_incell(uint8_t enable) |
| 426 | { |
| 427 | /*Enable the gpios in 75->97->77 order for incell panel*/ |
| 428 | if (enable) { |
| 429 | gpio_tlmm_config(enable_gpio_1.pin_id, 0, |
| 430 | enable_gpio_1.pin_direction, enable_gpio_1.pin_pull, |
| 431 | enable_gpio_1.pin_strength, enable_gpio_1.pin_state); |
| 432 | gpio_set_dir(enable_gpio_1.pin_id, 2); |
| 433 | |
| 434 | gpio_tlmm_config(enp_gpio.pin_id, 0, |
| 435 | enp_gpio.pin_direction, enp_gpio.pin_pull, |
| 436 | enp_gpio.pin_strength, enp_gpio.pin_state); |
| 437 | gpio_set_dir(enp_gpio.pin_id, 2); |
| 438 | |
| 439 | gpio_tlmm_config(enn_gpio_1.pin_id, 0, |
| 440 | enn_gpio_1.pin_direction, enn_gpio_1.pin_pull, |
| 441 | enn_gpio_1.pin_strength, enn_gpio_1.pin_state); |
| 442 | gpio_set_dir(enn_gpio_1.pin_id, 2); |
| 443 | } |
| 444 | else { |
| 445 | gpio_set_dir(enable_gpio_1.pin_id, 0); |
| 446 | gpio_set_dir(enp_gpio.pin_id, 0); /* ENP */ |
| 447 | gpio_set_dir(enn_gpio_1.pin_id, 0); /* ENN */ |
| 448 | } |
| 449 | } |
| 450 | |
Vineet Bajaj | 5be1e4a | 2015-02-02 15:07:49 +0530 | [diff] [blame] | 451 | int target_panel_reset_jdi_a216(uint8_t enable) |
| 452 | { |
| 453 | if (enable) { |
| 454 | gpio_tlmm_config(ts_reset_gpio.pin_id, 0, |
| 455 | ts_reset_gpio.pin_direction, ts_reset_gpio.pin_pull, |
| 456 | ts_reset_gpio.pin_strength, ts_reset_gpio.pin_state); |
| 457 | gpio_set_dir(ts_reset_gpio.pin_id, GPIO_STATE_HIGH); |
| 458 | } else { |
| 459 | gpio_set_dir(ts_reset_gpio.pin_id, GPIO_STATE_LOW); |
| 460 | } |
| 461 | } |
| 462 | |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 463 | int target_panel_reset(uint8_t enable, struct panel_reset_sequence *resetseq, |
| 464 | struct msm_panel_info *pinfo) |
| 465 | { |
| 466 | int ret = NO_ERROR; |
Mao Flynn | 8140947 | 2014-04-10 15:01:30 +0800 | [diff] [blame] | 467 | uint32_t hw_id = board_hardware_id(); |
| 468 | uint32_t hw_subtype = board_hardware_subtype(); |
Gustavo Solaira | 80c274c | 2014-10-22 16:21:27 -0300 | [diff] [blame] | 469 | uint32_t target_id, plat_hw_ver_major; |
Mao Flynn | 8140947 | 2014-04-10 15:01:30 +0800 | [diff] [blame] | 470 | |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 471 | if (enable) { |
| 472 | if (pinfo->mipi.use_enable_gpio) { |
Gustavo Solaira | fb6fdd6 | 2014-09-30 08:15:32 -0300 | [diff] [blame] | 473 | /* set enable gpio pin for SKUT1 */ |
| 474 | if ((hw_id == HW_PLATFORM_QRD) && |
Gustavo Solaira | 80c274c | 2014-10-22 16:21:27 -0300 | [diff] [blame] | 475 | (hw_subtype == HW_PLATFORM_SUBTYPE_SKUT1)) { |
| 476 | target_id = board_target_id(); |
| 477 | plat_hw_ver_major = ((target_id >> 16) & 0xFF); |
| 478 | if ((plat_hw_ver_major & 0x0F) == 0x1) |
| 479 | enable_gpio = enable_gpio_skut1; |
| 480 | else |
| 481 | enable_gpio = enable_gpio_skut2; |
| 482 | } |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 483 | gpio_tlmm_config(enable_gpio.pin_id, 0, |
| 484 | enable_gpio.pin_direction, enable_gpio.pin_pull, |
| 485 | enable_gpio.pin_strength, |
| 486 | enable_gpio.pin_state); |
| 487 | |
| 488 | gpio_set_dir(enable_gpio.pin_id, 2); |
| 489 | } |
| 490 | |
vijay kumar | dd51c59 | 2015-01-05 12:46:28 +0530 | [diff] [blame] | 491 | if (platform_is_msm8939() || platform_is_msm8929()) { |
Mao Flynn | 732e3c2 | 2014-07-02 17:39:02 +0800 | [diff] [blame] | 492 | if ((hw_id == HW_PLATFORM_QRD) && |
| 493 | (hw_subtype == HW_PLATFORM_SUBTYPE_SKUK)) |
| 494 | target_panel_reset_skuk(enable); |
Vineet Bajaj | 5be1e4a | 2015-02-02 15:07:49 +0530 | [diff] [blame] | 495 | if (((hw_id == HW_PLATFORM_SURF) && |
| 496 | (hw_subtype == HW_PLATFORM_SUBTYPE_CDP_1)) || |
| 497 | ((hw_id == HW_PLATFORM_MTP) && |
| 498 | (hw_subtype == HW_PLATFORM_SUBTYPE_MTP_3))) |
Vineet Bajaj | 3acf94f | 2014-12-04 19:55:03 +0530 | [diff] [blame] | 499 | target_panel_reset_incell(enable); |
Vineet Bajaj | 5be1e4a | 2015-02-02 15:07:49 +0530 | [diff] [blame] | 500 | if ((hw_id == HW_PLATFORM_SURF) && |
| 501 | (hw_subtype == HW_PLATFORM_SUBTYPE_CDP_2)) |
| 502 | target_panel_reset_jdi_a216(enable); |
Mao Flynn | 732e3c2 | 2014-07-02 17:39:02 +0800 | [diff] [blame] | 503 | } else { /* msm8916 */ |
| 504 | if ((hw_id == HW_PLATFORM_QRD) && |
| 505 | (hw_subtype == HW_PLATFORM_SUBTYPE_SKUH)) |
| 506 | target_panel_reset_skuh(enable); |
Mao Flynn | 8140947 | 2014-04-10 15:01:30 +0800 | [diff] [blame] | 507 | } |
| 508 | |
Shuo Yan | c8a417f | 2014-05-20 14:44:56 +0800 | [diff] [blame] | 509 | if (hw_id == HW_PLATFORM_MTP || hw_id == HW_PLATFORM_SURF) { |
| 510 | /* configure backlight gpio for MTP & CDP */ |
Vineet Bajaj | 3acf94f | 2014-12-04 19:55:03 +0530 | [diff] [blame] | 511 | gpio_tlmm_config(bkl_gpio.pin_id, 0, |
| 512 | bkl_gpio.pin_direction, bkl_gpio.pin_pull, |
| 513 | bkl_gpio.pin_strength, bkl_gpio.pin_state); |
| 514 | gpio_set_dir(bkl_gpio.pin_id, 2); |
Shuo Yan | c8a417f | 2014-05-20 14:44:56 +0800 | [diff] [blame] | 515 | } |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 516 | |
| 517 | gpio_tlmm_config(reset_gpio.pin_id, 0, |
| 518 | reset_gpio.pin_direction, reset_gpio.pin_pull, |
| 519 | reset_gpio.pin_strength, reset_gpio.pin_state); |
| 520 | |
| 521 | gpio_set_dir(reset_gpio.pin_id, 2); |
| 522 | |
| 523 | /* reset */ |
| 524 | for (int i = 0; i < RESET_GPIO_SEQ_LEN; i++) { |
| 525 | if (resetseq->pin_state[i] == GPIO_STATE_LOW) |
| 526 | gpio_set_dir(reset_gpio.pin_id, GPIO_STATE_LOW); |
| 527 | else |
| 528 | gpio_set_dir(reset_gpio.pin_id, GPIO_STATE_HIGH); |
| 529 | mdelay(resetseq->sleep[i]); |
| 530 | } |
| 531 | } else if(!target_cont_splash_screen()) { |
| 532 | gpio_set_dir(reset_gpio.pin_id, 0); |
| 533 | if (pinfo->mipi.use_enable_gpio) |
| 534 | gpio_set_dir(enable_gpio.pin_id, 0); |
Mao Flynn | 8140947 | 2014-04-10 15:01:30 +0800 | [diff] [blame] | 535 | |
vijay kumar | dd51c59 | 2015-01-05 12:46:28 +0530 | [diff] [blame] | 536 | if (platform_is_msm8939() || platform_is_msm8929()) { |
Mao Flynn | 732e3c2 | 2014-07-02 17:39:02 +0800 | [diff] [blame] | 537 | if ((hw_id == HW_PLATFORM_QRD) && |
| 538 | (hw_subtype == HW_PLATFORM_SUBTYPE_SKUK)) |
| 539 | target_panel_reset_skuk(enable); |
| 540 | } else { /* msm8916 */ |
| 541 | if ((hw_id == HW_PLATFORM_QRD) && |
| 542 | (hw_subtype == HW_PLATFORM_SUBTYPE_SKUH)) |
| 543 | target_panel_reset_skuh(enable); |
Mao Flynn | 8140947 | 2014-04-10 15:01:30 +0800 | [diff] [blame] | 544 | } |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 545 | } |
| 546 | |
| 547 | return ret; |
| 548 | } |
| 549 | |
Kuogee Hsieh | 93bcff6 | 2014-08-22 14:02:08 -0700 | [diff] [blame] | 550 | int target_ldo_ctrl(uint8_t enable, struct msm_panel_info *pinfo) |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 551 | { |
Padmanabhan Komanduru | 0ed51fb | 2014-06-04 12:22:08 +0530 | [diff] [blame] | 552 | /* |
| 553 | * The PMIC regulators needed for display are enabled in SBL. |
| 554 | * There is no access to the regulators is LK. |
| 555 | */ |
| 556 | return NO_ERROR; |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 557 | } |
| 558 | |
| 559 | bool target_display_panel_node(char *panel_name, char *pbuf, uint16_t buf_size) |
| 560 | { |
Veera Sundaram Sankaran | c95d675 | 2014-07-31 11:49:52 -0700 | [diff] [blame] | 561 | return gcdb_display_cmdline_arg(panel_name, pbuf, buf_size); |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 562 | } |
| 563 | |
| 564 | void target_display_init(const char *panel_name) |
| 565 | { |
Padmanabhan Komanduru | 1869a76 | 2014-04-01 20:12:05 +0530 | [diff] [blame] | 566 | uint32_t panel_loop = 0; |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 567 | uint32_t ret = 0; |
Veera Sundaram Sankaran | 7868d54 | 2015-01-02 14:48:47 -0800 | [diff] [blame] | 568 | char cont_splash = '\0'; |
Jeevan Shriram | b0d523a | 2014-05-30 12:55:17 -0700 | [diff] [blame] | 569 | |
Veera Sundaram Sankaran | 7868d54 | 2015-01-02 14:48:47 -0800 | [diff] [blame] | 570 | set_panel_cmd_string(panel_name, &cont_splash); |
Sandeep Panda | e07c07b | 2014-08-25 17:04:17 +0530 | [diff] [blame] | 571 | panel_name += strspn(panel_name, " "); |
Veera Sundaram Sankaran | 3b75882 | 2014-10-17 12:15:39 -0700 | [diff] [blame] | 572 | |
| 573 | if (!strcmp(panel_name, NO_PANEL_CONFIG) |
| 574 | || !strcmp(panel_name, SIM_VIDEO_PANEL) |
| 575 | || !strcmp(panel_name, SIM_CMD_PANEL)) { |
Veera Sundaram Sankaran | c95d675 | 2014-07-31 11:49:52 -0700 | [diff] [blame] | 576 | dprintf(INFO, "Selected panel: %s\nSkip panel configuration\n", |
Veera Sundaram Sankaran | 3b75882 | 2014-10-17 12:15:39 -0700 | [diff] [blame] | 577 | panel_name); |
Jeevan Shriram | b0d523a | 2014-05-30 12:55:17 -0700 | [diff] [blame] | 578 | return; |
| 579 | } |
| 580 | |
Padmanabhan Komanduru | 1869a76 | 2014-04-01 20:12:05 +0530 | [diff] [blame] | 581 | do { |
Justin Philip | be9de5c | 2014-09-17 12:26:49 +0530 | [diff] [blame] | 582 | target_force_cont_splash_disable(false); |
Padmanabhan Komanduru | 1869a76 | 2014-04-01 20:12:05 +0530 | [diff] [blame] | 583 | ret = gcdb_display_init(panel_name, MDP_REV_50, MIPI_FB_ADDR); |
| 584 | if (!ret || ret == ERR_NOT_SUPPORTED) { |
| 585 | break; |
| 586 | } else { |
| 587 | target_force_cont_splash_disable(true); |
| 588 | msm_display_off(); |
Padmanabhan Komanduru | 1869a76 | 2014-04-01 20:12:05 +0530 | [diff] [blame] | 589 | } |
| 590 | } while (++panel_loop <= oem_panel_max_auto_detect_panels()); |
Veera Sundaram Sankaran | 7868d54 | 2015-01-02 14:48:47 -0800 | [diff] [blame] | 591 | |
| 592 | if (cont_splash == '0') { |
| 593 | dprintf(INFO, "Forcing continuous splash disable\n"); |
| 594 | target_force_cont_splash_disable(true); |
| 595 | } |
Padmanabhan Komanduru | cd5645e | 2014-03-25 20:34:18 +0530 | [diff] [blame] | 596 | } |
| 597 | |
| 598 | void target_display_shutdown(void) |
| 599 | { |
| 600 | gcdb_display_shutdown(); |
| 601 | } |