Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
adi_max32_clock_control.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023-2024 Analog Devices, Inc.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_DRIVERS_CLOCK_CONTROL_ADI_MAX32_CLOCK_CONTROL_H_
8#define ZEPHYR_INCLUDE_DRIVERS_CLOCK_CONTROL_ADI_MAX32_CLOCK_CONTROL_H_
9
11
13
14#include <wrap_max32_sys.h>
15
21
22 /* Peripheral clock source:
23 * Can be (see: adi_max32_clock.h file):
24 *
25 * ADI_MAX32_PRPH_CLK_SRC_PCLK
26 * ADI_MAX32_PRPH_CLK_SRC_EXTCLK
27 * ADI_MAX32_PRPH_CLK_SRC_IBRO
28 * ADI_MAX32_PRPH_CLK_SRC_ERFO
29 * ADI_MAX32_PRPH_CLK_SRC_ERTCO
30 * ADI_MAX32_PRPH_CLK_SRC_INRO
31 * ADI_MAX32_PRPH_CLK_SRC_ISO
32 * ADI_MAX32_PRPH_CLK_SRC_IBRO_DIV8
33 */
35};
36
38#define ADI_MAX32_SYSCLK_PRESCALER DT_PROP_OR(DT_NODELABEL(gcr), sysclk_prescaler, 1)
39
40#define ADI_MAX32_CLK_IPO_FREQ DT_PROP(DT_NODELABEL(clk_ipo), clock_frequency)
41#define ADI_MAX32_CLK_ERFO_FREQ DT_PROP(DT_NODELABEL(clk_erfo), clock_frequency)
42#define ADI_MAX32_CLK_IBRO_FREQ DT_PROP(DT_NODELABEL(clk_ibro), clock_frequency)
43#define ADI_MAX32_CLK_ISO_FREQ DT_PROP_OR(DT_NODELABEL(clk_iso), clock_frequency, 0)
44#define ADI_MAX32_CLK_INRO_FREQ DT_PROP(DT_NODELABEL(clk_inro), clock_frequency)
45#define ADI_MAX32_CLK_ERTCO_FREQ DT_PROP(DT_NODELABEL(clk_ertco), clock_frequency)
46/* External clock may not be defined so _OR is used */
47#define ADI_MAX32_CLK_EXTCLK_FREQ DT_PROP_OR(DT_NODELABEL(clk_extclk), clock_frequency, 0)
48
49#define DT_GCR_CLOCKS_CTRL DT_CLOCKS_CTLR(DT_NODELABEL(gcr))
50
51#if DT_SAME_NODE(DT_GCR_CLOCKS_CTRL, DT_NODELABEL(clk_ipo))
52#define ADI_MAX32_SYSCLK_SRC ADI_MAX32_CLK_IPO
53#define ADI_MAX32_SYSCLK_FREQ (ADI_MAX32_CLK_IPO_FREQ / ADI_MAX32_SYSCLK_PRESCALER)
54#endif
55#if DT_SAME_NODE(DT_GCR_CLOCKS_CTRL, DT_NODELABEL(clk_erfo))
56#define ADI_MAX32_SYSCLK_SRC ADI_MAX32_CLK_ERFO
57#define ADI_MAX32_SYSCLK_FREQ (ADI_MAX32_CLK_ERFO_FREQ / ADI_MAX32_SYSCLK_PRESCALER)
58#endif
59#if DT_SAME_NODE(DT_GCR_CLOCKS_CTRL, DT_NODELABEL(clk_ibro))
60#define ADI_MAX32_SYSCLK_SRC ADI_MAX32_CLK_IBRO
61#define ADI_MAX32_SYSCLK_FREQ (ADI_MAX32_CLK_IBRO_FREQ / ADI_MAX32_SYSCLK_PRESCALER)
62#endif
63#if DT_SAME_NODE(DT_GCR_CLOCKS_CTRL, DT_NODELABEL(clk_iso))
64#define ADI_MAX32_SYSCLK_SRC ADI_MAX32_CLK_ISO
65#define ADI_MAX32_SYSCLK_FREQ (ADI_MAX32_CLK_ISO_FREQ / ADI_MAX32_SYSCLK_PRESCALER)
66#endif
67#if DT_SAME_NODE(DT_GCR_CLOCKS_CTRL, DT_NODELABEL(clk_inro))
68#define ADI_MAX32_SYSCLK_SRC ADI_MAX32_CLK_INRO
69#define ADI_MAX32_SYSCLK_FREQ (ADI_MAX32_CLK_INRO_FREQ / ADI_MAX32_SYSCLK_PRESCALER)
70#endif
71#if DT_SAME_NODE(DT_GCR_CLOCKS_CTRL, DT_NODELABEL(clk_ertco))
72#define ADI_MAX32_SYSCLK_SRC ADI_MAX32_CLK_ERTCO
73#define ADI_MAX32_SYSCLK_FREQ (ADI_MAX32_CLK_ERTCO_FREQ / ADI_MAX32_SYSCLK_PRESCALER)
74#endif
75#if DT_SAME_NODE(DT_GCR_CLOCKS_CTRL, DT_NODELABEL(clk_extclk))
76#define ADI_MAX32_SYSCLK_SRC ADI_MAX32_CLK_EXTCLK
77#define ADI_MAX32_SYSCLK_FREQ (ADI_MAX32_CLK_EXTCLK_FREQ / ADI_MAX32_SYSCLK_PRESCALER)
78#endif
79
80#ifndef ADI_MAX32_SYSCLK_SRC
81#define ADI_MAX32_SYSCLK_SRC ADI_MAX32_CLK_IPO
82#define ADI_MAX32_SYSCLK_FREQ (ADI_MAX32_CLK_IPO_FREQ / ADI_MAX32_SYSCLK_PRESCALER)
83#endif
84
85#define ADI_MAX32_PCLK_FREQ (ADI_MAX32_SYSCLK_FREQ / 2)
86
87#define ADI_MAX32_GET_PRPH_CLK_FREQ(clk_src) \
88 ((clk_src) == ADI_MAX32_PRPH_CLK_SRC_PCLK ? ADI_MAX32_PCLK_FREQ \
89 : (clk_src) == ADI_MAX32_PRPH_CLK_SRC_IBRO ? ADI_MAX32_CLK_IBRO_FREQ \
90 : (clk_src) == ADI_MAX32_PRPH_CLK_SRC_ERFO ? ADI_MAX32_CLK_ERFO_FREQ \
91 : (clk_src) == ADI_MAX32_PRPH_CLK_SRC_ERTCO ? ADI_MAX32_CLK_ERTCO_FREQ \
92 : (clk_src) == ADI_MAX32_PRPH_CLK_SRC_INRO ? ADI_MAX32_CLK_INRO_FREQ \
93 : (clk_src) == ADI_MAX32_PRPH_CLK_SRC_ISO ? ADI_MAX32_CLK_ISO_FREQ \
94 : (clk_src) == ADI_MAX32_PRPH_CLK_SRC_IBRO_DIV8 ? (ADI_MAX32_CLK_IBRO_FREQ / 8) \
95 : (clk_src) == ADI_MAX32_PRPH_CLK_SRC_EXTCLK ? ADI_MAX32_CLK_EXTCLK_FREQ \
96 : 0)
97
98#endif /* ZEPHYR_INCLUDE_DRIVERS_CLOCK_CONTROL_ADI_MAX32_CLOCK_CONTROL_H_ */
Public Clock Control APIs.
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
Driver structure definition.
Definition: adi_max32_clock_control.h:18
uint32_t clk_src
Definition: adi_max32_clock_control.h:34
uint32_t bit
Definition: adi_max32_clock_control.h:20
uint32_t bus
Definition: adi_max32_clock_control.h:19