@@ -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+
398475enum 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
0 commit comments