Skip to content

Commit 921f25c

Browse files
Hi-Im-Daviderdemsimsek
authored andcommitted
[nrf fromtree] drivers: clock_control: Add macros for AUXPLL output frequencies
These represent the outputted frequencies of the AUXPLL of different settings set in the device tree set using dt-bindings in nrf-auxpll.h. This is added to remove the need for 'magic numbers' in drivers and tests. Signed-off-by: David Jewsbury <[email protected]> (cherry picked from commit 0770210)
1 parent c6dbf15 commit 921f25c

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

include/zephyr/drivers/clock_control/nrf_clock_control.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,29 @@ uint32_t z_nrf_clock_bt_ctlr_hf_get_startup_time_us(void);
188188
/* Specifies that default precision of the clock is sufficient. */
189189
#define NRF_CLOCK_CONTROL_PRECISION_DEFAULT 0
190190

191+
/* AUXPLL devicetree takes in raw register values, these are the actual frequencies outputted */
192+
#define CLOCK_CONTROL_NRF_AUXPLL_FREQ_OUT_MIN_HZ 80000000
193+
#define CLOCK_CONTROL_NRF_AUXPLL_FREQ_OUT_AUDIO_44K1_HZ 11289591
194+
#define CLOCK_CONTROL_NRF_AUXPLL_FREQ_OUT_USB24M_HZ 24000000
195+
#define CLOCK_CONTROL_NRF_AUXPLL_FREQ_OUT_AUDIO_48K_HZ 12287963
196+
197+
/* Internal helper macro to map DT property value to output frequency */
198+
#define _CLOCK_CONTROL_NRF_AUXPLL_MAP_FREQ(freq_val) \
199+
((freq_val) == NRF_AUXPLL_FREQ_DIV_MIN ? \
200+
CLOCK_CONTROL_NRF_AUXPLL_FREQ_OUT_MIN_HZ : \
201+
(freq_val) == NRF_AUXPLL_FREQ_DIV_AUDIO_44K1 ? \
202+
CLOCK_CONTROL_NRF_AUXPLL_FREQ_OUT_AUDIO_44K1_HZ : \
203+
(freq_val) == NRF_AUXPLL_FREQ_DIV_USB24M ? \
204+
CLOCK_CONTROL_NRF_AUXPLL_FREQ_OUT_USB24M_HZ : \
205+
(freq_val) == NRF_AUXPLL_FREQ_DIV_AUDIO_48K ? \
206+
CLOCK_CONTROL_NRF_AUXPLL_FREQ_OUT_AUDIO_48K_HZ : 0)
207+
208+
/* Public macro to get output frequency of AUXPLL */
209+
#define CLOCK_CONTROL_NRF_AUXPLL_GET_FREQ(node) \
210+
COND_CODE_1(DT_NODE_HAS_PROP(node, nordic_frequency), \
211+
(_CLOCK_CONTROL_NRF_AUXPLL_MAP_FREQ(DT_PROP(node, nordic_frequency))), \
212+
(0))
213+
191214
struct nrf_clock_spec {
192215
uint32_t frequency;
193216
uint16_t accuracy : 15;

0 commit comments

Comments
 (0)