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#include <common.h>
29#include <pci.h>
30#include <asm/processor.h>
31#include <asm/mmu.h>
32#include <asm/immap_85xx.h>
33#include <asm/fsl_ddr_sdram.h>
34#include <ioports.h>
35#include <spd_sdram.h>
36#include <miiphy.h>
37#include <netdev.h>
38
39#if defined(CONFIG_DDR_ECC)
40extern void ddr_enable_ecc(unsigned int dram_size);
41#endif
42
43void local_bus_init(void);
44long int fixed_sdram(void);
45
46
47
48
49
50
51
52
53const iop_conf_t iop_conf_tab[4][32] = {
54
55
56 {
57 { 0, 1, 0, 1, 0, 0 },
58 { 0, 1, 0, 0, 0, 0 },
59 { 0, 1, 0, 1, 0, 0 },
60 { 0, 1, 0, 1, 0, 0 },
61 { 0, 1, 0, 0, 0, 0 },
62 { 0, 1, 0, 0, 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, 1, 0, 0 },
69 { 0, 1, 0, 1, 0, 0 },
70 { 0, 1, 0, 1, 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, 0, 0, 0, 0 },
77 { 0, 1, 0, 0, 0, 0 },
78 { 0, 1, 0, 0, 0, 0 },
79 { 0, 1, 1, 1, 0, 0 },
80 { 0, 1, 1, 0, 0, 0 },
81 { 0, 0, 0, 1, 0, 0 },
82 { 0, 1, 1, 1, 0, 0 },
83 { 0, 0, 0, 1, 0, 0 },
84 { 0, 0, 0, 1, 0, 0 },
85 { 0, 0, 0, 1, 0, 0 },
86 { 0, 0, 0, 1, 0, 0 },
87 { 0, 0, 0, 0, 0, 0 },
88 { 0, 0, 0, 1, 0, 0 }
89 },
90
91
92 {
93 { 0, 1, 0, 1, 0, 0 },
94 { 0, 1, 0, 0, 0, 0 },
95 { 0, 1, 1, 1, 0, 0 },
96 { 0, 1, 0, 0, 0, 0 },
97 { 0, 1, 0, 0, 0, 0 },
98 { 0, 1, 0, 0, 0, 0 },
99 { 0, 1, 0, 1, 0, 0 },
100 { 0, 1, 0, 1, 0, 0 },
101 { 0, 1, 0, 1, 0, 0 },
102 { 0, 1, 0, 1, 0, 0 },
103 { 0, 1, 0, 0, 0, 0 },
104 { 0, 1, 0, 0, 0, 0 },
105 { 0, 1, 0, 0, 0, 0 },
106 { 0, 1, 0, 0, 0, 0 },
107 { 1, 1, 0, 0, 0, 0 },
108 { 1, 1, 0, 0, 0, 0 },
109 { 1, 1, 0, 1, 0, 0 },
110 { 1, 1, 0, 1, 0, 0 },
111 { 1, 1, 0, 0, 0, 0 },
112 { 1, 1, 0, 0, 0, 0 },
113 { 1, 1, 0, 0, 0, 0 },
114 { 1, 1, 0, 0, 0, 0 },
115 { 1, 1, 0, 0, 0, 0 },
116 { 1, 1, 0, 0, 0, 0 },
117 { 1, 1, 0, 1, 0, 0 },
118 { 1, 1, 0, 1, 0, 0 },
119 { 1, 1, 0, 1, 0, 0 },
120 { 1, 1, 0, 1, 0, 0 },
121 { 0, 0, 0, 0, 0, 0 },
122 { 0, 0, 0, 0, 0, 0 },
123 { 0, 0, 0, 0, 0, 0 },
124 { 0, 0, 0, 0, 0, 0 }
125 },
126
127
128 {
129 { 0, 0, 0, 1, 0, 0 },
130 { 0, 0, 0, 1, 0, 0 },
131 { 0, 1, 1, 0, 0, 0 },
132 { 0, 0, 0, 1, 0, 0 },
133 { 0, 0, 0, 1, 0, 0 },
134 { 0, 0, 0, 1, 0, 0 },
135 { 0, 0, 0, 1, 0, 0 },
136 { 0, 0, 0, 1, 0, 0 },
137 { 0, 1, 0, 1, 0, 0 },
138 { 0, 1, 0, 0, 0, 0 },
139 { 0, 1, 0, 0, 0, 0 },
140 { 0, 1, 0, 0, 0, 0 },
141 { 0, 1, 0, 0, 0, 0 },
142 { 1, 1, 0, 0, 0, 0 },
143 { 1, 1, 0, 0, 0, 0 },
144 { 0, 1, 0, 0, 0, 0 },
145 { 0, 1, 0, 0, 0, 0 },
146 { 0, 1, 0, 0, 0, 0 },
147 { 0, 1, 0, 0, 0, 0 },
148 { 0, 1, 0, 1, 0, 0 },
149 { 0, 0, 0, 1, 0, 0 },
150 { 0, 0, 0, 1, 0, 0 },
151 { 0, 0, 0, 0, 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, 0 },
156 { 0, 0, 0, 1, 0, 0 },
157 { 0, 0, 0, 1, 0, 0 },
158 { 0, 0, 0, 1, 0, 1 },
159 { 0, 0, 0, 1, 0, 0 },
160 { 0, 0, 0, 1, 0, 0 },
161 },
162
163
164 {
165 { 1, 1, 0, 0, 0, 0 },
166 { 1, 1, 1, 1, 0, 0 },
167 { 1, 1, 0, 1, 0, 0 },
168 { 1, 1, 0, 0, 0, 0 },
169 { 1, 1, 0, 1, 0, 0 },
170 { 1, 1, 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, 0, 0, 1, 0, 0 },
177 { 0, 0, 0, 1, 0, 0 },
178 { 0, 0, 0, 1, 0, 0 },
179 { 0, 1, 0, 0, 0, 0 },
180 { 0, 1, 0, 1, 0, 0 },
181 { 0, 1, 1, 0, 1, 0 },
182 { 0, 0, 0, 1, 0, 0 },
183 { 0, 0, 0, 0, 0, 0 },
184 { 0, 0, 0, 0, 0, 0 },
185 { 0, 0, 0, 0, 0, 0 },
186 { 0, 0, 0, 0, 0, 0 },
187 { 0, 1, 0, 1, 0, 0 },
188 { 0, 1, 0, 0, 0, 0 },
189 { 0, 0, 0, 1, 0, 1 },
190 { 0, 0, 0, 1, 0, 1 },
191 { 0, 0, 0, 1, 0, 1 },
192 { 0, 0, 0, 1, 0, 1 },
193 { 0, 0, 0, 0, 0, 0 },
194 { 0, 0, 0, 0, 0, 0 },
195 { 0, 0, 0, 0, 0, 0 },
196 { 0, 0, 0, 0, 0, 0 }
197 }
198};
199
200
201int board_early_init_f (void)
202{
203 return 0;
204}
205
206void reset_phy (void)
207{
208}
209
210
211int checkboard (void)
212{
213 puts("Board: MicroSys PM856\n");
214
215#ifdef CONFIG_PCI
216 printf(" PCI1: 32 bit, %d MHz (compiled)\n",
217 CONFIG_SYS_CLK_FREQ / 1000000);
218#else
219 printf(" PCI1: disabled\n");
220#endif
221
222
223
224
225 local_bus_init();
226
227 return 0;
228}
229
230
231phys_size_t
232initdram(int board_type)
233{
234 long dram_size = 0;
235
236
237 puts("Initializing\n");
238
239#if defined(CONFIG_DDR_DLL)
240 {
241 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
242 int i,x;
243
244 x = 10;
245
246
247
248
249 gur->ddrdllcr = 0x81000000;
250 asm("sync;isync;msync");
251 udelay (200);
252 while (gur->ddrdllcr != 0x81000100)
253 {
254 gur->devdisr = gur->devdisr | 0x00010000;
255 asm("sync;isync;msync");
256 for (i=0; i<x; i++)
257 ;
258 gur->devdisr = gur->devdisr & 0xfff7ffff;
259 asm("sync;isync;msync");
260 x++;
261 }
262 }
263#endif
264
265#if defined(CONFIG_SPD_EEPROM)
266 dram_size = fsl_ddr_sdram();
267 dram_size = setup_ddr_tlbs(dram_size / 0x100000);
268 dram_size *= 0x100000;
269#else
270 dram_size = fixed_sdram ();
271#endif
272
273#if defined(CONFIG_DDR_ECC)
274
275
276
277 ddr_enable_ecc(dram_size);
278#endif
279
280 puts(" DDR: ");
281 return dram_size;
282}
283
284
285
286
287
288
289void
290local_bus_init(void)
291{
292 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
293 volatile ccsr_lbc_t *lbc = (void *)(CONFIG_SYS_MPC85xx_LBC_ADDR);
294
295 uint clkdiv;
296 uint lbc_hz;
297 sys_info_t sysinfo;
298
299
300
301
302
303
304
305
306
307
308 get_sys_info(&sysinfo);
309 clkdiv = lbc->lcrr & LCRR_CLKDIV;
310 lbc_hz = sysinfo.freqSystemBus / 1000000 / clkdiv;
311
312 if (lbc_hz < 66) {
313 lbc->lcrr = CONFIG_SYS_LBC_LCRR | 0x80000000;
314
315 } else if (lbc_hz >= 133) {
316 lbc->lcrr = CONFIG_SYS_LBC_LCRR & (~0x80000000);
317
318 } else {
319
320
321
322
323 uint pvr = get_pvr();
324 uint temp_lbcdll = 0;
325
326 if (pvr == PVR_85xx_REV1) {
327
328 lbc->lcrr = 0x10000004;
329 }
330
331 lbc->lcrr = CONFIG_SYS_LBC_LCRR & (~0x80000000);
332 udelay(200);
333
334
335
336
337
338 temp_lbcdll = gur->lbcdllcr;
339 gur->lbcdllcr = (((temp_lbcdll & 0xff) << 16) | 0x80000000);
340 asm("sync;isync;msync");
341 }
342}
343
344#if defined(CONFIG_SYS_DRAM_TEST)
345int testdram (void)
346{
347 uint *pstart = (uint *) CONFIG_SYS_MEMTEST_START;
348 uint *pend = (uint *) CONFIG_SYS_MEMTEST_END;
349 uint *p;
350
351 printf("SDRAM test phase 1:\n");
352 for (p = pstart; p < pend; p++)
353 *p = 0xaaaaaaaa;
354
355 for (p = pstart; p < pend; p++) {
356 if (*p != 0xaaaaaaaa) {
357 printf ("SDRAM test fails at: %08x\n", (uint) p);
358 return 1;
359 }
360 }
361
362 printf("SDRAM test phase 2:\n");
363 for (p = pstart; p < pend; p++)
364 *p = 0x55555555;
365
366 for (p = pstart; p < pend; p++) {
367 if (*p != 0x55555555) {
368 printf ("SDRAM test fails at: %08x\n", (uint) p);
369 return 1;
370 }
371 }
372
373 printf("SDRAM test passed.\n");
374 return 0;
375}
376#endif
377
378
379#if !defined(CONFIG_SPD_EEPROM)
380
381
382
383long int fixed_sdram (void)
384{
385 #ifndef CONFIG_SYS_RAMBOOT
386 volatile ccsr_ddr_t *ddr= (void *)(CONFIG_SYS_MPC85xx_DDR_ADDR);
387
388 ddr->cs0_bnds = CONFIG_SYS_DDR_CS0_BNDS;
389 ddr->cs0_config = CONFIG_SYS_DDR_CS0_CONFIG;
390 ddr->timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1;
391 ddr->timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2;
392 ddr->sdram_mode = CONFIG_SYS_DDR_MODE;
393 ddr->sdram_interval = CONFIG_SYS_DDR_INTERVAL;
394 #if defined (CONFIG_DDR_ECC)
395 ddr->err_disable = 0x0000000D;
396 ddr->err_sbe = 0x00ff0000;
397 #endif
398 asm("sync;isync;msync");
399 udelay(500);
400 #if defined (CONFIG_DDR_ECC)
401
402 ddr->sdram_cfg = (CONFIG_SYS_DDR_CONTROL | 0x20000000);
403 #else
404 ddr->sdram_cfg = CONFIG_SYS_DDR_CONTROL;
405 #endif
406 asm("sync; isync; msync");
407 udelay(500);
408 #endif
409 return CONFIG_SYS_SDRAM_SIZE * 1024 * 1024;
410}
411#endif
412
413
414#if defined(CONFIG_PCI)
415
416
417
418
419#ifndef CONFIG_PCI_PNP
420static struct pci_config_table pci_mpc85xxads_config_table[] = {
421 { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
422 PCI_IDSEL_NUMBER, PCI_ANY_ID,
423 pci_cfgfunc_config_device, { PCI_ENET0_IOADDR,
424 PCI_ENET0_MEMADDR,
425 PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER
426 } },
427 { }
428};
429#endif
430
431
432static struct pci_controller hose = {
433#ifndef CONFIG_PCI_PNP
434 config_table: pci_mpc85xxads_config_table,
435#endif
436};
437
438#endif
439
440
441void
442pci_init_board(void)
443{
444#ifdef CONFIG_PCI
445 pci_mpc85xx_init(&hose);
446#endif
447}
448
449int board_eth_init(bd_t *bis)
450{
451 cpu_eth_init(bis);
452 return pci_eth_init(bis);
453}
454