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