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 | |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 61 | static uint32_t dsi_pll_lock_status(uint32_t pll_base) |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 62 | { |
Dhaval Patel | bb40871 | 2014-03-18 11:45:53 -0700 | [diff] [blame] | 63 | uint32_t counter, status; |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 64 | |
Dhaval Patel | bb40871 | 2014-03-18 11:45:53 -0700 | [diff] [blame] | 65 | udelay(100); |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 66 | mdss_dsi_uniphy_pll_lock_detect_setting(pll_base); |
Dhaval Patel | bb40871 | 2014-03-18 11:45:53 -0700 | [diff] [blame] | 67 | |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 68 | status = readl(pll_base + 0x00c0) & 0x01; |
Dhaval Patel | bb40871 | 2014-03-18 11:45:53 -0700 | [diff] [blame] | 69 | for (counter = 0; counter < 5 && !status; counter++) { |
| 70 | udelay(100); |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 71 | status = readl(pll_base + 0x00c0) & 0x01; |
Dhaval Patel | bb40871 | 2014-03-18 11:45:53 -0700 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | return status; |
| 75 | } |
| 76 | |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 77 | static uint32_t dsi_pll_enable_seq_b(uint32_t pll_base) |
Dhaval Patel | bb40871 | 2014-03-18 11:45:53 -0700 | [diff] [blame] | 78 | { |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 79 | mdss_dsi_uniphy_pll_sw_reset(pll_base); |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 80 | |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 81 | writel(0x01, pll_base + 0x0020); /* GLB CFG */ |
Dhaval Patel | bb40871 | 2014-03-18 11:45:53 -0700 | [diff] [blame] | 82 | udelay(1); |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 83 | writel(0x05, pll_base + 0x0020); /* GLB CFG */ |
Dhaval Patel | bb40871 | 2014-03-18 11:45:53 -0700 | [diff] [blame] | 84 | udelay(200); |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 85 | writel(0x07, pll_base + 0x0020); /* GLB CFG */ |
Dhaval Patel | bb40871 | 2014-03-18 11:45:53 -0700 | [diff] [blame] | 86 | udelay(500); |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 87 | writel(0x0f, pll_base + 0x0020); /* GLB CFG */ |
Dhaval Patel | bb40871 | 2014-03-18 11:45:53 -0700 | [diff] [blame] | 88 | udelay(500); |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 89 | |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 90 | return dsi_pll_lock_status(pll_base); |
Dhaval Patel | bb40871 | 2014-03-18 11:45:53 -0700 | [diff] [blame] | 91 | } |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 92 | |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 93 | static uint32_t dsi_pll_enable_seq_d(uint32_t pll_base) |
Dhaval Patel | bb40871 | 2014-03-18 11:45:53 -0700 | [diff] [blame] | 94 | { |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 95 | mdss_dsi_uniphy_pll_sw_reset(pll_base); |
Dhaval Patel | bb40871 | 2014-03-18 11:45:53 -0700 | [diff] [blame] | 96 | |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 97 | writel(0x01, pll_base + 0x0020); /* GLB CFG */ |
Dhaval Patel | bb40871 | 2014-03-18 11:45:53 -0700 | [diff] [blame] | 98 | udelay(1); |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 99 | writel(0x05, pll_base + 0x0020); /* GLB CFG */ |
Dhaval Patel | bb40871 | 2014-03-18 11:45:53 -0700 | [diff] [blame] | 100 | udelay(200); |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 101 | writel(0x07, pll_base + 0x0020); /* GLB CFG */ |
Dhaval Patel | bb40871 | 2014-03-18 11:45:53 -0700 | [diff] [blame] | 102 | udelay(250); |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 103 | writel(0x05, pll_base + 0x0020); /* GLB CFG */ |
Dhaval Patel | bb40871 | 2014-03-18 11:45:53 -0700 | [diff] [blame] | 104 | udelay(200); |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 105 | writel(0x07, pll_base + 0x0220); /* GLB CFG */ |
Dhaval Patel | bb40871 | 2014-03-18 11:45:53 -0700 | [diff] [blame] | 106 | udelay(500); |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 107 | writel(0x0f, pll_base + 0x0220); /* GLB CFG */ |
Dhaval Patel | bb40871 | 2014-03-18 11:45:53 -0700 | [diff] [blame] | 108 | udelay(500); |
| 109 | |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 110 | return dsi_pll_lock_status(pll_base); |
Dhaval Patel | bb40871 | 2014-03-18 11:45:53 -0700 | [diff] [blame] | 111 | } |
| 112 | |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 113 | static void dsi_pll_enable_seq(uint32_t pll_base) |
Dhaval Patel | bb40871 | 2014-03-18 11:45:53 -0700 | [diff] [blame] | 114 | { |
| 115 | uint32_t counter, status; |
| 116 | |
| 117 | for (counter = 0; counter < 3; counter++) { |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 118 | status = dsi_pll_enable_seq_b(pll_base); |
Dhaval Patel | bb40871 | 2014-03-18 11:45:53 -0700 | [diff] [blame] | 119 | if (status) |
| 120 | break; |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 121 | status = dsi_pll_enable_seq_d(pll_base); |
Dhaval Patel | bb40871 | 2014-03-18 11:45:53 -0700 | [diff] [blame] | 122 | if (status) |
| 123 | break; |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 124 | status = dsi_pll_enable_seq_d(pll_base); |
Dhaval Patel | bb40871 | 2014-03-18 11:45:53 -0700 | [diff] [blame] | 125 | if(status) |
| 126 | break; |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 127 | } |
Dhaval Patel | bb40871 | 2014-03-18 11:45:53 -0700 | [diff] [blame] | 128 | |
| 129 | if (!status) |
| 130 | dprintf(CRITICAL, "Pll lock sequence failed\n"); |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 131 | } |
| 132 | |
Kuogee Hsieh | df96174 | 2013-12-18 14:13:45 -0800 | [diff] [blame] | 133 | static int msm8974_wled_backlight_ctrl(uint8_t enable) |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 134 | { |
Chandan Uddaraju | d1bcbeb | 2013-07-01 18:13:48 -0700 | [diff] [blame] | 135 | uint32_t platform_id = board_platform_id(); |
| 136 | uint32_t hardware_id = board_hardware_id(); |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 137 | uint8_t slave_id = 1; |
Chandan Uddaraju | d1bcbeb | 2013-07-01 18:13:48 -0700 | [diff] [blame] | 138 | |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 139 | if (enable) { |
| 140 | if (platform_id == MSM8974AC) |
| 141 | if ((hardware_id == HW_PLATFORM_MTP) |
| 142 | || (hardware_id == HW_PLATFORM_LIQUID)) |
| 143 | slave_id = 3; |
Chandan Uddaraju | d1bcbeb | 2013-07-01 18:13:48 -0700 | [diff] [blame] | 144 | |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 145 | pm8x41_wled_config_slave_id(slave_id); |
| 146 | pm8x41_wled_config(&wled_ctrl); |
| 147 | pm8x41_wled_sink_control(enable); |
| 148 | pm8x41_wled_iled_sync_control(enable); |
Jayant Shekhar | 855c500 | 2013-12-06 17:36:07 +0530 | [diff] [blame] | 149 | pm8x41_wled_led_mod_enable(enable); |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 150 | } |
| 151 | pm8x41_wled_enable(enable); |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 152 | |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 153 | return NO_ERROR; |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 154 | } |
| 155 | |
Kuogee Hsieh | df96174 | 2013-12-18 14:13:45 -0800 | [diff] [blame] | 156 | static int msm8974_pwm_backlight_ctrl(int gpio_num, int lpg_chan, int enable) |
| 157 | { |
| 158 | struct pm8x41_gpio gpio_param = { |
| 159 | .direction = PM_GPIO_DIR_OUT, |
| 160 | .function = PM_GPIO_FUNC_2, |
| 161 | .vin_sel = 2, /* VIN_2 */ |
| 162 | .pull = PM_GPIO_PULL_UP_1_5 | PM_GPIO_PULLDOWN_10, |
| 163 | .output_buffer = PM_GPIO_OUT_CMOS, |
| 164 | .out_strength = PM_GPIO_OUT_DRIVE_HIGH, |
| 165 | }; |
| 166 | |
| 167 | dprintf(SPEW, "%s: gpio=%d lpg=%d enable=%d\n", __func__, |
| 168 | gpio_num, lpg_chan, enable); |
| 169 | |
| 170 | if (enable) { |
| 171 | pm8x41_gpio_config(gpio_num, &gpio_param); |
| 172 | pm8x41_lpg_write(lpg_chan, 0x41, 0x33); /* LPG_PWM_SIZE_CLK, */ |
| 173 | pm8x41_lpg_write(lpg_chan, 0x42, 0x01); /* LPG_PWM_FREQ_PREDIV */ |
| 174 | pm8x41_lpg_write(lpg_chan, 0x43, 0x20); /* LPG_PWM_TYPE_CONFIG */ |
| 175 | pm8x41_lpg_write(lpg_chan, 0x44, 0xb2); /* LPG_VALUE_LSB */ |
| 176 | pm8x41_lpg_write(lpg_chan, 0x45, 0x01); /* LPG_VALUE_MSB */ |
| 177 | pm8x41_lpg_write(lpg_chan, 0x46, 0xe4); /* LPG_ENABLE_CONTROL */ |
| 178 | } else { |
| 179 | pm8x41_lpg_write(lpg_chan, 0x46, 0x00); |
| 180 | } |
| 181 | |
| 182 | return NO_ERROR; |
| 183 | } |
| 184 | |
| 185 | int target_backlight_ctrl(struct backlight *bl, uint8_t enable) |
| 186 | { |
| 187 | uint32_t ret = NO_ERROR; |
| 188 | |
| 189 | if (!bl) { |
| 190 | dprintf(CRITICAL, "backlight structure is not available\n"); |
| 191 | return ERR_INVALID_ARGS; |
| 192 | } |
| 193 | |
| 194 | switch (bl->bl_interface_type) { |
| 195 | case BL_WLED: |
| 196 | ret = msm8974_wled_backlight_ctrl(enable); |
| 197 | break; |
| 198 | case BL_PWM: |
Dhaval Patel | 499b7d2 | 2014-01-07 21:57:30 -0800 | [diff] [blame] | 199 | ret = msm8974_pwm_backlight_ctrl(pwm_gpio.pin_id, |
| 200 | PWM_BL_LPG_CHAN_ID, |
Kuogee Hsieh | df96174 | 2013-12-18 14:13:45 -0800 | [diff] [blame] | 201 | enable); |
| 202 | break; |
| 203 | default: |
| 204 | dprintf(CRITICAL, "backlight type:%d not supported\n", |
| 205 | bl->bl_interface_type); |
| 206 | return ERR_NOT_SUPPORTED; |
| 207 | } |
| 208 | |
| 209 | return ret; |
| 210 | } |
| 211 | |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 212 | int target_panel_clock(uint8_t enable, struct msm_panel_info *pinfo) |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 213 | { |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 214 | struct mdss_dsi_pll_config *pll_data; |
| 215 | uint32_t dual_dsi = pinfo->mipi.dual_dsi; |
| 216 | dprintf(SPEW, "target_panel_clock\n"); |
| 217 | |
| 218 | pll_data = pinfo->mipi.dsi_pll_config; |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 219 | if (enable) { |
| 220 | mdp_gdsc_ctrl(enable); |
| 221 | mdp_clock_init(); |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 222 | mdss_dsi_auto_pll_config(DSI0_PLL_BASE, |
| 223 | MIPI_DSI0_BASE, pll_data); |
| 224 | dsi_pll_enable_seq(DSI0_PLL_BASE); |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 225 | mmss_clock_auto_pll_init(DSI0_PHY_PLL_OUT, dual_dsi, |
| 226 | pll_data->pclk_m, |
| 227 | pll_data->pclk_n, |
| 228 | pll_data->pclk_d); |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 229 | } else if(!target_cont_splash_screen()) { |
| 230 | // * Add here for continuous splash * |
Siddhartha Agrawal | c88737b | 2013-05-29 20:41:35 -0700 | [diff] [blame] | 231 | mmss_clock_disable(dual_dsi); |
| 232 | mdp_clock_disable(dual_dsi); |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 233 | } |
| 234 | |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 235 | return NO_ERROR; |
Asaf Penso | 325f43a | 2013-05-21 21:55:48 +0300 | [diff] [blame] | 236 | } |
| 237 | |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 238 | /* Pull DISP_RST_N high to get panel out of reset */ |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 239 | int target_panel_reset(uint8_t enable, struct panel_reset_sequence *resetseq, |
| 240 | struct msm_panel_info *pinfo) |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 241 | { |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 242 | uint32_t rst_gpio = reset_gpio.pin_id; |
Chandan Uddaraju | d1bcbeb | 2013-07-01 18:13:48 -0700 | [diff] [blame] | 243 | uint32_t platform_id = board_platform_id(); |
| 244 | uint32_t hardware_id = board_hardware_id(); |
| 245 | |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 246 | struct pm8x41_gpio resetgpio_param = { |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 247 | .direction = PM_GPIO_DIR_OUT, |
| 248 | .output_buffer = PM_GPIO_OUT_CMOS, |
| 249 | .out_strength = PM_GPIO_OUT_DRIVE_MED, |
| 250 | }; |
| 251 | |
Chandan Uddaraju | d1bcbeb | 2013-07-01 18:13:48 -0700 | [diff] [blame] | 252 | if (platform_id == MSM8974AC) |
Chandan Uddaraju | b2cee90 | 2013-09-05 18:31:23 -0700 | [diff] [blame] | 253 | if ((hardware_id == HW_PLATFORM_MTP) |
Chandan Uddaraju | d1bcbeb | 2013-07-01 18:13:48 -0700 | [diff] [blame] | 254 | || (hardware_id == HW_PLATFORM_LIQUID)) |
| 255 | rst_gpio = 20; |
| 256 | |
| 257 | dprintf(SPEW, "platform_id: %u, rst_gpio: %u\n", |
| 258 | platform_id, rst_gpio); |
| 259 | |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 260 | pm8x41_gpio_config(rst_gpio, &resetgpio_param); |
Siddhartha Agrawal | c43c487 | 2013-04-21 16:23:16 -0700 | [diff] [blame] | 261 | if (enable) { |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 262 | gpio_tlmm_config(enable_gpio.pin_id, 0, |
| 263 | enable_gpio.pin_direction, enable_gpio.pin_pull, |
| 264 | enable_gpio.pin_strength, enable_gpio.pin_state); |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 265 | |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 266 | gpio_set(enable_gpio.pin_id, resetseq->pin_direction); |
| 267 | pm8x41_gpio_set(rst_gpio, resetseq->pin_state[0]); |
| 268 | mdelay(resetseq->sleep[0]); |
| 269 | pm8x41_gpio_set(rst_gpio, resetseq->pin_state[1]); |
| 270 | mdelay(resetseq->sleep[1]); |
| 271 | pm8x41_gpio_set(rst_gpio, resetseq->pin_state[2]); |
| 272 | mdelay(resetseq->sleep[2]); |
Siddhartha Agrawal | c43c487 | 2013-04-21 16:23:16 -0700 | [diff] [blame] | 273 | } else { |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 274 | resetgpio_param.out_strength = PM_GPIO_OUT_DRIVE_LOW; |
| 275 | pm8x41_gpio_config(rst_gpio, &resetgpio_param); |
Chandan Uddaraju | d1bcbeb | 2013-07-01 18:13:48 -0700 | [diff] [blame] | 276 | pm8x41_gpio_set(rst_gpio, PM_GPIO_FUNC_LOW); |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 277 | gpio_set(enable_gpio.pin_id, resetseq->pin_direction); |
Siddhartha Agrawal | c43c487 | 2013-04-21 16:23:16 -0700 | [diff] [blame] | 278 | } |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 279 | return NO_ERROR; |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 280 | } |
| 281 | |
Kuogee Hsieh | 93bcff6 | 2014-08-22 14:02:08 -0700 | [diff] [blame] | 282 | int target_ldo_ctrl(uint8_t enable, struct msm_panel_info *pinfo) |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 283 | { |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 284 | uint32_t ldocounter = 0; |
| 285 | uint32_t pm8x41_ldo_base = 0x13F00; |
Deepa Dinamani | ec4835b | 2013-06-03 16:14:24 -0700 | [diff] [blame] | 286 | |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 287 | while (ldocounter < TOTAL_LDO_DEFINED) { |
| 288 | struct pm8x41_ldo ldo_entry = LDO((pm8x41_ldo_base + |
| 289 | 0x100 * ldo_entry_array[ldocounter].ldo_id), |
| 290 | ldo_entry_array[ldocounter].ldo_type); |
Deepa Dinamani | ec4835b | 2013-06-03 16:14:24 -0700 | [diff] [blame] | 291 | |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 292 | dprintf(SPEW, "Setting %s\n", |
| 293 | ldo_entry_array[ldocounter].ldo_id); |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 294 | |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 295 | /* Set voltage during power on */ |
| 296 | if (enable) { |
| 297 | pm8x41_ldo_set_voltage(&ldo_entry, |
| 298 | ldo_entry_array[ldocounter].ldo_voltage); |
| 299 | pm8x41_ldo_control(&ldo_entry, enable); |
| 300 | } else if(ldo_entry_array[ldocounter].ldo_id != HFPLL_LDO_ID) { |
| 301 | pm8x41_ldo_control(&ldo_entry, enable); |
| 302 | } |
| 303 | ldocounter++; |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 304 | } |
| 305 | |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 306 | return NO_ERROR; |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 307 | } |
| 308 | |
Asaf Penso | e6870ff | 2013-07-07 17:23:56 +0300 | [diff] [blame] | 309 | static int msm8974_mdss_edp_panel_clock(int enable) |
| 310 | { |
| 311 | if (enable) { |
| 312 | mdp_gdsc_ctrl(enable); |
| 313 | mdp_clock_init(); |
| 314 | edp_clk_enable(); |
Asaf Penso | e6870ff | 2013-07-07 17:23:56 +0300 | [diff] [blame] | 315 | } else if (!target_cont_splash_screen()) { |
| 316 | /* Add here for continuous splash */ |
Kuogee Hsieh | df636eb | 2013-08-01 14:52:08 -0700 | [diff] [blame] | 317 | edp_clk_disable(); |
| 318 | mdp_clock_disable(); |
| 319 | mdp_gdsc_ctrl(enable); |
Asaf Penso | e6870ff | 2013-07-07 17:23:56 +0300 | [diff] [blame] | 320 | } |
| 321 | |
| 322 | return 0; |
| 323 | } |
| 324 | |
| 325 | static int msm8974_edp_panel_power(int enable) |
| 326 | { |
| 327 | struct pm8x41_gpio gpio36_param = { |
| 328 | .direction = PM_GPIO_DIR_OUT, |
Kuogee Hsieh | 80f3db0 | 2013-10-04 15:51:37 -0700 | [diff] [blame] | 329 | .function = PM_GPIO_FUNC_2, |
| 330 | .vin_sel = 2, /* VIN_2 */ |
| 331 | .pull = PM_GPIO_PULL_UP_1_5 | PM_GPIO_PULLDOWN_10, |
Asaf Penso | e6870ff | 2013-07-07 17:23:56 +0300 | [diff] [blame] | 332 | .output_buffer = PM_GPIO_OUT_CMOS, |
Kuogee Hsieh | 80f3db0 | 2013-10-04 15:51:37 -0700 | [diff] [blame] | 333 | .out_strength = PM_GPIO_OUT_DRIVE_HIGH, |
Asaf Penso | e6870ff | 2013-07-07 17:23:56 +0300 | [diff] [blame] | 334 | }; |
| 335 | |
| 336 | struct pm8x41_ldo ldo12 = LDO(PM8x41_LDO12, PLDO_TYPE); |
| 337 | |
| 338 | if (enable) { |
| 339 | /* Enable backlight */ |
| 340 | dprintf(SPEW, "Enable Backlight\n"); |
Kuogee Hsieh | df96174 | 2013-12-18 14:13:45 -0800 | [diff] [blame] | 341 | msm8974_pwm_backlight_ctrl(36, 8, 1); |
Asaf Penso | e6870ff | 2013-07-07 17:23:56 +0300 | [diff] [blame] | 342 | dprintf(SPEW, "Enable Backlight Done\n"); |
| 343 | |
| 344 | /* Turn on LDO12 for edp vdda */ |
| 345 | dprintf(SPEW, "Setting LDO12 n"); |
| 346 | pm8x41_ldo_set_voltage(&ldo12, 1800000); |
| 347 | pm8x41_ldo_control(&ldo12, enable); |
| 348 | dprintf(SPEW, "Setting LDO12 Done\n"); |
| 349 | |
| 350 | /* Panel Enable */ |
| 351 | dprintf(SPEW, "Panel Enable\n"); |
| 352 | gpio_tlmm_config(58, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_8MA, |
| 353 | GPIO_DISABLE); |
| 354 | gpio_set(58, 2); |
| 355 | dprintf(SPEW, "Panel Enable Done\n"); |
| 356 | } else { |
| 357 | /* Keep LDO12 on, otherwise kernel will not boot */ |
Kuogee Hsieh | df636eb | 2013-08-01 14:52:08 -0700 | [diff] [blame] | 358 | gpio_set(58, 0); |
Kuogee Hsieh | df96174 | 2013-12-18 14:13:45 -0800 | [diff] [blame] | 359 | msm8974_pwm_backlight_ctrl(36, 8, 0); |
Asaf Penso | e6870ff | 2013-07-07 17:23:56 +0300 | [diff] [blame] | 360 | } |
| 361 | |
| 362 | return 0; |
| 363 | } |
| 364 | |
Ajay Singh Parmar | eef1d60 | 2014-03-15 17:41:52 -0700 | [diff] [blame] | 365 | bool target_display_panel_node(char *panel_name, char *pbuf, uint16_t buf_size) |
| 366 | { |
| 367 | int prefix_string_len = strlen(DISPLAY_CMDLINE_PREFIX); |
| 368 | bool ret = true; |
| 369 | |
| 370 | panel_name += strspn(panel_name, " "); |
| 371 | |
| 372 | if (!strcmp(panel_name, HDMI_PANEL_NAME)) { |
| 373 | if (buf_size < (prefix_string_len + LK_OVERRIDE_PANEL_LEN + |
| 374 | HDMI_CONTROLLER_STRING)) { |
| 375 | dprintf(CRITICAL, "command line argument is greater than buffer size\n"); |
| 376 | return false; |
| 377 | } |
| 378 | |
| 379 | strlcpy(pbuf, DISPLAY_CMDLINE_PREFIX, buf_size); |
| 380 | buf_size -= prefix_string_len; |
| 381 | strlcat(pbuf, LK_OVERRIDE_PANEL, buf_size); |
| 382 | buf_size -= LK_OVERRIDE_PANEL_LEN; |
| 383 | strlcat(pbuf, HDMI_CONTROLLER_STRING, buf_size); |
| 384 | } else { |
Veera Sundaram Sankaran | c95d675 | 2014-07-31 11:49:52 -0700 | [diff] [blame] | 385 | ret = gcdb_display_cmdline_arg(panel_name, pbuf, buf_size); |
Ajay Singh Parmar | eef1d60 | 2014-03-15 17:41:52 -0700 | [diff] [blame] | 386 | } |
| 387 | |
| 388 | return ret; |
| 389 | } |
| 390 | |
Aravind Venkateswaran | 6385f7e | 2014-02-25 16:45:11 -0800 | [diff] [blame] | 391 | void target_display_init(const char *panel_name) |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 392 | { |
| 393 | uint32_t hw_id = board_hardware_id(); |
Casey Piper | 74f8e5c | 2013-09-05 15:00:30 -0700 | [diff] [blame] | 394 | uint32_t panel_loop = 0; |
| 395 | uint32_t ret = 0; |
Ajay Singh Parmar | eef1d60 | 2014-03-15 17:41:52 -0700 | [diff] [blame] | 396 | |
Channagoud Kadabi | 62ac4cb | 2014-05-13 11:55:38 -0700 | [diff] [blame] | 397 | if (target_hw_interposer()) |
| 398 | return; |
| 399 | |
Ajay Singh Parmar | eef1d60 | 2014-03-15 17:41:52 -0700 | [diff] [blame] | 400 | panel_name += strspn(panel_name, " "); |
| 401 | |
Veera Sundaram Sankaran | 3b75882 | 2014-10-17 12:15:39 -0700 | [diff] [blame^] | 402 | if (!strcmp(panel_name, NO_PANEL_CONFIG) |
| 403 | || !strcmp(panel_name, SIM_VIDEO_PANEL) |
| 404 | || !strcmp(panel_name, SIM_DUALDSI_VIDEO_PANEL) |
| 405 | || !strcmp(panel_name, SIM_CMD_PANEL) |
| 406 | || !strcmp(panel_name, SIM_DUALDSI_CMD_PANEL)) { |
| 407 | dprintf(INFO, "Selected panel: %s\nSkip panel configuration\n", |
| 408 | panel_name); |
Jeevan Shriram | b0d523a | 2014-05-30 12:55:17 -0700 | [diff] [blame] | 409 | return; |
Veera Sundaram Sankaran | c95d675 | 2014-07-31 11:49:52 -0700 | [diff] [blame] | 410 | } else if (!strcmp(panel_name, HDMI_PANEL_NAME)) { |
Ajay Singh Parmar | eef1d60 | 2014-03-15 17:41:52 -0700 | [diff] [blame] | 411 | dprintf(INFO, "%s: HDMI is primary\n", __func__); |
| 412 | return; |
| 413 | } |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 414 | switch (hw_id) { |
Asaf Penso | e6870ff | 2013-07-07 17:23:56 +0300 | [diff] [blame] | 415 | case HW_PLATFORM_LIQUID: |
Kuogee Hsieh | df636eb | 2013-08-01 14:52:08 -0700 | [diff] [blame] | 416 | edp_panel_init(&(panel.panel_info)); |
Asaf Penso | e6870ff | 2013-07-07 17:23:56 +0300 | [diff] [blame] | 417 | panel.clk_func = msm8974_mdss_edp_panel_clock; |
| 418 | panel.power_func = msm8974_edp_panel_power; |
| 419 | panel.fb.base = (void *)EDP_FB_ADDR; |
Asaf Penso | e6870ff | 2013-07-07 17:23:56 +0300 | [diff] [blame] | 420 | panel.fb.format = FB_FORMAT_RGB888; |
| 421 | panel.mdp_rev = MDP_REV_50; |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 422 | |
| 423 | if (msm_display_init(&panel)) { |
| 424 | dprintf(CRITICAL, "edp init failed!\n"); |
| 425 | return; |
| 426 | } |
| 427 | |
| 428 | edp_enable = 1; |
Asaf Penso | e6870ff | 2013-07-07 17:23:56 +0300 | [diff] [blame] | 429 | break; |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 430 | default: |
Casey Piper | 74f8e5c | 2013-09-05 15:00:30 -0700 | [diff] [blame] | 431 | do { |
Justin Philip | be9de5c | 2014-09-17 12:26:49 +0530 | [diff] [blame] | 432 | target_force_cont_splash_disable(false); |
Aravind Venkateswaran | d494f96 | 2014-02-25 17:16:49 -0800 | [diff] [blame] | 433 | ret = gcdb_display_init(panel_name, MDP_REV_50, |
| 434 | MIPI_FB_ADDR); |
Casey Piper | cc7e52e | 2013-10-01 15:51:04 -0700 | [diff] [blame] | 435 | if (!ret || ret == ERR_NOT_SUPPORTED) { |
| 436 | break; |
| 437 | } else { |
Casey Piper | 74f8e5c | 2013-09-05 15:00:30 -0700 | [diff] [blame] | 438 | target_force_cont_splash_disable(true); |
| 439 | msm_display_off(); |
Casey Piper | 74f8e5c | 2013-09-05 15:00:30 -0700 | [diff] [blame] | 440 | } |
Casey Piper | 74f8e5c | 2013-09-05 15:00:30 -0700 | [diff] [blame] | 441 | } while (++panel_loop <= oem_panel_max_auto_detect_panels()); |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 442 | break; |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 443 | } |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 444 | } |
| 445 | |
Aravind Venkateswaran | dd50c1a | 2014-02-25 14:42:43 -0800 | [diff] [blame] | 446 | void target_display_shutdown(void) |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 447 | { |
Casey Piper | 98e94f1 | 2013-09-09 20:42:15 -0700 | [diff] [blame] | 448 | uint32_t hw_id = board_hardware_id(); |
| 449 | switch (hw_id) { |
| 450 | case HW_PLATFORM_LIQUID: |
| 451 | if (edp_enable) |
| 452 | msm_display_off(); |
| 453 | break; |
| 454 | default: |
| 455 | gcdb_display_shutdown(); |
| 456 | break; |
| 457 | } |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 458 | } |