Skip to content

Commit 5d65d00

Browse files
travis3630rlubos
authored andcommitted
soc: nordic: nrf7120: Update wifi for ns build
Update Wi-FI setup for non secure build, In nrf7120pdk/nrf7120/cpuapp build, mpc and spu configuration are done in soc.c. In nrf7120pdk/nrf7120/cpuapp/ns build, mpc and spu configuration are done target_cfg_71.c(Secure processing environment). Signed-off-by: Travis Lam <[email protected]>
1 parent caa50df commit 5d65d00

File tree

2 files changed

+35
-49
lines changed

2 files changed

+35
-49
lines changed

soc/nordic/nrf71/Kconfig

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,4 @@ config NRF_TRUSTZONE_RAM_REGION_SIZE
5050
This abstraction allows us to configure TRUSTZONE without depending
5151
on peripheral specific symbols.
5252

53-
# TODO: Remove this option once all pre-ENG variants support AMBIX03
54-
config SOC_NRF7120_HAS_AMBIX03
55-
bool "AMBIX03 available"
56-
depends on SOC_NRF7120_PREENG
57-
5853
endif # SOC_SERIES_NRF71X

soc/nordic/nrf71/soc.c

Lines changed: 35 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,8 @@
3838

3939
LOG_MODULE_REGISTER(soc, CONFIG_SOC_LOG_LEVEL);
4040

41-
static inline void write_reg32(uintptr_t addr, uint32_t value)
42-
{
43-
*((volatile uint32_t *)addr) = value;
44-
}
45-
46-
/* Copied from TF-M implementation */
41+
#if !defined(CONFIG_TRUSTED_EXECUTION_NONSECURE)
42+
/* Copied from TF-M native driver */
4743
struct mpc_region_override {
4844
nrf_mpc_override_config_t config;
4945
nrf_owner_t owner_id;
@@ -111,6 +107,7 @@ static inline NRF_SPU_Type *spu_instance_from_peripheral_addr(uint32_t periphera
111107
return (NRF_SPU_Type *)(0x50000000 | apb_bus_number);
112108
}
113109

110+
#ifdef CONFIG_BOARD_NRF7120PDK_NRF7120_CPUAPP_EMU
114111
static void spu_peripheral_config_non_secure(const uint32_t periph_base_address, bool periph_lock)
115112
{
116113
uint8_t periph_id = NRFX_PERIPHERAL_ID_GET(periph_base_address);
@@ -135,56 +132,55 @@ static void spu_peripheral_config_non_secure(const uint32_t periph_base_address,
135132
nrf_spu_periph_perm_lock_enable(nrf_spu, index);
136133
#endif
137134
}
135+
#endif /* CONFIG_BOARD_NRF7120PDK_NRF7120_CPUAPP_EMU */
136+
/* End of TF-M native driver */
138137

139-
#define MPC00_OVERRIDE_COUNT 7
140-
static uint32_t get_mpc00_override_next_index(void)
141-
{
142-
static uint32_t index;
143-
144-
NRFX_ASSERT(index < MPC00_OVERRIDE_COUNT);
145-
return index++;
146-
}
147-
148-
#ifdef CONFIG_SOC_NRF7120_HAS_AMBIX03
149-
#define MPC03_OVERRIDE_COUNT 4
150-
static uint32_t get_mpc03_override_next_index(void)
151-
{
152-
static uint32_t index;
153-
154-
NRFX_ASSERT(index < MPC03_OVERRIDE_COUNT);
155-
return index++;
156-
}
157-
#endif /* CONFIG_SOC_NRF7120_HAS_AMBIX03 */
158-
159-
static void wifi_setup(void)
138+
void wifi_mpc_configuration(void)
160139
{
161140
struct mpc_region_override override;
141+
uint32_t index = 0;
162142

163143
/* Make RAM_00/01/02 (AMBIX00 + AMBIX03) accessible to the Wi-Fi domain*/
164144
init_mpc_region_override(&override);
165145
override.start_address = 0x20000000;
166146
override.endaddr = 0x200E0000;
167-
override.index = get_mpc00_override_next_index();
147+
override.index = index++;
168148
mpc_configure_override(NRF_MPC00, &override);
169149

170150
/* MRAM MPC overrides for wifi */
171151
init_mpc_region_override(&override);
172152
override.start_address = 0x00000000;
173153
override.endaddr = 0x01000000;
174-
override.index = get_mpc00_override_next_index();
154+
override.index = index++;
175155
mpc_configure_override(NRF_MPC00, &override);
176156

177-
#ifdef CONFIG_SOC_NRF7120_HAS_AMBIX03
178157
/* Make RAM_02 (AMBIX03) accessible to the Wi-Fi domain for IPC */
179158
init_mpc_region_override(&override);
180159
override.start_address = 0x200C0000;
181160
override.endaddr = 0x200E0000;
182-
override.index = get_mpc03_override_next_index();
161+
override.index = 0;
183162
mpc_configure_override(NRF_MPC03, &override);
184-
#endif /* CONFIG_SOC_NRF7120_HAS_AMBIX03 */
163+
}
185164

186-
/* Make GRTC accessible from the WIFI-Core */
187-
spu_peripheral_config_non_secure(NRF_GRTC_S_BASE, true);
165+
void grtc_configuration(void)
166+
{
167+
/* Split security configuration to let Wi-Fi access GRTC */
168+
nrf_spu_feature_secattr_set(NRF_SPU20, NRF_SPU_FEATURE_GRTC_CC, 15, 0, 0);
169+
nrf_spu_feature_secattr_set(NRF_SPU20, NRF_SPU_FEATURE_GRTC_CC, 14, 0, 0);
170+
nrf_spu_feature_secattr_set(NRF_SPU20, NRF_SPU_FEATURE_GRTC_INTERRUPT, 4, 0, 0);
171+
nrf_spu_feature_secattr_set(NRF_SPU20, NRF_SPU_FEATURE_GRTC_INTERRUPT, 5, 0, 0);
172+
nrf_spu_feature_secattr_set(NRF_SPU20, NRF_SPU_FEATURE_GRTC_SYSCOUNTER, 0, 0, 0);
173+
}
174+
#endif /* CONFIG_TRUSTED_EXECUTION_NONSECURE */
175+
176+
#if !defined(CONFIG_TRUSTED_EXECUTION_NONSECURE) || defined(__NRF_TFM__)
177+
void wifi_setup(void)
178+
{
179+
#if !defined(CONFIG_TRUSTED_EXECUTION_NONSECURE)
180+
/* Skip for tf-m, configuration exist in target_cfg_71.c */
181+
wifi_mpc_configuration();
182+
183+
grtc_configuration();
188184

189185
/* EMU platform uses UART 20 for the Wi-Fi console */
190186
#ifdef CONFIG_BOARD_NRF7120PDK_NRF7120_CPUAPP_EMU
@@ -196,21 +192,16 @@ static void wifi_setup(void)
196192
/* Set permission for TXD */
197193
nrf_spu_feature_secattr_set(NRF_SPU20, NRF_SPU_FEATURE_GPIO_PIN, 1, 4,
198194
SPU_FEATURE_GPIO_PIN_SECATTR_NonSecure);
199-
#endif /* CONFIG_BOARD_NRF7120PDK_NRF7120_CPUAPP_EMU */
200-
201-
/* Split security configuration to let Wi-Fi access GRTC */
202-
nrf_spu_feature_secattr_set(NRF_SPU20, NRF_SPU_FEATURE_GRTC_CC, 15, 0, 0);
203-
nrf_spu_feature_secattr_set(NRF_SPU20, NRF_SPU_FEATURE_GRTC_CC, 14, 0, 0);
204-
nrf_spu_feature_secattr_set(NRF_SPU20, NRF_SPU_FEATURE_GRTC_INTERRUPT, 4, 0, 0);
205-
nrf_spu_feature_secattr_set(NRF_SPU20, NRF_SPU_FEATURE_GRTC_INTERRUPT, 5, 0, 0);
206-
nrf_spu_feature_secattr_set(NRF_SPU20, NRF_SPU_FEATURE_GRTC_SYSCOUNTER, 0, 0, 0);
195+
#endif
196+
#endif
207197

208198
/* Kickstart the LMAC processor */
209199
NRF_WIFICORE_LRCCONF_LRC0->POWERON =
210200
(LRCCONF_POWERON_MAIN_AlwaysOn << LRCCONF_POWERON_MAIN_Pos);
211201
NRF_WIFICORE_LMAC_VPR->INITPC = NRF_WICR->RESERVED[0];
212202
NRF_WIFICORE_LMAC_VPR->CPURUN = (VPR_CPURUN_EN_Running << VPR_CPURUN_EN_Pos);
213203
}
204+
#endif
214205

215206
void soc_early_init_hook(void)
216207
{
@@ -220,18 +211,18 @@ void soc_early_init_hook(void)
220211
#if !defined(CONFIG_TRUSTED_EXECUTION_NONSECURE) || defined(__NRF_TFM__)
221212
/* Currently not supported for non-secure */
222213
SystemCoreClockUpdate();
214+
wifi_setup();
223215
#endif
224216

225217
#ifdef __NRF_TFM__
226-
/* TF-M enables the instruction cache from target_cfg.c, so we
218+
/* TF-M enables the instruction cache from target_cfg_71.c, so we
227219
* don't need to enable it here.
228220
*/
229221
#else
230222
/* Enable ICACHE */
231223
sys_cache_instr_enable();
232224
#endif
233225

234-
wifi_setup();
235226
}
236227

237228
void arch_busy_wait(uint32_t time_us)

0 commit comments

Comments
 (0)