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);
136void z_nrf_clock_control_lf_on(
enum nrf_lfclk_start_mode start_mode);
150void z_nrf_clock_bt_ctlr_hf_request(
void);
156void z_nrf_clock_bt_ctlr_hf_release(
void);
161#if defined(CONFIG_CLOCK_CONTROL_NRF2)
164#define NRF_CLOCK_CONTROL_FREQUENCY_MAX UINT32_MAX
167#define NRF_CLOCK_CONTROL_ACCURACY_MAX 1
169#define NRF_CLOCK_CONTROL_ACCURACY_PPM(ppm) (ppm)
172#define NRF_CLOCK_CONTROL_PRECISION_HIGH 1
174#define NRF_CLOCK_CONTROL_PRECISION_DEFAULT 0
176struct nrf_clock_spec {
182__subsystem
struct nrf_clock_control_driver_api {
185 int (*request)(
const struct device *dev,
186 const struct nrf_clock_spec *spec,
188 int (*release)(
const struct device *dev,
189 const struct nrf_clock_spec *spec);
190 int (*cancel_or_release)(
const struct device *dev,
191 const struct nrf_clock_spec *spec,
228int nrf_clock_control_request(
const struct device *dev,
229 const struct nrf_clock_spec *spec,
232 const struct nrf_clock_control_driver_api *api =
233 (
const struct nrf_clock_control_driver_api *)dev->
api;
235 return api->request(dev, spec, cli);
253int nrf_clock_control_release(
const struct device *dev,
254 const struct nrf_clock_spec *spec)
256 const struct nrf_clock_control_driver_api *api =
257 (
const struct nrf_clock_control_driver_api *)dev->
api;
259 return api->release(dev, spec);
285int nrf_clock_control_cancel_or_release(
const struct device *dev,
286 const struct nrf_clock_spec *spec,
289 const struct nrf_clock_control_driver_api *api =
290 (
const struct nrf_clock_control_driver_api *)dev->
api;
292 return api->cancel_or_release(dev, spec, cli);
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:412
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:418
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