Skip to content

Commit

Permalink
[nrf fromtree] drivers: hwinfo: Support for reset reasons in nRF54H20
Browse files Browse the repository at this point in the history
Adding support for reset reasons in the nRF54H20 SoC.

Signed-off-by: Karol Lasończyk <[email protected]>
(cherry picked from commit 1fedfd52b6b573f63103ffb01cc0854732e1ed7d)
  • Loading branch information
kl-cruz committed Nov 22, 2024
1 parent 84477d9 commit 0b5d939
Showing 1 changed file with 32 additions and 5 deletions.
37 changes: 32 additions & 5 deletions drivers/hwinfo/hwinfo_nrf.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <zephyr/drivers/hwinfo.h>
#include <string.h>
#include <zephyr/sys/byteorder.h>
#if !defined(CONFIG_SOC_SERIES_NRF54HX) && !defined(CONFIG_BOARD_QEMU_CORTEX_M0)
#if !defined(CONFIG_BOARD_QEMU_CORTEX_M0)
#include <helpers/nrfx_reset_reason.h>
#endif

Expand Down Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 0b5d939

Please sign in to comment.