diff --git a/arch/arm/src/nrf53/CMakeLists.txt b/arch/arm/src/nrf53/CMakeLists.txt index 578753af53..e3b539489a 100644 --- a/arch/arm/src/nrf53/CMakeLists.txt +++ b/arch/arm/src/nrf53/CMakeLists.txt @@ -26,7 +26,8 @@ set(SRCS nrf53_allocateheap.c nrf53_lowputc.c nrf53_gpio.c - nrf53_uid.c) + nrf53_uid.c + nrf53_spu.c) if(CONFIG_NRF53_SYSTIMER_SYSTICK) list(APPEND SRCS nrf53_systick.c) diff --git a/arch/arm/src/nrf53/Make.defs b/arch/arm/src/nrf53/Make.defs index 5f33f0ae9d..4df869ebcf 100644 --- a/arch/arm/src/nrf53/Make.defs +++ b/arch/arm/src/nrf53/Make.defs @@ -22,7 +22,7 @@ include armv8-m/Make.defs CHIP_CSRCS += nrf53_start.c nrf53_clockconfig.c nrf53_irq.c nrf53_utils.c CHIP_CSRCS += nrf53_allocateheap.c nrf53_lowputc.c nrf53_gpio.c -CHIP_CSRCS += nrf53_uid.c +CHIP_CSRCS += nrf53_uid.c nrf53_spu.c ifeq ($(CONFIG_NRF53_SYSTIMER_SYSTICK),y) CHIP_CSRCS += nrf53_systick.c diff --git a/arch/arm/src/nrf53/nrf53_rptun.c b/arch/arm/src/nrf53/nrf53_rptun.c index 1d7a8d04a6..3f4fb1b4c2 100644 --- a/arch/arm/src/nrf53/nrf53_rptun.c +++ b/arch/arm/src/nrf53/nrf53_rptun.c @@ -33,7 +33,6 @@ #include #include "arm_internal.h" -#include "hardware/nrf53_spu.h" #include "nrf53_ipc.h" @@ -494,12 +493,6 @@ int nrf53_rptun_init(const char *shmemname, const char *cpuname) dev->master = false; #endif -#ifdef CONFIG_NRF53_APPCORE - /* Set secure domain - this allows net core to access shared mem */ - - putreg32(SPU_EXTDOMAIN_SECUREMAPPING_SECATTR, NRF53_SPU_EXTDOMAIN(0)); -#endif - /* Subscribe to IPC */ #ifdef CONFIG_NRF53_APPCORE diff --git a/arch/arm/src/nrf53/nrf53_spu.c b/arch/arm/src/nrf53/nrf53_spu.c new file mode 100644 index 0000000000..f7d2147868 --- /dev/null +++ b/arch/arm/src/nrf53/nrf53_spu.c @@ -0,0 +1,58 @@ +/**************************************************************************** + * arch/arm/src/nrf53/nrf53_spu.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include "arm_internal.h" + +#include "hardware/nrf53_spu.h" + +#include "nrf53_spu.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +#ifdef HAVE_SPU_CONFIG +/**************************************************************************** + * Name: nrf53_spu_configure + ****************************************************************************/ + +void nrf53_spu_configure(void) +{ +#ifdef CONFIG_RPTUN + /* Set secure domain - this allows net core to access shared mem */ + + putreg32(SPU_EXTDOMAIN_SECUREMAPPING_SECATTR, NRF53_SPU_EXTDOMAIN(0)); +#endif +} +#endif diff --git a/arch/arm/src/nrf53/nrf53_spu.h b/arch/arm/src/nrf53/nrf53_spu.h new file mode 100644 index 0000000000..59e3518c0b --- /dev/null +++ b/arch/arm/src/nrf53/nrf53_spu.h @@ -0,0 +1,55 @@ +/**************************************************************************** + * arch/arm/src/nrf53/nrf53_spu.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __ARCH_ARM_SRC_NRF53_NRF53_SPU_H +#define __ARCH_ARM_SRC_NRF53_NRF53_SPU_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* SPU only for secure app core image */ + +#if defined(CONFIG_NRF53_APPCORE) && \ + !defined(CONFIG_ARCH_TRUSTZONE_NONSECURE) +# define HAVE_SPU_CONFIG +#else +# undef HAVE_SPU_CONFIG +#endif + +/**************************************************************************** + * Public Functions Prototypes + ****************************************************************************/ + +#ifdef HAVE_SPU_CONFIG +/**************************************************************************** + * Name: nrf53_spu_configure + ****************************************************************************/ + +void nrf53_spu_configure(void); +#endif + +#endif /* __ARCH_ARM_SRC_NRF53_NRF53_SPU_H */ diff --git a/arch/arm/src/nrf53/nrf53_start.c b/arch/arm/src/nrf53/nrf53_start.c index c5647768bf..2850f82353 100644 --- a/arch/arm/src/nrf53/nrf53_start.c +++ b/arch/arm/src/nrf53/nrf53_start.c @@ -45,6 +45,7 @@ #include "nrf53_cpunet.h" #include "nrf53_gpio.h" #include "nrf53_serial.h" +#include "nrf53_spu.h" /**************************************************************************** * Pre-processor Definitions @@ -184,6 +185,12 @@ void __start(void) __asm__ __volatile__ ("\tcpsid i\n"); +#ifdef HAVE_SPU_CONFIG + /* Configure SPU before cpunet boot */ + + nrf53_spu_configure(); +#endif + /* Handle APPROTECT configuration */ nrf53_approtect();