From 183e7445c618d8d4eac14023f6506f1f0dc31de1 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Mon, 29 Oct 2018 11:46:54 +0000 Subject: [PATCH] soc: nordic: Add Nordic GPREGRET setting support Adds support for setting GPREGRET register when rebooting. Signed-off-by: Jamie McCrae --- soc/arm/nordic_nrf/nrf51/CMakeLists.txt | 1 + soc/arm/nordic_nrf/nrf51/power.c | 15 +++++++++++++++ soc/arm/nordic_nrf/nrf52/power.c | 8 ++++++++ 3 files changed, 24 insertions(+) create mode 100644 soc/arm/nordic_nrf/nrf51/power.c diff --git a/soc/arm/nordic_nrf/nrf51/CMakeLists.txt b/soc/arm/nordic_nrf/nrf51/CMakeLists.txt index 82548794e61..bdbeda41ac9 100644 --- a/soc/arm/nordic_nrf/nrf51/CMakeLists.txt +++ b/soc/arm/nordic_nrf/nrf51/CMakeLists.txt @@ -5,5 +5,6 @@ zephyr_compile_definitions_ifdef( ) zephyr_sources( + power.c soc.c ) diff --git a/soc/arm/nordic_nrf/nrf51/power.c b/soc/arm/nordic_nrf/nrf51/power.c new file mode 100644 index 00000000000..2e90d68dd38 --- /dev/null +++ b/soc/arm/nordic_nrf/nrf51/power.c @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2018 Intel Corporation. + * + * SPDX-License-Identifier: Apache-2.0 + */ +#include +#include + +/* Overrides the weak ARM implementation: + Set general purpose retention register and reboot */ +void sys_arch_reboot(int type) +{ + nrf_power_gpregret_set((uint8_t)type); + NVIC_SystemReset(); +} diff --git a/soc/arm/nordic_nrf/nrf52/power.c b/soc/arm/nordic_nrf/nrf52/power.c index d8641c4bf5e..9ee8ac23984 100644 --- a/soc/arm/nordic_nrf/nrf52/power.c +++ b/soc/arm/nordic_nrf/nrf52/power.c @@ -115,3 +115,11 @@ bool _sys_soc_is_valid_power_state(enum power_states state) return false; } + +/* Overrides the weak ARM implementation: + Set general purpose retention register and reboot */ +void sys_arch_reboot(int type) +{ + nrf_power_gpregret_set((uint8_t)type); + NVIC_SystemReset(); +}