8
8
#include <zephyr/drivers/hwinfo.h>
9
9
#include <string.h>
10
10
#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
12
16
#include <helpers/nrfx_reset_reason.h>
17
+ #define RESET_CAUSE_AVAILABLE 1
13
18
#endif
14
19
15
20
#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)
63
68
return length ;
64
69
}
65
70
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
+
67
95
int z_impl_hwinfo_get_reset_cause (uint32_t * cause )
68
96
{
69
97
uint32_t flags = 0 ;
@@ -73,19 +101,21 @@ int z_impl_hwinfo_get_reset_cause(uint32_t *cause)
73
101
if (reason & NRFX_RESET_REASON_RESETPIN_MASK ) {
74
102
flags |= RESET_PIN ;
75
103
}
76
- if (reason & NRFX_RESET_REASON_DOG_MASK ) {
104
+ if (reason & REASON_WATCHDOG ) {
77
105
flags |= RESET_WATCHDOG ;
78
106
}
79
- if (reason & NRFX_RESET_REASON_LOCKUP_MASK ) {
107
+
108
+ if (reason & REASON_LOCKUP ) {
80
109
flags |= RESET_CPU_LOCKUP ;
81
110
}
111
+
82
112
if (reason & NRFX_RESET_REASON_OFF_MASK ) {
83
113
flags |= RESET_LOW_POWER_WAKE ;
84
114
}
85
115
if (reason & NRFX_RESET_REASON_DIF_MASK ) {
86
116
flags |= RESET_DEBUG ;
87
117
}
88
- if (reason & NRFX_RESET_REASON_SREQ_MASK ) {
118
+ if (reason & REASON_SOFTWARE ) {
89
119
flags |= RESET_SOFTWARE ;
90
120
}
91
121
@@ -124,11 +154,7 @@ int z_impl_hwinfo_get_reset_cause(uint32_t *cause)
124
154
flags |= RESET_DEBUG ;
125
155
}
126
156
#endif
127
- #if !NRF_POWER_HAS_RESETREAS
128
- if (reason & NRFX_RESET_REASON_DOG1_MASK ) {
129
- flags |= RESET_WATCHDOG ;
130
- }
131
- #endif
157
+
132
158
#if NRFX_RESET_REASON_HAS_GRTC
133
159
if (reason & NRFX_RESET_REASON_GRTC_MASK ) {
134
160
flags |= RESET_CLOCK ;
@@ -147,6 +173,7 @@ int z_impl_hwinfo_get_reset_cause(uint32_t *cause)
147
173
if (reason & NRFX_RESET_REASON_LCTRLAP_MASK ) {
148
174
flags |= RESET_DEBUG ;
149
175
}
176
+
150
177
#endif
151
178
#if defined(NRFX_RESET_REASON_TAMPC_MASK )
152
179
if (reason & NRFX_RESET_REASON_TAMPC_MASK ) {
@@ -184,4 +211,4 @@ int z_impl_hwinfo_get_supported_reset_cause(uint32_t *supported)
184
211
185
212
return 0 ;
186
213
}
187
- #endif
214
+ #endif /* RESET_CAUSE_AVAILABLE */
0 commit comments