|
1 | 1 | /*
|
2 |
| - * Copyright 2022 NXP |
3 |
| - * All rights reserved. |
| 2 | + * Copyright 2024 NXP |
4 | 3 | *
|
5 | 4 | * SPDX-License-Identifier: BSD-3-Clause
|
6 | 5 | */
|
7 |
| -#include "hal_clock.h" |
8 | 6 | #include "fsl_clock.h"
|
9 |
| - |
10 |
| -/******************************************************************************* |
11 |
| - * Definitions |
12 |
| - ******************************************************************************/ |
13 |
| -volatile uint32_t g_clockSourceFreq[kCLOCK_LdbPll + 1]; |
14 |
| - |
15 |
| -uint32_t CLOCK_GetIpFreq(clock_root_t name) |
16 |
| -{ |
17 |
| - hal_clk_id_e clk_id = (hal_clk_id_e)(name + HAL_CLOCK_PLATFORM_SOURCE_NUM); |
18 |
| - return HAL_ClockGetIpFreq(clk_id); |
19 |
| -} |
20 |
| - |
21 |
| -/*! |
22 |
| - * @brief Get CCM Root Clock Source. |
23 |
| - * |
24 |
| - * @param root Which root clock node to get, see \ref clock_root_t. |
25 |
| - * @param src Clock mux value to get, see \ref clock_root_mux_source_t. |
26 |
| - * @return Clock source |
27 |
| - */ |
28 |
| -clock_name_t CLOCK_GetRootClockSource(clock_root_t root, uint32_t src) |
29 |
| -{ |
30 |
| - return s_clockSourceName[root][src]; |
31 |
| -} |
32 |
| - |
33 |
| - |
34 |
| -/*! |
35 |
| - * @brief Power Off Root Clock |
36 |
| - * |
37 |
| - * @param root Which root clock node to set, see \ref clock_root_t. |
38 |
| - */ |
39 |
| -void CLOCK_PowerOffRootClock(clock_root_t root) |
40 |
| -{ |
41 |
| - hal_clk_t hal_ClkCfg = { |
42 |
| - .clk_id = (hal_clk_id_e)(HAL_CLOCK_PLATFORM_SOURCE_NUM + root), |
43 |
| - .enable_clk = false, |
44 |
| - }; |
45 |
| - HAL_ClockSetRootClk(&hal_ClkCfg); |
46 |
| -} |
47 |
| - |
48 |
| -/*! |
49 |
| - * @brief Power On Root Clock |
50 |
| - * |
51 |
| - * @param root Which root clock node to set, see \ref clock_root_t. |
52 |
| - */ |
53 |
| -void CLOCK_PowerOnRootClock(clock_root_t root) |
54 |
| -{ |
55 |
| - hal_clk_t hal_ClkCfg = { |
56 |
| - .clk_id = (hal_clk_id_e)(HAL_CLOCK_PLATFORM_SOURCE_NUM + root), |
57 |
| - .enable_clk = true, |
58 |
| - }; |
59 |
| - HAL_ClockSetRootClk(&hal_ClkCfg); |
60 |
| -} |
61 |
| - |
62 |
| -/*! |
63 |
| - * @brief Configure Root Clock |
64 |
| - * |
65 |
| - * @param root Which root clock node to set, see \ref clock_root_t. |
66 |
| - * @param config root clock config, see \ref clock_root_config_t |
67 |
| - */ |
68 |
| -void CLOCK_SetRootClock(clock_root_t root, const clock_root_config_t *config) |
69 |
| -{ |
70 |
| - hal_clk_id_e pclk_id = (hal_clk_id_e)(CLOCK_GetRootClockSource(root, config->mux)); |
71 |
| - hal_clk_t hal_ClkCfg = { |
72 |
| - .clk_id = (hal_clk_id_e)(HAL_CLOCK_PLATFORM_SOURCE_NUM + root), |
73 |
| - .pclk_id = pclk_id, |
74 |
| - .div = config->div, |
75 |
| - .enable_clk = true, |
76 |
| - .clk_round_opt = hal_clk_round_auto, |
77 |
| - }; |
78 |
| - HAL_ClockSetRootClk(&hal_ClkCfg); |
79 |
| -} |
80 |
| - |
81 |
| -/*! |
82 |
| - * @brief Enable the clock for specific IP. |
83 |
| - * |
84 |
| - * @param name Which clock to enable, see \ref clock_lpcg_t. |
85 |
| - */ |
86 |
| -void CLOCK_EnableClock(clock_ip_name_t name) |
87 |
| -{ |
88 |
| - hal_clk_t hal_ClkCfg = { |
89 |
| - .clk_id = (hal_clk_id_e)(HAL_CLOCK_PLATFORM_SOURCE_NUM + name), |
90 |
| - .enable_clk = true, |
91 |
| - }; |
92 |
| - HAL_ClockSetRootClk(&hal_ClkCfg); |
93 |
| -} |
94 |
| - |
95 |
| -/*! |
96 |
| - * @brief Disable the clock for specific IP. |
97 |
| - * |
98 |
| - * @param name Which clock to disable, see \ref clock_lpcg_t. |
99 |
| - */ |
100 |
| -void CLOCK_DisableClock(clock_ip_name_t name) |
101 |
| -{ |
102 |
| - hal_clk_t hal_ClkCfg = { |
103 |
| - .clk_id = (hal_clk_id_e)(HAL_CLOCK_PLATFORM_SOURCE_NUM + name), |
104 |
| - .enable_clk = false, |
105 |
| - }; |
106 |
| - HAL_ClockSetRootClk(&hal_ClkCfg); |
107 |
| -} |
0 commit comments