soc: nordic: nrf53: network CPU Force-OFF management
This commit introduces a common API for managing nRF53 SoC network CPU Force-OFF state. From the application CPU point of view, the network CPU is a shared resource used by multiple users. The current solution where every user controls the network core state directly leads to dependencies between users and does not scale well. To address this problem there should be a single entity responsible for controlling the network CPU Force-OFF signal. This commit introduces such module. Signed-off-by: Jędrzej Ciupis <jedrzej.ciupis@nordicsemi.no>
This commit is contained in:
parent
5600ae335b
commit
ec3c3f153b
|
@ -3,6 +3,7 @@
|
|||
zephyr_library_sources(soc.c)
|
||||
zephyr_include_directories(.)
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_SOC_NRF53_CPUNET_MGMT nrf53_cpunet_mgmt.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_NRF53_SYNC_RTC sync_rtc.c)
|
||||
|
||||
if (CONFIG_SOC_NRF53_ANOMALY_160_WORKAROUND_NEEDED AND
|
||||
|
|
|
@ -24,6 +24,7 @@ config SOC_NRF5340_CPUAPP
|
|||
select ARMV8_M_DSP
|
||||
select HAS_POWEROFF
|
||||
select SOC_COMPATIBLE_NRF5340_CPUAPP
|
||||
select SOC_NRF53_CPUNET_MGMT
|
||||
imply SOC_NRF53_RTC_PRETICK
|
||||
imply SOC_NRF53_ANOMALY_168_WORKAROUND
|
||||
|
||||
|
@ -138,6 +139,12 @@ config SOC_NRF_GPIO_FORWARDER_FOR_NRF5340
|
|||
help
|
||||
hidden option for including the nRF GPIO pin forwarding
|
||||
|
||||
config SOC_NRF53_CPUNET_MGMT
|
||||
bool
|
||||
select ONOFF
|
||||
help
|
||||
hidden option for including the nRF53 network CPU management
|
||||
|
||||
if !TRUSTED_EXECUTION_NONSECURE || BUILD_WITH_TFM
|
||||
|
||||
config SOC_ENABLE_LFXO
|
||||
|
|
68
soc/nordic/nrf53/nrf53_cpunet_mgmt.c
Normal file
68
soc/nordic/nrf53/nrf53_cpunet_mgmt.c
Normal file
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* Copyright (c) 2024 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file Nordic Semiconductor nRF53 processors family management helper for the network CPU.
|
||||
*/
|
||||
|
||||
#include <nrf53_cpunet_mgmt.h>
|
||||
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/init.h>
|
||||
#include <zephyr/sys/__assert.h>
|
||||
#include <zephyr/sys/notify.h>
|
||||
#include <zephyr/sys/onoff.h>
|
||||
|
||||
#include <hal/nrf_reset.h>
|
||||
|
||||
static struct onoff_manager cpunet_mgr;
|
||||
|
||||
static void onoff_start(struct onoff_manager *mgr, onoff_notify_fn notify)
|
||||
{
|
||||
nrf_reset_network_force_off(NRF_RESET, false);
|
||||
|
||||
notify(mgr, 0);
|
||||
}
|
||||
|
||||
static void onoff_stop(struct onoff_manager *mgr, onoff_notify_fn notify)
|
||||
{
|
||||
nrf_reset_network_force_off(NRF_RESET, true);
|
||||
|
||||
notify(mgr, 0);
|
||||
}
|
||||
|
||||
static int nrf53_cpunet_mgmt_init(void)
|
||||
{
|
||||
static const struct onoff_transitions transitions = {
|
||||
.start = onoff_start,
|
||||
.stop = onoff_stop
|
||||
};
|
||||
|
||||
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;
|
||||
int ignored;
|
||||
struct onoff_client cli;
|
||||
|
||||
if (on) {
|
||||
sys_notify_init_spinwait(&cli.notify);
|
||||
|
||||
ret = onoff_request(&cpunet_mgr, &cli);
|
||||
__ASSERT_NO_MSG(ret >= 0);
|
||||
|
||||
/* The transition is synchronous and shall take effect immediately. */
|
||||
ret = sys_notify_fetch_result(&cli.notify, &ignored);
|
||||
} else {
|
||||
ret = onoff_release(&cpunet_mgr);
|
||||
}
|
||||
|
||||
__ASSERT_NO_MSG(ret >= 0);
|
||||
}
|
31
soc/nordic/nrf53/nrf53_cpunet_mgmt.h
Normal file
31
soc/nordic/nrf53/nrf53_cpunet_mgmt.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (c) 2024 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file Nordic Semiconductor nRF53 processors family management helper for the network CPU.
|
||||
*/
|
||||
|
||||
#ifndef NRF53_CPUNET_MGMT_H__
|
||||
#define NRF53_CPUNET_MGMT_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
/**
|
||||
* @brief Enables or disables nRF53 network CPU.
|
||||
*
|
||||
* This function shall be used to control the network CPU exclusively. Internally, it keeps track of
|
||||
* the requests to enable or disable nRF53 network CPU. It guarantees to enable the network CPU if
|
||||
* at least one user requests it and to keep it enabled until all users release it.
|
||||
*
|
||||
* In conseqeuence, if @p on equals @c true then the network CPU is guaranteed to be enabled when
|
||||
* this function returns. If @p on equals @c false then nothing can be inferred about the state of
|
||||
* the network CPU when the function returns.
|
||||
*
|
||||
* @param on indicates whether the network CPU shall be powered on or off.
|
||||
*/
|
||||
void nrf53_cpunet_enable(bool on);
|
||||
|
||||
#endif /* NRF53_CPUNET_MGMT_H__ */
|
Loading…
Reference in a new issue