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
26 changes: 26 additions & 0 deletions dts/common/nordic/nrf54l15.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,32 @@
status = "disabled";
};

power: power@10e000 {
compatible = "nordic,nrf-power";
reg = <0x10e000 0x1000>;
ranges = <0x0 0x10e000 0x1000>;
interrupts = <270 NRF_DEFAULT_IRQ_PRIORITY>;
status = "disabled";
#address-cells = <1>;
#size-cells = <1>;

gpregret1: gpregret1@51c {
#address-cells = <1>;
#size-cells = <1>;
compatible = "nordic,nrf-gpregret";
reg = <0x51c 0x1>;
status = "disabled";
};

gpregret2: gpregret2@520 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "nordic,nrf-gpregret";
reg = <0x520 0x1>;
status = "disabled";
};
};

regulators: regulator@120000 {
compatible = "nordic,nrf54l-regulators";
reg = <0x120000 0x1000>;
Expand Down
9 changes: 9 additions & 0 deletions samples/boards/nordic/nrf_sys_event/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright 2024 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(soc_sys_event)

FILE(GLOB app_sources src/*.c)
target_sources(app PRIVATE ${app_sources})
4 changes: 4 additions & 0 deletions samples/boards/nordic/nrf_sys_event/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2024 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

CONFIG_NRF_SYS_EVENT=y
28 changes: 28 additions & 0 deletions samples/boards/nordic/nrf_sys_event/sample.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
sample:
name: nRF System events
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
integration_platforms:
- nrf52840dk/nrf52840
- nrf5340dk/nrf5340/cpuapp
- nrf5340dk/nrf5340/cpunet
- nrf54h20dk/nrf54h20/cpuapp
- nrf54h20dk/nrf54h20/cpurad
- nrf54l15dk/nrf54l15/cpuapp
41 changes: 41 additions & 0 deletions samples/boards/nordic/nrf_sys_event/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2024 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <nrf_sys_event.h>
#include <stdio.h>

int main(void)
{
printf("request global constant latency mode\n");
if (nrf_sys_event_request_global_constlat()) {
printf("failed to request global constant latency mode\n");
return 0;
}
printf("constant latency mode enabled\n");

printf("request global constant latency mode again\n");
if (nrf_sys_event_request_global_constlat()) {
printf("failed to request global constant latency mode\n");
return 0;
}

printf("release global constant latency mode\n");
printf("constant latency mode will remain enabled\n");
if (nrf_sys_event_release_global_constlat()) {
printf("failed to release global constant latency mode\n");
return 0;
}

printf("release global constant latency mode again\n");
printf("constant latency mode will be disabled\n");
if (nrf_sys_event_release_global_constlat()) {
printf("failed to release global constant latency mode\n");
return 0;
}

printf("constant latency mode disabled\n");
return 0;
}
2 changes: 2 additions & 0 deletions soc/nordic/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ if(CONFIG_TFM_PARTITION_PLATFORM)
$<TARGET_PROPERTY:tfm,TFM_BINARY_DIR>/api_ns/interface/include
)
endif()

zephyr_library_sources_ifdef(CONFIG_NRF_SYS_EVENT nrf_sys_event.c)
4 changes: 4 additions & 0 deletions soc/nordic/common/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@
config HAS_NORDIC_DMM
bool

config NRF_SYS_EVENT
bool "nRF system event support"
select NRFX_POWER if !NRF_PLATFORM_HALTIUM

rsource "vpr/Kconfig"
95 changes: 95 additions & 0 deletions soc/nordic/common/nrf_sys_event.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
* Copyright (c) 2024 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <nrf_sys_event.h>

#if CONFIG_SOC_SERIES_NRF54HX

/*
* The 54HX is not yet supported by an nrfx driver nor the system controller so
* we implement an ISR and concurrent access safe reference counting implementation
* here using the nrfx hal.
*/

#include <hal/nrf_lrcconf.h>

static struct k_spinlock global_constlat_lock;
static uint16_t global_constlat_count;

int nrf_sys_event_request_global_constlat(void)
{
K_SPINLOCK(&global_constlat_lock) {
if (global_constlat_count == 0) {
#if CONFIG_SOC_NRF54H20_CPUAPP
nrf_lrcconf_task_trigger(NRF_LRCCONF010,
NRF_LRCCONF_TASK_CONSTLAT_ENABLE);
#elif CONFIG_SOC_NRF54H20_CPURAD
nrf_lrcconf_task_trigger(NRF_LRCCONF000,
NRF_LRCCONF_TASK_CONSTLAT_ENABLE);
nrf_lrcconf_task_trigger(NRF_LRCCONF020,
NRF_LRCCONF_TASK_CONSTLAT_ENABLE);
#else

Check notice on line 34 in soc/nordic/common/nrf_sys_event.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

soc/nordic/common/nrf_sys_event.c:34 - nrf_lrcconf_task_trigger(NRF_LRCCONF010, - NRF_LRCCONF_TASK_CONSTLAT_ENABLE); + nrf_lrcconf_task_trigger(NRF_LRCCONF010, NRF_LRCCONF_TASK_CONSTLAT_ENABLE); #elif CONFIG_SOC_NRF54H20_CPURAD - nrf_lrcconf_task_trigger(NRF_LRCCONF000, - NRF_LRCCONF_TASK_CONSTLAT_ENABLE); - nrf_lrcconf_task_trigger(NRF_LRCCONF020, - NRF_LRCCONF_TASK_CONSTLAT_ENABLE); + nrf_lrcconf_task_trigger(NRF_LRCCONF000, NRF_LRCCONF_TASK_CONSTLAT_ENABLE); + nrf_lrcconf_task_trigger(NRF_LRCCONF020, NRF_LRCCONF_TASK_CONSTLAT_ENABLE);
#error "unsupported"
#endif
}

global_constlat_count++;
}

return 0;
}

int nrf_sys_event_release_global_constlat(void)
{
K_SPINLOCK(&global_constlat_lock) {
if (global_constlat_count == 1) {
#if CONFIG_SOC_NRF54H20_CPUAPP
nrf_lrcconf_task_trigger(NRF_LRCCONF010,
NRF_LRCCONF_TASK_CONSTLAT_DISABLE);
#elif CONFIG_SOC_NRF54H20_CPURAD
nrf_lrcconf_task_trigger(NRF_LRCCONF000,
NRF_LRCCONF_TASK_CONSTLAT_DISABLE);
nrf_lrcconf_task_trigger(NRF_LRCCONF020,
NRF_LRCCONF_TASK_CONSTLAT_DISABLE);
#else

Check notice on line 57 in soc/nordic/common/nrf_sys_event.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

soc/nordic/common/nrf_sys_event.c:57 - nrf_lrcconf_task_trigger(NRF_LRCCONF010, - NRF_LRCCONF_TASK_CONSTLAT_DISABLE); + nrf_lrcconf_task_trigger(NRF_LRCCONF010, NRF_LRCCONF_TASK_CONSTLAT_DISABLE); #elif CONFIG_SOC_NRF54H20_CPURAD - nrf_lrcconf_task_trigger(NRF_LRCCONF000, - NRF_LRCCONF_TASK_CONSTLAT_DISABLE); - nrf_lrcconf_task_trigger(NRF_LRCCONF020, - NRF_LRCCONF_TASK_CONSTLAT_DISABLE); + nrf_lrcconf_task_trigger(NRF_LRCCONF000, NRF_LRCCONF_TASK_CONSTLAT_DISABLE); + nrf_lrcconf_task_trigger(NRF_LRCCONF020, NRF_LRCCONF_TASK_CONSTLAT_DISABLE);
#error "unsupported"
#endif
}

global_constlat_count--;
}

return 0;
}

#else

/*
* The nrfx power driver already contains an ISR and concurrent access safe reference
* counting API so we just use it directly when available.
*/

#include <nrfx_power.h>

int nrf_sys_event_request_global_constlat(void)
{
nrfx_err_t err;

err = nrfx_power_constlat_mode_request();

return (err == NRFX_SUCCESS || err == NRFX_ERROR_ALREADY) ? 0 : -EAGAIN;
}

int nrf_sys_event_release_global_constlat(void)
{
nrfx_err_t err;

err = nrfx_power_constlat_mode_free();

return (err == NRFX_SUCCESS || err == NRFX_ERROR_BUSY) ? 0 : -EAGAIN;
}

#endif
30 changes: 30 additions & 0 deletions soc/nordic/common/nrf_sys_event.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2024 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/kernel.h>

/**
* @brief Request lowest latency for system events
*
* @details System will be configured for lowest latency after first
* call to nrf_sys_event_request_global_constlat() and will remain
* configured for lowest latency until matching number of calls to
* nrf_sys_event_release_global_constlat() occur.
*
* @retval 0 if successful
* @retval -errno code otherwise
*/
int nrf_sys_event_request_global_constlat(void);

/**
* @brief Release low latency request
*
* @see nrf_sys_event_request_global_constlat()
*
* @retval 0 if successful
* @retval -errno code otherwise
*/
int nrf_sys_event_release_global_constlat(void);
Loading