Skip to content

Commit 511e742

Browse files
ahasztagnvlsianpu
authored andcommitted
[nrf noup] nrf_cleanup: temporary GRTC cleanup with no counter reset
nrf-squash! [nrf noup] nrf_cleanup: nRF54h: fix missing peripheral cleanup The GRTC should not reset its value and stop running when switching for MCUBoot to application. Also in general, this should not be done in case of reset - so the nrfx_grtc_unit function should not reset the counter value. This will be fixed in nrfx (NRFX-8487), but the solution is needed quicker. Hence, a temporary uninit function for GRTC was added in nrf_cleanup, fixing this issue for MCUBoot. Signed-off-by: Artur Hadasz <[email protected]>
1 parent 35be0b7 commit 511e742

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

boot/zephyr/nrf_cleanup.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,35 @@ static inline void nrf_cleanup_rtc(NRF_RTC_Type * rtc_reg)
5252
#endif
5353

5454
#if defined(CONFIG_NRF_GRTC_TIMER)
55+
56+
/**
57+
* This function is temporary and should be removed once nrfx_grtc_uninit
58+
* no longer resets the counter - see NRFX-8487.
59+
*/
60+
static inline void nrfx_grtc_uninit_no_counter_reset(void)
61+
{
62+
uint32_t ch_mask = NRFX_GRTC_CONFIG_ALLOWED_CC_CHANNELS_MASK;
63+
64+
#if NRF_GRTC_HAS_RTCOUNTER
65+
uint32_t grtc_all_int_mask = (NRFX_GRTC_CONFIG_ALLOWED_CC_CHANNELS_MASK |
66+
GRTC_NON_SYSCOMPARE_INT_MASK);
67+
#else
68+
uint32_t grtc_all_int_mask = NRFX_GRTC_CONFIG_ALLOWED_CC_CHANNELS_MASK;
69+
#endif
70+
71+
nrfy_grtc_int_disable(NRF_GRTC, grtc_all_int_mask);
72+
73+
for (uint8_t chan = 0; ch_mask; chan++, ch_mask >>= 1)
74+
{
75+
nrfx_grtc_syscounter_cc_disable(chan);
76+
nrfx_grtc_channel_free(chan);
77+
}
78+
nrfy_grtc_int_uninit(NRF_GRTC);
79+
}
80+
5581
static inline void nrf_cleanup_grtc(void)
5682
{
57-
nrfx_grtc_uninit();
83+
nrfx_grtc_uninit_no_counter_reset();
5884
}
5985
#endif
6086

0 commit comments

Comments
 (0)