1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29#include <common.h>
30#include <watchdog.h>
31#include <command.h>
32#include <mpc83xx.h>
33#include <asm/processor.h>
34#include <libfdt.h>
35#include <tsec.h>
36#include <netdev.h>
37#include <fsl_esdhc.h>
38#ifdef CONFIG_BOOTCOUNT_LIMIT
39#include <asm/immap_qe.h>
40#include <asm/io.h>
41#endif
42
43DECLARE_GLOBAL_DATA_PTR;
44
45int checkcpu(void)
46{
47 volatile immap_t *immr;
48 ulong clock = gd->cpu_clk;
49 u32 pvr = get_pvr();
50 u32 spridr;
51 char buf[32];
52 int i;
53
54 const struct cpu_type {
55 char name[15];
56 u32 partid;
57 } cpu_type_list [] = {
58 CPU_TYPE_ENTRY(8311),
59 CPU_TYPE_ENTRY(8313),
60 CPU_TYPE_ENTRY(8314),
61 CPU_TYPE_ENTRY(8315),
62 CPU_TYPE_ENTRY(8321),
63 CPU_TYPE_ENTRY(8323),
64 CPU_TYPE_ENTRY(8343),
65 CPU_TYPE_ENTRY(8347_TBGA_),
66 CPU_TYPE_ENTRY(8347_PBGA_),
67 CPU_TYPE_ENTRY(8349),
68 CPU_TYPE_ENTRY(8358_TBGA_),
69 CPU_TYPE_ENTRY(8358_PBGA_),
70 CPU_TYPE_ENTRY(8360),
71 CPU_TYPE_ENTRY(8377),
72 CPU_TYPE_ENTRY(8378),
73 CPU_TYPE_ENTRY(8379),
74 };
75
76 immr = (immap_t *)CONFIG_SYS_IMMR;
77
78 puts("CPU: ");
79
80 switch (pvr & 0xffff0000) {
81 case PVR_E300C1:
82 printf("e300c1, ");
83 break;
84
85 case PVR_E300C2:
86 printf("e300c2, ");
87 break;
88
89 case PVR_E300C3:
90 printf("e300c3, ");
91 break;
92
93 case PVR_E300C4:
94 printf("e300c4, ");
95 break;
96
97 default:
98 printf("Unknown core, ");
99 }
100
101 spridr = immr->sysconf.spridr;
102
103 for (i = 0; i < ARRAY_SIZE(cpu_type_list); i++)
104 if (cpu_type_list[i].partid == PARTID_NO_E(spridr)) {
105 puts("MPC");
106 puts(cpu_type_list[i].name);
107 if (IS_E_PROCESSOR(spridr))
108 puts("E");
109 if (REVID_MAJOR(spridr) >= 2)
110 puts("A");
111 printf(", Rev: %d.%d", REVID_MAJOR(spridr),
112 REVID_MINOR(spridr));
113 break;
114 }
115
116 if (i == ARRAY_SIZE(cpu_type_list))
117 printf("(SPRIDR %08x unknown), ", spridr);
118
119 printf(" at %s MHz, ", strmhz(buf, clock));
120
121 printf("CSB: %s MHz\n", strmhz(buf, gd->csb_clk));
122
123 return 0;
124}
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154void upmconfig (uint upm, uint *table, uint size)
155{
156 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
157 volatile fsl_lbus_t *lbus = &immap->lbus;
158 volatile uchar *dummy = NULL;
159 const u32 msel = (upm + 4) << BR_MSEL_SHIFT;
160 volatile u32 *mxmr = &lbus->mamr + upm;
161 uint i;
162
163
164 for (i = 0; i < 8; i++) {
165 if ((lbus->bank[i].br & BR_MSEL) == msel) {
166 dummy = (uchar *) (lbus->bank[i].br & BR_BA);
167 break;
168 }
169 }
170
171 if (!dummy) {
172 printf("Error: %s() could not find matching BR\n", __FUNCTION__);
173 hang();
174 }
175
176
177 *mxmr = (*mxmr & 0xCFFFFFC0) | 0x10000000;
178
179 for (i = 0; i < size; i++) {
180 lbus->mdr = table[i];
181 __asm__ __volatile__ ("sync");
182 *dummy = 0;
183 __asm__ __volatile__ ("sync");
184 while(((*mxmr & 0x3f) != ((i + 1) & 0x3f)));
185 }
186
187
188 *mxmr &= 0xCFFFFFC0;
189}
190
191
192int
193do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
194{
195 ulong msr;
196#ifndef MPC83xx_RESET
197 ulong addr;
198#endif
199
200 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
201
202#ifdef MPC83xx_RESET
203
204 __asm__ __volatile__ ("mfmsr %0":"=r" (msr):);
205
206 msr &= ~( MSR_EE | MSR_IR | MSR_DR);
207 __asm__ __volatile__ ("mtmsr %0"::"r" (msr));
208
209
210 immap->reset.rpr = 0x52535445;
211 __asm__ __volatile__ ("sync");
212 __asm__ __volatile__ ("isync");
213
214
215 while(!((immap->reset.rcer) & RCER_CRE));
216
217 printf("Resetting the board.");
218 printf("\n");
219
220 udelay(200);
221
222
223 immap->reset.rcr = RCR_SWHR;
224
225#else
226
227 immap->reset.rmr = RMR_CSRE;
228
229
230 __asm__ __volatile__ ("mfmsr %0":"=r" (msr):);
231
232 msr &= ~(MSR_ME | MSR_EE | MSR_IR | MSR_DR);
233 __asm__ __volatile__ ("mtmsr %0"::"r" (msr));
234
235
236
237
238
239 addr = CONFIG_SYS_RESET_ADDRESS;
240
241 printf("resetting the board.");
242 printf("\n");
243 ((void (*)(void)) addr) ();
244#endif
245
246 return 1;
247}
248
249
250
251
252
253
254unsigned long get_tbclk(void)
255{
256 ulong tbclk;
257
258 tbclk = (gd->bus_clk + 3L) / 4L;
259
260 return tbclk;
261}
262
263
264#if defined(CONFIG_WATCHDOG)
265void watchdog_reset (void)
266{
267 int re_enable = disable_interrupts();
268
269
270 volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
271 immr->wdt.swsrr = 0x556c;
272 immr->wdt.swsrr = 0xaa39;
273
274 if (re_enable)
275 enable_interrupts ();
276}
277#endif
278
279
280
281
282
283int cpu_eth_init(bd_t *bis)
284{
285#if defined(CONFIG_UEC_ETH)
286 uec_standard_init(bis);
287#endif
288
289#if defined(CONFIG_TSEC_ENET)
290 tsec_standard_init(bis);
291#endif
292 return 0;
293}
294
295
296
297
298
299int cpu_mmc_init(bd_t *bis)
300{
301#ifdef CONFIG_FSL_ESDHC
302 return fsl_esdhc_mmc_init(bis);
303#else
304 return 0;
305#endif
306}
307
308#ifdef CONFIG_BOOTCOUNT_LIMIT
309
310#if !defined(CONFIG_MPC8360)
311#error "CONFIG_BOOTCOUNT_LIMIT only for MPC8360 implemented"
312#endif
313
314#if !defined(CONFIG_BOOTCOUNT_ADDR)
315#define CONFIG_BOOTCOUNT_ADDR (0x110000 + QE_MURAM_SIZE - 2 * sizeof(unsigned long))
316#endif
317
318#include <asm/io.h>
319
320void bootcount_store (ulong a)
321{
322 void *reg = (void *)(CONFIG_SYS_IMMR + CONFIG_BOOTCOUNT_ADDR);
323 out_be32 (reg, a);
324 out_be32 (reg + 4, BOOTCOUNT_MAGIC);
325}
326
327ulong bootcount_load (void)
328{
329 void *reg = (void *)(CONFIG_SYS_IMMR + CONFIG_BOOTCOUNT_ADDR);
330
331 if (in_be32 (reg + 4) != BOOTCOUNT_MAGIC)
332 return 0;
333 else
334 return in_be32 (reg);
335}
336#endif
337