Skip to content

Commit ea26d51

Browse files
committed
[nrf noup] soc: nordic: nrf54l Fix for arch_busy_wait on 54l with tfm
Noup as it patches code that does not exist in zephyr arch_busy_wait waited half the expected time due to SystemCoreClock being set back to the default value when ns builds. Changed to rely on device tree as to avoid hardcoded clock frequencies Signed-off-by: Dag Erik Gjørvad <[email protected]>
1 parent a70d6bd commit ea26d51

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

soc/nordic/nrf54l/soc.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ LOG_MODULE_REGISTER(soc, CONFIG_SOC_LOG_LEVEL);
4747
#define HFXO_NODE DT_NODELABEL(hfxo)
4848
#endif
4949

50+
/* Different build images uses different CPU names. That is handled here */
51+
#if DT_PROP(DT_PATH(cpus, cpu_0), clock_frequency)
52+
#define DEVICE_CLOCK_FREQ DT_PROP(DT_PATH(cpus, cpu_0), clock_frequency)
53+
#elif DT_PROP(DT_PATH(cpus, cpu_1), clock_frequency)
54+
#define DEVICE_CLOCK_FREQ DT_PROP(DT_PATH(cpus, cpu_1), clock_frequency)
55+
#endif
56+
5057
#if defined(NRF_APPLICATION)
5158
static inline void power_and_clock_configuration(void)
5259
{
@@ -170,19 +177,16 @@ static inline void power_and_clock_configuration(void)
170177

171178
int nordicsemi_nrf54l_init(void)
172179
{
173-
/* Update the SystemCoreClock global variable with current core clock
174-
* retrieved from hardware state.
175-
*/
176-
#if !defined(CONFIG_TRUSTED_EXECUTION_NONSECURE) || defined(__NRF_TFM__)
177-
/* Currently not supported for non-secure */
178-
SystemCoreClockUpdate();
179-
#endif
180-
181180
#ifdef __NRF_TFM__
182181
/* TF-M enables the instruction cache from target_cfg.c, so we
183182
* don't need to enable it here.
184183
*/
185184
#else
185+
/* Update SystemCoreClock in Zephyr based on device tree to avoid SystemCoreClock
186+
* being overwritten with default value when initializing with TF-M
187+
*/
188+
SystemCoreClock = DEVICE_CLOCK_FREQ;
189+
186190
/* Enable ICACHE */
187191
sys_cache_instr_enable();
188192
#endif

0 commit comments

Comments
 (0)