Skip to content
Open
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
70 changes: 20 additions & 50 deletions drivers/timer/nrf_grtc_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,7 @@ static inline uint64_t counter(void)

static inline int get_comparator(uint32_t chan, uint64_t *cc)
{
nrfx_err_t result;

result = nrfx_grtc_syscounter_cc_value_read(chan, cc);
if (result != NRFX_SUCCESS) {
if (result != NRFX_ERROR_INVALID_PARAM) {
return -EAGAIN;
}
return -EPERM;
}
return 0;
return nrfx_grtc_syscounter_cc_value_read(chan, cc);
}

/*
Expand Down Expand Up @@ -173,14 +164,14 @@ static void sys_clock_timeout_handler(int32_t id, uint64_t cc_val, void *p_conte
int32_t z_nrf_grtc_timer_chan_alloc(void)
{
uint8_t chan;
nrfx_err_t err_code;
int err_code;

/* Prevent allocating all available channels - one must be left for system purposes. */
if (ext_channels_allocated >= EXT_CHAN_COUNT) {
return -ENOMEM;
}
err_code = nrfx_grtc_channel_alloc(&chan);
if (err_code != NRFX_SUCCESS) {
if (err_code < 0) {
return -ENOMEM;
}
ext_channels_allocated++;
Expand All @@ -190,9 +181,9 @@ int32_t z_nrf_grtc_timer_chan_alloc(void)
void z_nrf_grtc_timer_chan_free(int32_t chan)
{
IS_CHANNEL_ALLOWED_ASSERT(chan);
nrfx_err_t err_code = nrfx_grtc_channel_free(chan);
int err_code = nrfx_grtc_channel_free(chan);

if (err_code == NRFX_SUCCESS) {
if (err_code == 0) {
ext_channels_allocated--;
}
}
Expand Down Expand Up @@ -249,19 +240,13 @@ int z_nrf_grtc_timer_compare_read(int32_t chan, uint64_t *val)
static int compare_set_nolocks(int32_t chan, uint64_t target_time,
z_nrf_grtc_timer_compare_handler_t handler, void *user_data)
{
nrfx_err_t result;

__ASSERT_NO_MSG(target_time < COUNTER_SPAN);
nrfx_grtc_channel_t user_channel_data = {
.handler = handler,
.p_context = user_data,
.channel = chan,
};
result = nrfx_grtc_syscounter_cc_absolute_set(&user_channel_data, target_time, true);
if (result != NRFX_SUCCESS) {
return -EPERM;
}
return 0;
return nrfx_grtc_syscounter_cc_absolute_set(&user_channel_data, target_time, true);
}

static int compare_set(int32_t chan, uint64_t target_time,
Expand Down Expand Up @@ -314,31 +299,22 @@ int z_nrf_grtc_timer_capture_prepare(int32_t chan)
.p_context = NULL,
.channel = chan,
};
nrfx_err_t result;

IS_CHANNEL_ALLOWED_ASSERT(chan);

/* Set the CC value to mark channel as not triggered and also to enable it
* (makes CCEN=1). COUNTER_SPAN is used so as not to fire an event unnecessarily
* - it can be assumed that such a large value will never be reached.
*/
result = nrfx_grtc_syscounter_cc_absolute_set(&user_channel_data, COUNTER_SPAN, false);

if (result != NRFX_SUCCESS) {
return -EPERM;
}

return 0;
return nrfx_grtc_syscounter_cc_absolute_set(&user_channel_data, COUNTER_SPAN, false);
}

int z_nrf_grtc_timer_capture_read(int32_t chan, uint64_t *captured_time)
{
/* TODO: The implementation should probably go to nrfx_grtc and this
* should be just a wrapper for some nrfx_grtc_syscounter_capture_read.
*/

uint64_t capt_time;
nrfx_err_t result;
int result;

IS_CHANNEL_ALLOWED_ASSERT(chan);

Expand All @@ -349,14 +325,8 @@ int z_nrf_grtc_timer_capture_read(int32_t chan, uint64_t *captured_time)
*/
return -EBUSY;
}
result = nrfx_grtc_syscounter_cc_value_read(chan, &capt_time);
if (result != NRFX_SUCCESS) {
return -EPERM;
}

__ASSERT_NO_MSG(capt_time < COUNTER_SPAN);

*captured_time = capt_time;
result = nrfx_grtc_syscounter_cc_value_read(chan, captured_time);
__ASSERT_NO_MSG(*captured_time < COUNTER_SPAN);

return 0;
}
Expand All @@ -369,7 +339,7 @@ uint64_t z_nrf_grtc_timer_startup_value_get(void)
#if defined(CONFIG_POWEROFF) && defined(CONFIG_NRF_GRTC_START_SYSCOUNTER)
int z_nrf_grtc_wakeup_prepare(uint64_t wake_time_us)
{
nrfx_err_t err_code;
int err_code;
static uint8_t systemoff_channel;
uint64_t now = counter();
nrfx_grtc_sleep_config_t sleep_cfg;
Expand All @@ -392,9 +362,9 @@ int z_nrf_grtc_wakeup_prepare(uint64_t wake_time_us)
k_spinlock_key_t key = k_spin_lock(&lock);

err_code = nrfx_grtc_channel_alloc(&systemoff_channel);
if (err_code != NRFX_SUCCESS) {
if (err_code < 0) {
k_spin_unlock(&lock, key);
return -ENOMEM;
return err_code;
}
(void)nrfx_grtc_syscounter_cc_int_disable(systemoff_channel);
ret = compare_set(systemoff_channel,
Expand Down Expand Up @@ -459,7 +429,7 @@ uint32_t sys_clock_elapsed(void)

static int sys_clock_driver_init(void)
{
nrfx_err_t err_code;
int err_code;

IRQ_CONNECT(DT_IRQN(GRTC_NODE), DT_IRQ(GRTC_NODE, priority), nrfx_isr,
nrfx_grtc_irq_handler, 0);
Expand All @@ -477,19 +447,19 @@ static int sys_clock_driver_init(void)
#endif

err_code = nrfx_grtc_init(0);
if (err_code != NRFX_SUCCESS) {
return -EPERM;
if (err_code < 0) {
return err_code;
}

#if defined(CONFIG_NRF_GRTC_START_SYSCOUNTER)
err_code = nrfx_grtc_syscounter_start(true, &system_clock_channel_data.channel);
if (err_code != NRFX_SUCCESS) {
return err_code == NRFX_ERROR_NO_MEM ? -ENOMEM : -EPERM;
if (err_code < 0) {
return err_code;
}
#else
err_code = nrfx_grtc_channel_alloc(&system_clock_channel_data.channel);
if (err_code != NRFX_SUCCESS) {
return -ENOMEM;
if (err_code < 0) {
return err_code;
}
#endif /* CONFIG_NRF_GRTC_START_SYSCOUNTER */

Expand Down
22 changes: 5 additions & 17 deletions modules/hal_nordic/nrfx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,10 @@ zephyr_library_sources(nrfx_glue.c)
zephyr_library_sources(${HELPERS_DIR}/nrfx_flag32_allocator.c)
zephyr_library_sources_ifdef(CONFIG_HAS_NORDIC_RAM_CTRL ${HELPERS_DIR}/nrfx_ram_ctrl.c)

if(CONFIG_NRFX_GPPI)
zephyr_library_sources_ifdef(CONFIG_NRFX_GPPI_V1 ${HELPERS_DIR}/internal/nrfx_gppiv1_shim.c)
if(CONFIG_HAS_HW_NRF_PPI)
zephyr_library_sources_ifdef(CONFIG_NRFX_GPPI_V1 ${HELPERS_DIR}/internal/nrfx_gppiv1_ppi.c)
zephyr_library_sources_ifdef(CONFIG_NRFX_GPPI_V1 ${HELPERS_DIR}/internal/nrfx_ppi.c)
zephyr_library_sources_ifndef(CONFIG_NRFX_GPPI_V1 ${HELPERS_DIR}/nrfx_gppi_ppi.c)
else()
zephyr_library_sources_ifdef(CONFIG_NRFX_GPPI_V1 ${HELPERS_DIR}/internal/nrfx_gppiv1_dppi.c)
zephyr_library_sources_ifndef(CONFIG_NRFX_GPPI_V1 ${HELPERS_DIR}/nrfx_gppi_dppi.c)
zephyr_library_sources_ifdef(CONFIG_NRFX_GPPI_V1 ${HELPERS_DIR}/internal/nrfx_dppi.c)
endif()
if(CONFIG_NRFX_GPPI AND NOT CONFIG_NRFX_GPPI_V1)
zephyr_library_sources_ifdef(CONFIG_HAS_HW_NRF_PPI ${HELPERS_DIR}/nrfx_gppi_ppi.c)
zephyr_library_sources_ifdef(CONFIG_HAS_HW_NRF_DPPIC ${HELPERS_DIR}/nrfx_gppi_dppi.c)
zephyr_library_sources_ifdef(CONFIG_SOC_COMPATIBLE_NRF54LX ${HELPERS_DIR}/nrfx_gppi_lumos.c)
endif()

zephyr_library_sources_ifdef(CONFIG_NRFX_PRS ${SRC_DIR}/prs/nrfx_prs.c)
Expand Down Expand Up @@ -219,14 +212,9 @@ zephyr_compile_definitions_ifdef(CONFIG_SOC_NRF54LX_DISABLE_FICR_TRIMCNF NRF_DIS
zephyr_compile_definitions_ifdef(CONFIG_SOC_NRF54LX_SKIP_GLITCHDETECTOR_DISABLE NRF_SKIP_GLITCHDETECTOR_DISABLE)
zephyr_compile_definitions_ifndef(CONFIG_SOC_NRF54L_ANOMALY_56_WORKAROUND NRF54L_CONFIGURATION_56_ENABLE=0)

if(CONFIG_SOC_COMPATIBLE_NRF54LX AND CONFIG_NRFX_GPPI)
zephyr_library_sources_ifdef(CONFIG_NRFX_GPPI_V1 ${HELPERS_DIR}/internal/nrfx_gppiv1_ppib.c)
zephyr_library_sources_ifdef(CONFIG_NRFX_GPPI_V1 ${HELPERS_DIR}/internal/nrfx_ppib.c)
zephyr_library_sources_ifndef(CONFIG_NRFX_GPPI_V1 ${HELPERS_DIR}/nrfx_gppi_lumos.c)
endif()

if(CONFIG_SOC_SERIES_NRF54HX AND CONFIG_NRFX_GPPI_V1)
zephyr_library_sources(${HELPERS_DIR}/internal/nrfx_gppiv1_ipct.c)
zephyr_library_sources(${HELPERS_DIR}/internal/nrfx_gppiv1_shim.c)
endif()


Expand Down
143 changes: 0 additions & 143 deletions modules/hal_nordic/nrfx/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -56,93 +56,6 @@ config NRFX_CRACEN
bool "CRACEN drivers"
depends on SOC_COMPATIBLE_NRF54LX

config NRFX_DPPI
bool

config NRFX_DPPI0
bool "DPPI0 driver instance"
default y if NRFX_GPPI_V1
depends on $(dt_nodelabel_exists,dppic0)
select NRFX_DPPI

config NRFX_DPPI00
bool "DPPI00 driver instance"
default y if NRFX_GPPI_V1
depends on $(dt_nodelabel_exists,dppic00)
select NRFX_DPPI

config NRFX_DPPI10
bool "DPPI10 driver instance"
default y if NRFX_GPPI_V1
depends on $(dt_nodelabel_exists,dppic10)
select NRFX_DPPI

config NRFX_DPPI20
bool "DPPI20 driver instance"
default y if NRFX_GPPI_V1
depends on $(dt_nodelabel_exists,dppic20)
select NRFX_DPPI

config NRFX_DPPI30
bool "DPPI30 driver instance"
default y if NRFX_GPPI_V1
depends on $(dt_nodelabel_exists,dppic30)
select NRFX_DPPI

config NRFX_DPPI020
bool "DPPI020 driver instance"
default y if NRFX_GPPI_V1
depends on $(dt_nodelabel_exists,dppic020)
select NRFX_DPPI

config NRFX_DPPI120
bool "DPPI120 driver instance"
default y if NRFX_GPPI_V1
depends on $(dt_nodelabel_exists,dppic120)
select NRFX_DPPI

config NRFX_DPPI130
bool "DPPI130 driver instance"
default y if NRFX_GPPI_V1
depends on $(dt_nodelabel_exists,dppic130)
select NRFX_DPPI

config NRFX_DPPI131
bool "DPPI131 driver instance"
default y if NRFX_GPPI_V1
depends on $(dt_nodelabel_exists,dppic131)
select NRFX_DPPI

config NRFX_DPPI132
bool "DPPI132 driver instance"
default y if NRFX_GPPI_V1
depends on $(dt_nodelabel_exists,dppic132)
select NRFX_DPPI

config NRFX_DPPI133
bool "DPPI133 driver instance"
default y if NRFX_GPPI_V1
depends on $(dt_nodelabel_exists,dppic133)
select NRFX_DPPI

config NRFX_DPPI134
bool "DPPI134 driver instance"
default y if NRFX_GPPI_V1
depends on $(dt_nodelabel_exists,dppic134)
select NRFX_DPPI

config NRFX_DPPI135
bool "DPPI135 driver instance"
default y if NRFX_GPPI_V1
depends on $(dt_nodelabel_exists,dppic135)
select NRFX_DPPI

config NRFX_DPPI136
bool "DPPI136 driver instance"
default y if NRFX_GPPI_V1
depends on $(dt_nodelabel_exists,dppic136)
select NRFX_DPPI

config NRFX_EGU
bool

Expand Down Expand Up @@ -292,62 +205,6 @@ config NRFX_POWER
# internally the USBREG driver.
select NRFX_USBREG if $(dt_nodelabel_exists,usbreg)

config NRFX_PPI
bool "PPI allocator"
default y if NRFX_GPPI_V1
depends on $(dt_nodelabel_exists,ppi)

config NRFX_PPIB
bool

config NRFX_PPIB00
bool "PPIB00 driver instance"
default y if NRFX_GPPI_V1
depends on $(dt_nodelabel_exists,ppib00)
select NRFX_PPIB

config NRFX_PPIB01
bool "PPIB01 driver instance"
default y if NRFX_GPPI_V1
depends on $(dt_nodelabel_exists,ppib01)
select NRFX_PPIB

config NRFX_PPIB10
bool "PPIB10 driver instance"
default y if NRFX_GPPI_V1
depends on $(dt_nodelabel_exists,ppib10)
select NRFX_PPIB

config NRFX_PPIB11
bool "PPIB11 driver instance"
default y if NRFX_GPPI_V1
depends on $(dt_nodelabel_exists,ppib11)
select NRFX_PPIB

config NRFX_PPIB20
bool "PPIB20 driver instance"
default y if NRFX_GPPI_V1
depends on $(dt_nodelabel_exists,ppib20)
select NRFX_PPIB

config NRFX_PPIB21
bool "PPIB21 driver instance"
default y if NRFX_GPPI_V1
depends on $(dt_nodelabel_exists,ppib21)
select NRFX_PPIB

config NRFX_PPIB22
bool "PPIB22 driver instance"
default y if NRFX_GPPI_V1
depends on $(dt_nodelabel_exists,ppib22)
select NRFX_PPIB

config NRFX_PPIB30
bool "PPIB30 driver instance"
default y if NRFX_GPPI_V1
depends on $(dt_nodelabel_exists,ppib30)
select NRFX_PPIB

config NRFX_PWM
bool "PWM driver"

Expand Down
12 changes: 0 additions & 12 deletions modules/hal_nordic/nrfx/Kconfig.logging
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ config NRFX_COMP_LOG
bool "COMP driver logging"
depends on NRFX_COMP

config NRFX_DPPI_LOG
bool "DPPI driver logging"
depends on NRFX_DPPI

config NRFX_EGU_LOG
bool "EGU driver logging"
depends on NRFX_EGU
Expand Down Expand Up @@ -64,14 +60,6 @@ config NRFX_POWER_LOG
bool "POWER driver logging"
depends on NRFX_POWER

config NRFX_PPI_LOG
bool "PPI driver logging"
depends on NRFX_PPI

config NRFX_PPIB_LOG
bool "PPIB driver logging"
depends on NRFX_PPIB

config NRFX_PRS_LOG
bool "PRS driver logging"
depends on NRFX_PRS
Expand Down
Loading
Loading