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
4 changes: 4 additions & 0 deletions boards/ezurio/bl54l15_dvk/nrf54l_10_15_cpuapp_common.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@
status = "okay";
};

&xo {
status = "okay";
};

&spi00 {
status = "okay";
cs-gpios = <&gpio2 5 GPIO_ACTIVE_LOW>;
Expand Down
4 changes: 4 additions & 0 deletions boards/ezurio/bl54l15u_dvk/nrf54l15_cpuapp_common.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@
status = "okay";
};

&xo {
status = "okay";
};

&spi00 {
status = "okay";
cs-gpios = <&gpio2 5 GPIO_ACTIVE_LOW>;
Expand Down
4 changes: 4 additions & 0 deletions boards/native/nrf_bsim/nrf54l15bsim_nrf54l15_cpuapp.dts
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,7 @@
&clock {
status = "okay";
};

&xo {
status = "okay";
};
4 changes: 4 additions & 0 deletions boards/native/nrf_bsim/nrf54lm20bsim_nrf54lm20a_cpuapp.dts
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,7 @@
&clock {
status = "okay";
};

&xo {
status = "okay";
};
4 changes: 4 additions & 0 deletions boards/nordic/nrf54l15dk/nrf54l_05_10_15_cpuapp_common.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@
status = "okay";
};

&xo {
status = "okay";
};

&gpregret1 {
status = "okay";

Expand Down
4 changes: 4 additions & 0 deletions boards/nordic/nrf54lm20dk/nrf54lm20a_cpuapp_common.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@
status = "okay";
};

&xo {
status = "okay";
};

&ieee802154 {
status = "okay";
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@
status = "okay";
};

&xo {
status = "okay";
};

&spi00 {
status = "okay";
cs-gpios = <&gpio2 5 GPIO_ACTIVE_LOW>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@
status = "okay";
};

&xo {
status = "okay";
};

&spi00 {
status = "okay";
cs-gpios = <&gpio2 5 GPIO_ACTIVE_LOW>;
Expand Down
4 changes: 4 additions & 0 deletions boards/we/ophelia4ev/ophelia4ev_nrf54l15_cpuapp.dts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@
status = "okay";
};

&xo {
status = "okay";
};

&spi00 {
status = "okay";

Expand Down
4 changes: 4 additions & 0 deletions drivers/clock_control/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_NRF_HSFLL_LOCAL clock_cont
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_NRF_IRON_HSFLL_LOCAL clock_control_nrf_iron_hsfll_local.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_NRF_LFCLK clock_control_nrf_lfclk.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_NRF_AUXPLL clock_control_nrf_auxpll.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_NRF_HFCLK clock_control_nrf_hfclk.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_NRF_COMMON clock_control_nrf_common.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_BOUFFALOLAB_BL60X clock_control_bl60x.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_BOUFFALOLAB_BL61X clock_control_bl61x.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_BOUFFALOLAB_BL70X clock_control_bl70x.c)
Expand Down Expand Up @@ -129,3 +131,5 @@ endif()
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_AST10X0 clock_control_ast10x0.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_MAX32 clock_control_max32.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_WCH_RCC clock_control_wch_rcc.c)

zephyr_linker_sources(SECTIONS clock_control_nrf_irq_handlers.ld)
15 changes: 15 additions & 0 deletions drivers/clock_control/Kconfig.nrf
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,21 @@ config CLOCK_CONTROL_NRF_LFCLK_CLOCK_TIMEOUT_MS

endif # CLOCK_CONTROL_NRF_LFCLK

config CLOCK_CONTROL_NRF_COMMON
bool

config CLOCK_CONTROL_NRF_HFCLK
bool "NRF HFCLK driver support"
depends on DT_HAS_NORDIC_NRF_CLOCK_HFCLK_ENABLED
select CLOCK_CONTROL_NRF_COMMON
default y

config CLOCK_CONTROL_NRF_XO
bool "NRF XO driver support"
depends on DT_HAS_NORDIC_NRF_CLOCK_XO_ENABLED
select CLOCK_CONTROL_NRF_COMMON
default y

config CLOCK_CONTROL_NRF_AUXPLL
bool "nRF Auxiliary PLL driver"
default y
Expand Down
49 changes: 4 additions & 45 deletions drivers/clock_control/clock_control_nrf.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <zephyr/drivers/clock_control.h>
#include <zephyr/drivers/clock_control/nrf_clock_control.h>
#include "nrf_clock_calibration.h"
#include "clock_control_nrf_common.h"
#include <nrfx_clock.h>
#include <zephyr/logging/log.h>
#include <zephyr/shell/shell.h>
Expand Down Expand Up @@ -317,7 +318,7 @@ static void hfclk_start(void)
hf_start_tstamp = k_uptime_get();
}

nrfx_clock_hfclk_start();
nrfx_clock_start(NRF_CLOCK_DOMAIN_HFCLK);
}

static void hfclk_stop(void)
Expand All @@ -326,7 +327,7 @@ static void hfclk_stop(void)
hf_stop_tstamp = k_uptime_get();
}

nrfx_clock_hfclk_stop();
nrfx_clock_stop(NRF_CLOCK_DOMAIN_HFCLK);
}

#if NRF_CLOCK_HAS_HFCLK24M
Expand Down Expand Up @@ -421,47 +422,6 @@ static void generic_hfclk_stop(void)
irq_unlock(key);
}


void z_nrf_clock_bt_ctlr_hf_request(void)
{
if (atomic_or(&hfclk_users, HF_USER_BT) & HF_USER_GENERIC) {
/* generic request already activated clock. */
return;
}

hfclk_start();
}

void z_nrf_clock_bt_ctlr_hf_release(void)
{
/* It's not enough to use only atomic_and() here for synchronization,
* see the explanation in generic_hfclk_stop().
*/
unsigned int key = irq_lock();

hfclk_users &= ~HF_USER_BT;
/* Skip stopping if generic is still requesting the clock. */
if (!(hfclk_users & HF_USER_GENERIC)) {
struct nrf_clock_control_sub_data *sub_data =
get_sub_data(CLOCK_DEVICE, CLOCK_CONTROL_NRF_TYPE_HFCLK);

/* State needs to be set to OFF as BT API does not call stop API which
* normally setting this state.
*/
sub_data->flags = CLOCK_CONTROL_STATUS_OFF;
hfclk_stop();
}

irq_unlock(key);
}

#if DT_NODE_EXISTS(DT_NODELABEL(hfxo))
uint32_t z_nrf_clock_bt_ctlr_hf_get_startup_time_us(void)
{
return DT_PROP(DT_NODELABEL(hfxo), startup_time_us);
}
#endif

static int stop(const struct device *dev, clock_control_subsys_t subsys,
uint32_t ctx)
{
Expand Down Expand Up @@ -812,8 +772,7 @@ static int clk_init(const struct device *dev)
IRQ_CONNECT(LFRC_IRQn, DT_INST_IRQ(0, priority), nrfx_isr, nrfx_power_clock_irq_handler, 0);
#endif

IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority),
nrfx_isr, nrfx_power_clock_irq_handler, 0);
clock_control_nrf_common_connect_irq();

nrfx_err = nrfx_clock_init(clock_event_handler);
if (nrfx_err != NRFX_SUCCESS) {
Expand Down
41 changes: 41 additions & 0 deletions drivers/clock_control/clock_control_nrf_common.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2025 Nordic Semiconductor ASA
* SPDX-License-Identifier: Apache-2.0
*/

#include "clock_control_nrf_common.h"
#include <nrfx.h>
#include <nrfx_clock.h>

#if NRFX_CHECK(NRFX_POWER_ENABLED)
#include <nrfx_power.h>
#endif

#define DT_DRV_COMPAT nordic_nrf_clock

static bool irq_connected;

static void clock_irq_handler(void)
{
#if NRFX_CHECK(NRFX_POWER_ENABLED)
nrfx_power_irq_handler();
#endif

STRUCT_SECTION_FOREACH(clock_control_nrf_irq_handler, irq) {
irq->handler();
}

/* temporary fix, it will be removed when all the clocks are moved to their files */
nrfx_clock_irq_handler();
}

void clock_control_nrf_common_connect_irq(void)
{
if (irq_connected) {
return;
}
irq_connected = true;

IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority),
nrfx_isr, clock_irq_handler, 0);
}

Check notice on line 41 in drivers/clock_control/clock_control_nrf_common.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

drivers/clock_control/clock_control_nrf_common.c:41 - IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority), - nrfx_isr, clock_irq_handler, 0); + IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority), nrfx_isr, clock_irq_handler, 0);
20 changes: 20 additions & 0 deletions drivers/clock_control/clock_control_nrf_common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright (c) 2025 Nordic Semiconductor ASA
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef CLOCK_CONTROL_NRF_COMMON_H__
#define CLOCK_CONTROL_NRF_COMMON_H__

struct clock_control_nrf_irq_handler {
void (*handler)(void); /* Clock interrupt handler */
};

#define CLOCK_CONTROL_NRF_IRQ_HANDLERS_ITERABLE(name, _a) \
STRUCT_SECTION_ITERABLE(clock_control_nrf_irq_handler, name) = { \
.handler = _a, \
}

Check notice on line 16 in drivers/clock_control/clock_control_nrf_common.h

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

drivers/clock_control/clock_control_nrf_common.h:16 - void (*handler)(void); /* Clock interrupt handler */ + void (*handler)(void); /* Clock interrupt handler */ }; -#define CLOCK_CONTROL_NRF_IRQ_HANDLERS_ITERABLE(name, _a) \ - STRUCT_SECTION_ITERABLE(clock_control_nrf_irq_handler, name) = { \ - .handler = _a, \ +#define CLOCK_CONTROL_NRF_IRQ_HANDLERS_ITERABLE(name, _a) \ + STRUCT_SECTION_ITERABLE(clock_control_nrf_irq_handler, name) = { \ + .handler = _a, \

void clock_control_nrf_common_connect_irq(void);

#endif /* CLOCK_CONTROL_NRF_COMMON_H__ */
Loading
Loading