Skip to content

Commit 625a31e

Browse files
gmarulljukkar
authored andcommitted
[nrf fromlist] 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. Upstream PR #: 81122 Signed-off-by: Gerard Marull-Paretas <[email protected]> (cherry picked from commit 21901ca3f1a535466a5b4023d66bf492d974d808)
1 parent 817682f commit 625a31e

File tree

3 files changed

+13
-20
lines changed

3 files changed

+13
-20
lines changed

boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-common.dtsi

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
&hfxo {
1212
status = "okay";
1313
accuracy-ppm = <30>;
14-
startup-time-us = <850>;
15-
mode = "crystal";
1614
};
1715

1816
&lfxo {

drivers/clock_control/clock_control_nrf2_hfxo.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
LOG_MODULE_DECLARE(clock_control_nrf2, CONFIG_CLOCK_CONTROL_LOG_LEVEL);
1313

1414
#include <soc_lrcconf.h>
15+
#include <hal/nrf_bicr.h>
1516

1617
BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1,
1718
"multiple instances not supported");
@@ -24,14 +25,16 @@ struct dev_data_hfxo {
2425
#if defined(CONFIG_ZERO_LATENCY_IRQS)
2526
uint16_t request_count;
2627
#endif /* CONFIG_ZERO_LATENCY_IRQS */
28+
k_timeout_t start_up_time;
2729
};
2830

2931
struct dev_config_hfxo {
3032
uint32_t fixed_frequency;
3133
uint16_t fixed_accuracy;
32-
k_timeout_t start_up_time;
3334
};
3435

36+
#define BICR (NRF_BICR_Type *)DT_REG_ADDR(DT_NODELABEL(bicr))
37+
3538
#if defined(CONFIG_ZERO_LATENCY_IRQS)
3639
static uint32_t full_irq_lock(void)
3740
{
@@ -114,8 +117,6 @@ static void onoff_start_hfxo(struct onoff_manager *mgr, onoff_notify_fn notify)
114117
{
115118
struct dev_data_hfxo *dev_data =
116119
CONTAINER_OF(mgr, struct dev_data_hfxo, mgr);
117-
const struct device *dev = DEVICE_DT_INST_GET(0);
118-
const struct dev_config_hfxo *dev_config = dev->config;
119120

120121
dev_data->notify = notify;
121122
request_hfxo(dev_data);
@@ -124,7 +125,7 @@ static void onoff_start_hfxo(struct onoff_manager *mgr, onoff_notify_fn notify)
124125
* unreliable. Hence the timer is used to simply wait the expected
125126
* start-up time. To be removed once the hardware is fixed.
126127
*/
127-
k_timer_start(&dev_data->timer, dev_config->start_up_time, K_NO_WAIT);
128+
k_timer_start(&dev_data->timer, dev_data->start_up_time, K_NO_WAIT);
128129
}
129130

130131
static void stop_hfxo(struct dev_data_hfxo *dev_data)
@@ -258,13 +259,21 @@ static int init_hfxo(const struct device *dev)
258259
.start = onoff_start_hfxo,
259260
.stop = onoff_stop_hfxo
260261
};
262+
uint32_t start_up_time;
261263
int rc;
262264

263265
rc = onoff_manager_init(&dev_data->mgr, &transitions);
264266
if (rc < 0) {
265267
return rc;
266268
}
267269

270+
start_up_time = nrf_bicr_hfxo_startup_time_us_get(BICR);
271+
if (start_up_time == NRF_BICR_HFXO_STARTUP_TIME_UNCONFIGURED) {
272+
return -EINVAL;
273+
}
274+
275+
dev_data->start_up_time = K_USEC(start_up_time);
276+
268277
k_timer_init(&dev_data->timer, hfxo_start_up_timer_handler, NULL);
269278

270279
return 0;
@@ -286,7 +295,6 @@ static struct dev_data_hfxo data_hfxo;
286295
static const struct dev_config_hfxo config_hfxo = {
287296
.fixed_frequency = DT_INST_PROP(0, clock_frequency),
288297
.fixed_accuracy = DT_INST_PROP(0, accuracy_ppm),
289-
.start_up_time = K_USEC(DT_INST_PROP(0, startup_time_us)),
290298
};
291299

292300
DEVICE_DT_INST_DEFINE(0, init_hfxo, NULL,

dts/bindings/clock/nordic,nrf54h-hfxo.yaml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,3 @@ properties:
1515
type: int
1616
description: Clock accuracy in parts per million
1717
required: true
18-
19-
startup-time-us:
20-
type: int
21-
description: Clock startup time in micro seconds
22-
required: true
23-
24-
mode:
25-
type: string
26-
description: HFXO operational mode
27-
required: true
28-
enum:
29-
- "crystal"
30-
- "external-square"

0 commit comments

Comments
 (0)