1 /* 2 * Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved. 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 #ifndef __HAL_SYSFREQ_H__ 16 #define __HAL_SYSFREQ_H__ 17 18 #ifdef __cplusplus 19 extern "C" { 20 #endif 21 22 #include "hal_cmu.h" 23 24 enum HAL_SYSFREQ_USER_T { 25 HAL_SYSFREQ_USER_INIT, 26 HAL_SYSFREQ_USER_OVERLAY, 27 HAL_SYSFREQ_USER_USB, 28 HAL_SYSFREQ_USER_BT, 29 HAL_SYSFREQ_USER_ANC, 30 HAL_SYSFREQ_USER_WIFI, 31 HAL_SYSFREQ_USER_TRNG, 32 HAL_SYSFREQ_USER_APP_0, 33 HAL_SYSFREQ_USER_APP_1, 34 HAL_SYSFREQ_USER_APP_2, 35 HAL_SYSFREQ_USER_APP_3, 36 HAL_SYSFREQ_USER_APP_4, 37 HAL_SYSFREQ_USER_APP_5, 38 HAL_SYSFREQ_USER_APP_6, 39 HAL_SYSFREQ_USER_APP_7, 40 HAL_SYSFREQ_USER_APP_8, 41 HAL_SYSFREQ_USER_APP_9, 42 HAL_SYSFREQ_USER_APP_10, 43 HAL_SYSFREQ_USER_APP_11, 44 HAL_SYSFREQ_USER_APP_12, 45 HAL_SYSFREQ_USER_APP_13, 46 HAL_SYSFREQ_USER_APP_14, 47 HAL_SYSFREQ_USER_APP_15, 48 49 HAL_SYSFREQ_USER_QTY 50 }; 51 52 void hal_sysfreq_set_min_freq(enum HAL_CMU_FREQ_T freq); 53 54 int hal_sysfreq_req(enum HAL_SYSFREQ_USER_T user, enum HAL_CMU_FREQ_T freq); 55 56 enum HAL_CMU_FREQ_T hal_sysfreq_get(void); 57 58 enum HAL_CMU_FREQ_T hal_sysfreq_get_hw_freq(void); 59 60 int hal_sysfreq_busy(void); 61 62 void hal_sysfreq_print_user_freq(void); 63 64 void hal_sysfreq_add_freq_time(int idle, uint32_t cur_time); 65 66 void hal_sysfreq_print_freq_stats(void); 67 68 #ifdef __cplusplus 69 } 70 #endif 71 72 #endif 73 74