|
13 | 13 | */ |
14 | 14 |
|
15 | 15 | #include <zephyr/devicetree.h> |
16 | | -#include <zephyr/dt-bindings/regulator/nrf5x.h> |
17 | 16 | #include <zephyr/kernel.h> |
18 | 17 | #include <zephyr/devicetree.h> |
19 | 18 | #include <zephyr/init.h> |
20 | 19 | #include <zephyr/logging/log.h> |
21 | 20 | #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); |
23 | 25 |
|
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> |
26 | 30 | #include <hal/nrf_glitchdet.h> |
27 | 31 | #include <hal/nrf_oscillators.h> |
28 | 32 | #include <hal/nrf_power.h> |
29 | 33 | #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> |
38 | 35 |
|
39 | | -#if defined(NRF_APPLICATION) |
40 | 36 | #define LFXO_NODE DT_NODELABEL(lfxo) |
41 | 37 | #define HFXO_NODE DT_NODELABEL(hfxo) |
42 | | -#endif |
43 | 38 |
|
44 | | -static int nordicsemi_nrf54l_init(void) |
| 39 | +static inline void power_and_clock_configuration(void) |
45 | 40 | { |
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 | + */ |
55 | 48 | #if DT_ENUM_HAS_VALUE(LFXO_NODE, load_capacitors, internal) |
56 | 49 | uint32_t xosc32ktrim = NRF_FICR->XOSC32KTRIM; |
57 | 50 |
|
@@ -165,7 +158,22 @@ static int nordicsemi_nrf54l_init(void) |
165 | 158 | nrf_regulators_vreg_enable_set(NRF_REGULATORS, NRF_REGULATORS_VREG_MAIN, true); |
166 | 159 | #endif |
167 | 160 |
|
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 |
169 | 177 |
|
170 | 178 | return 0; |
171 | 179 | } |
|
0 commit comments