aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios-contrib/ext/mcux-sdk/devices/LPC54S005/drivers/fsl_clock.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios-contrib/ext/mcux-sdk/devices/LPC54S005/drivers/fsl_clock.h')
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/devices/LPC54S005/drivers/fsl_clock.h1294
1 files changed, 1294 insertions, 0 deletions
diff --git a/lib/chibios-contrib/ext/mcux-sdk/devices/LPC54S005/drivers/fsl_clock.h b/lib/chibios-contrib/ext/mcux-sdk/devices/LPC54S005/drivers/fsl_clock.h
new file mode 100644
index 000000000..33ae727ef
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/devices/LPC54S005/drivers/fsl_clock.h
@@ -0,0 +1,1294 @@
1/*
2 * Copyright (c) 2016, Freescale Semiconductor, Inc.
3 * Copyright 2016 - 2019 , NXP
4 * All rights reserved.
5 *
6 *
7 * SPDX-License-Identifier: BSD-3-Clause
8 */
9
10#ifndef _FSL_CLOCK_H_
11#define _FSL_CLOCK_H_
12
13#include "fsl_common.h"
14
15/*! @addtogroup clock */
16/*! @{ */
17
18/*! @file */
19
20/*******************************************************************************
21 * Definitions
22 *****************************************************************************/
23
24/*! @name Driver version */
25/*@{*/
26/*! @brief CLOCK driver version 2.3.1. */
27#define FSL_CLOCK_DRIVER_VERSION (MAKE_VERSION(2, 3, 1))
28/*@}*/
29
30/*! @brief Configure whether driver controls clock
31 *
32 * When set to 0, peripheral drivers will enable clock in initialize function
33 * and disable clock in de-initialize function. When set to 1, peripheral
34 * driver will not control the clock, application could control the clock out of
35 * the driver.
36 *
37 * @note All drivers share this feature switcher. If it is set to 1, application
38 * should handle clock enable and disable for all drivers.
39 */
40#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL))
41#define FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL 0
42#endif
43
44/*!
45 * @brief User-defined the size of cache for CLOCK_PllGetConfig() function.
46 *
47 * Once define this MACRO to be non-zero value, CLOCK_PllGetConfig() function
48 * would cache the recent calulation and accelerate the execution to get the
49 * right settings.
50 */
51#ifndef CLOCK_USR_CFG_PLL_CONFIG_CACHE_COUNT
52#define CLOCK_USR_CFG_PLL_CONFIG_CACHE_COUNT 2U
53#endif
54
55/* Definition for delay API in clock driver, users can redefine it to the real application. */
56#ifndef SDK_DEVICE_MAXIMUM_CPU_CLOCK_FREQUENCY
57#define SDK_DEVICE_MAXIMUM_CPU_CLOCK_FREQUENCY (180000000UL)
58#endif
59
60/*! @brief Clock ip name array for ADC. */
61#define ADC_CLOCKS \
62 { \
63 kCLOCK_Adc0 \
64 }
65/*! @brief Clock ip name array for ROM. */
66#define ROM_CLOCKS \
67 { \
68 kCLOCK_Rom \
69 }
70/*! @brief Clock ip name array for SRAM. */
71#define SRAM_CLOCKS \
72 { \
73 kCLOCK_Sram1, kCLOCK_Sram2, kCLOCK_Sram3 \
74 }
75/*! @brief Clock ip name array for FLASH. */
76#define FLASH_CLOCKS \
77 { \
78 kCLOCK_Flash \
79 }
80/*! @brief Clock ip name array for FMC. */
81#define FMC_CLOCKS \
82 { \
83 kCLOCK_Fmc \
84 }
85/*! @brief Clock ip name array for EEPROM. */
86#define EEPROM_CLOCKS \
87 { \
88 kCLOCK_Eeprom \
89 }
90/*! @brief Clock ip name array for SPIFI. */
91#define SPIFI_CLOCKS \
92 { \
93 kCLOCK_Spifi \
94 }
95/*! @brief Clock ip name array for INPUTMUX. */
96#define INPUTMUX_CLOCKS \
97 { \
98 kCLOCK_InputMux \
99 }
100/*! @brief Clock ip name array for IOCON. */
101#define IOCON_CLOCKS \
102 { \
103 kCLOCK_Iocon \
104 }
105/*! @brief Clock ip name array for GPIO. */
106#define GPIO_CLOCKS \
107 { \
108 kCLOCK_Gpio0, kCLOCK_Gpio1, kCLOCK_Gpio2, kCLOCK_Gpio3, kCLOCK_Gpio4, kCLOCK_Gpio5 \
109 }
110/*! @brief Clock ip name array for PINT. */
111#define PINT_CLOCKS \
112 { \
113 kCLOCK_Pint \
114 }
115/*! @brief Clock ip name array for GINT. */
116#define GINT_CLOCKS \
117 { \
118 kCLOCK_Gint, kCLOCK_Gint \
119 }
120/*! @brief Clock ip name array for DMA. */
121#define DMA_CLOCKS \
122 { \
123 kCLOCK_Dma \
124 }
125/*! @brief Clock ip name array for CRC. */
126#define CRC_CLOCKS \
127 { \
128 kCLOCK_Crc \
129 }
130/*! @brief Clock ip name array for WWDT. */
131#define WWDT_CLOCKS \
132 { \
133 kCLOCK_Wwdt \
134 }
135/*! @brief Clock ip name array for RTC. */
136#define RTC_CLOCKS \
137 { \
138 kCLOCK_Rtc \
139 }
140/*! @brief Clock ip name array for ADC0. */
141#define ADC0_CLOCKS \
142 { \
143 kCLOCK_Adc0 \
144 }
145/*! @brief Clock ip name array for MRT. */
146#define MRT_CLOCKS \
147 { \
148 kCLOCK_Mrt \
149 }
150/*! @brief Clock ip name array for RIT. */
151#define RIT_CLOCKS \
152 { \
153 kCLOCK_Rit \
154 }
155/*! @brief Clock ip name array for SCT0. */
156#define SCT_CLOCKS \
157 { \
158 kCLOCK_Sct0 \
159 }
160/*! @brief Clock ip name array for MCAN. */
161#define MCAN_CLOCKS \
162 { \
163 kCLOCK_Mcan0, kCLOCK_Mcan1 \
164 }
165/*! @brief Clock ip name array for UTICK. */
166#define UTICK_CLOCKS \
167 { \
168 kCLOCK_Utick \
169 }
170/*! @brief Clock ip name array for FLEXCOMM. */
171#define FLEXCOMM_CLOCKS \
172 { \
173 kCLOCK_FlexComm0, kCLOCK_FlexComm1, kCLOCK_FlexComm2, kCLOCK_FlexComm3, kCLOCK_FlexComm4, kCLOCK_FlexComm5, \
174 kCLOCK_FlexComm6, kCLOCK_FlexComm7, kCLOCK_FlexComm8, kCLOCK_FlexComm9, kCLOCK_FlexComm10 \
175 }
176/*! @brief Clock ip name array for LPUART. */
177#define LPUART_CLOCKS \
178 { \
179 kCLOCK_MinUart0, kCLOCK_MinUart1, kCLOCK_MinUart2, kCLOCK_MinUart3, kCLOCK_MinUart4, kCLOCK_MinUart5, \
180 kCLOCK_MinUart6, kCLOCK_MinUart7, kCLOCK_MinUart8, kCLOCK_MinUart9 \
181 }
182
183/*! @brief Clock ip name array for BI2C. */
184#define BI2C_CLOCKS \
185 { \
186 kCLOCK_BI2c0, kCLOCK_BI2c1, kCLOCK_BI2c2, kCLOCK_BI2c3, kCLOCK_BI2c4, kCLOCK_BI2c5, kCLOCK_BI2c6, \
187 kCLOCK_BI2c7, kCLOCK_BI2c8, kCLOCK_BI2c9 \
188 }
189/*! @brief Clock ip name array for LSPI. */
190#define LPSI_CLOCKS \
191 { \
192 kCLOCK_LSpi0, kCLOCK_LSpi1, kCLOCK_LSpi2, kCLOCK_LSpi3, kCLOCK_LSpi4, kCLOCK_LSpi5, kCLOCK_LSpi6, \
193 kCLOCK_LSpi7, kCLOCK_LSpi8, kCLOCK_LSpi9 \
194 }
195/*! @brief Clock ip name array for FLEXI2S. */
196#define FLEXI2S_CLOCKS \
197 { \
198 kCLOCK_FlexI2s0, kCLOCK_FlexI2s1, kCLOCK_FlexI2s2, kCLOCK_FlexI2s3, kCLOCK_FlexI2s4, kCLOCK_FlexI2s5, \
199 kCLOCK_FlexI2s6, kCLOCK_FlexI2s7, kCLOCK_FlexI2s8, kCLOCK_FlexI2s9 \
200 }
201/*! @brief Clock ip name array for DMIC. */
202#define DMIC_CLOCKS \
203 { \
204 kCLOCK_DMic \
205 }
206/*! @brief Clock ip name array for CT32B. */
207#define CTIMER_CLOCKS \
208 { \
209 kCLOCK_Ct32b0, kCLOCK_Ct32b1, kCLOCK_Ct32b2, kCLOCK_Ct32b3, kCLOCK_Ct32b4 \
210 }
211/*! @brief Clock ip name array for LCD. */
212#define LCD_CLOCKS \
213 { \
214 kCLOCK_Lcd \
215 }
216/*! @brief Clock ip name array for SDIO. */
217#define SDIO_CLOCKS \
218 { \
219 kCLOCK_Sdio \
220 }
221/*! @brief Clock ip name array for USBRAM. */
222#define USBRAM_CLOCKS \
223 { \
224 kCLOCK_UsbRam1 \
225 }
226/*! @brief Clock ip name array for EMC. */
227#define EMC_CLOCKS \
228 { \
229 kCLOCK_Emc \
230 }
231/*! @brief Clock ip name array for ETH. */
232#define ETH_CLOCKS \
233 { \
234 kCLOCK_Eth \
235 }
236/*! @brief Clock ip name array for AES. */
237#define AES_CLOCKS \
238 { \
239 kCLOCK_Aes \
240 }
241/*! @brief Clock ip name array for OTP. */
242#define OTP_CLOCKS \
243 { \
244 kCLOCK_Otp \
245 }
246/*! @brief Clock ip name array for RNG. */
247#define RNG_CLOCKS \
248 { \
249 kCLOCK_Rng \
250 }
251/*! @brief Clock ip name array for USBHMR0. */
252#define USBHMR0_CLOCKS \
253 { \
254 kCLOCK_Usbhmr0 \
255 }
256/*! @brief Clock ip name array for USBHSL0. */
257#define USBHSL0_CLOCKS \
258 { \
259 kCLOCK_Usbhsl0 \
260 }
261/*! @brief Clock ip name array for SHA0. */
262#define SHA0_CLOCKS \
263 { \
264 kCLOCK_Sha0 \
265 }
266/*! @brief Clock ip name array for SMARTCARD. */
267#define SMARTCARD_CLOCKS \
268 { \
269 kCLOCK_SmartCard0, kCLOCK_SmartCard1 \
270 }
271/*! @brief Clock ip name array for USBD. */
272#define USBD_CLOCKS \
273 { \
274 kCLOCK_Usbd0, kCLOCK_Usbh1, kCLOCK_Usbd1 \
275 }
276/*! @brief Clock ip name array for USBH. */
277#define USBH_CLOCKS \
278 { \
279 kCLOCK_Usbh1 \
280 }
281/*! @brief Clock gate name used for CLOCK_EnableClock/CLOCK_DisableClock. */
282/*------------------------------------------------------------------------------
283 clock_ip_name_t definition:
284------------------------------------------------------------------------------*/
285
286#define CLK_GATE_REG_OFFSET_SHIFT 8U
287#define CLK_GATE_REG_OFFSET_MASK 0xFFFFFF00U
288#define CLK_GATE_BIT_SHIFT_SHIFT 0U
289#define CLK_GATE_BIT_SHIFT_MASK 0x000000FFU
290
291#define CLK_GATE_DEFINE(reg_offset, bit_shift) \
292 ((((reg_offset) << CLK_GATE_REG_OFFSET_SHIFT) & CLK_GATE_REG_OFFSET_MASK) | \
293 (((bit_shift) << CLK_GATE_BIT_SHIFT_SHIFT) & CLK_GATE_BIT_SHIFT_MASK))
294
295#define CLK_GATE_ABSTRACT_REG_OFFSET(x) (((uint32_t)(x)&CLK_GATE_REG_OFFSET_MASK) >> CLK_GATE_REG_OFFSET_SHIFT)
296#define CLK_GATE_ABSTRACT_BITS_SHIFT(x) (((uint32_t)(x)&CLK_GATE_BIT_SHIFT_MASK) >> CLK_GATE_BIT_SHIFT_SHIFT)
297
298#define AHB_CLK_CTRL0 0
299#define AHB_CLK_CTRL1 1
300#define AHB_CLK_CTRL2 2
301#define ASYNC_CLK_CTRL0 3
302
303/*! @brief Clock gate name used for CLOCK_EnableClock/CLOCK_DisableClock. */
304typedef enum _clock_ip_name
305{
306 kCLOCK_IpInvalid = 0U,
307 kCLOCK_Rom = CLK_GATE_DEFINE(AHB_CLK_CTRL0, 1),
308 kCLOCK_Sram1 = CLK_GATE_DEFINE(AHB_CLK_CTRL0, 3),
309 kCLOCK_Sram2 = CLK_GATE_DEFINE(AHB_CLK_CTRL0, 4),
310 kCLOCK_Sram3 = CLK_GATE_DEFINE(AHB_CLK_CTRL0, 5),
311 kCLOCK_Spifi = CLK_GATE_DEFINE(AHB_CLK_CTRL0, 10),
312 kCLOCK_InputMux = CLK_GATE_DEFINE(AHB_CLK_CTRL0, 11),
313 kCLOCK_Iocon = CLK_GATE_DEFINE(AHB_CLK_CTRL0, 13),
314 kCLOCK_Gpio0 = CLK_GATE_DEFINE(AHB_CLK_CTRL0, 14),
315 kCLOCK_Gpio1 = CLK_GATE_DEFINE(AHB_CLK_CTRL0, 15),
316 kCLOCK_Gpio2 = CLK_GATE_DEFINE(AHB_CLK_CTRL0, 16),
317 kCLOCK_Gpio3 = CLK_GATE_DEFINE(AHB_CLK_CTRL0, 17),
318 kCLOCK_Pint = CLK_GATE_DEFINE(AHB_CLK_CTRL0, 18),
319 kCLOCK_Gint = CLK_GATE_DEFINE(AHB_CLK_CTRL0, 19),
320 kCLOCK_Dma = CLK_GATE_DEFINE(AHB_CLK_CTRL0, 20),
321 kCLOCK_Crc = CLK_GATE_DEFINE(AHB_CLK_CTRL0, 21),
322 kCLOCK_Wwdt = CLK_GATE_DEFINE(AHB_CLK_CTRL0, 22),
323 kCLOCK_Rtc = CLK_GATE_DEFINE(AHB_CLK_CTRL0, 23),
324 kCLOCK_Adc0 = CLK_GATE_DEFINE(AHB_CLK_CTRL0, 27),
325 kCLOCK_Mrt = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 0),
326 kCLOCK_Rit = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 1),
327 kCLOCK_Sct0 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 2),
328 kCLOCK_Mcan0 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 7),
329 kCLOCK_Mcan1 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 8),
330 kCLOCK_Utick = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 10),
331 kCLOCK_FlexComm0 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 11),
332 kCLOCK_FlexComm1 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 12),
333 kCLOCK_FlexComm2 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 13),
334 kCLOCK_FlexComm3 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 14),
335 kCLOCK_FlexComm4 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 15),
336 kCLOCK_FlexComm5 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 16),
337 kCLOCK_FlexComm6 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 17),
338 kCLOCK_FlexComm7 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 18),
339 kCLOCK_MinUart0 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 11),
340 kCLOCK_MinUart1 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 12),
341 kCLOCK_MinUart2 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 13),
342 kCLOCK_MinUart3 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 14),
343 kCLOCK_MinUart4 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 15),
344 kCLOCK_MinUart5 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 16),
345 kCLOCK_MinUart6 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 17),
346 kCLOCK_MinUart7 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 18),
347 kCLOCK_LSpi0 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 11),
348 kCLOCK_LSpi1 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 12),
349 kCLOCK_LSpi2 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 13),
350 kCLOCK_LSpi3 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 14),
351 kCLOCK_LSpi4 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 15),
352 kCLOCK_LSpi5 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 16),
353 kCLOCK_LSpi6 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 17),
354 kCLOCK_LSpi7 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 18),
355 kCLOCK_BI2c0 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 11),
356 kCLOCK_BI2c1 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 12),
357 kCLOCK_BI2c2 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 13),
358 kCLOCK_BI2c3 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 14),
359 kCLOCK_BI2c4 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 15),
360 kCLOCK_BI2c5 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 16),
361 kCLOCK_BI2c6 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 17),
362 kCLOCK_BI2c7 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 18),
363 kCLOCK_FlexI2s0 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 11),
364 kCLOCK_FlexI2s1 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 12),
365 kCLOCK_FlexI2s2 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 13),
366 kCLOCK_FlexI2s3 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 14),
367 kCLOCK_FlexI2s4 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 15),
368 kCLOCK_FlexI2s5 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 16),
369 kCLOCK_FlexI2s6 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 17),
370 kCLOCK_FlexI2s7 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 18),
371 kCLOCK_DMic = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 19),
372 kCLOCK_Ct32b2 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 22),
373 kCLOCK_Usbd0 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 25),
374 kCLOCK_Ct32b0 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 26),
375 kCLOCK_Ct32b1 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 27),
376 kCLOCK_BodyBias0 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 29),
377 kCLOCK_EzhArchB0 = CLK_GATE_DEFINE(AHB_CLK_CTRL1, 31),
378 kCLOCK_Lcd = CLK_GATE_DEFINE(AHB_CLK_CTRL2, 2),
379 kCLOCK_Sdio = CLK_GATE_DEFINE(AHB_CLK_CTRL2, 3),
380 kCLOCK_Usbh1 = CLK_GATE_DEFINE(AHB_CLK_CTRL2, 4),
381 kCLOCK_Usbd1 = CLK_GATE_DEFINE(AHB_CLK_CTRL2, 5),
382 kCLOCK_UsbRam1 = CLK_GATE_DEFINE(AHB_CLK_CTRL2, 6),
383 kCLOCK_Emc = CLK_GATE_DEFINE(AHB_CLK_CTRL2, 7),
384 kCLOCK_Eth = CLK_GATE_DEFINE(AHB_CLK_CTRL2, 8),
385 kCLOCK_Gpio4 = CLK_GATE_DEFINE(AHB_CLK_CTRL2, 9),
386 kCLOCK_Gpio5 = CLK_GATE_DEFINE(AHB_CLK_CTRL2, 10),
387 kCLOCK_Aes = CLK_GATE_DEFINE(AHB_CLK_CTRL2, 11),
388 kCLOCK_Otp = CLK_GATE_DEFINE(AHB_CLK_CTRL2, 12),
389 kCLOCK_Rng = CLK_GATE_DEFINE(AHB_CLK_CTRL2, 13),
390 kCLOCK_FlexComm8 = CLK_GATE_DEFINE(AHB_CLK_CTRL2, 14),
391 kCLOCK_FlexComm9 = CLK_GATE_DEFINE(AHB_CLK_CTRL2, 15),
392 kCLOCK_MinUart8 = CLK_GATE_DEFINE(AHB_CLK_CTRL2, 14),
393 kCLOCK_MinUart9 = CLK_GATE_DEFINE(AHB_CLK_CTRL2, 15),
394 kCLOCK_LSpi8 = CLK_GATE_DEFINE(AHB_CLK_CTRL2, 14),
395 kCLOCK_LSpi9 = CLK_GATE_DEFINE(AHB_CLK_CTRL2, 15),
396 kCLOCK_BI2c8 = CLK_GATE_DEFINE(AHB_CLK_CTRL2, 14),
397 kCLOCK_BI2c9 = CLK_GATE_DEFINE(AHB_CLK_CTRL2, 15),
398 kCLOCK_FlexI2s8 = CLK_GATE_DEFINE(AHB_CLK_CTRL2, 14),
399 kCLOCK_FlexI2s9 = CLK_GATE_DEFINE(AHB_CLK_CTRL2, 15),
400 kCLOCK_Usbhmr0 = CLK_GATE_DEFINE(AHB_CLK_CTRL2, 16),
401 kCLOCK_Usbhsl0 = CLK_GATE_DEFINE(AHB_CLK_CTRL2, 17),
402 kCLOCK_Sha0 = CLK_GATE_DEFINE(AHB_CLK_CTRL2, 18),
403 kCLOCK_SmartCard0 = CLK_GATE_DEFINE(AHB_CLK_CTRL2, 19),
404 kCLOCK_SmartCard1 = CLK_GATE_DEFINE(AHB_CLK_CTRL2, 20),
405 kCLOCK_FlexComm10 = CLK_GATE_DEFINE(AHB_CLK_CTRL2, 21),
406 kCLOCK_Puf = CLK_GATE_DEFINE(AHB_CLK_CTRL2, 23),
407
408 kCLOCK_Ct32b3 = CLK_GATE_DEFINE(ASYNC_CLK_CTRL0, 13),
409 kCLOCK_Ct32b4 = CLK_GATE_DEFINE(ASYNC_CLK_CTRL0, 14)
410} clock_ip_name_t;
411
412/*! @brief Clock name used to get clock frequency. */
413typedef enum _clock_name
414{
415 kCLOCK_CoreSysClk, /*!< Core/system clock (aka MAIN_CLK) */
416 kCLOCK_BusClk, /*!< Bus clock (AHB clock) */
417 kCLOCK_ClockOut, /*!< CLOCKOUT */
418 kCLOCK_FroHf, /*!< FRO48/96 */
419 kCLOCK_UsbPll, /*!< USB1 PLL */
420 kCLOCK_Mclk, /*!< MCLK */
421 kCLOCK_Fro12M, /*!< FRO12M */
422 kCLOCK_ExtClk, /*!< External Clock */
423 kCLOCK_PllOut, /*!< PLL Output */
424 kCLOCK_UsbClk, /*!< USB input */
425 kCLOCK_WdtOsc, /*!< Watchdog Oscillator */
426 kCLOCK_Frg, /*!< Frg Clock */
427 kCLOCK_AsyncApbClk, /*!< Async APB clock */
428} clock_name_t;
429
430/**
431 * Clock source selections for the asynchronous APB clock
432 */
433typedef enum _async_clock_src
434{
435 kCLOCK_AsyncMainClk = 0, /*!< Main System clock */
436 kCLOCK_AsyncFro12Mhz, /*!< 12MHz FRO */
437 kCLOCK_AsyncAudioPllClk,
438 kCLOCK_AsyncI2cClkFc6,
439
440} async_clock_src_t;
441
442/*! @brief Clock Mux Switches
443 * The encoding is as follows each connection identified is 32bits wide while 24bits are valuable
444 * starting from LSB upwards
445 *
446 * [4 bits for choice, 0 means invalid choice] [8 bits mux ID]*
447 *
448 */
449
450#define CLK_ATTACH_ID(mux, sel, pos) ((((uint32_t)(mux) << 0U) | (((uint32_t)(sel) + 1U) & 0xFU) << 8U) << ((pos)*12U))
451#define MUX_A(mux, sel) CLK_ATTACH_ID((mux), (sel), 0U)
452#define MUX_B(mux, sel, selector) (CLK_ATTACH_ID((mux), (sel), 1U) | ((selector) << 24U))
453
454#define GET_ID_ITEM(connection) ((connection)&0xFFFU)
455#define GET_ID_NEXT_ITEM(connection) ((connection) >> 12U)
456#define GET_ID_ITEM_MUX(connection) ((uint8_t)((connection)&0xFFU))
457#define GET_ID_ITEM_SEL(connection) ((uint8_t)((((connection)&0xF00U) >> 8U) - 1U))
458#define GET_ID_SELECTOR(connection) ((connection)&0xF000000U)
459
460#define CM_STICKCLKSEL 0
461#define CM_MAINCLKSELA 1
462#define CM_MAINCLKSELB 2
463#define CM_CLKOUTCLKSELA 3
464#define CM_SYSPLLCLKSEL 5
465#define CM_AUDPLLCLKSEL 7
466#define CM_SPIFICLKSEL 9
467#define CM_ADCASYNCCLKSEL 10
468#define CM_USB0CLKSEL 11
469#define CM_USB1CLKSEL 12
470#define CM_FXCOMCLKSEL0 13
471#define CM_FXCOMCLKSEL1 14
472#define CM_FXCOMCLKSEL2 15
473#define CM_FXCOMCLKSEL3 16
474#define CM_FXCOMCLKSEL4 17
475#define CM_FXCOMCLKSEL5 18
476#define CM_FXCOMCLKSEL6 19
477#define CM_FXCOMCLKSEL7 20
478#define CM_FXCOMCLKSEL8 21
479#define CM_FXCOMCLKSEL9 22
480#define CM_FXCOMCLKSEL10 23
481#define CM_MCLKCLKSEL 25
482#define CM_FRGCLKSEL 27
483#define CM_DMICCLKSEL 28
484#define CM_SCTCLKSEL 29
485#define CM_LCDCLKSEL 30
486#define CM_SDIOCLKSEL 31
487
488#define CM_ASYNCAPB 32U
489
490typedef enum _clock_attach_id
491{
492
493 kSYSTICK_DIV_CLK_to_SYSTICKCLK = MUX_A(CM_STICKCLKSEL, 0),
494 kWDT_OSC_to_SYSTICKCLK = MUX_A(CM_STICKCLKSEL, 1),
495 kOSC32K_to_SYSTICKCLK = MUX_A(CM_STICKCLKSEL, 2),
496 kFRO12M_to_SYSTICKCLK = MUX_A(CM_STICKCLKSEL, 3),
497 kNONE_to_SYSTICKCLK = MUX_A(CM_STICKCLKSEL, 7),
498
499 kFRO12M_to_MAIN_CLK = MUX_A(CM_MAINCLKSELA, 0) | MUX_B(CM_MAINCLKSELB, 0, 0),
500 kEXT_CLK_to_MAIN_CLK = MUX_A(CM_MAINCLKSELA, 1) | MUX_B(CM_MAINCLKSELB, 0, 0),
501 kWDT_OSC_to_MAIN_CLK = MUX_A(CM_MAINCLKSELA, 2) | MUX_B(CM_MAINCLKSELB, 0, 0),
502 kFRO_HF_to_MAIN_CLK = MUX_A(CM_MAINCLKSELA, 3) | MUX_B(CM_MAINCLKSELB, 0, 0),
503 kSYS_PLL_to_MAIN_CLK = MUX_A(CM_MAINCLKSELA, 0) | MUX_B(CM_MAINCLKSELB, 2, 0),
504 kOSC32K_to_MAIN_CLK = MUX_A(CM_MAINCLKSELA, 0) | MUX_B(CM_MAINCLKSELB, 3, 0),
505
506 kMAIN_CLK_to_CLKOUT = MUX_A(CM_CLKOUTCLKSELA, 0),
507 kEXT_CLK_to_CLKOUT = MUX_A(CM_CLKOUTCLKSELA, 1),
508 kWDT_OSC_to_CLKOUT = MUX_A(CM_CLKOUTCLKSELA, 2),
509 kFRO_HF_to_CLKOUT = MUX_A(CM_CLKOUTCLKSELA, 3),
510 kSYS_PLL_to_CLKOUT = MUX_A(CM_CLKOUTCLKSELA, 4),
511 kUSB_PLL_to_CLKOUT = MUX_A(CM_CLKOUTCLKSELA, 5),
512 kAUDIO_PLL_to_CLKOUT = MUX_A(CM_CLKOUTCLKSELA, 6),
513 kOSC32K_OSC_to_CLKOUT = MUX_A(CM_CLKOUTCLKSELA, 7),
514
515 kFRO12M_to_SYS_PLL = MUX_A(CM_SYSPLLCLKSEL, 0),
516 kEXT_CLK_to_SYS_PLL = MUX_A(CM_SYSPLLCLKSEL, 1),
517 kWDT_OSC_to_SYS_PLL = MUX_A(CM_SYSPLLCLKSEL, 2),
518 kOSC32K_to_SYS_PLL = MUX_A(CM_SYSPLLCLKSEL, 3),
519 kNONE_to_SYS_PLL = MUX_A(CM_SYSPLLCLKSEL, 7),
520
521 kFRO12M_to_AUDIO_PLL = MUX_A(CM_AUDPLLCLKSEL, 0),
522 kEXT_CLK_to_AUDIO_PLL = MUX_A(CM_AUDPLLCLKSEL, 1),
523 kNONE_to_AUDIO_PLL = MUX_A(CM_AUDPLLCLKSEL, 7),
524
525 kMAIN_CLK_to_SPIFI_CLK = MUX_A(CM_SPIFICLKSEL, 0),
526 kSYS_PLL_to_SPIFI_CLK = MUX_A(CM_SPIFICLKSEL, 1),
527 kUSB_PLL_to_SPIFI_CLK = MUX_A(CM_SPIFICLKSEL, 2),
528 kFRO_HF_to_SPIFI_CLK = MUX_A(CM_SPIFICLKSEL, 3),
529 kAUDIO_PLL_to_SPIFI_CLK = MUX_A(CM_SPIFICLKSEL, 4),
530 kNONE_to_SPIFI_CLK = MUX_A(CM_SPIFICLKSEL, 7),
531
532 kFRO_HF_to_ADC_CLK = MUX_A(CM_ADCASYNCCLKSEL, 0),
533 kSYS_PLL_to_ADC_CLK = MUX_A(CM_ADCASYNCCLKSEL, 1),
534 kUSB_PLL_to_ADC_CLK = MUX_A(CM_ADCASYNCCLKSEL, 2),
535 kAUDIO_PLL_to_ADC_CLK = MUX_A(CM_ADCASYNCCLKSEL, 3),
536 kNONE_to_ADC_CLK = MUX_A(CM_ADCASYNCCLKSEL, 7),
537
538 kFRO_HF_to_USB0_CLK = MUX_A(CM_USB0CLKSEL, 0),
539 kSYS_PLL_to_USB0_CLK = MUX_A(CM_USB0CLKSEL, 1),
540 kUSB_PLL_to_USB0_CLK = MUX_A(CM_USB0CLKSEL, 2),
541 kNONE_to_USB0_CLK = MUX_A(CM_USB0CLKSEL, 7),
542
543 kFRO_HF_to_USB1_CLK = MUX_A(CM_USB1CLKSEL, 0),
544 kSYS_PLL_to_USB1_CLK = MUX_A(CM_USB1CLKSEL, 1),
545 kUSB_PLL_to_USB1_CLK = MUX_A(CM_USB1CLKSEL, 2),
546 kNONE_to_USB1_CLK = MUX_A(CM_USB1CLKSEL, 7),
547
548 kFRO12M_to_FLEXCOMM0 = MUX_A(CM_FXCOMCLKSEL0, 0),
549 kFRO_HF_to_FLEXCOMM0 = MUX_A(CM_FXCOMCLKSEL0, 1),
550 kAUDIO_PLL_to_FLEXCOMM0 = MUX_A(CM_FXCOMCLKSEL0, 2),
551 kMCLK_to_FLEXCOMM0 = MUX_A(CM_FXCOMCLKSEL0, 3),
552 kFRG_to_FLEXCOMM0 = MUX_A(CM_FXCOMCLKSEL0, 4),
553 kNONE_to_FLEXCOMM0 = MUX_A(CM_FXCOMCLKSEL0, 7),
554
555 kFRO12M_to_FLEXCOMM1 = MUX_A(CM_FXCOMCLKSEL1, 0),
556 kFRO_HF_to_FLEXCOMM1 = MUX_A(CM_FXCOMCLKSEL1, 1),
557 kAUDIO_PLL_to_FLEXCOMM1 = MUX_A(CM_FXCOMCLKSEL1, 2),
558 kMCLK_to_FLEXCOMM1 = MUX_A(CM_FXCOMCLKSEL1, 3),
559 kFRG_to_FLEXCOMM1 = MUX_A(CM_FXCOMCLKSEL1, 4),
560 kNONE_to_FLEXCOMM1 = MUX_A(CM_FXCOMCLKSEL1, 7),
561
562 kFRO12M_to_FLEXCOMM2 = MUX_A(CM_FXCOMCLKSEL2, 0),
563 kFRO_HF_to_FLEXCOMM2 = MUX_A(CM_FXCOMCLKSEL2, 1),
564 kAUDIO_PLL_to_FLEXCOMM2 = MUX_A(CM_FXCOMCLKSEL2, 2),
565 kMCLK_to_FLEXCOMM2 = MUX_A(CM_FXCOMCLKSEL2, 3),
566 kFRG_to_FLEXCOMM2 = MUX_A(CM_FXCOMCLKSEL2, 4),
567 kNONE_to_FLEXCOMM2 = MUX_A(CM_FXCOMCLKSEL2, 7),
568
569 kFRO12M_to_FLEXCOMM3 = MUX_A(CM_FXCOMCLKSEL3, 0),
570 kFRO_HF_to_FLEXCOMM3 = MUX_A(CM_FXCOMCLKSEL3, 1),
571 kAUDIO_PLL_to_FLEXCOMM3 = MUX_A(CM_FXCOMCLKSEL3, 2),
572 kMCLK_to_FLEXCOMM3 = MUX_A(CM_FXCOMCLKSEL3, 3),
573 kFRG_to_FLEXCOMM3 = MUX_A(CM_FXCOMCLKSEL3, 4),
574 kNONE_to_FLEXCOMM3 = MUX_A(CM_FXCOMCLKSEL3, 7),
575
576 kFRO12M_to_FLEXCOMM4 = MUX_A(CM_FXCOMCLKSEL4, 0),
577 kFRO_HF_to_FLEXCOMM4 = MUX_A(CM_FXCOMCLKSEL4, 1),
578 kAUDIO_PLL_to_FLEXCOMM4 = MUX_A(CM_FXCOMCLKSEL4, 2),
579 kMCLK_to_FLEXCOMM4 = MUX_A(CM_FXCOMCLKSEL4, 3),
580 kFRG_to_FLEXCOMM4 = MUX_A(CM_FXCOMCLKSEL4, 4),
581 kNONE_to_FLEXCOMM4 = MUX_A(CM_FXCOMCLKSEL4, 7),
582
583 kFRO12M_to_FLEXCOMM5 = MUX_A(CM_FXCOMCLKSEL5, 0),
584 kFRO_HF_to_FLEXCOMM5 = MUX_A(CM_FXCOMCLKSEL5, 1),
585 kAUDIO_PLL_to_FLEXCOMM5 = MUX_A(CM_FXCOMCLKSEL5, 2),
586 kMCLK_to_FLEXCOMM5 = MUX_A(CM_FXCOMCLKSEL5, 3),
587 kFRG_to_FLEXCOMM5 = MUX_A(CM_FXCOMCLKSEL5, 4),
588 kNONE_to_FLEXCOMM5 = MUX_A(CM_FXCOMCLKSEL5, 7),
589
590 kFRO12M_to_FLEXCOMM6 = MUX_A(CM_FXCOMCLKSEL6, 0),
591 kFRO_HF_to_FLEXCOMM6 = MUX_A(CM_FXCOMCLKSEL6, 1),
592 kAUDIO_PLL_to_FLEXCOMM6 = MUX_A(CM_FXCOMCLKSEL6, 2),
593 kMCLK_to_FLEXCOMM6 = MUX_A(CM_FXCOMCLKSEL6, 3),
594 kFRG_to_FLEXCOMM6 = MUX_A(CM_FXCOMCLKSEL6, 4),
595 kNONE_to_FLEXCOMM6 = MUX_A(CM_FXCOMCLKSEL6, 7),
596
597 kFRO12M_to_FLEXCOMM7 = MUX_A(CM_FXCOMCLKSEL7, 0),
598 kFRO_HF_to_FLEXCOMM7 = MUX_A(CM_FXCOMCLKSEL7, 1),
599 kAUDIO_PLL_to_FLEXCOMM7 = MUX_A(CM_FXCOMCLKSEL7, 2),
600 kMCLK_to_FLEXCOMM7 = MUX_A(CM_FXCOMCLKSEL7, 3),
601 kFRG_to_FLEXCOMM7 = MUX_A(CM_FXCOMCLKSEL7, 4),
602 kNONE_to_FLEXCOMM7 = MUX_A(CM_FXCOMCLKSEL7, 7),
603
604 kFRO12M_to_FLEXCOMM8 = MUX_A(CM_FXCOMCLKSEL8, 0),
605 kFRO_HF_to_FLEXCOMM8 = MUX_A(CM_FXCOMCLKSEL8, 1),
606 kAUDIO_PLL_to_FLEXCOMM8 = MUX_A(CM_FXCOMCLKSEL8, 2),
607 kMCLK_to_FLEXCOMM8 = MUX_A(CM_FXCOMCLKSEL8, 3),
608 kFRG_to_FLEXCOMM8 = MUX_A(CM_FXCOMCLKSEL8, 4),
609 kNONE_to_FLEXCOMM8 = MUX_A(CM_FXCOMCLKSEL8, 7),
610
611 kFRO12M_to_FLEXCOMM9 = MUX_A(CM_FXCOMCLKSEL9, 0),
612 kFRO_HF_to_FLEXCOMM9 = MUX_A(CM_FXCOMCLKSEL9, 1),
613 kAUDIO_PLL_to_FLEXCOMM9 = MUX_A(CM_FXCOMCLKSEL9, 2),
614 kMCLK_to_FLEXCOMM9 = MUX_A(CM_FXCOMCLKSEL9, 3),
615 kFRG_to_FLEXCOMM9 = MUX_A(CM_FXCOMCLKSEL9, 4),
616 kNONE_to_FLEXCOMM9 = MUX_A(CM_FXCOMCLKSEL9, 7),
617
618 kMAIN_CLK_to_FLEXCOMM10 = MUX_A(CM_FXCOMCLKSEL10, 0),
619 kSYS_PLL_to_FLEXCOMM10 = MUX_A(CM_FXCOMCLKSEL10, 1),
620 kUSB_PLL_to_FLEXCOMM10 = MUX_A(CM_FXCOMCLKSEL10, 2),
621 kFRO_HF_to_FLEXCOMM10 = MUX_A(CM_FXCOMCLKSEL10, 3),
622 kAUDIO_PLL_to_FLEXCOMM10 = MUX_A(CM_FXCOMCLKSEL10, 4),
623 kNONE_to_FLEXCOMM10 = MUX_A(CM_FXCOMCLKSEL10, 7),
624
625 kFRO_HF_to_MCLK = MUX_A(CM_MCLKCLKSEL, 0),
626 kAUDIO_PLL_to_MCLK = MUX_A(CM_MCLKCLKSEL, 1),
627 kNONE_to_MCLK = MUX_A(CM_MCLKCLKSEL, 7),
628
629 kMAIN_CLK_to_FRG = MUX_A(CM_FRGCLKSEL, 0),
630 kSYS_PLL_to_FRG = MUX_A(CM_FRGCLKSEL, 1),
631 kFRO12M_to_FRG = MUX_A(CM_FRGCLKSEL, 2),
632 kFRO_HF_to_FRG = MUX_A(CM_FRGCLKSEL, 3),
633 kNONE_to_FRG = MUX_A(CM_FRGCLKSEL, 7),
634
635 kFRO12M_to_DMIC = MUX_A(CM_DMICCLKSEL, 0),
636 kFRO_HF_DIV_to_DMIC = MUX_A(CM_DMICCLKSEL, 1),
637 kAUDIO_PLL_to_DMIC = MUX_A(CM_DMICCLKSEL, 2),
638 kMCLK_to_DMIC = MUX_A(CM_DMICCLKSEL, 3),
639 kMAIN_CLK_to_DMIC = MUX_A(CM_DMICCLKSEL, 4),
640 kWDT_OSC_to_DMIC = MUX_A(CM_DMICCLKSEL, 5),
641 kNONE_to_DMIC = MUX_A(CM_DMICCLKSEL, 7),
642
643 kMAIN_CLK_to_SCT_CLK = MUX_A(CM_SCTCLKSEL, 0),
644 kSYS_PLL_to_SCT_CLK = MUX_A(CM_SCTCLKSEL, 1),
645 kFRO_HF_to_SCT_CLK = MUX_A(CM_SCTCLKSEL, 2),
646 kAUDIO_PLL_to_SCT_CLK = MUX_A(CM_SCTCLKSEL, 3),
647 kNONE_to_SCT_CLK = MUX_A(CM_SCTCLKSEL, 7),
648
649 kMAIN_CLK_to_LCD_CLK = MUX_A(CM_LCDCLKSEL, 0),
650 kLCDCLKIN_to_LCD_CLK = MUX_A(CM_LCDCLKSEL, 1),
651 kFRO_HF_to_LCD_CLK = MUX_A(CM_LCDCLKSEL, 2),
652 kNONE_to_LCD_CLK = MUX_A(CM_LCDCLKSEL, 3),
653
654 kMAIN_CLK_to_SDIO_CLK = MUX_A(CM_SDIOCLKSEL, 0),
655 kSYS_PLL_to_SDIO_CLK = MUX_A(CM_SDIOCLKSEL, 1),
656 kUSB_PLL_to_SDIO_CLK = MUX_A(CM_SDIOCLKSEL, 2),
657 kFRO_HF_to_SDIO_CLK = MUX_A(CM_SDIOCLKSEL, 3),
658 kAUDIO_PLL_to_SDIO_CLK = MUX_A(CM_SDIOCLKSEL, 4),
659 kNONE_to_SDIO_CLK = MUX_A(CM_SDIOCLKSEL, 7),
660
661 kMAIN_CLK_to_ASYNC_APB = MUX_A(CM_ASYNCAPB, 0),
662 kFRO12M_to_ASYNC_APB = MUX_A(CM_ASYNCAPB, 1),
663 kAUDIO_PLL_to_ASYNC_APB = MUX_A(CM_ASYNCAPB, 2),
664 kI2C_CLK_FC6_to_ASYNC_APB = MUX_A(CM_ASYNCAPB, 3),
665 kNONE_to_NONE = (int)0x80000000U,
666} clock_attach_id_t;
667
668/* Clock dividers */
669typedef enum _clock_div_name
670{
671 kCLOCK_DivSystickClk = 0,
672 kCLOCK_DivArmTrClkDiv = 1,
673 kCLOCK_DivCan0Clk = 2,
674 kCLOCK_DivCan1Clk = 3,
675 kCLOCK_DivSmartCard0Clk = 4,
676 kCLOCK_DivSmartCard1Clk = 5,
677 kCLOCK_DivAhbClk = 32,
678 kCLOCK_DivClkOut = 33,
679 kCLOCK_DivFrohfClk = 34,
680 kCLOCK_DivSpifiClk = 36,
681 kCLOCK_DivAdcAsyncClk = 37,
682 kCLOCK_DivUsb0Clk = 38,
683 kCLOCK_DivUsb1Clk = 39,
684 kCLOCK_DivFrg = 40,
685 kCLOCK_DivDmicClk = 42,
686 kCLOCK_DivMClk = 43,
687 kCLOCK_DivLcdClk = 44,
688 kCLOCK_DivSctClk = 45,
689 kCLOCK_DivEmcClk = 46,
690 kCLOCK_DivSdioClk = 47
691} clock_div_name_t;
692
693/*******************************************************************************
694 * API
695 ******************************************************************************/
696
697#if defined(__cplusplus)
698extern "C" {
699#endif /* __cplusplus */
700
701static inline void CLOCK_EnableClock(clock_ip_name_t clk)
702{
703 uint32_t index = CLK_GATE_ABSTRACT_REG_OFFSET(clk);
704 if (index < 3UL)
705 {
706 SYSCON->AHBCLKCTRLSET[index] = (1UL << CLK_GATE_ABSTRACT_BITS_SHIFT(clk));
707 }
708 else
709 {
710 SYSCON->ASYNCAPBCTRL = SYSCON_ASYNCAPBCTRL_ENABLE(1);
711 ASYNC_SYSCON->ASYNCAPBCLKCTRLSET = (1UL << CLK_GATE_ABSTRACT_BITS_SHIFT(clk));
712 }
713}
714
715static inline void CLOCK_DisableClock(clock_ip_name_t clk)
716{
717 uint32_t index = CLK_GATE_ABSTRACT_REG_OFFSET(clk);
718 if (index < 3UL)
719 {
720 SYSCON->AHBCLKCTRLCLR[index] = (1UL << CLK_GATE_ABSTRACT_BITS_SHIFT(clk));
721 }
722 else
723 {
724 ASYNC_SYSCON->ASYNCAPBCLKCTRLCLR = (1UL << CLK_GATE_ABSTRACT_BITS_SHIFT(clk));
725 SYSCON->ASYNCAPBCTRL = SYSCON_ASYNCAPBCTRL_ENABLE(0);
726 }
727}
728
729/**
730 * @brief
731 * Initialize the Core clock to given frequency (12, 48 or 96 MHz), this API is implememnt in ROM code.
732 * Turns on FRO and uses default CCO, if freq is 12000000, then high speed output is off, else high speed
733 * output is enabled.
734 * Usage: CLOCK_SetupFROClocking(frequency), (frequency must be one of 12, 48 or 96 MHz)
735 * Note: Need to make sure ROM and OTP has power(PDRUNCFG0[17,29]= 0U) before calling this API since this API is
736 * implemented in ROM code and the FROHF TRIM value is stored in OTP
737 *
738 * @param froFreq target fro frequency.
739 * @return Nothing
740 */
741
742void CLOCK_SetupFROClocking(uint32_t froFreq);
743
744/**
745 * @brief Configure the clock selection muxes.
746 * @param connection : Clock to be configured.
747 * @return Nothing
748 */
749void CLOCK_AttachClk(clock_attach_id_t connection);
750/**
751 * @brief Get the actual clock attach id.
752 * This fuction uses the offset in input attach id, then it reads the actual source value in
753 * the register and combine the offset to obtain an actual attach id.
754 * @param attachId : Clock attach id to get.
755 * @return Clock source value.
756 */
757clock_attach_id_t CLOCK_GetClockAttachId(clock_attach_id_t attachId);
758/**
759 * @brief Setup peripheral clock dividers.
760 * @param div_name : Clock divider name
761 * @param divided_by_value: Value to be divided
762 * @param reset : Whether to reset the divider counter.
763 * @return Nothing
764 */
765void CLOCK_SetClkDiv(clock_div_name_t div_name, uint32_t divided_by_value, bool reset);
766
767/*! @brief Return Frequency of selected clock
768 * @return Frequency of selected clock
769 */
770uint32_t CLOCK_GetFreq(clock_name_t clockName);
771/*! @brief Return Frequency of FRO 12MHz
772 * @return Frequency of FRO 12MHz
773 */
774uint32_t CLOCK_GetFro12MFreq(void);
775/*! @brief Return Frequency of ClockOut
776 * @return Frequency of ClockOut
777 */
778uint32_t CLOCK_GetClockOutClkFreq(void);
779/*! @brief Return Frequency of Spifi Clock
780 * @return Frequency of Spifi.
781 */
782uint32_t CLOCK_GetSpifiClkFreq(void);
783/*! @brief Return Frequency of Adc Clock
784 * @return Frequency of Adc Clock.
785 */
786uint32_t CLOCK_GetAdcClkFreq(void);
787/*! brief Return Frequency of MCAN Clock
788 * param MCanSel : 0U: MCAN0; 1U: MCAN1
789 * return Frequency of MCAN Clock
790 */
791uint32_t CLOCK_GetMCanClkFreq(uint32_t MCanSel);
792/*! @brief Return Frequency of Usb0 Clock
793 * @return Frequency of Usb0 Clock.
794 */
795uint32_t CLOCK_GetUsb0ClkFreq(void);
796/*! @brief Return Frequency of Usb1 Clock
797 * @return Frequency of Usb1 Clock.
798 */
799uint32_t CLOCK_GetUsb1ClkFreq(void);
800/*! @brief Return Frequency of MClk Clock
801 * @return Frequency of MClk Clock.
802 */
803uint32_t CLOCK_GetMclkClkFreq(void);
804/*! @brief Return Frequency of SCTimer Clock
805 * @return Frequency of SCTimer Clock.
806 */
807uint32_t CLOCK_GetSctClkFreq(void);
808/*! @brief Return Frequency of SDIO Clock
809 * @return Frequency of SDIO Clock.
810 */
811uint32_t CLOCK_GetSdioClkFreq(void);
812/*! @brief Return Frequency of LCD Clock
813 * @return Frequency of LCD Clock.
814 */
815uint32_t CLOCK_GetLcdClkFreq(void);
816/*! @brief Return Frequency of LCD CLKIN Clock
817 * @return Frequency of LCD CLKIN Clock.
818 */
819uint32_t CLOCK_GetLcdClkIn(void);
820/*! @brief Return Frequency of External Clock
821 * @return Frequency of External Clock. If no external clock is used returns 0.
822 */
823uint32_t CLOCK_GetExtClkFreq(void);
824/*! @brief Return Frequency of Watchdog Oscillator
825 * @return Frequency of Watchdog Oscillator
826 */
827uint32_t CLOCK_GetWdtOscFreq(void);
828/*! @brief Return Frequency of High-Freq output of FRO
829 * @return Frequency of High-Freq output of FRO
830 */
831uint32_t CLOCK_GetFroHfFreq(void);
832/*! @brief Return Frequency of frg
833 * @return Frequency of FRG
834 */
835uint32_t CLOCK_GetFrgClkFreq(void);
836/*! @brief Return Frequency of dmic
837 * @return Frequency of DMIC
838 */
839uint32_t CLOCK_GetDmicClkFreq(void);
840
841/*!
842 * @brief Set FRG Clk
843 * @return
844 * 1: if set FRG CLK successfully.
845 * 0: if set FRG CLK fail.
846 */
847uint32_t CLOCK_SetFRGClock(uint32_t freq);
848
849/*! @brief Return Frequency of PLL
850 * @return Frequency of PLL
851 */
852uint32_t CLOCK_GetPllOutFreq(void);
853/*! @brief Return Frequency of USB PLL
854 * @return Frequency of PLL
855 */
856uint32_t CLOCK_GetUsbPllOutFreq(void);
857/*! @brief Return Frequency of AUDIO PLL
858 * @return Frequency of PLL
859 */
860uint32_t CLOCK_GetAudioPllOutFreq(void);
861/*! @brief Return Frequency of 32kHz osc
862 * @return Frequency of 32kHz osc
863 */
864uint32_t CLOCK_GetOsc32KFreq(void);
865/*! @brief Return Frequency of Core System
866 * @return Frequency of Core System
867 */
868uint32_t CLOCK_GetCoreSysClkFreq(void);
869/*! @brief Return Frequency of I2S MCLK Clock
870 * @return Frequency of I2S MCLK Clock
871 */
872uint32_t CLOCK_GetI2SMClkFreq(void);
873/*! @brief Return Frequency of Flexcomm functional Clock
874 * @return Frequency of Flexcomm functional Clock
875 */
876uint32_t CLOCK_GetFlexCommClkFreq(uint32_t id);
877
878/*! @brief return FRG Clk
879 * @return Frequency of FRG CLK.
880 */
881uint32_t CLOCK_GetFRGInputClock(void);
882/*! @brief Return Asynchronous APB Clock source
883 * @return Asynchronous APB CLock source
884 */
885__STATIC_INLINE async_clock_src_t CLOCK_GetAsyncApbClkSrc(void)
886{
887 return (async_clock_src_t)(uint32_t)(ASYNC_SYSCON->ASYNCAPBCLKSELA & 0x3U);
888}
889/*! @brief Return Frequency of Asynchronous APB Clock
890 * @return Frequency of Asynchronous APB Clock Clock
891 */
892uint32_t CLOCK_GetAsyncApbClkFreq(void);
893/*! @brief Return EMC source
894 * @return EMC source
895 */
896__STATIC_INLINE uint32_t CLOCK_GetEmcClkFreq(void)
897{
898 uint32_t freqtmp;
899
900 freqtmp = CLOCK_GetCoreSysClkFreq() / ((SYSCON->AHBCLKDIV & 0xffU) + 1U);
901 return freqtmp / ((SYSCON->EMCCLKDIV & 0xffU) + 1U);
902}
903/*! @brief Return Audio PLL input clock rate
904 * @return Audio PLL input clock rate
905 */
906uint32_t CLOCK_GetAudioPLLInClockRate(void);
907/*! @brief Return System PLL input clock rate
908 * @return System PLL input clock rate
909 */
910uint32_t CLOCK_GetSystemPLLInClockRate(void);
911
912/*! @brief Return System PLL output clock rate
913 * @param recompute : Forces a PLL rate recomputation if true
914 * @return System PLL output clock rate
915 * @note The PLL rate is cached in the driver in a variable as
916 * the rate computation function can take some time to perform. It
917 * is recommended to use 'false' with the 'recompute' parameter.
918 */
919uint32_t CLOCK_GetSystemPLLOutClockRate(bool recompute);
920
921/*! @brief Return System AUDIO PLL output clock rate
922 * @param recompute : Forces a AUDIO PLL rate recomputation if true
923 * @return System AUDIO PLL output clock rate
924 * @note The AUDIO PLL rate is cached in the driver in a variable as
925 * the rate computation function can take some time to perform. It
926 * is recommended to use 'false' with the 'recompute' parameter.
927 */
928uint32_t CLOCK_GetAudioPLLOutClockRate(bool recompute);
929
930/*! @brief Return System USB PLL output clock rate
931 * @param recompute : Forces a USB PLL rate recomputation if true
932 * @return System USB PLL output clock rate
933 * @note The USB PLL rate is cached in the driver in a variable as
934 * the rate computation function can take some time to perform. It
935 * is recommended to use 'false' with the 'recompute' parameter.
936 */
937uint32_t CLOCK_GetUsbPLLOutClockRate(bool recompute);
938
939/*! @brief Enables and disables PLL bypass mode
940 * @brief bypass : true to bypass PLL (PLL output = PLL input, false to disable bypass
941 * @return System PLL output clock rate
942 */
943__STATIC_INLINE void CLOCK_SetBypassPLL(bool bypass)
944{
945 if (bypass)
946 {
947 SYSCON->SYSPLLCTRL |= (1UL << SYSCON_SYSPLLCTRL_BYPASS_SHIFT);
948 }
949 else
950 {
951 SYSCON->SYSPLLCTRL &= ~(1UL << SYSCON_SYSPLLCTRL_BYPASS_SHIFT);
952 }
953}
954
955/*! @brief Check if PLL is locked or not
956 * @return true if the PLL is locked, false if not locked
957 */
958__STATIC_INLINE bool CLOCK_IsSystemPLLLocked(void)
959{
960 return (bool)((SYSCON->SYSPLLSTAT & SYSCON_SYSPLLSTAT_LOCK_MASK) != 0U);
961}
962
963/*! @brief Check if USB PLL is locked or not
964 * @return true if the USB PLL is locked, false if not locked
965 */
966__STATIC_INLINE bool CLOCK_IsUsbPLLLocked(void)
967{
968 return (bool)((SYSCON->USBPLLSTAT & SYSCON_USBPLLSTAT_LOCK_MASK) != 0U);
969}
970
971/*! @brief Check if AUDIO PLL is locked or not
972 * @return true if the AUDIO PLL is locked, false if not locked
973 */
974__STATIC_INLINE bool CLOCK_IsAudioPLLLocked(void)
975{
976 return (bool)((SYSCON->AUDPLLSTAT & SYSCON_AUDPLLSTAT_LOCK_MASK) != 0U);
977}
978
979/*! @brief Enables and disables SYS OSC
980 * @brief enable : true to enable SYS OSC, false to disable SYS OSC
981 */
982__STATIC_INLINE void CLOCK_Enable_SysOsc(bool enable)
983{
984 if (enable)
985 {
986 SYSCON->PDRUNCFGCLR[0] |= SYSCON_PDRUNCFG_PDEN_VD2_ANA_MASK;
987 SYSCON->PDRUNCFGCLR[1] |= SYSCON_PDRUNCFG_PDEN_SYSOSC_MASK;
988 }
989
990 else
991 {
992 SYSCON->PDRUNCFGSET[0] = SYSCON_PDRUNCFG_PDEN_VD2_ANA_MASK;
993 SYSCON->PDRUNCFGSET[1] = SYSCON_PDRUNCFG_PDEN_SYSOSC_MASK;
994 }
995}
996
997/*! @brief Store the current PLL rate
998 * @param rate: Current rate of the PLL
999 * @return Nothing
1000 **/
1001void CLOCK_SetStoredPLLClockRate(uint32_t rate);
1002
1003/*! @brief Store the current AUDIO PLL rate
1004 * @param rate: Current rate of the PLL
1005 * @return Nothing
1006 **/
1007void CLOCK_SetStoredAudioPLLClockRate(uint32_t rate);
1008
1009/*! @brief PLL configuration structure flags for 'flags' field
1010 * These flags control how the PLL configuration function sets up the PLL setup structure.<br>
1011 *
1012 * When the PLL_CONFIGFLAG_USEINRATE flag is selected, the 'InputRate' field in the
1013 * configuration structure must be assigned with the expected PLL frequency. If the
1014 * PLL_CONFIGFLAG_USEINRATE is not used, 'InputRate' is ignored in the configuration
1015 * function and the driver will determine the PLL rate from the currently selected
1016 * PLL source. This flag might be used to configure the PLL input clock more accurately
1017 * when using the WDT oscillator or a more dyanmic CLKIN source.<br>
1018 *
1019 * When the PLL_CONFIGFLAG_FORCENOFRACT flag is selected, the PLL hardware for the
1020 * automatic bandwidth selection, Spread Spectrum (SS) support, and fractional M-divider
1021 * are not used.<br>
1022 */
1023#define PLL_CONFIGFLAG_USEINRATE (1U << 0U) /*!< Flag to use InputRate in PLL configuration structure for setup */
1024#define PLL_CONFIGFLAG_FORCENOFRACT \
1025 (1U << 2U) /*!< Force non-fractional output mode, PLL output will not use the fractional, automatic bandwidth, or \
1026 SS hardware */
1027
1028/*! @brief PLL configuration structure
1029 *
1030 * This structure can be used to configure the settings for a PLL
1031 * setup structure. Fill in the desired configuration for the PLL
1032 * and call the PLL setup function to fill in a PLL setup structure.
1033 */
1034typedef struct _pll_config
1035{
1036 uint32_t desiredRate; /*!< Desired PLL rate in Hz */
1037 uint32_t inputRate; /*!< PLL input clock in Hz, only used if PLL_CONFIGFLAG_USEINRATE flag is set */
1038 uint32_t flags; /*!< PLL configuration flags, Or'ed value of PLL_CONFIGFLAG_* definitions */
1039} pll_config_t;
1040
1041/*! @brief PLL setup structure flags for 'flags' field
1042 * These flags control how the PLL setup function sets up the PLL
1043 */
1044#define PLL_SETUPFLAG_POWERUP (1U << 0U) /*!< Setup will power on the PLL after setup */
1045#define PLL_SETUPFLAG_WAITLOCK (1U << 1U) /*!< Setup will wait for PLL lock, implies the PLL will be pwoered on */
1046#define PLL_SETUPFLAG_ADGVOLT (1U << 2U) /*!< Optimize system voltage for the new PLL rate */
1047
1048/*! @brief PLL setup structure
1049 * This structure can be used to pre-build a PLL setup configuration
1050 * at run-time and quickly set the PLL to the configuration. It can be
1051 * populated with the PLL setup function. If powering up or waiting
1052 * for PLL lock, the PLL input clock source should be configured prior
1053 * to PLL setup.
1054 */
1055typedef struct _pll_setup
1056{
1057 uint32_t pllctrl; /*!< PLL control register SYSPLLCTRL */
1058 uint32_t pllndec; /*!< PLL NDEC register SYSPLLNDEC */
1059 uint32_t pllpdec; /*!< PLL PDEC register SYSPLLPDEC */
1060 uint32_t pllmdec; /*!< PLL MDEC registers SYSPLLPDEC */
1061 uint32_t pllRate; /*!< Acutal PLL rate */
1062 uint32_t audpllfrac; /*!< only aduio PLL has this function*/
1063 uint32_t flags; /*!< PLL setup flags, Or'ed value of PLL_SETUPFLAG_* definitions */
1064} pll_setup_t;
1065
1066/*! @brief PLL status definitions
1067 */
1068typedef enum _pll_error
1069{
1070 kStatus_PLL_Success = MAKE_STATUS(kStatusGroup_Generic, 0), /*!< PLL operation was successful */
1071 kStatus_PLL_OutputTooLow = MAKE_STATUS(kStatusGroup_Generic, 1), /*!< PLL output rate request was too low */
1072 kStatus_PLL_OutputTooHigh = MAKE_STATUS(kStatusGroup_Generic, 2), /*!< PLL output rate request was too high */
1073 kStatus_PLL_InputTooLow = MAKE_STATUS(kStatusGroup_Generic, 3), /*!< PLL input rate is too low */
1074 kStatus_PLL_InputTooHigh = MAKE_STATUS(kStatusGroup_Generic, 4), /*!< PLL input rate is too high */
1075 kStatus_PLL_OutsideIntLimit = MAKE_STATUS(kStatusGroup_Generic, 5), /*!< Requested output rate isn't possible */
1076 kStatus_PLL_CCOTooLow = MAKE_STATUS(kStatusGroup_Generic, 6), /*!< Requested CCO rate isn't possible */
1077 kStatus_PLL_CCOTooHigh = MAKE_STATUS(kStatusGroup_Generic, 7) /*!< Requested CCO rate isn't possible */
1078} pll_error_t;
1079
1080/*! @brief USB clock source definition. */
1081typedef enum _clock_usb_src
1082{
1083 kCLOCK_UsbSrcFro = (uint32_t)kCLOCK_FroHf, /*!< Use FRO 96 or 48 MHz. */
1084 kCLOCK_UsbSrcSystemPll = (uint32_t)kCLOCK_PllOut, /*!< Use System PLL output. */
1085 kCLOCK_UsbSrcMainClock = (uint32_t)kCLOCK_CoreSysClk, /*!< Use Main clock. */
1086 kCLOCK_UsbSrcUsbPll = (uint32_t)kCLOCK_UsbPll, /*!< Use USB PLL clock. */
1087
1088 kCLOCK_UsbSrcNone = SYSCON_USB0CLKSEL_SEL(
1089 7U) /*!< Use None, this may be selected in order to reduce power when no output is needed.. */
1090} clock_usb_src_t;
1091
1092/*! @brief USB PDEL Divider. */
1093typedef enum _usb_pll_psel
1094{
1095 pSel_Divide_1 = 0U,
1096 pSel_Divide_2,
1097 pSel_Divide_4,
1098 pSel_Divide_8
1099} usb_pll_psel;
1100
1101/*! @brief PLL setup structure
1102 * This structure can be used to pre-build a USB PLL setup configuration
1103 * at run-time and quickly set the usb PLL to the configuration. It can be
1104 * populated with the USB PLL setup function. If powering up or waiting
1105 * for USB PLL lock, the PLL input clock source should be configured prior
1106 * to USB PLL setup.
1107 */
1108typedef struct _usb_pll_setup
1109{
1110 uint8_t msel; /*!< USB PLL control register msel:1U-256U */
1111 uint8_t psel; /*!< USB PLL control register psel:only support inter 1U 2U 4U 8U */
1112 uint8_t nsel; /*!< USB PLL control register nsel:only suppoet inter 1U 2U 3U 4U */
1113 bool direct; /*!< USB PLL CCO output control */
1114 bool bypass; /*!< USB PLL inout clock bypass control */
1115 bool fbsel; /*!< USB PLL ineter mode and non-integer mode control*/
1116 uint32_t inputRate; /*!< USB PLL input rate */
1117} usb_pll_setup_t;
1118
1119/*! @brief Return System PLL output clock rate from setup structure
1120 * @param pSetup : Pointer to a PLL setup structure
1121 * @return System PLL output clock rate the setup structure will generate
1122 */
1123uint32_t CLOCK_GetSystemPLLOutFromSetup(pll_setup_t *pSetup);
1124
1125/*! @brief Return System AUDIO PLL output clock rate from setup structure
1126 * @param pSetup : Pointer to a PLL setup structure
1127 * @return System PLL output clock rate the setup structure will generate
1128 */
1129uint32_t CLOCK_GetAudioPLLOutFromSetup(pll_setup_t *pSetup);
1130
1131/*! @brief Return System AUDIO PLL output clock rate from audio fractioanl setup structure
1132 * @param pSetup : Pointer to a PLL setup structure
1133 * @return System PLL output clock rate the setup structure will generate
1134 */
1135uint32_t CLOCK_GetAudioPLLOutFromFractSetup(pll_setup_t *pSetup);
1136
1137/*! @brief Return System USB PLL output clock rate from setup structure
1138 * @param pSetup : Pointer to a PLL setup structure
1139 * @return System PLL output clock rate the setup structure will generate
1140 */
1141uint32_t CLOCK_GetUsbPLLOutFromSetup(const usb_pll_setup_t *pSetup);
1142
1143/*! @brief Set PLL output based on the passed PLL setup data
1144 * @param pControl : Pointer to populated PLL control structure to generate setup with
1145 * @param pSetup : Pointer to PLL setup structure to be filled
1146 * @return PLL_ERROR_SUCCESS on success, or PLL setup error code
1147 * @note Actual frequency for setup may vary from the desired frequency based on the
1148 * accuracy of input clocks, rounding, non-fractional PLL mode, etc.
1149 */
1150pll_error_t CLOCK_SetupPLLData(pll_config_t *pControl, pll_setup_t *pSetup);
1151
1152/*! @brief Set AUDIO PLL output based on the passed AUDIO PLL setup data
1153 * @param pControl : Pointer to populated PLL control structure to generate setup with
1154 * @param pSetup : Pointer to PLL setup structure to be filled
1155 * @return PLL_ERROR_SUCCESS on success, or PLL setup error code
1156 * @note Actual frequency for setup may vary from the desired frequency based on the
1157 * accuracy of input clocks, rounding, non-fractional PLL mode, etc.
1158 */
1159pll_error_t CLOCK_SetupAudioPLLData(pll_config_t *pControl, pll_setup_t *pSetup);
1160
1161/*! @brief Set PLL output from PLL setup structure (precise frequency)
1162 * @param pSetup : Pointer to populated PLL setup structure
1163 * @param flagcfg : Flag configuration for PLL config structure
1164 * @return PLL_ERROR_SUCCESS on success, or PLL setup error code
1165 * @note This function will power off the PLL, setup the PLL with the
1166 * new setup data, and then optionally powerup the PLL, wait for PLL lock,
1167 * and adjust system voltages to the new PLL rate. The function will not
1168 * alter any source clocks (ie, main systen clock) that may use the PLL,
1169 * so these should be setup prior to and after exiting the function.
1170 */
1171pll_error_t CLOCK_SetupSystemPLLPrec(pll_setup_t *pSetup, uint32_t flagcfg);
1172
1173/*! @brief Set AUDIO PLL output from AUDIOPLL setup structure (precise frequency)
1174 * @param pSetup : Pointer to populated PLL setup structure
1175 * @param flagcfg : Flag configuration for PLL config structure
1176 * @return PLL_ERROR_SUCCESS on success, or PLL setup error code
1177 * @note This function will power off the PLL, setup the PLL with the
1178 * new setup data, and then optionally powerup the AUDIO PLL, wait for PLL lock,
1179 * and adjust system voltages to the new AUDIOPLL rate. The function will not
1180 * alter any source clocks (ie, main systen clock) that may use the AUDIO PLL,
1181 * so these should be setup prior to and after exiting the function.
1182 */
1183pll_error_t CLOCK_SetupAudioPLLPrec(pll_setup_t *pSetup, uint32_t flagcfg);
1184
1185/*! @brief Set AUDIO PLL output from AUDIOPLL setup structure using the Audio Fractional divider register(precise
1186 * frequency)
1187 * @param pSetup : Pointer to populated PLL setup structure
1188 * @param flagcfg : Flag configuration for PLL config structure
1189 * @return PLL_ERROR_SUCCESS on success, or PLL setup error code
1190 * @note This function will power off the PLL, setup the PLL with the
1191 * new setup data, and then optionally powerup the AUDIO PLL, wait for PLL lock,
1192 * and adjust system voltages to the new AUDIOPLL rate. The function will not
1193 * alter any source clocks (ie, main systen clock) that may use the AUDIO PLL,
1194 * so these should be setup prior to and after exiting the function.
1195 */
1196pll_error_t CLOCK_SetupAudioPLLPrecFract(pll_setup_t *pSetup, uint32_t flagcfg);
1197
1198/**
1199 * @brief Set PLL output from PLL setup structure (precise frequency)
1200 * @param pSetup : Pointer to populated PLL setup structure
1201 * @return kStatus_PLL_Success on success, or PLL setup error code
1202 * @note This function will power off the PLL, setup the PLL with the
1203 * new setup data, and then optionally powerup the PLL, wait for PLL lock,
1204 * and adjust system voltages to the new PLL rate. The function will not
1205 * alter any source clocks (ie, main systen clock) that may use the PLL,
1206 * so these should be setup prior to and after exiting the function.
1207 */
1208pll_error_t CLOCK_SetPLLFreq(const pll_setup_t *pSetup);
1209
1210/**
1211 * @brief Set Audio PLL output from Audio PLL setup structure (precise frequency)
1212 * @param pSetup : Pointer to populated PLL setup structure
1213 * @return kStatus_PLL_Success on success, or Audio PLL setup error code
1214 * @note This function will power off the PLL, setup the Audio PLL with the
1215 * new setup data, and then optionally powerup the PLL, wait for Audio PLL lock,
1216 * and adjust system voltages to the new PLL rate. The function will not
1217 * alter any source clocks (ie, main systen clock) that may use the Audio PLL,
1218 * so these should be setup prior to and after exiting the function.
1219 */
1220pll_error_t CLOCK_SetAudioPLLFreq(const pll_setup_t *pSetup);
1221
1222/**
1223 * @brief Set USB PLL output from USB PLL setup structure (precise frequency)
1224 * @param pSetup : Pointer to populated USB PLL setup structure
1225 * @return kStatus_PLL_Success on success, or USB PLL setup error code
1226 * @note This function will power off the USB PLL, setup the PLL with the
1227 * new setup data, and then optionally powerup the USB PLL, wait for USB PLL lock,
1228 * and adjust system voltages to the new USB PLL rate. The function will not
1229 * alter any source clocks (ie, usb pll clock) that may use the USB PLL,
1230 * so these should be setup prior to and after exiting the function.
1231 */
1232pll_error_t CLOCK_SetUsbPLLFreq(const usb_pll_setup_t *pSetup);
1233
1234/*! @brief Set PLL output based on the multiplier and input frequency
1235 * @param multiply_by : multiplier
1236 * @param input_freq : Clock input frequency of the PLL
1237 * @return Nothing
1238 * @note Unlike the Chip_Clock_SetupSystemPLLPrec() function, this
1239 * function does not disable or enable PLL power, wait for PLL lock,
1240 * or adjust system voltages. These must be done in the application.
1241 * The function will not alter any source clocks (ie, main systen clock)
1242 * that may use the PLL, so these should be setup prior to and after
1243 * exiting the function.
1244 */
1245void CLOCK_SetupSystemPLLMult(uint32_t multiply_by, uint32_t input_freq);
1246
1247/*! @brief Disable USB clock.
1248 *
1249 * Disable USB clock.
1250 */
1251static inline void CLOCK_DisableUsbDevicefs0Clock(clock_ip_name_t clk)
1252{
1253 CLOCK_DisableClock(clk);
1254}
1255
1256/*! @brief Enable USB Device FS clock.
1257 * @param src : clock source
1258 * @param freq: clock frequency
1259 * Enable USB Device Full Speed clock.
1260 */
1261bool CLOCK_EnableUsbfs0DeviceClock(clock_usb_src_t src, uint32_t freq);
1262
1263/*! @brief Enable USB HOST FS clock.
1264 * @param src : clock source
1265 * @param freq: clock frequency
1266 * Enable USB HOST Full Speed clock.
1267 */
1268bool CLOCK_EnableUsbfs0HostClock(clock_usb_src_t src, uint32_t freq);
1269
1270/*! @brief Set the current Usb PLL Rate
1271 */
1272void CLOCK_SetStoredUsbPLLClockRate(uint32_t rate);
1273
1274/*! @brief Enable USB Device HS clock.
1275 * @param src : clock source
1276 * @param freq: clock frequency
1277 * Enable USB Device High Speed clock.
1278 */
1279bool CLOCK_EnableUsbhs0DeviceClock(clock_usb_src_t src, uint32_t freq);
1280
1281/*! @brief Enable USB HOST HS clock.
1282 * @param src : clock source
1283 * @param freq: clock frequency
1284 * Enable USB HOST High Speed clock.
1285 */
1286bool CLOCK_EnableUsbhs0HostClock(clock_usb_src_t src, uint32_t freq);
1287
1288#if defined(__cplusplus)
1289}
1290#endif /* __cplusplus */
1291
1292/*! @} */
1293
1294#endif /* _FSL_CLOCK_H_ */