Skip to content

Commit 3f0e8a0

Browse files
committed
[nrf fromlist] soc: nordic: nrf54l: Setup power and clock only on secure build
Setup regulators and oscillators only on cpuapp secure target. Upstream PR #: 85870 Signed-off-by: Krzysztof Chruściński <[email protected]>
1 parent 956662e commit 3f0e8a0

File tree

1 file changed

+31
-22
lines changed

1 file changed

+31
-22
lines changed

soc/nordic/nrf54l/soc.c

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,38 +20,32 @@
2020
#include <zephyr/logging/log.h>
2121
#include <zephyr/cache.h>
2222
#include <zephyr/dt-bindings/regulator/nrf5x.h>
23+
#include <soc/nrfx_coredep.h>
24+
#include <nrf_erratas.h>
25+
#include <system_nrf54l.h>
26+
#include <zephyr/drivers/clock_control/nrf_clock_control.h>
27+
LOG_MODULE_REGISTER(soc, CONFIG_SOC_LOG_LEVEL);
28+
29+
#if defined(NRF_APPLICATION) && !defined(CONFIG_TRUSTED_EXECUTION_NONSECURE)
2330

24-
#if defined(NRF_APPLICATION)
2531
#include <cmsis_core.h>
2632
#include <hal/nrf_glitchdet.h>
2733
#include <hal/nrf_oscillators.h>
2834
#include <hal/nrf_power.h>
2935
#include <hal/nrf_regulators.h>
30-
#endif
31-
#include <soc/nrfx_coredep.h>
3236

33-
#include <nrf_erratas.h>
34-
#include <system_nrf54l.h>
35-
#include <zephyr/drivers/clock_control/nrf_clock_control.h>
36-
37-
LOG_MODULE_REGISTER(soc, CONFIG_SOC_LOG_LEVEL);
38-
39-
#if defined(NRF_APPLICATION)
4037
#define LFXO_NODE DT_NODELABEL(lfxo)
4138
#define HFXO_NODE DT_NODELABEL(hfxo)
42-
#endif
4339

44-
static int nordicsemi_nrf54l_init(void)
40+
static inline void power_and_clock_configuration(void)
4541
{
46-
/* Update the SystemCoreClock global variable with current core clock
47-
* retrieved from the DT.
48-
*/
49-
SystemCoreClock = NRF_PERIPH_GET_FREQUENCY(DT_NODELABEL(cpu));
50-
51-
#if defined(NRF_APPLICATION)
52-
/* Enable ICACHE */
53-
sys_cache_instr_enable();
54-
42+
/* NRF_REGULATORS and NRF_OSCILLATORS are configured to be secure
43+
* as NRF_REGULATORS.POFCON is needed by the secure image to
44+
* prevent glitches when the power supply is attacked.
45+
*
46+
* NRF_OSCILLATORS is also configured as secure because of a HW limitation
47+
* that requires them to be configured with the same security property.
48+
*/
5549
#if DT_ENUM_HAS_VALUE(LFXO_NODE, load_capacitors, internal)
5650
uint32_t xosc32ktrim = NRF_FICR->XOSC32KTRIM;
5751

@@ -165,7 +159,22 @@ static int nordicsemi_nrf54l_init(void)
165159
nrf_regulators_vreg_enable_set(NRF_REGULATORS, NRF_REGULATORS_VREG_MAIN, true);
166160
#endif
167161

168-
#endif /* NRF_APPLICATION */
162+
}
163+
#endif /* NRF_APPLICATION && !CONFIG_TRUSTED_EXECUTION_NONSECURE */
164+
165+
static int nordicsemi_nrf54l_init(void)
166+
{
167+
/* Update the SystemCoreClock global variable with current core clock
168+
* retrieved from the DT.
169+
*/
170+
SystemCoreClock = NRF_PERIPH_GET_FREQUENCY(DT_NODELABEL(cpu));
171+
172+
/* Enable ICACHE. Empty if cache is not enabled. */
173+
sys_cache_instr_enable();
174+
175+
#if defined(NRF_APPLICATION) && !defined(CONFIG_TRUSTED_EXECUTION_NONSECURE)
176+
power_and_clock_configuration();
177+
#endif
169178

170179
return 0;
171180
}

0 commit comments

Comments
 (0)