Channagoud Kadabi | f8ad8e7 | 2015-01-06 15:10:13 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2014-2015 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 |
| 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 <platform/irqs.h> |
| 32 | #include <platform/gpio.h> |
| 33 | #include <reg.h> |
| 34 | #include <target.h> |
| 35 | #include <platform.h> |
| 36 | #include <dload_util.h> |
| 37 | #include <uart_dm.h> |
| 38 | #include <mmc.h> |
| 39 | #include <spmi.h> |
| 40 | #include <board.h> |
| 41 | #include <smem.h> |
| 42 | #include <baseband.h> |
Sridhar Parasuram | d75ade5 | 2015-03-09 15:45:16 -0700 | [diff] [blame] | 43 | #include <regulator.h> |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 44 | #include <dev/keys.h> |
| 45 | #include <pm8x41.h> |
| 46 | #include <crypto5_wrapper.h> |
| 47 | #include <clock.h> |
| 48 | #include <partition_parser.h> |
| 49 | #include <scm.h> |
| 50 | #include <platform/clock.h> |
| 51 | #include <platform/gpio.h> |
| 52 | #include <platform/timer.h> |
| 53 | #include <stdlib.h> |
| 54 | #include <ufs.h> |
| 55 | #include <boot_device.h> |
| 56 | #include <qmp_phy.h> |
Channagoud Kadabi | 7d30820 | 2014-12-22 12:07:04 -0800 | [diff] [blame] | 57 | #include <sdhci_msm.h> |
| 58 | #include <qusb2_phy.h> |
Channagoud Kadabi | 2bab29b | 2015-02-11 13:26:03 -0800 | [diff] [blame] | 59 | #include <rpmb.h> |
Sridhar Parasuram | 9f28f67 | 2015-03-17 15:40:47 -0700 | [diff] [blame] | 60 | #include <rpm-glink.h> |
Channagoud Kadabi | bb8f1f9 | 2015-04-27 11:14:45 -0700 | [diff] [blame] | 61 | #if ENABLE_WBC |
| 62 | #include <pm_app_smbchg.h> |
| 63 | #endif |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 64 | |
Channagoud Kadabi | 4a870cf | 2015-01-21 10:39:01 -0800 | [diff] [blame] | 65 | #define CE_INSTANCE 1 |
Channagoud Kadabi | 7edb9b4 | 2015-08-11 23:45:31 -0700 | [diff] [blame] | 66 | #define CE_EE 0 |
Channagoud Kadabi | 4a870cf | 2015-01-21 10:39:01 -0800 | [diff] [blame] | 67 | #define CE_FIFO_SIZE 64 |
| 68 | #define CE_READ_PIPE 3 |
| 69 | #define CE_WRITE_PIPE 2 |
| 70 | #define CE_READ_PIPE_LOCK_GRP 0 |
| 71 | #define CE_WRITE_PIPE_LOCK_GRP 0 |
| 72 | #define CE_ARRAY_SIZE 20 |
| 73 | |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 74 | #define PMIC_ARB_CHANNEL_NUM 0 |
| 75 | #define PMIC_ARB_OWNER_ID 0 |
| 76 | |
| 77 | static void set_sdc_power_ctrl(void); |
| 78 | static uint32_t mmc_pwrctl_base[] = |
| 79 | { MSM_SDC1_BASE, MSM_SDC2_BASE }; |
| 80 | |
| 81 | static uint32_t mmc_sdhci_base[] = |
| 82 | { MSM_SDC1_SDHCI_BASE, MSM_SDC2_SDHCI_BASE }; |
| 83 | |
| 84 | static uint32_t mmc_sdc_pwrctl_irq[] = |
| 85 | { SDCC1_PWRCTL_IRQ, SDCC2_PWRCTL_IRQ }; |
| 86 | |
| 87 | struct mmc_device *dev; |
| 88 | struct ufs_dev ufs_device; |
| 89 | |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 90 | void target_early_init(void) |
| 91 | { |
| 92 | #if WITH_DEBUG_UART |
Channagoud Kadabi | 35503c4 | 2014-11-14 16:22:43 -0800 | [diff] [blame] | 93 | uart_dm_init(8, 0, BLSP2_UART1_BASE); |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 94 | #endif |
| 95 | } |
| 96 | |
| 97 | /* Return 1 if vol_up pressed */ |
Amit Blay | 6a3e88b | 2015-06-23 22:25:06 +0300 | [diff] [blame] | 98 | int target_volume_up() |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 99 | { |
| 100 | uint8_t status = 0; |
| 101 | struct pm8x41_gpio gpio; |
| 102 | |
| 103 | /* Configure the GPIO */ |
| 104 | gpio.direction = PM_GPIO_DIR_IN; |
| 105 | gpio.function = 0; |
| 106 | gpio.pull = PM_GPIO_PULL_UP_30; |
| 107 | gpio.vin_sel = 2; |
| 108 | |
| 109 | pm8x41_gpio_config(2, &gpio); |
| 110 | |
| 111 | /* Wait for the pmic gpio config to take effect */ |
| 112 | thread_sleep(1); |
| 113 | |
| 114 | /* Get status of P_GPIO_5 */ |
Channagoud Kadabi | 99d2370 | 2015-02-02 20:52:17 -0800 | [diff] [blame] | 115 | pm8x41_gpio_get(2, &status); |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 116 | |
| 117 | return !status; /* active low */ |
| 118 | } |
| 119 | |
| 120 | /* Return 1 if vol_down pressed */ |
| 121 | uint32_t target_volume_down() |
| 122 | { |
| 123 | return pm8x41_resin_status(); |
| 124 | } |
| 125 | |
| 126 | static void target_keystatus() |
| 127 | { |
| 128 | keys_init(); |
| 129 | |
| 130 | if(target_volume_down()) |
| 131 | keys_post_event(KEY_VOLUMEDOWN, 1); |
| 132 | |
| 133 | if(target_volume_up()) |
| 134 | keys_post_event(KEY_VOLUMEUP, 1); |
| 135 | } |
| 136 | |
| 137 | void target_uninit(void) |
| 138 | { |
| 139 | if (platform_boot_dev_isemmc()) |
| 140 | { |
| 141 | mmc_put_card_to_sleep(dev); |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 142 | } |
Channagoud Kadabi | 2bab29b | 2015-02-11 13:26:03 -0800 | [diff] [blame] | 143 | |
| 144 | if (is_sec_app_loaded()) |
| 145 | { |
| 146 | if (unload_sec_app() < 0) |
| 147 | { |
| 148 | dprintf(CRITICAL, "Failed to unload App for rpmb\n"); |
| 149 | ASSERT(0); |
| 150 | } |
| 151 | } |
| 152 | |
Channagoud Kadabi | bb8f1f9 | 2015-04-27 11:14:45 -0700 | [diff] [blame] | 153 | #if ENABLE_WBC |
Channagoud Kadabi | 2216561 | 2015-07-22 14:04:37 -0700 | [diff] [blame] | 154 | if (board_hardware_id() == HW_PLATFORM_MTP) |
| 155 | pm_appsbl_set_dcin_suspend(1); |
Channagoud Kadabi | bb8f1f9 | 2015-04-27 11:14:45 -0700 | [diff] [blame] | 156 | #endif |
| 157 | |
Channagoud Kadabi | 7edb9b4 | 2015-08-11 23:45:31 -0700 | [diff] [blame] | 158 | |
| 159 | if (crypto_initialized()) |
| 160 | { |
| 161 | crypto_eng_cleanup(); |
| 162 | clock_ce_disable(CE_INSTANCE); |
| 163 | } |
| 164 | |
Sridhar Parasuram | 9f28f67 | 2015-03-17 15:40:47 -0700 | [diff] [blame] | 165 | /* Tear down glink channels */ |
| 166 | rpm_glink_uninit(); |
| 167 | |
Channagoud Kadabi | 2bab29b | 2015-02-11 13:26:03 -0800 | [diff] [blame] | 168 | if (rpmb_uninit() < 0) |
| 169 | { |
| 170 | dprintf(CRITICAL, "RPMB uninit failed\n"); |
| 171 | ASSERT(0); |
| 172 | } |
| 173 | |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 174 | } |
| 175 | |
| 176 | static void set_sdc_power_ctrl() |
| 177 | { |
| 178 | /* Drive strength configs for sdc pins */ |
| 179 | struct tlmm_cfgs sdc1_hdrv_cfg[] = |
| 180 | { |
| 181 | { SDC1_CLK_HDRV_CTL_OFF, TLMM_CUR_VAL_16MA, TLMM_HDRV_MASK, SDC1_HDRV_PULL_CTL }, |
| 182 | { SDC1_CMD_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK, SDC1_HDRV_PULL_CTL }, |
| 183 | { SDC1_DATA_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK, SDC1_HDRV_PULL_CTL }, |
| 184 | }; |
| 185 | |
| 186 | /* Pull configs for sdc pins */ |
| 187 | struct tlmm_cfgs sdc1_pull_cfg[] = |
| 188 | { |
| 189 | { SDC1_CLK_PULL_CTL_OFF, TLMM_NO_PULL, TLMM_PULL_MASK, SDC1_HDRV_PULL_CTL }, |
| 190 | { SDC1_CMD_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK, SDC1_HDRV_PULL_CTL }, |
| 191 | { SDC1_DATA_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK, SDC1_HDRV_PULL_CTL }, |
| 192 | }; |
| 193 | |
| 194 | struct tlmm_cfgs sdc1_rclk_cfg[] = |
| 195 | { |
| 196 | { SDC1_RCLK_PULL_CTL_OFF, TLMM_PULL_DOWN, TLMM_PULL_MASK, SDC1_HDRV_PULL_CTL }, |
| 197 | }; |
| 198 | |
| 199 | /* Set the drive strength & pull control values */ |
| 200 | tlmm_set_hdrive_ctrl(sdc1_hdrv_cfg, ARRAY_SIZE(sdc1_hdrv_cfg)); |
| 201 | tlmm_set_pull_ctrl(sdc1_pull_cfg, ARRAY_SIZE(sdc1_pull_cfg)); |
| 202 | tlmm_set_pull_ctrl(sdc1_rclk_cfg, ARRAY_SIZE(sdc1_rclk_cfg)); |
| 203 | } |
| 204 | |
| 205 | void target_sdc_init() |
| 206 | { |
| 207 | struct mmc_config_data config = {0}; |
| 208 | |
| 209 | /* Set drive strength & pull ctrl values */ |
| 210 | set_sdc_power_ctrl(); |
| 211 | |
| 212 | config.bus_width = DATA_BUS_WIDTH_8BIT; |
| 213 | config.max_clk_rate = MMC_CLK_192MHZ; |
Channagoud Kadabi | 99d2370 | 2015-02-02 20:52:17 -0800 | [diff] [blame] | 214 | config.hs400_support = 1; |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 215 | |
| 216 | /* Try slot 1*/ |
| 217 | config.slot = 1; |
| 218 | config.sdhc_base = mmc_sdhci_base[config.slot - 1]; |
| 219 | config.pwrctl_base = mmc_pwrctl_base[config.slot - 1]; |
| 220 | config.pwr_irq = mmc_sdc_pwrctl_irq[config.slot - 1]; |
| 221 | |
| 222 | if (!(dev = mmc_init(&config))) |
| 223 | { |
| 224 | /* Try slot 2 */ |
| 225 | config.slot = 2; |
| 226 | config.max_clk_rate = MMC_CLK_200MHZ; |
| 227 | config.sdhc_base = mmc_sdhci_base[config.slot - 1]; |
| 228 | config.pwrctl_base = mmc_pwrctl_base[config.slot - 1]; |
| 229 | config.pwr_irq = mmc_sdc_pwrctl_irq[config.slot - 1]; |
| 230 | |
| 231 | if (!(dev = mmc_init(&config))) |
| 232 | { |
| 233 | dprintf(CRITICAL, "mmc init failed!"); |
| 234 | ASSERT(0); |
| 235 | } |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | void *target_mmc_device() |
| 240 | { |
| 241 | if (platform_boot_dev_isemmc()) |
| 242 | return (void *) dev; |
| 243 | else |
| 244 | return (void *) &ufs_device; |
| 245 | } |
| 246 | |
| 247 | void target_init(void) |
| 248 | { |
| 249 | dprintf(INFO, "target_init()\n"); |
| 250 | |
Sridhar Parasuram | 1d22432 | 2015-06-15 11:03:40 -0700 | [diff] [blame] | 251 | pmic_info_populate(); |
| 252 | |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 253 | spmi_init(PMIC_ARB_CHANNEL_NUM, PMIC_ARB_OWNER_ID); |
| 254 | |
Channagoud Kadabi | bb8f1f9 | 2015-04-27 11:14:45 -0700 | [diff] [blame] | 255 | /* Initialize Glink */ |
| 256 | rpm_glink_init(); |
| 257 | |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 258 | target_keystatus(); |
| 259 | |
| 260 | if (target_use_signed_kernel()) |
| 261 | target_crypto_init_params(); |
| 262 | |
| 263 | platform_read_boot_config(); |
| 264 | |
Sridhar Parasuram | 50b9d96 | 2015-02-12 11:28:09 -0800 | [diff] [blame] | 265 | #ifdef MMC_SDHCI_SUPPORT |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 266 | if (platform_boot_dev_isemmc()) |
| 267 | { |
| 268 | target_sdc_init(); |
| 269 | } |
Sridhar Parasuram | 50b9d96 | 2015-02-12 11:28:09 -0800 | [diff] [blame] | 270 | #endif |
| 271 | #ifdef UFS_SUPPORT |
| 272 | if (!platform_boot_dev_isemmc()) |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 273 | { |
| 274 | ufs_device.base = UFS_BASE; |
| 275 | ufs_init(&ufs_device); |
| 276 | } |
Sridhar Parasuram | 50b9d96 | 2015-02-12 11:28:09 -0800 | [diff] [blame] | 277 | #endif |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 278 | |
| 279 | /* Storage initialization is complete, read the partition table info */ |
Channagoud Kadabi | 58a273b | 2015-02-10 12:56:22 -0800 | [diff] [blame] | 280 | mmc_read_partition_table(0); |
Channagoud Kadabi | 2bab29b | 2015-02-11 13:26:03 -0800 | [diff] [blame] | 281 | |
Channagoud Kadabi | 1171d8d | 2015-07-30 19:12:44 -0700 | [diff] [blame] | 282 | #if ENABLE_WBC |
| 283 | /* Look for battery voltage and make sure we have enough to bootup |
| 284 | * Otherwise initiate battery charging |
| 285 | * Charging should happen as early as possible, any other driver |
| 286 | * initialization before this should consider the power impact |
| 287 | */ |
| 288 | if (board_hardware_id() == HW_PLATFORM_MTP) |
| 289 | pm_appsbl_chg_check_weak_battery_status(1); |
| 290 | #endif |
| 291 | |
Channagoud Kadabi | 2bab29b | 2015-02-11 13:26:03 -0800 | [diff] [blame] | 292 | if (rpmb_init() < 0) |
| 293 | { |
| 294 | dprintf(CRITICAL, "RPMB init failed\n"); |
| 295 | ASSERT(0); |
| 296 | } |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | unsigned board_machtype(void) |
| 300 | { |
| 301 | return LINUX_MACHTYPE_UNKNOWN; |
| 302 | } |
| 303 | |
| 304 | /* Detect the target type */ |
| 305 | void target_detect(struct board_data *board) |
| 306 | { |
| 307 | /* This is filled from board.c */ |
| 308 | } |
| 309 | |
Dhaval Patel | b95039c | 2015-03-16 11:14:06 -0700 | [diff] [blame] | 310 | static uint8_t splash_override; |
| 311 | /* Returns 1 if target supports continuous splash screen. */ |
| 312 | int target_cont_splash_screen() |
| 313 | { |
| 314 | uint8_t splash_screen = 0; |
| 315 | if(!splash_override) { |
| 316 | switch(board_hardware_id()) |
| 317 | { |
| 318 | case HW_PLATFORM_SURF: |
| 319 | case HW_PLATFORM_MTP: |
| 320 | case HW_PLATFORM_FLUID: |
| 321 | dprintf(SPEW, "Target_cont_splash=1\n"); |
| 322 | splash_screen = 1; |
| 323 | break; |
| 324 | default: |
| 325 | dprintf(SPEW, "Target_cont_splash=0\n"); |
| 326 | splash_screen = 0; |
| 327 | } |
| 328 | } |
| 329 | return splash_screen; |
| 330 | } |
| 331 | |
| 332 | void target_force_cont_splash_disable(uint8_t override) |
| 333 | { |
| 334 | splash_override = override; |
| 335 | } |
| 336 | |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 337 | /* Detect the modem type */ |
| 338 | void target_baseband_detect(struct board_data *board) |
| 339 | { |
| 340 | uint32_t platform; |
| 341 | |
| 342 | platform = board->platform; |
| 343 | |
| 344 | switch(platform) { |
Channagoud Kadabi | 439df82 | 2015-05-26 11:14:16 -0700 | [diff] [blame] | 345 | case APQ8096: |
| 346 | board->baseband = BASEBAND_APQ; |
| 347 | break; |
Channagoud Kadabi | 4a4c05e | 2015-03-30 15:18:58 -0700 | [diff] [blame] | 348 | case MSM8996: |
Channagoud Kadabi | 99d2370 | 2015-02-02 20:52:17 -0800 | [diff] [blame] | 349 | if (board->platform_version == 0x10000) |
| 350 | board->baseband = BASEBAND_APQ; |
| 351 | else |
| 352 | board->baseband = BASEBAND_MSM; |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 353 | break; |
| 354 | default: |
| 355 | dprintf(CRITICAL, "Platform type: %u is not supported\n",platform); |
| 356 | ASSERT(0); |
| 357 | }; |
| 358 | } |
| 359 | unsigned target_baseband() |
| 360 | { |
| 361 | return board_baseband(); |
| 362 | } |
| 363 | |
| 364 | void target_serialno(unsigned char *buf) |
| 365 | { |
| 366 | unsigned int serialno; |
| 367 | if (target_is_emmc_boot()) { |
| 368 | serialno = mmc_get_psn(); |
| 369 | snprintf((char *)buf, 13, "%x", serialno); |
| 370 | } |
| 371 | } |
| 372 | |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 373 | int emmc_recovery_init(void) |
| 374 | { |
| 375 | return _emmc_recovery_init(); |
| 376 | } |
| 377 | |
| 378 | void target_usb_phy_reset() |
| 379 | { |
| 380 | usb30_qmp_phy_reset(); |
| 381 | qusb2_phy_reset(); |
| 382 | } |
| 383 | |
| 384 | target_usb_iface_t* target_usb30_init() |
| 385 | { |
| 386 | target_usb_iface_t *t_usb_iface; |
| 387 | |
| 388 | t_usb_iface = calloc(1, sizeof(target_usb_iface_t)); |
| 389 | ASSERT(t_usb_iface); |
| 390 | |
| 391 | t_usb_iface->phy_init = usb30_qmp_phy_init; |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 392 | t_usb_iface->phy_reset = target_usb_phy_reset; |
| 393 | t_usb_iface->clock_init = clock_usb30_init; |
| 394 | t_usb_iface->vbus_override = 1; |
| 395 | |
| 396 | return t_usb_iface; |
| 397 | } |
| 398 | |
| 399 | /* identify the usb controller to be used for the target */ |
| 400 | const char * target_usb_controller() |
| 401 | { |
| 402 | return "dwc"; |
| 403 | } |
| 404 | |
| 405 | uint32_t target_override_pll() |
| 406 | { |
Channagoud Kadabi | 1e5144b | 2015-04-28 17:15:05 -0700 | [diff] [blame] | 407 | if (board_soc_version() >= 0x20000) |
| 408 | return 0; |
| 409 | else |
| 410 | return 1; |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 411 | } |
| 412 | |
Channagoud Kadabi | 4a870cf | 2015-01-21 10:39:01 -0800 | [diff] [blame] | 413 | crypto_engine_type board_ce_type(void) |
| 414 | { |
Channagoud Kadabi | 7edb9b4 | 2015-08-11 23:45:31 -0700 | [diff] [blame] | 415 | return CRYPTO_ENGINE_TYPE_HW; |
Channagoud Kadabi | 4a870cf | 2015-01-21 10:39:01 -0800 | [diff] [blame] | 416 | } |
| 417 | |
| 418 | /* Set up params for h/w CE. */ |
| 419 | void target_crypto_init_params() |
| 420 | { |
| 421 | struct crypto_init_params ce_params; |
| 422 | |
| 423 | /* Set up base addresses and instance. */ |
| 424 | ce_params.crypto_instance = CE_INSTANCE; |
| 425 | ce_params.crypto_base = MSM_CE_BASE; |
| 426 | ce_params.bam_base = MSM_CE_BAM_BASE; |
| 427 | |
| 428 | /* Set up BAM config. */ |
| 429 | ce_params.bam_ee = CE_EE; |
| 430 | ce_params.pipes.read_pipe = CE_READ_PIPE; |
| 431 | ce_params.pipes.write_pipe = CE_WRITE_PIPE; |
| 432 | ce_params.pipes.read_pipe_grp = CE_READ_PIPE_LOCK_GRP; |
| 433 | ce_params.pipes.write_pipe_grp = CE_WRITE_PIPE_LOCK_GRP; |
| 434 | |
| 435 | /* Assign buffer sizes. */ |
| 436 | ce_params.num_ce = CE_ARRAY_SIZE; |
| 437 | ce_params.read_fifo_size = CE_FIFO_SIZE; |
| 438 | ce_params.write_fifo_size = CE_FIFO_SIZE; |
| 439 | |
| 440 | /* BAM is initialized by TZ for this platform. |
| 441 | * Do not do it again as the initialization address space |
| 442 | * is locked. |
| 443 | */ |
| 444 | ce_params.do_bam_init = 0; |
| 445 | |
| 446 | crypto_init_params(&ce_params); |
| 447 | } |
Channagoud Kadabi | 083290f | 2015-03-13 14:18:38 -0700 | [diff] [blame] | 448 | |
| 449 | unsigned target_pause_for_battery_charge(void) |
| 450 | { |
| 451 | uint8_t pon_reason = pm8x41_get_pon_reason(); |
| 452 | uint8_t is_cold_boot = pm8x41_get_is_cold_boot(); |
| 453 | dprintf(INFO, "%s : pon_reason is %d cold_boot:%d\n", __func__, |
| 454 | pon_reason, is_cold_boot); |
| 455 | /* In case of fastboot reboot,adb reboot or if we see the power key |
| 456 | * pressed we do not want go into charger mode. |
| 457 | * fastboot reboot is warm boot with PON hard reset bit not set |
| 458 | * adb reboot is a cold boot with PON hard reset bit set |
| 459 | */ |
| 460 | if (is_cold_boot && |
| 461 | (!(pon_reason & HARD_RST)) && |
| 462 | (!(pon_reason & KPDPWR_N)) && |
| 463 | ((pon_reason & PON1))) |
| 464 | return 1; |
| 465 | else |
| 466 | return 0; |
| 467 | } |
Channagoud Kadabi | 23edc0c | 2015-03-27 18:31:32 -0700 | [diff] [blame] | 468 | |
| 469 | int set_download_mode(enum dload_mode mode) |
| 470 | { |
| 471 | int ret = 0; |
| 472 | ret = scm_dload_mode(mode); |
| 473 | |
| 474 | return ret; |
| 475 | } |
Channagoud Kadabi | ffc4b90 | 2015-06-25 23:14:27 -0700 | [diff] [blame] | 476 | |
Channagoud Kadabi | 65b518d | 2015-08-05 16:17:14 -0700 | [diff] [blame] | 477 | void pmic_reset_configure(uint8_t reset_type) |
Channagoud Kadabi | ffc4b90 | 2015-06-25 23:14:27 -0700 | [diff] [blame] | 478 | { |
Channagoud Kadabi | 65b518d | 2015-08-05 16:17:14 -0700 | [diff] [blame] | 479 | pm8994_reset_configure(reset_type); |
Channagoud Kadabi | ffc4b90 | 2015-06-25 23:14:27 -0700 | [diff] [blame] | 480 | } |