Skip to content

Commit 54d86e8

Browse files
bjarki-andreasenkartben
authored andcommitted
drivers: clock_control: nrf2_hfxo: impl resolve and startup_time
Implement nrf_clock_control_resolve() and nrf_clock_control_get_startup_time_us() APIs. Signed-off-by: Bjarki Arge Andreasen <[email protected]>
1 parent 6aeca71 commit 54d86e8

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

drivers/clock_control/clock_control_nrf2_hfxo.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,39 @@ static int init_hfxo(const struct device *dev)
271271
return 0;
272272
}
273273

274+
static int api_resolve(const struct device *dev,
275+
const struct nrf_clock_spec *req_spec,
276+
struct nrf_clock_spec *res_spec)
277+
{
278+
const struct dev_config_hfxo *dev_config = dev->config;
279+
280+
if (!is_clock_spec_valid(dev, req_spec)) {
281+
return -EINVAL;
282+
}
283+
284+
res_spec->frequency = dev_config->fixed_frequency;
285+
res_spec->accuracy = dev_config->fixed_accuracy;
286+
res_spec->precision = NRF_CLOCK_CONTROL_PRECISION_HIGH;
287+
return 0;
288+
}
289+
290+
static int api_get_startup_time(const struct device *dev,
291+
const struct nrf_clock_spec *spec,
292+
uint32_t *startup_time_us)
293+
{
294+
if (!is_clock_spec_valid(dev, spec)) {
295+
return -EINVAL;
296+
}
297+
298+
*startup_time_us = nrf_bicr_hfxo_startup_time_us_get(BICR);
299+
300+
if (*startup_time_us == NRF_BICR_HFXO_STARTUP_TIME_UNCONFIGURED) {
301+
return -EINVAL;
302+
}
303+
304+
return 0;
305+
}
306+
274307
static DEVICE_API(nrf_clock_control, drv_api_hfxo) = {
275308
.std_api = {
276309
.on = api_nosys_on_off,
@@ -280,6 +313,8 @@ static DEVICE_API(nrf_clock_control, drv_api_hfxo) = {
280313
.request = api_request_hfxo,
281314
.release = api_release_hfxo,
282315
.cancel_or_release = api_cancel_or_release_hfxo,
316+
.resolve = api_resolve,
317+
.get_startup_time = api_get_startup_time,
283318
};
284319

285320
static struct dev_data_hfxo data_hfxo;

0 commit comments

Comments
 (0)