1 /** 2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 * 15 * Description: Provides PM_Clock header \n 16 * 17 * History: \n 18 * 2023-01-11, Create file. \n 19 */ 20 21 #ifndef PM_CLOCK_H 22 #define PM_CLOCK_H 23 24 #include <stdbool.h> 25 #include "common_def.h" 26 #include "errcode.h" 27 #include "pm_clock_porting.h" 28 29 #ifdef __cplusplus 30 #if __cplusplus 31 extern "C" { 32 #endif /* __cplusplus */ 33 #endif /* __cplusplus */ 34 35 /** 36 * @defgroup drivers_driver_pm_clock PM Clock 37 * @ingroup drivers_driver_pm 38 * @{ 39 */ 40 41 #if defined(CONFIG_PM_SUPPORT_CLOCK_CRG_API) && (CONFIG_PM_SUPPORT_CLOCK_CRG_API == 1) 42 /** 43 * @if Eng 44 * @brief Config the common CRG CLOCK. 45 * @param [in] id The common CRG CLOCK ID. 46 * @param [in] clk_src The CLOCK source. 47 * @param [in] clk_div The CLOCK divider. 48 * @retval ERRCODE_SUCC Success. 49 * @retval Other Failure. For details, see @ref errcode_t. 50 * @else 51 * @brief 配置公共CRG时钟。 52 * @param [in] id 公共CRG时钟模块ID。 53 * @param [in] clk_src 时钟源。 54 * @param [in] clk_div 时钟分频系数。 55 * @retval ERRCODE_SUCC 成功。 56 * @retval Other 失败,参考 @ref errcode_t 。 57 * @endif 58 */ 59 errcode_t uapi_clock_crg_config(clock_crg_id_t id, clock_clk_src_t clk_src, uint8_t clk_div); 60 61 /** 62 * @if Eng 63 * @brief Get the common CRG CLOCK frequency. 64 * @param [in] id The common CRG CLOCK ID. 65 * @return The common CRG CLOCK frequency. 66 * @else 67 * @brief 获取公共CRG时钟模块频率。 68 * @param [in] id 公共CRG时钟模块ID。 69 * @return 公共CRG时钟模块频率。 70 * @endif 71 */ 72 uint32_t uapi_clock_crg_get_freq(clock_crg_id_t id); 73 #endif 74 75 /** 76 * @if Eng 77 * @brief Config the CLOCK gating. 78 * @param [in] id The CLOCK gating ID. 79 * @param [in] clk_en The CLOCK is enabled when the value is true. The CLOCK is disabled when the value is false. 80 * @else 81 * @brief 配置时钟门控。 82 * @param [in] id 时钟门控ID。 83 * @param [in] clk_en 当值为true时,时钟开启。当值为false时,时钟关闭。 84 * @endif 85 */ 86 void uapi_clock_clken_config(clock_clken_id_t id, bool clk_en); 87 88 /** 89 * @if Eng 90 * @brief Config the CLOCK selector. 91 * @param [in] id The CLOCK selector ID. 92 * @param [in] clk_sel Configured value of the CLOCK selector. 93 * @else 94 * @brief 配置时钟选择器。 95 * @param [in] id 时钟选择器ID。 96 * @param [in] clk_sel 时钟选择器配置值。 97 * @endif 98 */ 99 void uapi_clock_clksel_config(clock_clksel_id_t id, uint8_t clk_sel); 100 101 /** 102 * @if Eng 103 * @brief Config the CLOCK frequency divisor. 104 * @param [in] id The CLOCK divider ID. 105 * @param [in] clk_div The CLOCK frequency divisor. 106 * @else 107 * @brief 配置时钟分频系数。 108 * @param [in] id 时钟分频器ID。 109 * @param [in] clk_div 时钟频率分频系数。 110 * @endif 111 */ 112 void uapi_clock_clkdiv_config(clock_clkdiv_id_t id, uint8_t clk_div); 113 114 /** 115 * @if Eng 116 * @brief Get the CLOCK frequency divisor. 117 * @param [in] id The CLOCK divider ID. 118 * @return The CLOCK frequency divisor. 119 * @else 120 * @brief 获取时钟分频系数。 121 * @param [in] id 时钟分频器ID。 122 * @return 时钟分频系数。 123 * @endif 124 */ 125 uint8_t uapi_clock_get_clkdiv(clock_clkdiv_id_t id); 126 127 /** 128 * @if Eng 129 * @brief Clock control API. 130 * @param [in] type Clock control type. 131 * @param [in] param Clock control parameter. 132 * @retval ERRCODE_SUCC Success. 133 * @retval Other Failure. For details, see @ref errcode_t. 134 * @else 135 * @brief 时钟控制API。 136 * @param [in] type 时钟控制类型。 137 * @param [in] param 时钟控制参数。 138 * @retval ERRCODE_SUCC 成功。 139 * @retval Other 失败,参考 @ref errcode_t 。 140 * @endif 141 */ 142 errcode_t uapi_clock_control(clock_control_type_t type, uint8_t param); 143 144 /** 145 * @} 146 */ 147 148 #ifdef __cplusplus 149 #if __cplusplus 150 } 151 #endif /* __cplusplus */ 152 #endif /* __cplusplus */ 153 154 #endif 155