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
41
42
43
44
45
46
47
48const iop_conf_t iop_conf_tab[4][32] = {
49
50
51 {
52 { 0, 1, 0, 1, 0, 0 },
53 { 0, 1, 0, 0, 0, 0 },
54 { 0, 1, 0, 1, 0, 0 },
55 { 0, 1, 0, 1, 0, 0 },
56 { 0, 1, 0, 0, 0, 0 },
57 { 0, 1, 0, 0, 0, 0 },
58 { 0, 1, 0, 1, 0, 0 },
59 { 0, 1, 0, 1, 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, 0, 0, 0 },
67 { 0, 1, 0, 0, 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, 1, 1, 0, 0 },
75 { 0, 1, 1, 0, 0, 0 },
76 { 0, 0, 0, 1, 0, 0 },
77 { 0, 1, 1, 1, 0, 0 },
78 { 0, 0, 0, 1, 0, 0 },
79 { 0, 0, 0, 1, 0, 0 },
80 { 0, 0, 0, 1, 0, 0 },
81 { 0, 0, 0, 1, 0, 0 },
82 { 1, 0, 0, 0, 0, 0 },
83 { 0, 0, 0, 1, 0, 0 }
84 },
85
86
87 {
88 { 1, 1, 0, 1, 0, 0 },
89 { 1, 1, 0, 0, 0, 0 },
90 { 1, 1, 1, 1, 0, 0 },
91 { 1, 1, 0, 0, 0, 0 },
92 { 1, 1, 0, 0, 0, 0 },
93 { 1, 1, 0, 0, 0, 0 },
94 { 1, 1, 0, 1, 0, 0 },
95 { 1, 1, 0, 1, 0, 0 },
96 { 1, 1, 0, 1, 0, 0 },
97 { 1, 1, 0, 1, 0, 0 },
98 { 1, 1, 0, 0, 0, 0 },
99 { 1, 1, 0, 0, 0, 0 },
100 { 1, 1, 0, 0, 0, 0 },
101 { 1, 1, 0, 0, 0, 0 },
102 { 0, 1, 0, 0, 0, 0 },
103 { 0, 1, 0, 0, 0, 0 },
104 { 0, 1, 0, 1, 0, 0 },
105 { 0, 1, 0, 1, 0, 0 },
106 { 0, 1, 0, 0, 0, 0 },
107 { 0, 1, 0, 0, 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, 1, 0, 0 },
113 { 0, 1, 0, 1, 0, 0 },
114 { 0, 1, 0, 1, 0, 0 },
115 { 0, 1, 0, 1, 0, 0 },
116 { 0, 0, 0, 0, 0, 0 },
117 { 0, 0, 0, 0, 0, 0 },
118 { 0, 0, 0, 0, 0, 0 },
119 { 0, 0, 0, 0, 0, 0 }
120 },
121
122
123 {
124 { 0, 0, 0, 1, 0, 0 },
125 { 0, 0, 0, 1, 0, 0 },
126 { 0, 1, 1, 0, 0, 0 },
127 { 0, 0, 0, 1, 0, 0 },
128 { 0, 0, 0, 1, 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, 1, 0, 1, 0, 0 },
133 { 0, 1, 0, 0, 0, 0 },
134 { 0, 1, 0, 0, 0, 0 },
135 { 0, 1, 0, 0, 0, 0 },
136 { 1, 1, 0, 0, 0, 0 },
137 { 1, 1, 0, 0, 0, 0 },
138 { 0, 0, 0, 1, 0, 0 },
139 { 0, 1, 0, 0, 0, 0 },
140 { 1, 1, 0, 0, 0, 0 },
141 { 0, 1, 0, 0, 0, 0 },
142 { 0, 0, 0, 1, 0, 0 },
143 { 0, 1, 0, 1, 0, 0 },
144 { 0, 0, 0, 1, 0, 0 },
145 { 1, 0, 0, 1, 0, 0 },
146 { 1, 0, 0, 0, 0, 0 },
147 { 0, 0, 0, 1, 0, 0 },
148 { 0, 0, 0, 1, 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, 1 },
154 { 0, 0, 0, 1, 0, 0 },
155 { 0, 0, 0, 1, 0, 0 },
156 },
157
158
159 {
160 { 1, 1, 0, 0, 0, 0 },
161 { 1, 1, 1, 1, 0, 0 },
162 { 1, 1, 0, 1, 0, 0 },
163 { 1, 1, 0, 0, 0, 0 },
164 { 1, 1, 1, 1, 0, 0 },
165 { 1, 1, 0, 1, 0, 0 },
166 { 0, 0, 0, 1, 0, 0 },
167 { 0, 0, 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, 1, 0, 0, 0, 0 },
175 { 0, 1, 0, 1, 0, 0 },
176 { 0, 1, 1, 0, 1, 0 },
177 { 0, 0, 0, 1, 0, 0 },
178 { 0, 0, 0, 0, 0, 0 },
179 { 0, 0, 0, 0, 0, 0 },
180 { 0, 0, 0, 0, 0, 0 },
181 { 0, 0, 0, 0, 0, 0 },
182 { 0, 1, 0, 1, 0, 0 },
183 { 0, 1, 0, 0, 0, 0 },
184 { 0, 0, 0, 1, 0, 1 },
185 { 0, 0, 0, 1, 0, 1 },
186 { 0, 0, 0, 1, 0, 1 },
187 { 0, 0, 0, 1, 0, 1 },
188 { 0, 0, 0, 0, 0, 0 },
189 { 0, 0, 0, 0, 0, 0 },
190 { 0, 0, 0, 0, 0, 0 },
191 { 0, 0, 0, 0, 0, 0 }
192 }
193};
194
195int board_early_init_f (void)
196{
197#if defined(CONFIG_PCI)
198 volatile ccsr_pcix_t *pci = (void *)(CONFIG_SYS_MPC85xx_PCIX_ADDR);
199
200 pci->peer &= 0xfffffffdf;
201#endif
202 return 0;
203}
204
205void reset_phy (void)
206{
207#if defined(CONFIG_ETHER_ON_FCC)
208 volatile unsigned char *bcsr = (unsigned char *) CONFIG_SYS_BCSR;
209#endif
210
211
212
213#if (CONFIG_ETHER_INDEX == 2)
214 bcsr[0] &= ~0x20;
215 udelay(2);
216 bcsr[0] |= 0x20;
217 udelay(1000);
218#elif (CONFIG_ETHER_INDEX == 3)
219 bcsr[0] &= ~0x10;
220 udelay(2);
221 bcsr[0] |= 0x10;
222 udelay(1000);
223#endif
224#if defined(CONFIG_MII) && defined(CONFIG_ETHER_ON_FCC)
225
226 miiphy_reset("FCC1", 0x0);
227
228
229 bb_miiphy_write(NULL, 0, MII_MIPSCR, 0xf028);
230
231 bb_miiphy_write(NULL, 0x02, MII_BMCR,
232 BMCR_ANENABLE | BMCR_ANRESTART);
233#endif
234}
235
236int checkboard (void)
237{
238 sys_info_t sysinfo;
239 char buf[32];
240
241 get_sys_info (&sysinfo);
242
243#ifdef CONFIG_SBC8560
244 printf ("Board: Wind River SBC8560 Board\n");
245#else
246 printf ("Board: Wind River SBC8540 Board\n");
247#endif
248 printf ("\tCPU: %s MHz\n", strmhz(buf, sysinfo.freqProcessor[0]));
249 printf ("\tCCB: %s MHz\n", strmhz(buf, sysinfo.freqSystemBus));
250 printf ("\tDDR: %s MHz\n", strmhz(buf, sysinfo.freqSystemBus/2));
251 if((CONFIG_SYS_LBC_LCRR & 0x0f) == 2 || (CONFIG_SYS_LBC_LCRR & 0x0f) == 4 \
252 || (CONFIG_SYS_LBC_LCRR & 0x0f) == 8) {
253 printf ("\tLBC: %s MHz\n",
254 strmhz(buf, sysinfo.freqSystemBus/(CONFIG_SYS_LBC_LCRR & 0x0f)));
255 } else {
256 printf("\tLBC: unknown\n");
257 }
258 printf("\tCPM: %s MHz\n", strmhz(buf, sysinfo.freqSystemBus));
259 printf("L1 D-cache 32KB, L1 I-cache 32KB enabled.\n");
260 return (0);
261}
262
263
264#if defined(CONFIG_SYS_DRAM_TEST)
265int testdram (void)
266{
267 uint *pstart = (uint *) CONFIG_SYS_MEMTEST_START;
268 uint *pend = (uint *) CONFIG_SYS_MEMTEST_END;
269 uint *p;
270
271 printf("SDRAM test phase 1:\n");
272 for (p = pstart; p < pend; p++)
273 *p = 0xaaaaaaaa;
274
275 for (p = pstart; p < pend; p++) {
276 if (*p != 0xaaaaaaaa) {
277 printf ("SDRAM test fails at: %08x\n", (uint) p);
278 return 1;
279 }
280 }
281
282 printf("SDRAM test phase 2:\n");
283 for (p = pstart; p < pend; p++)
284 *p = 0x55555555;
285
286 for (p = pstart; p < pend; p++) {
287 if (*p != 0x55555555) {
288 printf ("SDRAM test fails at: %08x\n", (uint) p);
289 return 1;
290 }
291 }
292
293 printf("SDRAM test passed.\n");
294 return 0;
295}
296#endif
297
298#if !defined(CONFIG_SPD_EEPROM)
299
300
301
302phys_size_t fixed_sdram(void)
303{
304
305#define CONFIG_SYS_DDR_CONTROL 0xc2000000
306
307 #ifndef CONFIG_SYS_RAMBOOT
308 volatile ccsr_ddr_t *ddr= (void *)(CONFIG_SYS_MPC85xx_DDR_ADDR);
309
310#if (CONFIG_SYS_SDRAM_SIZE == 512)
311 ddr->cs0_bnds = 0x0000000f;
312#else
313 ddr->cs0_bnds = 0x00000007;
314#endif
315 ddr->cs1_bnds = 0x0010001f;
316 ddr->cs2_bnds = 0x00000000;
317 ddr->cs3_bnds = 0x00000000;
318 ddr->cs0_config = 0x80000102;
319 ddr->cs1_config = 0x80000102;
320 ddr->cs2_config = 0x00000000;
321 ddr->cs3_config = 0x00000000;
322 ddr->timing_cfg_1 = 0x37334321;
323 ddr->timing_cfg_2 = 0x00000800;
324 ddr->sdram_cfg = 0x42000000;
325 ddr->sdram_mode = 0x00000022;
326 ddr->sdram_interval = 0x05200100;
327 ddr->err_sbe = 0x00ff0000;
328 #if defined (CONFIG_DDR_ECC)
329 ddr->err_disable = 0x0000000D;
330 #endif
331 asm("sync;isync;msync");
332 udelay(500);
333 #if defined (CONFIG_DDR_ECC)
334
335 ddr->sdram_cfg = (CONFIG_SYS_DDR_CONTROL | 0x20000000);
336 #else
337 ddr->sdram_cfg = CONFIG_SYS_DDR_CONTROL;
338 #endif
339 asm("sync; isync; msync");
340 udelay(500);
341 #endif
342 return CONFIG_SYS_SDRAM_SIZE * 1024 * 1024;
343}
344#endif
345
346
347#if defined(CONFIG_OF_BOARD_SETUP)
348void
349ft_board_setup(void *blob, bd_t *bd)
350{
351 int node, tmp[2];
352#ifdef CONFIG_PCI
353 const char *path;
354#endif
355
356 ft_cpu_setup(blob, bd);
357
358 node = fdt_path_offset(blob, "/aliases");
359 tmp[0] = 0;
360 if (node >= 0) {
361#ifdef CONFIG_PCI
362 path = fdt_getprop(blob, node, "pci0", NULL);
363 if (path) {
364 tmp[1] = hose.last_busno - hose.first_busno;
365 do_fixup_by_path(blob, path, "bus-range", &tmp, 8, 1);
366 }
367#endif
368 }
369}
370#endif
371