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#include <common.h>
28#include <watchdog.h>
29#include <command.h>
30#include <mpc8260.h>
31#include <netdev.h>
32#include <asm/processor.h>
33#include <asm/cpm_8260.h>
34
35#if defined(CONFIG_OF_LIBFDT)
36#include <libfdt.h>
37#include <fdt_support.h>
38#endif
39
40DECLARE_GLOBAL_DATA_PTR;
41
42#if defined(CONFIG_GET_CPU_STR_F)
43extern int get_cpu_str_f (char *buf);
44#endif
45
46int checkcpu (void)
47{
48 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
49 ulong clock = gd->cpu_clk;
50 uint pvr = get_pvr ();
51 uint immr, rev, m, k;
52 char buf[32];
53
54 puts ("CPU: ");
55
56 switch (pvr) {
57 case PVR_8260:
58 case PVR_8260_HIP3:
59 k = 3;
60 break;
61 case PVR_8260_HIP4:
62 k = 4;
63 break;
64 case PVR_8260_HIP7R1:
65 case PVR_8260_HIP7RA:
66 case PVR_8260_HIP7:
67 k = 7;
68 break;
69 default:
70 return -1;
71 }
72 rev = pvr & 0xff;
73
74 immr = immap->im_memctl.memc_immr;
75 if ((immr & IMMR_ISB_MSK) != CONFIG_SYS_IMMR)
76 return -1;
77
78#if defined(CONFIG_GET_CPU_STR_F)
79 get_cpu_str_f (buf);
80 printf ("%s (HiP%d Rev %02x, Mask ", buf, k, rev);
81#else
82 printf (CPU_ID_STR " (HiP%d Rev %02x, Mask ", k, rev);
83#endif
84
85
86
87
88
89
90
91
92 m = immr & (IMMR_PARTNUM_MSK | IMMR_MASKNUM_MSK);
93 k = immap->im_dprambase16[PROFF_REVNUM / sizeof(u16)];
94
95 switch (m) {
96 case 0x0000:
97 puts ("0.2 2J24M");
98 break;
99 case 0x0010:
100 puts ("A.0 K22A");
101 break;
102 case 0x0011:
103 puts ("A.1 1K22A-XC");
104 break;
105 case 0x0001:
106 puts ("B.1 1K23A");
107 break;
108 case 0x0021:
109 puts ("B.2 2K23A-XC");
110 break;
111 case 0x0023:
112 puts ("B.3 3K23A");
113 break;
114 case 0x0024:
115 puts ("C.2 6K23A");
116 break;
117 case 0x0060:
118 puts ("A.0(A) 2K25A");
119 break;
120 case 0x0062:
121 puts ("B.1 4K25A");
122 break;
123 case 0x0064:
124 puts ("C.0 5K25A");
125 break;
126 case 0x0A00:
127 puts ("0.0 0K49M");
128 break;
129 case 0x0A01:
130 puts ("0.1 1K49M");
131 break;
132 case 0x0A10:
133 puts ("1.0 1K49M");
134 break;
135 case 0x0C00:
136 puts ("0.0 0K50M");
137 break;
138 case 0x0C10:
139 puts ("1.0 1K50M");
140 break;
141 case 0x0D00:
142 puts ("0.0 0K50M");
143 break;
144 case 0x0D10:
145 puts ("1.0 1K50M");
146 break;
147 default:
148 printf ("unknown [immr=0x%04x,k=0x%04x]", m, k);
149 break;
150 }
151
152 printf (") at %s MHz\n", strmhz (buf, clock));
153
154 return 0;
155}
156
157
158
159
160
161
162
163void upmconfig (uint upm, uint * table, uint size)
164{
165 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
166 volatile memctl8260_t *memctl = &immap->im_memctl;
167 volatile uchar *dummy = (uchar *) BRx_BA_MSK;
168 uint i;
169
170
171
172 memctl->memc_or11 = ORxU_AM_MSK;
173
174 switch (upm) {
175
176 case UPMA:
177 memctl->memc_br11 =
178 ((uint)dummy & BRx_BA_MSK) | BRx_PS_32 | BRx_MS_UPMA |
179 BRx_V;
180 memctl->memc_mamr = MxMR_OP_WARR;
181 break;
182
183 case UPMB:
184 memctl->memc_br11 =
185 ((uint)dummy & BRx_BA_MSK) | BRx_PS_32 | BRx_MS_UPMB |
186 BRx_V;
187 memctl->memc_mbmr = MxMR_OP_WARR;
188 break;
189
190 case UPMC:
191 memctl->memc_br11 =
192 ((uint)dummy & BRx_BA_MSK) | BRx_PS_32 | BRx_MS_UPMC |
193 BRx_V;
194 memctl->memc_mcmr = MxMR_OP_WARR;
195 break;
196
197 default:
198 panic ("upmconfig passed invalid UPM number (%u)\n", upm);
199 break;
200
201 }
202
203
204
205
206
207
208
209
210
211 for (i = 0; i < size; i++) {
212 memctl->memc_mdr = table[i];
213 *dummy = 0;
214 }
215
216
217 memctl->memc_br11 = 0;
218}
219
220
221
222#if !defined(CONFIG_HAVE_OWN_RESET)
223int
224do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
225{
226 ulong msr, addr;
227
228 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
229
230 immap->im_clkrst.car_rmr = RMR_CSRE;
231
232
233 __asm__ __volatile__ ("mfmsr %0":"=r" (msr):);
234
235 msr &= ~(MSR_ME | MSR_EE | MSR_IR | MSR_DR);
236 __asm__ __volatile__ ("mtmsr %0"::"r" (msr));
237
238
239
240
241
242#ifdef CONFIG_SYS_RESET_ADDRESS
243 addr = CONFIG_SYS_RESET_ADDRESS;
244#else
245
246
247
248
249
250 addr = CONFIG_SYS_MONITOR_BASE - sizeof (ulong);
251#endif
252 ((void (*)(void)) addr) ();
253 return 1;
254
255}
256#endif
257
258
259
260
261
262
263
264unsigned long get_tbclk (void)
265{
266 ulong tbclk;
267
268 tbclk = (gd->bus_clk + 3L) / 4L;
269
270 return (tbclk);
271}
272
273
274
275#if defined(CONFIG_WATCHDOG)
276void watchdog_reset (void)
277{
278 int re_enable = disable_interrupts ();
279
280 reset_8260_watchdog ((immap_t *) CONFIG_SYS_IMMR);
281 if (re_enable)
282 enable_interrupts ();
283}
284#endif
285
286
287#if defined(CONFIG_OF_LIBFDT) && defined (CONFIG_OF_BOARD_SETUP)
288void ft_cpu_setup (void *blob, bd_t *bd)
289{
290#if defined(CONFIG_HAS_ETH0) || defined(CONFIG_HAS_ETH1) ||\
291 defined(CONFIG_HAS_ETH2) || defined(CONFIG_HAS_ETH3)
292 fdt_fixup_ethernet(blob);
293#endif
294
295 do_fixup_by_compat_u32(blob, "fsl,cpm2-brg",
296 "clock-frequency", bd->bi_brgfreq, 1);
297
298 do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
299 "bus-frequency", bd->bi_busfreq, 1);
300 do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
301 "timebase-frequency", OF_TBCLK, 1);
302 do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
303 "clock-frequency", bd->bi_intfreq, 1);
304 fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
305}
306#endif
307
308
309
310
311
312int cpu_eth_init(bd_t *bis)
313{
314#if defined(CONFIG_ETHER_ON_FCC)
315 fec_initialize(bis);
316#endif
317#if defined(CONFIG_ETHER_ON_SCC)
318 mpc82xx_scc_enet_initialize(bis);
319#endif
320 return 0;
321}
322