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