1  /*
2  * Copyright (C) 2017-2024 Alibaba Group Holding Limited
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #include <stdint.h>
20 #include <soc.h>
21 #include <sys_clk.h>
22 #include <drv/io.h>
23 
24 uint32_t g_system_clock = IHS_VALUE;
25 
26 #if CONFIG_BOARD_XIAOHUI_EVB
soc_get_cpu_freq(uint32_t idx)27 uint32_t soc_get_cpu_freq(uint32_t idx)
28 {
29     return 50*1000000;
30 }
31 
soc_get_coretim_freq(void)32 uint32_t soc_get_coretim_freq(void)
33 {
34     return 25*1000000;
35 }
36 
soc_get_uart_freq(uint32_t idx)37 uint32_t soc_get_uart_freq(uint32_t idx)
38 {
39     return 36*1000000;
40 }
41 
soc_get_timer_freq(uint32_t idx)42 uint32_t soc_get_timer_freq(uint32_t idx)
43 {
44     return 25*1000000;
45 }
46 
47 #else
soc_get_cpu_freq(uint32_t idx)48 uint32_t soc_get_cpu_freq(uint32_t idx)
49 {
50     return g_system_clock;
51 }
52 
soc_get_cur_cpu_freq(void)53 uint32_t soc_get_cur_cpu_freq(void)
54 {
55     return g_system_clock;
56 }
57 
soc_get_coretim_freq(void)58 uint32_t soc_get_coretim_freq(void)
59 {
60     return g_system_clock;
61 }
62 
soc_get_uart_freq(uint32_t idx)63 uint32_t soc_get_uart_freq(uint32_t idx)
64 {
65     return g_system_clock;
66 }
67 
soc_sysclk_config(system_clk_config_t * config)68 csi_error_t soc_sysclk_config(system_clk_config_t *config)
69 {
70     return CSI_OK;
71 }
72 
soc_reset_uart(uint32_t idx)73 void soc_reset_uart(uint32_t idx)
74 {
75 }
76 
soc_get_timer_freq(uint32_t idx)77 uint32_t soc_get_timer_freq(uint32_t idx)
78 {
79     return g_system_clock;
80 }
81 #endif
82 
soc_clk_enable(int32_t module)83 void soc_clk_enable(int32_t module)
84 {
85 }
86 
soc_clk_disable(int32_t module)87 void soc_clk_disable(int32_t module)
88 {
89 }
90 
soc_set_sys_freq(uint32_t val)91 void soc_set_sys_freq(uint32_t val)
92 {
93     g_system_clock = val;
94 }
95 
96 
97