]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | // SPDX-License-Identifier: GPL-2.0+ |
f046ccd1 | 2 | /* |
03051c3d | 3 | * Copyright (C) 2004-2007 Freescale Semiconductor, Inc. |
f046ccd1 EL |
4 | */ |
5 | ||
6 | /* | |
7 | * CPU specific code for the MPC83xx family. | |
8 | * | |
9 | * Derived from the MPC8260 and MPC85xx. | |
10 | */ | |
11 | ||
12 | #include <common.h> | |
30c7c434 | 13 | #include <cpu_func.h> |
36bf446b | 14 | #include <irq_func.h> |
90526e9f | 15 | #include <net.h> |
049f8d6f | 16 | #include <time.h> |
2189d5f1 | 17 | #include <vsprintf.h> |
f046ccd1 EL |
18 | #include <watchdog.h> |
19 | #include <command.h> | |
20 | #include <mpc83xx.h> | |
21 | #include <asm/processor.h> | |
b08c8c48 | 22 | #include <linux/libfdt.h> |
75b9d4ae | 23 | #include <tsec.h> |
0e8454e9 | 24 | #include <netdev.h> |
e1ac387f | 25 | #include <fsl_esdhc.h> |
9403fc41 | 26 | #if defined(CONFIG_BOOTCOUNT_LIMIT) && !defined(CONFIG_ARCH_MPC831X) |
38d67a4e | 27 | #include <linux/immap_qe.h> |
f70fd13e HS |
28 | #include <asm/io.h> |
29 | #endif | |
f046ccd1 | 30 | |
d87080b7 WD |
31 | DECLARE_GLOBAL_DATA_PTR; |
32 | ||
19fbdca4 | 33 | #ifndef CONFIG_CPU_MPC83XX |
f046ccd1 EL |
34 | int checkcpu(void) |
35 | { | |
5f820439 | 36 | volatile immap_t *immr; |
f046ccd1 EL |
37 | ulong clock = gd->cpu_clk; |
38 | u32 pvr = get_pvr(); | |
5f820439 | 39 | u32 spridr; |
f046ccd1 | 40 | char buf[32]; |
d891ab95 | 41 | int ret; |
e5c4ade4 KP |
42 | int i; |
43 | ||
e5c4ade4 KP |
44 | const struct cpu_type { |
45 | char name[15]; | |
46 | u32 partid; | |
47 | } cpu_type_list [] = { | |
7c619ddc | 48 | CPU_TYPE_ENTRY(8308), |
a88731a6 | 49 | CPU_TYPE_ENTRY(8309), |
e5c4ade4 KP |
50 | CPU_TYPE_ENTRY(8311), |
51 | CPU_TYPE_ENTRY(8313), | |
52 | CPU_TYPE_ENTRY(8314), | |
53 | CPU_TYPE_ENTRY(8315), | |
54 | CPU_TYPE_ENTRY(8321), | |
55 | CPU_TYPE_ENTRY(8323), | |
56 | CPU_TYPE_ENTRY(8343), | |
57 | CPU_TYPE_ENTRY(8347_TBGA_), | |
58 | CPU_TYPE_ENTRY(8347_PBGA_), | |
59 | CPU_TYPE_ENTRY(8349), | |
60 | CPU_TYPE_ENTRY(8358_TBGA_), | |
61 | CPU_TYPE_ENTRY(8358_PBGA_), | |
62 | CPU_TYPE_ENTRY(8360), | |
63 | CPU_TYPE_ENTRY(8377), | |
64 | CPU_TYPE_ENTRY(8378), | |
65 | CPU_TYPE_ENTRY(8379), | |
66 | }; | |
f046ccd1 | 67 | |
6d0f6bcf | 68 | immr = (immap_t *)CONFIG_SYS_IMMR; |
5f820439 | 69 | |
d891ab95 SG |
70 | ret = prt_83xx_rsr(); |
71 | if (ret) | |
72 | return ret; | |
73 | ||
54b2d434 | 74 | puts("CPU: "); |
95e7ef89 SW |
75 | |
76 | switch (pvr & 0xffff0000) { | |
77 | case PVR_E300C1: | |
78 | printf("e300c1, "); | |
79 | break; | |
80 | ||
81 | case PVR_E300C2: | |
82 | printf("e300c2, "); | |
83 | break; | |
84 | ||
85 | case PVR_E300C3: | |
86 | printf("e300c3, "); | |
87 | break; | |
88 | ||
03051c3d DL |
89 | case PVR_E300C4: |
90 | printf("e300c4, "); | |
91 | break; | |
92 | ||
95e7ef89 SW |
93 | default: |
94 | printf("Unknown core, "); | |
f046ccd1 EL |
95 | } |
96 | ||
5f820439 | 97 | spridr = immr->sysconf.spridr; |
6902df56 | 98 | |
e5c4ade4 KP |
99 | for (i = 0; i < ARRAY_SIZE(cpu_type_list); i++) |
100 | if (cpu_type_list[i].partid == PARTID_NO_E(spridr)) { | |
101 | puts("MPC"); | |
102 | puts(cpu_type_list[i].name); | |
103 | if (IS_E_PROCESSOR(spridr)) | |
104 | puts("E"); | |
dfe812c7 KP |
105 | if ((SPR_FAMILY(spridr) == SPR_834X_FAMILY || |
106 | SPR_FAMILY(spridr) == SPR_836X_FAMILY) && | |
107 | REVID_MAJOR(spridr) >= 2) | |
e5c4ade4 KP |
108 | puts("A"); |
109 | printf(", Rev: %d.%d", REVID_MAJOR(spridr), | |
110 | REVID_MINOR(spridr)); | |
111 | break; | |
112 | } | |
113 | ||
114 | if (i == ARRAY_SIZE(cpu_type_list)) | |
115 | printf("(SPRIDR %08x unknown), ", spridr); | |
116 | ||
117 | printf(" at %s MHz, ", strmhz(buf, clock)); | |
118 | ||
c6731fe2 | 119 | printf("CSB: %s MHz\n", strmhz(buf, gd->arch.csb_clk)); |
54b2d434 | 120 | |
f046ccd1 EL |
121 | return 0; |
122 | } | |
19fbdca4 | 123 | #endif |
f046ccd1 | 124 | |
76fdad1f | 125 | #ifndef CONFIG_SYSRESET |
f046ccd1 | 126 | int |
54841ab5 | 127 | do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) |
f046ccd1 | 128 | { |
07a2505f WD |
129 | ulong msr; |
130 | #ifndef MPC83xx_RESET | |
131 | ulong addr; | |
132 | #endif | |
f046ccd1 | 133 | |
6d0f6bcf | 134 | volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; |
f046ccd1 | 135 | |
4c006dd1 MZ |
136 | puts("Resetting the board.\n"); |
137 | ||
f046ccd1 | 138 | #ifdef MPC83xx_RESET |
4c006dd1 | 139 | |
f046ccd1 | 140 | /* Interrupts and MMU off */ |
5c229985 MS |
141 | msr = mfmsr(); |
142 | msr &= ~(MSR_EE | MSR_IR | MSR_DR); | |
143 | mtmsr(msr); | |
f046ccd1 EL |
144 | |
145 | /* enable Reset Control Reg */ | |
146 | immap->reset.rpr = 0x52535445; | |
5c229985 MS |
147 | sync(); |
148 | isync(); | |
f046ccd1 EL |
149 | |
150 | /* confirm Reset Control Reg is enabled */ | |
5c229985 MS |
151 | while(!((immap->reset.rcer) & RCER_CRE)) |
152 | ; | |
f046ccd1 | 153 | |
f046ccd1 EL |
154 | udelay(200); |
155 | ||
156 | /* perform reset, only one bit */ | |
07a2505f WD |
157 | immap->reset.rcr = RCR_SWHR; |
158 | ||
159 | #else /* ! MPC83xx_RESET */ | |
f046ccd1 | 160 | |
07a2505f WD |
161 | immap->reset.rmr = RMR_CSRE; /* Checkstop Reset enable */ |
162 | ||
163 | /* Interrupts and MMU off */ | |
5c229985 | 164 | msr = mfmsr(); |
f046ccd1 | 165 | msr &= ~(MSR_ME | MSR_EE | MSR_IR | MSR_DR); |
5c229985 | 166 | mtmsr(msr); |
f046ccd1 EL |
167 | |
168 | /* | |
169 | * Trying to execute the next instruction at a non-existing address | |
170 | * should cause a machine check, resulting in reset | |
171 | */ | |
6d0f6bcf | 172 | addr = CONFIG_SYS_RESET_ADDRESS; |
f046ccd1 | 173 | |
f046ccd1 | 174 | ((void (*)(void)) addr) (); |
07a2505f WD |
175 | #endif /* MPC83xx_RESET */ |
176 | ||
f046ccd1 EL |
177 | return 1; |
178 | } | |
76fdad1f | 179 | #endif |
f046ccd1 EL |
180 | |
181 | /* | |
182 | * Get timebase clock frequency (like cpu_clk in Hz) | |
183 | */ | |
2c21749d | 184 | #ifndef CONFIG_TIMER |
f046ccd1 EL |
185 | unsigned long get_tbclk(void) |
186 | { | |
63a7578e | 187 | return (gd->bus_clk + 3L) / 4L; |
f046ccd1 | 188 | } |
2c21749d | 189 | #endif |
f046ccd1 EL |
190 | |
191 | #if defined(CONFIG_WATCHDOG) | |
192 | void watchdog_reset (void) | |
193 | { | |
2ad6b513 TT |
194 | int re_enable = disable_interrupts(); |
195 | ||
196 | /* Reset the 83xx watchdog */ | |
6d0f6bcf | 197 | volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR; |
2ad6b513 TT |
198 | immr->wdt.swsrr = 0x556c; |
199 | immr->wdt.swsrr = 0xaa39; | |
200 | ||
201 | if (re_enable) | |
9d3915b2 | 202 | enable_interrupts(); |
f046ccd1 | 203 | } |
2ad6b513 | 204 | #endif |
62ec6418 | 205 | |
8835836a | 206 | #ifndef CONFIG_DM_ETH |
75b9d4ae AF |
207 | /* |
208 | * Initializes on-chip ethernet controllers. | |
209 | * to override, implement board_eth_init() | |
dd35479a | 210 | */ |
dd35479a BW |
211 | int cpu_eth_init(bd_t *bis) |
212 | { | |
8e55258f HW |
213 | #if defined(CONFIG_UEC_ETH) |
214 | uec_standard_init(bis); | |
0e8454e9 | 215 | #endif |
8e55258f | 216 | |
75b9d4ae AF |
217 | #if defined(CONFIG_TSEC_ENET) |
218 | tsec_standard_init(bis); | |
dd35479a BW |
219 | #endif |
220 | return 0; | |
221 | } | |
8835836a | 222 | #endif /* !CONFIG_DM_ETH */ |
e1ac387f AF |
223 | |
224 | /* | |
225 | * Initializes on-chip MMC controllers. | |
226 | * to override, implement board_mmc_init() | |
227 | */ | |
228 | int cpu_mmc_init(bd_t *bis) | |
229 | { | |
230 | #ifdef CONFIG_FSL_ESDHC | |
231 | return fsl_esdhc_mmc_init(bis); | |
232 | #else | |
233 | return 0; | |
234 | #endif | |
235 | } | |
1e718f43 MS |
236 | |
237 | void ppcDWstore(unsigned int *addr, unsigned int *value) | |
238 | { | |
239 | asm("lfd 1, 0(%1)\n\t" | |
240 | "stfd 1, 0(%0)" | |
241 | : | |
242 | : "r" (addr), "r" (value) | |
243 | : "memory"); | |
244 | } | |
245 | ||
246 | void ppcDWload(unsigned int *addr, unsigned int *ret) | |
247 | { | |
248 | asm("lfd 1, 0(%0)\n\t" | |
249 | "stfd 1, 0(%1)" | |
250 | : | |
251 | : "r" (addr), "r" (ret) | |
252 | : "memory"); | |
253 | } |