From ee458692b5e96e5d3d814432d2095be02e0b0c43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B8e?= Date: Fri, 25 Apr 2025 09:02:32 +0200 Subject: [PATCH] soc: nrf53: Port nrf53_cpunet_mgmt_init to soc_early_init_hook MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Port from SYS_INIT to soc_early_init_hook because SYS_INIT is legacy. Signed-off-by: Sebastian Bøe --- soc/nordic/nrf53/nrf53_cpunet_mgmt.c | 4 +--- soc/nordic/nrf53/nrf53_cpunet_mgmt.h | 18 ++++++++++++++++++ soc/nordic/nrf53/soc.c | 7 +++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/soc/nordic/nrf53/nrf53_cpunet_mgmt.c b/soc/nordic/nrf53/nrf53_cpunet_mgmt.c index f566fafff09..823bd4a2515 100644 --- a/soc/nordic/nrf53/nrf53_cpunet_mgmt.c +++ b/soc/nordic/nrf53/nrf53_cpunet_mgmt.c @@ -67,7 +67,7 @@ static void onoff_stop(struct onoff_manager *mgr, onoff_notify_fn notify) notify(mgr, 0); } -static int nrf53_cpunet_mgmt_init(void) +int nrf53_cpunet_mgmt_init(void) { static const struct onoff_transitions transitions = { .start = onoff_start, @@ -77,8 +77,6 @@ static int nrf53_cpunet_mgmt_init(void) return onoff_manager_init(&cpunet_mgr, &transitions); } -SYS_INIT(nrf53_cpunet_mgmt_init, PRE_KERNEL_1, 0); - void nrf53_cpunet_enable(bool on) { int ret; diff --git a/soc/nordic/nrf53/nrf53_cpunet_mgmt.h b/soc/nordic/nrf53/nrf53_cpunet_mgmt.h index 5427af0be7f..184d27c781b 100644 --- a/soc/nordic/nrf53/nrf53_cpunet_mgmt.h +++ b/soc/nordic/nrf53/nrf53_cpunet_mgmt.h @@ -33,4 +33,22 @@ void nrf53_cpunet_enable(bool on); */ void nrf53_cpunet_init(void); +/** + * @brief Initialize the CPU network management system for the nRF5340. + * + * This function sets up an on-off manager for managing the network core of the nRF5340. + * It configures the necessary transitions for starting and stopping the network core. + * + * The function also ensures proper handling of GPIO pin forwarding when the + * `CONFIG_SOC_NRF_GPIO_FORWARDER_FOR_NRF5340` configuration is enabled. Pins are + * forwarded to the network core during startup and reassigned to the application + * core during shutdown. + * + * @return 0 on success, or a negative error code on failure. + * + * @note This function relies on the `onoff_manager` API to manage the start and stop + * transitions for the network core. + */ +int nrf53_cpunet_mgmt_init(void); + #endif /* NRF53_CPUNET_MGMT_H__ */ diff --git a/soc/nordic/nrf53/soc.c b/soc/nordic/nrf53/soc.c index 7fbe69b434b..e53a3e75231 100644 --- a/soc/nordic/nrf53/soc.c +++ b/soc/nordic/nrf53/soc.c @@ -553,6 +553,13 @@ void soc_early_init_hook(void) #if defined(CONFIG_SOC_DCDC_NRF53X_HV) || DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(vregh)) nrf_regulators_vreg_enable_set(NRF_REGULATORS, NRF_REGULATORS_VREG_HIGH, true); #endif + +#if defined(CONFIG_SOC_NRF53_CPUNET_MGMT) + int err = nrf53_cpunet_mgmt_init(); + + __ASSERT_NO_MSG(err == 0); + (void)err; +#endif } void soc_late_init_hook(void)