Skip to content

Hfclk separation #93976

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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 drivers/clock_control/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_NRF54H_HFXO clock_cont
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_NRF_HSFLL_LOCAL clock_control_nrf_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)

if(CONFIG_CLOCK_CONTROL_RENESAS_RZA2M_CPG)
Expand Down Expand Up @@ -125,3 +127,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)
9 changes: 9 additions & 0 deletions drivers/clock_control/Kconfig.nrf
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,15 @@ 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_AUXPLL
bool "nRF Auxiliary PLL driver"
default y
Expand Down
10 changes: 5 additions & 5 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 @@ -800,9 +801,8 @@ static int clk_init(const struct device *dev)
.start = onoff_start,
.stop = onoff_stop
};

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
36 changes: 36 additions & 0 deletions drivers/clock_control/clock_control_nrf_common.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#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 = false;

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);
}
17 changes: 17 additions & 0 deletions drivers/clock_control/clock_control_nrf_common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*$$$LICENCE_NORDIC_STANDARD<2016>$$$*/

#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, \
}

void clock_control_nrf_common_connect_irq( void );

#endif // CLOCK_CONTROL_NRF_COMMON_H__
Loading