zhaochen | ed3bdfb | 2018-02-06 19:09:17 +0800 | [diff] [blame] | 1 | /* Copyright (c) 2014-2018 The Linux Foundation. All rights reserved. |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [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 |
Sridhar Parasuram | 568e7a6 | 2015-08-06 13:16:02 -0700 | [diff] [blame] | 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, nit |
| 22 | * PROCUREMENT OF |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 24 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 25 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 27 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | */ |
| 29 | |
| 30 | #include <debug.h> |
| 31 | #include <platform/iomap.h> |
| 32 | #include <platform/irqs.h> |
| 33 | #include <platform/gpio.h> |
| 34 | #include <reg.h> |
| 35 | #include <target.h> |
| 36 | #include <platform.h> |
| 37 | #include <dload_util.h> |
| 38 | #include <uart_dm.h> |
| 39 | #include <mmc.h> |
| 40 | #include <spmi.h> |
| 41 | #include <board.h> |
| 42 | #include <smem.h> |
| 43 | #include <baseband.h> |
Sridhar Parasuram | d75ade5 | 2015-03-09 15:45:16 -0700 | [diff] [blame] | 44 | #include <regulator.h> |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 45 | #include <dev/keys.h> |
| 46 | #include <pm8x41.h> |
Vijay Kumar Pendoti | e1fff02 | 2016-05-04 13:04:32 +0530 | [diff] [blame] | 47 | #include <pm8x41_hw.h> |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 48 | #include <crypto5_wrapper.h> |
| 49 | #include <clock.h> |
| 50 | #include <partition_parser.h> |
| 51 | #include <scm.h> |
| 52 | #include <platform/clock.h> |
| 53 | #include <platform/gpio.h> |
| 54 | #include <platform/timer.h> |
| 55 | #include <stdlib.h> |
| 56 | #include <ufs.h> |
| 57 | #include <boot_device.h> |
| 58 | #include <qmp_phy.h> |
Channagoud Kadabi | 7d30820 | 2014-12-22 12:07:04 -0800 | [diff] [blame] | 59 | #include <sdhci_msm.h> |
| 60 | #include <qusb2_phy.h> |
Sridhar Parasuram | 568e7a6 | 2015-08-06 13:16:02 -0700 | [diff] [blame] | 61 | #include <secapp_loader.h> |
Channagoud Kadabi | 2bab29b | 2015-02-11 13:26:03 -0800 | [diff] [blame] | 62 | #include <rpmb.h> |
Sridhar Parasuram | 9f28f67 | 2015-03-17 15:40:47 -0700 | [diff] [blame] | 63 | #include <rpm-glink.h> |
Channagoud Kadabi | bb8f1f9 | 2015-04-27 11:14:45 -0700 | [diff] [blame] | 64 | #if ENABLE_WBC |
| 65 | #include <pm_app_smbchg.h> |
| 66 | #endif |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 67 | |
c_wufeng | f433f23 | 2015-09-21 15:21:21 +0800 | [diff] [blame] | 68 | #if LONG_PRESS_POWER_ON |
| 69 | #include <shutdown_detect.h> |
| 70 | #endif |
| 71 | |
c_wufeng | 196210d | 2015-09-21 12:49:43 +0800 | [diff] [blame] | 72 | #if PON_VIB_SUPPORT |
| 73 | #include <vibrator.h> |
| 74 | #define VIBRATE_TIME 250 |
| 75 | #endif |
c_wufeng | f433f23 | 2015-09-21 15:21:21 +0800 | [diff] [blame] | 76 | |
Channagoud Kadabi | 9b28c0b | 2016-01-11 18:42:33 -0800 | [diff] [blame] | 77 | #include <pm_smbchg_usb_chgpth.h> |
| 78 | |
zhaochen | ed3bdfb | 2018-02-06 19:09:17 +0800 | [diff] [blame] | 79 | #if MOUNT_EMMC_LE |
| 80 | #define ROOTFS_EMMC_PATH " root=/dev/mmcblk0p" |
| 81 | #else |
| 82 | #define ROOTFS_EMMC_PATH " root=/dev/mmcblock0p" |
| 83 | #endif |
| 84 | |
Channagoud Kadabi | 4a870cf | 2015-01-21 10:39:01 -0800 | [diff] [blame] | 85 | #define CE_INSTANCE 1 |
Channagoud Kadabi | 7edb9b4 | 2015-08-11 23:45:31 -0700 | [diff] [blame] | 86 | #define CE_EE 0 |
Channagoud Kadabi | 4a870cf | 2015-01-21 10:39:01 -0800 | [diff] [blame] | 87 | #define CE_FIFO_SIZE 64 |
| 88 | #define CE_READ_PIPE 3 |
| 89 | #define CE_WRITE_PIPE 2 |
| 90 | #define CE_READ_PIPE_LOCK_GRP 0 |
| 91 | #define CE_WRITE_PIPE_LOCK_GRP 0 |
| 92 | #define CE_ARRAY_SIZE 20 |
| 93 | |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 94 | #define PMIC_ARB_CHANNEL_NUM 0 |
| 95 | #define PMIC_ARB_OWNER_ID 0 |
| 96 | |
Vijay Kumar Pendoti | e1fff02 | 2016-05-04 13:04:32 +0530 | [diff] [blame] | 97 | #define SMBCHG_USB_RT_STS 0x21310 |
| 98 | #define SMBCHG_DC_RT_STS 0x21410 |
| 99 | #define USBIN_UV_RT_STS BIT(0) |
| 100 | #define USBIN_OV_RT_STS BIT(1) |
| 101 | #define DCIN_UV_RT_STS BIT(0) |
| 102 | #define DCIN_OV_RT_STS BIT(1) |
| 103 | |
Channagoud Kadabi | 4021fa9 | 2015-11-03 16:35:26 -0800 | [diff] [blame] | 104 | enum |
| 105 | { |
| 106 | FUSION_I2S_MTP = 1, |
| 107 | FUSION_SLIMBUS = 2, |
| 108 | } mtp_subtype; |
| 109 | |
| 110 | enum |
| 111 | { |
| 112 | FUSION_I2S_CDP = 2, |
| 113 | } cdp_subtype; |
| 114 | |
Tanya Finkel | 619fc2a | 2016-08-16 14:11:26 +0300 | [diff] [blame] | 115 | static uint8_t flash_memory_slot = 0; |
| 116 | static void set_sdc_power_ctrl(); |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 117 | static uint32_t mmc_pwrctl_base[] = |
| 118 | { MSM_SDC1_BASE, MSM_SDC2_BASE }; |
| 119 | |
| 120 | static uint32_t mmc_sdhci_base[] = |
| 121 | { MSM_SDC1_SDHCI_BASE, MSM_SDC2_SDHCI_BASE }; |
| 122 | |
| 123 | static uint32_t mmc_sdc_pwrctl_irq[] = |
| 124 | { SDCC1_PWRCTL_IRQ, SDCC2_PWRCTL_IRQ }; |
| 125 | |
| 126 | struct mmc_device *dev; |
| 127 | struct ufs_dev ufs_device; |
| 128 | |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 129 | void target_early_init(void) |
| 130 | { |
| 131 | #if WITH_DEBUG_UART |
Channagoud Kadabi | 35503c4 | 2014-11-14 16:22:43 -0800 | [diff] [blame] | 132 | uart_dm_init(8, 0, BLSP2_UART1_BASE); |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 133 | #endif |
| 134 | } |
| 135 | |
| 136 | /* Return 1 if vol_up pressed */ |
Amit Blay | 6a3e88b | 2015-06-23 22:25:06 +0300 | [diff] [blame] | 137 | int target_volume_up() |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 138 | { |
lijuang | 2d2b8a0 | 2015-06-05 21:34:15 +0800 | [diff] [blame] | 139 | static uint8_t first_time = 0; |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 140 | uint8_t status = 0; |
| 141 | struct pm8x41_gpio gpio; |
| 142 | |
lijuang | 2d2b8a0 | 2015-06-05 21:34:15 +0800 | [diff] [blame] | 143 | if (!first_time) { |
| 144 | /* Configure the GPIO */ |
| 145 | gpio.direction = PM_GPIO_DIR_IN; |
| 146 | gpio.function = 0; |
| 147 | gpio.pull = PM_GPIO_PULL_UP_30; |
| 148 | gpio.vin_sel = 2; |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 149 | |
lijuang | 2d2b8a0 | 2015-06-05 21:34:15 +0800 | [diff] [blame] | 150 | pm8x41_gpio_config(2, &gpio); |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 151 | |
lijuang | 2d2b8a0 | 2015-06-05 21:34:15 +0800 | [diff] [blame] | 152 | /* Wait for the pmic gpio config to take effect */ |
| 153 | udelay(10000); |
| 154 | |
| 155 | first_time = 1; |
| 156 | } |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 157 | |
| 158 | /* Get status of P_GPIO_5 */ |
Channagoud Kadabi | 99d2370 | 2015-02-02 20:52:17 -0800 | [diff] [blame] | 159 | pm8x41_gpio_get(2, &status); |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 160 | |
| 161 | return !status; /* active low */ |
| 162 | } |
| 163 | |
| 164 | /* Return 1 if vol_down pressed */ |
| 165 | uint32_t target_volume_down() |
| 166 | { |
| 167 | return pm8x41_resin_status(); |
| 168 | } |
| 169 | |
| 170 | static void target_keystatus() |
| 171 | { |
| 172 | keys_init(); |
| 173 | |
| 174 | if(target_volume_down()) |
| 175 | keys_post_event(KEY_VOLUMEDOWN, 1); |
| 176 | |
| 177 | if(target_volume_up()) |
| 178 | keys_post_event(KEY_VOLUMEUP, 1); |
| 179 | } |
| 180 | |
| 181 | void target_uninit(void) |
| 182 | { |
| 183 | if (platform_boot_dev_isemmc()) |
| 184 | { |
| 185 | mmc_put_card_to_sleep(dev); |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 186 | } |
Channagoud Kadabi | 2bab29b | 2015-02-11 13:26:03 -0800 | [diff] [blame] | 187 | |
Mayank Grover | 77c17d3 | 2017-10-26 12:13:21 +0530 | [diff] [blame] | 188 | if (target_get_vb_version() >= VB_M && |
Mayank Grover | 2995f50 | 2017-09-12 19:19:20 +0530 | [diff] [blame] | 189 | is_sec_app_loaded()) |
Channagoud Kadabi | 2bab29b | 2015-02-11 13:26:03 -0800 | [diff] [blame] | 190 | { |
Sridhar Parasuram | 568e7a6 | 2015-08-06 13:16:02 -0700 | [diff] [blame] | 191 | if (send_milestone_call_to_tz() < 0) |
Channagoud Kadabi | 2bab29b | 2015-02-11 13:26:03 -0800 | [diff] [blame] | 192 | { |
| 193 | dprintf(CRITICAL, "Failed to unload App for rpmb\n"); |
| 194 | ASSERT(0); |
| 195 | } |
| 196 | } |
| 197 | |
Channagoud Kadabi | bb8f1f9 | 2015-04-27 11:14:45 -0700 | [diff] [blame] | 198 | #if ENABLE_WBC |
Channagoud Kadabi | 2216561 | 2015-07-22 14:04:37 -0700 | [diff] [blame] | 199 | if (board_hardware_id() == HW_PLATFORM_MTP) |
| 200 | pm_appsbl_set_dcin_suspend(1); |
Channagoud Kadabi | bb8f1f9 | 2015-04-27 11:14:45 -0700 | [diff] [blame] | 201 | #endif |
| 202 | |
Channagoud Kadabi | 7edb9b4 | 2015-08-11 23:45:31 -0700 | [diff] [blame] | 203 | |
| 204 | if (crypto_initialized()) |
| 205 | { |
| 206 | crypto_eng_cleanup(); |
| 207 | clock_ce_disable(CE_INSTANCE); |
| 208 | } |
| 209 | |
Sridhar Parasuram | 9f28f67 | 2015-03-17 15:40:47 -0700 | [diff] [blame] | 210 | /* Tear down glink channels */ |
| 211 | rpm_glink_uninit(); |
| 212 | |
Mayank Grover | 77c17d3 | 2017-10-26 12:13:21 +0530 | [diff] [blame] | 213 | if (target_get_vb_version() >= VB_M) |
Channagoud Kadabi | 2bab29b | 2015-02-11 13:26:03 -0800 | [diff] [blame] | 214 | { |
Mayank Grover | 2995f50 | 2017-09-12 19:19:20 +0530 | [diff] [blame] | 215 | if (rpmb_uninit() < 0) |
| 216 | { |
| 217 | dprintf(CRITICAL, "RPMB uninit failed\n"); |
| 218 | ASSERT(0); |
| 219 | } |
Channagoud Kadabi | 2bab29b | 2015-02-11 13:26:03 -0800 | [diff] [blame] | 220 | } |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | static void set_sdc_power_ctrl() |
| 224 | { |
Tanya Finkel | 619fc2a | 2016-08-16 14:11:26 +0300 | [diff] [blame] | 225 | uint32_t reg = 0; |
| 226 | uint8_t clk = 0; |
| 227 | uint8_t cmd = 0; |
| 228 | uint8_t dat = 0; |
| 229 | |
| 230 | if (flash_memory_slot == 0x1) |
| 231 | { |
| 232 | clk = TLMM_CUR_VAL_10MA; |
| 233 | cmd = TLMM_CUR_VAL_8MA; |
| 234 | dat = TLMM_CUR_VAL_8MA; |
| 235 | reg = SDC1_HDRV_PULL_CTL; |
| 236 | } |
| 237 | else if (flash_memory_slot == 0x2) |
| 238 | { |
| 239 | clk = TLMM_CUR_VAL_16MA; |
| 240 | cmd = TLMM_CUR_VAL_10MA; |
| 241 | dat = TLMM_CUR_VAL_10MA; |
| 242 | reg = SDC2_HDRV_PULL_CTL; |
| 243 | } |
| 244 | |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 245 | /* Drive strength configs for sdc pins */ |
| 246 | struct tlmm_cfgs sdc1_hdrv_cfg[] = |
| 247 | { |
Tanya Finkel | 619fc2a | 2016-08-16 14:11:26 +0300 | [diff] [blame] | 248 | { SDC1_CLK_HDRV_CTL_OFF, clk, TLMM_HDRV_MASK, reg }, |
| 249 | { SDC1_CMD_HDRV_CTL_OFF, cmd, TLMM_HDRV_MASK, reg }, |
| 250 | { SDC1_DATA_HDRV_CTL_OFF, dat, TLMM_HDRV_MASK, reg }, |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 251 | }; |
| 252 | |
| 253 | /* Pull configs for sdc pins */ |
| 254 | struct tlmm_cfgs sdc1_pull_cfg[] = |
| 255 | { |
Tanya Finkel | 619fc2a | 2016-08-16 14:11:26 +0300 | [diff] [blame] | 256 | { SDC1_CLK_PULL_CTL_OFF, TLMM_NO_PULL, TLMM_PULL_MASK, reg }, |
| 257 | { SDC1_CMD_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK, reg }, |
| 258 | { SDC1_DATA_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK, reg }, |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 259 | }; |
| 260 | |
| 261 | struct tlmm_cfgs sdc1_rclk_cfg[] = |
| 262 | { |
Tanya Finkel | 619fc2a | 2016-08-16 14:11:26 +0300 | [diff] [blame] | 263 | { SDC1_RCLK_PULL_CTL_OFF, TLMM_PULL_DOWN, TLMM_PULL_MASK, reg }, |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 264 | }; |
| 265 | |
| 266 | /* Set the drive strength & pull control values */ |
| 267 | tlmm_set_hdrive_ctrl(sdc1_hdrv_cfg, ARRAY_SIZE(sdc1_hdrv_cfg)); |
| 268 | tlmm_set_pull_ctrl(sdc1_pull_cfg, ARRAY_SIZE(sdc1_pull_cfg)); |
| 269 | tlmm_set_pull_ctrl(sdc1_rclk_cfg, ARRAY_SIZE(sdc1_rclk_cfg)); |
| 270 | } |
| 271 | |
c_wufeng | f433f23 | 2015-09-21 15:21:21 +0800 | [diff] [blame] | 272 | uint32_t target_is_pwrkey_pon_reason() |
| 273 | { |
| 274 | uint8_t pon_reason = pm8950_get_pon_reason(); |
Vijay Kumar Pendoti | e1fff02 | 2016-05-04 13:04:32 +0530 | [diff] [blame] | 275 | |
c_wufeng | f433f23 | 2015-09-21 15:21:21 +0800 | [diff] [blame] | 276 | if (pm8x41_get_is_cold_boot() && ((pon_reason == KPDPWR_N) || (pon_reason == (KPDPWR_N|PON1)))) |
| 277 | return 1; |
Vijay Kumar Pendoti | e1fff02 | 2016-05-04 13:04:32 +0530 | [diff] [blame] | 278 | else if (pon_reason == PON1) |
| 279 | { |
| 280 | /* DC charger is present or USB charger is present */ |
| 281 | if (((USBIN_UV_RT_STS | USBIN_OV_RT_STS) & pm8x41_reg_read(SMBCHG_USB_RT_STS)) == 0 || |
| 282 | ((DCIN_UV_RT_STS | DCIN_OV_RT_STS) & pm8x41_reg_read(SMBCHG_DC_RT_STS)) == 0) |
| 283 | return 0; |
| 284 | else |
| 285 | return 1; |
| 286 | } |
c_wufeng | f433f23 | 2015-09-21 15:21:21 +0800 | [diff] [blame] | 287 | else |
| 288 | return 0; |
| 289 | } |
| 290 | |
| 291 | |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 292 | void target_sdc_init() |
| 293 | { |
| 294 | struct mmc_config_data config = {0}; |
| 295 | |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 296 | config.bus_width = DATA_BUS_WIDTH_8BIT; |
| 297 | config.max_clk_rate = MMC_CLK_192MHZ; |
Channagoud Kadabi | 99d2370 | 2015-02-02 20:52:17 -0800 | [diff] [blame] | 298 | config.hs400_support = 1; |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 299 | |
| 300 | /* Try slot 1*/ |
Tanya Finkel | 619fc2a | 2016-08-16 14:11:26 +0300 | [diff] [blame] | 301 | flash_memory_slot = 1; |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 302 | config.slot = 1; |
| 303 | config.sdhc_base = mmc_sdhci_base[config.slot - 1]; |
| 304 | config.pwrctl_base = mmc_pwrctl_base[config.slot - 1]; |
| 305 | config.pwr_irq = mmc_sdc_pwrctl_irq[config.slot - 1]; |
| 306 | |
Tanya Finkel | 619fc2a | 2016-08-16 14:11:26 +0300 | [diff] [blame] | 307 | /* Set drive strength & pull ctrl values */ |
| 308 | set_sdc_power_ctrl(); |
| 309 | |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 310 | if (!(dev = mmc_init(&config))) |
| 311 | { |
| 312 | /* Try slot 2 */ |
Tanya Finkel | 619fc2a | 2016-08-16 14:11:26 +0300 | [diff] [blame] | 313 | flash_memory_slot = 2; |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 314 | config.slot = 2; |
| 315 | config.max_clk_rate = MMC_CLK_200MHZ; |
| 316 | config.sdhc_base = mmc_sdhci_base[config.slot - 1]; |
| 317 | config.pwrctl_base = mmc_pwrctl_base[config.slot - 1]; |
| 318 | config.pwr_irq = mmc_sdc_pwrctl_irq[config.slot - 1]; |
| 319 | |
Tanya Finkel | 619fc2a | 2016-08-16 14:11:26 +0300 | [diff] [blame] | 320 | /* Set drive strength & pull ctrl values */ |
| 321 | set_sdc_power_ctrl(); |
| 322 | |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 323 | if (!(dev = mmc_init(&config))) |
| 324 | { |
| 325 | dprintf(CRITICAL, "mmc init failed!"); |
| 326 | ASSERT(0); |
| 327 | } |
| 328 | } |
| 329 | } |
| 330 | |
| 331 | void *target_mmc_device() |
| 332 | { |
| 333 | if (platform_boot_dev_isemmc()) |
| 334 | return (void *) dev; |
| 335 | else |
| 336 | return (void *) &ufs_device; |
| 337 | } |
| 338 | |
| 339 | void target_init(void) |
| 340 | { |
| 341 | dprintf(INFO, "target_init()\n"); |
| 342 | |
Sridhar Parasuram | 1d22432 | 2015-06-15 11:03:40 -0700 | [diff] [blame] | 343 | pmic_info_populate(); |
| 344 | |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 345 | spmi_init(PMIC_ARB_CHANNEL_NUM, PMIC_ARB_OWNER_ID); |
| 346 | |
Channagoud Kadabi | bb8f1f9 | 2015-04-27 11:14:45 -0700 | [diff] [blame] | 347 | /* Initialize Glink */ |
| 348 | rpm_glink_init(); |
| 349 | |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 350 | target_keystatus(); |
| 351 | |
c_wufeng | f433f23 | 2015-09-21 15:21:21 +0800 | [diff] [blame] | 352 | #if defined(LONG_PRESS_POWER_ON) || defined(PON_VIB_SUPPORT) |
| 353 | switch(board_hardware_id()) |
| 354 | { |
| 355 | case HW_PLATFORM_QRD: |
| 356 | #if LONG_PRESS_POWER_ON |
| 357 | shutdown_detect(); |
| 358 | #endif |
c_wufeng | 196210d | 2015-09-21 12:49:43 +0800 | [diff] [blame] | 359 | #if PON_VIB_SUPPORT |
| 360 | vib_timed_turn_on(VIBRATE_TIME); |
| 361 | #endif |
c_wufeng | f433f23 | 2015-09-21 15:21:21 +0800 | [diff] [blame] | 362 | break; |
| 363 | } |
| 364 | #endif |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 365 | |
| 366 | if (target_use_signed_kernel()) |
| 367 | target_crypto_init_params(); |
| 368 | |
| 369 | platform_read_boot_config(); |
| 370 | |
Sridhar Parasuram | 50b9d96 | 2015-02-12 11:28:09 -0800 | [diff] [blame] | 371 | #ifdef MMC_SDHCI_SUPPORT |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 372 | if (platform_boot_dev_isemmc()) |
| 373 | { |
| 374 | target_sdc_init(); |
| 375 | } |
Sridhar Parasuram | 50b9d96 | 2015-02-12 11:28:09 -0800 | [diff] [blame] | 376 | #endif |
| 377 | #ifdef UFS_SUPPORT |
| 378 | if (!platform_boot_dev_isemmc()) |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 379 | { |
| 380 | ufs_device.base = UFS_BASE; |
| 381 | ufs_init(&ufs_device); |
| 382 | } |
Sridhar Parasuram | 50b9d96 | 2015-02-12 11:28:09 -0800 | [diff] [blame] | 383 | #endif |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 384 | |
| 385 | /* Storage initialization is complete, read the partition table info */ |
Channagoud Kadabi | 58a273b | 2015-02-10 12:56:22 -0800 | [diff] [blame] | 386 | mmc_read_partition_table(0); |
Channagoud Kadabi | 2bab29b | 2015-02-11 13:26:03 -0800 | [diff] [blame] | 387 | |
Channagoud Kadabi | 1171d8d | 2015-07-30 19:12:44 -0700 | [diff] [blame] | 388 | #if ENABLE_WBC |
| 389 | /* Look for battery voltage and make sure we have enough to bootup |
| 390 | * Otherwise initiate battery charging |
| 391 | * Charging should happen as early as possible, any other driver |
| 392 | * initialization before this should consider the power impact |
| 393 | */ |
Channagoud Kadabi | 25fd8ce | 2015-08-19 14:45:08 -0700 | [diff] [blame] | 394 | switch(board_hardware_id()) |
| 395 | { |
| 396 | case HW_PLATFORM_MTP: |
| 397 | case HW_PLATFORM_FLUID: |
lijuang | 0e98add | 2015-11-10 10:40:27 +0800 | [diff] [blame] | 398 | case HW_PLATFORM_QRD: |
Parth Dixit | 550ddf3 | 2016-11-28 17:00:29 +0530 | [diff] [blame] | 399 | if(target_is_pmi_enabled()) |
| 400 | pm_appsbl_chg_check_weak_battery_status(1); |
Channagoud Kadabi | 25fd8ce | 2015-08-19 14:45:08 -0700 | [diff] [blame] | 401 | break; |
| 402 | default: |
| 403 | /* Charging not supported */ |
| 404 | break; |
| 405 | }; |
Channagoud Kadabi | 1171d8d | 2015-07-30 19:12:44 -0700 | [diff] [blame] | 406 | #endif |
| 407 | |
Mayank Grover | 77c17d3 | 2017-10-26 12:13:21 +0530 | [diff] [blame] | 408 | if (VB_M <= target_get_vb_version()) |
Sridhar Parasuram | 568e7a6 | 2015-08-06 13:16:02 -0700 | [diff] [blame] | 409 | { |
Mayank Grover | 2995f50 | 2017-09-12 19:19:20 +0530 | [diff] [blame] | 410 | /* Initialize Qseecom */ |
| 411 | if (qseecom_init() < 0) |
| 412 | { |
| 413 | dprintf(CRITICAL, "Failed to initialize qseecom\n"); |
| 414 | ASSERT(0); |
| 415 | } |
Sridhar Parasuram | 568e7a6 | 2015-08-06 13:16:02 -0700 | [diff] [blame] | 416 | |
Mayank Grover | 2995f50 | 2017-09-12 19:19:20 +0530 | [diff] [blame] | 417 | /* Start Qseecom */ |
| 418 | if (qseecom_tz_init() < 0) |
| 419 | { |
| 420 | dprintf(CRITICAL, "Failed to start qseecom\n"); |
| 421 | ASSERT(0); |
| 422 | } |
Sridhar Parasuram | 568e7a6 | 2015-08-06 13:16:02 -0700 | [diff] [blame] | 423 | |
Mayank Grover | 2995f50 | 2017-09-12 19:19:20 +0530 | [diff] [blame] | 424 | if (rpmb_init() < 0) |
| 425 | { |
| 426 | dprintf(CRITICAL, "RPMB init failed\n"); |
| 427 | ASSERT(0); |
| 428 | } |
Sridhar Parasuram | 568e7a6 | 2015-08-06 13:16:02 -0700 | [diff] [blame] | 429 | |
Mayank Grover | 2995f50 | 2017-09-12 19:19:20 +0530 | [diff] [blame] | 430 | /* |
| 431 | * Load the sec app for first time |
| 432 | */ |
| 433 | if (load_sec_app() < 0) |
| 434 | { |
| 435 | dprintf(CRITICAL, "Failed to load App for verified\n"); |
| 436 | ASSERT(0); |
| 437 | } |
Sridhar Parasuram | c61ecc2 | 2015-09-22 13:53:31 -0700 | [diff] [blame] | 438 | } |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 439 | } |
| 440 | |
| 441 | unsigned board_machtype(void) |
| 442 | { |
| 443 | return LINUX_MACHTYPE_UNKNOWN; |
| 444 | } |
| 445 | |
| 446 | /* Detect the target type */ |
| 447 | void target_detect(struct board_data *board) |
| 448 | { |
| 449 | /* This is filled from board.c */ |
| 450 | } |
| 451 | |
Dhaval Patel | b95039c | 2015-03-16 11:14:06 -0700 | [diff] [blame] | 452 | static uint8_t splash_override; |
| 453 | /* Returns 1 if target supports continuous splash screen. */ |
| 454 | int target_cont_splash_screen() |
| 455 | { |
| 456 | uint8_t splash_screen = 0; |
Channagoud Kadabi | 25fd8ce | 2015-08-19 14:45:08 -0700 | [diff] [blame] | 457 | if(!splash_override && !pm_appsbl_charging_in_progress()) { |
Dhaval Patel | b95039c | 2015-03-16 11:14:06 -0700 | [diff] [blame] | 458 | switch(board_hardware_id()) |
| 459 | { |
| 460 | case HW_PLATFORM_SURF: |
| 461 | case HW_PLATFORM_MTP: |
| 462 | case HW_PLATFORM_FLUID: |
feifanz | 76fe648 | 2015-09-02 15:25:16 +0800 | [diff] [blame] | 463 | case HW_PLATFORM_QRD: |
Kuogee Hsieh | b976dfc | 2015-08-28 13:21:30 -0700 | [diff] [blame] | 464 | case HW_PLATFORM_LIQUID: |
Siddharth Zaveri | acaacc3 | 2015-12-12 15:10:33 -0500 | [diff] [blame] | 465 | case HW_PLATFORM_DRAGON: |
| 466 | case HW_PLATFORM_ADP: |
Dhaval Patel | b95039c | 2015-03-16 11:14:06 -0700 | [diff] [blame] | 467 | dprintf(SPEW, "Target_cont_splash=1\n"); |
| 468 | splash_screen = 1; |
| 469 | break; |
| 470 | default: |
| 471 | dprintf(SPEW, "Target_cont_splash=0\n"); |
| 472 | splash_screen = 0; |
| 473 | } |
| 474 | } |
| 475 | return splash_screen; |
| 476 | } |
| 477 | |
| 478 | void target_force_cont_splash_disable(uint8_t override) |
| 479 | { |
| 480 | splash_override = override; |
| 481 | } |
| 482 | |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 483 | /* Detect the modem type */ |
| 484 | void target_baseband_detect(struct board_data *board) |
| 485 | { |
| 486 | uint32_t platform; |
Channagoud Kadabi | 4021fa9 | 2015-11-03 16:35:26 -0800 | [diff] [blame] | 487 | uint32_t platform_hardware; |
| 488 | uint32_t platform_subtype; |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 489 | |
| 490 | platform = board->platform; |
Channagoud Kadabi | 4021fa9 | 2015-11-03 16:35:26 -0800 | [diff] [blame] | 491 | platform_hardware = board->platform_hw; |
| 492 | platform_subtype = board->platform_subtype; |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 493 | |
Channagoud Kadabi | 4021fa9 | 2015-11-03 16:35:26 -0800 | [diff] [blame] | 494 | if (platform_hardware == HW_PLATFORM_SURF) |
| 495 | { |
| 496 | if (platform_subtype == FUSION_I2S_CDP) |
| 497 | board->baseband = BASEBAND_MDM; |
| 498 | } |
| 499 | else if (platform_hardware == HW_PLATFORM_MTP) |
| 500 | { |
| 501 | if (platform_subtype == FUSION_I2S_MTP || |
| 502 | platform_subtype == FUSION_SLIMBUS) |
| 503 | board->baseband = BASEBAND_MDM; |
| 504 | } |
| 505 | /* |
| 506 | * Special case if MDM is not set look for chip info to decide |
| 507 | * platform subtype |
| 508 | */ |
| 509 | if (board->baseband != BASEBAND_MDM) |
| 510 | { |
| 511 | switch(platform) { |
| 512 | case APQ8096: |
Channagoud Kadabi | ee2b65e | 2016-01-11 19:10:29 -0800 | [diff] [blame] | 513 | case APQ8096AU: |
| 514 | case APQ8096SG: |
Channagoud Kadabi | 99d2370 | 2015-02-02 20:52:17 -0800 | [diff] [blame] | 515 | board->baseband = BASEBAND_APQ; |
Channagoud Kadabi | 4021fa9 | 2015-11-03 16:35:26 -0800 | [diff] [blame] | 516 | break; |
| 517 | case MSM8996: |
Channagoud Kadabi | ee2b65e | 2016-01-11 19:10:29 -0800 | [diff] [blame] | 518 | case MSM8996SG: |
| 519 | case MSM8996AU: |
| 520 | case MSM8996L: |
| 521 | board->baseband = BASEBAND_MSM; |
Channagoud Kadabi | 4021fa9 | 2015-11-03 16:35:26 -0800 | [diff] [blame] | 522 | break; |
| 523 | default: |
| 524 | dprintf(CRITICAL, "Platform type: %u is not supported\n",platform); |
| 525 | ASSERT(0); |
| 526 | }; |
| 527 | } |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 528 | } |
Channagoud Kadabi | 4021fa9 | 2015-11-03 16:35:26 -0800 | [diff] [blame] | 529 | |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 530 | unsigned target_baseband() |
| 531 | { |
| 532 | return board_baseband(); |
| 533 | } |
| 534 | |
| 535 | void target_serialno(unsigned char *buf) |
| 536 | { |
| 537 | unsigned int serialno; |
| 538 | if (target_is_emmc_boot()) { |
| 539 | serialno = mmc_get_psn(); |
| 540 | snprintf((char *)buf, 13, "%x", serialno); |
| 541 | } |
| 542 | } |
| 543 | |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 544 | int emmc_recovery_init(void) |
| 545 | { |
| 546 | return _emmc_recovery_init(); |
| 547 | } |
| 548 | |
| 549 | void target_usb_phy_reset() |
| 550 | { |
| 551 | usb30_qmp_phy_reset(); |
| 552 | qusb2_phy_reset(); |
| 553 | } |
| 554 | |
Tanya Finkel | 77318e0 | 2016-05-17 14:20:59 +0300 | [diff] [blame] | 555 | void target_usb_phy_sec_reset() |
| 556 | { |
| 557 | qusb2_phy_reset(); |
| 558 | } |
| 559 | |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 560 | target_usb_iface_t* target_usb30_init() |
| 561 | { |
| 562 | target_usb_iface_t *t_usb_iface; |
| 563 | |
| 564 | t_usb_iface = calloc(1, sizeof(target_usb_iface_t)); |
| 565 | ASSERT(t_usb_iface); |
| 566 | |
Tanya Finkel | 77318e0 | 2016-05-17 14:20:59 +0300 | [diff] [blame] | 567 | |
| 568 | /* for SBC we use secondary port */ |
| 569 | if (board_hardware_id() == HW_PLATFORM_SBC) |
| 570 | { |
| 571 | /* secondary port have no QMP phy,use only QUSB2 phy that have only reset */ |
| 572 | t_usb_iface->phy_init = NULL; |
| 573 | t_usb_iface->phy_reset = target_usb_phy_sec_reset; |
| 574 | t_usb_iface->clock_init = clock_usb20_init; |
| 575 | } else { |
| 576 | t_usb_iface->phy_init = usb30_qmp_phy_init; |
| 577 | t_usb_iface->phy_reset = target_usb_phy_reset; |
| 578 | t_usb_iface->clock_init = clock_usb30_init; |
| 579 | } |
| 580 | |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 581 | t_usb_iface->vbus_override = 1; |
| 582 | |
| 583 | return t_usb_iface; |
| 584 | } |
| 585 | |
| 586 | /* identify the usb controller to be used for the target */ |
| 587 | const char * target_usb_controller() |
| 588 | { |
| 589 | return "dwc"; |
| 590 | } |
| 591 | |
| 592 | uint32_t target_override_pll() |
| 593 | { |
Channagoud Kadabi | 1e5144b | 2015-04-28 17:15:05 -0700 | [diff] [blame] | 594 | if (board_soc_version() >= 0x20000) |
| 595 | return 0; |
| 596 | else |
| 597 | return 1; |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 598 | } |
| 599 | |
Channagoud Kadabi | 4a870cf | 2015-01-21 10:39:01 -0800 | [diff] [blame] | 600 | crypto_engine_type board_ce_type(void) |
| 601 | { |
Channagoud Kadabi | 7edb9b4 | 2015-08-11 23:45:31 -0700 | [diff] [blame] | 602 | return CRYPTO_ENGINE_TYPE_HW; |
Channagoud Kadabi | 4a870cf | 2015-01-21 10:39:01 -0800 | [diff] [blame] | 603 | } |
| 604 | |
| 605 | /* Set up params for h/w CE. */ |
| 606 | void target_crypto_init_params() |
| 607 | { |
| 608 | struct crypto_init_params ce_params; |
| 609 | |
| 610 | /* Set up base addresses and instance. */ |
| 611 | ce_params.crypto_instance = CE_INSTANCE; |
| 612 | ce_params.crypto_base = MSM_CE_BASE; |
| 613 | ce_params.bam_base = MSM_CE_BAM_BASE; |
| 614 | |
| 615 | /* Set up BAM config. */ |
| 616 | ce_params.bam_ee = CE_EE; |
| 617 | ce_params.pipes.read_pipe = CE_READ_PIPE; |
| 618 | ce_params.pipes.write_pipe = CE_WRITE_PIPE; |
| 619 | ce_params.pipes.read_pipe_grp = CE_READ_PIPE_LOCK_GRP; |
| 620 | ce_params.pipes.write_pipe_grp = CE_WRITE_PIPE_LOCK_GRP; |
| 621 | |
| 622 | /* Assign buffer sizes. */ |
| 623 | ce_params.num_ce = CE_ARRAY_SIZE; |
| 624 | ce_params.read_fifo_size = CE_FIFO_SIZE; |
| 625 | ce_params.write_fifo_size = CE_FIFO_SIZE; |
| 626 | |
| 627 | /* BAM is initialized by TZ for this platform. |
| 628 | * Do not do it again as the initialization address space |
| 629 | * is locked. |
| 630 | */ |
| 631 | ce_params.do_bam_init = 0; |
| 632 | |
| 633 | crypto_init_params(&ce_params); |
| 634 | } |
Channagoud Kadabi | 083290f | 2015-03-13 14:18:38 -0700 | [diff] [blame] | 635 | |
| 636 | unsigned target_pause_for_battery_charge(void) |
| 637 | { |
| 638 | uint8_t pon_reason = pm8x41_get_pon_reason(); |
| 639 | uint8_t is_cold_boot = pm8x41_get_is_cold_boot(); |
Channagoud Kadabi | 9b28c0b | 2016-01-11 18:42:33 -0800 | [diff] [blame] | 640 | pm_smbchg_usb_chgpth_pwr_pth_type charger_path = PM_SMBCHG_USB_CHGPTH_PWR_PATH__INVALID; |
| 641 | dprintf(INFO, "%s : pon_reason is %d cold_boot:%d charger path: %d\n", __func__, |
| 642 | pon_reason, is_cold_boot, charger_path); |
Channagoud Kadabi | 083290f | 2015-03-13 14:18:38 -0700 | [diff] [blame] | 643 | /* In case of fastboot reboot,adb reboot or if we see the power key |
| 644 | * pressed we do not want go into charger mode. |
| 645 | * fastboot reboot is warm boot with PON hard reset bit not set |
| 646 | * adb reboot is a cold boot with PON hard reset bit set |
| 647 | */ |
Channagoud Kadabi | 9b28c0b | 2016-01-11 18:42:33 -0800 | [diff] [blame] | 648 | pm_smbchg_get_charger_path(1, &charger_path); |
Channagoud Kadabi | 083290f | 2015-03-13 14:18:38 -0700 | [diff] [blame] | 649 | if (is_cold_boot && |
| 650 | (!(pon_reason & HARD_RST)) && |
| 651 | (!(pon_reason & KPDPWR_N)) && |
Channagoud Kadabi | 9b28c0b | 2016-01-11 18:42:33 -0800 | [diff] [blame] | 652 | ((pon_reason & PON1)) && |
| 653 | ((charger_path == PM_SMBCHG_USB_CHGPTH_PWR_PATH__DC_CHARGER) || |
| 654 | (charger_path == PM_SMBCHG_USB_CHGPTH_PWR_PATH__USB_CHARGER))) |
| 655 | |
Channagoud Kadabi | 083290f | 2015-03-13 14:18:38 -0700 | [diff] [blame] | 656 | return 1; |
| 657 | else |
| 658 | return 0; |
| 659 | } |
Channagoud Kadabi | 23edc0c | 2015-03-27 18:31:32 -0700 | [diff] [blame] | 660 | |
lijuang | 395b5e6 | 2015-11-19 17:39:44 +0800 | [diff] [blame] | 661 | int set_download_mode(enum reboot_reason mode) |
Channagoud Kadabi | 23edc0c | 2015-03-27 18:31:32 -0700 | [diff] [blame] | 662 | { |
| 663 | int ret = 0; |
| 664 | ret = scm_dload_mode(mode); |
| 665 | |
| 666 | return ret; |
| 667 | } |
Channagoud Kadabi | ffc4b90 | 2015-06-25 23:14:27 -0700 | [diff] [blame] | 668 | |
Channagoud Kadabi | 65b518d | 2015-08-05 16:17:14 -0700 | [diff] [blame] | 669 | void pmic_reset_configure(uint8_t reset_type) |
Channagoud Kadabi | ffc4b90 | 2015-06-25 23:14:27 -0700 | [diff] [blame] | 670 | { |
Vamshi Krishna B V | 49ffb8d | 2018-03-07 12:56:27 +0530 | [diff] [blame] | 671 | uint8_t sec_pmic_reset_type = reset_type; |
| 672 | |
| 673 | /* use shutdown for non-core pmic's on hard_reset */ |
| 674 | if (reset_type == PON_PSHOLD_HARD_RESET) |
| 675 | sec_pmic_reset_type = PON_PSHOLD_SHUTDOWN; |
| 676 | |
| 677 | /* Confiure primary pmic PM8996 */ |
| 678 | pm8996_reset_configure(0, reset_type); |
| 679 | |
| 680 | /* Confiure secondary pmic PMI8996 */ |
| 681 | pm8996_reset_configure(2, sec_pmic_reset_type); |
| 682 | |
| 683 | /* Check if third pmic PM8004 present */ |
| 684 | if ((board_pmic_target(2) & 0xff) == 0xC) |
| 685 | { |
| 686 | /* Confiure PM8004 */ |
| 687 | pm8996_reset_configure(4, reset_type); |
| 688 | |
| 689 | /* Check if fourth pmic PMK8001 present */ |
| 690 | if ((board_pmic_target(3) & 0xff) == 0x12) |
| 691 | pm8996_reset_configure(6, sec_pmic_reset_type); |
| 692 | } |
| 693 | else if ((board_pmic_target(2) & 0xff) == 0x12) |
| 694 | { |
| 695 | /* check and configure if third pmic is PMK8001 */ |
| 696 | pm8996_reset_configure(6, sec_pmic_reset_type); |
| 697 | } |
Channagoud Kadabi | ffc4b90 | 2015-06-25 23:14:27 -0700 | [diff] [blame] | 698 | } |
lijuang | 3606df8 | 2015-09-02 21:14:43 +0800 | [diff] [blame] | 699 | |
| 700 | uint32_t target_get_pmic() |
| 701 | { |
| 702 | return PMIC_IS_PMI8996; |
| 703 | } |
Channagoud Kadabi | 85c7ec3 | 2016-01-28 23:09:21 -0800 | [diff] [blame] | 704 | |
| 705 | int target_update_cmdline(char *cmdline) |
| 706 | { |
| 707 | uint32_t platform_id = board_platform_id(); |
| 708 | int len = 0; |
| 709 | if (platform_id == APQ8096SG || platform_id == MSM8996SG) |
| 710 | { |
| 711 | strlcpy(cmdline, " fpsimd.fpsimd_settings=0", TARGET_MAX_CMDLNBUF); |
| 712 | len = strlen (cmdline); |
Prasad Sodagudi | d76d180 | 2016-05-03 23:18:14 +0530 | [diff] [blame] | 713 | |
| 714 | /* App settings are not required for other than v1.0 SoC */ |
| 715 | if (board_soc_version() > 0x10000) { |
| 716 | strlcpy(cmdline + len, " app_setting.use_app_setting=0", TARGET_MAX_CMDLNBUF - len); |
| 717 | len = strlen (cmdline); |
| 718 | } |
Channagoud Kadabi | 85c7ec3 | 2016-01-28 23:09:21 -0800 | [diff] [blame] | 719 | } |
| 720 | |
| 721 | return len; |
| 722 | } |
anisha agarwal | ebc52bc | 2016-07-08 15:50:00 -0700 | [diff] [blame] | 723 | |
| 724 | #if _APPEND_CMDLINE |
| 725 | int get_target_boot_params(const char *cmdline, const char *part, char **buf) |
| 726 | { |
| 727 | int system_ptn_index = -1; |
| 728 | unsigned int lun = 0; |
| 729 | char lun_char_base = 'a', lun_char_limit = 'h'; |
| 730 | |
| 731 | /*allocate buflen for largest possible string*/ |
zhaochen | ed3bdfb | 2018-02-06 19:09:17 +0800 | [diff] [blame] | 732 | uint32_t buflen = strlen(ROOTFS_EMMC_PATH) + sizeof(int) + 1; /*1 character for null termination*/ |
anisha agarwal | ebc52bc | 2016-07-08 15:50:00 -0700 | [diff] [blame] | 733 | |
| 734 | if (!cmdline || !part ) { |
| 735 | dprintf(CRITICAL, "WARN: Invalid input param\n"); |
| 736 | return -1; |
| 737 | } |
| 738 | |
| 739 | system_ptn_index = partition_get_index(part); |
| 740 | if (system_ptn_index == -1) |
| 741 | { |
| 742 | dprintf(CRITICAL,"Unable to find partition %s\n",part); |
| 743 | return -1; |
| 744 | } |
| 745 | |
| 746 | *buf = (char *)malloc(buflen); |
| 747 | if(!(*buf)) { |
| 748 | dprintf(CRITICAL,"Unable to allocate memory for boot params\n"); |
| 749 | return -1; |
| 750 | } |
| 751 | |
| 752 | /* |
| 753 | * check if cmdline contains "root="/"" at the beginning of buffer or |
| 754 | * " root="/"ubi.mtd" in the middle of buffer. |
| 755 | */ |
| 756 | if ((strncmp(cmdline," root=",strlen(" root=")) == 0) || |
| 757 | strstr(cmdline, " root=")) |
| 758 | dprintf(DEBUG, "DEBUG: cmdline has root=\n"); |
| 759 | else |
| 760 | { |
| 761 | if (platform_boot_dev_isemmc()) { |
zhaochen | ed3bdfb | 2018-02-06 19:09:17 +0800 | [diff] [blame] | 762 | snprintf(*buf, buflen, ROOTFS_EMMC_PATH"%d", |
anisha agarwal | ebc52bc | 2016-07-08 15:50:00 -0700 | [diff] [blame] | 763 | system_ptn_index + 1); |
| 764 | } else { |
| 765 | lun = partition_get_lun(system_ptn_index); |
| 766 | if ((lun_char_base + lun) > lun_char_limit) { |
| 767 | dprintf(CRITICAL, "lun value exceeds limit\n"); |
| 768 | return -1; |
| 769 | } |
| 770 | snprintf(*buf, buflen, " root=/dev/sd%c%d", |
| 771 | lun_char_base + lun, |
| 772 | partition_get_index_in_lun(part, lun)); |
| 773 | } |
| 774 | } |
| 775 | /*in success case buf will be freed in the calling function of this*/ |
| 776 | return 0; |
| 777 | } |
| 778 | #endif |