Jeevan Shriram | 2d3500b | 2014-12-29 16:25:06 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved. |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +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> |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 32 | #include <err.h> |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 33 | #include <msm_panel.h> |
Arpita Banerjee | 0906ffd | 2013-05-24 16:25:38 -0700 | [diff] [blame] | 34 | #include <mipi_dsi.h> |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 35 | #include <pm8x41.h> |
| 36 | #include <pm8x41_wled.h> |
| 37 | #include <board.h> |
| 38 | #include <mdp5.h> |
Aravind Venkateswaran | fada7f3 | 2013-09-19 15:23:34 -0700 | [diff] [blame] | 39 | #include <scm.h> |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 40 | #include <platform/gpio.h> |
| 41 | #include <platform/iomap.h> |
| 42 | #include <target/display.h> |
| 43 | |
Casey Piper | cbdfbd2 | 2013-08-14 17:22:16 -0700 | [diff] [blame] | 44 | #include "include/panel.h" |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 45 | #include "include/display_resource.h" |
Veera Sundaram Sankaran | 87f8813 | 2015-01-28 11:32:44 -0800 | [diff] [blame] | 46 | #include "gcdb_display.h" |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 47 | |
Dhaval Patel | 815567c | 2013-07-31 11:13:25 -0700 | [diff] [blame] | 48 | #define HFPLL_LDO_ID 8 |
| 49 | |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 50 | static struct pm8x41_wled_data wled_ctrl = { |
rayzhang | a3667cd | 2013-07-01 12:22:54 +0800 | [diff] [blame] | 51 | .mod_scheme = 0x00, |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 52 | .led1_brightness = (0x0F << 8) | 0xEF, |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 53 | .max_duty_cycle = 0x01, |
rayzhang | a3667cd | 2013-07-01 12:22:54 +0800 | [diff] [blame] | 54 | .ovp = 0x0, |
Zhenhua Huang | d5355cb | 2013-09-04 16:03:01 +0800 | [diff] [blame] | 55 | .full_current_scale = 0x19, |
| 56 | .fdbck = 0x1 |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 57 | }; |
| 58 | |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 59 | static uint32_t dsi_pll_enable_seq_m(uint32_t pll_base) |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 60 | { |
| 61 | uint32_t i = 0; |
| 62 | uint32_t pll_locked = 0; |
| 63 | |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 64 | mdss_dsi_uniphy_pll_sw_reset(pll_base); |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 65 | |
| 66 | /* |
| 67 | * Add hardware recommended delays between register writes for |
| 68 | * the updates to take effect. These delays are necessary for the |
| 69 | * PLL to successfully lock |
| 70 | */ |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 71 | writel(0x01, pll_base + 0x0020); /* GLB CFG */ |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 72 | udelay(200); |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 73 | writel(0x05, pll_base + 0x0020); /* GLB CFG */ |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 74 | udelay(200); |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 75 | writel(0x0f, pll_base + 0x0020); /* GLB CFG */ |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 76 | udelay(1000); |
| 77 | |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 78 | mdss_dsi_uniphy_pll_lock_detect_setting(pll_base); |
| 79 | pll_locked = readl(pll_base + 0x00c0) & 0x01; |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 80 | for (i = 0; (i < 4) && !pll_locked; i++) { |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 81 | writel(0x07, pll_base + 0x0020); /* GLB CFG */ |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 82 | if (i != 0) |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 83 | writel(0x34, pll_base + 0x00070); /* CAL CFG1*/ |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 84 | udelay(1); |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 85 | writel(0x0f, pll_base + 0x0020); /* GLB CFG */ |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 86 | udelay(1000); |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 87 | mdss_dsi_uniphy_pll_lock_detect_setting(pll_base); |
| 88 | pll_locked = readl(pll_base + 0x00c0) & 0x01; |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | return pll_locked; |
| 92 | } |
| 93 | |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 94 | static uint32_t dsi_pll_enable_seq_d(uint32_t pll_base) |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 95 | { |
| 96 | uint32_t pll_locked = 0; |
| 97 | |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 98 | mdss_dsi_uniphy_pll_sw_reset(pll_base); |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 99 | |
| 100 | /* |
| 101 | * Add hardware recommended delays between register writes for |
| 102 | * the updates to take effect. These delays are necessary for the |
| 103 | * PLL to successfully lock |
| 104 | */ |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 105 | writel(0x01, pll_base + 0x0020); /* GLB CFG */ |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 106 | udelay(200); |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 107 | writel(0x05, pll_base + 0x0020); /* GLB CFG */ |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 108 | udelay(200); |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 109 | writel(0x07, pll_base + 0x0020); /* GLB CFG */ |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 110 | udelay(200); |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 111 | writel(0x05, pll_base + 0x0020); /* GLB CFG */ |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -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 */ |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 114 | udelay(200); |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 115 | writel(0x0f, pll_base + 0x0020); /* GLB CFG */ |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 116 | udelay(1000); |
| 117 | |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 118 | mdss_dsi_uniphy_pll_lock_detect_setting(pll_base); |
| 119 | pll_locked = readl(pll_base + 0x00c0) & 0x01; |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 120 | |
| 121 | return pll_locked; |
| 122 | } |
| 123 | |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 124 | static uint32_t dsi_pll_enable_seq_f1(uint32_t pll_base) |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 125 | { |
| 126 | uint32_t pll_locked = 0; |
| 127 | |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 128 | mdss_dsi_uniphy_pll_sw_reset(pll_base); |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 129 | |
| 130 | /* |
| 131 | * Add hardware recommended delays between register writes for |
| 132 | * the updates to take effect. These delays are necessary for the |
| 133 | * PLL to successfully lock |
| 134 | */ |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 135 | writel(0x01, pll_base + 0x0020); /* GLB CFG */ |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 136 | udelay(200); |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 137 | writel(0x05, pll_base + 0x0020); /* GLB CFG */ |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 138 | udelay(200); |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 139 | writel(0x0f, pll_base + 0x0020); /* GLB CFG */ |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 140 | udelay(200); |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 141 | writel(0x0d, pll_base + 0x0020); /* GLB CFG */ |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 142 | udelay(200); |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 143 | writel(0x0f, pll_base + 0x0020); /* GLB CFG */ |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 144 | udelay(1000); |
| 145 | |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 146 | mdss_dsi_uniphy_pll_lock_detect_setting(pll_base); |
| 147 | pll_locked = readl(pll_base + 0x00c0) & 0x01; |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 148 | |
| 149 | return pll_locked; |
| 150 | } |
| 151 | |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 152 | static uint32_t dsi_pll_enable_seq_c(uint32_t pll_base) |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 153 | { |
| 154 | uint32_t pll_locked = 0; |
| 155 | |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 156 | mdss_dsi_uniphy_pll_sw_reset(pll_base); |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 157 | |
| 158 | /* |
| 159 | * Add hardware recommended delays between register writes for |
| 160 | * the updates to take effect. These delays are necessary for the |
| 161 | * PLL to successfully lock |
| 162 | */ |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 163 | writel(0x01, pll_base + 0x0020); /* GLB CFG */ |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 164 | udelay(200); |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 165 | writel(0x05, pll_base + 0x0020); /* GLB CFG */ |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 166 | udelay(200); |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 167 | writel(0x0f, pll_base + 0x0020); /* GLB CFG */ |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 168 | udelay(1000); |
| 169 | |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 170 | mdss_dsi_uniphy_pll_lock_detect_setting(pll_base); |
| 171 | pll_locked = readl(pll_base + 0x00c0) & 0x01; |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 172 | |
| 173 | return pll_locked; |
| 174 | } |
| 175 | |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 176 | static uint32_t dsi_pll_enable_seq_e(uint32_t pll_base) |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 177 | { |
| 178 | uint32_t pll_locked = 0; |
| 179 | |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 180 | mdss_dsi_uniphy_pll_sw_reset(pll_base); |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 181 | |
| 182 | /* |
| 183 | * Add hardware recommended delays between register writes for |
| 184 | * the updates to take effect. These delays are necessary for the |
| 185 | * PLL to successfully lock |
| 186 | */ |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 187 | writel(0x01, pll_base + 0x0020); /* GLB CFG */ |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 188 | udelay(200); |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 189 | writel(0x05, pll_base + 0x0020); /* GLB CFG */ |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 190 | udelay(200); |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 191 | writel(0x0d, pll_base + 0x0020); /* GLB CFG */ |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 192 | udelay(1); |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 193 | writel(0x0f, pll_base + 0x0020); /* GLB CFG */ |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 194 | udelay(1000); |
| 195 | |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 196 | mdss_dsi_uniphy_pll_lock_detect_setting(pll_base); |
| 197 | pll_locked = readl(pll_base + 0x00c0) & 0x01; |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 198 | |
| 199 | return pll_locked; |
| 200 | } |
| 201 | |
Vineet Bajaj | bb14cb0 | 2014-04-25 00:38:09 +0530 | [diff] [blame] | 202 | static int msm8226_wled_backlight_ctrl(uint8_t enable) |
| 203 | { |
| 204 | if (enable) { |
| 205 | pm8x41_wled_config(&wled_ctrl); |
| 206 | pm8x41_wled_sink_control(enable); |
| 207 | pm8x41_wled_iled_sync_control(enable); |
| 208 | pm8x41_wled_led_mod_enable(enable); |
| 209 | } |
| 210 | pm8x41_wled_enable(enable); |
| 211 | |
| 212 | return NO_ERROR; |
| 213 | } |
| 214 | |
| 215 | static int msm8226_pwm_backlight_ctrl(int gpio_num, int lpg_chan, int enable) |
| 216 | { |
| 217 | struct pm8x41_gpio gpio_param = { |
| 218 | .direction = PM_GPIO_DIR_OUT, |
| 219 | .function = PM_GPIO_FUNC_2, |
| 220 | .vin_sel = 2, /* VIN_2 */ |
| 221 | .pull = PM_GPIO_PULL_UP_1_5 | PM_GPIO_PULLDOWN_10, |
| 222 | .output_buffer = PM_GPIO_OUT_CMOS, |
| 223 | .out_strength = PM_GPIO_OUT_DRIVE_HIGH, |
| 224 | }; |
| 225 | |
| 226 | dprintf(SPEW, "%s: gpio=%d lpg=%d enable=%d\n", __func__, |
| 227 | gpio_num, lpg_chan, enable); |
| 228 | |
| 229 | if (enable) { |
| 230 | pm8x41_gpio_config(gpio_num, &gpio_param); |
| 231 | pm8x41_lpg_write(lpg_chan, 0x41, 0x33); /* LPG_PWM_SIZE_CLK, */ |
| 232 | pm8x41_lpg_write(lpg_chan, 0x42, 0x01); /* LPG_PWM_FREQ_PREDIV */ |
| 233 | pm8x41_lpg_write(lpg_chan, 0x43, 0x20); /* LPG_PWM_TYPE_CONFIG */ |
| 234 | pm8x41_lpg_write(lpg_chan, 0x44, 0xb2); /* LPG_VALUE_LSB */ |
| 235 | pm8x41_lpg_write(lpg_chan, 0x45, 0x01); /* LPG_VALUE_MSB */ |
| 236 | pm8x41_lpg_write(lpg_chan, 0x46, 0xe4); /* LPG_ENABLE_CONTROL */ |
| 237 | } else { |
| 238 | pm8x41_lpg_write(lpg_chan, 0x46, 0x00); |
| 239 | } |
| 240 | |
| 241 | return NO_ERROR; |
| 242 | } |
| 243 | |
| 244 | |
Kuogee Hsieh | df96174 | 2013-12-18 14:13:45 -0800 | [diff] [blame] | 245 | int target_backlight_ctrl(struct backlight *bl, uint8_t enable) |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 246 | { |
Vineet Bajaj | bb14cb0 | 2014-04-25 00:38:09 +0530 | [diff] [blame] | 247 | uint32_t ret = NO_ERROR; |
| 248 | |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 249 | dprintf(SPEW, "target_backlight_ctrl\n"); |
| 250 | |
Kuogee Hsieh | df96174 | 2013-12-18 14:13:45 -0800 | [diff] [blame] | 251 | if (!bl) { |
| 252 | dprintf(CRITICAL, "backlight structure is not available\n"); |
| 253 | return ERR_INVALID_ARGS; |
| 254 | } |
| 255 | |
Vineet Bajaj | bb14cb0 | 2014-04-25 00:38:09 +0530 | [diff] [blame] | 256 | switch (bl->bl_interface_type) { |
| 257 | case BL_WLED: |
| 258 | ret = msm8226_wled_backlight_ctrl(enable); |
| 259 | break; |
| 260 | case BL_PWM: |
| 261 | ret = msm8226_pwm_backlight_ctrl(pwm_gpio.pin_id, |
| 262 | PWM_BL_LPG_CHAN_ID, |
| 263 | enable); |
| 264 | break; |
Aravind Venkateswaran | d4b5760 | 2015-01-29 23:22:14 -0800 | [diff] [blame] | 265 | case BL_DCS: |
| 266 | break; |
Vineet Bajaj | bb14cb0 | 2014-04-25 00:38:09 +0530 | [diff] [blame] | 267 | default: |
| 268 | dprintf(CRITICAL, "backlight type:%d not supported\n", |
Kuogee Hsieh | df96174 | 2013-12-18 14:13:45 -0800 | [diff] [blame] | 269 | bl->bl_interface_type); |
Vineet Bajaj | bb14cb0 | 2014-04-25 00:38:09 +0530 | [diff] [blame] | 270 | return ERR_NOT_SUPPORTED; |
Kuogee Hsieh | df96174 | 2013-12-18 14:13:45 -0800 | [diff] [blame] | 271 | } |
| 272 | |
Vineet Bajaj | bb14cb0 | 2014-04-25 00:38:09 +0530 | [diff] [blame] | 273 | return ret; |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 274 | } |
| 275 | |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 276 | static void dsi_pll_enable_seq(uint32_t pll_base) |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 277 | { |
Padmanabhan Komanduru | 703bd6d | 2014-03-25 19:57:01 +0530 | [diff] [blame] | 278 | if (dsi_pll_enable_seq_m(pll_base)) { |
| 279 | } else if (dsi_pll_enable_seq_d(pll_base)) { |
| 280 | } else if (dsi_pll_enable_seq_d(pll_base)) { |
| 281 | } else if (dsi_pll_enable_seq_f1(pll_base)) { |
| 282 | } else if (dsi_pll_enable_seq_c(pll_base)) { |
| 283 | } else if (dsi_pll_enable_seq_e(pll_base)) { |
Casey Piper | aee8120 | 2013-08-26 11:14:02 -0700 | [diff] [blame] | 284 | } else { |
| 285 | dprintf(CRITICAL, "Not able to enable the pll\n"); |
| 286 | } |
| 287 | } |
| 288 | |
Arpita Banerjee | 0906ffd | 2013-05-24 16:25:38 -0700 | [diff] [blame] | 289 | int target_panel_clock(uint8_t enable, struct msm_panel_info *pinfo) |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 290 | { |
Aravind Venkateswaran | fada7f3 | 2013-09-19 15:23:34 -0700 | [diff] [blame] | 291 | int32_t ret; |
Arpita Banerjee | 0906ffd | 2013-05-24 16:25:38 -0700 | [diff] [blame] | 292 | struct mdss_dsi_pll_config *pll_data; |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 293 | dprintf(SPEW, "target_panel_clock\n"); |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 294 | |
Arpita Banerjee | 0906ffd | 2013-05-24 16:25:38 -0700 | [diff] [blame] | 295 | pll_data = pinfo->mipi.dsi_pll_config; |
| 296 | |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 297 | if (enable) { |
| 298 | mdp_gdsc_ctrl(enable); |
Aravind Venkateswaran | 5f54692 | 2013-09-19 15:13:43 -0700 | [diff] [blame] | 299 | mmss_bus_clocks_enable(); |
| 300 | mdp_clock_enable(); |
Aravind Venkateswaran | fada7f3 | 2013-09-19 15:23:34 -0700 | [diff] [blame] | 301 | ret = restore_secure_cfg(SECURE_DEVICE_MDSS); |
| 302 | if (ret) { |
| 303 | dprintf(CRITICAL, |
| 304 | "%s: Failed to restore MDP security configs", |
| 305 | __func__); |
| 306 | mdp_clock_disable(); |
| 307 | mmss_bus_clocks_disable(); |
| 308 | mdp_gdsc_ctrl(0); |
| 309 | return ret; |
| 310 | } |
Padmanabhan Komanduru | c0766c8 | 2015-04-27 16:39:15 -0700 | [diff] [blame] | 311 | mdss_dsi_auto_pll_config(pinfo->mipi.pll_base, |
Jeevan Shriram | 2d3500b | 2014-12-29 16:25:06 -0800 | [diff] [blame] | 312 | pinfo->mipi.ctl_base, pll_data); |
Padmanabhan Komanduru | c0766c8 | 2015-04-27 16:39:15 -0700 | [diff] [blame] | 313 | dsi_pll_enable_seq(pinfo->mipi.pll_base); |
Aravind Venkateswaran | 5f54692 | 2013-09-19 15:13:43 -0700 | [diff] [blame] | 314 | mmss_dsi_clocks_enable(pll_data->pclk_m, |
Arpita Banerjee | 0906ffd | 2013-05-24 16:25:38 -0700 | [diff] [blame] | 315 | pll_data->pclk_n, |
| 316 | pll_data->pclk_d); |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 317 | } else if(!target_cont_splash_screen()) { |
Aravind Venkateswaran | 5f54692 | 2013-09-19 15:13:43 -0700 | [diff] [blame] | 318 | mmss_dsi_clocks_disable(); |
| 319 | mdp_clock_disable(); |
| 320 | mmss_bus_clocks_disable(); |
| 321 | mdp_gdsc_ctrl(enable); |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 322 | } |
| 323 | |
| 324 | return 0; |
| 325 | } |
| 326 | |
Dhaval Patel | 7a34956 | 2013-08-08 20:43:52 -0700 | [diff] [blame] | 327 | int target_panel_reset(uint8_t enable, struct panel_reset_sequence *resetseq, |
| 328 | struct msm_panel_info *pinfo) |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 329 | { |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 330 | int ret = NO_ERROR; |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 331 | if (enable) { |
Aravind Venkateswaran | af24121 | 2013-11-04 16:46:46 -0800 | [diff] [blame] | 332 | if (pinfo->mipi.use_enable_gpio) { |
| 333 | gpio_tlmm_config(enable_gpio.pin_id, 0, |
| 334 | enable_gpio.pin_direction, enable_gpio.pin_pull, |
| 335 | enable_gpio.pin_strength, |
| 336 | enable_gpio.pin_state); |
| 337 | |
| 338 | gpio_set_dir(enable_gpio.pin_id, 2); |
| 339 | } |
| 340 | |
Dhaval Patel | 7a34956 | 2013-08-08 20:43:52 -0700 | [diff] [blame] | 341 | gpio_tlmm_config(reset_gpio.pin_id, 0, |
| 342 | reset_gpio.pin_direction, reset_gpio.pin_pull, |
| 343 | reset_gpio.pin_strength, reset_gpio.pin_state); |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 344 | |
Dhaval Patel | 7a34956 | 2013-08-08 20:43:52 -0700 | [diff] [blame] | 345 | gpio_set_dir(reset_gpio.pin_id, 2); |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 346 | |
Dhaval Patel | 7a34956 | 2013-08-08 20:43:52 -0700 | [diff] [blame] | 347 | gpio_set_value(reset_gpio.pin_id, resetseq->pin_state[0]); |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 348 | mdelay(resetseq->sleep[0]); |
Dhaval Patel | 7a34956 | 2013-08-08 20:43:52 -0700 | [diff] [blame] | 349 | gpio_set_value(reset_gpio.pin_id, resetseq->pin_state[1]); |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 350 | mdelay(resetseq->sleep[1]); |
Dhaval Patel | 7a34956 | 2013-08-08 20:43:52 -0700 | [diff] [blame] | 351 | gpio_set_value(reset_gpio.pin_id, resetseq->pin_state[2]); |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 352 | mdelay(resetseq->sleep[2]); |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 353 | } else if(!target_cont_splash_screen()) { |
Dhaval Patel | 7a34956 | 2013-08-08 20:43:52 -0700 | [diff] [blame] | 354 | gpio_set_value(reset_gpio.pin_id, 0); |
Aravind Venkateswaran | af24121 | 2013-11-04 16:46:46 -0800 | [diff] [blame] | 355 | if (pinfo->mipi.use_enable_gpio) |
| 356 | gpio_set_value(enable_gpio.pin_id, 0); |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 357 | } |
| 358 | |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 359 | return ret; |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 360 | } |
| 361 | |
Kuogee Hsieh | 93bcff6 | 2014-08-22 14:02:08 -0700 | [diff] [blame] | 362 | int target_ldo_ctrl(uint8_t enable, struct msm_panel_info *pinfo) |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 363 | { |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 364 | uint32_t ret = NO_ERROR; |
| 365 | uint32_t ldocounter = 0; |
| 366 | uint32_t pm8x41_ldo_base = 0x13F00; |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 367 | |
Dhaval Patel | 7a34956 | 2013-08-08 20:43:52 -0700 | [diff] [blame] | 368 | while (ldocounter < TOTAL_LDO_DEFINED) { |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 369 | struct pm8x41_ldo ldo_entry = LDO((pm8x41_ldo_base + |
| 370 | 0x100 * ldo_entry_array[ldocounter].ldo_id), |
| 371 | ldo_entry_array[ldocounter].ldo_type); |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 372 | |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 373 | dprintf(SPEW, "Setting %s\n", |
| 374 | ldo_entry_array[ldocounter].ldo_id); |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 375 | |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 376 | /* Set voltage during power on */ |
Dhaval Patel | 815567c | 2013-07-31 11:13:25 -0700 | [diff] [blame] | 377 | if (enable) { |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 378 | pm8x41_ldo_set_voltage(&ldo_entry, |
| 379 | ldo_entry_array[ldocounter].ldo_voltage); |
Dhaval Patel | 815567c | 2013-07-31 11:13:25 -0700 | [diff] [blame] | 380 | |
| 381 | pm8x41_ldo_control(&ldo_entry, enable); |
| 382 | |
| 383 | } else if(!target_cont_splash_screen() && |
| 384 | ldo_entry_array[ldocounter].ldo_id != HFPLL_LDO_ID) { |
| 385 | pm8x41_ldo_control(&ldo_entry, enable); |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 386 | } |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 387 | ldocounter++; |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 388 | } |
| 389 | |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 390 | return ret; |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 391 | } |
| 392 | |
Dhaval Patel | 7709c41 | 2015-05-12 10:09:41 -0700 | [diff] [blame] | 393 | int target_dsi_phy_config(struct mdss_dsi_phy_ctrl *phy_db) |
| 394 | { |
| 395 | memcpy(phy_db->regulator, panel_regulator_settings, REGULATOR_SIZE); |
| 396 | memcpy(phy_db->ctrl, panel_physical_ctrl, PHYSICAL_SIZE); |
| 397 | memcpy(phy_db->strength, panel_strength_ctrl, STRENGTH_SIZE); |
| 398 | memcpy(phy_db->bistCtrl, panel_bist_ctrl, BIST_SIZE); |
| 399 | memcpy(phy_db->laneCfg, panel_lane_config, LANE_SIZE); |
| 400 | return NO_ERROR; |
| 401 | } |
| 402 | |
Padmanabhan Komanduru | bccbcdc | 2015-06-30 16:19:24 +0530 | [diff] [blame^] | 403 | bool target_display_panel_node(char *pbuf, uint16_t buf_size) |
Ajay Singh Parmar | eef1d60 | 2014-03-15 17:41:52 -0700 | [diff] [blame] | 404 | { |
Padmanabhan Komanduru | bccbcdc | 2015-06-30 16:19:24 +0530 | [diff] [blame^] | 405 | return gcdb_display_cmdline_arg(pbuf, buf_size); |
Ajay Singh Parmar | eef1d60 | 2014-03-15 17:41:52 -0700 | [diff] [blame] | 406 | } |
| 407 | |
Aravind Venkateswaran | 6385f7e | 2014-02-25 16:45:11 -0800 | [diff] [blame] | 408 | void target_display_init(const char *panel_name) |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 409 | { |
Pradeep Jilagam | feb1598 | 2013-10-29 13:08:51 +0530 | [diff] [blame] | 410 | uint32_t panel_loop = 0; |
| 411 | uint32_t ret = 0; |
Aravind Venkateswaran | 148e0df | 2014-03-28 16:26:05 -0700 | [diff] [blame] | 412 | uint32_t fb_addr = MIPI_FB_ADDR; |
Padmanabhan Komanduru | bccbcdc | 2015-06-30 16:19:24 +0530 | [diff] [blame^] | 413 | struct oem_panel_data oem; |
Veera Sundaram Sankaran | 7868d54 | 2015-01-02 14:48:47 -0800 | [diff] [blame] | 414 | |
Padmanabhan Komanduru | bccbcdc | 2015-06-30 16:19:24 +0530 | [diff] [blame^] | 415 | set_panel_cmd_string(panel_name); |
| 416 | oem = mdss_dsi_get_oem_data(); |
Aravind Venkateswaran | 148e0df | 2014-03-28 16:26:05 -0700 | [diff] [blame] | 417 | |
Padmanabhan Komanduru | bccbcdc | 2015-06-30 16:19:24 +0530 | [diff] [blame^] | 418 | if (!strcmp(oem.panel, NO_PANEL_CONFIG) |
| 419 | || !strcmp(oem.panel, SIM_VIDEO_PANEL) |
| 420 | || !strcmp(oem.panel, SIM_CMD_PANEL) |
| 421 | || oem.skip) { |
Veera Sundaram Sankaran | c95d675 | 2014-07-31 11:49:52 -0700 | [diff] [blame] | 422 | dprintf(INFO, "Selected panel: %s\nSkip panel configuration\n", |
Padmanabhan Komanduru | bccbcdc | 2015-06-30 16:19:24 +0530 | [diff] [blame^] | 423 | oem.panel); |
Jeevan Shriram | b0d523a | 2014-05-30 12:55:17 -0700 | [diff] [blame] | 424 | return; |
| 425 | } |
| 426 | |
Aravind Venkateswaran | 148e0df | 2014-03-28 16:26:05 -0700 | [diff] [blame] | 427 | if (board_hardware_subtype() == HW_PLATFORM_SUBTYPE_QVGA) |
| 428 | fb_addr = MIPI_FB_ADDR_QVGA; |
Pradeep Jilagam | feb1598 | 2013-10-29 13:08:51 +0530 | [diff] [blame] | 429 | |
| 430 | do { |
Justin Philip | be9de5c | 2014-09-17 12:26:49 +0530 | [diff] [blame] | 431 | target_force_cont_splash_disable(false); |
Padmanabhan Komanduru | bccbcdc | 2015-06-30 16:19:24 +0530 | [diff] [blame^] | 432 | ret = gcdb_display_init(oem.panel, MDP_REV_50, fb_addr); |
Pradeep Jilagam | feb1598 | 2013-10-29 13:08:51 +0530 | [diff] [blame] | 433 | if (!ret || ret == ERR_NOT_SUPPORTED) { |
| 434 | break; |
| 435 | } else { |
| 436 | target_force_cont_splash_disable(true); |
| 437 | msm_display_off(); |
Pradeep Jilagam | feb1598 | 2013-10-29 13:08:51 +0530 | [diff] [blame] | 438 | } |
| 439 | } while (++panel_loop <= oem_panel_max_auto_detect_panels()); |
| 440 | |
Padmanabhan Komanduru | bccbcdc | 2015-06-30 16:19:24 +0530 | [diff] [blame^] | 441 | if (!oem.cont_splash) { |
Veera Sundaram Sankaran | 7868d54 | 2015-01-02 14:48:47 -0800 | [diff] [blame] | 442 | dprintf(INFO, "Forcing continuous splash disable\n"); |
| 443 | target_force_cont_splash_disable(true); |
| 444 | } |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 445 | } |
| 446 | |
Aravind Venkateswaran | dd50c1a | 2014-02-25 14:42:43 -0800 | [diff] [blame] | 447 | void target_display_shutdown(void) |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 448 | { |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 449 | gcdb_display_shutdown(); |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 450 | } |