Umang Agrawal | 898a191 | 2018-02-13 16:09:10 +0530 | [diff] [blame] | 1 | /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +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> |
Aparna Mallavarapu | bc6315e | 2015-04-11 04:00:43 +0530 | [diff] [blame] | 40 | #include <pm8x41_hw.h> |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +0530 | [diff] [blame] | 41 | #include <board.h> |
| 42 | #include <baseband.h> |
| 43 | #include <hsusb.h> |
| 44 | #include <scm.h> |
| 45 | #include <platform/gpio.h> |
| 46 | #include <platform/gpio.h> |
| 47 | #include <platform/irqs.h> |
| 48 | #include <platform/clock.h> |
Aparna Mallavarapu | bc6315e | 2015-04-11 04:00:43 +0530 | [diff] [blame] | 49 | #include <platform/timer.h> |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +0530 | [diff] [blame] | 50 | #include <crypto5_wrapper.h> |
| 51 | #include <partition_parser.h> |
| 52 | #include <stdlib.h> |
Aparna Mallavarapu | fa5f8a7 | 2015-03-31 06:21:36 +0530 | [diff] [blame] | 53 | #include <rpm-smd.h> |
Aparna Mallavarapu | bc6315e | 2015-04-11 04:00:43 +0530 | [diff] [blame] | 54 | #include <spmi.h> |
| 55 | #include <sdhci_msm.h> |
| 56 | #include <clock.h> |
Parth Dixit | 6e6bad5 | 2015-07-30 19:02:38 +0530 | [diff] [blame] | 57 | #include <boot_device.h> |
| 58 | #include <secapp_loader.h> |
| 59 | #include <rpmb.h> |
lijuang | 3606df8 | 2015-09-02 21:14:43 +0800 | [diff] [blame] | 60 | #include <smem.h> |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +0530 | [diff] [blame] | 61 | |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 62 | #include "target/display.h" |
| 63 | |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +0530 | [diff] [blame] | 64 | #if LONG_PRESS_POWER_ON |
| 65 | #include <shutdown_detect.h> |
| 66 | #endif |
| 67 | |
Matthew Qin | 47dfdb7 | 2015-06-10 21:29:11 +0800 | [diff] [blame] | 68 | #if PON_VIB_SUPPORT |
| 69 | #include <vibrator.h> |
| 70 | #endif |
| 71 | |
| 72 | #if PON_VIB_SUPPORT |
| 73 | #define VIBRATE_TIME 250 |
| 74 | #endif |
| 75 | |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +0530 | [diff] [blame] | 76 | #define PMIC_ARB_CHANNEL_NUM 0 |
| 77 | #define PMIC_ARB_OWNER_ID 0 |
| 78 | #define TLMM_VOL_UP_BTN_GPIO 85 |
Unnati Gandhi | fe004a9 | 2015-06-01 13:06:06 +0530 | [diff] [blame] | 79 | #define TLMM_VOL_UP_BTN_GPIO_8956 113 |
Parth Dixit | 720d3b9 | 2015-10-30 01:21:34 +0530 | [diff] [blame] | 80 | #define TLMM_VOL_UP_BTN_GPIO_8937 91 |
Wufeng | f2e3731 | 2016-04-12 16:09:47 +0800 | [diff] [blame] | 81 | #define TLMM_VOL_DOWN_BTN_GPIO 128 |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +0530 | [diff] [blame] | 82 | |
| 83 | #define FASTBOOT_MODE 0x77665500 |
Aparna Mallavarapu | 680a133 | 2015-04-29 19:14:09 +0530 | [diff] [blame] | 84 | #define RECOVERY_MODE 0x77665502 |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +0530 | [diff] [blame] | 85 | #define PON_SOFT_RB_SPARE 0x88F |
| 86 | |
Parth Dixit | 17b8519 | 2016-12-28 15:51:33 +0530 | [diff] [blame] | 87 | #define EXT4_CMDLINE " rootfstype=ext4 root=/dev/mmcblk0p" |
| 88 | |
Aparna Mallavarapu | 1e8b093 | 2015-03-29 23:38:13 +0530 | [diff] [blame] | 89 | #define CE1_INSTANCE 1 |
| 90 | #define CE_EE 1 |
| 91 | #define CE_FIFO_SIZE 64 |
| 92 | #define CE_READ_PIPE 3 |
| 93 | #define CE_WRITE_PIPE 2 |
| 94 | #define CE_READ_PIPE_LOCK_GRP 0 |
| 95 | #define CE_WRITE_PIPE_LOCK_GRP 0 |
| 96 | #define CE_ARRAY_SIZE 20 |
Wufeng | f2e3731 | 2016-04-12 16:09:47 +0800 | [diff] [blame] | 97 | #define SUB_TYPE_SKUT 0x0A |
Vijay Kumar Pendoti | 0d69884 | 2016-09-23 16:23:16 +0530 | [diff] [blame] | 98 | #define SMBCHG_USB_RT_STS 0x21310 |
| 99 | #define USBIN_UV_RT_STS BIT(0) |
Umang Agrawal | 898a191 | 2018-02-13 16:09:10 +0530 | [diff] [blame] | 100 | #define USBIN_UV_RT_STS_PMI632 BIT(2) |
Aparna Mallavarapu | 1e8b093 | 2015-03-29 23:38:13 +0530 | [diff] [blame] | 101 | |
Aparna Mallavarapu | 7b638e6 | 2015-03-26 05:51:57 +0530 | [diff] [blame] | 102 | struct mmc_device *dev; |
| 103 | |
| 104 | static uint32_t mmc_pwrctl_base[] = |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +0530 | [diff] [blame] | 105 | { MSM_SDC1_BASE, MSM_SDC2_BASE }; |
| 106 | |
Aparna Mallavarapu | 7b638e6 | 2015-03-26 05:51:57 +0530 | [diff] [blame] | 107 | static uint32_t mmc_sdhci_base[] = |
| 108 | { MSM_SDC1_SDHCI_BASE, MSM_SDC2_SDHCI_BASE }; |
| 109 | |
| 110 | static uint32_t mmc_sdc_pwrctl_irq[] = |
| 111 | { SDCC1_PWRCTL_IRQ, SDCC2_PWRCTL_IRQ }; |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +0530 | [diff] [blame] | 112 | |
| 113 | void target_early_init(void) |
| 114 | { |
| 115 | #if WITH_DEBUG_UART |
Aparna Mallavarapu | 7b638e6 | 2015-03-26 05:51:57 +0530 | [diff] [blame] | 116 | uart_dm_init(2, 0, BLSP1_UART1_BASE); |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +0530 | [diff] [blame] | 117 | #endif |
| 118 | } |
| 119 | |
Aparna Mallavarapu | 7b638e6 | 2015-03-26 05:51:57 +0530 | [diff] [blame] | 120 | static void set_sdc_power_ctrl() |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +0530 | [diff] [blame] | 121 | { |
Aparna Mallavarapu | 7b638e6 | 2015-03-26 05:51:57 +0530 | [diff] [blame] | 122 | /* Drive strength configs for sdc pins */ |
| 123 | struct tlmm_cfgs sdc1_hdrv_cfg[] = |
| 124 | { |
| 125 | { SDC1_CLK_HDRV_CTL_OFF, TLMM_CUR_VAL_16MA, TLMM_HDRV_MASK, 0}, |
| 126 | { SDC1_CMD_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK, 0}, |
| 127 | { SDC1_DATA_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK , 0}, |
| 128 | }; |
| 129 | |
| 130 | /* Pull configs for sdc pins */ |
| 131 | struct tlmm_cfgs sdc1_pull_cfg[] = |
| 132 | { |
| 133 | { SDC1_CLK_PULL_CTL_OFF, TLMM_NO_PULL, TLMM_PULL_MASK, 0}, |
| 134 | { SDC1_CMD_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK, 0}, |
| 135 | { SDC1_DATA_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK, 0}, |
| 136 | }; |
| 137 | |
Aparna Mallavarapu | 2913891 | 2015-04-13 23:45:35 +0530 | [diff] [blame] | 138 | struct tlmm_cfgs sdc1_rclk_cfg[] = |
| 139 | { |
| 140 | { SDC1_RCLK_PULL_CTL_OFF, TLMM_PULL_DOWN, TLMM_PULL_MASK, 0}, |
| 141 | }; |
| 142 | |
Aparna Mallavarapu | 7b638e6 | 2015-03-26 05:51:57 +0530 | [diff] [blame] | 143 | /* Set the drive strength & pull control values */ |
| 144 | tlmm_set_hdrive_ctrl(sdc1_hdrv_cfg, ARRAY_SIZE(sdc1_hdrv_cfg)); |
| 145 | tlmm_set_pull_ctrl(sdc1_pull_cfg, ARRAY_SIZE(sdc1_pull_cfg)); |
Aparna Mallavarapu | 2913891 | 2015-04-13 23:45:35 +0530 | [diff] [blame] | 146 | tlmm_set_pull_ctrl(sdc1_rclk_cfg, ARRAY_SIZE(sdc1_rclk_cfg)); |
Aparna Mallavarapu | 7b638e6 | 2015-03-26 05:51:57 +0530 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | void target_sdc_init() |
| 150 | { |
| 151 | struct mmc_config_data config; |
| 152 | |
| 153 | /* Set drive strength & pull ctrl values */ |
| 154 | set_sdc_power_ctrl(); |
| 155 | |
| 156 | /* Try slot 1*/ |
| 157 | config.slot = 1; |
| 158 | config.bus_width = DATA_BUS_WIDTH_8BIT; |
Aparna Mallavarapu | 680a133 | 2015-04-29 19:14:09 +0530 | [diff] [blame] | 159 | config.max_clk_rate = MMC_CLK_192MHZ; |
Aparna Mallavarapu | 7b638e6 | 2015-03-26 05:51:57 +0530 | [diff] [blame] | 160 | config.sdhc_base = mmc_sdhci_base[config.slot - 1]; |
| 161 | config.pwrctl_base = mmc_pwrctl_base[config.slot - 1]; |
| 162 | config.pwr_irq = mmc_sdc_pwrctl_irq[config.slot - 1]; |
| 163 | config.hs400_support = 1; |
| 164 | |
| 165 | if (!(dev = mmc_init(&config))) { |
| 166 | /* Try slot 2 */ |
| 167 | config.slot = 2; |
| 168 | config.max_clk_rate = MMC_CLK_200MHZ; |
| 169 | config.sdhc_base = mmc_sdhci_base[config.slot - 1]; |
| 170 | config.pwrctl_base = mmc_pwrctl_base[config.slot - 1]; |
| 171 | config.pwr_irq = mmc_sdc_pwrctl_irq[config.slot - 1]; |
| 172 | config.hs400_support = 0; |
| 173 | |
| 174 | if (!(dev = mmc_init(&config))) { |
| 175 | dprintf(CRITICAL, "mmc init failed!"); |
| 176 | ASSERT(0); |
| 177 | } |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | void *target_mmc_device() |
| 182 | { |
| 183 | return (void *) dev; |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +0530 | [diff] [blame] | 184 | } |
| 185 | |
| 186 | /* Return 1 if vol_up pressed */ |
Rami Butstein | e51318a | 2015-05-27 16:23:17 +0300 | [diff] [blame] | 187 | int target_volume_up() |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +0530 | [diff] [blame] | 188 | { |
lijuang | 2d2b8a0 | 2015-06-05 21:34:15 +0800 | [diff] [blame] | 189 | static uint8_t first_time = 0; |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +0530 | [diff] [blame] | 190 | uint8_t status = 0; |
Unnati Gandhi | e3a5c0e | 2015-06-14 17:31:07 +0530 | [diff] [blame] | 191 | uint32_t vol_up_gpio; |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +0530 | [diff] [blame] | 192 | |
Unnati Gandhi | fe004a9 | 2015-06-01 13:06:06 +0530 | [diff] [blame] | 193 | if(platform_is_msm8956()) |
Unnati Gandhi | e3a5c0e | 2015-06-14 17:31:07 +0530 | [diff] [blame] | 194 | vol_up_gpio = TLMM_VOL_UP_BTN_GPIO_8956; |
lijuang | f656368 | 2018-04-04 20:26:52 +0800 | [diff] [blame] | 195 | else if(platform_is_msm8937() || platform_is_msm8917() || |
| 196 | platform_is_sdm429() || platform_is_sdm439()) |
Parth Dixit | 720d3b9 | 2015-10-30 01:21:34 +0530 | [diff] [blame] | 197 | vol_up_gpio = TLMM_VOL_UP_BTN_GPIO_8937; |
Unnati Gandhi | fe004a9 | 2015-06-01 13:06:06 +0530 | [diff] [blame] | 198 | else |
Unnati Gandhi | e3a5c0e | 2015-06-14 17:31:07 +0530 | [diff] [blame] | 199 | vol_up_gpio = TLMM_VOL_UP_BTN_GPIO; |
| 200 | |
lijuang | 2d2b8a0 | 2015-06-05 21:34:15 +0800 | [diff] [blame] | 201 | if (!first_time) { |
| 202 | gpio_tlmm_config(vol_up_gpio, 0, GPIO_INPUT, GPIO_PULL_UP, GPIO_2MA, GPIO_ENABLE); |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +0530 | [diff] [blame] | 203 | |
lijuang | 2d2b8a0 | 2015-06-05 21:34:15 +0800 | [diff] [blame] | 204 | /* Wait for the gpio config to take effect - debounce time */ |
| 205 | udelay(10000); |
| 206 | |
| 207 | first_time = 1; |
| 208 | } |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +0530 | [diff] [blame] | 209 | |
| 210 | /* Get status of GPIO */ |
Unnati Gandhi | e3a5c0e | 2015-06-14 17:31:07 +0530 | [diff] [blame] | 211 | status = gpio_status(vol_up_gpio); |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +0530 | [diff] [blame] | 212 | |
Aparna Mallavarapu | fa5f8a7 | 2015-03-31 06:21:36 +0530 | [diff] [blame] | 213 | /* Active low signal. */ |
Aparna Mallavarapu | db938b6 | 2015-04-09 01:00:55 +0530 | [diff] [blame] | 214 | return !status; |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +0530 | [diff] [blame] | 215 | } |
| 216 | |
| 217 | /* Return 1 if vol_down pressed */ |
| 218 | uint32_t target_volume_down() |
| 219 | { |
Wufeng | f2e3731 | 2016-04-12 16:09:47 +0800 | [diff] [blame] | 220 | static bool vol_down_key_init = false; |
| 221 | |
| 222 | if ((board_hardware_id() == HW_PLATFORM_QRD) && |
| 223 | (board_hardware_subtype() == SUB_TYPE_SKUT)) { |
| 224 | uint32_t status = 0; |
| 225 | |
| 226 | if (!vol_down_key_init) { |
| 227 | gpio_tlmm_config(TLMM_VOL_DOWN_BTN_GPIO, 0, GPIO_INPUT, GPIO_PULL_UP, |
| 228 | GPIO_2MA, GPIO_ENABLE); |
| 229 | /* Wait for the gpio config to take effect - debounce time */ |
| 230 | thread_sleep(10); |
| 231 | vol_down_key_init = true; |
| 232 | } |
| 233 | |
| 234 | /* Get status of GPIO */ |
| 235 | status = gpio_status(TLMM_VOL_DOWN_BTN_GPIO); |
| 236 | |
| 237 | /* Active low signal. */ |
| 238 | return !status; |
| 239 | } else { |
| 240 | /* Volume down button tied in with PMIC RESIN. */ |
| 241 | return pm8x41_resin_status(); |
| 242 | } |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +0530 | [diff] [blame] | 243 | } |
| 244 | |
Parth Dixit | 300a3b9 | 2015-06-19 16:38:12 +0530 | [diff] [blame] | 245 | uint32_t target_is_pwrkey_pon_reason() |
| 246 | { |
Umang Agrawal | 898a191 | 2018-02-13 16:09:10 +0530 | [diff] [blame] | 247 | uint32_t pmic = target_get_pmic(); |
| 248 | uint8_t pon_reason = 0; |
| 249 | bool usb_present_sts = 0; |
| 250 | |
| 251 | if (pmic == PMIC_IS_PMI632) |
| 252 | { |
| 253 | pon_reason = pmi632_get_pon_reason(); |
| 254 | usb_present_sts = !(USBIN_UV_RT_STS_PMI632 & |
Vijay Kumar Pendoti | 0d69884 | 2016-09-23 16:23:16 +0530 | [diff] [blame] | 255 | pm8x41_reg_read(SMBCHG_USB_RT_STS)); |
Umang Agrawal | 898a191 | 2018-02-13 16:09:10 +0530 | [diff] [blame] | 256 | } |
| 257 | else |
| 258 | { |
| 259 | pon_reason = pm8950_get_pon_reason(); |
| 260 | usb_present_sts = !(USBIN_UV_RT_STS & |
| 261 | pm8x41_reg_read(SMBCHG_USB_RT_STS)); |
| 262 | } |
| 263 | |
Parth Dixit | 300a3b9 | 2015-06-19 16:38:12 +0530 | [diff] [blame] | 264 | if (pm8x41_get_is_cold_boot() && ((pon_reason == KPDPWR_N) || (pon_reason == (KPDPWR_N|PON1)))) |
| 265 | return 1; |
Vijay Kumar Pendoti | 0d69884 | 2016-09-23 16:23:16 +0530 | [diff] [blame] | 266 | else if ((pon_reason == PON1) && (!usb_present_sts)) |
| 267 | return 1; |
Parth Dixit | 300a3b9 | 2015-06-19 16:38:12 +0530 | [diff] [blame] | 268 | else |
| 269 | return 0; |
| 270 | } |
| 271 | |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +0530 | [diff] [blame] | 272 | static void target_keystatus() |
| 273 | { |
| 274 | keys_init(); |
| 275 | |
| 276 | if(target_volume_down()) |
| 277 | keys_post_event(KEY_VOLUMEDOWN, 1); |
| 278 | |
| 279 | if(target_volume_up()) |
| 280 | keys_post_event(KEY_VOLUMEUP, 1); |
| 281 | } |
| 282 | |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +0530 | [diff] [blame] | 283 | void target_init(void) |
| 284 | { |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +0530 | [diff] [blame] | 285 | dprintf(INFO, "target_init()\n"); |
| 286 | |
| 287 | spmi_init(PMIC_ARB_CHANNEL_NUM, PMIC_ARB_OWNER_ID); |
| 288 | |
Parth Dixit | 550ddf3 | 2016-11-28 17:00:29 +0530 | [diff] [blame] | 289 | if(target_is_pmi_enabled()) |
Parth Dixit | 3e6dead | 2015-12-08 15:04:54 +0530 | [diff] [blame] | 290 | { |
lijuang | f656368 | 2018-04-04 20:26:52 +0800 | [diff] [blame] | 291 | if(platform_is_msm8937() || platform_is_msm8917() || |
| 292 | platform_is_sdm429() || platform_is_sdm439()) |
Parth Dixit | 3e6dead | 2015-12-08 15:04:54 +0530 | [diff] [blame] | 293 | { |
Parth Dixit | 550ddf3 | 2016-11-28 17:00:29 +0530 | [diff] [blame] | 294 | uint8_t pmi_rev = 0; |
| 295 | uint32_t pmi_type = 0; |
| 296 | |
Umang Agrawal | 1b18058 | 2018-04-17 18:56:57 +0530 | [diff] [blame^] | 297 | pmi_type = board_pmic_target(1) & PMIC_TYPE_MASK; |
Parth Dixit | 550ddf3 | 2016-11-28 17:00:29 +0530 | [diff] [blame] | 298 | if(pmi_type == PMIC_IS_PMI8950) |
| 299 | { |
| 300 | /* read pmic spare register for rev */ |
| 301 | pmi_rev = pmi8950_get_pmi_subtype(); |
| 302 | if(pmi_rev) |
| 303 | board_pmi_target_set(1,pmi_rev); |
| 304 | } |
Parth Dixit | 3e6dead | 2015-12-08 15:04:54 +0530 | [diff] [blame] | 305 | } |
| 306 | } |
| 307 | |
Parth Dixit | 550ddf3 | 2016-11-28 17:00:29 +0530 | [diff] [blame] | 308 | |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +0530 | [diff] [blame] | 309 | target_keystatus(); |
| 310 | |
Aparna Mallavarapu | 7b638e6 | 2015-03-26 05:51:57 +0530 | [diff] [blame] | 311 | target_sdc_init(); |
| 312 | if (partition_read_table()) |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +0530 | [diff] [blame] | 313 | { |
Aparna Mallavarapu | 7b638e6 | 2015-03-26 05:51:57 +0530 | [diff] [blame] | 314 | dprintf(CRITICAL, "Error reading the partition table info\n"); |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +0530 | [diff] [blame] | 315 | ASSERT(0); |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +0530 | [diff] [blame] | 316 | } |
Aparna Mallavarapu | 7b638e6 | 2015-03-26 05:51:57 +0530 | [diff] [blame] | 317 | |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +0530 | [diff] [blame] | 318 | #if LONG_PRESS_POWER_ON |
Parth Dixit | 550ddf3 | 2016-11-28 17:00:29 +0530 | [diff] [blame] | 319 | if(target_is_pmi_enabled()) |
| 320 | shutdown_detect(); |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +0530 | [diff] [blame] | 321 | #endif |
Matthew Qin | 47dfdb7 | 2015-06-10 21:29:11 +0800 | [diff] [blame] | 322 | |
| 323 | #if PON_VIB_SUPPORT |
| 324 | /* turn on vibrator to indicate that phone is booting up to end user */ |
Parth Dixit | 550ddf3 | 2016-11-28 17:00:29 +0530 | [diff] [blame] | 325 | if(target_is_pmi_enabled()) |
| 326 | vib_timed_turn_on(VIBRATE_TIME); |
Matthew Qin | 47dfdb7 | 2015-06-10 21:29:11 +0800 | [diff] [blame] | 327 | #endif |
| 328 | |
Aparna Mallavarapu | 1e8b093 | 2015-03-29 23:38:13 +0530 | [diff] [blame] | 329 | if (target_use_signed_kernel()) |
| 330 | target_crypto_init_params(); |
Aparna Mallavarapu | fa5f8a7 | 2015-03-31 06:21:36 +0530 | [diff] [blame] | 331 | |
Parth Dixit | 5b954e0 | 2015-10-17 22:20:31 +0530 | [diff] [blame] | 332 | #if VERIFIED_BOOT |
Mayank Grover | e2384ad | 2017-10-26 12:11:17 +0530 | [diff] [blame] | 333 | if (VB_M <= target_get_vb_version()) |
Parth Dixit | 6e6bad5 | 2015-07-30 19:02:38 +0530 | [diff] [blame] | 334 | { |
Mayank Grover | 32ba299 | 2017-09-06 11:14:00 +0530 | [diff] [blame] | 335 | clock_ce_enable(CE1_INSTANCE); |
Parth Dixit | 6e6bad5 | 2015-07-30 19:02:38 +0530 | [diff] [blame] | 336 | |
Mayank Grover | 32ba299 | 2017-09-06 11:14:00 +0530 | [diff] [blame] | 337 | /* Initialize Qseecom */ |
| 338 | if (qseecom_init() < 0) |
| 339 | { |
| 340 | dprintf(CRITICAL, "Failed to initialize qseecom\n"); |
| 341 | ASSERT(0); |
| 342 | } |
Parth Dixit | 6e6bad5 | 2015-07-30 19:02:38 +0530 | [diff] [blame] | 343 | |
Mayank Grover | 32ba299 | 2017-09-06 11:14:00 +0530 | [diff] [blame] | 344 | /* Start Qseecom */ |
| 345 | if (qseecom_tz_init() < 0) |
| 346 | { |
| 347 | dprintf(CRITICAL, "Failed to start qseecom\n"); |
| 348 | ASSERT(0); |
| 349 | } |
Parth Dixit | 6e6bad5 | 2015-07-30 19:02:38 +0530 | [diff] [blame] | 350 | |
Mayank Grover | 32ba299 | 2017-09-06 11:14:00 +0530 | [diff] [blame] | 351 | if (rpmb_init() < 0) |
| 352 | { |
| 353 | dprintf(CRITICAL, "RPMB init failed\n"); |
| 354 | ASSERT(0); |
| 355 | } |
Parth Dixit | b4b2ffa | 2015-10-09 15:31:14 +0530 | [diff] [blame] | 356 | |
Mayank Grover | 32ba299 | 2017-09-06 11:14:00 +0530 | [diff] [blame] | 357 | /* |
| 358 | * Load the sec app for first time |
| 359 | */ |
| 360 | if (load_sec_app() < 0) |
| 361 | { |
| 362 | dprintf(CRITICAL, "Failed to load App for verified\n"); |
| 363 | ASSERT(0); |
| 364 | } |
Parth Dixit | 6e6bad5 | 2015-07-30 19:02:38 +0530 | [diff] [blame] | 365 | } |
Parth Dixit | 5b954e0 | 2015-10-17 22:20:31 +0530 | [diff] [blame] | 366 | #endif |
| 367 | |
Aparna Mallavarapu | fa5f8a7 | 2015-03-31 06:21:36 +0530 | [diff] [blame] | 368 | #if SMD_SUPPORT |
| 369 | rpm_smd_init(); |
| 370 | #endif |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +0530 | [diff] [blame] | 371 | } |
| 372 | |
| 373 | void target_serialno(unsigned char *buf) |
| 374 | { |
| 375 | uint32_t serialno; |
| 376 | if (target_is_emmc_boot()) { |
| 377 | serialno = mmc_get_psn(); |
| 378 | snprintf((char *)buf, 13, "%x", serialno); |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | unsigned board_machtype(void) |
| 383 | { |
Aparna Mallavarapu | e9bdacd | 2015-03-15 14:24:21 +0530 | [diff] [blame] | 384 | return LINUX_MACHTYPE_UNKNOWN; |
| 385 | } |
| 386 | |
| 387 | /* Detect the target type */ |
| 388 | void target_detect(struct board_data *board) |
| 389 | { |
| 390 | /* This is already filled as part of board.c */ |
| 391 | } |
| 392 | |
| 393 | /* Detect the modem type */ |
| 394 | void target_baseband_detect(struct board_data *board) |
| 395 | { |
| 396 | uint32_t platform; |
| 397 | |
| 398 | platform = board->platform; |
| 399 | |
| 400 | switch(platform) { |
| 401 | case MSM8952: |
| 402 | case MSM8956: |
| 403 | case MSM8976: |
Parth Dixit | 4ec3fe2 | 2015-10-30 00:44:33 +0530 | [diff] [blame] | 404 | case MSM8937: |
Parth Dixit | 660369e | 2016-05-12 09:53:15 +0530 | [diff] [blame] | 405 | case MSM8940: |
Parth Dixit | 05f3c9f | 2016-03-18 17:14:57 +0530 | [diff] [blame] | 406 | case MSM8917: |
Mayank Grover | cd5f0ff | 2016-10-03 18:08:52 +0530 | [diff] [blame] | 407 | case MSM8920: |
Parth Dixit | 05f3c9f | 2016-03-18 17:14:57 +0530 | [diff] [blame] | 408 | case MSM8217: |
| 409 | case MSM8617: |
lijuang | f656368 | 2018-04-04 20:26:52 +0800 | [diff] [blame] | 410 | case SDM429: |
| 411 | case SDM439: |
Aparna Mallavarapu | e9bdacd | 2015-03-15 14:24:21 +0530 | [diff] [blame] | 412 | board->baseband = BASEBAND_MSM; |
| 413 | break; |
Aparna Mallavarapu | 815b324 | 2015-04-29 11:08:14 +0530 | [diff] [blame] | 414 | case APQ8052: |
| 415 | case APQ8056: |
| 416 | case APQ8076: |
Parth Dixit | 4ec3fe2 | 2015-10-30 00:44:33 +0530 | [diff] [blame] | 417 | case APQ8037: |
Parth Dixit | 05f3c9f | 2016-03-18 17:14:57 +0530 | [diff] [blame] | 418 | case APQ8017: |
Aparna Mallavarapu | 815b324 | 2015-04-29 11:08:14 +0530 | [diff] [blame] | 419 | board->baseband = BASEBAND_APQ; |
| 420 | break; |
Aparna Mallavarapu | e9bdacd | 2015-03-15 14:24:21 +0530 | [diff] [blame] | 421 | default: |
| 422 | dprintf(CRITICAL, "Platform type: %u is not supported\n",platform); |
| 423 | ASSERT(0); |
| 424 | }; |
| 425 | } |
| 426 | |
| 427 | unsigned target_baseband() |
| 428 | { |
| 429 | return board_baseband(); |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +0530 | [diff] [blame] | 430 | } |
| 431 | |
lijuang | 395b5e6 | 2015-11-19 17:39:44 +0800 | [diff] [blame] | 432 | int set_download_mode(enum reboot_reason mode) |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +0530 | [diff] [blame] | 433 | { |
| 434 | int ret = 0; |
| 435 | ret = scm_dload_mode(mode); |
| 436 | |
| 437 | pm8x41_clear_pmic_watchdog(); |
| 438 | |
| 439 | return ret; |
| 440 | } |
| 441 | |
| 442 | int emmc_recovery_init(void) |
| 443 | { |
| 444 | return _emmc_recovery_init(); |
| 445 | } |
| 446 | |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +0530 | [diff] [blame] | 447 | unsigned target_pause_for_battery_charge(void) |
| 448 | { |
Umang Agrawal | 898a191 | 2018-02-13 16:09:10 +0530 | [diff] [blame] | 449 | uint32_t pmic = target_get_pmic(); |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +0530 | [diff] [blame] | 450 | uint8_t pon_reason = pm8x41_get_pon_reason(); |
| 451 | uint8_t is_cold_boot = pm8x41_get_is_cold_boot(); |
Parth Dixit | 550ddf3 | 2016-11-28 17:00:29 +0530 | [diff] [blame] | 452 | bool usb_present_sts = 1; /* don't care by default */ |
| 453 | |
Umang Agrawal | 898a191 | 2018-02-13 16:09:10 +0530 | [diff] [blame] | 454 | if (target_is_pmi_enabled()) |
| 455 | { |
| 456 | if (pmic == PMIC_IS_PMI632) |
| 457 | usb_present_sts = !(USBIN_UV_RT_STS_PMI632 & |
| 458 | pm8x41_reg_read(SMBCHG_USB_RT_STS)); |
| 459 | else |
| 460 | usb_present_sts = (!(USBIN_UV_RT_STS & |
| 461 | pm8x41_reg_read(SMBCHG_USB_RT_STS))); |
| 462 | } |
Parth Dixit | 550ddf3 | 2016-11-28 17:00:29 +0530 | [diff] [blame] | 463 | |
Zhenhua Huang | b46b9b5 | 2015-04-21 19:53:09 +0800 | [diff] [blame] | 464 | dprintf(INFO, "%s : pon_reason is:0x%x cold_boot:%d usb_sts:%d\n", __func__, |
| 465 | pon_reason, is_cold_boot, usb_present_sts); |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +0530 | [diff] [blame] | 466 | /* In case of fastboot reboot,adb reboot or if we see the power key |
| 467 | * pressed we do not want go into charger mode. |
| 468 | * fastboot reboot is warm boot with PON hard reset bit not set |
| 469 | * adb reboot is a cold boot with PON hard reset bit set |
| 470 | */ |
| 471 | if (is_cold_boot && |
| 472 | (!(pon_reason & HARD_RST)) && |
| 473 | (!(pon_reason & KPDPWR_N)) && |
Zhenhua Huang | b46b9b5 | 2015-04-21 19:53:09 +0800 | [diff] [blame] | 474 | usb_present_sts) |
Aparna Mallavarapu | ca67688 | 2015-01-19 20:39:06 +0530 | [diff] [blame] | 475 | return 1; |
| 476 | else |
| 477 | return 0; |
| 478 | } |
Aparna Mallavarapu | 7b638e6 | 2015-03-26 05:51:57 +0530 | [diff] [blame] | 479 | |
| 480 | void target_uninit(void) |
| 481 | { |
c_wufeng | 8324c04 | 2016-01-25 10:37:37 +0800 | [diff] [blame] | 482 | #if PON_VIB_SUPPORT |
Parth Dixit | 550ddf3 | 2016-11-28 17:00:29 +0530 | [diff] [blame] | 483 | if(target_is_pmi_enabled()) |
| 484 | turn_off_vib_early(); |
c_wufeng | 8324c04 | 2016-01-25 10:37:37 +0800 | [diff] [blame] | 485 | #endif |
Aparna Mallavarapu | 7b638e6 | 2015-03-26 05:51:57 +0530 | [diff] [blame] | 486 | mmc_put_card_to_sleep(dev); |
| 487 | sdhci_mode_disable(&dev->host); |
Aparna Mallavarapu | 1e8b093 | 2015-03-29 23:38:13 +0530 | [diff] [blame] | 488 | if (crypto_initialized()) |
Vijay Kumar Pendoti | b0f9ba3 | 2016-04-15 16:55:30 +0530 | [diff] [blame] | 489 | { |
Aparna Mallavarapu | 1e8b093 | 2015-03-29 23:38:13 +0530 | [diff] [blame] | 490 | crypto_eng_cleanup(); |
Vijay Kumar Pendoti | b0f9ba3 | 2016-04-15 16:55:30 +0530 | [diff] [blame] | 491 | clock_ce_disable(CE1_INSTANCE); |
| 492 | } |
Aparna Mallavarapu | 1e8b093 | 2015-03-29 23:38:13 +0530 | [diff] [blame] | 493 | |
| 494 | if (target_is_ssd_enabled()) |
| 495 | clock_ce_disable(CE1_INSTANCE); |
Aparna Mallavarapu | fa5f8a7 | 2015-03-31 06:21:36 +0530 | [diff] [blame] | 496 | |
Parth Dixit | 5b954e0 | 2015-10-17 22:20:31 +0530 | [diff] [blame] | 497 | #if VERIFIED_BOOT |
Mayank Grover | e2384ad | 2017-10-26 12:11:17 +0530 | [diff] [blame] | 498 | if (VB_M <= target_get_vb_version()) |
Parth Dixit | 6e6bad5 | 2015-07-30 19:02:38 +0530 | [diff] [blame] | 499 | { |
Mayank Grover | 32ba299 | 2017-09-06 11:14:00 +0530 | [diff] [blame] | 500 | if (is_sec_app_loaded()) |
Parth Dixit | 6e6bad5 | 2015-07-30 19:02:38 +0530 | [diff] [blame] | 501 | { |
Mayank Grover | 32ba299 | 2017-09-06 11:14:00 +0530 | [diff] [blame] | 502 | if (send_milestone_call_to_tz() < 0) |
| 503 | { |
| 504 | dprintf(CRITICAL, "Failed to unload App for rpmb\n"); |
| 505 | ASSERT(0); |
| 506 | } |
| 507 | } |
| 508 | |
| 509 | if (rpmb_uninit() < 0) |
| 510 | { |
| 511 | dprintf(CRITICAL, "RPMB uninit failed\n"); |
Parth Dixit | 6e6bad5 | 2015-07-30 19:02:38 +0530 | [diff] [blame] | 512 | ASSERT(0); |
| 513 | } |
Parth Dixit | 6e6bad5 | 2015-07-30 19:02:38 +0530 | [diff] [blame] | 514 | |
Mayank Grover | 32ba299 | 2017-09-06 11:14:00 +0530 | [diff] [blame] | 515 | clock_ce_disable(CE1_INSTANCE); |
Parth Dixit | 6e6bad5 | 2015-07-30 19:02:38 +0530 | [diff] [blame] | 516 | } |
Parth Dixit | b73ff34 | 2015-10-27 17:34:08 +0530 | [diff] [blame] | 517 | #endif |
Parth Dixit | 5b954e0 | 2015-10-17 22:20:31 +0530 | [diff] [blame] | 518 | |
Aparna Mallavarapu | fa5f8a7 | 2015-03-31 06:21:36 +0530 | [diff] [blame] | 519 | #if SMD_SUPPORT |
| 520 | rpm_smd_uninit(); |
| 521 | #endif |
Aparna Mallavarapu | 7b638e6 | 2015-03-26 05:51:57 +0530 | [diff] [blame] | 522 | } |
| 523 | |
| 524 | void target_usb_init(void) |
| 525 | { |
| 526 | uint32_t val; |
| 527 | |
| 528 | /* Select and enable external configuration with USB PHY */ |
| 529 | ulpi_write(ULPI_MISC_A_VBUSVLDEXTSEL | ULPI_MISC_A_VBUSVLDEXT, ULPI_MISC_A_SET); |
| 530 | |
| 531 | /* Enable sess_vld */ |
| 532 | val = readl(USB_GENCONFIG_2) | GEN2_SESS_VLD_CTRL_EN; |
| 533 | writel(val, USB_GENCONFIG_2); |
| 534 | |
| 535 | /* Enable external vbus configuration in the LINK */ |
| 536 | val = readl(USB_USBCMD); |
| 537 | val |= SESS_VLD_CTRL; |
| 538 | writel(val, USB_USBCMD); |
| 539 | } |
| 540 | |
| 541 | void target_usb_stop(void) |
| 542 | { |
| 543 | /* Disable VBUS mimicing in the controller. */ |
| 544 | ulpi_write(ULPI_MISC_A_VBUSVLDEXTSEL | ULPI_MISC_A_VBUSVLDEXT, ULPI_MISC_A_CLEAR); |
| 545 | } |
Aparna Mallavarapu | 1e8b093 | 2015-03-29 23:38:13 +0530 | [diff] [blame] | 546 | |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 547 | static uint8_t splash_override; |
| 548 | /* Returns 1 if target supports continuous splash screen. */ |
| 549 | int target_cont_splash_screen() |
| 550 | { |
| 551 | uint8_t splash_screen = 0; |
| 552 | if (!splash_override) { |
| 553 | switch (board_hardware_id()) { |
| 554 | case HW_PLATFORM_MTP: |
| 555 | case HW_PLATFORM_SURF: |
Vishnuvardhan Prodduturi | e116c00 | 2015-07-14 17:14:25 +0530 | [diff] [blame] | 556 | case HW_PLATFORM_RCM: |
feifanz | 174c82c | 2015-04-15 18:57:07 +0800 | [diff] [blame] | 557 | case HW_PLATFORM_QRD: |
Padmanabhan Komanduru | 9d49f89 | 2015-04-10 12:58:46 -0700 | [diff] [blame] | 558 | splash_screen = 1; |
| 559 | break; |
| 560 | default: |
| 561 | splash_screen = 0; |
| 562 | break; |
| 563 | } |
| 564 | dprintf(SPEW, "Target_cont_splash=%d\n", splash_screen); |
| 565 | } |
| 566 | return splash_screen; |
| 567 | } |
| 568 | |
| 569 | void target_force_cont_splash_disable(uint8_t override) |
| 570 | { |
| 571 | splash_override = override; |
| 572 | } |
| 573 | |
Ray Zhang | f95f5b9 | 2015-06-25 15:34:29 +0800 | [diff] [blame] | 574 | uint8_t target_panel_auto_detect_enabled() |
| 575 | { |
| 576 | uint8_t ret = 0; |
| 577 | |
| 578 | switch(board_hardware_id()) |
| 579 | { |
| 580 | case HW_PLATFORM_QRD: |
| 581 | ret = platform_is_msm8956() ? 1 : 0; |
| 582 | break; |
| 583 | case HW_PLATFORM_SURF: |
| 584 | case HW_PLATFORM_MTP: |
| 585 | default: |
| 586 | ret = 0; |
| 587 | } |
| 588 | return ret; |
| 589 | } |
| 590 | |
Aparna Mallavarapu | 1e8b093 | 2015-03-29 23:38:13 +0530 | [diff] [blame] | 591 | /* Do any target specific intialization needed before entering fastboot mode */ |
| 592 | void target_fastboot_init(void) |
| 593 | { |
| 594 | if (target_is_ssd_enabled()) { |
| 595 | clock_ce_enable(CE1_INSTANCE); |
| 596 | target_load_ssd_keystore(); |
| 597 | } |
| 598 | } |
| 599 | |
| 600 | void target_load_ssd_keystore(void) |
| 601 | { |
| 602 | uint64_t ptn; |
| 603 | int index; |
| 604 | uint64_t size; |
| 605 | uint32_t *buffer = NULL; |
| 606 | |
| 607 | if (!target_is_ssd_enabled()) |
| 608 | return; |
| 609 | |
| 610 | index = partition_get_index("ssd"); |
| 611 | |
| 612 | ptn = partition_get_offset(index); |
| 613 | if (ptn == 0){ |
| 614 | dprintf(CRITICAL, "Error: ssd partition not found\n"); |
| 615 | return; |
| 616 | } |
| 617 | |
| 618 | size = partition_get_size(index); |
| 619 | if (size == 0) { |
| 620 | dprintf(CRITICAL, "Error: invalid ssd partition size\n"); |
| 621 | return; |
| 622 | } |
| 623 | |
| 624 | buffer = memalign(CACHE_LINE, ROUNDUP(size, CACHE_LINE)); |
| 625 | if (!buffer) { |
| 626 | dprintf(CRITICAL, "Error: allocating memory for ssd buffer\n"); |
| 627 | return; |
| 628 | } |
| 629 | |
| 630 | if (mmc_read(ptn, buffer, size)) { |
| 631 | dprintf(CRITICAL, "Error: cannot read data\n"); |
| 632 | free(buffer); |
| 633 | return; |
| 634 | } |
| 635 | |
| 636 | clock_ce_enable(CE1_INSTANCE); |
| 637 | scm_protect_keystore(buffer, size); |
| 638 | clock_ce_disable(CE1_INSTANCE); |
| 639 | free(buffer); |
| 640 | } |
| 641 | |
| 642 | crypto_engine_type board_ce_type(void) |
| 643 | { |
| 644 | return CRYPTO_ENGINE_TYPE_HW; |
| 645 | } |
| 646 | |
| 647 | /* Set up params for h/w CE. */ |
| 648 | void target_crypto_init_params() |
| 649 | { |
| 650 | struct crypto_init_params ce_params; |
| 651 | |
| 652 | /* Set up base addresses and instance. */ |
| 653 | ce_params.crypto_instance = CE1_INSTANCE; |
| 654 | ce_params.crypto_base = MSM_CE1_BASE; |
| 655 | ce_params.bam_base = MSM_CE1_BAM_BASE; |
| 656 | |
| 657 | /* Set up BAM config. */ |
| 658 | ce_params.bam_ee = CE_EE; |
| 659 | ce_params.pipes.read_pipe = CE_READ_PIPE; |
| 660 | ce_params.pipes.write_pipe = CE_WRITE_PIPE; |
| 661 | ce_params.pipes.read_pipe_grp = CE_READ_PIPE_LOCK_GRP; |
| 662 | ce_params.pipes.write_pipe_grp = CE_WRITE_PIPE_LOCK_GRP; |
| 663 | |
| 664 | /* Assign buffer sizes. */ |
| 665 | ce_params.num_ce = CE_ARRAY_SIZE; |
| 666 | ce_params.read_fifo_size = CE_FIFO_SIZE; |
| 667 | ce_params.write_fifo_size = CE_FIFO_SIZE; |
| 668 | |
| 669 | /* BAM is initialized by TZ for this platform. |
| 670 | * Do not do it again as the initialization address space |
| 671 | * is locked. |
| 672 | */ |
| 673 | ce_params.do_bam_init = 0; |
| 674 | |
| 675 | crypto_init_params(&ce_params); |
| 676 | } |
lijuang | 3606df8 | 2015-09-02 21:14:43 +0800 | [diff] [blame] | 677 | |
Parth Dixit | 550ddf3 | 2016-11-28 17:00:29 +0530 | [diff] [blame] | 678 | bool target_is_pmi_enabled(void) |
| 679 | { |
| 680 | if(platform_is_msm8917() && |
Parth Dixit | acec6bf | 2017-02-27 19:06:39 +0530 | [diff] [blame] | 681 | (board_hardware_subtype() == HW_PLATFORM_SUBTYPE_SAP_NOPMI)) |
Parth Dixit | 550ddf3 | 2016-11-28 17:00:29 +0530 | [diff] [blame] | 682 | return 0; |
| 683 | else |
| 684 | return 1; |
| 685 | } |
| 686 | |
Parth Dixit | 17b8519 | 2016-12-28 15:51:33 +0530 | [diff] [blame] | 687 | #if _APPEND_CMDLINE |
| 688 | int get_target_boot_params(const char *cmdline, const char *part, char **buf) |
| 689 | { |
| 690 | int system_ptn_index = -1; |
| 691 | uint32_t buflen; |
| 692 | int ret = -1; |
| 693 | |
| 694 | if (!cmdline || !part ) { |
| 695 | dprintf(CRITICAL, "WARN: Invalid input param\n"); |
| 696 | return -1; |
| 697 | } |
| 698 | |
| 699 | if (!strstr(cmdline, "root=/dev/ram")) /* This check is to handle kdev boot */ |
| 700 | { |
| 701 | if (target_is_emmc_boot()) { |
| 702 | buflen = strlen(EXT4_CMDLINE) + sizeof(int) +1; |
| 703 | *buf = (char *)malloc(buflen); |
| 704 | if(!(*buf)) { |
| 705 | dprintf(CRITICAL,"Unable to allocate memory for boot params\n"); |
| 706 | return -1; |
| 707 | } |
| 708 | /* Below is for emmc boot */ |
| 709 | system_ptn_index = partition_get_index(part) + 1; /* Adding +1 as offsets for eMMC start at 1 and NAND at 0 */ |
| 710 | if (system_ptn_index < 0) { |
| 711 | dprintf(CRITICAL, |
| 712 | "WARN: Cannot get partition index for %s\n", part); |
| 713 | free(*buf); |
| 714 | return -1; |
| 715 | } |
| 716 | snprintf(*buf, buflen, EXT4_CMDLINE"%d", system_ptn_index); |
| 717 | ret = 0; |
| 718 | } |
| 719 | } |
| 720 | /*in success case buf will be freed in the calling function of this*/ |
| 721 | return ret; |
| 722 | } |
| 723 | #endif |
| 724 | |
lijuang | 3606df8 | 2015-09-02 21:14:43 +0800 | [diff] [blame] | 725 | uint32_t target_get_pmic() |
| 726 | { |
Umang Agrawal | 898a191 | 2018-02-13 16:09:10 +0530 | [diff] [blame] | 727 | if (target_is_pmi_enabled()) { |
Umang Agrawal | 1b18058 | 2018-04-17 18:56:57 +0530 | [diff] [blame^] | 728 | uint32_t pmi_type = board_pmic_target(1) & PMIC_TYPE_MASK; |
Umang Agrawal | 898a191 | 2018-02-13 16:09:10 +0530 | [diff] [blame] | 729 | if (pmi_type == PMIC_IS_PMI632) |
| 730 | return PMIC_IS_PMI632; |
| 731 | else |
| 732 | return PMIC_IS_PMI8950; |
| 733 | } |
| 734 | else { |
| 735 | return PMIC_IS_UNKNOWN; |
| 736 | } |
lijuang | 3606df8 | 2015-09-02 21:14:43 +0800 | [diff] [blame] | 737 | } |
Maria Yu | 3ce8b63 | 2018-03-23 13:26:31 +0530 | [diff] [blame] | 738 | |
| 739 | void pmic_reset_configure(uint8_t reset_type) |
| 740 | { |
| 741 | uint32_t pmi_type; |
| 742 | |
| 743 | pmi_type = target_get_pmic(); |
| 744 | if (pmi_type == PMIC_IS_PMI632) { |
| 745 | pmi632_reset_configure(reset_type); |
| 746 | } else { |
| 747 | if(target_is_pmi_enabled()) { |
| 748 | pm8994_reset_configure(reset_type); |
| 749 | } else { |
| 750 | pm8x41_reset_configure(reset_type); |
| 751 | } |
| 752 | } |
| 753 | } |
| 754 | |