Skip to content

Commit d55a82c

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 7b64590 commit d55a82c

File tree

1 file changed

+33
-25
lines changed

1 file changed

+33
-25
lines changed

soc/nordic/nrf54l/soc.c

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,45 +13,38 @@
1313
*/
1414

1515
#include <zephyr/devicetree.h>
16-
#include <zephyr/dt-bindings/regulator/nrf5x.h>
1716
#include <zephyr/kernel.h>
1817
#include <zephyr/devicetree.h>
1918
#include <zephyr/init.h>
2019
#include <zephyr/logging/log.h>
2120
#include <zephyr/cache.h>
22-
#include <zephyr/dt-bindings/regulator/nrf5x.h>
21+
#include <soc/nrfx_coredep.h>
22+
#include <system_nrf54l.h>
23+
#include <soc.h>
24+
LOG_MODULE_REGISTER(soc, CONFIG_SOC_LOG_LEVEL);
2325

24-
#if defined(NRF_APPLICATION)
25-
#include <cmsis_core.h>
26+
#if (defined(NRF_APPLICATION) && !defined(CONFIG_TRUSTED_EXECUTION_NONSECURE)) || \
27+
!defined(__ZEPHYR__)
28+
29+
#include <nrf_erratas.h>
2630
#include <hal/nrf_glitchdet.h>
2731
#include <hal/nrf_oscillators.h>
2832
#include <hal/nrf_power.h>
2933
#include <hal/nrf_regulators.h>
30-
#endif
31-
#include <soc/nrfx_coredep.h>
32-
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);
34+
#include <zephyr/dt-bindings/regulator/nrf5x.h>
3835

39-
#if defined(NRF_APPLICATION)
4036
#define LFXO_NODE DT_NODELABEL(lfxo)
4137
#define HFXO_NODE DT_NODELABEL(hfxo)
42-
#endif
4338

44-
static int nordicsemi_nrf54l_init(void)
39+
static inline void power_and_clock_configuration(void)
4540
{
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-
41+
/* NRF_REGULATORS and NRF_OSCILLATORS are configured to be secure
42+
* as NRF_REGULATORS.POFCON is needed by the secure image to
43+
* prevent glitches when the power supply is attacked.
44+
*
45+
* NRF_OSCILLATORS is also configured as secure because of a HW limitation
46+
* that requires them to be configured with the same security property.
47+
*/
5548
#if DT_ENUM_HAS_VALUE(LFXO_NODE, load_capacitors, internal)
5649
uint32_t xosc32ktrim = NRF_FICR->XOSC32KTRIM;
5750

@@ -165,7 +158,22 @@ static int nordicsemi_nrf54l_init(void)
165158
nrf_regulators_vreg_enable_set(NRF_REGULATORS, NRF_REGULATORS_VREG_MAIN, true);
166159
#endif
167160

168-
#endif /* NRF_APPLICATION */
161+
}
162+
#endif /* NRF_APPLICATION && !CONFIG_TRUSTED_EXECUTION_NONSECURE */
163+
164+
int nordicsemi_nrf54l_init(void)
165+
{
166+
/* Update the SystemCoreClock global variable with current core clock
167+
* retrieved from the DT.
168+
*/
169+
SystemCoreClock = NRF_PERIPH_GET_FREQUENCY(DT_NODELABEL(cpu));
170+
171+
sys_cache_instr_enable();
172+
173+
#if (defined(NRF_APPLICATION) && !defined(CONFIG_TRUSTED_EXECUTION_NONSECURE)) || \
174+
!defined(__ZEPHYR__)
175+
power_and_clock_configuration();
176+
#endif
169177

170178
return 0;
171179
}

0 commit comments

Comments
 (0)