From ea26d51772acbbb8569ed5a9ae718d117a23942e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag=20Erik=20Gj=C3=B8rvad?= Date: Tue, 12 Nov 2024 11:55:03 +0100 Subject: [PATCH] [nrf noup] soc: nordic: nrf54l Fix for arch_busy_wait on 54l with tfm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- soc/nordic/nrf54l/soc.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/soc/nordic/nrf54l/soc.c b/soc/nordic/nrf54l/soc.c index 65f6cc183ce..dd0e2729daa 100644 --- a/soc/nordic/nrf54l/soc.c +++ b/soc/nordic/nrf54l/soc.c @@ -47,6 +47,13 @@ LOG_MODULE_REGISTER(soc, CONFIG_SOC_LOG_LEVEL); #define HFXO_NODE DT_NODELABEL(hfxo) #endif +/* Different build images uses different CPU names. That is handled here */ +#if DT_PROP(DT_PATH(cpus, cpu_0), clock_frequency) +#define DEVICE_CLOCK_FREQ DT_PROP(DT_PATH(cpus, cpu_0), clock_frequency) +#elif DT_PROP(DT_PATH(cpus, cpu_1), clock_frequency) +#define DEVICE_CLOCK_FREQ DT_PROP(DT_PATH(cpus, cpu_1), clock_frequency) +#endif + #if defined(NRF_APPLICATION) static inline void power_and_clock_configuration(void) { @@ -170,19 +177,16 @@ static inline void power_and_clock_configuration(void) int nordicsemi_nrf54l_init(void) { - /* Update the SystemCoreClock global variable with current core clock - * retrieved from hardware state. - */ -#if !defined(CONFIG_TRUSTED_EXECUTION_NONSECURE) || defined(__NRF_TFM__) - /* Currently not supported for non-secure */ - SystemCoreClockUpdate(); -#endif - #ifdef __NRF_TFM__ /* TF-M enables the instruction cache from target_cfg.c, so we * don't need to enable it here. */ #else + /* Update SystemCoreClock in Zephyr based on device tree to avoid SystemCoreClock + * being overwritten with default value when initializing with TF-M + */ + SystemCoreClock = DEVICE_CLOCK_FREQ; + /* Enable ICACHE */ sys_cache_instr_enable(); #endif