]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | // SPDX-License-Identifier: GPL-2.0+ |
ddfeb0aa | 2 | /* |
de778115 | 3 | * Copyright (C) 2013-2017 Altera Corporation <www.altera.com> |
ddfeb0aa CLS |
4 | */ |
5 | ||
6 | #include <common.h> | |
09140113 | 7 | #include <command.h> |
691d719d | 8 | #include <init.h> |
de778115 | 9 | #include <wait_bit.h> |
ddfeb0aa CLS |
10 | #include <asm/io.h> |
11 | #include <asm/arch/clock_manager.h> | |
12 | ||
a832ddba PM |
13 | DECLARE_GLOBAL_DATA_PTR; |
14 | ||
de778115 | 15 | void cm_wait_for_lock(u32 mask) |
ddfeb0aa | 16 | { |
de778115 LFT |
17 | u32 inter_val; |
18 | u32 retry = 0; | |
ddfeb0aa | 19 | do { |
177ba1f9 | 20 | #if defined(CONFIG_TARGET_SOCFPGA_GEN5) |
94172c79 LFT |
21 | inter_val = readl(socfpga_get_clkmgr_addr() + |
22 | CLKMGR_INTER) & mask; | |
508791a0 | 23 | #else |
94172c79 LFT |
24 | inter_val = readl(socfpga_get_clkmgr_addr() + |
25 | CLKMGR_STAT) & mask; | |
177ba1f9 LFT |
26 | #endif |
27 | /* Wait for stable lock */ | |
036ba54f MV |
28 | if (inter_val == mask) |
29 | retry++; | |
30 | else | |
31 | retry = 0; | |
32 | if (retry >= 10) | |
33 | break; | |
34 | } while (1); | |
ddfeb0aa CLS |
35 | } |
36 | ||
37 | /* function to poll in the fsm busy bit */ | |
de778115 | 38 | int cm_wait_for_fsm(void) |
ddfeb0aa | 39 | { |
94172c79 LFT |
40 | return wait_for_bit_le32((const void *)(socfpga_get_clkmgr_addr() + |
41 | CLKMGR_STAT), CLKMGR_STAT_BUSY, false, 20000, | |
42 | false); | |
a832ddba PM |
43 | } |
44 | ||
45 | int set_cpu_clk_info(void) | |
46 | { | |
49e508e9 | 47 | #if defined(CONFIG_TARGET_SOCFPGA_GEN5) |
a832ddba PM |
48 | /* Calculate the clock frequencies required for drivers */ |
49 | cm_get_l4_sp_clk_hz(); | |
50 | cm_get_mmc_controller_clk_hz(); | |
49e508e9 | 51 | #endif |
a832ddba PM |
52 | |
53 | gd->bd->bi_arm_freq = cm_get_mpu_clk_hz() / 1000000; | |
54 | gd->bd->bi_dsp_freq = 0; | |
177ba1f9 LFT |
55 | |
56 | #if defined(CONFIG_TARGET_SOCFPGA_GEN5) | |
a832ddba | 57 | gd->bd->bi_ddr_freq = cm_get_sdram_clk_hz() / 1000000; |
508791a0 | 58 | #else |
177ba1f9 LFT |
59 | gd->bd->bi_ddr_freq = 0; |
60 | #endif | |
a832ddba PM |
61 | |
62 | return 0; | |
63 | } | |
64 | ||
b4b9814f | 65 | #ifndef CONFIG_SPL_BUILD |
09140113 SG |
66 | static int do_showclocks(struct cmd_tbl *cmdtp, int flag, int argc, |
67 | char *const argv[]) | |
a832ddba PM |
68 | { |
69 | cm_print_clock_quick_summary(); | |
70 | return 0; | |
71 | } | |
72 | ||
73 | U_BOOT_CMD( | |
74 | clocks, CONFIG_SYS_MAXARGS, 1, do_showclocks, | |
75 | "display clocks", | |
76 | "" | |
77 | ); | |
b4b9814f | 78 | #endif |