From 0b5d939a7b01e397a6cf8f12c4fdbe36b1ac71f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20Laso=C5=84czyk?= Date: Fri, 22 Nov 2024 10:02:36 +0100 Subject: [PATCH] [nrf fromtree] drivers: hwinfo: Support for reset reasons in nRF54H20 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adding support for reset reasons in the nRF54H20 SoC. Signed-off-by: Karol Lasończyk (cherry picked from commit 1fedfd52b6b573f63103ffb01cc0854732e1ed7d) --- drivers/hwinfo/hwinfo_nrf.c | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/drivers/hwinfo/hwinfo_nrf.c b/drivers/hwinfo/hwinfo_nrf.c index d1fca5350a6..384bc497c10 100644 --- a/drivers/hwinfo/hwinfo_nrf.c +++ b/drivers/hwinfo/hwinfo_nrf.c @@ -8,7 +8,7 @@ #include #include #include -#if !defined(CONFIG_SOC_SERIES_NRF54HX) && !defined(CONFIG_BOARD_QEMU_CORTEX_M0) +#if !defined(CONFIG_BOARD_QEMU_CORTEX_M0) #include #endif @@ -63,7 +63,7 @@ ssize_t z_impl_hwinfo_get_device_id(uint8_t *buffer, size_t length) return length; } -#if !defined(CONFIG_SOC_SERIES_NRF54HX) && !defined(CONFIG_BOARD_QEMU_CORTEX_M0) +#if !defined(CONFIG_BOARD_QEMU_CORTEX_M0) int z_impl_hwinfo_get_reset_cause(uint32_t *cause) { uint32_t flags = 0; @@ -76,16 +76,35 @@ int z_impl_hwinfo_get_reset_cause(uint32_t *cause) if (reason & NRFX_RESET_REASON_DOG_MASK) { flags |= RESET_WATCHDOG; } - if (reason & NRFX_RESET_REASON_LOCKUP_MASK) { + +#if defined(NRF_RESETINFO) + if (NRFX_RESET_REASON_LOCAL_DOG0_MASK) { + flags |= RESET_WATCHDOG; + } +#endif + +#if defined(NRF_RESETINFO) + if (reason & NRFX_RESET_REASON_LOCAL_LOCKUP_MASK) +#else + if (reason & NRFX_RESET_REASON_LOCKUP_MASK) +#endif + { flags |= RESET_CPU_LOCKUP; } + if (reason & NRFX_RESET_REASON_OFF_MASK) { flags |= RESET_LOW_POWER_WAKE; } if (reason & NRFX_RESET_REASON_DIF_MASK) { flags |= RESET_DEBUG; } - if (reason & NRFX_RESET_REASON_SREQ_MASK) { + +#if defined(NRF_RESETINFO) + if (reason & NRFX_RESET_REASON_LOCAL_SREQ_MASK) +#else + if (reason & NRFX_RESET_REASON_SREQ_MASK) +#endif + { flags |= RESET_SOFTWARE; } @@ -124,11 +143,19 @@ int z_impl_hwinfo_get_reset_cause(uint32_t *cause) flags |= RESET_DEBUG; } #endif + #if !NRF_POWER_HAS_RESETREAS - if (reason & NRFX_RESET_REASON_DOG1_MASK) { + +#if defined(NRF_RESETINFO) + if (NRFX_RESET_REASON_LOCAL_DOG1_MASK) +#else + if (reason & NRFX_RESET_REASON_DOG1_MASK) +#endif + { flags |= RESET_WATCHDOG; } #endif + #if NRFX_RESET_REASON_HAS_GRTC if (reason & NRFX_RESET_REASON_GRTC_MASK) { flags |= RESET_CLOCK;