aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios-contrib/ext/mcux-sdk/devices/MIMX8MM6/drivers/fsl_clock.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios-contrib/ext/mcux-sdk/devices/MIMX8MM6/drivers/fsl_clock.h')
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/devices/MIMX8MM6/drivers/fsl_clock.h1260
1 files changed, 1260 insertions, 0 deletions
diff --git a/lib/chibios-contrib/ext/mcux-sdk/devices/MIMX8MM6/drivers/fsl_clock.h b/lib/chibios-contrib/ext/mcux-sdk/devices/MIMX8MM6/drivers/fsl_clock.h
new file mode 100644
index 000000000..e7b6d5642
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/devices/MIMX8MM6/drivers/fsl_clock.h
@@ -0,0 +1,1260 @@
1/*
2 * Copyright 2018 - 2020 NXP
3 * All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
8#ifndef _FSL_CLOCK_H_
9#define _FSL_CLOCK_H_
10
11#include "fsl_device_registers.h"
12#include "fsl_common.h"
13#include <stdint.h>
14#include <stdbool.h>
15#include <stddef.h>
16#include <assert.h>
17
18/*!
19 * @addtogroup clock
20 * @{
21 */
22
23/*******************************************************************************
24 * Definitions
25 ******************************************************************************/
26
27/*! @name Driver version */
28/*@{*/
29/*! @brief CLOCK driver version 2.2.2. */
30#define FSL_CLOCK_DRIVER_VERSION (MAKE_VERSION(2, 2, 2))
31/*@}*/
32
33/* Definition for delay API in clock driver, users can redefine it to the real application. */
34#ifndef SDK_DEVICE_MAXIMUM_CPU_CLOCK_FREQUENCY
35#define SDK_DEVICE_MAXIMUM_CPU_CLOCK_FREQUENCY (400000000UL)
36#endif
37
38/*!
39 * @brief XTAL 24M clock frequency.
40 */
41#define OSC24M_CLK_FREQ 24000000U
42/*!
43 * @brief pad clock frequency.
44 */
45#define CLKPAD_FREQ 0U
46
47/*! @brief Clock ip name array for ECSPI. */
48#define ECSPI_CLOCKS \
49 { \
50 kCLOCK_IpInvalid, kCLOCK_Ecspi1, kCLOCK_Ecspi2, kCLOCK_Ecspi3, \
51 }
52
53/*! @brief Clock ip name array for GPIO. */
54#define GPIO_CLOCKS \
55 { \
56 kCLOCK_IpInvalid, kCLOCK_Gpio1, kCLOCK_Gpio2, kCLOCK_Gpio3, kCLOCK_Gpio4, kCLOCK_Gpio5, \
57 }
58
59/*! @brief Clock ip name array for GPT. */
60#define GPT_CLOCKS \
61 { \
62 kCLOCK_IpInvalid, kCLOCK_Gpt1, kCLOCK_Gpt2, kCLOCK_Gpt3, kCLOCK_Gpt4, kCLOCK_Gpt5, kCLOCK_Gpt6, \
63 }
64
65/*! @brief Clock ip name array for I2C. */
66#define I2C_CLOCKS \
67 { \
68 kCLOCK_IpInvalid, kCLOCK_I2c1, kCLOCK_I2c2, kCLOCK_I2c3, kCLOCK_I2c4, \
69 }
70
71/*! @brief Clock ip name array for IOMUX. */
72#define IOMUX_CLOCKS \
73 { \
74 kCLOCK_Iomux, \
75 }
76
77/*! @brief Clock ip name array for IPMUX. */
78#define IPMUX_CLOCKS \
79 { \
80 kCLOCK_Ipmux1, kCLOCK_Ipmux2, kCLOCK_Ipmux3, kCLOCK_Ipmux4, \
81 }
82
83/*! @brief Clock ip name array for PWM. */
84#define PWM_CLOCKS \
85 { \
86 kCLOCK_IpInvalid, kCLOCK_Pwm1, kCLOCK_Pwm2, kCLOCK_Pwm3, kCLOCK_Pwm4, \
87 }
88
89/*! @brief Clock ip name array for RDC. */
90#define RDC_CLOCKS \
91 { \
92 kCLOCK_Rdc, \
93 }
94
95/*! @brief Clock ip name array for SAI. */
96#define SAI_CLOCKS \
97 { \
98 kCLOCK_IpInvalid, kCLOCK_Sai1, kCLOCK_Sai2, kCLOCK_Sai3, kCLOCK_Sai4, kCLOCK_Sai5, kCLOCK_Sai6, \
99 }
100
101/*! @brief Clock ip name array for RDC SEMA42. */
102#define RDC_SEMA42_CLOCKS \
103 { \
104 kCLOCK_IpInvalid, kCLOCK_Sema42_1, kCLOCK_Sema42_2 \
105 }
106
107/*! @brief Clock ip name array for UART. */
108#define UART_CLOCKS \
109 { \
110 kCLOCK_IpInvalid, kCLOCK_Uart1, kCLOCK_Uart2, kCLOCK_Uart3, kCLOCK_Uart4, \
111 }
112
113/*! @brief Clock ip name array for USDHC. */
114#define USDHC_CLOCKS \
115 { \
116 kCLOCK_IpInvalid, kCLOCK_Usdhc1, kCLOCK_Usdhc2, kCLOCK_Usdhc3 \
117 }
118
119/*! @brief Clock ip name array for WDOG. */
120#define WDOG_CLOCKS \
121 { \
122 kCLOCK_IpInvalid, kCLOCK_Wdog1, kCLOCK_Wdog2, kCLOCK_Wdog3 \
123 }
124
125/*! @brief Clock ip name array for TEMPSENSOR. */
126#define TMU_CLOCKS \
127 { \
128 kCLOCK_TempSensor, \
129 }
130
131/*! @brief Clock ip name array for SDMA. */
132#define SDMA_CLOCKS \
133 { \
134 kCLOCK_Sdma1, kCLOCK_Sdma2, kCLOCK_Sdma3 \
135 }
136
137/*! @brief Clock ip name array for MU. */
138#define MU_CLOCKS \
139 { \
140 kCLOCK_Mu \
141 }
142
143/*! @brief Clock ip name array for QSPI. */
144#define QSPI_CLOCKS \
145 { \
146 kCLOCK_Qspi \
147 }
148
149/*! @brief Clock ip name array for PDM. */
150#define PDM_CLOCKS \
151 { \
152 kCLOCK_Pdm \
153 }
154
155/*!
156 * @brief CCM reg macros to extract corresponding registers bit field.
157 */
158#define CCM_BIT_FIELD_EXTRACTION(val, mask, shift) (((val) & (mask)) >> (shift))
159
160/*!
161 * @brief CCM reg macros to map corresponding registers.
162 */
163#define CCM_REG_OFF(root, off) (*((volatile uint32_t *)((uint32_t)(root) + (off))))
164#define CCM_REG(root) CCM_REG_OFF(root, 0U)
165#define CCM_REG_SET(root) CCM_REG_OFF(root, 4U)
166#define CCM_REG_CLR(root) CCM_REG_OFF(root, 8U)
167
168/*!
169 * @brief CCM Analog registers offset.
170 */
171#define AUDIO_PLL1_GEN_CTRL_OFFSET 0x00
172#define AUDIO_PLL2_GEN_CTRL_OFFSET 0x14
173#define VIDEO_PLL1_GEN_CTRL_OFFSET 0x28
174#define GPU_PLL_GEN_CTRL_OFFSET 0x64
175#define VPU_PLL_GEN_CTRL_OFFSET 0x74
176#define ARM_PLL_GEN_CTRL_OFFSET 0x84
177#define SYS_PLL1_GEN_CTRL_OFFSET 0x94
178#define SYS_PLL2_GEN_CTRL_OFFSET 0x104
179#define SYS_PLL3_GEN_CTRL_OFFSET 0x114
180#define DRAM_PLL_GEN_CTRL_OFFSET 0x50
181
182/*!
183 * @brief CCM ANALOG tuple macros to map corresponding registers and bit fields.
184 */
185#define CCM_ANALOG_TUPLE(reg, shift) ((((reg)&0xFFFFU) << 16U) | ((shift)))
186#define CCM_ANALOG_TUPLE_SHIFT(tuple) (((uint32_t)(tuple)) & 0x1FU)
187#define CCM_ANALOG_TUPLE_REG_OFF(base, tuple, off) \
188 (*((volatile uint32_t *)((uint32_t)(base) + (((uint32_t)(tuple) >> 16U) & 0xFFFFU) + (off))))
189#define CCM_ANALOG_TUPLE_REG(base, tuple) CCM_ANALOG_TUPLE_REG_OFF(base, tuple, 0U)
190
191/*!
192 * @brief CCM CCGR and root tuple
193 */
194#define CCM_TUPLE(ccgr, root) ((ccgr) << 16U | (root))
195#define CCM_TUPLE_CCGR(tuple) ((uint32_t)(&(CCM)->CCGR[(uint32_t)(tuple) >> 16U].CCGR))
196#define CCM_TUPLE_ROOT(tuple) ((uint32_t)(&(CCM)->ROOT[(uint32_t)(tuple)&0xFFFFU].TARGET_ROOT))
197
198/*! @brief Clock name used to get clock frequency. */
199typedef enum _clock_name
200{
201 kCLOCK_CoreM4Clk, /*!< ARM M4 Core clock */
202
203 kCLOCK_AxiClk, /*!< Main AXI bus clock. */
204 kCLOCK_AhbClk, /*!< AHB bus clock. */
205 kCLOCK_IpgClk, /*!< IPG bus clock. */
206
207 /* -------------------------------- Other clock --------------------------*/
208} clock_name_t;
209
210#define kCLOCK_CoreSysClk kCLOCK_CoreM4Clk /*!< For compatible with other platforms without CCM. */
211#define CLOCK_GetCoreSysClkFreq CLOCK_GetCoreM4Freq /*!< For compatible with other platforms without CCM. */
212
213/*! @brief CCM CCGR gate control. */
214typedef enum _clock_ip_name
215{
216 kCLOCK_IpInvalid = -1,
217
218 kCLOCK_Debug = CCM_TUPLE(4U, 32U), /*!< DEBUG Clock Gate.*/
219
220 kCLOCK_Dram = CCM_TUPLE(5U, 64U), /*!< DRAM Clock Gate.*/
221
222 kCLOCK_Ecspi1 = CCM_TUPLE(7U, 101U), /*!< ECSPI1 Clock Gate.*/
223 kCLOCK_Ecspi2 = CCM_TUPLE(8U, 102U), /*!< ECSPI2 Clock Gate.*/
224 kCLOCK_Ecspi3 = CCM_TUPLE(9U, 131U), /*!< ECSPI3 Clock Gate.*/
225
226 kCLOCK_Gpio1 = CCM_TUPLE(11U, 33U), /*!< GPIO1 Clock Gate.*/
227 kCLOCK_Gpio2 = CCM_TUPLE(12U, 33U), /*!< GPIO2 Clock Gate.*/
228 kCLOCK_Gpio3 = CCM_TUPLE(13U, 33U), /*!< GPIO3 Clock Gate.*/
229 kCLOCK_Gpio4 = CCM_TUPLE(14U, 33U), /*!< GPIO4 Clock Gate.*/
230 kCLOCK_Gpio5 = CCM_TUPLE(15U, 33U), /*!< GPIO5 Clock Gate.*/
231
232 kCLOCK_Gpt1 = CCM_TUPLE(16U, 107U), /*!< GPT1 Clock Gate.*/
233 kCLOCK_Gpt2 = CCM_TUPLE(17U, 108U), /*!< GPT2 Clock Gate.*/
234 kCLOCK_Gpt3 = CCM_TUPLE(18U, 109U), /*!< GPT3 Clock Gate.*/
235 kCLOCK_Gpt4 = CCM_TUPLE(19U, 110U), /*!< GPT4 Clock Gate.*/
236 kCLOCK_Gpt5 = CCM_TUPLE(20U, 111U), /*!< GPT5 Clock Gate.*/
237 kCLOCK_Gpt6 = CCM_TUPLE(21U, 112U), /*!< GPT6 Clock Gate.*/
238
239 kCLOCK_I2c1 = CCM_TUPLE(23U, 90U), /*!< I2C1 Clock Gate.*/
240 kCLOCK_I2c2 = CCM_TUPLE(24U, 91U), /*!< I2C2 Clock Gate.*/
241 kCLOCK_I2c3 = CCM_TUPLE(25U, 92U), /*!< I2C3 Clock Gate.*/
242 kCLOCK_I2c4 = CCM_TUPLE(26U, 93U), /*!< I2C4 Clock Gate.*/
243
244 kCLOCK_Iomux = CCM_TUPLE(27U, 33U), /*!< IOMUX Clock Gate.*/
245 kCLOCK_Ipmux1 = CCM_TUPLE(28U, 33U), /*!< IPMUX1 Clock Gate.*/
246 kCLOCK_Ipmux2 = CCM_TUPLE(29U, 33U), /*!< IPMUX2 Clock Gate.*/
247 kCLOCK_Ipmux3 = CCM_TUPLE(30U, 33U), /*!< IPMUX3 Clock Gate.*/
248 kCLOCK_Ipmux4 = CCM_TUPLE(31U, 33U), /*!< IPMUX4 Clock Gate.*/
249
250 kCLOCK_Mu = CCM_TUPLE(33U, 33U), /*!< MU Clock Gate.*/
251
252 kCLOCK_Ocram = CCM_TUPLE(35U, 16U), /*!< OCRAM Clock Gate.*/
253 kCLOCK_OcramS = CCM_TUPLE(36U, 32U), /*!< OCRAM S Clock Gate.*/
254
255 kCLOCK_Pwm1 = CCM_TUPLE(40U, 103U), /*!< PWM1 Clock Gate.*/
256 kCLOCK_Pwm2 = CCM_TUPLE(41U, 104U), /*!< PWM2 Clock Gate.*/
257 kCLOCK_Pwm3 = CCM_TUPLE(42U, 105U), /*!< PWM3 Clock Gate.*/
258 kCLOCK_Pwm4 = CCM_TUPLE(43U, 106U), /*!< PWM4 Clock Gate.*/
259
260 kCLOCK_Qspi = CCM_TUPLE(47U, 87U), /*!< QSPI Clock Gate.*/
261
262 kCLOCK_Rdc = CCM_TUPLE(49U, 33U), /*!< RDC Clock Gate.*/
263
264 kCLOCK_Sai1 = CCM_TUPLE(51U, 75U), /*!< SAI1 Clock Gate.*/
265 kCLOCK_Sai2 = CCM_TUPLE(52U, 76U), /*!< SAI2 Clock Gate.*/
266 kCLOCK_Sai3 = CCM_TUPLE(53U, 77U), /*!< SAI3 Clock Gate.*/
267 kCLOCK_Sai4 = CCM_TUPLE(54U, 78U), /*!< SAI4 Clock Gate.*/
268 kCLOCK_Sai5 = CCM_TUPLE(55U, 79U), /*!< SAI5 Clock Gate.*/
269 kCLOCK_Sai6 = CCM_TUPLE(56U, 80U), /*!< SAI6 Clock Gate.*/
270
271 kCLOCK_Sdma1 = CCM_TUPLE(58U, 33U), /*!< SDMA1 Clock Gate.*/
272 kCLOCK_Sdma2 = CCM_TUPLE(59U, 35U), /*!< SDMA2 Clock Gate.*/
273
274 kCLOCK_Sec_Debug = CCM_TUPLE(60U, 33U), /*!< SEC_DEBUG Clock Gate.*/
275
276 kCLOCK_Sema42_1 = CCM_TUPLE(61U, 33U), /*!< RDC SEMA42 Clock Gate.*/
277 kCLOCK_Sema42_2 = CCM_TUPLE(62U, 33U), /*!< RDC SEMA42 Clock Gate.*/
278
279 kCLOCK_Sim_display = CCM_TUPLE(63U, 16U), /*!< SIM_Display Clock Gate.*/
280 kCLOCK_Sim_m = CCM_TUPLE(65U, 32U), /*!< SIM_M Clock Gate.*/
281 kCLOCK_Sim_main = CCM_TUPLE(66U, 16U), /*!< SIM_MAIN Clock Gate.*/
282 kCLOCK_Sim_s = CCM_TUPLE(67U, 32U), /*!< SIM_S Clock Gate.*/
283 kCLOCK_Sim_wakeup = CCM_TUPLE(68U, 32U), /*!< SIM_WAKEUP Clock Gate.*/
284
285 kCLOCK_Uart1 = CCM_TUPLE(73U, 94U), /*!< UART1 Clock Gate.*/
286 kCLOCK_Uart2 = CCM_TUPLE(74U, 95U), /*!< UART2 Clock Gate.*/
287 kCLOCK_Uart3 = CCM_TUPLE(75U, 96U), /*!< UART3 Clock Gate.*/
288 kCLOCK_Uart4 = CCM_TUPLE(76U, 97U), /*!< UART4 Clock Gate.*/
289
290 kCLOCK_Usdhc1 = CCM_TUPLE(81U, 88U), /*!< USDHC1 Clock Gate.*/
291 kCLOCK_Usdhc2 = CCM_TUPLE(82U, 89U), /*!< USDHC2 Clock Gate.*/
292 kCLOCK_Wdog1 = CCM_TUPLE(83U, 114U), /*!< WDOG1 Clock Gate.*/
293 kCLOCK_Wdog2 = CCM_TUPLE(84U, 114U), /*!< WDOG2 Clock Gate.*/
294 kCLOCK_Wdog3 = CCM_TUPLE(85U, 114U), /*!< WDOG3 Clock Gate.*/
295
296 kCLOCK_Pdm = CCM_TUPLE(91U, 132U), /*!< PDM Clock Gate.*/
297 kCLOCK_Usdhc3 = CCM_TUPLE(94U, 121U), /*!< USDHC3 Clock Gate.*/
298 kCLOCK_Sdma3 = CCM_TUPLE(95U, 35U), /*!< SDMA3 Clock Gate.*/
299
300 kCLOCK_TempSensor = CCM_TUPLE(98U, 0xFFFF), /*!< TempSensor Clock Gate.*/
301
302} clock_ip_name_t;
303
304/*! @brief ccm root name used to get clock frequency. */
305typedef enum _clock_root_control
306{
307 kCLOCK_RootM4 = (uint32_t)(&(CCM)->ROOT[1].TARGET_ROOT), /*!< ARM Cortex-M4 Clock control name.*/
308 kCLOCK_RootAxi = (uint32_t)(&(CCM)->ROOT[16].TARGET_ROOT), /*!< AXI Clock control name.*/
309 kCLOCK_RootNoc = (uint32_t)(&(CCM)->ROOT[26].TARGET_ROOT), /*!< NOC Clock control name.*/
310 kCLOCK_RootAhb = (uint32_t)(&(CCM)->ROOT[32].TARGET_ROOT), /*!< AHB Clock control name.*/
311 kCLOCK_RootIpg = (uint32_t)(&(CCM)->ROOT[33].TARGET_ROOT), /*!< IPG Clock control name.*/
312 kCLOCK_RootAudioAhb = (uint32_t)(&(CCM)->ROOT[34].TARGET_ROOT), /*!< Audio AHB Clock control name.*/
313 kCLOCK_RootAudioIpg = (uint32_t)(&(CCM)->ROOT[35].TARGET_ROOT), /*!< Audio IPG Clock control name.*/
314 kCLOCK_RootDramAlt = (uint32_t)(&(CCM)->ROOT[64].TARGET_ROOT), /*!< DRAM ALT Clock control name.*/
315
316 kCLOCK_RootSai1 = (uint32_t)(&(CCM)->ROOT[75].TARGET_ROOT), /*!< SAI1 Clock control name.*/
317 kCLOCK_RootSai2 = (uint32_t)(&(CCM)->ROOT[76].TARGET_ROOT), /*!< SAI2 Clock control name.*/
318 kCLOCK_RootSai3 = (uint32_t)(&(CCM)->ROOT[77].TARGET_ROOT), /*!< SAI3 Clock control name.*/
319 kCLOCK_RootSai4 = (uint32_t)(&(CCM)->ROOT[78].TARGET_ROOT), /*!< SAI4 Clock control name.*/
320 kCLOCK_RootSai5 = (uint32_t)(&(CCM)->ROOT[79].TARGET_ROOT), /*!< SAI5 Clock control name.*/
321 kCLOCK_RootSai6 = (uint32_t)(&(CCM)->ROOT[80].TARGET_ROOT), /*!< SAI6 Clock control name.*/
322
323 kCLOCK_RootQspi = (uint32_t)(&(CCM)->ROOT[87].TARGET_ROOT), /*!< QSPI Clock control name.*/
324
325 kCLOCK_RootI2c1 = (uint32_t)(&(CCM)->ROOT[90].TARGET_ROOT), /*!< I2C1 Clock control name.*/
326 kCLOCK_RootI2c2 = (uint32_t)(&(CCM)->ROOT[91].TARGET_ROOT), /*!< I2C2 Clock control name.*/
327 kCLOCK_RootI2c3 = (uint32_t)(&(CCM)->ROOT[92].TARGET_ROOT), /*!< I2C3 Clock control name.*/
328 kCLOCK_RootI2c4 = (uint32_t)(&(CCM)->ROOT[93].TARGET_ROOT), /*!< I2C4 Clock control name.*/
329
330 kCLOCK_RootUart1 = (uint32_t)(&(CCM)->ROOT[94].TARGET_ROOT), /*!< UART1 Clock control name.*/
331 kCLOCK_RootUart2 = (uint32_t)(&(CCM)->ROOT[95].TARGET_ROOT), /*!< UART2 Clock control name.*/
332 kCLOCK_RootUart3 = (uint32_t)(&(CCM)->ROOT[96].TARGET_ROOT), /*!< UART3 Clock control name.*/
333 kCLOCK_RootUart4 = (uint32_t)(&(CCM)->ROOT[97].TARGET_ROOT), /*!< UART4 Clock control name.*/
334
335 kCLOCK_RootEcspi1 = (uint32_t)(&(CCM)->ROOT[101].TARGET_ROOT), /*!< ECSPI1 Clock control name.*/
336 kCLOCK_RootEcspi2 = (uint32_t)(&(CCM)->ROOT[102].TARGET_ROOT), /*!< ECSPI2 Clock control name.*/
337 kCLOCK_RootEcspi3 = (uint32_t)(&(CCM)->ROOT[131].TARGET_ROOT), /*!< ECSPI3 Clock control name.*/
338
339 kCLOCK_RootPwm1 = (uint32_t)(&(CCM)->ROOT[103].TARGET_ROOT), /*!< PWM1 Clock control name.*/
340 kCLOCK_RootPwm2 = (uint32_t)(&(CCM)->ROOT[104].TARGET_ROOT), /*!< PWM2 Clock control name.*/
341 kCLOCK_RootPwm3 = (uint32_t)(&(CCM)->ROOT[105].TARGET_ROOT), /*!< PWM3 Clock control name.*/
342 kCLOCK_RootPwm4 = (uint32_t)(&(CCM)->ROOT[106].TARGET_ROOT), /*!< PWM4 Clock control name.*/
343
344 kCLOCK_RootGpt1 = (uint32_t)(&(CCM)->ROOT[107].TARGET_ROOT), /*!< GPT1 Clock control name.*/
345 kCLOCK_RootGpt2 = (uint32_t)(&(CCM)->ROOT[108].TARGET_ROOT), /*!< GPT2 Clock control name.*/
346 kCLOCK_RootGpt3 = (uint32_t)(&(CCM)->ROOT[109].TARGET_ROOT), /*!< GPT3 Clock control name.*/
347 kCLOCK_RootGpt4 = (uint32_t)(&(CCM)->ROOT[110].TARGET_ROOT), /*!< GPT4 Clock control name.*/
348 kCLOCK_RootGpt5 = (uint32_t)(&(CCM)->ROOT[111].TARGET_ROOT), /*!< GPT5 Clock control name.*/
349 kCLOCK_RootGpt6 = (uint32_t)(&(CCM)->ROOT[112].TARGET_ROOT), /*!< GPT6 Clock control name.*/
350
351 kCLOCK_RootWdog = (uint32_t)(&(CCM)->ROOT[114].TARGET_ROOT), /*!< WDOG Clock control name.*/
352
353 kCLOCK_RootPdm = (uint32_t)(&(CCM)->ROOT[132].TARGET_ROOT), /*!< PDM Clock control name.*/
354
355} clock_root_control_t;
356
357/*! @brief Root clock select enumeration for ARM Cortex-M4 core. */
358typedef enum _clock_rootmux_m4_clk_sel
359{
360 kCLOCK_M4RootmuxOsc24M = 0U, /*!< ARM Cortex-M4 Clock from OSC 24M.*/
361 kCLOCK_M4RootmuxSysPll2Div5 = 1U, /*!< ARM Cortex-M4 Clock from SYSTEM PLL2 divided by 5.*/
362 kCLOCK_M4RootmuxSysPll2Div4 = 2U, /*!< ARM Cortex-M4 Clock from SYSTEM PLL2 divided by 4.*/
363 kCLOCK_M4RootmuxSysPll1Div3 = 3U, /*!< ARM Cortex-M4 Clock from SYSTEM PLL1 divided by 3.*/
364 kCLOCK_M4RootmuxSysPll1 = 4U, /*!< ARM Cortex-M4 Clock from SYSTEM PLL1.*/
365 kCLOCK_M4RootmuxAudioPll1 = 5U, /*!< ARM Cortex-M4 Clock from AUDIO PLL1.*/
366 kCLOCK_M4RootmuxVideoPll1 = 6U, /*!< ARM Cortex-M4 Clock from VIDEO PLL1.*/
367 kCLOCK_M4RootmuxSysPll3 = 7U, /*!< ARM Cortex-M4 Clock from SYSTEM PLL3.*/
368} clock_rootmux_m4_clk_sel_t;
369
370/*! @brief Root clock select enumeration for AXI bus. */
371typedef enum _clock_rootmux_axi_clk_sel
372{
373 kCLOCK_AxiRootmuxOsc24M = 0U, /*!< ARM AXI Clock from OSC 24M.*/
374 kCLOCK_AxiRootmuxSysPll2Div3 = 1U, /*!< ARM AXI Clock from SYSTEM PLL2 divided by 3.*/
375 kCLOCK_AxiRootmuxSysPll1 = 2U, /*!< ARM AXI Clock from SYSTEM PLL1.*/
376 kCLOCK_AxiRootmuxSysPll2Div4 = 3U, /*!< ARM AXI Clock from SYSTEM PLL2 divided by 4.*/
377 kCLOCK_AxiRootmuxSysPll2 = 4U, /*!< ARM AXI Clock from SYSTEM PLL2.*/
378 kCLOCK_AxiRootmuxAudioPll1 = 5U, /*!< ARM AXI Clock from AUDIO PLL1.*/
379 kCLOCK_AxiRootmuxVideoPll1 = 6U, /*!< ARM AXI Clock from VIDEO PLL1.*/
380 kCLOCK_AxiRootmuxSysPll1Div8 = 7U, /*!< ARM AXI Clock from SYSTEM PLL1 divided by 8.*/
381} clock_rootmux_axi_clk_sel_t;
382
383/*! @brief Root clock select enumeration for AHB bus. */
384typedef enum _clock_rootmux_ahb_clk_sel
385{
386 kCLOCK_AhbRootmuxOsc24M = 0U, /*!< ARM AHB Clock from OSC 24M.*/
387 kCLOCK_AhbRootmuxSysPll1Div6 = 1U, /*!< ARM AHB Clock from SYSTEM PLL1 divided by 6.*/
388 kCLOCK_AhbRootmuxSysPll1 = 2U, /*!< ARM AHB Clock from SYSTEM PLL1.*/
389 kCLOCK_AhbRootmuxSysPll1Div2 = 3U, /*!< ARM AHB Clock from SYSTEM PLL1 divided by 2.*/
390 kCLOCK_AhbRootmuxSysPll2Div8 = 4U, /*!< ARM AHB Clock from SYSTEM PLL2 divided by 8.*/
391 kCLOCK_AhbRootmuxSysPll3 = 5U, /*!< ARM AHB Clock from SYSTEM PLL3.*/
392 kCLOCK_AhbRootmuxAudioPll1 = 6U, /*!< ARM AHB Clock from AUDIO PLL1.*/
393 kCLOCK_AhbRootmuxVideoPll1 = 7U, /*!< ARM AHB Clock from VIDEO PLL1.*/
394} clock_rootmux_ahb_clk_sel_t;
395
396/*! @brief Root clock select enumeration for Audio AHB bus. */
397typedef enum _clock_rootmux_audio_ahb_clk_sel
398{
399 kCLOCK_AudioAhbRootmuxOsc24M = 0U, /*!< ARM Audio AHB Clock from OSC 24M.*/
400 kCLOCK_AudioAhbRootmuxSysPll2Div2 = 1U, /*!< ARM Audio AHB Clock from SYSTEM PLL2 divided by 2.*/
401 kCLOCK_AudioAhbRootmuxSysPll1 = 2U, /*!< ARM Audio AHB Clock from SYSTEM PLL1.*/
402 kCLOCK_AudioAhbRootmuxSysPll2 = 3U, /*!< ARM Audio AHB Clock from SYSTEM PLL2.*/
403 kCLOCK_AudioAhbRootmuxSysPll2Div6 = 4U, /*!< ARM Audio AHB Clock from SYSTEM PLL2 divided by 6.*/
404 kCLOCK_AudioAhbRootmuxSysPll3 = 5U, /*!< ARM Audio AHB Clock from SYSTEM PLL3.*/
405 kCLOCK_AudioAhbRootmuxAudioPll1 = 6U, /*!< ARM Audio AHB Clock from AUDIO PLL1.*/
406 kCLOCK_AudioAhbRootmuxVideoPll1 = 7U, /*!< ARM Audio AHB Clock from VIDEO PLL1.*/
407} clock_rootmux_audio_ahb_clk_sel_t;
408/*! @brief Root clock select enumeration for QSPI peripheral. */
409typedef enum _clock_rootmux_qspi_clk_sel
410{
411 kCLOCK_QspiRootmuxOsc24M = 0U, /*!< ARM QSPI Clock from OSC 24M.*/
412 kCLOCK_QspiRootmuxSysPll1Div2 = 1U, /*!< ARM QSPI Clock from SYSTEM PLL1 divided by 2.*/
413 kCLOCK_QspiRootmuxSysPll2Div3 = 2U, /*!< ARM QSPI Clock from SYSTEM PLL2 divided by 3.*/
414 kCLOCK_QspiRootmuxSysPll2Div2 = 3U, /*!< ARM QSPI Clock from SYSTEM PLL2 divided by 2.*/
415 kCLOCK_QspiRootmuxAudioPll2 = 4U, /*!< ARM QSPI Clock from AUDIO PLL2.*/
416 kCLOCK_QspiRootmuxSysPll1Div3 = 5U, /*!< ARM QSPI Clock from SYSTEM PLL1 divided by 3 */
417 kCLOCK_QspiRootmuxSysPll3 = 6, /*!< ARM QSPI Clock from SYSTEM PLL3.*/
418 kCLOCK_QspiRootmuxSysPll1Div8 = 7U, /*!< ARM QSPI Clock from SYSTEM PLL1 divided by 8.*/
419} clock_rootmux_qspi_clk_sel_t;
420
421/*! @brief Root clock select enumeration for ECSPI peripheral. */
422typedef enum _clock_rootmux_ecspi_clk_sel
423{
424 kCLOCK_EcspiRootmuxOsc24M = 0U, /*!< ECSPI Clock from OSC 24M.*/
425 kCLOCK_EcspiRootmuxSysPll2Div5 = 1U, /*!< ECSPI Clock from SYSTEM PLL2 divided by 5.*/
426 kCLOCK_EcspiRootmuxSysPll1Div20 = 2U, /*!< ECSPI Clock from SYSTEM PLL1 divided by 20.*/
427 kCLOCK_EcspiRootmuxSysPll1Div5 = 3U, /*!< ECSPI Clock from SYSTEM PLL1 divided by 5.*/
428 kCLOCK_EcspiRootmuxSysPll1 = 4U, /*!< ECSPI Clock from SYSTEM PLL1.*/
429 kCLOCK_EcspiRootmuxSysPll3 = 5U, /*!< ECSPI Clock from SYSTEM PLL3.*/
430 kCLOCK_EcspiRootmuxSysPll2Div4 = 6U, /*!< ECSPI Clock from SYSTEM PLL2 divided by 4.*/
431 kCLOCK_EcspiRootmuxAudioPll2 = 7U, /*!< ECSPI Clock from AUDIO PLL2.*/
432} clock_rootmux_ecspi_clk_sel_t;
433
434/*! @brief Root clock select enumeration for I2C peripheral. */
435typedef enum _clock_rootmux_i2c_clk_sel
436{
437 kCLOCK_I2cRootmuxOsc24M = 0U, /*!< I2C Clock from OSC 24M.*/
438 kCLOCK_I2cRootmuxSysPll1Div5 = 1U, /*!< I2C Clock from SYSTEM PLL1 divided by 5.*/
439 kCLOCK_I2cRootmuxSysPll2Div20 = 2U, /*!< I2C Clock from SYSTEM PLL2 divided by 20.*/
440 kCLOCK_I2cRootmuxSysPll3 = 3U, /*!< I2C Clock from SYSTEM PLL3 .*/
441 kCLOCK_I2cRootmuxAudioPll1 = 4U, /*!< I2C Clock from AUDIO PLL1.*/
442 kCLOCK_I2cRootmuxVideoPll1 = 5U, /*!< I2C Clock from VIDEO PLL1.*/
443 kCLOCK_I2cRootmuxAudioPll2 = 6U, /*!< I2C Clock from AUDIO PLL2.*/
444 kCLOCK_I2cRootmuxSysPll1Div6 = 7U, /*!< I2C Clock from SYSTEM PLL1 divided by 6.*/
445} clock_rootmux_i2c_clk_sel_t;
446
447/*! @brief Root clock select enumeration for UART peripheral. */
448typedef enum _clock_rootmux_uart_clk_sel
449{
450 kCLOCK_UartRootmuxOsc24M = 0U, /*!< UART Clock from OSC 24M.*/
451 kCLOCK_UartRootmuxSysPll1Div10 = 1U, /*!< UART Clock from SYSTEM PLL1 divided by 10.*/
452 kCLOCK_UartRootmuxSysPll2Div5 = 2U, /*!< UART Clock from SYSTEM PLL2 divided by 5.*/
453 kCLOCK_UartRootmuxSysPll2Div10 = 3U, /*!< UART Clock from SYSTEM PLL2 divided by 10.*/
454 kCLOCK_UartRootmuxSysPll3 = 4U, /*!< UART Clock from SYSTEM PLL3.*/
455 kCLOCK_UartRootmuxExtClk2 = 5U, /*!< UART Clock from External Clock 2.*/
456 kCLOCK_UartRootmuxExtClk34 = 6U, /*!< UART Clock from External Clock 3, External Clock 4.*/
457 kCLOCK_UartRootmuxAudioPll2 = 7U, /*!< UART Clock from Audio PLL2.*/
458} clock_rootmux_uart_clk_sel_t;
459
460/*! @brief Root clock select enumeration for GPT peripheral. */
461typedef enum _clock_rootmux_gpt
462{
463 kCLOCK_GptRootmuxOsc24M = 0U, /*!< GPT Clock from OSC 24M.*/
464 kCLOCK_GptRootmuxSystemPll2Div10 = 1U, /*!< GPT Clock from SYSTEM PLL2 divided by 10.*/
465 kCLOCK_GptRootmuxSysPll1Div2 = 2U, /*!< GPT Clock from SYSTEM PLL1 divided by 2.*/
466 kCLOCK_GptRootmuxSysPll1Div20 = 3U, /*!< GPT Clock from SYSTEM PLL1 divided by 20.*/
467 kCLOCK_GptRootmuxVideoPll1 = 4U, /*!< GPT Clock from VIDEO PLL1.*/
468 kCLOCK_GptRootmuxSystemPll1Div10 = 5U, /*!< GPT Clock from SYSTEM PLL1 divided by 10.*/
469 kCLOCK_GptRootmuxAudioPll1 = 6U, /*!< GPT Clock from AUDIO PLL1.*/
470 kCLOCK_GptRootmuxExtClk123 = 7U, /*!< GPT Clock from External Clock1, External Clock2, External Clock3.*/
471} clock_rootmux_gpt_t;
472
473/*! @brief Root clock select enumeration for WDOG peripheral. */
474typedef enum _clock_rootmux_wdog_clk_sel
475{
476 kCLOCK_WdogRootmuxOsc24M = 0U, /*!< WDOG Clock from OSC 24M.*/
477 kCLOCK_WdogRootmuxSysPll1Div6 = 1U, /*!< WDOG Clock from SYSTEM PLL1 divided by 6.*/
478 kCLOCK_WdogRootmuxSysPll1Div5 = 2U, /*!< WDOG Clock from SYSTEM PLL1 divided by 5.*/
479 kCLOCK_WdogRootmuxVpuPll = 3U, /*!< WDOG Clock from VPU DLL.*/
480 kCLOCK_WdogRootmuxSystemPll2Div8 = 4U, /*!< WDOG Clock from SYSTEM PLL2 divided by 8.*/
481 kCLOCK_WdogRootmuxSystemPll3 = 5U, /*!< WDOG Clock from SYSTEM PLL3.*/
482 kCLOCK_WdogRootmuxSystemPll1Div10 = 6U, /*!< WDOG Clock from SYSTEM PLL1 divided by 10.*/
483 kCLOCK_WdogRootmuxSystemPll2Div6 = 7U, /*!< WDOG Clock from SYSTEM PLL2 divided by 6.*/
484} clock_rootmux_wdog_clk_sel_t;
485
486/*! @brief Root clock select enumeration for PWM peripheral. */
487typedef enum _clock_rootmux_pwm_clk_sel
488{
489 kCLOCK_PwmRootmuxOsc24M = 0U, /*!< PWM Clock from OSC 24M.*/
490 kCLOCK_PwmRootmuxSysPll2Div10 = 1U, /*!< PWM Clock from SYSTEM PLL2 divided by 10.*/
491 kCLOCK_PwmRootmuxSysPll1Div5 = 2U, /*!< PWM Clock from SYSTEM PLL1 divided by 5.*/
492 kCLOCK_PwmRootmuxSysPll1Div20 = 3U, /*!< PWM Clock from SYSTEM PLL1 divided by 20.*/
493 kCLOCK_PwmRootmuxSystemPll3 = 4U, /*!< PWM Clock from SYSTEM PLL3.*/
494 kCLOCK_PwmRootmuxExtClk12 = 5U, /*!< PWM Clock from External Clock1, External Clock2.*/
495 kCLOCK_PwmRootmuxSystemPll1Div10 = 6U, /*!< PWM Clock from SYSTEM PLL1 divided by 10.*/
496 kCLOCK_PwmRootmuxVideoPll1 = 7U, /*!< PWM Clock from VIDEO PLL1.*/
497} clock_rootmux_Pwm_clk_sel_t;
498
499/*! @brief Root clock select enumeration for SAI peripheral. */
500typedef enum _clock_rootmux_sai_clk_sel
501{
502 kCLOCK_SaiRootmuxOsc24M = 0U, /*!< SAI Clock from OSC 24M.*/
503 kCLOCK_SaiRootmuxAudioPll1 = 1U, /*!< SAI Clock from AUDIO PLL1.*/
504 kCLOCK_SaiRootmuxAudioPll2 = 2U, /*!< SAI Clock from AUDIO PLL2.*/
505 kCLOCK_SaiRootmuxVideoPll1 = 3U, /*!< SAI Clock from VIDEO PLL1.*/
506 kCLOCK_SaiRootmuxSysPll1Div6 = 4U, /*!< SAI Clock from SYSTEM PLL1 divided by 6.*/
507 kCLOCK_SaiRootmuxOsc26m = 5U, /*!< SAI Clock from OSC HDMI 26M.*/
508 kCLOCK_SaiRootmuxExtClk1 = 6U, /*!< SAI Clock from External Clock1, External Clock2, External Clock3.*/
509 kCLOCK_SaiRootmuxExtClk2 = 7U, /*!< SAI Clock from External Clock2, External Clock3, External Clock4.*/
510} clock_rootmux_sai_clk_sel_t;
511
512/*! @brief Root clock select enumeration for PDM peripheral. */
513typedef enum _clock_rootmux_pdm_clk_sel
514{
515 kCLOCK_PdmRootmuxOsc24M = 0U, /*!< GPT Clock from OSC 24M.*/
516 kCLOCK_PdmRootmuxSystemPll2 = 1U, /*!< GPT Clock from SYSTEM PLL2 divided by 10.*/
517 kCLOCK_PdmRootmuxAudioPll1 = 2U, /*!< GPT Clock from SYSTEM PLL1 divided by 2.*/
518 kCLOCK_PdmRootmuxSysPll1 = 3U, /*!< GPT Clock from SYSTEM PLL1 divided by 20.*/
519 kCLOCK_PdmRootmuxSysPll2 = 4U, /*!< GPT Clock from VIDEO PLL1.*/
520 kCLOCK_PdmRootmuxSysPll3 = 5U, /*!< GPT Clock from SYSTEM PLL1 divided by 10.*/
521 kCLOCK_PdmRootmuxExtClk3 = 6U, /*!< GPT Clock from AUDIO PLL1.*/
522 kCLOCK_PdmRootmuxAudioPll2 = 7U, /*!< GPT Clock from External Clock1, External Clock2, External Clock3.*/
523} clock_rootmux_pdm_clk_sel_t;
524
525/*! @brief Root clock select enumeration for NOC CLK. */
526typedef enum _clock_rootmux_noc_clk_sel
527{
528 kCLOCK_NocRootmuxOsc24M = 0U, /*!< NOC Clock from OSC 24M.*/
529 kCLOCK_NocRootmuxSysPll1 = 1U, /*!< NOC Clock from SYSTEM PLL1.*/
530 kCLOCK_NocRootmuxSysPll3 = 2U, /*!< NOC Clock from SYSTEM PLL3.*/
531 kCLOCK_NocRootmuxSysPll2 = 3U, /*!< NOC Clock from SYSTEM PLL2.*/
532 kCLOCK_NocRootmuxSysPll2Div2 = 4U, /*!< NOC Clock from SYSTEM PLL2 divided by 2.*/
533 kCLOCK_NocRootmuxAudioPll1 = 5U, /*!< NOC Clock from AUDIO PLL1.*/
534 kCLOCK_NocRootmuxVideoPll1 = 6U, /*!< NOC Clock from VIDEO PLL1.*/
535 kCLOCK_NocRootmuxAudioPll2 = 7U, /*!< NOC Clock from AUDIO PLL2.*/
536
537} clock_rootmux_noc_clk_sel_t;
538
539/*! @brief CCM PLL gate control. */
540typedef enum _clock_pll_gate
541{
542 kCLOCK_ArmPllGate = (uint32_t)(&(CCM)->PLL_CTRL[12].PLL_CTRL), /*!< ARM PLL Gate.*/
543
544 kCLOCK_GpuPllGate = (uint32_t)(&(CCM)->PLL_CTRL[13].PLL_CTRL), /*!< GPU PLL Gate.*/
545 kCLOCK_VpuPllGate = (uint32_t)(&(CCM)->PLL_CTRL[14].PLL_CTRL), /*!< VPU PLL Gate.*/
546 kCLOCK_DramPllGate = (uint32_t)(&(CCM)->PLL_CTRL[15].PLL_CTRL), /*!< DRAM PLL1 Gate.*/
547
548 kCLOCK_SysPll1Gate = (uint32_t)(&(CCM)->PLL_CTRL[16].PLL_CTRL), /*!< SYSTEM PLL1 Gate.*/
549 kCLOCK_SysPll1Div2Gate = (uint32_t)(&(CCM)->PLL_CTRL[17].PLL_CTRL), /*!< SYSTEM PLL1 Div2 Gate.*/
550 kCLOCK_SysPll1Div3Gate = (uint32_t)(&(CCM)->PLL_CTRL[18].PLL_CTRL), /*!< SYSTEM PLL1 Div3 Gate.*/
551 kCLOCK_SysPll1Div4Gate = (uint32_t)(&(CCM)->PLL_CTRL[19].PLL_CTRL), /*!< SYSTEM PLL1 Div4 Gate.*/
552 kCLOCK_SysPll1Div5Gate = (uint32_t)(&(CCM)->PLL_CTRL[20].PLL_CTRL), /*!< SYSTEM PLL1 Div5 Gate.*/
553 kCLOCK_SysPll1Div6Gate = (uint32_t)(&(CCM)->PLL_CTRL[21].PLL_CTRL), /*!< SYSTEM PLL1 Div6 Gate.*/
554 kCLOCK_SysPll1Div8Gate = (uint32_t)(&(CCM)->PLL_CTRL[22].PLL_CTRL), /*!< SYSTEM PLL1 Div8 Gate.*/
555 kCLOCK_SysPll1Div10Gate = (uint32_t)(&(CCM)->PLL_CTRL[23].PLL_CTRL), /*!< SYSTEM PLL1 Div10 Gate.*/
556 kCLOCK_SysPll1Div20Gate = (uint32_t)(&(CCM)->PLL_CTRL[24].PLL_CTRL), /*!< SYSTEM PLL1 Div20 Gate.*/
557
558 kCLOCK_SysPll2Gate = (uint32_t)(&(CCM)->PLL_CTRL[25].PLL_CTRL), /*!< SYSTEM PLL2 Gate.*/
559 kCLOCK_SysPll2Div2Gate = (uint32_t)(&(CCM)->PLL_CTRL[26].PLL_CTRL), /*!< SYSTEM PLL2 Div2 Gate.*/
560 kCLOCK_SysPll2Div3Gate = (uint32_t)(&(CCM)->PLL_CTRL[27].PLL_CTRL), /*!< SYSTEM PLL2 Div3 Gate.*/
561 kCLOCK_SysPll2Div4Gate = (uint32_t)(&(CCM)->PLL_CTRL[28].PLL_CTRL), /*!< SYSTEM PLL2 Div4 Gate.*/
562 kCLOCK_SysPll2Div5Gate = (uint32_t)(&(CCM)->PLL_CTRL[29].PLL_CTRL), /*!< SYSTEM PLL2 Div5 Gate.*/
563 kCLOCK_SysPll2Div6Gate = (uint32_t)(&(CCM)->PLL_CTRL[30].PLL_CTRL), /*!< SYSTEM PLL2 Div6 Gate.*/
564 kCLOCK_SysPll2Div8Gate = (uint32_t)(&(CCM)->PLL_CTRL[31].PLL_CTRL), /*!< SYSTEM PLL2 Div8 Gate.*/
565 kCLOCK_SysPll2Div10Gate = (uint32_t)(&(CCM)->PLL_CTRL[32].PLL_CTRL), /*!< SYSTEM PLL2 Div10 Gate.*/
566 kCLOCK_SysPll2Div20Gate = (uint32_t)(&(CCM)->PLL_CTRL[33].PLL_CTRL), /*!< SYSTEM PLL2 Div20 Gate.*/
567
568 kCLOCK_SysPll3Gate = (uint32_t)(&(CCM)->PLL_CTRL[34].PLL_CTRL), /*!< SYSTEM PLL3 Gate.*/
569
570 kCLOCK_AudioPll1Gate = (uint32_t)(&(CCM)->PLL_CTRL[35].PLL_CTRL), /*!< AUDIO PLL1 Gate.*/
571 kCLOCK_AudioPll2Gate = (uint32_t)(&(CCM)->PLL_CTRL[36].PLL_CTRL), /*!< AUDIO PLL2 Gate.*/
572 kCLOCK_VideoPll1Gate = (uint32_t)(&(CCM)->PLL_CTRL[37].PLL_CTRL), /*!< VIDEO PLL1 Gate.*/
573 kCLOCK_VideoPll2Gate = (uint32_t)(&(CCM)->PLL_CTRL[38].PLL_CTRL), /*!< VIDEO PLL2 Gate.*/
574} clock_pll_gate_t;
575
576/*! @brief CCM gate control value. */
577typedef enum _clock_gate_value
578{
579 kCLOCK_ClockNotNeeded = 0x0U, /*!< Clock always disabled.*/
580 kCLOCK_ClockNeededRun = 0x1111U, /*!< Clock enabled when CPU is running.*/
581 kCLOCK_ClockNeededRunWait = 0x2222U, /*!< Clock enabled when CPU is running or in WAIT mode.*/
582 kCLOCK_ClockNeededAll = 0x3333U, /*!< Clock always enabled.*/
583} clock_gate_value_t;
584
585/*!
586 * @brief PLL control names for PLL bypass.
587 *
588 * These constants define the PLL control names for PLL bypass.\n
589 * - 0:15: REG offset to CCM_ANALOG_BASE in bytes.
590 * - 16:20: bypass bit shift.
591 */
592typedef enum _clock_pll_bypass_ctrl
593{
594 kCLOCK_AudioPll1BypassCtrl =
595 CCM_ANALOG_TUPLE(AUDIO_PLL1_GEN_CTRL_OFFSET,
596 CCM_ANALOG_AUDIO_PLL1_GEN_CTRL_PLL_BYPASS_SHIFT), /*!< CCM Audio PLL1 bypass Control.*/
597
598 kCLOCK_AudioPll2BypassCtrl =
599 CCM_ANALOG_TUPLE(AUDIO_PLL2_GEN_CTRL_OFFSET,
600 CCM_ANALOG_AUDIO_PLL2_GEN_CTRL_PLL_BYPASS_SHIFT), /*!< CCM Audio PLL2 bypass Control.*/
601
602 kCLOCK_VideoPll1BypassCtrl =
603 CCM_ANALOG_TUPLE(VIDEO_PLL1_GEN_CTRL_OFFSET,
604 CCM_ANALOG_VIDEO_PLL1_GEN_CTRL_PLL_BYPASS_SHIFT), /*!< CCM Video Pll1 bypass Control.*/
605
606 kCLOCK_DramPllInternalPll1BypassCtrl = CCM_ANALOG_TUPLE(
607 DRAM_PLL_GEN_CTRL_OFFSET, CCM_ANALOG_DRAM_PLL_GEN_CTRL_PLL_BYPASS_SHIFT), /*!< CCM DRAM PLL bypass Control.*/
608
609 kCLOCK_GpuPLLPwrBypassCtrl = CCM_ANALOG_TUPLE(
610 GPU_PLL_GEN_CTRL_OFFSET, CCM_ANALOG_GPU_PLL_GEN_CTRL_PLL_BYPASS_SHIFT), /*!< CCM Gpu PLL bypass Control.*/
611
612 kCLOCK_VpuPllPwrBypassCtrl = CCM_ANALOG_TUPLE(
613 VPU_PLL_GEN_CTRL_OFFSET, CCM_ANALOG_VPU_PLL_GEN_CTRL_PLL_BYPASS_SHIFT), /*!< CCM Vpu PLL bypass Control.*/
614
615 kCLOCK_ArmPllPwrBypassCtrl = CCM_ANALOG_TUPLE(
616 ARM_PLL_GEN_CTRL_OFFSET, CCM_ANALOG_ARM_PLL_GEN_CTRL_PLL_BYPASS_SHIFT), /*!< CCM Arm PLL bypass Control.*/
617
618 kCLOCK_SysPll1InternalPll1BypassCtrl = CCM_ANALOG_TUPLE(
619 SYS_PLL1_GEN_CTRL_OFFSET, CCM_ANALOG_SYS_PLL1_GEN_CTRL_PLL_BYPASS_SHIFT), /*!< CCM System PLL1 bypass Control.*/
620
621 kCLOCK_SysPll2InternalPll1BypassCtrl = CCM_ANALOG_TUPLE(
622 SYS_PLL2_GEN_CTRL_OFFSET, CCM_ANALOG_SYS_PLL2_GEN_CTRL_PLL_BYPASS_SHIFT), /*!< CCM System PLL2 bypass Control.*/
623
624 kCLOCK_SysPll3InternalPll1BypassCtrl = CCM_ANALOG_TUPLE(
625 SYS_PLL3_GEN_CTRL_OFFSET, CCM_ANALOG_SYS_PLL3_GEN_CTRL_PLL_BYPASS_SHIFT), /*!< CCM System PLL3 bypass Control.*/
626} clock_pll_bypass_ctrl_t;
627
628/*!
629 * @brief PLL clock names for clock enable/disable settings.
630 *
631 * These constants define the PLL clock names for PLL clock enable/disable operations.\n
632 * - 0:15: REG offset to CCM_ANALOG_BASE in bytes.
633 * - 16:20: Clock enable bit shift.
634 */
635typedef enum _ccm_analog_pll_clke
636{
637 kCLOCK_AudioPll1Clke = CCM_ANALOG_TUPLE(AUDIO_PLL1_GEN_CTRL_OFFSET,
638 CCM_ANALOG_AUDIO_PLL1_GEN_CTRL_PLL_CLKE_SHIFT), /*!< Audio pll1 clke */
639 kCLOCK_AudioPll2Clke = CCM_ANALOG_TUPLE(AUDIO_PLL2_GEN_CTRL_OFFSET,
640 CCM_ANALOG_AUDIO_PLL2_GEN_CTRL_PLL_CLKE_SHIFT), /*!< Audio pll2 clke */
641 kCLOCK_VideoPll1Clke = CCM_ANALOG_TUPLE(VIDEO_PLL1_GEN_CTRL_OFFSET,
642 CCM_ANALOG_VIDEO_PLL1_GEN_CTRL_PLL_CLKE_SHIFT), /*!< Video pll1 clke */
643 kCLOCK_DramPllClke =
644 CCM_ANALOG_TUPLE(DRAM_PLL_GEN_CTRL_OFFSET, CCM_ANALOG_DRAM_PLL_GEN_CTRL_PLL_CLKE_SHIFT), /*!< Dram pll clke */
645
646 kCLOCK_GpuPllClke =
647 CCM_ANALOG_TUPLE(GPU_PLL_GEN_CTRL_OFFSET, CCM_ANALOG_GPU_PLL_GEN_CTRL_PLL_CLKE_SHIFT), /*!< Gpu pll clke */
648 kCLOCK_VpuPllClke =
649 CCM_ANALOG_TUPLE(VPU_PLL_GEN_CTRL_OFFSET, CCM_ANALOG_VPU_PLL_GEN_CTRL_PLL_CLKE_SHIFT), /*!< Vpu pll clke */
650 kCLOCK_ArmPllClke =
651 CCM_ANALOG_TUPLE(ARM_PLL_GEN_CTRL_OFFSET, CCM_ANALOG_ARM_PLL_GEN_CTRL_PLL_CLKE_SHIFT), /*!< Arm pll clke */
652
653 kCLOCK_SystemPll1Clke = CCM_ANALOG_TUPLE(SYS_PLL1_GEN_CTRL_OFFSET,
654 CCM_ANALOG_SYS_PLL1_GEN_CTRL_PLL_CLKE_SHIFT), /*!< System pll1 clke */
655 kCLOCK_SystemPll1Div2Clke = CCM_ANALOG_TUPLE(
656 SYS_PLL1_GEN_CTRL_OFFSET, CCM_ANALOG_SYS_PLL1_GEN_CTRL_PLL_DIV2_CLKE_SHIFT), /*!< System pll1 Div2 clke */
657 kCLOCK_SystemPll1Div3Clke = CCM_ANALOG_TUPLE(
658 SYS_PLL1_GEN_CTRL_OFFSET, CCM_ANALOG_SYS_PLL1_GEN_CTRL_PLL_DIV3_CLKE_SHIFT), /*!< System pll1 Div3 clke */
659 kCLOCK_SystemPll1Div4Clke = CCM_ANALOG_TUPLE(
660 SYS_PLL1_GEN_CTRL_OFFSET, CCM_ANALOG_SYS_PLL1_GEN_CTRL_PLL_DIV4_CLKE_SHIFT), /*!< System pll1 Div4 clke */
661 kCLOCK_SystemPll1Div5Clke = CCM_ANALOG_TUPLE(
662 SYS_PLL1_GEN_CTRL_OFFSET, CCM_ANALOG_SYS_PLL1_GEN_CTRL_PLL_DIV5_CLKE_SHIFT), /*!< System pll1 Div5 clke */
663 kCLOCK_SystemPll1Div6Clke = CCM_ANALOG_TUPLE(
664 SYS_PLL1_GEN_CTRL_OFFSET, CCM_ANALOG_SYS_PLL1_GEN_CTRL_PLL_DIV6_CLKE_SHIFT), /*!< System pll1 Div6 clke */
665 kCLOCK_SystemPll1Div8Clke = CCM_ANALOG_TUPLE(
666 SYS_PLL1_GEN_CTRL_OFFSET, CCM_ANALOG_SYS_PLL1_GEN_CTRL_PLL_DIV8_CLKE_SHIFT), /*!< System pll1 Div8 clke */
667 kCLOCK_SystemPll1Div10Clke = CCM_ANALOG_TUPLE(
668 SYS_PLL1_GEN_CTRL_OFFSET, CCM_ANALOG_SYS_PLL1_GEN_CTRL_PLL_DIV10_CLKE_SHIFT), /*!< System pll1 Div10 clke */
669 kCLOCK_SystemPll1Div20Clke = CCM_ANALOG_TUPLE(
670 SYS_PLL1_GEN_CTRL_OFFSET, CCM_ANALOG_SYS_PLL1_GEN_CTRL_PLL_DIV20_CLKE_SHIFT), /*!< System pll1 Div20 clke */
671
672 kCLOCK_SystemPll2Clke = CCM_ANALOG_TUPLE(SYS_PLL2_GEN_CTRL_OFFSET,
673 CCM_ANALOG_SYS_PLL2_GEN_CTRL_PLL_CLKE_SHIFT), /*!< System pll2 clke */
674 kCLOCK_SystemPll2Div2Clke = CCM_ANALOG_TUPLE(
675 SYS_PLL2_GEN_CTRL_OFFSET, CCM_ANALOG_SYS_PLL2_GEN_CTRL_PLL_DIV2_CLKE_SHIFT), /*!< System pll2 Div2 clke */
676 kCLOCK_SystemPll2Div3Clke = CCM_ANALOG_TUPLE(
677 SYS_PLL2_GEN_CTRL_OFFSET, CCM_ANALOG_SYS_PLL2_GEN_CTRL_PLL_DIV3_CLKE_SHIFT), /*!< System pll2 Div3 clke */
678 kCLOCK_SystemPll2Div4Clke = CCM_ANALOG_TUPLE(
679 SYS_PLL2_GEN_CTRL_OFFSET, CCM_ANALOG_SYS_PLL2_GEN_CTRL_PLL_DIV4_CLKE_SHIFT), /*!< System pll2 Div4 clke */
680 kCLOCK_SystemPll2Div5Clke = CCM_ANALOG_TUPLE(
681 SYS_PLL2_GEN_CTRL_OFFSET, CCM_ANALOG_SYS_PLL2_GEN_CTRL_PLL_DIV5_CLKE_SHIFT), /*!< System pll2 Div5 clke */
682 kCLOCK_SystemPll2Div6Clke = CCM_ANALOG_TUPLE(
683 SYS_PLL2_GEN_CTRL_OFFSET, CCM_ANALOG_SYS_PLL2_GEN_CTRL_PLL_DIV6_CLKE_SHIFT), /*!< System pll2 Div6 clke */
684 kCLOCK_SystemPll2Div8Clke = CCM_ANALOG_TUPLE(
685 SYS_PLL2_GEN_CTRL_OFFSET, CCM_ANALOG_SYS_PLL2_GEN_CTRL_PLL_DIV8_CLKE_SHIFT), /*!< System pll2 Div8 clke */
686 kCLOCK_SystemPll2Div10Clke = CCM_ANALOG_TUPLE(
687 SYS_PLL2_GEN_CTRL_OFFSET, CCM_ANALOG_SYS_PLL2_GEN_CTRL_PLL_DIV10_CLKE_SHIFT), /*!< System pll2 Div10 clke */
688 kCLOCK_SystemPll2Div20Clke = CCM_ANALOG_TUPLE(
689 SYS_PLL2_GEN_CTRL_OFFSET, CCM_ANALOG_SYS_PLL2_GEN_CTRL_PLL_DIV20_CLKE_SHIFT), /*!< System pll2 Div20 clke */
690
691 kCLOCK_SystemPll3Clke = CCM_ANALOG_TUPLE(SYS_PLL3_GEN_CTRL_OFFSET,
692 CCM_ANALOG_SYS_PLL3_GEN_CTRL_PLL_CLKE_SHIFT), /*!< System pll3 clke */
693} clock_pll_clke_t;
694
695/*!
696 * @brief ANALOG Power down override control.
697 */
698typedef enum _clock_pll_ctrl
699{
700 /* Fractional PLL frequency */
701 kCLOCK_AudioPll1Ctrl = CCM_ANALOG_TUPLE(AUDIO_PLL1_GEN_CTRL_OFFSET, CCM_ANALOG_AUDIO_PLL1_GEN_CTRL_PLL_RST_SHIFT),
702 kCLOCK_AudioPll2Ctrl = CCM_ANALOG_TUPLE(AUDIO_PLL2_GEN_CTRL_OFFSET, CCM_ANALOG_AUDIO_PLL2_GEN_CTRL_PLL_RST_SHIFT),
703 kCLOCK_VideoPll1Ctrl = CCM_ANALOG_TUPLE(VIDEO_PLL1_GEN_CTRL_OFFSET, CCM_ANALOG_VIDEO_PLL1_GEN_CTRL_PLL_RST_SHIFT),
704 kCLOCK_DramPllCtrl = CCM_ANALOG_TUPLE(DRAM_PLL_GEN_CTRL_OFFSET, CCM_ANALOG_DRAM_PLL_GEN_CTRL_PLL_RST_SHIFT),
705 /* Integer PLL frequency */
706 kCLOCK_GpuPllCtrl = CCM_ANALOG_TUPLE(GPU_PLL_GEN_CTRL_OFFSET, CCM_ANALOG_GPU_PLL_GEN_CTRL_PLL_RST_SHIFT),
707 kCLOCK_VpuPllCtrl = CCM_ANALOG_TUPLE(VPU_PLL_GEN_CTRL_OFFSET, CCM_ANALOG_VPU_PLL_GEN_CTRL_PLL_RST_SHIFT),
708 kCLOCK_ArmPllCtrl = CCM_ANALOG_TUPLE(ARM_PLL_GEN_CTRL_OFFSET, CCM_ANALOG_ARM_PLL_GEN_CTRL_PLL_RST_SHIFT),
709 kCLOCK_SystemPll1Ctrl = CCM_ANALOG_TUPLE(SYS_PLL1_GEN_CTRL_OFFSET, CCM_ANALOG_SYS_PLL1_GEN_CTRL_PLL_RST_SHIFT),
710 kCLOCK_SystemPll2Ctrl = CCM_ANALOG_TUPLE(SYS_PLL2_GEN_CTRL_OFFSET, CCM_ANALOG_SYS_PLL2_GEN_CTRL_PLL_RST_SHIFT),
711 kCLOCK_SystemPll3Ctrl = CCM_ANALOG_TUPLE(SYS_PLL3_GEN_CTRL_OFFSET, CCM_ANALOG_SYS_PLL3_GEN_CTRL_PLL_RST_SHIFT),
712} clock_pll_ctrl_t;
713
714/*! @brief PLL reference clock select. */
715enum
716{
717 kANALOG_PllRefOsc24M = 0U, /*!< reference OSC 24M */
718 kANALOG_PllPadClk = 1U, /*!< reference PAD CLK */
719};
720
721/*!
722 * @brief Fractional-N PLL configuration.
723 * Note: all the dividers in this configuration structure are the actually divider, software will map it to register
724 * value
725 */
726typedef struct _ccm_analog_frac_pll_config
727{
728 uint8_t refSel; /*!< pll reference clock sel */
729
730 uint32_t mainDiv; /*!< Value of the 10-bit programmable main-divider, range must be 64~1023 */
731
732 uint32_t dsm; /*!< Value of 16-bit DSM */
733
734 uint8_t preDiv; /*!< Value of the 6-bit programmable pre-divider, range must be 1~63 */
735
736 uint8_t postDiv; /*!< Value of the 3-bit programmable Scaler, range must be 0~6 */
737} ccm_analog_frac_pll_config_t;
738
739/*!
740 * @brief Integer PLL configuration.
741 * Note: all the dividers in this configuration structure are the actually divider, software will map it to register
742 * value
743 */
744typedef struct _ccm_analog_integer_pll_config
745{
746 uint8_t refSel; /*!< pll reference clock sel */
747
748 uint32_t mainDiv; /*!< Value of the 10-bit programmable main-divider, range must be 64~1023 */
749
750 uint8_t preDiv; /*!< Value of the 6-bit programmable pre-divider, range must be 1~63 */
751
752 uint8_t postDiv; /*!< Value of the 3-bit programmable Scaler, range must be 0~6 */
753
754} ccm_analog_integer_pll_config_t;
755
756/*******************************************************************************
757 * API
758 ******************************************************************************/
759
760#if defined(__cplusplus)
761extern "C" {
762#endif
763
764/*!
765 * @name CCM Root Clock Setting
766 * @{
767 */
768
769/*!
770 * @brief Set clock root mux.
771 * User maybe need to set more than one mux ROOT according to the clock tree
772 * description in the reference manual.
773 *
774 * @param rootClk Root clock control (see @ref clock_root_control_t enumeration).
775 * @param mux Root mux value (see _ccm_rootmux_xxx enumeration).
776 */
777static inline void CLOCK_SetRootMux(clock_root_control_t rootClk, uint32_t mux)
778{
779 CCM_REG(rootClk) = (CCM_REG(rootClk) & (~CCM_TARGET_ROOT_MUX_MASK)) | CCM_TARGET_ROOT_MUX(mux);
780}
781
782/*!
783 * @brief Get clock root mux.
784 * In order to get the clock source of root, user maybe need to get more than one
785 * ROOT's mux value to obtain the final clock source of root.
786 *
787 * @param rootClk Root clock control (see @ref clock_root_control_t enumeration).
788 * @return Root mux value (see _ccm_rootmux_xxx enumeration).
789 */
790static inline uint32_t CLOCK_GetRootMux(clock_root_control_t rootClk)
791{
792 return (CCM_REG(rootClk) & CCM_TARGET_ROOT_MUX_MASK) >> CCM_TARGET_ROOT_MUX_SHIFT;
793}
794
795/*!
796 * @brief Enable clock root
797 *
798 * @param rootClk Root clock control (see @ref clock_root_control_t enumeration)
799 */
800static inline void CLOCK_EnableRoot(clock_root_control_t rootClk)
801{
802 CCM_REG_SET(rootClk) = CCM_TARGET_ROOT_SET_ENABLE_MASK;
803}
804
805/*!
806 * @brief Disable clock root
807 *
808 * @param rootClk Root control (see @ref clock_root_control_t enumeration)
809 */
810static inline void CLOCK_DisableRoot(clock_root_control_t rootClk)
811{
812 CCM_REG_CLR(rootClk) = CCM_TARGET_ROOT_CLR_ENABLE_MASK;
813}
814
815/*!
816 * @brief Check whether clock root is enabled
817 *
818 * @param rootClk Root control (see @ref clock_root_control_t enumeration)
819 * @return CCM root enabled or not.
820 * - true: Clock root is enabled.
821 * - false: Clock root is disabled.
822 */
823static inline bool CLOCK_IsRootEnabled(clock_root_control_t rootClk)
824{
825 return (bool)(CCM_REG(rootClk) & CCM_TARGET_ROOT_ENABLE_MASK);
826}
827
828/*!
829 * @brief Update clock root in one step, for dynamical clock switching
830 * Note: The PRE and POST dividers in this function are the actually divider, software will map it to register value
831 *
832 * @param ccmRootClk Root control (see @ref clock_root_control_t enumeration)
833 * @param mux Root mux value (see _ccm_rootmux_xxx enumeration)
834 * @param pre Pre divider value (0-7, divider=n+1)
835 * @param post Post divider value (0-63, divider=n+1)
836 */
837void CLOCK_UpdateRoot(clock_root_control_t ccmRootClk, uint32_t mux, uint32_t pre, uint32_t post);
838
839/*!
840 * @brief Set root clock divider
841 * Note: The PRE and POST dividers in this function are the actually divider, software will map it to register value
842 *
843 * @param ccmRootClk Root control (see @ref clock_root_control_t enumeration)
844 * @param pre Pre divider value (1-8)
845 * @param post Post divider value (1-64)
846 */
847void CLOCK_SetRootDivider(clock_root_control_t ccmRootClk, uint32_t pre, uint32_t post);
848
849/*!
850 * @brief Get clock root PRE_PODF.
851 * In order to get the clock source of root, user maybe need to get more than one
852 * ROOT's mux value to obtain the final clock source of root.
853 *
854 * @param rootClk Root clock name (see @ref clock_root_control_t enumeration).
855 * @return Root Pre divider value.
856 */
857static inline uint32_t CLOCK_GetRootPreDivider(clock_root_control_t rootClk)
858{
859 return ((CCM_REG(rootClk) & CCM_TARGET_ROOT_PRE_PODF_MASK) >> CCM_TARGET_ROOT_PRE_PODF_SHIFT) + 1U;
860}
861
862/*!
863 * @brief Get clock root POST_PODF.
864 * In order to get the clock source of root, user maybe need to get more than one
865 * ROOT's mux value to obtain the final clock source of root.
866 *
867 * @param rootClk Root clock name (see @ref clock_root_control_t enumeration).
868 * @return Root Post divider value.
869 */
870static inline uint32_t CLOCK_GetRootPostDivider(clock_root_control_t rootClk)
871{
872 return ((CCM_REG(rootClk) & CCM_TARGET_ROOT_POST_PODF_MASK) >> CCM_TARGET_ROOT_POST_PODF_SHIFT) + 1U;
873}
874
875/*!
876 * @name CCM Gate Control
877 * @{
878 */
879
880/*!
881 * @brief Set PLL or CCGR gate control
882 *
883 * @param ccmGate Gate control (see @ref clock_pll_gate_t and @ref clock_ip_name_t enumeration)
884 * @param control Gate control value (see @ref clock_gate_value_t)
885 */
886static inline void CLOCK_ControlGate(uint32_t ccmGate, clock_gate_value_t control)
887{
888 CCM_REG(ccmGate) = (uint32_t)control;
889}
890
891/*!
892 * @brief Enable CCGR clock gate and root clock gate for each module
893 * User should set specific gate for each module according to the description
894 * of the table of system clocks, gating and override in CCM chapter of
895 * reference manual. Take care of that one module may need to set more than
896 * one clock gate.
897 *
898 * @param ccmGate Gate control for each module (see @ref clock_ip_name_t enumeration).
899 */
900void CLOCK_EnableClock(clock_ip_name_t ccmGate);
901
902/*!
903 * @brief Disable CCGR clock gate for the each module
904 * User should set specific gate for each module according to the description
905 * of the table of system clocks, gating and override in CCM chapter of
906 * reference manual. Take care of that one module may need to set more than
907 * one clock gate.
908 *
909 * @param ccmGate Gate control for each module (see @ref clock_ip_name_t enumeration).
910 */
911void CLOCK_DisableClock(clock_ip_name_t ccmGate);
912
913/*!
914 * @name CCM Analog PLL Operatoin Functions
915 * @{
916 */
917
918/*!
919 * @brief Power up PLL
920 *
921 * @param base CCM_ANALOG base pointer.
922 * @param pllControl PLL control name (see @ref clock_pll_ctrl_t enumeration)
923 */
924static inline void CLOCK_PowerUpPll(CCM_ANALOG_Type *base, clock_pll_ctrl_t pllControl)
925{
926 CCM_ANALOG_TUPLE_REG(base, pllControl) |= (1UL << CCM_ANALOG_TUPLE_SHIFT(pllControl));
927}
928
929/*!
930 * @brief Power down PLL
931 *
932 * @param base CCM_ANALOG base pointer.
933 * @param pllControl PLL control name (see @ref clock_pll_ctrl_t enumeration)
934 */
935static inline void CLOCK_PowerDownPll(CCM_ANALOG_Type *base, clock_pll_ctrl_t pllControl)
936{
937 CCM_ANALOG_TUPLE_REG(base, pllControl) &= ~(1UL << CCM_ANALOG_TUPLE_SHIFT(pllControl));
938}
939
940/*!
941 * @brief PLL bypass setting
942 *
943 * @param base CCM_ANALOG base pointer.
944 * @param pllControl PLL control name (see ccm_analog_pll_control_t enumeration)
945 * @param bypass Bypass the PLL.
946 * - true: Bypass the PLL.
947 * - false: Do not bypass the PLL.
948 */
949static inline void CLOCK_SetPllBypass(CCM_ANALOG_Type *base, clock_pll_bypass_ctrl_t pllControl, bool bypass)
950{
951 if (bypass)
952 {
953 CCM_ANALOG_TUPLE_REG(base, pllControl) |= 1UL << CCM_ANALOG_TUPLE_SHIFT(pllControl);
954 }
955 else
956 {
957 CCM_ANALOG_TUPLE_REG(base, pllControl) &= ~(1UL << CCM_ANALOG_TUPLE_SHIFT(pllControl));
958 }
959}
960
961/*!
962 * @brief Check if PLL is bypassed
963 *
964 * @param base CCM_ANALOG base pointer.
965 * @param pllControl PLL control name (see ccm_analog_pll_control_t enumeration)
966 * @return PLL bypass status.
967 * - true: The PLL is bypassed.
968 * - false: The PLL is not bypassed.
969 */
970static inline bool CLOCK_IsPllBypassed(CCM_ANALOG_Type *base, clock_pll_bypass_ctrl_t pllControl)
971{
972 return (bool)(CCM_ANALOG_TUPLE_REG(base, pllControl) & (1UL << CCM_ANALOG_TUPLE_SHIFT(pllControl)));
973}
974
975/*!
976 * @brief Check if PLL clock is locked
977 *
978 * @param base CCM_ANALOG base pointer.
979 * @param pllControl PLL control name (see @ref clock_pll_ctrl_t enumeration)
980 * @return PLL lock status.
981 * - true: The PLL clock is locked.
982 * - false: The PLL clock is not locked.
983 */
984static inline bool CLOCK_IsPllLocked(CCM_ANALOG_Type *base, clock_pll_ctrl_t pllControl)
985{
986 return (bool)(CCM_ANALOG_TUPLE_REG(base, pllControl) & CCM_ANALOG_SYS_PLL1_GEN_CTRL_PLL_LOCK_MASK);
987}
988
989/*!
990 * @brief Enable PLL clock
991 *
992 * @param base CCM_ANALOG base pointer.
993 * @param pllClock PLL clock name (see ccm_analog_pll_clock_t enumeration)
994 */
995static inline void CLOCK_EnableAnalogClock(CCM_ANALOG_Type *base, clock_pll_clke_t pllClock)
996{
997 CCM_ANALOG_TUPLE_REG(base, pllClock) |= 1UL << CCM_ANALOG_TUPLE_SHIFT(pllClock);
998}
999
1000/*!
1001 * @brief Disable PLL clock
1002 *
1003 * @param base CCM_ANALOG base pointer.
1004 * @param pllClock PLL clock name (see ccm_analog_pll_clock_t enumeration)
1005 */
1006static inline void CLOCK_DisableAnalogClock(CCM_ANALOG_Type *base, clock_pll_clke_t pllClock)
1007{
1008 CCM_ANALOG_TUPLE_REG(base, pllClock) &= ~(1UL << CCM_ANALOG_TUPLE_SHIFT(pllClock));
1009}
1010
1011/*!
1012 * @brief Override PLL clock output enable
1013 *
1014 * @param base CCM_ANALOG base pointer.
1015 * @param ovClock PLL clock name (see @ref clock_pll_clke_t enumeration)
1016 * @param override Override the PLL.
1017 * - true: Override the PLL clke, CCM will handle it.
1018 * - false: Do not override the PLL clke.
1019 */
1020static inline void CLOCK_OverridePllClke(CCM_ANALOG_Type *base, clock_pll_clke_t ovClock, bool override)
1021{
1022 if (override)
1023 {
1024 CCM_ANALOG_TUPLE_REG(base, ovClock) |= 1UL << (CCM_ANALOG_TUPLE_SHIFT(ovClock) - 1UL);
1025 }
1026 else
1027 {
1028 CCM_ANALOG_TUPLE_REG(base, ovClock) &= ~(1UL << (CCM_ANALOG_TUPLE_SHIFT(ovClock) - 1UL));
1029 }
1030}
1031
1032/*!
1033 * @brief Override PLL power down
1034 *
1035 * @param base CCM_ANALOG base pointer.
1036 * @param pdClock PLL clock name (see @ref clock_pll_ctrl_t enumeration)
1037 * @param override Override the PLL.
1038 * - true: Override the PLL clke, CCM will handle it.
1039 * - false: Do not override the PLL clke.
1040 */
1041static inline void CLOCK_OverridePllPd(CCM_ANALOG_Type *base, clock_pll_ctrl_t pdClock, bool override)
1042{
1043 if (override)
1044 {
1045 CCM_ANALOG_TUPLE_REG(base, pdClock) |= 1UL << (CCM_ANALOG_TUPLE_SHIFT(pdClock) - 1UL);
1046 }
1047 else
1048 {
1049 CCM_ANALOG_TUPLE_REG(base, pdClock) &= ~(1UL << (CCM_ANALOG_TUPLE_SHIFT(pdClock) - 1UL));
1050 }
1051}
1052
1053/*!
1054 * @brief Initializes the ANALOG ARM PLL.
1055 *
1056 * @param config Pointer to the configuration structure(see @ref ccm_analog_integer_pll_config_t enumeration).
1057 *
1058 * @note This function can't detect whether the Arm PLL has been enabled and
1059 * used by some IPs.
1060 */
1061void CLOCK_InitArmPll(const ccm_analog_integer_pll_config_t *config);
1062
1063/*!
1064 * @brief De-initialize the ARM PLL.
1065 */
1066void CLOCK_DeinitArmPll(void);
1067
1068/*!
1069 * @brief Initializes the ANALOG SYS PLL1.
1070 *
1071 * @param config Pointer to the configuration structure(see @ref ccm_analog_integer_pll_config_t enumeration).
1072 *
1073 * @note This function can't detect whether the SYS PLL has been enabled and
1074 * used by some IPs.
1075 */
1076void CLOCK_InitSysPll1(const ccm_analog_integer_pll_config_t *config);
1077
1078/*!
1079 * @brief De-initialize the System PLL1.
1080 */
1081void CLOCK_DeinitSysPll1(void);
1082
1083/*!
1084 * @brief Initializes the ANALOG SYS PLL2.
1085 *
1086 * @param config Pointer to the configuration structure(see @ref ccm_analog_integer_pll_config_t enumeration).
1087 *
1088 * @note This function can't detect whether the SYS PLL has been enabled and
1089 * used by some IPs.
1090 */
1091void CLOCK_InitSysPll2(const ccm_analog_integer_pll_config_t *config);
1092
1093/*!
1094 * @brief De-initialize the System PLL2.
1095 */
1096void CLOCK_DeinitSysPll2(void);
1097
1098/*!
1099 * @brief Initializes the ANALOG SYS PLL3.
1100 *
1101 * @param config Pointer to the configuration structure(see @ref ccm_analog_integer_pll_config_t enumeration).
1102 *
1103 * @note This function can't detect whether the SYS PLL has been enabled and
1104 * used by some IPs.
1105 */
1106void CLOCK_InitSysPll3(const ccm_analog_integer_pll_config_t *config);
1107
1108/*!
1109 * @brief De-initialize the System PLL3.
1110 */
1111void CLOCK_DeinitSysPll3(void);
1112
1113/*!
1114 * @brief Initializes the ANALOG AUDIO PLL1.
1115 *
1116 * @param config Pointer to the configuration structure(see @ref ccm_analog_frac_pll_config_t enumeration).
1117 *
1118 * @note This function can't detect whether the AUDIO PLL has been enabled and
1119 * used by some IPs.
1120 */
1121void CLOCK_InitAudioPll1(const ccm_analog_frac_pll_config_t *config);
1122
1123/*!
1124 * @brief De-initialize the Audio PLL1.
1125 */
1126void CLOCK_DeinitAudioPll1(void);
1127
1128/*!
1129 * @brief Initializes the ANALOG AUDIO PLL2.
1130 *
1131 * @param config Pointer to the configuration structure(see @ref ccm_analog_frac_pll_config_t enumeration).
1132 *
1133 * @note This function can't detect whether the AUDIO PLL has been enabled and
1134 * used by some IPs.
1135 */
1136void CLOCK_InitAudioPll2(const ccm_analog_frac_pll_config_t *config);
1137
1138/*!
1139 * @brief De-initialize the Audio PLL2.
1140 */
1141void CLOCK_DeinitAudioPll2(void);
1142
1143/*!
1144 * @brief Initializes the ANALOG VIDEO PLL1.
1145 *
1146 * @param config Pointer to the configuration structure(see @ref ccm_analog_frac_pll_config_t enumeration).
1147 *
1148 */
1149void CLOCK_InitVideoPll1(const ccm_analog_frac_pll_config_t *config);
1150
1151/*!
1152 * @brief De-initialize the Video PLL1.
1153 */
1154void CLOCK_DeinitVideoPll1(void);
1155
1156/*!
1157 * @brief Initializes the ANALOG Integer PLL.
1158 *
1159 * @param base CCM ANALOG base address
1160 * @param config Pointer to the configuration structure(see @ref ccm_analog_integer_pll_config_t enumeration).
1161 * @param type integer pll type
1162 *
1163 */
1164void CLOCK_InitIntegerPll(CCM_ANALOG_Type *base, const ccm_analog_integer_pll_config_t *config, clock_pll_ctrl_t type);
1165
1166/*!
1167 * @brief Get the ANALOG Integer PLL clock frequency.
1168 *
1169 * @param base CCM ANALOG base address.
1170 * @param type integer pll type
1171 * @param pll1Bypass pll1 bypass flag
1172 * @param refClkFreq Reference clock frequency.
1173 *
1174 * @return Clock frequency
1175 */
1176uint32_t CLOCK_GetIntegerPllFreq(CCM_ANALOG_Type *base, clock_pll_ctrl_t type, uint32_t refClkFreq, bool pll1Bypass);
1177
1178/*!
1179 * @brief Initializes the ANALOG Fractional PLL.
1180 *
1181 * @param base CCM ANALOG base address.
1182 * @param config Pointer to the configuration structure(see @ref ccm_analog_frac_pll_config_t enumeration).
1183 * @param type fractional pll type.
1184 *
1185 */
1186void CLOCK_InitFracPll(CCM_ANALOG_Type *base, const ccm_analog_frac_pll_config_t *config, clock_pll_ctrl_t type);
1187
1188/*!
1189 * @brief Gets the ANALOG Fractional PLL clock frequency.
1190 *
1191 * @param base CCM_ANALOG base pointer.
1192 * @param type fractional pll type.
1193 * @param refClkFreq Reference clock frequency.
1194 *
1195 * @return Clock frequency
1196 */
1197uint32_t CLOCK_GetFracPllFreq(CCM_ANALOG_Type *base, clock_pll_ctrl_t type, uint32_t refClkFreq);
1198
1199/*!
1200 * @brief Gets PLL clock frequency.
1201 *
1202 * @param pll fractional pll type.
1203
1204 * @return Clock frequency
1205 */
1206uint32_t CLOCK_GetPllFreq(clock_pll_ctrl_t pll);
1207
1208/*!
1209 * @brief Gets PLL reference clock frequency.
1210 *
1211 * @param ctrl The pll control.
1212
1213 * @return Clock frequency
1214 */
1215uint32_t CLOCK_GetPllRefClkFreq(clock_pll_ctrl_t ctrl);
1216
1217/*!
1218 * @name CCM Get frequency
1219 * @{
1220 */
1221
1222/*!
1223 * @brief Gets the clock frequency for a specific clock name.
1224 *
1225 * This function checks the current clock configurations and then calculates
1226 * the clock frequency for a specific clock name defined in clock_name_t.
1227 *
1228 * @param clockName Clock names defined in clock_name_t
1229 * @return Clock frequency value in hertz
1230 */
1231uint32_t CLOCK_GetFreq(clock_name_t clockName);
1232
1233/*!
1234 * @brief Get the CCM Cortex M4 core frequency.
1235 *
1236 * @return Clock frequency; If the clock is invalid, returns 0.
1237 */
1238uint32_t CLOCK_GetCoreM4Freq(void);
1239
1240/*!
1241 * @brief Get the CCM Axi bus frequency.
1242 *
1243 * @return Clock frequency; If the clock is invalid, returns 0.
1244 */
1245uint32_t CLOCK_GetAxiFreq(void);
1246
1247/*!
1248 * @brief Get the CCM Ahb bus frequency.
1249 *
1250 * @return Clock frequency; If the clock is invalid, returns 0.
1251 */
1252uint32_t CLOCK_GetAhbFreq(void);
1253
1254/* @} */
1255
1256#if defined(__cplusplus)
1257}
1258#endif
1259/* @} */
1260#endif