Skip to content

Commit 53f3ce9

Browse files
degjorvaanangl
authored andcommitted
[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]> (cherry picked from commit 665aba4)
1 parent 50a2916 commit 53f3ce9

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
{
@@ -172,16 +179,18 @@ int nordicsemi_nrf54l_init(void)
172179
/* Update the SystemCoreClock global variable with current core clock
173180
* retrieved from hardware state.
174181
*/
175-
#if !defined(CONFIG_TRUSTED_EXECUTION_NONSECURE) || defined(__NRF_TFM__)
176-
/* Currently not supported for non-secure */
177-
SystemCoreClockUpdate();
178-
#endif
179182

180183
#ifdef __NRF_TFM__
181184
/* TF-M enables the instruction cache from target_cfg.c, so we
182185
* don't need to enable it here.
183186
*/
184187
#else
188+
189+
/* Update SystemCoreClock in Zephyr based on device tree to avoid SystemCoreClock
190+
* being overwritten with default value when initializing with TF-M
191+
*/
192+
SystemCoreClock = DEVICE_DT_CLOCK_FREQ;
193+
185194
/* Enable ICACHE */
186195
sys_cache_instr_enable();
187196
#endif

0 commit comments

Comments
 (0)