]>
Commit | Line | Data |
---|---|---|
1e9a164e DH |
1 | /* CPU specific code for the LEON3 CPU |
2 | * | |
e17c5200 FR |
3 | * (C) Copyright 2007, 2015 |
4 | * Daniel Hellstrom, Cobham Gaisler, daniel@gaisler.com | |
1e9a164e | 5 | * |
1a459660 | 6 | * SPDX-License-Identifier: GPL-2.0+ |
1e9a164e DH |
7 | */ |
8 | ||
9 | #include <common.h> | |
10 | #include <watchdog.h> | |
11 | #include <command.h> | |
89973f8a | 12 | #include <netdev.h> |
1e9a164e DH |
13 | |
14 | #include <asm/io.h> | |
15 | #include <asm/processor.h> | |
6c4359aa | 16 | #include <ambapp.h> |
1e9a164e DH |
17 | |
18 | DECLARE_GLOBAL_DATA_PTR; | |
19 | ||
20 | extern void _reset_reloc(void); | |
21 | ||
6c4359aa DH |
22 | int leon_cpu_cnt = 1; |
23 | int leon_ver = 3; | |
24 | unsigned int leon_cpu_freq = CONFIG_SYS_CLK_FREQ; | |
25 | ||
26 | int cpu_freq(void) | |
27 | { | |
28 | ambapp_ahbdev dev; | |
29 | ||
30 | if (leon_ver == 3) { | |
31 | ambapp_ahbmst_find(&ambapp_plb, VENDOR_GAISLER, | |
32 | GAISLER_LEON3, 0, &dev); | |
33 | } else { | |
34 | ambapp_ahbmst_find(&ambapp_plb, VENDOR_GAISLER, | |
35 | GAISLER_LEON4, 0, &dev); | |
36 | } | |
37 | ||
38 | leon_cpu_freq = ambapp_bus_freq(&ambapp_plb, dev.ahb_bus_index); | |
39 | ||
40 | return 0; | |
41 | } | |
42 | ||
1e9a164e DH |
43 | int checkcpu(void) |
44 | { | |
6c4359aa DH |
45 | int cnt; |
46 | char str[4]; | |
47 | ||
1e9a164e | 48 | /* check LEON version here */ |
6c4359aa DH |
49 | cnt = ambapp_ahbmst_count(&ambapp_plb, VENDOR_GAISLER, GAISLER_LEON3); |
50 | if (cnt <= 0) { | |
51 | cnt = ambapp_ahbmst_count(&ambapp_plb, VENDOR_GAISLER, | |
52 | GAISLER_LEON4); | |
53 | if (cnt > 0) | |
54 | leon_ver = 4; | |
55 | } | |
56 | ||
57 | cpu_freq(); | |
58 | ||
59 | str[0] = '\0'; | |
60 | if (cnt > 1) { | |
61 | leon_cpu_cnt = cnt; | |
62 | str[0] = '0' + cnt; | |
63 | str[1] = 'x'; | |
64 | str[2] = '\0'; | |
65 | } | |
66 | printf("CPU: %sLEON%d @ %dMHz\n", str, leon_ver, | |
67 | leon_cpu_freq / 1000000); | |
68 | ||
1e9a164e DH |
69 | return 0; |
70 | } | |
71 | ||
4c547754 FR |
72 | #ifdef CONFIG_DISPLAY_CPUINFO |
73 | ||
74 | int print_cpuinfo(void) | |
75 | { | |
76 | printf("CPU: LEON3\n"); | |
77 | return 0; | |
78 | } | |
79 | ||
80 | #endif | |
81 | ||
1e9a164e DH |
82 | /* ------------------------------------------------------------------------- */ |
83 | ||
84 | void cpu_reset(void) | |
85 | { | |
86 | /* Interrupts off */ | |
87 | disable_interrupts(); | |
88 | ||
89 | /* jump to restart in flash */ | |
90 | _reset_reloc(); | |
91 | } | |
92 | ||
54841ab5 | 93 | int do_reset(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) |
1e9a164e DH |
94 | { |
95 | cpu_reset(); | |
96 | ||
97 | return 1; | |
98 | ||
99 | } | |
100 | ||
101 | u64 flash_read64(void *addr) | |
102 | { | |
103 | return __raw_readq(addr); | |
104 | } | |
105 | ||
106 | /* ------------------------------------------------------------------------- */ | |
fc363ce3 BW |
107 | |
108 | #ifdef CONFIG_GRETH | |
109 | int cpu_eth_init(bd_t *bis) | |
110 | { | |
111 | return greth_initialize(bis); | |
112 | } | |
113 | #endif |