Skip to content

Commit 87bae93

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 a8ca36c commit 87bae93

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
@@ -48,6 +48,13 @@ LOG_MODULE_REGISTER(soc, CONFIG_SOC_LOG_LEVEL);
4848
#define HFXO_NODE DT_NODELABEL(hfxo)
4949
#endif
5050

51+
/*Building for cpuflpr with ns uses cpu_1 instead of cpu_0*/
52+
#if DT_PROP(DT_PATH(cpus, cpu_0), clock_frequency)
53+
#define DEVICE_DT_CLOCK_FREQ DT_PROP(DT_PATH(cpus, cpu_0), clock_frequency)
54+
#elif DT_PROP(DT_PATH(cpus, cpu_1), clock_frequency)
55+
#define DEVICE_DT_CLOCK_FREQ DT_PROP(DT_PATH(cpus, cpu_1), clock_frequency)
56+
#endif
57+
5158
#if defined(NRF_APPLICATION)
5259
static inline void power_and_clock_configuration(void)
5360
{
@@ -173,19 +180,16 @@ static inline void power_and_clock_configuration(void)
173180

174181
int nordicsemi_nrf54l_init(void)
175182
{
176-
/* Update the SystemCoreClock global variable with current core clock
177-
* retrieved from hardware state.
178-
*/
179-
#if !defined(CONFIG_TRUSTED_EXECUTION_NONSECURE) || defined(__NRF_TFM__)
180-
/* Currently not supported for non-secure */
181-
SystemCoreClockUpdate();
182-
#endif
183-
184183
#ifdef __NRF_TFM__
185184
/* TF-M enables the instruction cache from target_cfg.c, so we
186185
* don't need to enable it here.
187186
*/
188187
#else
188+
/* Update SystemCoreClock in Zephyr based on device tree to avoid SystemCoreClock
189+
* being overwritten with default value when initializing with TF-M
190+
*/
191+
SystemCoreClock = DEVICE_DT_CLOCK_FREQ;
192+
189193
/* Enable ICACHE */
190194
sys_cache_instr_enable();
191195
#endif

0 commit comments

Comments
 (0)