From 002ed73ff43193ba8f01c69a9de46cdbe7aa2235 Mon Sep 17 00:00:00 2001 From: Jiafei Pan Date: Tue, 3 Sep 2024 15:21:53 +0800 Subject: [PATCH] arm64: add sys_arch_reboot() support If PSCI is enabled, it will leverage psci reset API to achieve system reboot, otherwise a weak dump reboot API is provided, and platform can override these APIs if platform specified implementation provided. Signed-off-by: Jiafei Pan --- arch/arm64/core/CMakeLists.txt | 1 + arch/arm64/core/reboot.c | 35 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 arch/arm64/core/reboot.c diff --git a/arch/arm64/core/CMakeLists.txt b/arch/arm64/core/CMakeLists.txt index 03a34e439bb..31186ea5224 100644 --- a/arch/arm64/core/CMakeLists.txt +++ b/arch/arm64/core/CMakeLists.txt @@ -9,6 +9,7 @@ zephyr_library_sources( irq_init.c irq_manage.c prep_c.c + reboot.c reset.S reset.c switch.S diff --git a/arch/arm64/core/reboot.c b/arch/arm64/core/reboot.c new file mode 100644 index 00000000000..064b44f93bf --- /dev/null +++ b/arch/arm64/core/reboot.c @@ -0,0 +1,35 @@ +/* + * Copyright 2024 NXP + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include + +LOG_MODULE_DECLARE(os, CONFIG_KERNEL_LOG_LEVEL); + +#ifdef CONFIG_PM_CPU_OPS_PSCI +void __weak sys_arch_reboot(int type) +{ + unsigned char reset_type; + + if (type == SYS_REBOOT_COLD) { + reset_type = SYS_COLD_RESET; + } else if (type == SYS_REBOOT_WARM) { + reset_type = SYS_WARM_RESET; + } else { + LOG_ERR("Invalid reboot type"); + return; + } + pm_system_reset(reset_type); +} +#else +void __weak sys_arch_reboot(int type) +{ + LOG_WRN("%s is not implemented", __func__); + ARG_UNUSED(type); +} +#endif