88#include <zephyr/drivers/hwinfo.h>
99#include <string.h>
1010#include <zephyr/sys/byteorder.h>
11- #if !defined(CONFIG_SOC_SERIES_NRF54HX ) && !defined(CONFIG_BOARD_QEMU_CORTEX_M0 )
11+ #if defined(CONFIG_BOARD_QEMU_CORTEX_M0 ) || \
12+ (defined(CONFIG_NRF_PLATFORM_HALTIUM ) && \
13+ defined(CONFIG_RISCV_CORE_NORDIC_VPR ))
14+ #define RESET_CAUSE_AVAILABLE 0
15+ #else
1216#include <helpers/nrfx_reset_reason.h>
17+ #define RESET_CAUSE_AVAILABLE 1
1318#endif
1419
1520#if defined(CONFIG_TRUSTED_EXECUTION_NONSECURE ) && defined(NRF_FICR_S )
@@ -63,7 +68,30 @@ ssize_t z_impl_hwinfo_get_device_id(uint8_t *buffer, size_t length)
6368 return length ;
6469}
6570
66- #if !defined(CONFIG_SOC_SERIES_NRF54HX ) && !defined(CONFIG_BOARD_QEMU_CORTEX_M0 )
71+ #if RESET_CAUSE_AVAILABLE
72+
73+ #if defined(NRF_RESETINFO )
74+
75+ #define REASON_LOCKUP (NRFX_RESET_REASON_LOCKUP_MASK | NRFX_RESET_REASON_LOCAL_LOCKUP_MASK)
76+ #define REASON_SOFTWARE (NRFX_RESET_REASON_SREQ_MASK | NRFX_RESET_REASON_LOCAL_SREQ_MASK)
77+ #define REASON_WATCHDOG \
78+ (NRFX_RESET_REASON_DOG_MASK | \
79+ NRFX_RESET_REASON_LOCAL_DOG1_MASK | \
80+ NRFX_RESET_REASON_LOCAL_DOG0_MASK)
81+
82+ #else /* NRF_RESETINFO */
83+
84+ #define REASON_LOCKUP NRFX_RESET_REASON_LOCKUP_MASK
85+ #define REASON_SOFTWARE NRFX_RESET_REASON_SREQ_MASK
86+
87+ #if NRF_POWER_HAS_RESETREAS
88+ #define REASON_WATCHDOG NRFX_RESET_REASON_DOG_MASK
89+ #else
90+ #define REASON_WATCHDOG (NRFX_RESET_REASON_DOG0_MASK | NRFX_RESET_REASON_DOG1_MASK)
91+ #endif /* NRF_POWER_HAS_RESETREAS */
92+
93+ #endif /* NRF_RESETINFO */
94+
6795int z_impl_hwinfo_get_reset_cause (uint32_t * cause )
6896{
6997 uint32_t flags = 0 ;
@@ -73,19 +101,21 @@ int z_impl_hwinfo_get_reset_cause(uint32_t *cause)
73101 if (reason & NRFX_RESET_REASON_RESETPIN_MASK ) {
74102 flags |= RESET_PIN ;
75103 }
76- if (reason & NRFX_RESET_REASON_DOG_MASK ) {
104+ if (reason & REASON_WATCHDOG ) {
77105 flags |= RESET_WATCHDOG ;
78106 }
79- if (reason & NRFX_RESET_REASON_LOCKUP_MASK ) {
107+
108+ if (reason & REASON_LOCKUP ) {
80109 flags |= RESET_CPU_LOCKUP ;
81110 }
111+
82112 if (reason & NRFX_RESET_REASON_OFF_MASK ) {
83113 flags |= RESET_LOW_POWER_WAKE ;
84114 }
85115 if (reason & NRFX_RESET_REASON_DIF_MASK ) {
86116 flags |= RESET_DEBUG ;
87117 }
88- if (reason & NRFX_RESET_REASON_SREQ_MASK ) {
118+ if (reason & REASON_SOFTWARE ) {
89119 flags |= RESET_SOFTWARE ;
90120 }
91121
@@ -124,11 +154,7 @@ int z_impl_hwinfo_get_reset_cause(uint32_t *cause)
124154 flags |= RESET_DEBUG ;
125155 }
126156#endif
127- #if !NRF_POWER_HAS_RESETREAS
128- if (reason & NRFX_RESET_REASON_DOG1_MASK ) {
129- flags |= RESET_WATCHDOG ;
130- }
131- #endif
157+
132158#if NRFX_RESET_REASON_HAS_GRTC
133159 if (reason & NRFX_RESET_REASON_GRTC_MASK ) {
134160 flags |= RESET_CLOCK ;
@@ -147,6 +173,7 @@ int z_impl_hwinfo_get_reset_cause(uint32_t *cause)
147173 if (reason & NRFX_RESET_REASON_LCTRLAP_MASK ) {
148174 flags |= RESET_DEBUG ;
149175 }
176+
150177#endif
151178#if defined(NRFX_RESET_REASON_TAMPC_MASK )
152179 if (reason & NRFX_RESET_REASON_TAMPC_MASK ) {
@@ -184,4 +211,4 @@ int z_impl_hwinfo_get_supported_reset_cause(uint32_t *supported)
184211
185212 return 0 ;
186213}
187- #endif
214+ #endif /* RESET_CAUSE_AVAILABLE */
0 commit comments