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
30#include <common.h>
31#include <asm/processor.h>
32#include <asm/mmu.h>
33#include <asm/immap_85xx.h>
34#include <asm/fsl_ddr_sdram.h>
35#include <ioports.h>
36#include <spd_sdram.h>
37#include <miiphy.h>
38#include <libfdt.h>
39#include <fdt_support.h>
40
41long int fixed_sdram (void);
42
43
44
45
46
47
48
49
50const iop_conf_t iop_conf_tab[4][32] = {
51
52
53 {
54 { 0, 1, 0, 1, 0, 0 },
55 { 0, 1, 0, 0, 0, 0 },
56 { 0, 1, 0, 1, 0, 0 },
57 { 0, 1, 0, 1, 0, 0 },
58 { 0, 1, 0, 0, 0, 0 },
59 { 0, 1, 0, 0, 0, 0 },
60 { 0, 1, 0, 1, 0, 0 },
61 { 0, 1, 0, 1, 0, 0 },
62 { 0, 1, 0, 1, 0, 0 },
63 { 0, 1, 0, 1, 0, 0 },
64 { 0, 1, 0, 1, 0, 0 },
65 { 0, 1, 0, 1, 0, 0 },
66 { 0, 1, 0, 1, 0, 0 },
67 { 0, 1, 0, 1, 0, 0 },
68 { 0, 1, 0, 0, 0, 0 },
69 { 0, 1, 0, 0, 0, 0 },
70 { 0, 1, 0, 0, 0, 0 },
71 { 0, 1, 0, 0, 0, 0 },
72 { 0, 1, 0, 0, 0, 0 },
73 { 0, 1, 0, 0, 0, 0 },
74 { 0, 1, 0, 0, 0, 0 },
75 { 0, 1, 0, 0, 0, 0 },
76 { 0, 1, 1, 1, 0, 0 },
77 { 0, 1, 1, 0, 0, 0 },
78 { 0, 0, 0, 1, 0, 0 },
79 { 0, 1, 1, 1, 0, 0 },
80 { 0, 0, 0, 1, 0, 0 },
81 { 0, 0, 0, 1, 0, 0 },
82 { 0, 0, 0, 1, 0, 0 },
83 { 0, 0, 0, 1, 0, 0 },
84 { 1, 0, 0, 0, 0, 0 },
85 { 0, 0, 0, 1, 0, 0 }
86 },
87
88
89 {
90 { 1, 1, 0, 1, 0, 0 },
91 { 1, 1, 0, 0, 0, 0 },
92 { 1, 1, 1, 1, 0, 0 },
93 { 1, 1, 0, 0, 0, 0 },
94 { 1, 1, 0, 0, 0, 0 },
95 { 1, 1, 0, 0, 0, 0 },
96 { 1, 1, 0, 1, 0, 0 },
97 { 1, 1, 0, 1, 0, 0 },
98 { 1, 1, 0, 1, 0, 0 },
99 { 1, 1, 0, 1, 0, 0 },
100 { 1, 1, 0, 0, 0, 0 },
101 { 1, 1, 0, 0, 0, 0 },
102 { 1, 1, 0, 0, 0, 0 },
103 { 1, 1, 0, 0, 0, 0 },
104 { 0, 1, 0, 0, 0, 0 },
105 { 0, 1, 0, 0, 0, 0 },
106 { 0, 1, 0, 1, 0, 0 },
107 { 0, 1, 0, 1, 0, 0 },
108 { 0, 1, 0, 0, 0, 0 },
109 { 0, 1, 0, 0, 0, 0 },
110 { 0, 1, 0, 0, 0, 0 },
111 { 0, 1, 0, 0, 0, 0 },
112 { 0, 1, 0, 0, 0, 0 },
113 { 0, 1, 0, 0, 0, 0 },
114 { 0, 1, 0, 1, 0, 0 },
115 { 0, 1, 0, 1, 0, 0 },
116 { 0, 1, 0, 1, 0, 0 },
117 { 0, 1, 0, 1, 0, 0 },
118 { 0, 0, 0, 0, 0, 0 },
119 { 0, 0, 0, 0, 0, 0 },
120 { 0, 0, 0, 0, 0, 0 },
121 { 0, 0, 0, 0, 0, 0 }
122 },
123
124
125 {
126 { 0, 0, 0, 1, 0, 0 },
127 { 0, 0, 0, 1, 0, 0 },
128 { 0, 1, 1, 0, 0, 0 },
129 { 0, 0, 0, 1, 0, 0 },
130 { 0, 0, 0, 1, 0, 0 },
131 { 0, 0, 0, 1, 0, 0 },
132 { 0, 0, 0, 1, 0, 0 },
133 { 0, 0, 0, 1, 0, 0 },
134 { 0, 1, 0, 1, 0, 0 },
135 { 0, 1, 0, 0, 0, 0 },
136 { 0, 1, 0, 0, 0, 0 },
137 { 0, 1, 0, 0, 0, 0 },
138 { 1, 1, 0, 0, 0, 0 },
139 { 1, 1, 0, 0, 0, 0 },
140 { 0, 0, 0, 1, 0, 0 },
141 { 0, 1, 0, 0, 0, 0 },
142 { 1, 1, 0, 0, 0, 0 },
143 { 0, 1, 0, 0, 0, 0 },
144 { 0, 0, 0, 1, 0, 0 },
145 { 0, 1, 0, 1, 0, 0 },
146 { 0, 0, 0, 1, 0, 0 },
147 { 1, 0, 0, 1, 0, 0 },
148 { 1, 0, 0, 0, 0, 0 },
149 { 0, 0, 0, 1, 0, 0 },
150 { 0, 0, 0, 1, 0, 0 },
151 { 0, 0, 0, 1, 0, 0 },
152 { 0, 0, 0, 1, 0, 0 },
153 { 0, 0, 0, 1, 0, 0 },
154 { 0, 0, 0, 1, 0, 0 },
155 { 0, 0, 0, 1, 0, 1 },
156 { 0, 0, 0, 1, 0, 0 },
157 { 0, 0, 0, 1, 0, 0 },
158 },
159
160
161 {
162 { 1, 1, 0, 0, 0, 0 },
163 { 1, 1, 1, 1, 0, 0 },
164 { 1, 1, 0, 1, 0, 0 },
165 { 1, 1, 0, 0, 0, 0 },
166 { 1, 1, 1, 1, 0, 0 },
167 { 1, 1, 0, 1, 0, 0 },
168 { 0, 0, 0, 1, 0, 0 },
169 { 0, 0, 0, 1, 0, 0 },
170 { 0, 0, 0, 1, 0, 0 },
171 { 0, 0, 0, 1, 0, 0 },
172 { 0, 0, 0, 1, 0, 0 },
173 { 0, 0, 0, 1, 0, 0 },
174 { 0, 0, 0, 1, 0, 0 },
175 { 0, 0, 0, 1, 0, 0 },
176 { 0, 1, 0, 0, 0, 0 },
177 { 0, 1, 0, 1, 0, 0 },
178 { 0, 1, 1, 0, 1, 0 },
179 { 0, 0, 0, 1, 0, 0 },
180 { 0, 0, 0, 0, 0, 0 },
181 { 0, 0, 0, 0, 0, 0 },
182 { 0, 0, 0, 0, 0, 0 },
183 { 0, 0, 0, 0, 0, 0 },
184 { 0, 1, 0, 1, 0, 0 },
185 { 0, 1, 0, 0, 0, 0 },
186 { 0, 0, 0, 1, 0, 1 },
187 { 0, 0, 0, 1, 0, 1 },
188 { 0, 0, 0, 1, 0, 1 },
189 { 0, 0, 0, 1, 0, 1 },
190 { 0, 0, 0, 0, 0, 0 },
191 { 0, 0, 0, 0, 0, 0 },
192 { 0, 0, 0, 0, 0, 0 },
193 { 0, 0, 0, 0, 0, 0 }
194 }
195};
196
197int board_early_init_f (void)
198{
199#if defined(CONFIG_PCI)
200 volatile ccsr_pcix_t *pci = (void *)(CONFIG_SYS_MPC85xx_PCIX_ADDR);
201
202 pci->peer &= 0xfffffffdf;
203#endif
204 return 0;
205}
206
207void reset_phy (void)
208{
209#if defined(CONFIG_ETHER_ON_FCC)
210 volatile unsigned char *bcsr = (unsigned char *) CONFIG_SYS_BCSR;
211#endif
212
213
214
215#if (CONFIG_ETHER_INDEX == 2)
216 bcsr[0] &= ~0x20;
217 udelay(2);
218 bcsr[0] |= 0x20;
219 udelay(1000);
220#elif (CONFIG_ETHER_INDEX == 3)
221 bcsr[0] &= ~0x10;
222 udelay(2);
223 bcsr[0] |= 0x10;
224 udelay(1000);
225#endif
226#if defined(CONFIG_MII) && defined(CONFIG_ETHER_ON_FCC)
227
228 miiphy_reset("FCC1 ETHERNET", 0x0);
229
230
231 bb_miiphy_write(NULL, 0, PHY_MIPSCR, 0xf028);
232
233 bb_miiphy_write(NULL, 0x02, PHY_BMCR,
234 PHY_BMCR_AUTON | PHY_BMCR_RST_NEG);
235#endif
236}
237
238int checkboard (void)
239{
240 sys_info_t sysinfo;
241 char buf[32];
242
243 get_sys_info (&sysinfo);
244
245#ifdef CONFIG_SBC8560
246 printf ("Board: Wind River SBC8560 Board\n");
247#else
248 printf ("Board: Wind River SBC8540 Board\n");
249#endif
250 printf ("\tCPU: %s MHz\n", strmhz(buf, sysinfo.freqProcessor[0]));
251 printf ("\tCCB: %s MHz\n", strmhz(buf, sysinfo.freqSystemBus));
252 printf ("\tDDR: %s MHz\n", strmhz(buf, sysinfo.freqSystemBus/2));
253 if((CONFIG_SYS_LBC_LCRR & 0x0f) == 2 || (CONFIG_SYS_LBC_LCRR & 0x0f) == 4 \
254 || (CONFIG_SYS_LBC_LCRR & 0x0f) == 8) {
255 printf ("\tLBC: %s MHz\n",
256 strmhz(buf, sysinfo.freqSystemBus/(CONFIG_SYS_LBC_LCRR & 0x0f)));
257 } else {
258 printf("\tLBC: unknown\n");
259 }
260 printf("\tCPM: %s MHz\n", strmhz(buf, sysinfo.freqSystemBus));
261 printf("L1 D-cache 32KB, L1 I-cache 32KB enabled.\n");
262 return (0);
263}
264
265
266phys_size_t initdram (int board_type)
267{
268 long dram_size = 0;
269
270#if 0
271#if !defined(CONFIG_RAM_AS_FLASH)
272 volatile ccsr_lbc_t *lbc = (void *)(CONFIG_SYS_MPC85xx_LBC_ADDR);
273 sys_info_t sysinfo;
274 uint temp_lbcdll = 0;
275#endif
276#endif
277#if !defined(CONFIG_RAM_AS_FLASH) || defined(CONFIG_DDR_DLL)
278 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
279#endif
280#if defined(CONFIG_DDR_DLL)
281 uint temp_ddrdll = 0;
282
283
284 temp_ddrdll = gur->ddrdllcr;
285 gur->ddrdllcr = ((temp_ddrdll & 0xff) << 16) | 0x80000000;
286 asm("sync;isync;msync");
287#endif
288
289#if defined(CONFIG_SPD_EEPROM)
290 dram_size = fsl_ddr_sdram();
291 dram_size = setup_ddr_tlbs(dram_size / 0x100000);
292 dram_size *= 0x100000;
293#else
294 dram_size = fixed_sdram ();
295#endif
296
297#if 0
298#if !defined(CONFIG_RAM_AS_FLASH)
299 get_sys_info(&sysinfo);
300
301 if(sysinfo.freqSystemBus/(CONFIG_SYS_LBC_LCRR & 0x0f) < 66000000) {
302 lbc->lcrr = (CONFIG_SYS_LBC_LCRR & 0x0fffffff)| 0x80000000;
303 } else {
304#if defined(CONFIG_MPC85xx_REV1)
305 lbc->lcrr = 0x10000004;
306#endif
307 lbc->lcrr = CONFIG_SYS_LBC_LCRR & 0x7fffffff;
308 udelay(200);
309 temp_lbcdll = gur->lbcdllcr;
310 gur->lbcdllcr = ((temp_lbcdll & 0xff) << 16 ) | 0x80000000;
311 asm("sync;isync;msync");
312 }
313 lbc->or2 = CONFIG_SYS_OR2_PRELIM;
314 lbc->br2 = CONFIG_SYS_BR2_PRELIM;
315 lbc->lbcr = CONFIG_SYS_LBC_LBCR;
316 lbc->lsdmr = CONFIG_SYS_LBC_LSDMR_1;
317 asm("sync");
318 (unsigned int) * (ulong *)0 = 0x000000ff;
319 lbc->lsdmr = CONFIG_SYS_LBC_LSDMR_2;
320 asm("sync");
321 (unsigned int) * (ulong *)0 = 0x000000ff;
322 lbc->lsdmr = CONFIG_SYS_LBC_LSDMR_3;
323 asm("sync");
324 (unsigned int) * (ulong *)0 = 0x000000ff;
325 lbc->lsdmr = CONFIG_SYS_LBC_LSDMR_4;
326 asm("sync");
327 (unsigned int) * (ulong *)0 = 0x000000ff;
328 lbc->lsdmr = CONFIG_SYS_LBC_LSDMR_5;
329 asm("sync");
330 lbc->lsrt = CONFIG_SYS_LBC_LSRT;
331 asm("sync");
332 lbc->mrtpr = CONFIG_SYS_LBC_MRTPR;
333 asm("sync");
334#endif
335#endif
336
337#if defined(CONFIG_DDR_ECC)
338 {
339
340
341 volatile ccsr_ddr_t *ddr= (void *)(CONFIG_SYS_MPC85xx_DDR_ADDR);
342
343 dma_meminit(CONFIG_MEM_INIT_VALUE, dram_size);
344
345
346 ddr->err_disable = 0x00000000;
347 asm("sync;isync;msync");
348 }
349#endif
350
351 return dram_size;
352}
353
354
355#if defined(CONFIG_SYS_DRAM_TEST)
356int testdram (void)
357{
358 uint *pstart = (uint *) CONFIG_SYS_MEMTEST_START;
359 uint *pend = (uint *) CONFIG_SYS_MEMTEST_END;
360 uint *p;
361
362 printf("SDRAM test phase 1:\n");
363 for (p = pstart; p < pend; p++)
364 *p = 0xaaaaaaaa;
365
366 for (p = pstart; p < pend; p++) {
367 if (*p != 0xaaaaaaaa) {
368 printf ("SDRAM test fails at: %08x\n", (uint) p);
369 return 1;
370 }
371 }
372
373 printf("SDRAM test phase 2:\n");
374 for (p = pstart; p < pend; p++)
375 *p = 0x55555555;
376
377 for (p = pstart; p < pend; p++) {
378 if (*p != 0x55555555) {
379 printf ("SDRAM test fails at: %08x\n", (uint) p);
380 return 1;
381 }
382 }
383
384 printf("SDRAM test passed.\n");
385 return 0;
386}
387#endif
388
389#if !defined(CONFIG_SPD_EEPROM)
390
391
392
393long int fixed_sdram (void)
394{
395
396#define CONFIG_SYS_DDR_CONTROL 0xc2000000
397
398 #ifndef CONFIG_SYS_RAMBOOT
399 volatile ccsr_ddr_t *ddr= (void *)(CONFIG_SYS_MPC85xx_DDR_ADDR);
400
401#if (CONFIG_SYS_SDRAM_SIZE == 512)
402 ddr->cs0_bnds = 0x0000000f;
403#else
404 ddr->cs0_bnds = 0x00000007;
405#endif
406 ddr->cs1_bnds = 0x0010001f;
407 ddr->cs2_bnds = 0x00000000;
408 ddr->cs3_bnds = 0x00000000;
409 ddr->cs0_config = 0x80000102;
410 ddr->cs1_config = 0x80000102;
411 ddr->cs2_config = 0x00000000;
412 ddr->cs3_config = 0x00000000;
413 ddr->timing_cfg_1 = 0x37334321;
414 ddr->timing_cfg_2 = 0x00000800;
415 ddr->sdram_cfg = 0x42000000;
416 ddr->sdram_mode = 0x00000022;
417 ddr->sdram_interval = 0x05200100;
418 ddr->err_sbe = 0x00ff0000;
419 #if defined (CONFIG_DDR_ECC)
420 ddr->err_disable = 0x0000000D;
421 #endif
422 asm("sync;isync;msync");
423 udelay(500);
424 #if defined (CONFIG_DDR_ECC)
425
426 ddr->sdram_cfg = (CONFIG_SYS_DDR_CONTROL | 0x20000000);
427 #else
428 ddr->sdram_cfg = CONFIG_SYS_DDR_CONTROL;
429 #endif
430 asm("sync; isync; msync");
431 udelay(500);
432 #endif
433 return CONFIG_SYS_SDRAM_SIZE * 1024 * 1024;
434}
435#endif
436
437
438#if defined(CONFIG_OF_BOARD_SETUP)
439void
440ft_board_setup(void *blob, bd_t *bd)
441{
442 int node, tmp[2];
443#ifdef CONFIG_PCI
444 const char *path;
445#endif
446
447 ft_cpu_setup(blob, bd);
448
449 node = fdt_path_offset(blob, "/aliases");
450 tmp[0] = 0;
451 if (node >= 0) {
452#ifdef CONFIG_PCI
453 path = fdt_getprop(blob, node, "pci0", NULL);
454 if (path) {
455 tmp[1] = hose.last_busno - hose.first_busno;
456 do_fixup_by_path(blob, path, "bus-range", &tmp, 8, 1);
457 }
458#endif
459 }
460}
461#endif
462