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
2 changes: 1 addition & 1 deletion applications/nrf5340_audio/src/audio/audio_datapath.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <zephyr/zbus/zbus.h>
#include <zephyr/kernel.h>
#include <zephyr/shell/shell.h>
#include <nrfx_clock.h>
#include <nrfx_clock_hfclkaudio.h>
#include <contin_array.h>
#include <tone.h>
#include <pcm_mix.h>
Expand Down
1 change: 0 additions & 1 deletion applications/nrf5340_audio/src/audio/le_audio_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include <stdlib.h>
#include <zephyr/kernel.h>
#include <nrfx_clock.h>

#include "streamctrl.h"
#include "audio_datapath.h"
Expand Down
2 changes: 1 addition & 1 deletion applications/nrf5340_audio/src/modules/audio_i2s.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <zephyr/device.h>
#include <zephyr/drivers/pinctrl.h>
#include <nrfx_i2s.h>
#include <nrfx_clock.h>
#include <nrfx_clock_hfclkaudio.h>

#include "audio_sync_timer.h"

Expand Down
7 changes: 2 additions & 5 deletions applications/nrf5340_audio/src/utils/peripherals.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
#include "peripherals.h"

#include <nrfx_clock.h>
#include <nrfx_clock_hfclk.h>

#include "led_assignments.h"
#include "led.h"
Expand Down Expand Up @@ -148,10 +148,7 @@ int peripherals_init(void)
}

/* Use this to turn on 128 MHz clock for cpu_app */
ret = nrfx_clock_divider_set(NRF_CLOCK_DOMAIN_HFCLK, NRF_CLOCK_HFCLK_DIV_1);
if (ret) {
return ret;
}
nrfx_clock_hfclk_divider_set(NRF_CLOCK_HFCLK_DIV_1);

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
compatible = "nordic,nrf-spi";
status = "okay";
};

&lfclk {
k32src = "rc";
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@
};
};
};

&lfclk {
k32src = "rc";
};
38 changes: 38 additions & 0 deletions applications/nrf_desktop/src/modules/hfclk_lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(MODULE);

#if defined(CONFIG_CLOCK_CONTROL_NRF)
static struct onoff_manager *mgr;
#else
static const struct device *dev;
#endif
static struct onoff_client cli;

static void hfclk_lock(void)
{
#if defined(CONFIG_CLOCK_CONTROL_NRF)
if (mgr) {
return;
}
Expand All @@ -41,19 +46,52 @@ static void hfclk_lock(void)
module_set_state(MODULE_STATE_READY);
}
}
#else
if (dev) {
return;
}

dev = DEVICE_DT_GET_ONE(COND_CODE_1(NRF_CLOCK_HAS_HFCLK,
(nordic_nrf_clock_hfclk),
(nordic_nrf_clock_xo)));
if (!dev) {
module_set_state(MODULE_STATE_ERROR);
} else {
int err;

sys_notify_init_spinwait(&cli.notify);
err = nrf_clock_control_request(dev, NULL, &cli);
if (err < 0) {
dev = NULL;
module_set_state(MODULE_STATE_ERROR);
} else {
module_set_state(MODULE_STATE_READY);
}
}
#endif
}

static void hfclk_unlock(void)
{
int err;

#if defined(CONFIG_CLOCK_CONTROL_NRF)
if (!mgr) {
return;
}

err = onoff_cancel_or_release(mgr, &cli);
module_set_state((err < 0) ? MODULE_STATE_ERROR : MODULE_STATE_OFF);
mgr = NULL;
#else
if (!dev) {
return;
}

err = nrf_clock_control_cancel_or_release(dev, NULL, &cli);
module_set_state((err < 0) ? MODULE_STATE_ERROR : MODULE_STATE_OFF);
dev = NULL;
#endif
}


Expand Down
15 changes: 0 additions & 15 deletions drivers/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,4 @@ config HPF
default y if MSPI_HPF
# Temporary kconfig to include DPPI channel allocation for HPF

config CLOCK_CONTROL_NRF2
bool "Use NRF2 clock control API"
depends on CLOCK_CONTROL
depends on SOC_SERIES_NRF54HX && !RISCV_CORE_NORDIC_VPR
default y
help
The clock control drivers are currently split into two groups,
one which implement the "NRF2" clock control API, and one which
implements the "NRF" clock control API. This config helps
applications and subsystems align to the clock control API
implemented for an SoC.

This config can be removed once all clock control drivers have
been updated to use the "NRF2" API.

endmenu
19 changes: 19 additions & 0 deletions drivers/serial/uart_nrf_sw_lpuart.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,11 +354,19 @@ static void deactivate_rx(struct lpuart_data *data)
int err;

if (IS_ENABLED(CONFIG_NRF_SW_LPUART_HFXO_ON_RX)) {
#if defined(CONFIG_CLOCK_CONTROL_NRF)
struct onoff_manager *mgr =
z_nrf_clock_control_get_onoff(CLOCK_CONTROL_NRF_SUBSYS_HF);

err = onoff_cancel_or_release(mgr, &data->rx_clk_cli);
__ASSERT_NO_MSG(err >= 0);
#else
const struct device *dev = DEVICE_DT_GET_ONE(COND_CODE_1(NRF_CLOCK_HAS_HFCLK,
(nordic_nrf_clock_hfclk),
(nordic_nrf_clock_xo)));
err = nrf_clock_control_cancel_or_release(dev, NULL, &data->rx_clk_cli);
__ASSERT_NO_MSG(err >= 0);
#endif
}

/* abort rx */
Expand Down Expand Up @@ -413,13 +421,24 @@ static void rx_hfclk_callback(struct onoff_manager *mgr,

static void rx_hfclk_request(struct lpuart_data *data)
{
#if defined(CONFIG_CLOCK_CONTROL_NRF)
struct onoff_manager *mgr =
z_nrf_clock_control_get_onoff(CLOCK_CONTROL_NRF_SUBSYS_HF);
int err;

sys_notify_init_callback(&data->rx_clk_cli.notify, rx_hfclk_callback);
err = onoff_request(mgr, &data->rx_clk_cli);
__ASSERT_NO_MSG(err >= 0);
#else
const struct device *dev = DEVICE_DT_GET_ONE(COND_CODE_1(NRF_CLOCK_HAS_HFCLK,
(nordic_nrf_clock_hfclk),
(nordic_nrf_clock_xo)));
int err;

sys_notify_init_callback(&data->rx_clk_cli.notify, rx_hfclk_callback);
err = nrf_clock_control_request(dev, NULL, &data->rx_clk_cli);
__ASSERT_NO_MSG(err >= 0);
#endif
}

static void start_rx_activation(struct lpuart_data *data)
Expand Down
14 changes: 14 additions & 0 deletions dts/common/nordic/nrf54ls05b.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,20 @@
status = "disabled";
};

lfclk: lfclk@10e000 {
compatible = "nordic,nrf-clock-lfclk";
reg = <0x10e000 0x1000>;
interrupts = <270 NRF_DEFAULT_IRQ_PRIORITY>;
status = "disabled";
};

xo: xo@10e000 {
compatible = "nordic,nrf-clock-xo";
reg = <0x10e000 0x1000>;
interrupts = <270 NRF_DEFAULT_IRQ_PRIORITY>;
status = "disabled";
};

power: power@10e000 {
compatible = "nordic,nrf-power";
reg = <0x10e000 0x1000>;
Expand Down
14 changes: 14 additions & 0 deletions dts/common/nordic/nrf54lv10a.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,20 @@
status = "disabled";
};

lfclk: lfclk@10e000 {
compatible = "nordic,nrf-clock-lfclk";
reg = <0x10e000 0x1000>;
interrupts = <270 NRF_DEFAULT_IRQ_PRIORITY>;
status = "disabled";
};

xo: xo@10e000 {
compatible = "nordic,nrf-clock-xo";
reg = <0x10e000 0x1000>;
interrupts = <270 NRF_DEFAULT_IRQ_PRIORITY>;
status = "disabled";
};

power: power@10e000 {
compatible = "nordic,nrf-power";
reg = <0x10e000 0x1000>;
Expand Down
21 changes: 21 additions & 0 deletions dts/common/nordic/nrf7120_enga.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,27 @@
status = "disabled";
};

lfclk: lfclk@10e000 {
compatible = "nordic,nrf-clock-lfclk";
reg = <0x10e000 0x1000>;
interrupts = <270 NRF_DEFAULT_IRQ_PRIORITY>;
status = "disabled";
};

xo: xo@10e000 {
compatible = "nordic,nrf-clock-xo";
reg = <0x10e000 0x1000>;
interrupts = <270 NRF_DEFAULT_IRQ_PRIORITY>;
status = "disabled";
};

xo24m: xo24m@10e000 {
compatible = "nordic,nrf-clock-xo24m";
reg = <0x10e000 0x1000>;
interrupts = <270 NRF_DEFAULT_IRQ_PRIORITY>;
status = "disabled";
};

audio_auxpll: auxpll@130000 {
compatible = "nordic,nrf-auxpll";
reg = <0x130000 0x1000>;
Expand Down
22 changes: 17 additions & 5 deletions samples/bluetooth/direct_test_mode/src/dtm.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <hal/nrf_egu.h>
#include <hal/nrf_radio.h>

#if defined(CONFIG_CLOCK_CONTROL_NRF2)
#if defined(CONFIG_CLOCK_CONTROL_NRFS)
#include <hal/nrf_lrcconf.h>
#endif

Expand Down Expand Up @@ -718,23 +718,35 @@ static void anomaly_timer_handler(nrf_timer_event_t event_type, void *context);
static void dtm_timer_handler(nrf_timer_event_t event_type, void *context);
static void radio_handler(const void *context);

#if defined(CONFIG_CLOCK_CONTROL_NRF)
#if defined(CONFIG_CLOCK_CONTROL_NRFX)
static int clock_init(void)
{
int err;
int res;
struct onoff_manager *clk_mgr;
struct onoff_client clk_cli;
#if defined(CONFIG_CLOCK_CONTROL_NRF)
struct onoff_manager *clk_mgr;

clk_mgr = z_nrf_clock_control_get_onoff(CLOCK_CONTROL_NRF_SUBSYS_HF);
if (!clk_mgr) {
#else
const struct device *dev = DEVICE_DT_GET_ONE(COND_CODE_1(NRF_CLOCK_HAS_HFCLK,
(nordic_nrf_clock_hfclk),
(nordic_nrf_clock_xo)));

if (!dev) {
#endif
printk("Unable to get the Clock manager\n");
return -ENXIO;
}

sys_notify_init_spinwait(&clk_cli.notify);

#if defined(CONFIG_CLOCK_CONTROL_NRF)
err = onoff_request(clk_mgr, &clk_cli);
#else
err = nrf_clock_control_request(dev, NULL, &clk_cli);
#endif
if (err < 0) {
printk("Clock request failed: %d\n", err);
return err;
Expand All @@ -761,7 +773,7 @@ static int clock_init(void)
return err;
}

#elif defined(CONFIG_CLOCK_CONTROL_NRF2)
#elif defined(CONFIG_CLOCK_CONTROL_NRFS)

int clock_init(void)
{
Expand Down Expand Up @@ -791,7 +803,7 @@ int clock_init(void)

#else
BUILD_ASSERT(false, "No Clock Control driver");
#endif /* defined(CONFIG_CLOCK_CONTROL_NRF2) */
#endif /* defined(CONFIG_CLOCK_CONTROL_NRFS) */

static int timer_init(void)
{
Expand Down
5 changes: 2 additions & 3 deletions samples/bluetooth/nrf_auraconfig/src/nrf_auraconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <zephyr/zbus/zbus.h>
#include <zephyr/sys/byteorder.h>
#include <zephyr/shell/shell.h>
#include <nrfx_clock.h>
#include <nrfx_clock_hfclk.h>
#include <audio_defines.h>

#include "presets.h"
Expand Down Expand Up @@ -702,8 +702,7 @@ void nrf_auraconfig_main(void)

LOG_DBG("Main started");

ret = nrfx_clock_divider_set(NRF_CLOCK_DOMAIN_HFCLK, NRF_CLOCK_HFCLK_DIV_1);
ERR_CHK_MSG(ret, "Failed to set HFCLK divider");
nrfx_clock_hfclk_divider_set(NRF_CLOCK_HFCLK_DIV_1);

ret = led_init();
ERR_CHK_MSG(ret, "Failed to initialize LED module");
Expand Down
11 changes: 10 additions & 1 deletion samples/cellular/at_client/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,21 @@
/* To strictly comply with UART timing, enable external XTAL oscillator */
void enable_xtal(void)
{
struct onoff_manager *clk_mgr;
static struct onoff_client cli = {};

#if defined(CONFIG_CLOCK_CONTROL_NRF)
struct onoff_manager *clk_mgr;

clk_mgr = z_nrf_clock_control_get_onoff(CLOCK_CONTROL_NRF_SUBSYS_HF);
sys_notify_init_spinwait(&cli.notify);
(void)onoff_request(clk_mgr, &cli);
#else
const struct device *dev = DEVICE_DT_GET_ONE(COND_CODE_1(NRF_CLOCK_HAS_HFCLK,
(nordic_nrf_clock_hfclk),
(nordic_nrf_clock_xo)));
sys_notify_init_spinwait(&cli.notify);
(void)nrf_clock_control_request(dev, &cli);
#endif
}

int main(void)
Expand Down
Loading