From 0789758a4db5f438219a01ae82178c2f451f4ea0 Mon Sep 17 00:00:00 2001 From: Vignesh Radhakrishnan Date: Mon, 11 Dec 2017 13:17:58 -0800 Subject: [PATCH] Tegra194: mce: support for shutdown and reboot This patch adds support for shutdown/reboot handlers to the MCE driver. ATF communicates with mce using nvg interface for shutdown & reboot. Both shutdown and reboot use the same nvg index. However, the 1st bit of the nvg data argument differentiates whether its a shutdown or reboot. Change-Id: Id2d1b0c4fec55abf69b7f8adb65ca70bfa920e73 Signed-off-by: Vignesh Radhakrishnan --- .../soc/t194/drivers/include/mce_private.h | 5 +++++ .../tegra/soc/t194/drivers/include/t194_nvg.h | 7 +++++- plat/nvidia/tegra/soc/t194/drivers/mce/mce.c | 16 ++++++++++++++ plat/nvidia/tegra/soc/t194/drivers/mce/nvg.c | 22 +++++++++++++++++++ 4 files changed, 49 insertions(+), 1 deletion(-) diff --git a/plat/nvidia/tegra/soc/t194/drivers/include/mce_private.h b/plat/nvidia/tegra/soc/t194/drivers/include/mce_private.h index 226ab5bc5..9741d084f 100644 --- a/plat/nvidia/tegra/soc/t194/drivers/include/mce_private.h +++ b/plat/nvidia/tegra/soc/t194/drivers/include/mce_private.h @@ -7,6 +7,7 @@ #ifndef MCE_PRIVATE_H #define MCE_PRIVATE_H +#include #include /******************************************************************************* @@ -67,8 +68,12 @@ uint64_t nvg_cache_clean(void); uint64_t nvg_cache_clean_inval(void); uint64_t nvg_cache_inval_all(void); void nvg_enable_strict_checking_mode(void); +void nvg_system_shutdown(void); +void nvg_system_reboot(void); /* MCE helper functions */ void mce_enable_strict_checking(void); +void mce_system_shutdown(void); +void mce_system_reboot(void); #endif /* MCE_PRIVATE_H */ diff --git a/plat/nvidia/tegra/soc/t194/drivers/include/t194_nvg.h b/plat/nvidia/tegra/soc/t194/drivers/include/t194_nvg.h index cc0da80bf..06cbb4a2e 100644 --- a/plat/nvidia/tegra/soc/t194/drivers/include/t194_nvg.h +++ b/plat/nvidia/tegra/soc/t194/drivers/include/t194_nvg.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -128,6 +128,11 @@ typedef enum { TEGRA_NVG_SYSTEM_SC8 = 8 } tegra_nvg_system_sleep_state_t; +typedef enum { + TEGRA_NVG_SHUTDOWN = 0U, + TEGRA_NVG_REBOOT = 1U, +} tegra_nvg_shutdown_reboot_state_t; + // --------------------------------------------------------------------------- // NVG Data subformats // --------------------------------------------------------------------------- diff --git a/plat/nvidia/tegra/soc/t194/drivers/mce/mce.c b/plat/nvidia/tegra/soc/t194/drivers/mce/mce.c index c38099f05..00c671bcc 100644 --- a/plat/nvidia/tegra/soc/t194/drivers/mce/mce.c +++ b/plat/nvidia/tegra/soc/t194/drivers/mce/mce.c @@ -237,3 +237,19 @@ void mce_enable_strict_checking(void) } } #endif + +/******************************************************************************* + * Handler to power down the entire system + ******************************************************************************/ +void mce_system_shutdown(void) +{ + nvg_system_shutdown(); +} + +/******************************************************************************* + * Handler to reboot the entire system + ******************************************************************************/ +void mce_system_reboot(void) +{ + nvg_system_reboot(); +} diff --git a/plat/nvidia/tegra/soc/t194/drivers/mce/nvg.c b/plat/nvidia/tegra/soc/t194/drivers/mce/nvg.c index d6b56871b..a095fdd07 100644 --- a/plat/nvidia/tegra/soc/t194/drivers/mce/nvg.c +++ b/plat/nvidia/tegra/soc/t194/drivers/mce/nvg.c @@ -302,3 +302,25 @@ void nvg_enable_strict_checking_mode(void) nvg_set_request_data(TEGRA_NVG_CHANNEL_SECURITY_CONFIG, params); } #endif + +/* + * Request a reboot + * + * NVGDATA[0]: reboot command + */ +void nvg_system_reboot(void) +{ + /* issue command for reboot */ + nvg_set_request_data(TEGRA_NVG_CHANNEL_SHUTDOWN, TEGRA_NVG_REBOOT); +} + +/* + * Request a shutdown + * + * NVGDATA[0]: shutdown command + */ +void nvg_system_shutdown(void) +{ + /* issue command for shutdown */ + nvg_set_request_data(TEGRA_NVG_CHANNEL_SHUTDOWN, TEGRA_NVG_SHUTDOWN); +} -- GitLab