Kuogee Hsieh | df96174 | 2013-12-18 14:13:45 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved. |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [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> |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 32 | #include <err.h> |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 33 | #include <msm_panel.h> |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 34 | #include <mipi_dsi.h> |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 35 | #include <pm8x41.h> |
| 36 | #include <pm8x41_wled.h> |
| 37 | #include <board.h> |
| 38 | #include <mdp5.h> |
| 39 | #include <platform/gpio.h> |
Asaf Penso | c9080dc | 2013-05-21 21:53:50 +0300 | [diff] [blame] | 40 | #include <platform/clock.h> |
Siddhartha Agrawal | 1b2ed84 | 2013-05-29 18:02:28 -0700 | [diff] [blame] | 41 | #include <platform/iomap.h> |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 42 | #include <target/display.h> |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 43 | #include "include/panel.h" |
| 44 | #include "include/display_resource.h" |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 45 | |
| 46 | static struct msm_fb_panel_data panel; |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 47 | static uint8_t edp_enable; |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 48 | |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 49 | #define HFPLL_LDO_ID 12 |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 50 | |
Asaf Penso | 0ecd86f | 2013-05-29 14:49:19 +0300 | [diff] [blame] | 51 | static struct pm8x41_wled_data wled_ctrl = { |
Amy Maloche | 543b584 | 2013-07-31 18:07:38 -0700 | [diff] [blame] | 52 | .mod_scheme = 0x00, |
Asaf Penso | 0ecd86f | 2013-05-29 14:49:19 +0300 | [diff] [blame] | 53 | .led1_brightness = (0x0F << 8) | 0xEF, |
| 54 | .led2_brightness = (0x0F << 8) | 0xEF, |
| 55 | .led3_brightness = (0x0F << 8) | 0xEF, |
| 56 | .max_duty_cycle = 0x01, |
| 57 | .ovp = 0x2, |
| 58 | .full_current_scale = 0x19 |
| 59 | }; |
| 60 | |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 61 | static uint32_t dsi_pll_enable_seq(uint32_t ctl_base) |
| 62 | { |
| 63 | uint32_t rc = 0; |
| 64 | |
| 65 | mdss_dsi_uniphy_pll_sw_reset(ctl_base); |
| 66 | |
| 67 | writel(0x01, ctl_base + 0x0220); /* GLB CFG */ |
| 68 | mdelay(1); |
| 69 | writel(0x05, ctl_base + 0x0220); /* GLB CFG */ |
| 70 | mdelay(1); |
| 71 | writel(0x07, ctl_base + 0x0220); /* GLB CFG */ |
| 72 | mdelay(1); |
| 73 | writel(0x0f, ctl_base + 0x0220); /* GLB CFG */ |
| 74 | mdelay(1); |
| 75 | |
| 76 | mdss_dsi_uniphy_pll_lock_detect_setting(ctl_base); |
| 77 | |
| 78 | while (!(readl(ctl_base + 0x02c0) & 0x01)) { |
| 79 | mdss_dsi_uniphy_pll_sw_reset(ctl_base); |
| 80 | writel(0x01, ctl_base + 0x0220); /* GLB CFG */ |
| 81 | mdelay(1); |
| 82 | writel(0x05, ctl_base + 0x0220); /* GLB CFG */ |
| 83 | mdelay(1); |
| 84 | writel(0x07, ctl_base + 0x0220); /* GLB CFG */ |
| 85 | mdelay(1); |
| 86 | writel(0x05, ctl_base + 0x0220); /* GLB CFG */ |
| 87 | mdelay(1); |
| 88 | writel(0x07, ctl_base + 0x0220); /* GLB CFG */ |
| 89 | mdelay(1); |
| 90 | writel(0x0f, ctl_base + 0x0220); /* GLB CFG */ |
| 91 | mdelay(2); |
| 92 | mdss_dsi_uniphy_pll_lock_detect_setting(ctl_base); |
| 93 | } |
| 94 | return rc; |
| 95 | } |
| 96 | |
Kuogee Hsieh | df96174 | 2013-12-18 14:13:45 -0800 | [diff] [blame] | 97 | static int msm8974_wled_backlight_ctrl(uint8_t enable) |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 98 | { |
Chandan Uddaraju | d1bcbeb | 2013-07-01 18:13:48 -0700 | [diff] [blame] | 99 | uint32_t platform_id = board_platform_id(); |
| 100 | uint32_t hardware_id = board_hardware_id(); |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 101 | uint8_t slave_id = 1; |
Chandan Uddaraju | d1bcbeb | 2013-07-01 18:13:48 -0700 | [diff] [blame] | 102 | |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 103 | if (enable) { |
| 104 | if (platform_id == MSM8974AC) |
| 105 | if ((hardware_id == HW_PLATFORM_MTP) |
| 106 | || (hardware_id == HW_PLATFORM_LIQUID)) |
| 107 | slave_id = 3; |
Chandan Uddaraju | d1bcbeb | 2013-07-01 18:13:48 -0700 | [diff] [blame] | 108 | |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 109 | pm8x41_wled_config_slave_id(slave_id); |
| 110 | pm8x41_wled_config(&wled_ctrl); |
| 111 | pm8x41_wled_sink_control(enable); |
| 112 | pm8x41_wled_iled_sync_control(enable); |
Jayant Shekhar | 855c500 | 2013-12-06 17:36:07 +0530 | [diff] [blame] | 113 | pm8x41_wled_led_mod_enable(enable); |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 114 | } |
| 115 | pm8x41_wled_enable(enable); |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 116 | |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 117 | return NO_ERROR; |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 118 | } |
| 119 | |
Kuogee Hsieh | df96174 | 2013-12-18 14:13:45 -0800 | [diff] [blame] | 120 | static int msm8974_pwm_backlight_ctrl(int gpio_num, int lpg_chan, int enable) |
| 121 | { |
| 122 | struct pm8x41_gpio gpio_param = { |
| 123 | .direction = PM_GPIO_DIR_OUT, |
| 124 | .function = PM_GPIO_FUNC_2, |
| 125 | .vin_sel = 2, /* VIN_2 */ |
| 126 | .pull = PM_GPIO_PULL_UP_1_5 | PM_GPIO_PULLDOWN_10, |
| 127 | .output_buffer = PM_GPIO_OUT_CMOS, |
| 128 | .out_strength = PM_GPIO_OUT_DRIVE_HIGH, |
| 129 | }; |
| 130 | |
| 131 | dprintf(SPEW, "%s: gpio=%d lpg=%d enable=%d\n", __func__, |
| 132 | gpio_num, lpg_chan, enable); |
| 133 | |
| 134 | if (enable) { |
| 135 | pm8x41_gpio_config(gpio_num, &gpio_param); |
| 136 | pm8x41_lpg_write(lpg_chan, 0x41, 0x33); /* LPG_PWM_SIZE_CLK, */ |
| 137 | pm8x41_lpg_write(lpg_chan, 0x42, 0x01); /* LPG_PWM_FREQ_PREDIV */ |
| 138 | pm8x41_lpg_write(lpg_chan, 0x43, 0x20); /* LPG_PWM_TYPE_CONFIG */ |
| 139 | pm8x41_lpg_write(lpg_chan, 0x44, 0xb2); /* LPG_VALUE_LSB */ |
| 140 | pm8x41_lpg_write(lpg_chan, 0x45, 0x01); /* LPG_VALUE_MSB */ |
| 141 | pm8x41_lpg_write(lpg_chan, 0x46, 0xe4); /* LPG_ENABLE_CONTROL */ |
| 142 | } else { |
| 143 | pm8x41_lpg_write(lpg_chan, 0x46, 0x00); |
| 144 | } |
| 145 | |
| 146 | return NO_ERROR; |
| 147 | } |
| 148 | |
| 149 | int target_backlight_ctrl(struct backlight *bl, uint8_t enable) |
| 150 | { |
| 151 | uint32_t ret = NO_ERROR; |
| 152 | |
| 153 | if (!bl) { |
| 154 | dprintf(CRITICAL, "backlight structure is not available\n"); |
| 155 | return ERR_INVALID_ARGS; |
| 156 | } |
| 157 | |
| 158 | switch (bl->bl_interface_type) { |
| 159 | case BL_WLED: |
| 160 | ret = msm8974_wled_backlight_ctrl(enable); |
| 161 | break; |
| 162 | case BL_PWM: |
Dhaval Patel | 499b7d2 | 2014-01-07 21:57:30 -0800 | [diff] [blame] | 163 | ret = msm8974_pwm_backlight_ctrl(pwm_gpio.pin_id, |
| 164 | PWM_BL_LPG_CHAN_ID, |
Kuogee Hsieh | df96174 | 2013-12-18 14:13:45 -0800 | [diff] [blame] | 165 | enable); |
| 166 | break; |
| 167 | default: |
| 168 | dprintf(CRITICAL, "backlight type:%d not supported\n", |
| 169 | bl->bl_interface_type); |
| 170 | return ERR_NOT_SUPPORTED; |
| 171 | } |
| 172 | |
| 173 | return ret; |
| 174 | } |
| 175 | |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 176 | int target_panel_clock(uint8_t enable, struct msm_panel_info *pinfo) |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 177 | { |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 178 | struct mdss_dsi_pll_config *pll_data; |
| 179 | uint32_t dual_dsi = pinfo->mipi.dual_dsi; |
| 180 | dprintf(SPEW, "target_panel_clock\n"); |
| 181 | |
| 182 | pll_data = pinfo->mipi.dsi_pll_config; |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 183 | if (enable) { |
| 184 | mdp_gdsc_ctrl(enable); |
| 185 | mdp_clock_init(); |
Siddhartha Agrawal | 1a850cf | 2013-09-26 13:30:33 -0700 | [diff] [blame] | 186 | mdss_dsi_auto_pll_config(MIPI_DSI0_BASE, pll_data); |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 187 | dsi_pll_enable_seq(MIPI_DSI0_BASE); |
Siddhartha Agrawal | 1b2ed84 | 2013-05-29 18:02:28 -0700 | [diff] [blame] | 188 | if (panel.panel_info.mipi.dual_dsi && |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 189 | !(panel.panel_info.mipi.broadcast)) { |
Siddhartha Agrawal | 1a850cf | 2013-09-26 13:30:33 -0700 | [diff] [blame] | 190 | mdss_dsi_auto_pll_config(MIPI_DSI1_BASE, pll_data); |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 191 | dsi_pll_enable_seq(MIPI_DSI1_BASE); |
| 192 | } |
| 193 | mmss_clock_auto_pll_init(DSI0_PHY_PLL_OUT, dual_dsi, |
| 194 | pll_data->pclk_m, |
| 195 | pll_data->pclk_n, |
| 196 | pll_data->pclk_d); |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 197 | } else if(!target_cont_splash_screen()) { |
| 198 | // * Add here for continuous splash * |
Siddhartha Agrawal | c88737b | 2013-05-29 20:41:35 -0700 | [diff] [blame] | 199 | mmss_clock_disable(dual_dsi); |
| 200 | mdp_clock_disable(dual_dsi); |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 201 | } |
| 202 | |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 203 | return NO_ERROR; |
Asaf Penso | 325f43a | 2013-05-21 21:55:48 +0300 | [diff] [blame] | 204 | } |
| 205 | |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 206 | /* Pull DISP_RST_N high to get panel out of reset */ |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 207 | int target_panel_reset(uint8_t enable, struct panel_reset_sequence *resetseq, |
| 208 | struct msm_panel_info *pinfo) |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 209 | { |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 210 | uint32_t rst_gpio = reset_gpio.pin_id; |
Chandan Uddaraju | d1bcbeb | 2013-07-01 18:13:48 -0700 | [diff] [blame] | 211 | uint32_t platform_id = board_platform_id(); |
| 212 | uint32_t hardware_id = board_hardware_id(); |
| 213 | |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 214 | struct pm8x41_gpio resetgpio_param = { |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 215 | .direction = PM_GPIO_DIR_OUT, |
| 216 | .output_buffer = PM_GPIO_OUT_CMOS, |
| 217 | .out_strength = PM_GPIO_OUT_DRIVE_MED, |
| 218 | }; |
| 219 | |
Chandan Uddaraju | d1bcbeb | 2013-07-01 18:13:48 -0700 | [diff] [blame] | 220 | if (platform_id == MSM8974AC) |
Chandan Uddaraju | b2cee90 | 2013-09-05 18:31:23 -0700 | [diff] [blame] | 221 | if ((hardware_id == HW_PLATFORM_MTP) |
Chandan Uddaraju | d1bcbeb | 2013-07-01 18:13:48 -0700 | [diff] [blame] | 222 | || (hardware_id == HW_PLATFORM_LIQUID)) |
| 223 | rst_gpio = 20; |
| 224 | |
| 225 | dprintf(SPEW, "platform_id: %u, rst_gpio: %u\n", |
| 226 | platform_id, rst_gpio); |
| 227 | |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 228 | pm8x41_gpio_config(rst_gpio, &resetgpio_param); |
Siddhartha Agrawal | c43c487 | 2013-04-21 16:23:16 -0700 | [diff] [blame] | 229 | if (enable) { |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 230 | gpio_tlmm_config(enable_gpio.pin_id, 0, |
| 231 | enable_gpio.pin_direction, enable_gpio.pin_pull, |
| 232 | enable_gpio.pin_strength, enable_gpio.pin_state); |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 233 | |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 234 | gpio_set(enable_gpio.pin_id, resetseq->pin_direction); |
| 235 | pm8x41_gpio_set(rst_gpio, resetseq->pin_state[0]); |
| 236 | mdelay(resetseq->sleep[0]); |
| 237 | pm8x41_gpio_set(rst_gpio, resetseq->pin_state[1]); |
| 238 | mdelay(resetseq->sleep[1]); |
| 239 | pm8x41_gpio_set(rst_gpio, resetseq->pin_state[2]); |
| 240 | mdelay(resetseq->sleep[2]); |
Siddhartha Agrawal | c43c487 | 2013-04-21 16:23:16 -0700 | [diff] [blame] | 241 | } else { |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 242 | resetgpio_param.out_strength = PM_GPIO_OUT_DRIVE_LOW; |
| 243 | pm8x41_gpio_config(rst_gpio, &resetgpio_param); |
Chandan Uddaraju | d1bcbeb | 2013-07-01 18:13:48 -0700 | [diff] [blame] | 244 | pm8x41_gpio_set(rst_gpio, PM_GPIO_FUNC_LOW); |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 245 | gpio_set(enable_gpio.pin_id, resetseq->pin_direction); |
Siddhartha Agrawal | c43c487 | 2013-04-21 16:23:16 -0700 | [diff] [blame] | 246 | } |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 247 | return NO_ERROR; |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 248 | } |
| 249 | |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 250 | int target_ldo_ctrl(uint8_t enable) |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 251 | { |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 252 | uint32_t ldocounter = 0; |
| 253 | uint32_t pm8x41_ldo_base = 0x13F00; |
Deepa Dinamani | ec4835b | 2013-06-03 16:14:24 -0700 | [diff] [blame] | 254 | |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 255 | while (ldocounter < TOTAL_LDO_DEFINED) { |
| 256 | struct pm8x41_ldo ldo_entry = LDO((pm8x41_ldo_base + |
| 257 | 0x100 * ldo_entry_array[ldocounter].ldo_id), |
| 258 | ldo_entry_array[ldocounter].ldo_type); |
Deepa Dinamani | ec4835b | 2013-06-03 16:14:24 -0700 | [diff] [blame] | 259 | |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 260 | dprintf(SPEW, "Setting %s\n", |
| 261 | ldo_entry_array[ldocounter].ldo_id); |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 262 | |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 263 | /* Set voltage during power on */ |
| 264 | if (enable) { |
| 265 | pm8x41_ldo_set_voltage(&ldo_entry, |
| 266 | ldo_entry_array[ldocounter].ldo_voltage); |
| 267 | pm8x41_ldo_control(&ldo_entry, enable); |
| 268 | } else if(ldo_entry_array[ldocounter].ldo_id != HFPLL_LDO_ID) { |
| 269 | pm8x41_ldo_control(&ldo_entry, enable); |
| 270 | } |
| 271 | ldocounter++; |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 272 | } |
| 273 | |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 274 | return NO_ERROR; |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 275 | } |
| 276 | |
Asaf Penso | e6870ff | 2013-07-07 17:23:56 +0300 | [diff] [blame] | 277 | static int msm8974_mdss_edp_panel_clock(int enable) |
| 278 | { |
| 279 | if (enable) { |
| 280 | mdp_gdsc_ctrl(enable); |
| 281 | mdp_clock_init(); |
| 282 | edp_clk_enable(); |
Asaf Penso | e6870ff | 2013-07-07 17:23:56 +0300 | [diff] [blame] | 283 | } else if (!target_cont_splash_screen()) { |
| 284 | /* Add here for continuous splash */ |
Kuogee Hsieh | df636eb | 2013-08-01 14:52:08 -0700 | [diff] [blame] | 285 | edp_clk_disable(); |
| 286 | mdp_clock_disable(); |
| 287 | mdp_gdsc_ctrl(enable); |
Asaf Penso | e6870ff | 2013-07-07 17:23:56 +0300 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | return 0; |
| 291 | } |
| 292 | |
| 293 | static int msm8974_edp_panel_power(int enable) |
| 294 | { |
| 295 | struct pm8x41_gpio gpio36_param = { |
| 296 | .direction = PM_GPIO_DIR_OUT, |
Kuogee Hsieh | 80f3db0 | 2013-10-04 15:51:37 -0700 | [diff] [blame] | 297 | .function = PM_GPIO_FUNC_2, |
| 298 | .vin_sel = 2, /* VIN_2 */ |
| 299 | .pull = PM_GPIO_PULL_UP_1_5 | PM_GPIO_PULLDOWN_10, |
Asaf Penso | e6870ff | 2013-07-07 17:23:56 +0300 | [diff] [blame] | 300 | .output_buffer = PM_GPIO_OUT_CMOS, |
Kuogee Hsieh | 80f3db0 | 2013-10-04 15:51:37 -0700 | [diff] [blame] | 301 | .out_strength = PM_GPIO_OUT_DRIVE_HIGH, |
Asaf Penso | e6870ff | 2013-07-07 17:23:56 +0300 | [diff] [blame] | 302 | }; |
| 303 | |
| 304 | struct pm8x41_ldo ldo12 = LDO(PM8x41_LDO12, PLDO_TYPE); |
| 305 | |
| 306 | if (enable) { |
| 307 | /* Enable backlight */ |
| 308 | dprintf(SPEW, "Enable Backlight\n"); |
Kuogee Hsieh | df96174 | 2013-12-18 14:13:45 -0800 | [diff] [blame] | 309 | msm8974_pwm_backlight_ctrl(36, 8, 1); |
Asaf Penso | e6870ff | 2013-07-07 17:23:56 +0300 | [diff] [blame] | 310 | dprintf(SPEW, "Enable Backlight Done\n"); |
| 311 | |
| 312 | /* Turn on LDO12 for edp vdda */ |
| 313 | dprintf(SPEW, "Setting LDO12 n"); |
| 314 | pm8x41_ldo_set_voltage(&ldo12, 1800000); |
| 315 | pm8x41_ldo_control(&ldo12, enable); |
| 316 | dprintf(SPEW, "Setting LDO12 Done\n"); |
| 317 | |
| 318 | /* Panel Enable */ |
| 319 | dprintf(SPEW, "Panel Enable\n"); |
| 320 | gpio_tlmm_config(58, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_8MA, |
| 321 | GPIO_DISABLE); |
| 322 | gpio_set(58, 2); |
| 323 | dprintf(SPEW, "Panel Enable Done\n"); |
| 324 | } else { |
| 325 | /* Keep LDO12 on, otherwise kernel will not boot */ |
Kuogee Hsieh | df636eb | 2013-08-01 14:52:08 -0700 | [diff] [blame] | 326 | gpio_set(58, 0); |
Kuogee Hsieh | df96174 | 2013-12-18 14:13:45 -0800 | [diff] [blame] | 327 | msm8974_pwm_backlight_ctrl(36, 8, 0); |
Asaf Penso | e6870ff | 2013-07-07 17:23:56 +0300 | [diff] [blame] | 328 | } |
| 329 | |
| 330 | return 0; |
| 331 | } |
| 332 | |
Aravind Venkateswaran | 6385f7e | 2014-02-25 16:45:11 -0800 | [diff] [blame] | 333 | void target_display_init(const char *panel_name) |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 334 | { |
| 335 | uint32_t hw_id = board_hardware_id(); |
Casey Piper | 74f8e5c | 2013-09-05 15:00:30 -0700 | [diff] [blame] | 336 | uint32_t panel_loop = 0; |
| 337 | uint32_t ret = 0; |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 338 | switch (hw_id) { |
Asaf Penso | e6870ff | 2013-07-07 17:23:56 +0300 | [diff] [blame] | 339 | case HW_PLATFORM_LIQUID: |
Kuogee Hsieh | df636eb | 2013-08-01 14:52:08 -0700 | [diff] [blame] | 340 | edp_panel_init(&(panel.panel_info)); |
Asaf Penso | e6870ff | 2013-07-07 17:23:56 +0300 | [diff] [blame] | 341 | panel.clk_func = msm8974_mdss_edp_panel_clock; |
| 342 | panel.power_func = msm8974_edp_panel_power; |
| 343 | panel.fb.base = (void *)EDP_FB_ADDR; |
Asaf Penso | e6870ff | 2013-07-07 17:23:56 +0300 | [diff] [blame] | 344 | panel.fb.format = FB_FORMAT_RGB888; |
| 345 | panel.mdp_rev = MDP_REV_50; |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 346 | |
| 347 | if (msm_display_init(&panel)) { |
| 348 | dprintf(CRITICAL, "edp init failed!\n"); |
| 349 | return; |
| 350 | } |
| 351 | |
| 352 | edp_enable = 1; |
Asaf Penso | e6870ff | 2013-07-07 17:23:56 +0300 | [diff] [blame] | 353 | break; |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 354 | default: |
Casey Piper | 74f8e5c | 2013-09-05 15:00:30 -0700 | [diff] [blame] | 355 | do { |
Aravind Venkateswaran | d494f96 | 2014-02-25 17:16:49 -0800 | [diff] [blame^] | 356 | ret = gcdb_display_init(panel_name, MDP_REV_50, |
| 357 | MIPI_FB_ADDR); |
Casey Piper | cc7e52e | 2013-10-01 15:51:04 -0700 | [diff] [blame] | 358 | if (!ret || ret == ERR_NOT_SUPPORTED) { |
| 359 | break; |
| 360 | } else { |
Casey Piper | 74f8e5c | 2013-09-05 15:00:30 -0700 | [diff] [blame] | 361 | target_force_cont_splash_disable(true); |
| 362 | msm_display_off(); |
| 363 | target_force_cont_splash_disable(false); |
| 364 | } |
Casey Piper | 74f8e5c | 2013-09-05 15:00:30 -0700 | [diff] [blame] | 365 | } while (++panel_loop <= oem_panel_max_auto_detect_panels()); |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 366 | break; |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 367 | } |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 368 | } |
| 369 | |
Aravind Venkateswaran | dd50c1a | 2014-02-25 14:42:43 -0800 | [diff] [blame] | 370 | void target_display_shutdown(void) |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 371 | { |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 372 | uint32_t hw_id = board_hardware_id(); |
| 373 | switch (hw_id) { |
| 374 | case HW_PLATFORM_LIQUID: |
| 375 | if (edp_enable) |
| 376 | msm_display_off(); |
| 377 | break; |
| 378 | default: |
| 379 | gcdb_display_shutdown(); |
| 380 | break; |
| 381 | } |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 382 | } |