Skip to content

Commit 565a30c

Browse files
travis3630tomi-font
authored andcommitted
[nrf fromtree] platform: nrf7120: add wifi-setup support
Add WiFi mpc and spu configuration in target_cfg_71, as it is isolated in nrf7120/soc.c. Change-Id: Ifbfe70bad6b78b1b2f780c903a5f1a68d0c7ed1e Signed-off-by: Travis Lam <travis.lam@nordicsemi.no> (cherry picked from commit 7458a959dc0eb3c52603b7dafea9799ad6cdf779)
1 parent 040c1e2 commit 565a30c

File tree

2 files changed

+95
-8
lines changed

2 files changed

+95
-8
lines changed

platform/ext/target/nordic_nrf/common/core/target_cfg_71.c

Lines changed: 86 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,15 @@ enum tfm_plat_err_t nrf_mpc_init_cfg(void)
204204
* owner ID 0.
205205
*/
206206

207-
uint32_t index = 0;
207+
/* Related ticket: WZN-7283 and WZN-7278
208+
* assigning Wi-Fi register in MPC00 to be non-secure to align with Wi-Fi non secure base address
209+
* NRF_MPC->REGION[9].CONFIG = 0x320A; w-r = 1, secattr = NS , slave_num = 10
210+
*/
211+
*(volatile uint32_t*) 0x50041690 = 0x320A;
212+
213+
uint32_t index_mpc00 = 0;
214+
uint32_t index_mpc03 = 0;
215+
208216
/*
209217
* Configure the non-secure partition of the non-volatile
210218
* memory. This MPC region is intended to cover both the
@@ -218,7 +226,7 @@ enum tfm_plat_err_t nrf_mpc_init_cfg(void)
218226

219227
override.start_address = memory_regions.non_secure_partition_base;
220228
override.endaddr = NRF_UICR_S_BASE;
221-
override.index = index++;
229+
override.index = index_mpc00++;
222230

223231
mpc_configure_override(NRF_MPC00, &override);
224232
}
@@ -231,25 +239,72 @@ enum tfm_plat_err_t nrf_mpc_init_cfg(void)
231239

232240
override.start_address = NS_DATA_START;
233241
override.endaddr = 1 + NS_DATA_LIMIT;
234-
override.index = index++;
242+
override.index = index_mpc00++;
243+
244+
mpc_configure_override(NRF_MPC00, &override);
245+
}
246+
247+
/* Wi-Fi registers addr */
248+
{
249+
struct mpc_region_override override;
250+
251+
init_mpc_region_override(&override);
252+
253+
override.start_address = 0x48000000;
254+
override.endaddr = 0x48100000;
255+
override.index = index_mpc00++;
235256

236257
mpc_configure_override(NRF_MPC00, &override);
237258
}
238259

239-
if (index > 6) {
240-
/* Used more overrides than are available */
241-
tfm_core_panic();
260+
/* Configure RAM02 non-secure access via MPC00 for Wi-Fi non-sec access */
261+
{
262+
struct mpc_region_override override;
263+
264+
init_mpc_region_override(&override);
265+
266+
override.start_address = 0x200C0000;
267+
override.endaddr = 0x200E0000;
268+
override.index = index_mpc00++;
269+
270+
mpc_configure_override(NRF_MPC00, &override);
271+
}
272+
273+
/* Configure RAM02 non-secure access via MPC03 for Wi-Fi non-sec access */
274+
{
275+
struct mpc_region_override override;
276+
277+
init_mpc_region_override(&override);
278+
279+
override.start_address = 0x200C0000;
280+
override.endaddr = 0x200E0000;
281+
override.index = index_mpc03++;
282+
283+
mpc_configure_override(NRF_MPC03, &override);
242284
}
243285

244286
/* Lock and disable any unused MPC overrides to prevent malicious configuration */
245-
while (index <= 6) {
287+
while (index_mpc00 <= 6) {
246288
struct mpc_region_override override;
247289

248290
init_mpc_region_override(&override);
249291

250292
override.config.enable = false;
251293

252-
override.index = index++;
294+
override.index = index_mpc00++;
295+
296+
mpc_configure_override(NRF_MPC00, &override);
297+
}
298+
299+
/* Lock and disable any unused MPC overrides to prevent malicious configuration */
300+
while (index_mpc03 <= 3) {
301+
struct mpc_region_override override;
302+
303+
init_mpc_region_override(&override);
304+
305+
override.config.enable = false;
306+
307+
override.index = index_mpc03++;
253308

254309
mpc_configure_override(NRF_MPC00, &override);
255310
}
@@ -395,6 +450,28 @@ static void gpio_configuration(void)
395450
}
396451
}
397452

453+
void wifi_peripherals_configuration(void)
454+
{
455+
/* Split security configuration to let Wi-Fi access GRTC */
456+
nrf_spu_feature_secattr_set(NRF_SPU20, NRF_SPU_FEATURE_GRTC_CC, 15, 0, 0);
457+
nrf_spu_feature_secattr_set(NRF_SPU20, NRF_SPU_FEATURE_GRTC_CC, 14, 0, 0);
458+
nrf_spu_feature_secattr_set(NRF_SPU20, NRF_SPU_FEATURE_GRTC_INTERRUPT, 4, 0, 0);
459+
nrf_spu_feature_secattr_set(NRF_SPU20, NRF_SPU_FEATURE_GRTC_INTERRUPT, 5, 0, 0);
460+
nrf_spu_feature_secattr_set(NRF_SPU20, NRF_SPU_FEATURE_GRTC_SYSCOUNTER, 0, 0, 0);
461+
462+
/* TODO: Wi-Fi VPR uses UART 20 (PORT 2 Pin 2 is for the TX)
463+
* remove this line when we move to new PINSET that support uart20:
464+
* https://nordicsemi.atlassian.net/browse/WZN-6764
465+
*/
466+
spu_peripheral_config_non_secure(NRF_UARTE20_S_BASE, true);
467+
nrf_spu_feature_secattr_set(NRF_SPU00, NRF_SPU_FEATURE_GPIO_PIN, 2, 2,
468+
SPU_FEATURE_GPIO_PIN_SECATTR_NonSecure);
469+
470+
/* Set permission for TXD */
471+
nrf_spu_feature_secattr_set(NRF_SPU20, NRF_SPU_FEATURE_GPIO_PIN, 1, 4,
472+
SPU_FEATURE_GPIO_PIN_SECATTR_NonSecure);
473+
}
474+
398475
enum tfm_plat_err_t spu_periph_init_cfg(void)
399476
{
400477
/* Peripheral configuration */
@@ -430,6 +507,7 @@ enum tfm_plat_err_t spu_periph_init_cfg(void)
430507

431508
gpiote_channel_configuration();
432509
gpio_configuration();
510+
wifi_peripherals_configuration();
433511

434512
nrf_cache_enable(NRF_ICACHE);
435513

platform/ext/target/nordic_nrf/common/nrf7120/nrf71_init.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,22 @@
1919
* It is defined as weak to allow the sdk-nrf version to be used when available. */
2020
void __attribute__((weak)) CRACEN_IRQHandler(void){};
2121

22+
void __attribute__((weak)) wifi_setup(void){
23+
/* Kickstart the LMAC processor */
24+
NRF_WIFICORE_LRCCONF_LRC0->POWERON =
25+
(LRCCONF_POWERON_MAIN_AlwaysOn << LRCCONF_POWERON_MAIN_Pos);
26+
NRF_WIFICORE_LMAC_VPR->INITPC = NRF_WICR->RESERVED[0];
27+
NRF_WIFICORE_LMAC_VPR->CPURUN = (VPR_CPURUN_EN_Running << VPR_CPURUN_EN_Pos);
28+
}
29+
2230
int __attribute__((weak)) soc_early_init_hook(void){
2331
/* Update the SystemCoreClock global variable with current core clock
2432
* retrieved from hardware state.
2533
*/
2634
#if !defined(CONFIG_TRUSTED_EXECUTION_NONSECURE) || defined(__NRF_TFM__)
2735
/* Currently not supported for non-secure */
2836
SystemCoreClockUpdate();
37+
wifi_setup();
2938
#endif
3039
return 0;
3140
}

0 commit comments

Comments
 (0)