Skip to content

Commit

Permalink
[nrf fromlist] 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.

Upstream PR #: 81751

Signed-off-by: Karol Lasończyk <[email protected]>
  • Loading branch information
kl-cruz committed Dec 6, 2024
1 parent a7fe5f7 commit 475af47
Showing 1 changed file with 34 additions and 6 deletions.
40 changes: 34 additions & 6 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,37 @@ 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 (reason & NRFX_RESET_REASON_LOCAL_DOG0_MASK) {
flags |= RESET_WATCHDOG;
}
#endif

#if defined(NRF_RESETINFO)
if ((reason & NRFX_RESET_REASON_LOCKUP)
|| (reason & NRFX_RESET_REASON_LOCAL_LOCKUP_MASK))
#else

Check notice on line 89 in drivers/hwinfo/hwinfo_nrf.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/hwinfo/hwinfo_nrf.c:89 - if ((reason & NRFX_RESET_REASON_LOCKUP) - || (reason & NRFX_RESET_REASON_LOCAL_LOCKUP_MASK)) + if ((reason & NRFX_RESET_REASON_LOCKUP) || (reason & NRFX_RESET_REASON_LOCAL_LOCKUP_MASK))
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_SREQ)
|| (reason & NRFX_RESET_REASON_LOCAL_SREQ_MASK))
#else

Check notice on line 106 in drivers/hwinfo/hwinfo_nrf.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/hwinfo/hwinfo_nrf.c:106 - if ((reason & NRFX_RESET_REASON_SREQ) - || (reason & NRFX_RESET_REASON_LOCAL_SREQ_MASK)) + if ((reason & NRFX_RESET_REASON_SREQ) || (reason & NRFX_RESET_REASON_LOCAL_SREQ_MASK))
if (reason & NRFX_RESET_REASON_SREQ_MASK)
#endif
{
flags |= RESET_SOFTWARE;
}

Expand Down Expand Up @@ -124,11 +145,18 @@ 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 (reason & NRFX_RESET_REASON_LOCAL_DOG1_MASK)
#else
if (reason & NRFX_RESET_REASON_DOG1_MASK)
#endif
{
flags |= RESET_WATCHDOG;
}
#endif
#endif /* !NRF_POWER_HAS_RESETREAS */

#if NRFX_RESET_REASON_HAS_GRTC
if (reason & NRFX_RESET_REASON_GRTC_MASK) {
flags |= RESET_CLOCK;
Expand Down

0 comments on commit 475af47

Please sign in to comment.