7#ifndef ZEPHYR_INCLUDE_DRIVERS_CLOCK_CONTROL_NRF_CLOCK_CONTROL_H_
8#define ZEPHYR_INCLUDE_DRIVERS_CLOCK_CONTROL_NRF_CLOCK_CONTROL_H_
12#include <hal/nrf_clock.h>
21#if defined(CONFIG_CLOCK_CONTROL_NRF)
27enum clock_control_nrf_type {
28 CLOCK_CONTROL_NRF_TYPE_HFCLK,
29 CLOCK_CONTROL_NRF_TYPE_LFCLK,
30#if NRF_CLOCK_HAS_HFCLK192M
31 CLOCK_CONTROL_NRF_TYPE_HFCLK192M,
33#if NRF_CLOCK_HAS_HFCLKAUDIO
34 CLOCK_CONTROL_NRF_TYPE_HFCLKAUDIO,
36 CLOCK_CONTROL_NRF_TYPE_COUNT
42#define CLOCK_CONTROL_NRF_SUBSYS_HF \
43 ((clock_control_subsys_t)CLOCK_CONTROL_NRF_TYPE_HFCLK)
44#define CLOCK_CONTROL_NRF_SUBSYS_LF \
45 ((clock_control_subsys_t)CLOCK_CONTROL_NRF_TYPE_LFCLK)
46#define CLOCK_CONTROL_NRF_SUBSYS_HF192M \
47 ((clock_control_subsys_t)CLOCK_CONTROL_NRF_TYPE_HFCLK192M)
48#define CLOCK_CONTROL_NRF_SUBSYS_HFAUDIO \
49 ((clock_control_subsys_t)CLOCK_CONTROL_NRF_TYPE_HFCLKAUDIO)
52enum nrf_lfclk_start_mode {
53 CLOCK_CONTROL_NRF_LF_START_NOWAIT,
54 CLOCK_CONTROL_NRF_LF_START_AVAILABLE,
55 CLOCK_CONTROL_NRF_LF_START_STABLE,
59#ifdef CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC
60#define CLOCK_CONTROL_NRF_K32SRC NRF_CLOCK_LFCLK_RC
62#ifdef CONFIG_CLOCK_CONTROL_NRF_K32SRC_XTAL
63#define CLOCK_CONTROL_NRF_K32SRC NRF_CLOCK_LFCLK_XTAL
65#ifdef CONFIG_CLOCK_CONTROL_NRF_K32SRC_SYNTH
66#define CLOCK_CONTROL_NRF_K32SRC NRF_CLOCK_LFCLK_SYNTH
68#ifdef CONFIG_CLOCK_CONTROL_NRF_K32SRC_EXT_LOW_SWING
69#define CLOCK_CONTROL_NRF_K32SRC NRF_CLOCK_LFCLK_XTAL_LOW_SWING
71#ifdef CONFIG_CLOCK_CONTROL_NRF_K32SRC_EXT_FULL_SWING
72#define CLOCK_CONTROL_NRF_K32SRC NRF_CLOCK_LFCLK_XTAL_FULL_SWING
76#ifdef CONFIG_CLOCK_CONTROL_NRF_K32SRC_500PPM
77#define CLOCK_CONTROL_NRF_K32SRC_ACCURACY 0
79#ifdef CONFIG_CLOCK_CONTROL_NRF_K32SRC_250PPM
80#define CLOCK_CONTROL_NRF_K32SRC_ACCURACY 1
82#ifdef CONFIG_CLOCK_CONTROL_NRF_K32SRC_150PPM
83#define CLOCK_CONTROL_NRF_K32SRC_ACCURACY 2
85#ifdef CONFIG_CLOCK_CONTROL_NRF_K32SRC_100PPM
86#define CLOCK_CONTROL_NRF_K32SRC_ACCURACY 3
88#ifdef CONFIG_CLOCK_CONTROL_NRF_K32SRC_75PPM
89#define CLOCK_CONTROL_NRF_K32SRC_ACCURACY 4
91#ifdef CONFIG_CLOCK_CONTROL_NRF_K32SRC_50PPM
92#define CLOCK_CONTROL_NRF_K32SRC_ACCURACY 5
94#ifdef CONFIG_CLOCK_CONTROL_NRF_K32SRC_30PPM
95#define CLOCK_CONTROL_NRF_K32SRC_ACCURACY 6
97#ifdef CONFIG_CLOCK_CONTROL_NRF_K32SRC_20PPM
98#define CLOCK_CONTROL_NRF_K32SRC_ACCURACY 7
102void z_nrf_clock_calibration_force_start(
void);
110int z_nrf_clock_calibration_count(
void);
118int z_nrf_clock_calibration_skips_count(
void);
125bool z_nrf_clock_calibration_is_in_progress(
void);
143void z_nrf_clock_control_lf_on(
enum nrf_lfclk_start_mode start_mode);
157void z_nrf_clock_bt_ctlr_hf_request(
void);
163void z_nrf_clock_bt_ctlr_hf_release(
void);
168#if defined(CONFIG_CLOCK_CONTROL_NRF2)
171#define NRF_CLOCK_CONTROL_FREQUENCY_MAX UINT32_MAX
174#define NRF_CLOCK_CONTROL_ACCURACY_MAX 1
176#define NRF_CLOCK_CONTROL_ACCURACY_PPM(ppm) (ppm)
179#define NRF_CLOCK_CONTROL_PRECISION_HIGH 1
181#define NRF_CLOCK_CONTROL_PRECISION_DEFAULT 0
183struct nrf_clock_spec {
189__subsystem
struct nrf_clock_control_driver_api {
192 int (*request)(
const struct device *dev,
193 const struct nrf_clock_spec *spec,
195 int (*release)(
const struct device *dev,
196 const struct nrf_clock_spec *spec);
197 int (*cancel_or_release)(
const struct device *dev,
198 const struct nrf_clock_spec *spec,
235int nrf_clock_control_request(
const struct device *dev,
236 const struct nrf_clock_spec *spec,
239 const struct nrf_clock_control_driver_api *api =
240 (
const struct nrf_clock_control_driver_api *)dev->
api;
242 return api->request(dev, spec, cli);
259int nrf_clock_control_request_sync(
const struct device *dev,
260 const struct nrf_clock_spec *spec,
278int nrf_clock_control_release(
const struct device *dev,
279 const struct nrf_clock_spec *spec)
281 const struct nrf_clock_control_driver_api *api =
282 (
const struct nrf_clock_control_driver_api *)dev->
api;
284 return api->release(dev, spec);
310int nrf_clock_control_cancel_or_release(
const struct device *dev,
311 const struct nrf_clock_spec *spec,
314 const struct nrf_clock_control_driver_api *api =
315 (
const struct nrf_clock_control_driver_api *)dev->
api;
317 return api->cancel_or_release(dev, spec, cli);
331void nrf_clock_control_hfxo_request(
void);
342void nrf_clock_control_hfxo_release(
void);
Public Clock Control APIs.
void * clock_control_subsys_t
clock_control_subsys_t is a type to identify a clock controller sub-system.
Definition clock_control.h:58
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Definition clock_control.h:102
Runtime device structure (in ROM) per driver instance.
Definition device.h:411
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:417
Kernel timeout type.
Definition sys_clock.h:65
State associated with a client of an on-off service.
Definition onoff.h:274
State associated with an on-off manager.
Definition onoff.h:154