Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 31 additions & 27 deletions samples/boards/nordic/nrf_sys_event/sample.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
sample:
name: nRF System events
common:
harness: console
harness_config:
type: one_line
regex:
- "constant latency mode disabled"
platform_allow:
- nrf52dk/nrf52810
- nrf52dk/nrf52832
- nrf52833dk/nrf52820
- nrf52833dk/nrf52833
- nrf52840dk/nrf52811
- nrf52840dk/nrf52840
- nrf5340dk/nrf5340/cpuapp
- nrf5340dk/nrf5340/cpunet
- nrf54h20dk/nrf54h20/cpuapp
- nrf54h20dk/nrf54h20/cpurad
- nrf54l15dk/nrf54l15/cpuapp
- ophelia4ev/nrf54l15/cpuapp
integration_platforms:
- nrf52840dk/nrf52840
- nrf5340dk/nrf5340/cpuapp
- nrf5340dk/nrf5340/cpunet
- nrf54h20dk/nrf54h20/cpuapp
- nrf54h20dk/nrf54h20/cpurad
- nrf54l15dk/nrf54l15/cpuapp
- ophelia4ev/nrf54l15/cpuapp
tests:
sample.boards.nordic.nrf_sys_event:
harness: console
harness_config:
type: one_line
regex:
- "constant latency mode disabled"
platform_allow:
- nrf52dk/nrf52810
- nrf52dk/nrf52832
- nrf52833dk/nrf52820
- nrf52833dk/nrf52833
- nrf52840dk/nrf52811
- nrf52840dk/nrf52840
- nrf5340dk/nrf5340/cpuapp
- nrf5340dk/nrf5340/cpunet
- nrf54h20dk/nrf54h20/cpuapp
- nrf54h20dk/nrf54h20/cpurad
- nrf54l15dk/nrf54l15/cpuapp
- ophelia4ev/nrf54l15/cpuapp
integration_platforms:
- nrf52840dk/nrf52840
- nrf5340dk/nrf5340/cpuapp
- nrf5340dk/nrf5340/cpunet
- nrf54h20dk/nrf54h20/cpuapp
- nrf54h20dk/nrf54h20/cpurad
- nrf54l15dk/nrf54l15/cpuapp
- ophelia4ev/nrf54l15/cpuapp
sample.boards.nordic.nrf_sys_event: {}
sample.boards.nordic.nrf_sys_event.force_constlat:
extra_configs:
- CONFIG_SOC_NRF_FORCE_CONSTLAT=y
1 change: 1 addition & 0 deletions soc/nordic/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ if(CONFIG_TFM_PARTITION_PLATFORM)
endif()

zephyr_library_sources_ifdef(CONFIG_NRF_SYS_EVENT nrf_sys_event.c)
zephyr_library_sources_ifdef(CONFIG_SOC_NRF_FORCE_CONSTLAT nrf_constlat.c)
zephyr_library_sources_ifdef(CONFIG_MRAM_LATENCY mram_latency.c)
9 changes: 9 additions & 0 deletions soc/nordic/common/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ config NRF_SYS_EVENT
bool "nRF system event support"
select NRFX_POWER if !NRF_PLATFORM_HALTIUM

config SOC_NRF_FORCE_CONSTLAT
bool "Force constant latency mode in system ON"
depends on NRF_SYS_EVENT && !RISCV
help
In constant latency mode the CPU wakeup latency and the PPI task response
will be constant and kept at a minimum. This is secured by forcing a set
of base resources on while in sleep. The advantage of having a constant
and predictable latency will be at the cost of having increased power consumption.

config MRAM_LATENCY
bool "MRAM latency manager"
depends on NRFS_HAS_MRAM_SERVICE
Expand Down
17 changes: 17 additions & 0 deletions soc/nordic/common/nrf_constlat.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright (c) 2025 Embeint Pty Ltd
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/init.h>

#include <nrf_sys_event.h>

static int nrf_const_lat(void)
{
return nrf_sys_event_request_global_constlat();
}

/* Immediately after the SoC init functions */
SYS_INIT(nrf_const_lat, PRE_KERNEL_1, 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't this code actually be in one of the hooks, to avoid yet another SYS_INIT ? Or perhaps in soc.c?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a look around for an appropriate place and couldn't find one. For soc.c it would need to duplicated for each Nordic SoC. If that is preferred I can do that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to use on-off service and port Bluetooth Controllers to use them. Otherwise, low power mode would get set after radio events.

8 changes: 0 additions & 8 deletions soc/nordic/nrf54l/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,6 @@ config SOC_NRF54LX_SKIP_GLITCHDETECTOR_DISABLE
With this option, the glitch detector is not disabled during system initialization.
The CPU runs with the default state of glitch detector.

config SOC_NRF_FORCE_CONSTLAT
bool "Force constant-latency mode"
help
In constant latency mode the CPU wakeup latency and the PPI task response
will be constant and kept at a minimum. This is secured by forcing a set
of base resources on while in sleep. The advantage of having a constant
and predictable latency will be at the cost of having increased power consumption.

config SOC_NRF54L_ANOMALY_56_WORKAROUND
bool "Apply workaround 56 for nRF54L SoCs"
default y
Expand Down
4 changes: 0 additions & 4 deletions soc/nordic/nrf54l/soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,6 @@ static inline void power_and_clock_configuration(void)
nrf_oscillators_hfxo_cap_set(NRF_OSCILLATORS, false, 0);
#endif

if (IS_ENABLED(CONFIG_SOC_NRF_FORCE_CONSTLAT)) {
nrf_power_task_trigger(NRF_POWER, NRF_POWER_TASK_CONSTLAT);
}

#if (DT_PROP(DT_NODELABEL(vregmain), regulator_initial_mode) == NRF5X_REG_MODE_DCDC)
nrf_regulators_vreg_enable_set(NRF_REGULATORS, NRF_REGULATORS_VREG_MAIN, true);
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <zephyr/sys/byteorder.h>
#include <soc.h>

#include <nrf_sys_event.h>
#include <nrfx_gpiote.h>

#include "util/mem.h"
Expand Down Expand Up @@ -221,7 +222,11 @@ void radio_reset(void)
RADIO_TIMING_RU_Msk;
#endif /* !CONFIG_BT_CTLR_TIFS_HW */

#if defined(CONFIG_NRF_SYS_EVENT)
(void)nrf_sys_event_request_global_constlat();
#else /* !CONFIG_NRF_SYS_EVENT */
Comment on lines +225 to +227
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no expertise here, but the changes look reasonable.

NRF_POWER->TASKS_CONSTLAT = 1U;
#endif /* !CONFIG_NRF_SYS_EVENT */
#endif /* CONFIG_SOC_COMPATIBLE_NRF54LX */

#if defined(HAL_RADIO_GPIO_HAVE_PA_PIN) || defined(HAL_RADIO_GPIO_HAVE_LNA_PIN)
Expand Down Expand Up @@ -1788,7 +1793,11 @@ void radio_tmr_stop(void)
#endif /* !CONFIG_BT_CTLR_TIFS_HW */

#if defined(CONFIG_SOC_COMPATIBLE_NRF54LX)
#if defined(CONFIG_NRF_SYS_EVENT)
(void)nrf_sys_event_release_global_constlat();
#else /* !CONFIG_NRF_SYS_EVENT */
NRF_POWER->TASKS_LOWPWR = 1U;
#endif /* !CONFIG_NRF_SYS_EVENT */
#endif /* CONFIG_SOC_COMPATIBLE_NRF54LX */
}

Expand Down