Skip to content

Commit 5488f5a

Browse files
committed
[nrf noup] soc: nordic: nrf54l Fix for wait lasting half expected time
Noup as it patches code that does not exist in zephyr arch_busy_wait and k_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 5488f5a

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

soc/nordic/nrf54l/soc.c

Lines changed: 13 additions & 4 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
{
@@ -176,16 +183,18 @@ int nordicsemi_nrf54l_init(void)
176183
/* Update the SystemCoreClock global variable with current core clock
177184
* retrieved from hardware state.
178185
*/
179-
#if !defined(CONFIG_TRUSTED_EXECUTION_NONSECURE) || defined(__NRF_TFM__)
180-
/* Currently not supported for non-secure */
181-
SystemCoreClockUpdate();
182-
#endif
183186

184187
#ifdef __NRF_TFM__
185188
/* TF-M enables the instruction cache from target_cfg.c, so we
186189
* don't need to enable it here.
187190
*/
188191
#else
192+
193+
/* Update SystemCoreClock in Zephyr based on device tree to avoid SystemCoreClock
194+
* being overwritten with default value when initializing with TF-M
195+
*/
196+
SystemCoreClock = DEVICE_DT_CLOCK_FREQ;
197+
189198
/* Enable ICACHE */
190199
sys_cache_instr_enable();
191200
#endif

0 commit comments

Comments
 (0)