Umang Agrawal | abccfc9 | 2017-12-19 12:05:27 +0530 | [diff] [blame] | 1 | /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. |
Aparna Mallavarapu | 01fc00a | 2015-06-01 20:37:05 +0530 | [diff] [blame] | 2 | * |
| 3 | * Redistribution and use in source and binary forms, with or without |
| 4 | * modification, are permitted provided that the following conditions are |
| 5 | * 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 |
| 9 | * copyright notice, this list of conditions and the following |
| 10 | * disclaimer in the documentation and/or other materials provided |
| 11 | * with the 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 "AS IS" AND ANY EXPRESS OR IMPLIED |
| 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | */ |
| 28 | |
| 29 | #include <debug.h> |
| 30 | #include <platform/iomap.h> |
| 31 | #include <reg.h> |
| 32 | #include <target.h> |
| 33 | #include <platform.h> |
| 34 | #include <uart_dm.h> |
| 35 | #include <mmc.h> |
| 36 | #include <platform/gpio.h> |
| 37 | #include <dev/keys.h> |
| 38 | #include <spmi_v2.h> |
| 39 | #include <pm8x41.h> |
P.V. Phani Kumar | a053a32 | 2015-08-13 18:36:05 +0530 | [diff] [blame] | 40 | #include <pm8x41_hw.h> |
Aparna Mallavarapu | 01fc00a | 2015-06-01 20:37:05 +0530 | [diff] [blame] | 41 | #include <board.h> |
| 42 | #include <baseband.h> |
| 43 | #include <hsusb.h> |
| 44 | #include <scm.h> |
Aparna Mallavarapu | 01fc00a | 2015-06-01 20:37:05 +0530 | [diff] [blame] | 45 | #include <platform/irqs.h> |
| 46 | #include <platform/clock.h> |
P.V. Phani Kumar | a053a32 | 2015-08-13 18:36:05 +0530 | [diff] [blame] | 47 | #include <platform/timer.h> |
Aparna Mallavarapu | 01fc00a | 2015-06-01 20:37:05 +0530 | [diff] [blame] | 48 | #include <crypto5_wrapper.h> |
| 49 | #include <partition_parser.h> |
| 50 | #include <stdlib.h> |
P.V. Phani Kumar | a053a32 | 2015-08-13 18:36:05 +0530 | [diff] [blame] | 51 | #include <rpm-smd.h> |
| 52 | #include <spmi.h> |
| 53 | #include <sdhci_msm.h> |
| 54 | #include <clock.h> |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 55 | #include <boot_device.h> |
| 56 | #include <secapp_loader.h> |
| 57 | #include <rpmb.h> |
| 58 | #include <smem.h> |
| 59 | #include <qmp_phy.h> |
| 60 | #include <qusb2_phy.h> |
Padmanabhan Komanduru | 0104a89 | 2016-01-22 16:58:10 +0530 | [diff] [blame] | 61 | #include "target/display.h" |
Sourabh Banerjee | 51695cc | 2018-02-27 09:40:30 +0530 | [diff] [blame] | 62 | #include "recovery.h" |
| 63 | #include <ab_partition_parser.h> |
Aparna Mallavarapu | 01fc00a | 2015-06-01 20:37:05 +0530 | [diff] [blame] | 64 | |
| 65 | #if LONG_PRESS_POWER_ON |
| 66 | #include <shutdown_detect.h> |
| 67 | #endif |
| 68 | |
c_wufeng | 41310ae | 2016-01-14 17:59:22 +0800 | [diff] [blame] | 69 | #if PON_VIB_SUPPORT |
| 70 | #include <vibrator.h> |
| 71 | #define VIBRATE_TIME 250 |
| 72 | #endif |
| 73 | |
Aparna Mallavarapu | 01fc00a | 2015-06-01 20:37:05 +0530 | [diff] [blame] | 74 | #define PMIC_ARB_CHANNEL_NUM 0 |
| 75 | #define PMIC_ARB_OWNER_ID 0 |
| 76 | #define TLMM_VOL_UP_BTN_GPIO 85 |
| 77 | |
Vamshi Krishna B V | 8275376 | 2018-03-13 18:49:43 +0530 | [diff] [blame] | 78 | #define PRI_PMIC_SLAVE_ID 0 |
| 79 | #define SEC_PMIC_SLAVE_ID 2 |
| 80 | |
Aparna Mallavarapu | 01fc00a | 2015-06-01 20:37:05 +0530 | [diff] [blame] | 81 | #define FASTBOOT_MODE 0x77665500 |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 82 | #define RECOVERY_MODE 0x77665502 |
Aparna Mallavarapu | 01fc00a | 2015-06-01 20:37:05 +0530 | [diff] [blame] | 83 | #define PON_SOFT_RB_SPARE 0x88F |
Sourabh Banerjee | 51695cc | 2018-02-27 09:40:30 +0530 | [diff] [blame] | 84 | |
| 85 | #if VERITY_LE |
| 86 | #define ROOTDEV_CMDLINE " root=/dev/dm-0 dm=\"system none ro,0 1 android-verity /dev/mmcblk0p" |
| 87 | #else |
| 88 | #define ROOTDEV_CMDLINE " root=/dev/mmcblk0p" |
| 89 | #endif |
| 90 | |
| 91 | #define RECOVERY_ROOTDEV_CMDLINE " root=/dev/mmcblk0p" |
| 92 | #define ROOTDEV_FSTYPE_CMDLINE (" rootfstype=ext4 ") |
Aparna Mallavarapu | 01fc00a | 2015-06-01 20:37:05 +0530 | [diff] [blame] | 93 | |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 94 | #define CE1_INSTANCE 1 |
| 95 | #define CE_EE 1 |
| 96 | #define CE_FIFO_SIZE 64 |
| 97 | #define CE_READ_PIPE 3 |
| 98 | #define CE_WRITE_PIPE 2 |
| 99 | #define CE_READ_PIPE_LOCK_GRP 0 |
| 100 | #define CE_WRITE_PIPE_LOCK_GRP 0 |
| 101 | #define CE_ARRAY_SIZE 20 |
| 102 | |
Vijay Kumar Pendoti | 7e9226c | 2016-09-21 20:49:21 +0530 | [diff] [blame] | 103 | #define SMBCHG_USB_RT_STS 0x21310 |
| 104 | #define USBIN_UV_RT_STS BIT(0) |
Umang Agrawal | abccfc9 | 2017-12-19 12:05:27 +0530 | [diff] [blame] | 105 | #define USBIN_UV_RT_STS_PMI632 BIT(2) |
Vijay Kumar Pendoti | 7e9226c | 2016-09-21 20:49:21 +0530 | [diff] [blame] | 106 | |
P.V. Phani Kumar | a053a32 | 2015-08-13 18:36:05 +0530 | [diff] [blame] | 107 | struct mmc_device *dev; |
| 108 | |
| 109 | static uint32_t mmc_pwrctl_base[] = |
Aparna Mallavarapu | 01fc00a | 2015-06-01 20:37:05 +0530 | [diff] [blame] | 110 | { MSM_SDC1_BASE, MSM_SDC2_BASE }; |
| 111 | |
P.V. Phani Kumar | a053a32 | 2015-08-13 18:36:05 +0530 | [diff] [blame] | 112 | static uint32_t mmc_sdhci_base[] = |
| 113 | { MSM_SDC1_SDHCI_BASE, MSM_SDC2_SDHCI_BASE }; |
| 114 | |
| 115 | static uint32_t mmc_sdc_pwrctl_irq[] = |
| 116 | { SDCC1_PWRCTL_IRQ, SDCC2_PWRCTL_IRQ }; |
Aparna Mallavarapu | 01fc00a | 2015-06-01 20:37:05 +0530 | [diff] [blame] | 117 | |
| 118 | void target_early_init(void) |
| 119 | { |
| 120 | #if WITH_DEBUG_UART |
P.V. Phani Kumar | 2e4eeae | 2015-12-31 16:52:54 +0530 | [diff] [blame] | 121 | uart_dm_init(1, 0, BLSP1_UART0_BASE); |
Aparna Mallavarapu | 01fc00a | 2015-06-01 20:37:05 +0530 | [diff] [blame] | 122 | #endif |
| 123 | } |
| 124 | |
anisha agarwal | ebc52bc | 2016-07-08 15:50:00 -0700 | [diff] [blame] | 125 | #if _APPEND_CMDLINE |
Sourabh Banerjee | 51695cc | 2018-02-27 09:40:30 +0530 | [diff] [blame] | 126 | /* |
| 127 | get_target_boot_params: appends bootparam as per following conditions: |
| 128 | |
| 129 | 1. Always appends "rootfstype=ext4", if it is emmc boot path. |
| 130 | |
| 131 | 2. Appends more bootparams only if multi-slot is not supported |
| 132 | 2.1 If booting into recovery: |
| 133 | rootfstype=ext4 root=/dev/mmcblk0p<NN> |
| 134 | where: root=/dev/mmcblk0p<NN> is block device to "recoveryfs" partition |
| 135 | |
| 136 | 2.2 If booting into normal boot path: |
| 137 | 2.2.1 If verity is enabled: |
| 138 | root=/dev/dm-0 dm=\"system none ro,0 1 android-verity /dev/mmcblk0p<NN> |
| 139 | where: root=/dev/mmcblk0p<NN> is block device to "system" partition |
| 140 | |
| 141 | 2.2.2 If verity is not enabled |
| 142 | rootfstype=ext4 root=/dev/mmcblk0p<NN> |
| 143 | where: root=/dev/mmcblk0p<NN> is block device to "system" partition |
| 144 | */ |
anisha agarwal | ebc52bc | 2016-07-08 15:50:00 -0700 | [diff] [blame] | 145 | int get_target_boot_params(const char *cmdline, const char *part, char **buf) |
| 146 | { |
| 147 | int system_ptn_index = -1; |
| 148 | uint32_t buflen; |
| 149 | int ret = -1; |
| 150 | |
| 151 | if (!cmdline || !part ) { |
| 152 | dprintf(CRITICAL, "WARN: Invalid input param\n"); |
| 153 | return -1; |
| 154 | } |
| 155 | |
| 156 | if (!strstr(cmdline, "root=/dev/ram")) /* This check is to handle kdev boot */ |
| 157 | { |
| 158 | if (target_is_emmc_boot()) { |
Sourabh Banerjee | 51695cc | 2018-02-27 09:40:30 +0530 | [diff] [blame] | 159 | /* |
| 160 | Calculate length for "rootfstype=ext4" |
| 161 | The "rootfstype=ext4" is appended to kernel commandline in all conditions |
| 162 | The conditions are subsequently documented. |
| 163 | */ |
| 164 | buflen = sizeof(ROOTDEV_FSTYPE_CMDLINE); |
| 165 | |
| 166 | /* |
| 167 | Append other bootparams to command line |
| 168 | only if multi-slot is not supported. |
| 169 | */ |
| 170 | if(!partition_multislot_is_supported()) { |
| 171 | /* |
| 172 | When booting into recovery append |
| 173 | block device number for "recoveryfs" |
| 174 | Eventual command line looks like: |
| 175 | ...rootfstype=ext4 root=/dev/mmcblk0p<NN>... |
| 176 | */ |
| 177 | if(boot_into_recovery == true) { |
| 178 | buflen += strlen(RECOVERY_ROOTDEV_CMDLINE) + sizeof(int) + 1; |
| 179 | } else { |
| 180 | /* |
| 181 | When booting normally append command line |
| 182 | with verity bootparam only if VERITY_LE is |
| 183 | defined. The command line is as follows: |
| 184 | ...root=/dev/dm-0 dm=\"system none ro,0 1 android-verity /dev/mmcblk0p<NN>... |
| 185 | OR |
| 186 | ...root=/dev/mmcblk0p<NN>... |
| 187 | */ |
| 188 | buflen += strlen(ROOTDEV_CMDLINE) + sizeof(int) + 1; |
| 189 | } |
| 190 | } |
| 191 | |
anisha agarwal | ebc52bc | 2016-07-08 15:50:00 -0700 | [diff] [blame] | 192 | *buf = (char *)malloc(buflen); |
| 193 | if(!(*buf)) { |
| 194 | dprintf(CRITICAL,"Unable to allocate memory for boot params\n"); |
| 195 | return -1; |
| 196 | } |
| 197 | /* Below is for emmc boot */ |
| 198 | system_ptn_index = partition_get_index(part) + 1; /* Adding +1 as offsets for eMMC start at 1 and NAND at 0 */ |
| 199 | if (system_ptn_index < 0) { |
| 200 | dprintf(CRITICAL, |
Sourabh Banerjee | 51695cc | 2018-02-27 09:40:30 +0530 | [diff] [blame] | 201 | "WARN: Cannot get partition index for %s\n", part); |
anisha agarwal | ebc52bc | 2016-07-08 15:50:00 -0700 | [diff] [blame] | 202 | free(*buf); |
| 203 | return -1; |
| 204 | } |
Sourabh Banerjee | 51695cc | 2018-02-27 09:40:30 +0530 | [diff] [blame] | 205 | |
| 206 | if(!partition_multislot_is_supported()) { |
| 207 | if(boot_into_recovery == true) { |
| 208 | snprintf(*buf, buflen, "%s %s%d", ROOTDEV_FSTYPE_CMDLINE, |
| 209 | RECOVERY_ROOTDEV_CMDLINE, system_ptn_index); |
| 210 | } else { |
| 211 | snprintf(*buf, buflen, "%s %s%d", ROOTDEV_FSTYPE_CMDLINE, |
| 212 | ROOTDEV_CMDLINE, system_ptn_index); |
| 213 | } |
| 214 | } |
| 215 | |
anisha agarwal | ebc52bc | 2016-07-08 15:50:00 -0700 | [diff] [blame] | 216 | ret = 0; |
| 217 | } |
| 218 | } |
| 219 | /*in success case buf will be freed in the calling function of this*/ |
| 220 | return ret; |
| 221 | } |
| 222 | #endif |
| 223 | |
P.V. Phani Kumar | a053a32 | 2015-08-13 18:36:05 +0530 | [diff] [blame] | 224 | static void set_sdc_power_ctrl() |
Aparna Mallavarapu | 01fc00a | 2015-06-01 20:37:05 +0530 | [diff] [blame] | 225 | { |
P.V. Phani Kumar | a053a32 | 2015-08-13 18:36:05 +0530 | [diff] [blame] | 226 | /* Drive strength configs for sdc pins */ |
| 227 | struct tlmm_cfgs sdc1_hdrv_cfg[] = |
| 228 | { |
| 229 | { SDC1_CLK_HDRV_CTL_OFF, TLMM_CUR_VAL_16MA, TLMM_HDRV_MASK, 0}, |
| 230 | { SDC1_CMD_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK, 0}, |
| 231 | { SDC1_DATA_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK , 0}, |
| 232 | }; |
| 233 | |
| 234 | /* Pull configs for sdc pins */ |
| 235 | struct tlmm_cfgs sdc1_pull_cfg[] = |
| 236 | { |
| 237 | { SDC1_CLK_PULL_CTL_OFF, TLMM_NO_PULL, TLMM_PULL_MASK, 0}, |
| 238 | { SDC1_CMD_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK, 0}, |
| 239 | { SDC1_DATA_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK, 0}, |
| 240 | }; |
| 241 | |
| 242 | struct tlmm_cfgs sdc1_rclk_cfg[] = |
| 243 | { |
| 244 | { SDC1_RCLK_PULL_CTL_OFF, TLMM_PULL_DOWN, TLMM_PULL_MASK, 0}, |
| 245 | }; |
| 246 | |
| 247 | /* Set the drive strength & pull control values */ |
| 248 | tlmm_set_hdrive_ctrl(sdc1_hdrv_cfg, ARRAY_SIZE(sdc1_hdrv_cfg)); |
| 249 | tlmm_set_pull_ctrl(sdc1_pull_cfg, ARRAY_SIZE(sdc1_pull_cfg)); |
| 250 | tlmm_set_pull_ctrl(sdc1_rclk_cfg, ARRAY_SIZE(sdc1_rclk_cfg)); |
| 251 | } |
| 252 | |
| 253 | void target_sdc_init() |
| 254 | { |
| 255 | struct mmc_config_data config; |
| 256 | |
| 257 | /* Set drive strength & pull ctrl values */ |
| 258 | set_sdc_power_ctrl(); |
| 259 | |
| 260 | config.slot = MMC_SLOT; |
| 261 | config.bus_width = DATA_BUS_WIDTH_8BIT; |
| 262 | config.max_clk_rate = MMC_CLK_192MHZ; |
| 263 | config.sdhc_base = mmc_sdhci_base[config.slot - 1]; |
| 264 | config.pwrctl_base = mmc_pwrctl_base[config.slot - 1]; |
| 265 | config.pwr_irq = mmc_sdc_pwrctl_irq[config.slot - 1]; |
| 266 | config.hs400_support = 1; |
| 267 | |
| 268 | if (!(dev = mmc_init(&config))) { |
| 269 | /* Try different config. values */ |
| 270 | config.max_clk_rate = MMC_CLK_200MHZ; |
| 271 | config.sdhc_base = mmc_sdhci_base[config.slot - 1]; |
| 272 | config.pwrctl_base = mmc_pwrctl_base[config.slot - 1]; |
| 273 | config.pwr_irq = mmc_sdc_pwrctl_irq[config.slot - 1]; |
| 274 | config.hs400_support = 0; |
| 275 | |
| 276 | if (!(dev = mmc_init(&config))) { |
| 277 | dprintf(CRITICAL, "mmc init failed!"); |
| 278 | ASSERT(0); |
| 279 | } |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | void *target_mmc_device() |
| 284 | { |
| 285 | return (void *) dev; |
Aparna Mallavarapu | 01fc00a | 2015-06-01 20:37:05 +0530 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | /* Return 1 if vol_up pressed */ |
Gaurav Nebhwani | d9dd034 | 2016-01-28 16:35:55 +0530 | [diff] [blame] | 289 | int target_volume_up() |
Aparna Mallavarapu | 01fc00a | 2015-06-01 20:37:05 +0530 | [diff] [blame] | 290 | { |
| 291 | uint8_t status = 0; |
| 292 | |
| 293 | gpio_tlmm_config(TLMM_VOL_UP_BTN_GPIO, 0, GPIO_INPUT, GPIO_PULL_UP, GPIO_2MA, GPIO_ENABLE); |
| 294 | |
| 295 | /* Wait for the gpio config to take effect - debounce time */ |
| 296 | thread_sleep(10); |
| 297 | |
| 298 | /* Get status of GPIO */ |
| 299 | status = gpio_status(TLMM_VOL_UP_BTN_GPIO); |
| 300 | |
| 301 | /* Active high signal. */ |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 302 | return !status; |
Aparna Mallavarapu | 01fc00a | 2015-06-01 20:37:05 +0530 | [diff] [blame] | 303 | } |
| 304 | |
| 305 | /* Return 1 if vol_down pressed */ |
| 306 | uint32_t target_volume_down() |
| 307 | { |
| 308 | /* Volume down button tied in with PMIC RESIN. */ |
| 309 | return pm8x41_resin_status(); |
| 310 | } |
| 311 | |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 312 | uint32_t target_is_pwrkey_pon_reason() |
| 313 | { |
Umang Agrawal | abccfc9 | 2017-12-19 12:05:27 +0530 | [diff] [blame] | 314 | uint32_t pmic = target_get_pmic(); |
| 315 | uint8_t pon_reason = 0; |
Umang Agrawal | abccfc9 | 2017-12-19 12:05:27 +0530 | [diff] [blame] | 316 | bool usb_present_sts = 1; |
| 317 | |
| 318 | if (pmic == PMIC_IS_PMI632) |
| 319 | { |
Umang Agrawal | 5f14ae4 | 2018-02-21 15:51:18 +0530 | [diff] [blame] | 320 | pon_reason = pmi632_get_pon_reason(); |
Umang Agrawal | abccfc9 | 2017-12-19 12:05:27 +0530 | [diff] [blame] | 321 | usb_present_sts = !(USBIN_UV_RT_STS_PMI632 & |
Vijay Kumar Pendoti | 7e9226c | 2016-09-21 20:49:21 +0530 | [diff] [blame] | 322 | pm8x41_reg_read(SMBCHG_USB_RT_STS)); |
Umang Agrawal | abccfc9 | 2017-12-19 12:05:27 +0530 | [diff] [blame] | 323 | } |
| 324 | else |
| 325 | { |
| 326 | pon_reason = pm8950_get_pon_reason(); |
Umang Agrawal | 5f14ae4 | 2018-02-21 15:51:18 +0530 | [diff] [blame] | 327 | usb_present_sts = !(USBIN_UV_RT_STS & |
Umang Agrawal | abccfc9 | 2017-12-19 12:05:27 +0530 | [diff] [blame] | 328 | pm8x41_reg_read(SMBCHG_USB_RT_STS)); |
| 329 | } |
| 330 | |
Umang Agrawal | 5f14ae4 | 2018-02-21 15:51:18 +0530 | [diff] [blame] | 331 | if (pm8x41_get_is_cold_boot() && ((pon_reason == KPDPWR_N) || |
Umang Agrawal | abccfc9 | 2017-12-19 12:05:27 +0530 | [diff] [blame] | 332 | (pon_reason == (KPDPWR_N|PON1)))) |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 333 | return 1; |
Vijay Kumar Pendoti | 7e9226c | 2016-09-21 20:49:21 +0530 | [diff] [blame] | 334 | else if ((pon_reason == PON1) && (!usb_present_sts)) |
| 335 | return 1; |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 336 | else |
| 337 | return 0; |
| 338 | } |
| 339 | |
Aparna Mallavarapu | 01fc00a | 2015-06-01 20:37:05 +0530 | [diff] [blame] | 340 | static void target_keystatus() |
| 341 | { |
| 342 | keys_init(); |
| 343 | |
| 344 | if(target_volume_down()) |
| 345 | keys_post_event(KEY_VOLUMEDOWN, 1); |
| 346 | |
| 347 | if(target_volume_up()) |
| 348 | keys_post_event(KEY_VOLUMEUP, 1); |
| 349 | } |
| 350 | |
Aparna Mallavarapu | 01fc00a | 2015-06-01 20:37:05 +0530 | [diff] [blame] | 351 | void target_init(void) |
| 352 | { |
Aparna Mallavarapu | 01fc00a | 2015-06-01 20:37:05 +0530 | [diff] [blame] | 353 | dprintf(INFO, "target_init()\n"); |
| 354 | |
| 355 | spmi_init(PMIC_ARB_CHANNEL_NUM, PMIC_ARB_OWNER_ID); |
| 356 | |
| 357 | target_keystatus(); |
| 358 | |
P.V. Phani Kumar | a053a32 | 2015-08-13 18:36:05 +0530 | [diff] [blame] | 359 | target_sdc_init(); |
| 360 | if (partition_read_table()) |
| 361 | { |
| 362 | dprintf(CRITICAL, "Error reading the partition table info\n"); |
| 363 | ASSERT(0); |
Aparna Mallavarapu | 01fc00a | 2015-06-01 20:37:05 +0530 | [diff] [blame] | 364 | } |
P.V. Phani Kumar | a053a32 | 2015-08-13 18:36:05 +0530 | [diff] [blame] | 365 | |
Aparna Mallavarapu | 01fc00a | 2015-06-01 20:37:05 +0530 | [diff] [blame] | 366 | #if LONG_PRESS_POWER_ON |
Umang Agrawal | abccfc9 | 2017-12-19 12:05:27 +0530 | [diff] [blame] | 367 | if (target_is_pmi_enabled()) |
| 368 | shutdown_detect(); |
Aparna Mallavarapu | 01fc00a | 2015-06-01 20:37:05 +0530 | [diff] [blame] | 369 | #endif |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 370 | |
c_wufeng | 41310ae | 2016-01-14 17:59:22 +0800 | [diff] [blame] | 371 | #if PON_VIB_SUPPORT |
Umang Agrawal | abccfc9 | 2017-12-19 12:05:27 +0530 | [diff] [blame] | 372 | if (target_is_pmi_enabled()) |
| 373 | vib_timed_turn_on(VIBRATE_TIME); |
c_wufeng | 41310ae | 2016-01-14 17:59:22 +0800 | [diff] [blame] | 374 | #endif |
| 375 | |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 376 | |
| 377 | if (target_use_signed_kernel()) |
| 378 | target_crypto_init_params(); |
| 379 | |
Mayank Grover | 8b2f19a | 2017-10-26 12:12:17 +0530 | [diff] [blame] | 380 | if (VB_M <= target_get_vb_version()) |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 381 | { |
Mayank Grover | 6878e01 | 2017-09-06 11:04:03 +0530 | [diff] [blame] | 382 | clock_ce_enable(CE1_INSTANCE); |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 383 | |
Mayank Grover | 6878e01 | 2017-09-06 11:04:03 +0530 | [diff] [blame] | 384 | /* Initialize Qseecom */ |
| 385 | if (qseecom_init() < 0) |
| 386 | { |
| 387 | dprintf(CRITICAL, "Failed to initialize qseecom\n"); |
| 388 | ASSERT(0); |
| 389 | } |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 390 | |
Mayank Grover | 6878e01 | 2017-09-06 11:04:03 +0530 | [diff] [blame] | 391 | /* Start Qseecom */ |
| 392 | if (qseecom_tz_init() < 0) |
| 393 | { |
| 394 | dprintf(CRITICAL, "Failed to start qseecom\n"); |
| 395 | ASSERT(0); |
| 396 | } |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 397 | |
Mayank Grover | 6878e01 | 2017-09-06 11:04:03 +0530 | [diff] [blame] | 398 | if (rpmb_init() < 0) |
| 399 | { |
| 400 | dprintf(CRITICAL, "RPMB init failed\n"); |
| 401 | ASSERT(0); |
| 402 | } |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 403 | |
Mayank Grover | 6878e01 | 2017-09-06 11:04:03 +0530 | [diff] [blame] | 404 | /* |
| 405 | * Load the sec app for first time |
| 406 | */ |
| 407 | if (load_sec_app() < 0) |
| 408 | { |
| 409 | dprintf(CRITICAL, "Failed to load App for verified\n"); |
| 410 | ASSERT(0); |
| 411 | } |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 412 | } |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 413 | |
| 414 | #if SMD_SUPPORT |
| 415 | rpm_smd_init(); |
| 416 | #endif |
Aparna Mallavarapu | 01fc00a | 2015-06-01 20:37:05 +0530 | [diff] [blame] | 417 | } |
| 418 | |
| 419 | void target_serialno(unsigned char *buf) |
| 420 | { |
| 421 | uint32_t serialno; |
| 422 | if (target_is_emmc_boot()) { |
| 423 | serialno = mmc_get_psn(); |
| 424 | snprintf((char *)buf, 13, "%x", serialno); |
| 425 | } |
| 426 | } |
| 427 | |
| 428 | unsigned board_machtype(void) |
| 429 | { |
P.V. Phani Kumar | a053a32 | 2015-08-13 18:36:05 +0530 | [diff] [blame] | 430 | return LINUX_MACHTYPE_UNKNOWN; |
| 431 | } |
| 432 | |
| 433 | /* Detect the target type */ |
| 434 | void target_detect(struct board_data *board) |
| 435 | { |
| 436 | /* This is already filled as part of board.c */ |
| 437 | } |
| 438 | |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 439 | /* Detect the modem type */ |
P.V. Phani Kumar | a053a32 | 2015-08-13 18:36:05 +0530 | [diff] [blame] | 440 | void target_baseband_detect(struct board_data *board) |
| 441 | { |
| 442 | uint32_t platform; |
| 443 | |
| 444 | platform = board->platform; |
| 445 | |
| 446 | switch(platform) { |
Gaurav Nebhwani | 6c945a4 | 2016-02-16 17:26:51 +0530 | [diff] [blame] | 447 | case MSM8953: |
Mayank Grover | 759e0b0 | 2017-04-11 11:59:06 +0530 | [diff] [blame] | 448 | case SDM450: |
lijuang | 2f1c1f5 | 2017-12-12 14:44:32 +0800 | [diff] [blame] | 449 | case SDM632: |
P.V. Phani Kumar | a053a32 | 2015-08-13 18:36:05 +0530 | [diff] [blame] | 450 | board->baseband = BASEBAND_MSM; |
| 451 | break; |
Gaurav Nebhwani | 6c945a4 | 2016-02-16 17:26:51 +0530 | [diff] [blame] | 452 | case APQ8053: |
Mayank Grover | 3dc285c | 2017-12-26 12:47:09 +0530 | [diff] [blame] | 453 | case SDA450: |
lijuang | 2f1c1f5 | 2017-12-12 14:44:32 +0800 | [diff] [blame] | 454 | case SDA632: |
Gaurav Nebhwani | 22a0d9f | 2015-12-29 13:49:26 +0530 | [diff] [blame] | 455 | board->baseband = BASEBAND_APQ; |
| 456 | break; |
P.V. Phani Kumar | a053a32 | 2015-08-13 18:36:05 +0530 | [diff] [blame] | 457 | default: |
| 458 | dprintf(CRITICAL, "Platform type: %u is not supported\n",platform); |
| 459 | ASSERT(0); |
| 460 | }; |
Aparna Mallavarapu | 01fc00a | 2015-06-01 20:37:05 +0530 | [diff] [blame] | 461 | } |
| 462 | |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 463 | unsigned target_baseband() |
| 464 | { |
| 465 | return board_baseband(); |
| 466 | } |
lijuang | 395b5e6 | 2015-11-19 17:39:44 +0800 | [diff] [blame] | 467 | |
| 468 | int set_download_mode(enum reboot_reason mode) |
Aparna Mallavarapu | 01fc00a | 2015-06-01 20:37:05 +0530 | [diff] [blame] | 469 | { |
| 470 | int ret = 0; |
| 471 | ret = scm_dload_mode(mode); |
| 472 | |
| 473 | pm8x41_clear_pmic_watchdog(); |
| 474 | |
| 475 | return ret; |
| 476 | } |
| 477 | |
| 478 | int emmc_recovery_init(void) |
| 479 | { |
| 480 | return _emmc_recovery_init(); |
| 481 | } |
| 482 | |
| 483 | unsigned target_pause_for_battery_charge(void) |
| 484 | { |
Umang Agrawal | abccfc9 | 2017-12-19 12:05:27 +0530 | [diff] [blame] | 485 | uint32_t pmic = target_get_pmic(); |
Umang Agrawal | 5f14ae4 | 2018-02-21 15:51:18 +0530 | [diff] [blame] | 486 | uint8_t pon_reason = pm8x41_get_pon_reason(); |
| 487 | uint8_t is_cold_boot = pm8x41_get_is_cold_boot(); |
Umang Agrawal | abccfc9 | 2017-12-19 12:05:27 +0530 | [diff] [blame] | 488 | bool usb_present_sts = 1; |
| 489 | |
Umang Agrawal | 5f14ae4 | 2018-02-21 15:51:18 +0530 | [diff] [blame] | 490 | if (target_is_pmi_enabled()) |
Umang Agrawal | abccfc9 | 2017-12-19 12:05:27 +0530 | [diff] [blame] | 491 | { |
Umang Agrawal | 5f14ae4 | 2018-02-21 15:51:18 +0530 | [diff] [blame] | 492 | if (pmic == PMIC_IS_PMI632) |
| 493 | usb_present_sts = !(USBIN_UV_RT_STS_PMI632 & |
Zhenhua Huang | cf812d7 | 2016-01-27 17:27:47 +0800 | [diff] [blame] | 494 | pm8x41_reg_read(SMBCHG_USB_RT_STS)); |
Umang Agrawal | 5f14ae4 | 2018-02-21 15:51:18 +0530 | [diff] [blame] | 495 | else |
Umang Agrawal | abccfc9 | 2017-12-19 12:05:27 +0530 | [diff] [blame] | 496 | usb_present_sts = !(USBIN_UV_RT_STS & |
| 497 | pm8x41_reg_read(SMBCHG_USB_RT_STS)); |
| 498 | } |
| 499 | |
Zhenhua Huang | cf812d7 | 2016-01-27 17:27:47 +0800 | [diff] [blame] | 500 | dprintf(INFO, "%s : pon_reason is:0x%x cold_boot:%d usb_sts:%d\n", __func__, |
| 501 | pon_reason, is_cold_boot, usb_present_sts); |
Aparna Mallavarapu | 01fc00a | 2015-06-01 20:37:05 +0530 | [diff] [blame] | 502 | /* In case of fastboot reboot,adb reboot or if we see the power key |
| 503 | * pressed we do not want go into charger mode. |
| 504 | * fastboot reboot is warm boot with PON hard reset bit not set |
| 505 | * adb reboot is a cold boot with PON hard reset bit set |
| 506 | */ |
| 507 | if (is_cold_boot && |
| 508 | (!(pon_reason & HARD_RST)) && |
| 509 | (!(pon_reason & KPDPWR_N)) && |
Zhenhua Huang | cf812d7 | 2016-01-27 17:27:47 +0800 | [diff] [blame] | 510 | usb_present_sts) |
Aparna Mallavarapu | 01fc00a | 2015-06-01 20:37:05 +0530 | [diff] [blame] | 511 | return 1; |
| 512 | else |
| 513 | return 0; |
| 514 | } |
| 515 | |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 516 | void target_uninit(void) |
| 517 | { |
Mayank Grover | 92e5597 | 2018-03-23 17:58:16 +0530 | [diff] [blame] | 518 | #if PON_VIB_SUPPORT |
| 519 | if(target_is_pmi_enabled()) |
| 520 | turn_off_vib_early(); |
| 521 | #endif |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 522 | mmc_put_card_to_sleep(dev); |
| 523 | sdhci_mode_disable(&dev->host); |
| 524 | if (crypto_initialized()) |
| 525 | crypto_eng_cleanup(); |
| 526 | |
| 527 | if (target_is_ssd_enabled()) |
| 528 | clock_ce_disable(CE1_INSTANCE); |
| 529 | |
Mayank Grover | 8b2f19a | 2017-10-26 12:12:17 +0530 | [diff] [blame] | 530 | if (VB_M <= target_get_vb_version()) |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 531 | { |
Mayank Grover | 6878e01 | 2017-09-06 11:04:03 +0530 | [diff] [blame] | 532 | if (is_sec_app_loaded()) |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 533 | { |
Mayank Grover | 6878e01 | 2017-09-06 11:04:03 +0530 | [diff] [blame] | 534 | if (send_milestone_call_to_tz() < 0) |
| 535 | { |
| 536 | dprintf(CRITICAL, "Failed to unload App for rpmb\n"); |
| 537 | ASSERT(0); |
| 538 | } |
| 539 | } |
| 540 | |
| 541 | if (rpmb_uninit() < 0) |
| 542 | { |
| 543 | dprintf(CRITICAL, "RPMB uninit failed\n"); |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 544 | ASSERT(0); |
| 545 | } |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 546 | |
Mayank Grover | 6878e01 | 2017-09-06 11:04:03 +0530 | [diff] [blame] | 547 | clock_ce_disable(CE1_INSTANCE); |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 548 | } |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 549 | |
| 550 | #if SMD_SUPPORT |
| 551 | rpm_smd_uninit(); |
| 552 | #endif |
| 553 | } |
| 554 | |
Aparna Mallavarapu | 01fc00a | 2015-06-01 20:37:05 +0530 | [diff] [blame] | 555 | /* UTMI MUX configuration to connect PHY to SNPS controller: |
| 556 | * Configure primary HS phy mux to use UTMI interface |
| 557 | * (connected to usb30 controller). |
| 558 | */ |
| 559 | static void tcsr_hs_phy_mux_configure(void) |
| 560 | { |
| 561 | uint32_t reg; |
| 562 | |
| 563 | reg = readl(USB2_PHY_SEL); |
| 564 | |
| 565 | writel(reg | 0x1, USB2_PHY_SEL); |
| 566 | } |
| 567 | |
| 568 | /* configure hs phy mux if using dwc controller */ |
| 569 | void target_usb_phy_mux_configure(void) |
| 570 | { |
| 571 | if(!strcmp(target_usb_controller(), "dwc")) |
| 572 | { |
| 573 | tcsr_hs_phy_mux_configure(); |
| 574 | } |
| 575 | } |
| 576 | |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 577 | void target_usb_phy_reset() |
| 578 | { |
| 579 | |
| 580 | usb30_qmp_phy_reset(); |
| 581 | qusb2_phy_reset(); |
| 582 | } |
| 583 | |
Aparna Mallavarapu | 01fc00a | 2015-06-01 20:37:05 +0530 | [diff] [blame] | 584 | /* Initialize target specific USB handlers */ |
| 585 | target_usb_iface_t* target_usb30_init() |
| 586 | { |
| 587 | target_usb_iface_t *t_usb_iface; |
| 588 | |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 589 | t_usb_iface = (target_usb_iface_t *) calloc(1, sizeof(target_usb_iface_t)); |
Aparna Mallavarapu | 01fc00a | 2015-06-01 20:37:05 +0530 | [diff] [blame] | 590 | ASSERT(t_usb_iface); |
| 591 | |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 592 | t_usb_iface->mux_config = NULL; |
| 593 | t_usb_iface->phy_init = usb30_qmp_phy_init; |
| 594 | t_usb_iface->phy_reset = target_usb_phy_reset; |
| 595 | t_usb_iface->clock_init = clock_usb30_init; |
| 596 | t_usb_iface->vbus_override = 1; |
Aparna Mallavarapu | 01fc00a | 2015-06-01 20:37:05 +0530 | [diff] [blame] | 597 | |
| 598 | return t_usb_iface; |
| 599 | } |
| 600 | |
| 601 | /* identify the usb controller to be used for the target */ |
| 602 | const char * target_usb_controller() |
| 603 | { |
| 604 | return "dwc"; |
| 605 | } |
P.V. Phani Kumar | a053a32 | 2015-08-13 18:36:05 +0530 | [diff] [blame] | 606 | |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 607 | /* Do any target specific intialization needed before entering fastboot mode */ |
| 608 | void target_fastboot_init(void) |
| 609 | { |
| 610 | if (target_is_ssd_enabled()) { |
| 611 | clock_ce_enable(CE1_INSTANCE); |
| 612 | target_load_ssd_keystore(); |
| 613 | } |
| 614 | } |
| 615 | |
| 616 | void target_load_ssd_keystore(void) |
| 617 | { |
| 618 | uint64_t ptn; |
| 619 | int index; |
| 620 | uint64_t size; |
| 621 | uint32_t *buffer = NULL; |
| 622 | |
| 623 | if (!target_is_ssd_enabled()) |
| 624 | return; |
| 625 | |
| 626 | index = partition_get_index("ssd"); |
| 627 | |
| 628 | ptn = partition_get_offset(index); |
| 629 | if (ptn == 0){ |
| 630 | dprintf(CRITICAL, "Error: ssd partition not found\n"); |
| 631 | return; |
| 632 | } |
| 633 | |
| 634 | size = partition_get_size(index); |
| 635 | if (size == 0) { |
| 636 | dprintf(CRITICAL, "Error: invalid ssd partition size\n"); |
| 637 | return; |
| 638 | } |
| 639 | |
| 640 | buffer = memalign(CACHE_LINE, ROUNDUP(size, CACHE_LINE)); |
| 641 | if (!buffer) { |
| 642 | dprintf(CRITICAL, "Error: allocating memory for ssd buffer\n"); |
| 643 | return; |
| 644 | } |
| 645 | |
| 646 | if (mmc_read(ptn, buffer, size)) { |
| 647 | dprintf(CRITICAL, "Error: cannot read data\n"); |
| 648 | free(buffer); |
| 649 | return; |
| 650 | } |
| 651 | |
| 652 | clock_ce_enable(CE1_INSTANCE); |
| 653 | scm_protect_keystore(buffer, size); |
| 654 | clock_ce_disable(CE1_INSTANCE); |
| 655 | free(buffer); |
| 656 | } |
P.V. Phani Kumar | a053a32 | 2015-08-13 18:36:05 +0530 | [diff] [blame] | 657 | |
| 658 | crypto_engine_type board_ce_type(void) |
| 659 | { |
| 660 | return CRYPTO_ENGINE_TYPE_HW; |
| 661 | } |
| 662 | |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 663 | /* Set up params for h/w CE. */ |
| 664 | void target_crypto_init_params() |
| 665 | { |
| 666 | struct crypto_init_params ce_params; |
| 667 | |
| 668 | /* Set up base addresses and instance. */ |
| 669 | ce_params.crypto_instance = CE1_INSTANCE; |
| 670 | ce_params.crypto_base = MSM_CE1_BASE; |
| 671 | ce_params.bam_base = MSM_CE1_BAM_BASE; |
| 672 | |
| 673 | /* Set up BAM config. */ |
| 674 | ce_params.bam_ee = CE_EE; |
| 675 | ce_params.pipes.read_pipe = CE_READ_PIPE; |
| 676 | ce_params.pipes.write_pipe = CE_WRITE_PIPE; |
| 677 | ce_params.pipes.read_pipe_grp = CE_READ_PIPE_LOCK_GRP; |
| 678 | ce_params.pipes.write_pipe_grp = CE_WRITE_PIPE_LOCK_GRP; |
| 679 | |
| 680 | /* Assign buffer sizes. */ |
| 681 | ce_params.num_ce = CE_ARRAY_SIZE; |
| 682 | ce_params.read_fifo_size = CE_FIFO_SIZE; |
| 683 | ce_params.write_fifo_size = CE_FIFO_SIZE; |
| 684 | |
| 685 | /* BAM is initialized by TZ for this platform. |
| 686 | * Do not do it again as the initialization address space |
| 687 | * is locked. |
| 688 | */ |
| 689 | ce_params.do_bam_init = 0; |
| 690 | |
| 691 | crypto_init_params(&ce_params); |
| 692 | } |
P.V. Phani Kumar | a053a32 | 2015-08-13 18:36:05 +0530 | [diff] [blame] | 693 | |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 694 | uint32_t target_get_pmic() |
| 695 | { |
Umang Agrawal | abccfc9 | 2017-12-19 12:05:27 +0530 | [diff] [blame] | 696 | if (target_is_pmi_enabled()) { |
Umang Agrawal | 3ee3f6f | 2018-04-17 18:54:50 +0530 | [diff] [blame] | 697 | uint32_t pmi_type = board_pmic_target(1) & PMIC_TYPE_MASK; |
Umang Agrawal | abccfc9 | 2017-12-19 12:05:27 +0530 | [diff] [blame] | 698 | if (pmi_type == PMIC_IS_PMI632) |
| 699 | return PMIC_IS_PMI632; |
| 700 | else |
| 701 | return PMIC_IS_PMI8950; |
| 702 | } |
| 703 | else { |
| 704 | return PMIC_IS_UNKNOWN; |
| 705 | } |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 706 | } |
| 707 | |
Umang Agrawal | 89f6dcb | 2018-01-03 19:07:47 +0530 | [diff] [blame] | 708 | void pmic_reset_configure(uint8_t reset_type) |
| 709 | { |
| 710 | uint32_t pmi_type; |
Vamshi Krishna B V | 8275376 | 2018-03-13 18:49:43 +0530 | [diff] [blame] | 711 | uint8_t sec_reset_type = reset_type; |
Umang Agrawal | 89f6dcb | 2018-01-03 19:07:47 +0530 | [diff] [blame] | 712 | |
| 713 | pmi_type = target_get_pmic(); |
| 714 | if (pmi_type == PMIC_IS_PMI632) |
Vamshi Krishna B V | 8275376 | 2018-03-13 18:49:43 +0530 | [diff] [blame] | 715 | { |
Umang Agrawal | 89f6dcb | 2018-01-03 19:07:47 +0530 | [diff] [blame] | 716 | pmi632_reset_configure(reset_type); |
Vamshi Krishna B V | 8275376 | 2018-03-13 18:49:43 +0530 | [diff] [blame] | 717 | } |
Umang Agrawal | 89f6dcb | 2018-01-03 19:07:47 +0530 | [diff] [blame] | 718 | else |
Vamshi Krishna B V | 8275376 | 2018-03-13 18:49:43 +0530 | [diff] [blame] | 719 | { |
| 720 | if (reset_type == PON_PSHOLD_HARD_RESET) |
| 721 | sec_reset_type = PON_PSHOLD_SHUTDOWN; |
| 722 | |
| 723 | pm8996_reset_configure(PRI_PMIC_SLAVE_ID, reset_type); |
| 724 | pm8996_reset_configure(SEC_PMIC_SLAVE_ID, sec_reset_type); |
| 725 | } |
Umang Agrawal | 89f6dcb | 2018-01-03 19:07:47 +0530 | [diff] [blame] | 726 | } |
| 727 | |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 728 | struct qmp_reg qmp_settings[] = |
| 729 | { |
Mayank Grover | e55fe62 | 2016-10-13 18:39:05 +0530 | [diff] [blame] | 730 | {0x804, 0x01}, /* USB3PHY_PCIE_USB3_PCS_POWER_DOWN_CONTROL */ |
| 731 | |
| 732 | /* Common block settings */ |
| 733 | {0xAC, 0x14}, /* QSERDES_COM_SYSCLK_EN_SEL */ |
| 734 | {0x34, 0x08}, /* QSERDES_COM_BIAS_EN_CLKBUFLR_EN */ |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 735 | {0x174, 0x30}, /* QSERDES_COM_CLK_SELECT */ |
Mayank Grover | e55fe62 | 2016-10-13 18:39:05 +0530 | [diff] [blame] | 736 | {0x70, 0x0F}, /* USB3PHY_QSERDES_COM_BG_TRIM */ |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 737 | {0x19c, 0x01}, /* QSERDES_COM_SVS_MODE_CLK_SEL */ |
| 738 | {0x178, 0x00}, /* QSERDES_COM_HSCLK_SEL */ |
Mayank Grover | e55fe62 | 2016-10-13 18:39:05 +0530 | [diff] [blame] | 739 | {0x194, 0x06}, /* QSERDES_COM_CMN_CONFIG */ |
| 740 | {0x48, 0x0F}, /* USB3PHY_QSERDES_COM_PLL_IVCO */ |
| 741 | {0x3C, 0x02}, /* QSERDES_COM_SYS_CLK_CTRL */ |
| 742 | |
| 743 | /* PLL & Loop filter settings */ |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 744 | {0xd0, 0x82}, /* QSERDES_COM_DEC_START_MODE0 */ |
| 745 | {0xdc, 0x55}, /* QSERDES_COM_DIV_FRAC_START1_MODE0 */ |
| 746 | {0xe0, 0x55}, /* QSERDES_COM_DIV_FRAC_START2_MODE0 */ |
| 747 | {0xe4, 0x03}, /* QSERDES_COM_DIV_FRAC_START3_MODE0 */ |
| 748 | {0x78, 0x0b}, /* QSERDES_COM_CP_CTRL_MODE0 */ |
| 749 | {0x84, 0x16}, /* QSERDES_COM_PLL_RCTRL_MODE0 */ |
| 750 | {0x90, 0x28}, /* QSERDES_COM_PLL_CCTRL_MODE0 */ |
| 751 | {0x108, 0x80}, /* QSERDES_COM_INTEGLOOP_GAIN0_MODE0 */ |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 752 | {0x4c, 0x15}, /* QSERDES_COM_LOCK_CMP1_MODE0 */ |
| 753 | {0x50, 0x34}, /* QSERDES_COM_LOCK_CMP2_MODE0 */ |
| 754 | {0x54, 0x00}, /* QSERDES_COM_LOCK_CMP3_MODE0 */ |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 755 | {0x18c, 0x00}, /* QSERDES_COM_CORE_CLK_EN */ |
| 756 | {0xcc, 0x00}, /* QSERDES_COM_LOCK_CMP_CFG */ |
| 757 | {0x128, 0x00}, /* QSERDES_COM_VCO_TUNE_MAP */ |
| 758 | {0x0C, 0x0A}, /* QSERDES_COM_BG_TIMER */ |
Mayank Grover | e55fe62 | 2016-10-13 18:39:05 +0530 | [diff] [blame] | 759 | |
| 760 | /* SSC Settings */ |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 761 | {0x10, 0x01}, /* QSERDES_COM_SSC_EN_CENTER */ |
| 762 | {0x1c, 0x31}, /* QSERDES_COM_SSC_PER1 */ |
| 763 | {0x20, 0x01}, /* QSERDES_COM_SSC_PER2 */ |
| 764 | {0x14, 0x00}, /* QSERDES_COM_SSC_ADJ_PER1 */ |
| 765 | {0x18, 0x00}, /* QSERDES_COM_SSC_ADJ_PER2 */ |
| 766 | {0x24, 0xde}, /* QSERDES_COM_SSC_STEP_SIZE1 */ |
| 767 | {0x28, 0x07}, /* QSERDES_COM_SSC_STEP_SIZE2 */ |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 768 | |
| 769 | /* Rx Settings */ |
Mayank Grover | e55fe62 | 2016-10-13 18:39:05 +0530 | [diff] [blame] | 770 | {0x41C, 0x06}, /* QSERDES_RX_UCDR_SO_GAIN */ |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 771 | {0x4d8, 0x02}, /* QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2 */ |
Mayank Grover | e55fe62 | 2016-10-13 18:39:05 +0530 | [diff] [blame] | 772 | {0x4dc, 0x4c}, /* QSERDES_RX_RX_EQU_ADAPTOR_CNTRL3 */ |
| 773 | {0x4e0, 0xb8}, /* QSERDES_RX_RX_EQU_ADAPTOR_CNTRL4 */ |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 774 | {0x508, 0x77}, /* QSERDES_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1 */ |
| 775 | {0x50c, 0x80}, /* QSERDES_RX_RX_OFFSET_ADAPTOR_CNTRL2 */ |
| 776 | {0x514, 0x03}, /* QSERDES_RX_SIGDET_CNTRL */ |
| 777 | {0x51c, 0x16}, /* QSERDES_RX_SIGDET_DEGLITCH_CNTRL */ |
Mayank Grover | e55fe62 | 2016-10-13 18:39:05 +0530 | [diff] [blame] | 778 | {0x510, 0x0C}, /* QSERDES_RX_SIGDET_ENABLES */ |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 779 | |
| 780 | /* Tx settings */ |
| 781 | {0x268, 0x45}, /* QSERDES_TX_HIGHZ_TRANSCEIVEREN_BIAS_DRVR_EN */ |
| 782 | {0x2ac, 0x12}, /* QSERDES_TX_RCV_DETECT_LVL_2 */ |
| 783 | {0x294, 0x06}, /* QSERDES_TX_LANE_MODE */ |
Mayank Grover | e55fe62 | 2016-10-13 18:39:05 +0530 | [diff] [blame] | 784 | {0x824, 0x15}, /* PCIE_USB3_PCS_TXDEEMPH_M6DB_V0 */ |
| 785 | {0x828, 0x0E}, /* PCIE_USB3_PCS_TXDEEMPH_M3P5DB_V0 */ |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 786 | |
| 787 | /* FLL settings */ |
| 788 | {0x8c8, 0x83}, /* PCIE_USB3_PCS_FLL_CNTRL2 */ |
| 789 | {0x8c4, 0x02}, /* PCIE_USB3_PCS_FLL_CNTRL1 */ |
| 790 | {0x8cc, 0x09}, /* PCIE_USB3_PCS_FLL_CNT_VAL_L */ |
| 791 | {0x8D0, 0xA2}, /* PCIE_USB3_PCS_FLL_CNT_VAL_H_TOL */ |
| 792 | {0x8D4, 0x85}, /* PCIE_USB3_PCS_FLL_MAN_CODE */ |
| 793 | |
| 794 | /* PCS Settings */ |
| 795 | {0x880, 0xD1}, /* PCIE_USB3_PCS_LOCK_DETECT_CONFIG1 */ |
| 796 | {0x884, 0x1F}, /* PCIE_USB3_PCS_LOCK_DETECT_CONFIG2 */ |
| 797 | {0x888, 0x47}, /* PCIE_USB3_PCS_LOCK_DETECT_CONFIG3 */ |
Mayank Grover | e55fe62 | 2016-10-13 18:39:05 +0530 | [diff] [blame] | 798 | {0x864, 0x1B}, /* PCIE_USB3_PCS_POWER_STATE_CONFIG2 */ |
P.V. Phani Kumar | 77826d3 | 2015-12-26 20:56:35 +0530 | [diff] [blame] | 799 | {0x8B8, 0x75}, /* PCIE_USB3_PCS_RXEQTRAINING_WAIT_TIME */ |
| 800 | {0x8BC, 0x13}, /* PCIE_USB3_PCS_RXEQTRAINING_RUN_TIME */ |
| 801 | {0x8B0, 0x86}, /* PCIE_USB3_PCS_LFPS_TX_ECSTART_EQTLOCK */ |
| 802 | {0x8A0, 0x04}, /* PCIE_USB3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK */ |
| 803 | {0x88C, 0x44}, /* PCIE_USB3_PCS_TSYNC_RSYNC_TIME */ |
| 804 | {0x870, 0xE7}, /* PCIE_USB3_PCS_RCVR_DTCT_DLY_P1U2_L */ |
| 805 | {0x874, 0x03}, /* PCIE_USB3_PCS_RCVR_DTCT_DLY_P1U2_H */ |
| 806 | {0x878, 0x40}, /* PCIE_USB3_PCS_RCVR_DTCT_DLY_U3_L */ |
| 807 | {0x87c, 0x00}, /* PCIE_USB3_PCS_RCVR_DTCT_DLY_U3_H */ |
| 808 | {0x9D8, 0x88}, /* PCIE_USB3_PCS_RX_SIGDET_LVL */ |
| 809 | {0x808, 0x03}, /* PCIE_USB3_PCS_START_CONTROL */ |
| 810 | {0x800, 0x00}, /* PCIE_USB3_PCS_SW_RESET */ |
| 811 | }; |
| 812 | |
| 813 | struct qmp_reg *target_get_qmp_settings() |
| 814 | { |
| 815 | return qmp_settings; |
| 816 | } |
| 817 | |
| 818 | int target_get_qmp_regsize() |
| 819 | { |
| 820 | return ARRAY_SIZE(qmp_settings); |
| 821 | } |
Padmanabhan Komanduru | 0104a89 | 2016-01-22 16:58:10 +0530 | [diff] [blame] | 822 | static uint8_t splash_override; |
| 823 | /* Returns 1 if target supports continuous splash screen. */ |
| 824 | int target_cont_splash_screen() |
| 825 | { |
| 826 | uint8_t splash_screen = 0; |
| 827 | if (!splash_override) { |
| 828 | switch (board_hardware_id()) { |
| 829 | case HW_PLATFORM_MTP: |
| 830 | case HW_PLATFORM_SURF: |
| 831 | case HW_PLATFORM_RCM: |
| 832 | case HW_PLATFORM_QRD: |
| 833 | splash_screen = 1; |
| 834 | break; |
| 835 | default: |
| 836 | splash_screen = 0; |
| 837 | break; |
| 838 | } |
| 839 | dprintf(SPEW, "Target_cont_splash=%d\n", splash_screen); |
| 840 | } |
| 841 | return splash_screen; |
| 842 | } |
| 843 | |
| 844 | void target_force_cont_splash_disable(uint8_t override) |
| 845 | { |
| 846 | splash_override = override; |
| 847 | } |