diff --git a/samples/bluetooth/direct_test_mode/prj.conf b/samples/bluetooth/direct_test_mode/prj.conf index 850c5e611266..8788565a4e08 100644 --- a/samples/bluetooth/direct_test_mode/prj.conf +++ b/samples/bluetooth/direct_test_mode/prj.conf @@ -23,5 +23,6 @@ CONFIG_LOG_BACKEND_RTT=y CONFIG_NRFX_TIMER0=y CONFIG_NRFX_TIMER1=y CONFIG_NRFX_TIMER2=y +CONFIG_CLOCK_CONTROL=y CONFIG_FEM_AL_LIB=y diff --git a/samples/bluetooth/direct_test_mode/prj_hci.conf b/samples/bluetooth/direct_test_mode/prj_hci.conf index 3b00c98335d9..b92c82e9ec58 100644 --- a/samples/bluetooth/direct_test_mode/prj_hci.conf +++ b/samples/bluetooth/direct_test_mode/prj_hci.conf @@ -23,6 +23,7 @@ CONFIG_LOG_BACKEND_RTT=y CONFIG_NRFX_TIMER0=y CONFIG_NRFX_TIMER1=y CONFIG_NRFX_TIMER2=y +CONFIG_CLOCK_CONTROL=y CONFIG_FEM_AL_LIB=y diff --git a/samples/bluetooth/direct_test_mode/prj_usb.conf b/samples/bluetooth/direct_test_mode/prj_usb.conf index 12d257fa3296..8f5c63293a29 100644 --- a/samples/bluetooth/direct_test_mode/prj_usb.conf +++ b/samples/bluetooth/direct_test_mode/prj_usb.conf @@ -23,6 +23,7 @@ CONFIG_LOG_BACKEND_RTT=y CONFIG_NRFX_TIMER0=y CONFIG_NRFX_TIMER1=y CONFIG_NRFX_TIMER2=y +CONFIG_CLOCK_CONTROL=y CONFIG_FEM_AL_LIB=y diff --git a/samples/bluetooth/direct_test_mode/src/dtm.c b/samples/bluetooth/direct_test_mode/src/dtm.c index b9665647dfaf..b186474dedff 100644 --- a/samples/bluetooth/direct_test_mode/src/dtm.c +++ b/samples/bluetooth/direct_test_mode/src/dtm.c @@ -16,10 +16,8 @@ #endif /* CONFIG_FEM */ #include -#if defined(CONFIG_CLOCK_CONTROL_NRF) #include #include -#endif /* #if defined(CONFIG_CLOCK_CONTROL_NRF) */ #include #if !(defined(CONFIG_SOC_SERIES_NRF54HX) || defined(CONFIG_SOC_SERIES_NRF54LX)) #include @@ -28,6 +26,10 @@ #include #include +#if defined(CONFIG_CLOCK_CONTROL_NRF2) +#include +#endif + #ifdef NRF53_SERIES #include #endif /* NRF53_SERIES */ @@ -671,7 +673,43 @@ static int clock_init(void) return err; } -#endif /* defined(CONFIG_CLOCK_CONTROL_NRF) */ + +#elif defined(CONFIG_CLOCK_CONTROL_NRF2) + +int clock_init(void) +{ + int err; + int res; + const struct device *radio_clk_dev = + DEVICE_DT_GET_OR_NULL(DT_CLOCKS_CTLR(DT_NODELABEL(radio))); + struct onoff_client radio_cli; + + /** Keep radio domain powered all the time to reduce latency. */ + nrf_lrcconf_poweron_force_set(NRF_LRCCONF010, NRF_LRCCONF_POWER_DOMAIN_1, true); + + sys_notify_init_spinwait(&radio_cli.notify); + + err = nrf_clock_control_request(radio_clk_dev, NULL, &radio_cli); + + do { + err = sys_notify_fetch_result(&radio_cli.notify, &res); + if (!err && res) { + printk("Clock could not be started: %d\n", res); + return res; + } + } while (err == -EAGAIN); + +#if defined(NRF54L15_XXAA) + /* MLTPAN-20 */ + nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_PLLSTART); +#endif /* defined(NRF54L15_XXAA) */ + + return 0; +} + +#else +BUILD_ASSERT(false, "No Clock Control driver"); +#endif /* defined(CONFIG_CLOCK_CONTROL_NRF2) */ static int timer_init(void) { @@ -1102,12 +1140,10 @@ int dtm_init(dtm_iq_report_callback_t callback) { int err; -#if defined(CONFIG_CLOCK_CONTROL_NRF) err = clock_init(); if (err) { return err; } -#endif /* defined(CONFIG_CLOCK_CONTROL_NRF) */ #if defined(CONFIG_SOC_SERIES_NRF54HX) /* Apply HMPAN-102 workaround for nRF54H series */ diff --git a/samples/esb/esb_prx/prj.conf b/samples/esb/esb_prx/prj.conf index 9681a0e5ae44..4f4255090272 100644 --- a/samples/esb/esb_prx/prj.conf +++ b/samples/esb/esb_prx/prj.conf @@ -6,3 +6,4 @@ CONFIG_NCS_SAMPLES_DEFAULTS=y CONFIG_ESB=y CONFIG_DK_LIBRARY=y +CONFIG_CLOCK_CONTROL=y diff --git a/samples/esb/esb_prx/src/main.c b/samples/esb/esb_prx/src/main.c index 0a21f7e8485a..32e043c632b9 100644 --- a/samples/esb/esb_prx/src/main.c +++ b/samples/esb/esb_prx/src/main.c @@ -5,10 +5,8 @@ */ #include #include -#if defined(CONFIG_CLOCK_CONTROL_NRF) #include #include -#endif /* defined(CONFIG_CLOCK_CONTROL_NRF) */ #if defined(NRF54L15_XXAA) #include #endif /* defined(NRF54L15_XXAA) */ @@ -20,6 +18,9 @@ #include #include #include +#if defined(CONFIG_CLOCK_CONTROL_NRF2) +#include +#endif LOG_MODULE_REGISTER(esb_prx, CONFIG_ESB_PRX_APP_LOG_LEVEL); @@ -104,7 +105,45 @@ int clocks_start(void) LOG_DBG("HF clock started"); return 0; } -#endif /* defined(CONFIG_CLOCK_CONTROL_NRF) */ + +#elif defined(CONFIG_CLOCK_CONTROL_NRF2) + +int clocks_start(void) +{ + int err; + int res; + const struct device *radio_clk_dev = + DEVICE_DT_GET_OR_NULL(DT_CLOCKS_CTLR(DT_NODELABEL(radio))); + struct onoff_client radio_cli; + + /** Keep radio domain powered all the time to reduce latency. */ + nrf_lrcconf_poweron_force_set(NRF_LRCCONF010, NRF_LRCCONF_POWER_DOMAIN_1, true); + + sys_notify_init_spinwait(&radio_cli.notify); + + err = nrf_clock_control_request(radio_clk_dev, NULL, &radio_cli); + + do { + err = sys_notify_fetch_result(&radio_cli.notify, &res); + if (!err && res) { + LOG_ERR("Clock could not be started: %d", res); + return res; + } + } while (err == -EAGAIN); + +#if defined(NRF54L15_XXAA) + /* MLTPAN-20 */ + nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_PLLSTART); +#endif /* defined(NRF54L15_XXAA) */ + + LOG_DBG("HF clock started"); + + return 0; +} + +#else +BUILD_ASSERT(false, "No Clock Control driver"); +#endif /* defined(CONFIG_CLOCK_CONTROL_NRF2) */ int esb_initialize(void) { @@ -156,12 +195,10 @@ int main(void) LOG_INF("Enhanced ShockBurst prx sample"); -#if defined(CONFIG_CLOCK_CONTROL_NRF) err = clocks_start(); if (err) { return 0; } -#endif /* defined(CONFIG_CLOCK_CONTROL_NRF) */ err = dk_leds_init(); if (err) { diff --git a/samples/esb/esb_ptx/prj.conf b/samples/esb/esb_ptx/prj.conf index 9681a0e5ae44..4f4255090272 100644 --- a/samples/esb/esb_ptx/prj.conf +++ b/samples/esb/esb_ptx/prj.conf @@ -6,3 +6,4 @@ CONFIG_NCS_SAMPLES_DEFAULTS=y CONFIG_ESB=y CONFIG_DK_LIBRARY=y +CONFIG_CLOCK_CONTROL=y diff --git a/samples/esb/esb_ptx/src/main.c b/samples/esb/esb_ptx/src/main.c index 675498610f3c..fe880160165d 100644 --- a/samples/esb/esb_ptx/src/main.c +++ b/samples/esb/esb_ptx/src/main.c @@ -3,10 +3,8 @@ * * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ -#if defined(CONFIG_CLOCK_CONTROL_NRF) #include #include -#endif /* defined(CONFIG_CLOCK_CONTROL_NRF) */ #if defined(NRF54L15_XXAA) #include #endif /* defined(NRF54L15_XXAA) */ @@ -20,6 +18,9 @@ #include #include #include +#if defined(CONFIG_CLOCK_CONTROL_NRF2) +#include +#endif LOG_MODULE_REGISTER(esb_ptx, CONFIG_ESB_PTX_APP_LOG_LEVEL); @@ -97,7 +98,44 @@ int clocks_start(void) LOG_DBG("HF clock started"); return 0; } -#endif /* defined(CONFIG_CLOCK_CONTROL_NRF) */ + +#elif defined(CONFIG_CLOCK_CONTROL_NRF2) + +int clocks_start(void) +{ + int err; + int res; + const struct device *radio_clk_dev = + DEVICE_DT_GET_OR_NULL(DT_CLOCKS_CTLR(DT_NODELABEL(radio))); + struct onoff_client radio_cli; + + /** Keep radio domain powered all the time to reduce latency. */ + nrf_lrcconf_poweron_force_set(NRF_LRCCONF010, NRF_LRCCONF_POWER_DOMAIN_1, true); + + sys_notify_init_spinwait(&radio_cli.notify); + + err = nrf_clock_control_request(radio_clk_dev, NULL, &radio_cli); + + do { + err = sys_notify_fetch_result(&radio_cli.notify, &res); + if (!err && res) { + LOG_ERR("Clock could not be started: %d", res); + return res; + } + } while (err == -EAGAIN); + +#if defined(NRF54L15_XXAA) + /* MLTPAN-20 */ + nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_PLLSTART); +#endif /* defined(NRF54L15_XXAA) */ + + LOG_DBG("HF clock started"); + return 0; +} + +#else +BUILD_ASSERT(false, "No Clock Control driver"); +#endif /* defined(CONFIG_CLOCK_CONTROL_NRF2) */ int esb_initialize(void) { @@ -162,12 +200,10 @@ int main(void) LOG_INF("Enhanced ShockBurst ptx sample"); -#if defined(CONFIG_CLOCK_CONTROL_NRF) err = clocks_start(); if (err) { return 0; } -#endif /* defined(CONFIG_CLOCK_CONTROL_NRF) */ err = dk_leds_init(); if (err) { diff --git a/samples/peripheral/radio_test/prj.conf b/samples/peripheral/radio_test/prj.conf index 4c2f315905d4..c130dc5293b8 100644 --- a/samples/peripheral/radio_test/prj.conf +++ b/samples/peripheral/radio_test/prj.conf @@ -10,6 +10,7 @@ CONFIG_SHELL=y CONFIG_DYNAMIC_INTERRUPTS=y CONFIG_NRFX_TIMER0=y +CONFIG_CLOCK_CONTROL=y CONFIG_ENTROPY_GENERATOR=y CONFIG_NRF_SECURITY=y diff --git a/samples/peripheral/radio_test/prj_usb.conf b/samples/peripheral/radio_test/prj_usb.conf index f79b4a9f0033..92fcd71d21b1 100644 --- a/samples/peripheral/radio_test/prj_usb.conf +++ b/samples/peripheral/radio_test/prj_usb.conf @@ -10,6 +10,7 @@ CONFIG_SHELL=y CONFIG_DYNAMIC_INTERRUPTS=y CONFIG_NRFX_TIMER0=y +CONFIG_CLOCK_CONTROL=y CONFIG_ENTROPY_GENERATOR=y CONFIG_NRF_SECURITY=y diff --git a/samples/peripheral/radio_test/src/main.c b/samples/peripheral/radio_test/src/main.c index 1d7ff55c9b26..c5a498383692 100644 --- a/samples/peripheral/radio_test/src/main.c +++ b/samples/peripheral/radio_test/src/main.c @@ -5,13 +5,14 @@ */ #include -#if defined(CONFIG_CLOCK_CONTROL_NRF) #include #include -#endif /* defined(CONFIG_CLOCK_CONTROL_NRF) */ #if defined(NRF54L15_XXAA) #include #endif /* defined(NRF54L15_XXAA) */ +#if defined(CONFIG_CLOCK_CONTROL_NRF2) +#include +#endif #if defined(CONFIG_CLOCK_CONTROL_NRF) static void clock_init(void) @@ -50,15 +51,49 @@ static void clock_init(void) printk("Clock has started\n"); } + +#elif defined(CONFIG_CLOCK_CONTROL_NRF2) + +static void clock_init(void) +{ + int err; + int res; + const struct device *radio_clk_dev = + DEVICE_DT_GET_OR_NULL(DT_CLOCKS_CTLR(DT_NODELABEL(radio))); + struct onoff_client radio_cli; + + /** Keep radio domain powered all the time to reduce latency. */ + nrf_lrcconf_poweron_force_set(NRF_LRCCONF010, NRF_LRCCONF_POWER_DOMAIN_1, true); + + sys_notify_init_spinwait(&radio_cli.notify); + + err = nrf_clock_control_request(radio_clk_dev, NULL, &radio_cli); + + do { + err = sys_notify_fetch_result(&radio_cli.notify, &res); + if (!err && res) { + printk("Clock could not be started: %d\n", res); + return; + } + } while (err == -EAGAIN); + +#if defined(NRF54L15_XXAA) + /* MLTPAN-20 */ + nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_PLLSTART); +#endif /* defined(NRF54L15_XXAA) */ + + printk("Clock has started\n"); +} + +#else +BUILD_ASSERT(false, "No Clock Control driver"); #endif /* defined(CONFIG_CLOCK_CONTROL_NRF) */ int main(void) { printk("Starting Radio Test example\n"); -#if defined(CONFIG_CLOCK_CONTROL_NRF) clock_init(); -#endif /* defined(CONFIG_CLOCK_CONTROL_NRF) */ #if defined(CONFIG_SOC_SERIES_NRF54HX) /* Apply HMPAN-102 workaround for nRF54H series */