Skip to content

clock_control: add vendor specific API to get HF clock startup time #90615

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

Merged
3 changes: 1 addition & 2 deletions drivers/clock_control/Kconfig.nrf
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ endif # CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION

config CLOCK_CONTROL_NRF_HFINT_CALIBRATION
bool "HFINT clock calibration"
depends on SOC_NRF54L05 || SOC_NRF54L10 || SOC_NRF54L15
depends on DT_HAS_NORDIC_NRF_HFXO_ENABLED
depends on DT_HAS_NORDIC_NRF54L_HFXO_ENABLED
depends on !TRUSTED_EXECUTION_NONSECURE
select EXPERIMENTAL
help
Expand Down
7 changes: 7 additions & 0 deletions drivers/clock_control/clock_control_nrf.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,13 @@ void z_nrf_clock_bt_ctlr_hf_release(void)
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
9 changes: 9 additions & 0 deletions dts/arm/nordic/nrf51822.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@
};
};

clocks {
hfxo: hfxo {
compatible = "nordic,nrf51-hfxo";
clock-frequency = <16000000>;
startup-time-us = <1400>;
#clock-cells = <0>;
};
};

soc {
ficr: ficr@10000000 {
compatible = "nordic,nrf-ficr";
Expand Down
9 changes: 9 additions & 0 deletions dts/arm/nordic/nrf52805.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
};
};

clocks {
hfxo: hfxo {
compatible = "nordic,nrf52-hfxo";
clock-frequency = <64000000>;
startup-time-us = <1400>;
#clock-cells = <0>;
};
};

soc {
ficr: ficr@10000000 {
compatible = "nordic,nrf-ficr";
Expand Down
9 changes: 9 additions & 0 deletions dts/arm/nordic/nrf52810.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@
};
};

clocks {
hfxo: hfxo {
compatible = "nordic,nrf52-hfxo";
clock-frequency = <64000000>;
startup-time-us = <1400>;
#clock-cells = <0>;
};
};

soc {
ficr: ficr@10000000 {
compatible = "nordic,nrf-ficr";
Expand Down
9 changes: 9 additions & 0 deletions dts/arm/nordic/nrf52811.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@
};
};

clocks {
hfxo: hfxo {
compatible = "nordic,nrf52-hfxo";
clock-frequency = <64000000>;
startup-time-us = <1400>;
#clock-cells = <0>;
};
};

soc {
ficr: ficr@10000000 {
compatible = "nordic,nrf-ficr";
Expand Down
9 changes: 9 additions & 0 deletions dts/arm/nordic/nrf52820.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@
};
};

clocks {
hfxo: hfxo {
compatible = "nordic,nrf52-hfxo";
clock-frequency = <64000000>;
startup-time-us = <1400>;
#clock-cells = <0>;
};
};

soc {
ficr: ficr@10000000 {
compatible = "nordic,nrf-ficr";
Expand Down
9 changes: 9 additions & 0 deletions dts/arm/nordic/nrf52832.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@
};
};

clocks {
hfxo: hfxo {
compatible = "nordic,nrf52-hfxo";
clock-frequency = <64000000>;
startup-time-us = <1400>;
#clock-cells = <0>;
};
};

soc {
ficr: ficr@10000000 {
compatible = "nordic,nrf-ficr";
Expand Down
9 changes: 9 additions & 0 deletions dts/arm/nordic/nrf52833.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@
};
};

clocks {
hfxo: hfxo {
compatible = "nordic,nrf52-hfxo";
clock-frequency = <64000000>;
startup-time-us = <1400>;
#clock-cells = <0>;
};
};

soc {
ficr: ficr@10000000 {
compatible = "nordic,nrf-ficr";
Expand Down
9 changes: 9 additions & 0 deletions dts/arm/nordic/nrf52840.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@
};
};

clocks {
hfxo: hfxo {
compatible = "nordic,nrf52-hfxo";
clock-frequency = <64000000>;
startup-time-us = <1400>;
#clock-cells = <0>;
};
};

soc {
ficr: ficr@10000000 {
compatible = "nordic,nrf-ficr";
Expand Down
1 change: 1 addition & 0 deletions dts/arm/nordic/nrf5340_cpuapp_peripherals.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ oscillators: clock-controller@4000 {
compatible = "nordic,nrf53-hfxo";
#clock-cells = <0>;
clock-frequency = <DT_FREQ_M(32)>;
startup-time-us = <1400>;
};
};

Expand Down
26 changes: 26 additions & 0 deletions dts/bindings/clock/nordic,nrf51-hfxo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright (c) 2025 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

description: Nordic nRF high-frequency crystal oscillator (nRF51 series)

compatible: "nordic,nrf51-hfxo"

include: fixed-clock.yaml

properties:
clock-frequency:
const: 16000000

startup-time-us:
type: int
required: true
description: |
Startup time in microseconds.

The value can be obtained by first measuring the time between
TASKS_HFCLKSTART and EVENTS_HFCLKSTARTED. Then multiply
the value by 2 to account for temperature and supply variations.

Note that the startup time will be longer usual on the first
power-up and as such should not be used to determine
startup-time-us.
25 changes: 25 additions & 0 deletions dts/bindings/clock/nordic,nrf52-hfxo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (c) 2025 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

description: Nordic nRF high-frequency crystal oscillator (nRF52 series)

compatible: "nordic,nrf52-hfxo"

include: fixed-clock.yaml

properties:
clock-frequency:
const: 64000000

startup-time-us:
type: int
description: |
Startup time in microseconds.

The value can be obtained by first measuring the time between
TASKS_HFCLKSTART and EVENTS_HFCLKSTARTED. Then multiply
the value by 2 to account for temperature and supply variations.

Note that the startup time will be longer usual on the first
power-up and as such should not be used to determine
startup-time-us.
14 changes: 14 additions & 0 deletions dts/bindings/clock/nordic,nrf53-hfxo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ properties:
clock-frequency:
const: 32000000

startup-time-us:
type: int
required: true
description: |
Startup time in microseconds.

The value can be obtained by first measuring the time between
TASKS_HFCLKSTART and EVENTS_HFCLKSTARTED. Then multiply
the value by 2 to account for temperature and supply variations.

Note that the startup time will be longer usual on the first
power-up and as such should not be used to determine
startup-time-us.

load-capacitors:
type: string
enum:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
# Copyright (c) 2024 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

description: Nordic nRF high-frequency crystal oscillator
description: Nordic nRF high-frequency crystal oscillator (nRF54L series)

compatible: "nordic,nrf-hfxo"
compatible: "nordic,nrf54l-hfxo"

include: fixed-clock.yaml

properties:
clock-frequency:
const: 32000000

startup-time-us:
type: int
required: true
description: |
Startup time in microseconds.

The value can be obtained by first measuring the time between
TASKS_XOSTART and EVENTS_XOTUNED. Then multiply the value by 2 to
account for temperature and supply variations.

Note that the startup time will be longer usual on the first
power-up and as such should not be used to determine
startup-time-us.

load-capacitors:
type: string
enum:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Copyright (c) 2024 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

description: Nordic nRF low-frequency crystal oscillator
description: Nordic nRF low-frequency crystal oscillator (nRF54L series)

compatible: "nordic,nrf-lfxo"
compatible: "nordic,nrf54l-lfxo"

include: fixed-clock.yaml

Expand Down
5 changes: 3 additions & 2 deletions dts/vendor/nordic/nrf54l09.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,16 @@
};

lfxo: lfxo {
compatible = "nordic,nrf-lfxo";
compatible = "nordic,nrf54l-lfxo";
#clock-cells = <0>;
clock-frequency = <32768>;
};

hfxo: hfxo {
compatible = "nordic,nrf-hfxo";
compatible = "nordic,nrf54l-hfxo";
#clock-cells = <0>;
clock-frequency = <DT_FREQ_M(32)>;
startup-time-us = <1650>;
};

hfpll: hfpll {
Expand Down
5 changes: 3 additions & 2 deletions dts/vendor/nordic/nrf54l20.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,16 @@
};

lfxo: lfxo {
compatible = "nordic,nrf-lfxo";
compatible = "nordic,nrf54l-lfxo";
#clock-cells = <0>;
clock-frequency = <32768>;
};

hfxo: hfxo {
compatible = "nordic,nrf-hfxo";
compatible = "nordic,nrf54l-hfxo";
#clock-cells = <0>;
clock-frequency = <DT_FREQ_M(32)>;
startup-time-us = <1650>;
};

hfpll: hfpll {
Expand Down
5 changes: 3 additions & 2 deletions dts/vendor/nordic/nrf54l_05_10_15.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,16 @@
};

lfxo: lfxo {
compatible = "nordic,nrf-lfxo";
compatible = "nordic,nrf54l-lfxo";
#clock-cells = <0>;
clock-frequency = <32768>;
};

hfxo: hfxo {
compatible = "nordic,nrf-hfxo";
compatible = "nordic,nrf54l-hfxo";
#clock-cells = <0>;
clock-frequency = <DT_FREQ_M(32)>;
startup-time-us = <1650>;
};

hfpll: hfpll {
Expand Down
7 changes: 7 additions & 0 deletions include/zephyr/drivers/clock_control/nrf_clock_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ void z_nrf_clock_bt_ctlr_hf_request(void);
*/
void z_nrf_clock_bt_ctlr_hf_release(void);

/**
* @brief Get clock startup time
*
* @retval HFCLK startup time in microseconds
*/
uint32_t z_nrf_clock_bt_ctlr_hf_get_startup_time_us(void);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the bt_ctrl part be removed? The use-cases go beyond just Bluetooth controller.

Copy link
Collaborator Author

@bjarki-andreasen bjarki-andreasen May 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming is intended to match z_nrf_clock_bt_ctlr_hf_request() and _release() to make it recognizable and clearly differentiate it from nrf_clock_control_hfxo_request() and newer APIs. It is planned to be replaced by the newer APIs in the future by #90399 in any case :)


#endif /* defined(CONFIG_CLOCK_CONTROL_NRF) */


Expand Down
Loading