* 获取CPU频率 * @ret CPU频率 */
| 66 | * @ret CPU频率 |
| 67 | */ |
| 68 | unsigned long clk_get_cpu_rate(void) |
| 69 | { |
| 70 | unsigned long pll_rate, cpu_rate; |
| 71 | unsigned int ctrl; |
| 72 | |
| 73 | pll_rate = clk_get_pll_rate(); |
| 74 | ctrl = reg_read_32((volatile unsigned int *)LS1C_CLK_DIV_PARAM); |
| 75 | |
| 76 | // 选择时钟来源 |
| 77 | if (DIV_CPU_SEL & ctrl) // pll分频作为时钟信号 |
| 78 | { |
| 79 | if (DIV_CPU_EN & ctrl) |
| 80 | { |
| 81 | cpu_rate = pll_rate / ((ctrl & DIV_CPU) >> DIV_CPU_SHIFT); |
| 82 | } |
| 83 | else |
| 84 | { |
| 85 | cpu_rate = pll_rate / 2; |
| 86 | } |
| 87 | } |
| 88 | else // bypass模式,晶振作为时钟输入 |
| 89 | { |
| 90 | cpu_rate = APB_CLK; |
| 91 | } |
| 92 | |
| 93 | return cpu_rate; |
| 94 | } |
| 95 | |
| 96 | |
| 97 | /* |
no test coverage detected