Commit ac893456 authored by Manish Pandey's avatar Manish Pandey Committed by TrustedFirmware Code Review
Browse files

Merge changes from topic "tegra-downstream-01242020" into integration

* changes:
  Tegra186: memctrl: lock stream id security config
  Tegra194: remove support for simulated system suspend
  Tegra194: mce: fix multiple MISRA issues
  Tegra: bpmp: fix multiple MISRA issues
  Tegra194: se: fix multiple MISRA issues
  Tegra: compile PMC driver for Tegra132/Tegra210 platforms
  Tegra: memctrl_v2: remove weakly defined TZDRAM setup handler
  Tegra: remove weakly defined per-platform SiP handler
  Tegra: remove weakly defined PSCI platform handlers
  Tegra: remove weakly defined platform setup handlers
  Tegra: per-SoC DRAM base values
parents 235c8174 029b45d1
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
#include <t194_nvg.h> #include <t194_nvg.h>
#include <tegra_private.h> #include <tegra_private.h>
#define ID_AFR0_EL1_CACHE_OPS_SHIFT 12 #define ID_AFR0_EL1_CACHE_OPS_SHIFT U(12)
#define ID_AFR0_EL1_CACHE_OPS_MASK 0xFU #define ID_AFR0_EL1_CACHE_OPS_MASK U(0xF)
/* /*
* Reports the major and minor version of this interface. * Reports the major and minor version of this interface.
* *
...@@ -209,7 +209,7 @@ void nvg_enable_strict_checking_mode(void) ...@@ -209,7 +209,7 @@ void nvg_enable_strict_checking_mode(void)
uint64_t params = (uint64_t)(STRICT_CHECKING_ENABLED_SET | uint64_t params = (uint64_t)(STRICT_CHECKING_ENABLED_SET |
STRICT_CHECKING_LOCKED_SET); STRICT_CHECKING_LOCKED_SET);
nvg_set_request_data(TEGRA_NVG_CHANNEL_SECURITY_CONFIG, params); nvg_set_request_data((uint64_t)TEGRA_NVG_CHANNEL_SECURITY_CONFIG, params);
} }
#endif #endif
...@@ -221,7 +221,8 @@ void nvg_enable_strict_checking_mode(void) ...@@ -221,7 +221,8 @@ void nvg_enable_strict_checking_mode(void)
void nvg_system_reboot(void) void nvg_system_reboot(void)
{ {
/* issue command for reboot */ /* issue command for reboot */
nvg_set_request_data(TEGRA_NVG_CHANNEL_SHUTDOWN, TEGRA_NVG_REBOOT); nvg_set_request_data((uint64_t)TEGRA_NVG_CHANNEL_SHUTDOWN,
(uint64_t)TEGRA_NVG_REBOOT);
} }
/* /*
...@@ -232,5 +233,6 @@ void nvg_system_reboot(void) ...@@ -232,5 +233,6 @@ void nvg_system_reboot(void)
void nvg_system_shutdown(void) void nvg_system_shutdown(void)
{ {
/* issue command for shutdown */ /* issue command for shutdown */
nvg_set_request_data(TEGRA_NVG_CHANNEL_SHUTDOWN, TEGRA_NVG_SHUTDOWN); nvg_set_request_data((uint64_t)TEGRA_NVG_CHANNEL_SHUTDOWN,
(uint64_t)TEGRA_NVG_SHUTDOWN);
} }
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <drivers/delay_timer.h> #include <drivers/delay_timer.h>
#include <lib/mmio.h> #include <lib/mmio.h>
#include <lib/psci/psci.h> #include <lib/psci/psci.h>
#include <se.h>
#include <tegra_platform.h> #include <tegra_platform.h>
#include "se_private.h" #include "se_private.h"
...@@ -54,7 +55,7 @@ static bool tegra_se_is_operation_complete(void) ...@@ -54,7 +55,7 @@ static bool tegra_se_is_operation_complete(void)
*/ */
do { do {
val = tegra_se_read_32(CTX_SAVE_AUTO_STATUS); val = tegra_se_read_32(CTX_SAVE_AUTO_STATUS);
se_is_busy = !!(val & CTX_SAVE_AUTO_SE_BUSY); se_is_busy = ((val & CTX_SAVE_AUTO_SE_BUSY) != 0U);
/* sleep until SE finishes */ /* sleep until SE finishes */
if (se_is_busy) { if (se_is_busy) {
...@@ -186,7 +187,8 @@ int32_t tegra_se_suspend(void) ...@@ -186,7 +187,8 @@ int32_t tegra_se_suspend(void)
assert(tegra_bpmp_ipc_init() == 0); assert(tegra_bpmp_ipc_init() == 0);
/* Enable SE clock before SE context save */ /* Enable SE clock before SE context save */
tegra_bpmp_ipc_enable_clock(TEGRA_CLK_SE); ret = tegra_bpmp_ipc_enable_clock(TEGRA_CLK_SE);
assert(ret == 0);
/* save SE registers */ /* save SE registers */
se_regs[0] = mmio_read_32(TEGRA_SE0_BASE + SE0_MUTEX_WATCHDOG_NS_LIMIT); se_regs[0] = mmio_read_32(TEGRA_SE0_BASE + SE0_MUTEX_WATCHDOG_NS_LIMIT);
...@@ -201,7 +203,8 @@ int32_t tegra_se_suspend(void) ...@@ -201,7 +203,8 @@ int32_t tegra_se_suspend(void)
} }
/* Disable SE clock after SE context save */ /* Disable SE clock after SE context save */
tegra_bpmp_ipc_disable_clock(TEGRA_CLK_SE); ret = tegra_bpmp_ipc_disable_clock(TEGRA_CLK_SE);
assert(ret == 0);
return ret; return ret;
} }
...@@ -211,11 +214,14 @@ int32_t tegra_se_suspend(void) ...@@ -211,11 +214,14 @@ int32_t tegra_se_suspend(void)
*/ */
void tegra_se_resume(void) void tegra_se_resume(void)
{ {
int32_t ret = 0;
/* initialise communication channel with BPMP */ /* initialise communication channel with BPMP */
assert(tegra_bpmp_ipc_init() == 0); assert(tegra_bpmp_ipc_init() == 0);
/* Enable SE clock before SE context restore */ /* Enable SE clock before SE context restore */
tegra_bpmp_ipc_enable_clock(TEGRA_CLK_SE); ret = tegra_bpmp_ipc_enable_clock(TEGRA_CLK_SE);
assert(ret == 0);
/* /*
* When TZ takes over after System Resume, TZ should first reconfigure * When TZ takes over after System Resume, TZ should first reconfigure
...@@ -229,5 +235,6 @@ void tegra_se_resume(void) ...@@ -229,5 +235,6 @@ void tegra_se_resume(void)
mmio_write_32(TEGRA_PKA1_BASE + PKA1_MUTEX_WATCHDOG_NS_LIMIT, se_regs[3]); mmio_write_32(TEGRA_PKA1_BASE + PKA1_MUTEX_WATCHDOG_NS_LIMIT, se_regs[3]);
/* Disable SE clock after SE context restore */ /* Disable SE clock after SE context restore */
tegra_bpmp_ipc_disable_clock(TEGRA_CLK_SE); ret = tegra_bpmp_ipc_disable_clock(TEGRA_CLK_SE);
assert(ret == 0);
} }
...@@ -74,12 +74,12 @@ ...@@ -74,12 +74,12 @@
static inline uint32_t tegra_se_read_32(uint32_t offset) static inline uint32_t tegra_se_read_32(uint32_t offset)
{ {
return mmio_read_32(TEGRA_SE0_BASE + offset); return mmio_read_32((uint32_t)(TEGRA_SE0_BASE + offset));
} }
static inline void tegra_se_write_32(uint32_t offset, uint32_t val) static inline void tegra_se_write_32(uint32_t offset, uint32_t val)
{ {
mmio_write_32(TEGRA_SE0_BASE + offset, val); mmio_write_32((uint32_t)(TEGRA_SE0_BASE + offset), val);
} }
#endif /* SE_PRIVATE_H */ #endif /* SE_PRIVATE_H */
...@@ -44,14 +44,6 @@ static struct t19x_psci_percpu_data { ...@@ -44,14 +44,6 @@ static struct t19x_psci_percpu_data {
uint32_t wake_time; uint32_t wake_time;
} __aligned(CACHE_WRITEBACK_GRANULE) t19x_percpu_data[PLATFORM_CORE_COUNT]; } __aligned(CACHE_WRITEBACK_GRANULE) t19x_percpu_data[PLATFORM_CORE_COUNT];
/*
* tegra_fake_system_suspend acts as a boolean var controlling whether
* we are going to take fake system suspend code or normal system suspend code
* path. This variable is set inside the sip call handlers, when the kernel
* requests an SIP call to set the suspend debug flags.
*/
bool tegra_fake_system_suspend;
int32_t tegra_soc_validate_power_state(uint32_t power_state, int32_t tegra_soc_validate_power_state(uint32_t power_state,
psci_power_state_t *req_state) psci_power_state_t *req_state)
{ {
...@@ -171,8 +163,6 @@ int32_t tegra_soc_pwr_domain_suspend(const psci_power_state_t *target_state) ...@@ -171,8 +163,6 @@ int32_t tegra_soc_pwr_domain_suspend(const psci_power_state_t *target_state)
assert(ret == 0); assert(ret == 0);
} }
if (!tegra_fake_system_suspend) {
/* Prepare for system suspend */ /* Prepare for system suspend */
mce_update_cstate_info(&sc7_cstate_info); mce_update_cstate_info(&sc7_cstate_info);
...@@ -194,7 +184,6 @@ int32_t tegra_soc_pwr_domain_suspend(const psci_power_state_t *target_state) ...@@ -194,7 +184,6 @@ int32_t tegra_soc_pwr_domain_suspend(const psci_power_state_t *target_state)
/* set system suspend state for house-keeping */ /* set system suspend state for house-keeping */
tegra194_set_system_suspend_entry(); tegra194_set_system_suspend_entry();
}
} else { } else {
; /* do nothing */ ; /* do nothing */
} }
...@@ -301,7 +290,6 @@ int32_t tegra_soc_pwr_domain_power_down_wfi(const psci_power_state_t *target_sta ...@@ -301,7 +290,6 @@ int32_t tegra_soc_pwr_domain_power_down_wfi(const psci_power_state_t *target_sta
uint8_t stateid_afflvl2 = pwr_domain_state[PLAT_MAX_PWR_LVL] & uint8_t stateid_afflvl2 = pwr_domain_state[PLAT_MAX_PWR_LVL] &
TEGRA194_STATE_ID_MASK; TEGRA194_STATE_ID_MASK;
uint64_t val; uint64_t val;
u_register_t ns_sctlr_el1;
if (stateid_afflvl2 == PSTATE_ID_SOC_POWERDN) { if (stateid_afflvl2 == PSTATE_ID_SOC_POWERDN) {
/* /*
...@@ -313,35 +301,16 @@ int32_t tegra_soc_pwr_domain_power_down_wfi(const psci_power_state_t *target_sta ...@@ -313,35 +301,16 @@ int32_t tegra_soc_pwr_domain_power_down_wfi(const psci_power_state_t *target_sta
tegra194_get_cpu_reset_handler_size(); tegra194_get_cpu_reset_handler_size();
memcpy((void *)(uintptr_t)val, (void *)(uintptr_t)BL31_BASE, memcpy((void *)(uintptr_t)val, (void *)(uintptr_t)BL31_BASE,
(uintptr_t)&__BL31_END__ - (uintptr_t)BL31_BASE); (uintptr_t)&__BL31_END__ - (uintptr_t)BL31_BASE);
/*
* In fake suspend mode, ensure that the loopback procedure
* towards system suspend exit is started, instead of calling
* WFI. This is done by disabling both MMU's of EL1 & El3
* and calling tegra_secure_entrypoint().
*/
if (tegra_fake_system_suspend) {
/*
* Disable EL1's MMU.
*/
ns_sctlr_el1 = read_sctlr_el1();
ns_sctlr_el1 &= (~((u_register_t)SCTLR_M_BIT));
write_sctlr_el1(ns_sctlr_el1);
/*
* Disable MMU to power up the CPU in a "clean"
* state
*/
disable_mmu_el3();
tegra_secure_entrypoint();
panic();
}
} }
return PSCI_E_SUCCESS; return PSCI_E_SUCCESS;
} }
int32_t tegra_soc_pwr_domain_suspend_pwrdown_early(const psci_power_state_t *target_state)
{
return PSCI_E_NOT_SUPPORTED;
}
int32_t tegra_soc_pwr_domain_on(u_register_t mpidr) int32_t tegra_soc_pwr_domain_on(u_register_t mpidr)
{ {
uint64_t target_cpu = mpidr & MPIDR_CPU_MASK; uint64_t target_cpu = mpidr & MPIDR_CPU_MASK;
......
/* /*
* Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. * Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -18,12 +18,9 @@ ...@@ -18,12 +18,9 @@
#include <tegra_platform.h> #include <tegra_platform.h>
#include <stdbool.h> #include <stdbool.h>
extern bool tegra_fake_system_suspend;
/******************************************************************************* /*******************************************************************************
* Tegra194 SiP SMCs * Tegra194 SiP SMCs
******************************************************************************/ ******************************************************************************/
#define TEGRA_SIP_ENABLE_FAKE_SYSTEM_SUSPEND 0xC2FFFE03U
/******************************************************************************* /*******************************************************************************
* This function is responsible for handling all T194 SiP calls * This function is responsible for handling all T194 SiP calls
...@@ -39,25 +36,11 @@ int32_t plat_sip_handler(uint32_t smc_fid, ...@@ -39,25 +36,11 @@ int32_t plat_sip_handler(uint32_t smc_fid,
{ {
int32_t ret = -ENOTSUP; int32_t ret = -ENOTSUP;
(void)smc_fid;
(void)x1; (void)x1;
(void)x4; (void)x4;
(void)cookie; (void)cookie;
(void)flags; (void)flags;
if (smc_fid == TEGRA_SIP_ENABLE_FAKE_SYSTEM_SUSPEND) {
/*
* System suspend mode is set if the platform ATF is
* running on VDK and there is a debug SIP call. This mode
* ensures that the debug path is exercised, instead of
* regular code path to suit the pre-silicon platform needs.
* This includes replacing the call to WFI, with calls to
* system suspend exit procedures.
*/
if (tegra_platform_is_virt_dev_kit()) {
tegra_fake_system_suspend = true;
ret = 0;
}
}
return ret; return ret;
} }
/* /*
* Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2020, NVIDIA Corporation. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -184,6 +185,12 @@ plat_local_state_t tegra_soc_get_target_pwr_state(unsigned int lvl, ...@@ -184,6 +185,12 @@ plat_local_state_t tegra_soc_get_target_pwr_state(unsigned int lvl,
return target; return target;
} }
int32_t tegra_soc_cpu_standby(plat_local_state_t cpu_state)
{
(void)cpu_state;
return PSCI_E_SUCCESS;
}
int tegra_soc_pwr_domain_suspend(const psci_power_state_t *target_state) int tegra_soc_pwr_domain_suspend(const psci_power_state_t *target_state)
{ {
u_register_t mpidr = read_mpidr(); u_register_t mpidr = read_mpidr();
...@@ -412,6 +419,11 @@ int tegra_soc_pwr_domain_power_down_wfi(const psci_power_state_t *target_state) ...@@ -412,6 +419,11 @@ int tegra_soc_pwr_domain_power_down_wfi(const psci_power_state_t *target_state)
return PSCI_E_SUCCESS; return PSCI_E_SUCCESS;
} }
int32_t tegra_soc_pwr_domain_suspend_pwrdown_early(const psci_power_state_t *target_state)
{
return PSCI_E_NOT_SUPPORTED;
}
int tegra_soc_pwr_domain_on_finish(const psci_power_state_t *target_state) int tegra_soc_pwr_domain_on_finish(const psci_power_state_t *target_state)
{ {
const plat_params_from_bl2_t *plat_params = bl31_get_plat_params(); const plat_params_from_bl2_t *plat_params = bl31_get_plat_params();
...@@ -567,5 +579,16 @@ int tegra_soc_prepare_system_reset(void) ...@@ -567,5 +579,16 @@ int tegra_soc_prepare_system_reset(void)
/* Wait 1 ms to make sure clock source/device logic is stabilized. */ /* Wait 1 ms to make sure clock source/device logic is stabilized. */
mdelay(1); mdelay(1);
/*
* Program the PMC in order to restart the system.
*/
tegra_pmc_system_reset();
return PSCI_E_SUCCESS; return PSCI_E_SUCCESS;
} }
__dead2 void tegra_soc_prepare_system_off(void)
{
ERROR("Tegra System Off: operation not handled.\n");
panic();
}
/* /*
* Copyright (c) 2015-2019, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2015-2019, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2020, NVIDIA Corporation. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -140,6 +141,22 @@ void plat_enable_console(int32_t id) ...@@ -140,6 +141,22 @@ void plat_enable_console(int32_t id)
} }
} }
/*******************************************************************************
* Return pointer to the BL31 params from previous bootloader
******************************************************************************/
struct tegra_bl31_params *plat_get_bl31_params(void)
{
return NULL;
}
/*******************************************************************************
* Return pointer to the BL31 platform params from previous bootloader
******************************************************************************/
plat_params_from_bl2_t *plat_get_bl31_plat_params(void)
{
return NULL;
}
/******************************************************************************* /*******************************************************************************
* Handler for early platform setup * Handler for early platform setup
******************************************************************************/ ******************************************************************************/
...@@ -168,6 +185,9 @@ static const interrupt_prop_t tegra210_interrupt_props[] = { ...@@ -168,6 +185,9 @@ static const interrupt_prop_t tegra210_interrupt_props[] = {
GICV2_INTR_GROUP0, GIC_INTR_CFG_EDGE), GICV2_INTR_GROUP0, GIC_INTR_CFG_EDGE),
}; };
/*******************************************************************************
* Handler for late platform setup
******************************************************************************/
void plat_late_platform_setup(void) void plat_late_platform_setup(void)
{ {
const plat_params_from_bl2_t *plat_params = bl31_get_plat_params(); const plat_params_from_bl2_t *plat_params = bl31_get_plat_params();
......
# #
# Copyright (c) 2015-2019, ARM Limited and Contributors. All rights reserved. # Copyright (c) 2015-2019, ARM Limited and Contributors. All rights reserved.
# Copyright (c) 2020, NVIDIA Corporation. All rights reserved.
# #
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
# #
...@@ -33,6 +34,7 @@ BL31_SOURCES += drivers/ti/uart/aarch64/16550_console.S \ ...@@ -33,6 +34,7 @@ BL31_SOURCES += drivers/ti/uart/aarch64/16550_console.S \
${COMMON_DIR}/drivers/bpmp/bpmp.c \ ${COMMON_DIR}/drivers/bpmp/bpmp.c \
${COMMON_DIR}/drivers/flowctrl/flowctrl.c \ ${COMMON_DIR}/drivers/flowctrl/flowctrl.c \
${COMMON_DIR}/drivers/memctrl/memctrl_v1.c \ ${COMMON_DIR}/drivers/memctrl/memctrl_v1.c \
${COMMON_DIR}/drivers/pmc/pmc.c \
${SOC_DIR}/plat_psci_handlers.c \ ${SOC_DIR}/plat_psci_handlers.c \
${SOC_DIR}/plat_setup.c \ ${SOC_DIR}/plat_setup.c \
${SOC_DIR}/drivers/se/security_engine.c \ ${SOC_DIR}/drivers/se/security_engine.c \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment