1 /* 2 * Copyright (c) 2022 Winner Microelectronics 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 16 /** 17 * @file wm_cpu.h 18 * 19 * @brief cpu driver module 20 * 21 * @author dave 22 * 23 * @copyright (c) 2014 Winner Microelectronics Co., Ltd. 24 */ 25 #ifndef WM_CPU_H 26 #define WM_CPU_H 27 28 #include <stdint.h> 29 30 /**W800 BASE PLL CLOCK*/ 31 #define W800_PLL_CLK_MHZ (480) 32 33 enum CPU_CLK { 34 CPU_CLK_240M = 2, 35 CPU_CLK_160M = 3, 36 CPU_CLK_80M = 6, 37 CPU_CLK_40M = 12, 38 CPU_CLK_2M = 240, 39 }; 40 41 typedef union { 42 struct { 43 uint32_t CPU : 8; /*!< bit: 0.. 7 cpu clock divider */ 44 uint32_t WLAN : 8; /*!< bit: 8.. 15 Wlan clock divider */ 45 uint32_t BUS2 : 8; /*!< bit: 16.. 23 clock dividing ratio of bus2 & bus1 */ 46 uint32_t PD : 4; /*!< bit: 24.. 27 peripheral divider */ 47 uint32_t RSV : 3; /*!< bit: 28.. 30 Reserved */ 48 uint32_t DIV_EN : 1; /*!< bit: 31 divide frequency enable */ 49 } b; 50 uint32_t w; 51 } clk_div_reg; 52 53 #define UNIT_MHZ (1000000) 54 55 typedef struct { 56 u32 apbclk; 57 u32 cpuclk; 58 u32 wlanclk; 59 }tls_sys_clk; 60 61 /** 62 * @defgroup Driver_APIs Driver APIs 63 * @brief Driver APIs 64 */ 65 66 /** 67 * @addtogroup Driver_APIs 68 * @{ 69 */ 70 71 /** 72 * @defgroup CPUCLK_Driver_APIs CPU CLOCK Driver APIs 73 * @brief CPU CLOCK driver APIs 74 */ 75 76 /** 77 * @addtogroup CPUCLK_Driver_APIs 78 * @{ 79 */ 80 81 /** 82 * @brief This function is used to set cpu clock 83 * 84 * @param[in] clk select cpu clock 85 * clk == CPU_CLK_80M 80M 86 * clk == CPU_CLK_40M 40M 87 * 88 * @return None 89 * 90 * @note None 91 */ 92 void tls_sys_clk_set(u32 clk); 93 94 /** 95 * @brief This function is used to get cpu clock 96 * 97 * @param[out] *sysclk point to the addr for system clk output 98 * 99 * @return None 100 * 101 * @note None 102 */ 103 void tls_sys_clk_get(tls_sys_clk *sysclk); 104 105 /** 106 * @} 107 */ 108 109 /** 110 * @} 111 */ 112 113 #endif /* WM_CPU_H */ 114