Skip to content

Commit 0285cf4

Browse files
Hi-Im-Davidkartben
authored andcommitted
drivers: clock_control: update nrf2 lfosc_get_accuracy
Move lfosc_get_accuracy away from common library as not all devices need this function. Signed-off-by: David Jewsbury <david.jewsbury@nordicsemi.no>
1 parent bd5aefb commit 0285cf4

File tree

3 files changed

+34
-47
lines changed

3 files changed

+34
-47
lines changed

drivers/clock_control/clock_control_nrf2_common.c

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
#include "clock_control_nrf2_common.h"
77
#include <zephyr/drivers/clock_control/nrf_clock_control.h>
8-
#include <hal/nrf_bicr.h>
98

109
#include <zephyr/logging/log.h>
1110
LOG_MODULE_REGISTER(clock_control_nrf2, CONFIG_CLOCK_CONTROL_LOG_LEVEL);
@@ -20,8 +19,6 @@ LOG_MODULE_REGISTER(clock_control_nrf2, CONFIG_CLOCK_CONTROL_LOG_LEVEL);
2019
(idx * sizeof(array[0])) - \
2120
offsetof(type, array[0]))
2221

23-
#define BICR (NRF_BICR_Type *)DT_REG_ADDR(DT_NODELABEL(bicr))
24-
2522
/*
2623
* Definition of `struct clock_config_generic`.
2724
* Used to access `clock_config_*` structures in a common way.
@@ -92,40 +89,6 @@ static inline uint8_t get_index_of_highest_bit(uint32_t value)
9289
return value ? (uint8_t)(31 - __builtin_clz(value)) : 0;
9390
}
9491

95-
int lfosc_get_accuracy(uint16_t *accuracy)
96-
{
97-
switch (nrf_bicr_lfosc_accuracy_get(BICR)) {
98-
case NRF_BICR_LFOSC_ACCURACY_500PPM:
99-
*accuracy = 500U;
100-
break;
101-
case NRF_BICR_LFOSC_ACCURACY_250PPM:
102-
*accuracy = 250U;
103-
break;
104-
case NRF_BICR_LFOSC_ACCURACY_150PPM:
105-
*accuracy = 150U;
106-
break;
107-
case NRF_BICR_LFOSC_ACCURACY_100PPM:
108-
*accuracy = 100U;
109-
break;
110-
case NRF_BICR_LFOSC_ACCURACY_75PPM:
111-
*accuracy = 75U;
112-
break;
113-
case NRF_BICR_LFOSC_ACCURACY_50PPM:
114-
*accuracy = 50U;
115-
break;
116-
case NRF_BICR_LFOSC_ACCURACY_30PPM:
117-
*accuracy = 30U;
118-
break;
119-
case NRF_BICR_LFOSC_ACCURACY_20PPM:
120-
*accuracy = 20U;
121-
break;
122-
default:
123-
return -EINVAL;
124-
}
125-
126-
return 0;
127-
}
128-
12992
int clock_config_init(void *clk_cfg, uint8_t onoff_cnt, k_work_handler_t update_work_handler)
13093
{
13194
struct clock_config_generic *cfg = clk_cfg;

drivers/clock_control/clock_control_nrf2_common.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,6 @@ struct clock_onoff {
3636
struct clock_onoff onoff[_onoff_cnt]; \
3737
}
3838

39-
/**
40-
* @brief Obtain LFOSC accuracy in ppm.
41-
*
42-
* @param[out] accuracy Accuracy in ppm.
43-
*
44-
* @retval 0 On success
45-
* @retval -EINVAL If accuracy is not configured.
46-
*/
47-
int lfosc_get_accuracy(uint16_t *accuracy);
48-
4939
/**
5040
* @brief Initializes a clock configuration structure.
5141
*

drivers/clock_control/clock_control_nrf_lfclk.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,40 @@ struct lfclk_dev_config {
7171
uint32_t fixed_frequency;
7272
};
7373

74+
static int lfosc_get_accuracy(uint16_t *accuracy)
75+
{
76+
switch (nrf_bicr_lfosc_accuracy_get(BICR)) {
77+
case NRF_BICR_LFOSC_ACCURACY_500PPM:
78+
*accuracy = 500U;
79+
break;
80+
case NRF_BICR_LFOSC_ACCURACY_250PPM:
81+
*accuracy = 250U;
82+
break;
83+
case NRF_BICR_LFOSC_ACCURACY_150PPM:
84+
*accuracy = 150U;
85+
break;
86+
case NRF_BICR_LFOSC_ACCURACY_100PPM:
87+
*accuracy = 100U;
88+
break;
89+
case NRF_BICR_LFOSC_ACCURACY_75PPM:
90+
*accuracy = 75U;
91+
break;
92+
case NRF_BICR_LFOSC_ACCURACY_50PPM:
93+
*accuracy = 50U;
94+
break;
95+
case NRF_BICR_LFOSC_ACCURACY_30PPM:
96+
*accuracy = 30U;
97+
break;
98+
case NRF_BICR_LFOSC_ACCURACY_20PPM:
99+
*accuracy = 20U;
100+
break;
101+
default:
102+
return -EINVAL;
103+
}
104+
105+
return 0;
106+
}
107+
74108
static void clock_evt_handler(nrfs_clock_evt_t const *p_evt, void *context)
75109
{
76110
struct lfclk_dev_data *dev_data = context;

0 commit comments

Comments
 (0)