Commit f611fdd6 authored by Gerard Marull-Paretas's avatar Gerard Marull-Paretas Committed by Fabio Baltieri
Browse files

soc: nordic: nrf53: add option to enable cpunet



When not using BT, users may want to enable the cpunet core. Until now,
this has been done at board level (so duplicating unnecessary code)
using CONFIG_BOARD_ENABLE_CPUNET. The board-level options were usually
enabled automatically for BT, however, this was unnecessary as BT driver
already takes care of the setup.

Signed-off-by: default avatarGerard Marull-Paretas <gerard@teslabs.com>
parent 8bc461eb
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -145,6 +145,24 @@ config SOC_NRF53_CPUNET_MGMT
	help
	  hidden option for including the nRF53 network CPU management

config SOC_NRF53_CPUNET_ENABLE
	bool "NRF53 Network MCU is enabled at boot time"
	depends on !BT
	default y if NRF_802154_SER_HOST
	select SOC_NRF53_CPUNET_MGMT
	select SOC_NRF_GPIO_FORWARDER_FOR_NRF5340 if \
		$(dt_compat_enabled,$(DT_COMPAT_NORDIC_NRF_GPIO_FORWARDER))
	help
	  This option enables releasing the Network 'force off' signal, which
	  as a consequence will power up the Network MCU during system boot.
	  Additionally, the option allocates GPIO pins that will be used by UARTE
	  of the Network MCU.
	  Note: GPIO pin allocation can only be configured by the secure Application
	  MCU firmware, so when this option is used with the non-secure version of
	  the board, the application needs to take into consideration, that the
	  secure firmware image must already have configured GPIO allocation for the
	  Network MCU.

if !TRUSTED_EXECUTION_NONSECURE || BUILD_WITH_TFM

config SOC_ENABLE_LFXO
+28 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#include <zephyr/sys/onoff.h>

#include <hal/nrf_reset.h>
#include <hal/nrf_spu.h>

static struct onoff_manager cpunet_mgr;

@@ -66,3 +67,30 @@ void nrf53_cpunet_enable(bool on)

	__ASSERT_NO_MSG(ret >= 0);
}

#ifdef CONFIG_SOC_NRF53_CPUNET_ENABLE
static int nrf53_cpunet_init(void)
{
#if !defined(CONFIG_TRUSTED_EXECUTION_NONSECURE)
	/* Retain nRF5340 Network MCU in Secure domain (bus
	 * accesses by Network MCU will have Secure attribute set).
	 */
	nrf_spu_extdomain_set((NRF_SPU_Type *)DT_REG_ADDR(DT_NODELABEL(spu)), 0, true, false);
#endif /* !defined(CONFIG_TRUSTED_EXECUTION_NONSECURE) */

#if !defined(CONFIG_TRUSTED_EXECUTION_SECURE)
	/*
	 * Building Zephyr with CONFIG_TRUSTED_EXECUTION_SECURE=y implies
	 * building also a Non-Secure image. The Non-Secure image will, in
	 * this case do the remainder of actions to properly configure and
	 * boot the Network MCU.
	 */

	nrf53_cpunet_enable(true);
#endif /* !CONFIG_TRUSTED_EXECUTION_SECURE */

	return 0;
}

SYS_INIT(nrf53_cpunet_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE);
#endif /* CONFIG_SOC_NRF53_CPUNET_ENABLE */