drivers: clock_control: nrf54h-hfxo: use values from BICR

The real, applicable and trusted values are the ones flashed into BICR.
So, drop DT properties that replicate BICR and use runtime reads to BICR
instead.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
This commit is contained in:
Gerard Marull-Paretas 2024-11-07 15:08:48 +01:00 committed by Benjamin Cabé
parent 3d3dce61b6
commit 5415c42dd4
3 changed files with 13 additions and 20 deletions

View file

@ -11,8 +11,6 @@
&hfxo {
status = "okay";
accuracy-ppm = <30>;
startup-time-us = <850>;
mode = "crystal";
};
&lfxo {

View file

@ -12,6 +12,7 @@
LOG_MODULE_DECLARE(clock_control_nrf2, CONFIG_CLOCK_CONTROL_LOG_LEVEL);
#include <soc_lrcconf.h>
#include <hal/nrf_bicr.h>
BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1,
"multiple instances not supported");
@ -24,14 +25,16 @@ struct dev_data_hfxo {
#if defined(CONFIG_ZERO_LATENCY_IRQS)
uint16_t request_count;
#endif /* CONFIG_ZERO_LATENCY_IRQS */
k_timeout_t start_up_time;
};
struct dev_config_hfxo {
uint32_t fixed_frequency;
uint16_t fixed_accuracy;
k_timeout_t start_up_time;
};
#define BICR (NRF_BICR_Type *)DT_REG_ADDR(DT_NODELABEL(bicr))
#if defined(CONFIG_ZERO_LATENCY_IRQS)
static uint32_t full_irq_lock(void)
{
@ -106,8 +109,6 @@ static void onoff_start_hfxo(struct onoff_manager *mgr, onoff_notify_fn notify)
{
struct dev_data_hfxo *dev_data =
CONTAINER_OF(mgr, struct dev_data_hfxo, mgr);
const struct device *dev = DEVICE_DT_INST_GET(0);
const struct dev_config_hfxo *dev_config = dev->config;
dev_data->notify = notify;
request_hfxo(dev_data);
@ -116,7 +117,7 @@ static void onoff_start_hfxo(struct onoff_manager *mgr, onoff_notify_fn notify)
* unreliable. Hence the timer is used to simply wait the expected
* start-up time. To be removed once the hardware is fixed.
*/
k_timer_start(&dev_data->timer, dev_config->start_up_time, K_NO_WAIT);
k_timer_start(&dev_data->timer, dev_data->start_up_time, K_NO_WAIT);
}
static void stop_hfxo(struct dev_data_hfxo *dev_data)
@ -250,6 +251,7 @@ static int init_hfxo(const struct device *dev)
.start = onoff_start_hfxo,
.stop = onoff_stop_hfxo
};
uint32_t start_up_time;
int rc;
rc = onoff_manager_init(&dev_data->mgr, &transitions);
@ -257,6 +259,13 @@ static int init_hfxo(const struct device *dev)
return rc;
}
start_up_time = nrf_bicr_hfxo_startup_time_us_get(BICR);
if (start_up_time == NRF_BICR_HFXO_STARTUP_TIME_UNCONFIGURED) {
return -EINVAL;
}
dev_data->start_up_time = K_USEC(start_up_time);
k_timer_init(&dev_data->timer, hfxo_start_up_timer_handler, NULL);
return 0;
@ -278,7 +287,6 @@ static struct dev_data_hfxo data_hfxo;
static const struct dev_config_hfxo config_hfxo = {
.fixed_frequency = DT_INST_PROP(0, clock_frequency),
.fixed_accuracy = DT_INST_PROP(0, accuracy_ppm),
.start_up_time = K_USEC(DT_INST_PROP(0, startup_time_us)),
};
DEVICE_DT_INST_DEFINE(0, init_hfxo, NULL,

View file

@ -15,16 +15,3 @@ properties:
type: int
description: Clock accuracy in parts per million
required: true
startup-time-us:
type: int
description: Clock startup time in micro seconds
required: true
mode:
type: string
description: HFXO operational mode
required: true
enum:
- "crystal"
- "external-square"