1*91f16700Schasinglulu /* 2*91f16700Schasinglulu * Copyright (c) 2015-2019, ARM Limited and Contributors. All rights reserved. 3*91f16700Schasinglulu * Copyright (c) 2020, NVIDIA Corporation. All rights reserved. 4*91f16700Schasinglulu * 5*91f16700Schasinglulu * SPDX-License-Identifier: BSD-3-Clause 6*91f16700Schasinglulu */ 7*91f16700Schasinglulu 8*91f16700Schasinglulu #include <assert.h> 9*91f16700Schasinglulu 10*91f16700Schasinglulu #include <arch_helpers.h> 11*91f16700Schasinglulu #include <bl31/bl31.h> 12*91f16700Schasinglulu #include <bl31/interrupt_mgmt.h> 13*91f16700Schasinglulu #include <common/bl_common.h> 14*91f16700Schasinglulu #include <common/debug.h> 15*91f16700Schasinglulu #include <common/ep_info.h> 16*91f16700Schasinglulu #include <common/interrupt_props.h> 17*91f16700Schasinglulu #include <context.h> 18*91f16700Schasinglulu #include <cortex_a57.h> 19*91f16700Schasinglulu #include <denver.h> 20*91f16700Schasinglulu #include <drivers/arm/gic_common.h> 21*91f16700Schasinglulu #include <drivers/arm/gicv2.h> 22*91f16700Schasinglulu #include <drivers/console.h> 23*91f16700Schasinglulu #include <lib/el3_runtime/context_mgmt.h> 24*91f16700Schasinglulu #include <lib/utils.h> 25*91f16700Schasinglulu #include <lib/xlat_tables/xlat_tables_v2.h> 26*91f16700Schasinglulu #include <plat/common/platform.h> 27*91f16700Schasinglulu 28*91f16700Schasinglulu #include <mce.h> 29*91f16700Schasinglulu #include <memctrl.h> 30*91f16700Schasinglulu #include <smmu.h> 31*91f16700Schasinglulu #include <tegra_def.h> 32*91f16700Schasinglulu #include <tegra_platform.h> 33*91f16700Schasinglulu #include <tegra_private.h> 34*91f16700Schasinglulu 35*91f16700Schasinglulu extern void memcpy16(void *dest, const void *src, unsigned int length); 36*91f16700Schasinglulu 37*91f16700Schasinglulu /******************************************************************************* 38*91f16700Schasinglulu * Tegra186 CPU numbers in cluster #0 39*91f16700Schasinglulu ******************************************************************************* 40*91f16700Schasinglulu */ 41*91f16700Schasinglulu #define TEGRA186_CLUSTER0_CORE2 2U 42*91f16700Schasinglulu #define TEGRA186_CLUSTER0_CORE3 3U 43*91f16700Schasinglulu 44*91f16700Schasinglulu /******************************************************************************* 45*91f16700Schasinglulu * The Tegra power domain tree has a single system level power domain i.e. a 46*91f16700Schasinglulu * single root node. The first entry in the power domain descriptor specifies 47*91f16700Schasinglulu * the number of power domains at the highest power level. 48*91f16700Schasinglulu ******************************************************************************* 49*91f16700Schasinglulu */ 50*91f16700Schasinglulu static const uint8_t tegra_power_domain_tree_desc[] = { 51*91f16700Schasinglulu /* No of root nodes */ 52*91f16700Schasinglulu 1, 53*91f16700Schasinglulu /* No of clusters */ 54*91f16700Schasinglulu PLATFORM_CLUSTER_COUNT, 55*91f16700Schasinglulu /* No of CPU cores - cluster0 */ 56*91f16700Schasinglulu PLATFORM_MAX_CPUS_PER_CLUSTER, 57*91f16700Schasinglulu /* No of CPU cores - cluster1 */ 58*91f16700Schasinglulu PLATFORM_MAX_CPUS_PER_CLUSTER 59*91f16700Schasinglulu }; 60*91f16700Schasinglulu 61*91f16700Schasinglulu /******************************************************************************* 62*91f16700Schasinglulu * This function returns the Tegra default topology tree information. 63*91f16700Schasinglulu ******************************************************************************/ 64*91f16700Schasinglulu const uint8_t *plat_get_power_domain_tree_desc(void) 65*91f16700Schasinglulu { 66*91f16700Schasinglulu return tegra_power_domain_tree_desc; 67*91f16700Schasinglulu } 68*91f16700Schasinglulu 69*91f16700Schasinglulu /* 70*91f16700Schasinglulu * Table of regions to map using the MMU. 71*91f16700Schasinglulu */ 72*91f16700Schasinglulu static const mmap_region_t tegra_mmap[] = { 73*91f16700Schasinglulu MAP_REGION_FLAT(TEGRA_MISC_BASE, 0x10000U, /* 64KB */ 74*91f16700Schasinglulu MT_DEVICE | MT_RW | MT_SECURE), 75*91f16700Schasinglulu MAP_REGION_FLAT(TEGRA_TSA_BASE, 0x20000U, /* 128KB */ 76*91f16700Schasinglulu MT_DEVICE | MT_RW | MT_SECURE), 77*91f16700Schasinglulu MAP_REGION_FLAT(TEGRA_MC_STREAMID_BASE, 0x10000U, /* 64KB */ 78*91f16700Schasinglulu MT_DEVICE | MT_RW | MT_SECURE), 79*91f16700Schasinglulu MAP_REGION_FLAT(TEGRA_MC_BASE, 0x10000U, /* 64KB */ 80*91f16700Schasinglulu MT_DEVICE | MT_RW | MT_SECURE), 81*91f16700Schasinglulu MAP_REGION_FLAT(TEGRA_UARTA_BASE, 0x20000U, /* 128KB - UART A, B*/ 82*91f16700Schasinglulu MT_DEVICE | MT_RW | MT_SECURE), 83*91f16700Schasinglulu MAP_REGION_FLAT(TEGRA_UARTC_BASE, 0x20000U, /* 128KB - UART C, G */ 84*91f16700Schasinglulu MT_DEVICE | MT_RW | MT_SECURE), 85*91f16700Schasinglulu MAP_REGION_FLAT(TEGRA_UARTD_BASE, 0x30000U, /* 192KB - UART D, E, F */ 86*91f16700Schasinglulu MT_DEVICE | MT_RW | MT_SECURE), 87*91f16700Schasinglulu MAP_REGION_FLAT(TEGRA_FUSE_BASE, 0x10000U, /* 64KB */ 88*91f16700Schasinglulu MT_DEVICE | MT_RW | MT_SECURE), 89*91f16700Schasinglulu MAP_REGION_FLAT(TEGRA_GICD_BASE, 0x20000U, /* 128KB */ 90*91f16700Schasinglulu MT_DEVICE | MT_RW | MT_SECURE), 91*91f16700Schasinglulu MAP_REGION_FLAT(TEGRA_SE0_BASE, 0x10000U, /* 64KB */ 92*91f16700Schasinglulu MT_DEVICE | MT_RW | MT_SECURE), 93*91f16700Schasinglulu MAP_REGION_FLAT(TEGRA_PKA1_BASE, 0x10000U, /* 64KB */ 94*91f16700Schasinglulu MT_DEVICE | MT_RW | MT_SECURE), 95*91f16700Schasinglulu MAP_REGION_FLAT(TEGRA_RNG1_BASE, 0x10000U, /* 64KB */ 96*91f16700Schasinglulu MT_DEVICE | MT_RW | MT_SECURE), 97*91f16700Schasinglulu MAP_REGION_FLAT(TEGRA_CAR_RESET_BASE, 0x10000U, /* 64KB */ 98*91f16700Schasinglulu MT_DEVICE | MT_RW | MT_SECURE), 99*91f16700Schasinglulu MAP_REGION_FLAT(TEGRA_PMC_BASE, 0x40000U, /* 256KB */ 100*91f16700Schasinglulu MT_DEVICE | MT_RW | MT_SECURE), 101*91f16700Schasinglulu MAP_REGION_FLAT(TEGRA_TMRUS_BASE, 0x1000U, /* 4KB */ 102*91f16700Schasinglulu MT_DEVICE | MT_RO | MT_SECURE), 103*91f16700Schasinglulu MAP_REGION_FLAT(TEGRA_SCRATCH_BASE, 0x10000U, /* 64KB */ 104*91f16700Schasinglulu MT_DEVICE | MT_RW | MT_SECURE), 105*91f16700Schasinglulu MAP_REGION_FLAT(TEGRA_MMCRAB_BASE, 0x60000U, /* 384KB */ 106*91f16700Schasinglulu MT_DEVICE | MT_RW | MT_SECURE), 107*91f16700Schasinglulu MAP_REGION_FLAT(TEGRA_ARM_ACTMON_CTR_BASE, 0x20000U, /* 128KB - ARM/Denver */ 108*91f16700Schasinglulu MT_DEVICE | MT_RW | MT_SECURE), 109*91f16700Schasinglulu MAP_REGION_FLAT(TEGRA_SMMU0_BASE, 0x1000000U, /* 64KB */ 110*91f16700Schasinglulu MT_DEVICE | MT_RW | MT_SECURE), 111*91f16700Schasinglulu MAP_REGION_FLAT(TEGRA_HSP_DBELL_BASE, 0x10000U, /* 64KB */ 112*91f16700Schasinglulu MT_DEVICE | MT_RW | MT_SECURE), 113*91f16700Schasinglulu MAP_REGION_FLAT(TEGRA_BPMP_IPC_TX_PHYS_BASE, TEGRA_BPMP_IPC_CH_MAP_SIZE, /* 4KB */ 114*91f16700Schasinglulu MT_DEVICE | MT_RW | MT_SECURE), 115*91f16700Schasinglulu MAP_REGION_FLAT(TEGRA_BPMP_IPC_RX_PHYS_BASE, TEGRA_BPMP_IPC_CH_MAP_SIZE, /* 4KB */ 116*91f16700Schasinglulu MT_DEVICE | MT_RW | MT_SECURE), 117*91f16700Schasinglulu {0} 118*91f16700Schasinglulu }; 119*91f16700Schasinglulu 120*91f16700Schasinglulu /******************************************************************************* 121*91f16700Schasinglulu * Set up the pagetables as per the platform memory map & initialize the MMU 122*91f16700Schasinglulu ******************************************************************************/ 123*91f16700Schasinglulu const mmap_region_t *plat_get_mmio_map(void) 124*91f16700Schasinglulu { 125*91f16700Schasinglulu /* MMIO space */ 126*91f16700Schasinglulu return tegra_mmap; 127*91f16700Schasinglulu } 128*91f16700Schasinglulu 129*91f16700Schasinglulu /******************************************************************************* 130*91f16700Schasinglulu * Handler to get the System Counter Frequency 131*91f16700Schasinglulu ******************************************************************************/ 132*91f16700Schasinglulu uint32_t plat_get_syscnt_freq2(void) 133*91f16700Schasinglulu { 134*91f16700Schasinglulu return 31250000; 135*91f16700Schasinglulu } 136*91f16700Schasinglulu 137*91f16700Schasinglulu /******************************************************************************* 138*91f16700Schasinglulu * Maximum supported UART controllers 139*91f16700Schasinglulu ******************************************************************************/ 140*91f16700Schasinglulu #define TEGRA186_MAX_UART_PORTS 7 141*91f16700Schasinglulu 142*91f16700Schasinglulu /******************************************************************************* 143*91f16700Schasinglulu * This variable holds the UART port base addresses 144*91f16700Schasinglulu ******************************************************************************/ 145*91f16700Schasinglulu static uint32_t tegra186_uart_addresses[TEGRA186_MAX_UART_PORTS + 1] = { 146*91f16700Schasinglulu 0, /* undefined - treated as an error case */ 147*91f16700Schasinglulu TEGRA_UARTA_BASE, 148*91f16700Schasinglulu TEGRA_UARTB_BASE, 149*91f16700Schasinglulu TEGRA_UARTC_BASE, 150*91f16700Schasinglulu TEGRA_UARTD_BASE, 151*91f16700Schasinglulu TEGRA_UARTE_BASE, 152*91f16700Schasinglulu TEGRA_UARTF_BASE, 153*91f16700Schasinglulu TEGRA_UARTG_BASE, 154*91f16700Schasinglulu }; 155*91f16700Schasinglulu 156*91f16700Schasinglulu /******************************************************************************* 157*91f16700Schasinglulu * Enable console corresponding to the console ID 158*91f16700Schasinglulu ******************************************************************************/ 159*91f16700Schasinglulu void plat_enable_console(int32_t id) 160*91f16700Schasinglulu { 161*91f16700Schasinglulu static console_t uart_console; 162*91f16700Schasinglulu uint32_t console_clock; 163*91f16700Schasinglulu 164*91f16700Schasinglulu if ((id > 0) && (id < TEGRA186_MAX_UART_PORTS)) { 165*91f16700Schasinglulu /* 166*91f16700Schasinglulu * Reference clock used by the FPGAs is a lot slower. 167*91f16700Schasinglulu */ 168*91f16700Schasinglulu if (tegra_platform_is_fpga()) { 169*91f16700Schasinglulu console_clock = TEGRA_BOOT_UART_CLK_13_MHZ; 170*91f16700Schasinglulu } else { 171*91f16700Schasinglulu console_clock = TEGRA_BOOT_UART_CLK_408_MHZ; 172*91f16700Schasinglulu } 173*91f16700Schasinglulu 174*91f16700Schasinglulu (void)console_16550_register(tegra186_uart_addresses[id], 175*91f16700Schasinglulu console_clock, 176*91f16700Schasinglulu TEGRA_CONSOLE_BAUDRATE, 177*91f16700Schasinglulu &uart_console); 178*91f16700Schasinglulu console_set_scope(&uart_console, CONSOLE_FLAG_BOOT | 179*91f16700Schasinglulu CONSOLE_FLAG_RUNTIME | CONSOLE_FLAG_CRASH); 180*91f16700Schasinglulu } 181*91f16700Schasinglulu } 182*91f16700Schasinglulu 183*91f16700Schasinglulu /******************************************************************************* 184*91f16700Schasinglulu * Handler for early platform setup 185*91f16700Schasinglulu ******************************************************************************/ 186*91f16700Schasinglulu void plat_early_platform_setup(void) 187*91f16700Schasinglulu { 188*91f16700Schasinglulu uint64_t impl, val; 189*91f16700Schasinglulu const plat_params_from_bl2_t *plat_params = bl31_get_plat_params(); 190*91f16700Schasinglulu const struct tegra_bl31_params *arg_from_bl2 = plat_get_bl31_params(); 191*91f16700Schasinglulu 192*91f16700Schasinglulu /* Verify chip id is t186 */ 193*91f16700Schasinglulu assert(tegra_chipid_is_t186()); 194*91f16700Schasinglulu 195*91f16700Schasinglulu /* sanity check MCE firmware compatibility */ 196*91f16700Schasinglulu mce_verify_firmware_version(); 197*91f16700Schasinglulu 198*91f16700Schasinglulu /* 199*91f16700Schasinglulu * Do initial security configuration to allow DRAM/device access. 200*91f16700Schasinglulu */ 201*91f16700Schasinglulu tegra_memctrl_tzdram_setup(plat_params->tzdram_base, 202*91f16700Schasinglulu (uint32_t)plat_params->tzdram_size); 203*91f16700Schasinglulu 204*91f16700Schasinglulu impl = (read_midr() >> MIDR_IMPL_SHIFT) & (uint64_t)MIDR_IMPL_MASK; 205*91f16700Schasinglulu 206*91f16700Schasinglulu /* 207*91f16700Schasinglulu * Enable ECC and Parity Protection for Cortex-A57 CPUs (Tegra186 208*91f16700Schasinglulu * A02p and beyond). 209*91f16700Schasinglulu */ 210*91f16700Schasinglulu if ((plat_params->l2_ecc_parity_prot_dis != 1) && 211*91f16700Schasinglulu (impl != (uint64_t)DENVER_IMPL)) { 212*91f16700Schasinglulu 213*91f16700Schasinglulu val = read_l2ctlr_el1(); 214*91f16700Schasinglulu val |= CORTEX_A57_L2_ECC_PARITY_PROTECTION_BIT; 215*91f16700Schasinglulu write_l2ctlr_el1(val); 216*91f16700Schasinglulu } 217*91f16700Schasinglulu 218*91f16700Schasinglulu /* 219*91f16700Schasinglulu * The previous bootloader might not have placed the BL32 image 220*91f16700Schasinglulu * inside the TZDRAM. Platform handler to allow relocation of BL32 221*91f16700Schasinglulu * image to TZDRAM memory. This behavior might change per platform. 222*91f16700Schasinglulu */ 223*91f16700Schasinglulu plat_relocate_bl32_image(arg_from_bl2->bl32_image_info); 224*91f16700Schasinglulu } 225*91f16700Schasinglulu 226*91f16700Schasinglulu /******************************************************************************* 227*91f16700Schasinglulu * Handler for late platform setup 228*91f16700Schasinglulu ******************************************************************************/ 229*91f16700Schasinglulu void plat_late_platform_setup(void) 230*91f16700Schasinglulu { 231*91f16700Schasinglulu ; /* do nothing */ 232*91f16700Schasinglulu } 233*91f16700Schasinglulu 234*91f16700Schasinglulu /* Secure IRQs for Tegra186 */ 235*91f16700Schasinglulu static const interrupt_prop_t tegra186_interrupt_props[] = { 236*91f16700Schasinglulu INTR_PROP_DESC(TEGRA_SDEI_SGI_PRIVATE, PLAT_SDEI_CRITICAL_PRI, 237*91f16700Schasinglulu GICV2_INTR_GROUP0, GIC_INTR_CFG_EDGE), 238*91f16700Schasinglulu INTR_PROP_DESC(TEGRA186_TOP_WDT_IRQ, PLAT_TEGRA_WDT_PRIO, 239*91f16700Schasinglulu GICV2_INTR_GROUP0, GIC_INTR_CFG_EDGE), 240*91f16700Schasinglulu INTR_PROP_DESC(TEGRA186_AON_WDT_IRQ, PLAT_TEGRA_WDT_PRIO, 241*91f16700Schasinglulu GICV2_INTR_GROUP0, GIC_INTR_CFG_EDGE) 242*91f16700Schasinglulu }; 243*91f16700Schasinglulu 244*91f16700Schasinglulu /******************************************************************************* 245*91f16700Schasinglulu * Initialize the GIC and SGIs 246*91f16700Schasinglulu ******************************************************************************/ 247*91f16700Schasinglulu void plat_gic_setup(void) 248*91f16700Schasinglulu { 249*91f16700Schasinglulu tegra_gic_setup(tegra186_interrupt_props, ARRAY_SIZE(tegra186_interrupt_props)); 250*91f16700Schasinglulu tegra_gic_init(); 251*91f16700Schasinglulu 252*91f16700Schasinglulu /* 253*91f16700Schasinglulu * Initialize the FIQ handler only if the platform supports any 254*91f16700Schasinglulu * FIQ interrupt sources. 255*91f16700Schasinglulu */ 256*91f16700Schasinglulu tegra_fiq_handler_setup(); 257*91f16700Schasinglulu } 258*91f16700Schasinglulu 259*91f16700Schasinglulu /******************************************************************************* 260*91f16700Schasinglulu * Return pointer to the BL31 params from previous bootloader 261*91f16700Schasinglulu ******************************************************************************/ 262*91f16700Schasinglulu struct tegra_bl31_params *plat_get_bl31_params(void) 263*91f16700Schasinglulu { 264*91f16700Schasinglulu uint32_t val; 265*91f16700Schasinglulu 266*91f16700Schasinglulu val = mmio_read_32(TEGRA_SCRATCH_BASE + SCRATCH_BL31_PARAMS_ADDR); 267*91f16700Schasinglulu 268*91f16700Schasinglulu return (struct tegra_bl31_params *)(uintptr_t)val; 269*91f16700Schasinglulu } 270*91f16700Schasinglulu 271*91f16700Schasinglulu /******************************************************************************* 272*91f16700Schasinglulu * Return pointer to the BL31 platform params from previous bootloader 273*91f16700Schasinglulu ******************************************************************************/ 274*91f16700Schasinglulu plat_params_from_bl2_t *plat_get_bl31_plat_params(void) 275*91f16700Schasinglulu { 276*91f16700Schasinglulu uint32_t val; 277*91f16700Schasinglulu 278*91f16700Schasinglulu val = mmio_read_32(TEGRA_SCRATCH_BASE + SCRATCH_BL31_PLAT_PARAMS_ADDR); 279*91f16700Schasinglulu 280*91f16700Schasinglulu return (plat_params_from_bl2_t *)(uintptr_t)val; 281*91f16700Schasinglulu } 282*91f16700Schasinglulu 283*91f16700Schasinglulu /******************************************************************************* 284*91f16700Schasinglulu * This function implements a part of the critical interface between the psci 285*91f16700Schasinglulu * generic layer and the platform that allows the former to query the platform 286*91f16700Schasinglulu * to convert an MPIDR to a unique linear index. An error code (-1) is returned 287*91f16700Schasinglulu * in case the MPIDR is invalid. 288*91f16700Schasinglulu ******************************************************************************/ 289*91f16700Schasinglulu int32_t plat_core_pos_by_mpidr(u_register_t mpidr) 290*91f16700Schasinglulu { 291*91f16700Schasinglulu u_register_t cluster_id, cpu_id, pos; 292*91f16700Schasinglulu int32_t ret; 293*91f16700Schasinglulu 294*91f16700Schasinglulu cluster_id = (mpidr >> (u_register_t)MPIDR_AFF1_SHIFT) & (u_register_t)MPIDR_AFFLVL_MASK; 295*91f16700Schasinglulu cpu_id = (mpidr >> (u_register_t)MPIDR_AFF0_SHIFT) & (u_register_t)MPIDR_AFFLVL_MASK; 296*91f16700Schasinglulu 297*91f16700Schasinglulu /* 298*91f16700Schasinglulu * Validate cluster_id by checking whether it represents 299*91f16700Schasinglulu * one of the two clusters present on the platform. 300*91f16700Schasinglulu * Validate cpu_id by checking whether it represents a CPU in 301*91f16700Schasinglulu * one of the two clusters present on the platform. 302*91f16700Schasinglulu */ 303*91f16700Schasinglulu if ((cluster_id >= (u_register_t)PLATFORM_CLUSTER_COUNT) || 304*91f16700Schasinglulu (cpu_id >= (u_register_t)PLATFORM_MAX_CPUS_PER_CLUSTER)) { 305*91f16700Schasinglulu ret = -1; 306*91f16700Schasinglulu } else { 307*91f16700Schasinglulu /* calculate the core position */ 308*91f16700Schasinglulu pos = cpu_id + (cluster_id << 2U); 309*91f16700Schasinglulu 310*91f16700Schasinglulu /* check for non-existent CPUs */ 311*91f16700Schasinglulu if ((pos == TEGRA186_CLUSTER0_CORE2) || (pos == TEGRA186_CLUSTER0_CORE3)) { 312*91f16700Schasinglulu ret = -1; 313*91f16700Schasinglulu } else { 314*91f16700Schasinglulu ret = (int32_t)pos; 315*91f16700Schasinglulu } 316*91f16700Schasinglulu } 317*91f16700Schasinglulu 318*91f16700Schasinglulu return ret; 319*91f16700Schasinglulu } 320*91f16700Schasinglulu 321*91f16700Schasinglulu /******************************************************************************* 322*91f16700Schasinglulu * Handler to relocate BL32 image to TZDRAM 323*91f16700Schasinglulu ******************************************************************************/ 324*91f16700Schasinglulu void plat_relocate_bl32_image(const image_info_t *bl32_img_info) 325*91f16700Schasinglulu { 326*91f16700Schasinglulu const plat_params_from_bl2_t *plat_bl31_params = plat_get_bl31_plat_params(); 327*91f16700Schasinglulu const entry_point_info_t *bl32_ep_info = bl31_plat_get_next_image_ep_info(SECURE); 328*91f16700Schasinglulu uint64_t tzdram_start, tzdram_end, bl32_start, bl32_end; 329*91f16700Schasinglulu 330*91f16700Schasinglulu if ((bl32_img_info != NULL) && (bl32_ep_info != NULL)) { 331*91f16700Schasinglulu 332*91f16700Schasinglulu /* Relocate BL32 if it resides outside of the TZDRAM */ 333*91f16700Schasinglulu tzdram_start = plat_bl31_params->tzdram_base; 334*91f16700Schasinglulu tzdram_end = plat_bl31_params->tzdram_base + 335*91f16700Schasinglulu plat_bl31_params->tzdram_size; 336*91f16700Schasinglulu bl32_start = bl32_img_info->image_base; 337*91f16700Schasinglulu bl32_end = bl32_img_info->image_base + bl32_img_info->image_size; 338*91f16700Schasinglulu 339*91f16700Schasinglulu assert(tzdram_end > tzdram_start); 340*91f16700Schasinglulu assert(bl32_end > bl32_start); 341*91f16700Schasinglulu assert(bl32_ep_info->pc > tzdram_start); 342*91f16700Schasinglulu assert(bl32_ep_info->pc < tzdram_end); 343*91f16700Schasinglulu 344*91f16700Schasinglulu /* relocate BL32 */ 345*91f16700Schasinglulu if ((bl32_start >= tzdram_end) || (bl32_end <= tzdram_start)) { 346*91f16700Schasinglulu 347*91f16700Schasinglulu INFO("Relocate BL32 to TZDRAM\n"); 348*91f16700Schasinglulu 349*91f16700Schasinglulu (void)memcpy16((void *)(uintptr_t)bl32_ep_info->pc, 350*91f16700Schasinglulu (void *)(uintptr_t)bl32_start, 351*91f16700Schasinglulu bl32_img_info->image_size); 352*91f16700Schasinglulu 353*91f16700Schasinglulu /* clean up non-secure intermediate buffer */ 354*91f16700Schasinglulu zeromem((void *)(uintptr_t)bl32_start, 355*91f16700Schasinglulu bl32_img_info->image_size); 356*91f16700Schasinglulu } 357*91f16700Schasinglulu } 358*91f16700Schasinglulu } 359*91f16700Schasinglulu 360*91f16700Schasinglulu /******************************************************************************* 361*91f16700Schasinglulu * Handler to indicate support for System Suspend 362*91f16700Schasinglulu ******************************************************************************/ 363*91f16700Schasinglulu bool plat_supports_system_suspend(void) 364*91f16700Schasinglulu { 365*91f16700Schasinglulu return true; 366*91f16700Schasinglulu } 367*91f16700Schasinglulu /******************************************************************************* 368*91f16700Schasinglulu * Platform specific runtime setup. 369*91f16700Schasinglulu ******************************************************************************/ 370*91f16700Schasinglulu void plat_runtime_setup(void) 371*91f16700Schasinglulu { 372*91f16700Schasinglulu /* 373*91f16700Schasinglulu * During cold boot, it is observed that the arbitration 374*91f16700Schasinglulu * bit is set in the Memory controller leading to false 375*91f16700Schasinglulu * error interrupts in the non-secure world. To avoid 376*91f16700Schasinglulu * this, clean the interrupt status register before 377*91f16700Schasinglulu * booting into the non-secure world 378*91f16700Schasinglulu */ 379*91f16700Schasinglulu tegra_memctrl_clear_pending_interrupts(); 380*91f16700Schasinglulu 381*91f16700Schasinglulu /* 382*91f16700Schasinglulu * During boot, USB3 and flash media (SDMMC/SATA) devices need 383*91f16700Schasinglulu * access to IRAM. Because these clients connect to the MC and 384*91f16700Schasinglulu * do not have a direct path to the IRAM, the MC implements AHB 385*91f16700Schasinglulu * redirection during boot to allow path to IRAM. In this mode 386*91f16700Schasinglulu * accesses to a programmed memory address aperture are directed 387*91f16700Schasinglulu * to the AHB bus, allowing access to the IRAM. This mode must be 388*91f16700Schasinglulu * disabled before we jump to the non-secure world. 389*91f16700Schasinglulu */ 390*91f16700Schasinglulu tegra_memctrl_disable_ahb_redirection(); 391*91f16700Schasinglulu 392*91f16700Schasinglulu /* 393*91f16700Schasinglulu * Verify the integrity of the previously configured SMMU(s) 394*91f16700Schasinglulu * settings 395*91f16700Schasinglulu */ 396*91f16700Schasinglulu tegra_smmu_verify(); 397*91f16700Schasinglulu } 398