Skip to content

drivers: clock_control: Nordic nRF54L15 HFCLK can't be activated with clock_control_on() anymore #94176

Description

@GardeningStevie

Describe the bug

Since PR #86354, my application can't activate the HF clock source (external HF crystal) with clock_control_on() when the crystal is physically off. The error code -EPERM (-1) is returned.

Actually, the internal flags state is set to 2 which means CLOCK_CONTROL_STATUS_ON. That's the reason why clock_control_on() returns -1. However, the clock control state is wrong. I have checked the CLOCK register and crystal itself. It is off.

The reason for CLOCK_CONTROL_STATUS_ON is the call of clkstarted_handle() here

#if NRF_CLOCK_HAS_XO_TUNE
case NRFX_CLOCK_EVT_XO_TUNED:
clkstarted_handle(dev, CLOCK_CONTROL_NRF_TYPE_HFCLK);
break;

clkstarted_handle() enforces that the internal flags state is set to CLOCK_CONTROL_STATUS_ON. Somehow that state is never reset to CLOCK_CONTROL_STATUS_OFF.

I could "fix" this issue when I replaced the current implementation with the old one that checked if the current state is CLOCK_CONTROL_STATUS_STARTING which make sense IMHO.

{
struct nrf_clock_control_sub_data *data =
get_sub_data(dev, CLOCK_CONTROL_NRF_TYPE_HFCLK);
/* Check needed due to anomaly 201:
* HFCLKSTARTED may be generated twice.
*/
if (GET_STATUS(data->flags) == CLOCK_CONTROL_STATUS_STARTING) {
clkstarted_handle(dev, CLOCK_CONTROL_NRF_TYPE_HFCLK);
}
break;

I didn't check if the clock is handled really correctly with this work-around. I have just noticed that with this fix clock_control_on() and clock_control_off() work as expected.

I use these feature for crystals frequency checking in production. Unable to enable the crystal permanently is a release blocker for me.

Regression

  • This is a regression.

Steps to reproduce

Not entirely sure what is really required to reproduce. I have ...

  1. Bluetooth application in advertising mode
  2. Stop BT advertising
  3. Call clock_control_on(CLOCK_DEVICE, CLOCK_CONTROL_NRF_SUBSYS_HF);

Relevant log output

Impact

Showstopper – Prevents release or major functionality; system unusable.

Environment

  • Zephyr 4.2
  • Nordic nRF54L15

Additional Context

No response

Metadata

Metadata

Labels

StalebugThe issue is a bug, or the PR is fixing a bugplatform: nRFNordic nRFxpriority: lowLow impact/importance bug

Type

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions