Skip to content

Commit be6cf5c

Browse files
javlandsnandojve
authored andcommitted
soc: arm: atmel_sam: Sys_arch_reboot using RSTC
The previous implementation of the sys_arch_reboot function for the Atmel SAM series was using NVIC_SystemReset. This caused a reboot time of around 20 seconds on a SAM4SA16CA, which is now reduced by directly writing to the reset controller control register (RSTC_CR). Signed-off-by: Jaro Van Landschoot <[email protected]> Co-authored-by: Gerson Fernando Budke <[email protected]>
1 parent 6342aa3 commit be6cf5c

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

soc/arm/atmel_sam/common/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ zephyr_include_directories(.)
44
zephyr_library_sources_ifndef(CONFIG_SOC_SERIES_SAM4L soc_pmc.c)
55
zephyr_library_sources_ifndef(CONFIG_SOC_SERIES_SAM4L soc_gpio.c)
66
zephyr_library_sources_ifndef(CONFIG_SOC_SERIES_SAM4L soc_supc.c)
7+
zephyr_library_sources_ifndef(CONFIG_SOC_SERIES_SAM4L soc_power.c)
78
zephyr_library_sources_ifndef(CONFIG_SOC_SERIES_SAM4L soc_poweroff.c)
89

910
zephyr_library_sources_ifdef(CONFIG_SOC_SERIES_SAM4L soc_sam4l_pm.c)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (c) 2023 Basalte bv
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#define SAM_DT_RSTC_DRIVER DT_INST(0, atmel_sam_rstc)
8+
9+
#include <zephyr/kernel.h>
10+
#if defined(CONFIG_REBOOT)
11+
#include <zephyr/sys/reboot.h>
12+
#endif
13+
14+
#if defined(CONFIG_REBOOT)
15+
#if DT_NODE_HAS_STATUS(SAM_DT_RSTC_DRIVER, okay)
16+
17+
void sys_arch_reboot(int type)
18+
{
19+
Rstc *regs = (Rstc *)DT_REG_ADDR(SAM_DT_RSTC_DRIVER);
20+
21+
switch (type) {
22+
case SYS_REBOOT_COLD:
23+
regs->RSTC_CR = RSTC_CR_KEY_PASSWD
24+
| RSTC_CR_PROCRST
25+
#if defined(CONFIG_SOC_SERIES_SAM3X) || defined(CONFIG_SOC_SERIES_SAM4S) || \
26+
defined(CONFIG_SOC_SERIES_SAM4E)
27+
| RSTC_CR_PERRST
28+
#endif /* CONFIG_SOC_SERIES_SAM3X || CONFIG_SOC_SERIES_SAM4S || CONFIG_SOC_SERIES_SAM4E */
29+
;
30+
break;
31+
default:
32+
break;
33+
}
34+
}
35+
36+
#endif /* DT_NODE_HAS_STATUS */
37+
#endif /* CONFIG_REBOOT */

0 commit comments

Comments
 (0)