Skip to content

Commit 34963bf

Browse files
committed
Revert "[nrf noup] soc: nordic: nrf54l: Port Soc.c to be compatible with TFM"
This reverts commit 840fc45. Signed-off-by: Krzysztof Chruściński <[email protected]>
1 parent 8f015cb commit 34963bf

File tree

1 file changed

+17
-49
lines changed

1 file changed

+17
-49
lines changed

soc/nordic/nrf54l/soc.c

Lines changed: 17 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,13 @@
1212
* for the Nordic Semiconductor nRF54L family processor.
1313
*/
1414

15-
#ifdef __NRF_TFM__
16-
#include <autoconf.h>
17-
#endif
18-
1915
#include <zephyr/devicetree.h>
2016
#include <zephyr/dt-bindings/regulator/nrf5x.h>
2117
#include <zephyr/kernel.h>
2218
#include <zephyr/devicetree.h>
2319
#include <zephyr/init.h>
2420
#include <zephyr/logging/log.h>
25-
26-
#ifndef __NRF_TFM__
2721
#include <zephyr/cache.h>
28-
#endif
29-
3022
#include <zephyr/dt-bindings/regulator/nrf5x.h>
3123

3224
#if defined(NRF_APPLICATION)
@@ -48,9 +40,17 @@ LOG_MODULE_REGISTER(soc, CONFIG_SOC_LOG_LEVEL);
4840
#define HFXO_NODE DT_NODELABEL(hfxo)
4941
#endif
5042

51-
#if defined(NRF_APPLICATION)
52-
static inline void power_and_clock_configuration(void)
43+
static int nordicsemi_nrf54l_init(void)
5344
{
45+
/* Update the SystemCoreClock global variable with current core clock
46+
* retrieved from hardware state.
47+
*/
48+
SystemCoreClockUpdate();
49+
50+
#if defined(NRF_APPLICATION)
51+
/* Enable ICACHE */
52+
sys_cache_instr_enable();
53+
5454
#if DT_ENUM_HAS_VALUE(LFXO_NODE, load_capacitors, internal)
5555
uint32_t xosc32ktrim = NRF_FICR->XOSC32KTRIM;
5656

@@ -77,16 +77,16 @@ static inline void power_and_clock_configuration(void)
7777
* NOTE: The desired capacitance value is used in encoded from in INTCAP calculation formula
7878
* That is different than in case of HFXO.
7979
*/
80-
uint32_t cap_val_encoded =
81-
(((DT_PROP(LFXO_NODE, load_capacitance_femtofarad) - 4000UL) * 2UL) / 1000UL);
80+
uint32_t cap_val_encoded = (((DT_PROP(LFXO_NODE, load_capacitance_femtofarad) - 4000UL)
81+
* 2UL) / 1000UL);
8282

8383
/* Calculation of INTCAP code before rounding. Min that calculations here are done on
8484
* values multiplied by 2^9, e.g. 0.765625 * 2^9 = 392.
8585
* offset_k should be divided by 2^6, but to add it to value shifted by 2^9 we have to
8686
* multiply it be 2^3.
8787
*/
88-
uint32_t mid_val =
89-
(cap_val_encoded - 4UL) * (uint32_t)(slope_k + 392UL) + (offset_k << 3UL);
88+
uint32_t mid_val = (cap_val_encoded - 4UL) * (uint32_t)(slope_k + 392UL)
89+
+ (offset_k << 3UL);
9090

9191
/* Get integer part of the INTCAP code */
9292
uint32_t lfxo_intcap = mid_val >> 9UL;
@@ -132,9 +132,8 @@ static inline void power_and_clock_configuration(void)
132132
*/
133133
uint32_t cap_val_femto_f = DT_PROP(HFXO_NODE, load_capacitance_femtofarad);
134134

135-
uint32_t mid_val_intcap = (((cap_val_femto_f - 5500UL) * (uint32_t)(slope_m + 791UL)) +
136-
(offset_m << 2UL) * 1000UL) >>
137-
8UL;
135+
uint32_t mid_val_intcap = (((cap_val_femto_f - 5500UL) * (uint32_t)(slope_m + 791UL))
136+
+ (offset_m << 2UL) * 1000UL) >> 8UL;
138137

139138
/* Convert the calculated value to piko Farads */
140139
uint32_t hfxo_intcap = mid_val_intcap / 1000;
@@ -164,39 +163,8 @@ static inline void power_and_clock_configuration(void)
164163
#endif
165164
nrf_regulators_vreg_enable_set(NRF_REGULATORS, NRF_REGULATORS_VREG_MAIN, true);
166165
#endif
167-
}
168-
#endif /* NRF_APPLICATION */
169166

170-
int nordicsemi_nrf54l_init(void)
171-
{
172-
/* Update the SystemCoreClock global variable with current core clock
173-
* retrieved from hardware state.
174-
*/
175-
#if !defined(CONFIG_TRUSTED_EXECUTION_NONSECURE) || defined(__NRF_TFM__)
176-
/* Currently not supported for non-secure */
177-
SystemCoreClockUpdate();
178-
#endif
179-
180-
#ifdef __NRF_TFM__
181-
/* TF-M enables the instruction cache from target_cfg.c, so we
182-
* don't need to enable it here.
183-
*/
184-
#else
185-
/* Enable ICACHE */
186-
sys_cache_instr_enable();
187-
#endif
188-
189-
/* NRF_REGULATORS and NRF_OSCILLATORS are configured to be secure
190-
* as NRF_REGULATORS.POFCON is needed by the secure domain to
191-
* prevent glitches when the power supply is attacked.
192-
*
193-
* NRF_OSCILLATORS is also configured as secure because of a HW limitation
194-
* that requires them to be configured with the same security property.
195-
*/
196-
#if (defined(NRF_APPLICATION) && !defined(CONFIG_TRUSTED_EXECUTION_NONSECURE)) || \
197-
defined(__NRF_TFM__)
198-
power_and_clock_configuration();
199-
#endif
167+
#endif /* NRF_APPLICATION */
200168

201169
return 0;
202170
}

0 commit comments

Comments
 (0)