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#include <common.h>
26#include <pci.h>
27#include <asm/processor.h>
28#include <asm/mmu.h>
29#include <asm/immap_85xx.h>
30#include <asm/fsl_ddr_sdram.h>
31#include <ioports.h>
32#include <spd_sdram.h>
33#include <libfdt.h>
34#include <fdt_support.h>
35
36#include "../common/cadmus.h"
37#include "../common/eeprom.h"
38#include "../common/via.h"
39
40#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
41extern void ddr_enable_ecc(unsigned int dram_size);
42#endif
43
44void local_bus_init(void);
45void sdram_init(void);
46
47
48
49
50
51
52
53
54const iop_conf_t iop_conf_tab[4][32] = {
55
56
57 {
58 { 0, 1, 0, 1, 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, 0, 0, 0 },
63 { 0, 1, 0, 0, 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, 1, 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, 0, 0, 0, 0 },
80 { 0, 1, 1, 1, 0, 0 },
81 { 0, 1, 1, 0, 0, 0 },
82 { 0, 0, 0, 1, 0, 0 },
83 { 0, 1, 1, 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, 1, 0, 0 },
88 { 1, 0, 0, 0, 0, 0 },
89 { 0, 0, 0, 1, 0, 0 }
90 },
91
92
93 {
94 { 1, 1, 0, 1, 0, 0 },
95 { 1, 1, 0, 0, 0, 0 },
96 { 1, 1, 1, 1, 0, 0 },
97 { 1, 1, 0, 0, 0, 0 },
98 { 1, 1, 0, 0, 0, 0 },
99 { 1, 1, 0, 0, 0, 0 },
100 { 1, 1, 0, 1, 0, 0 },
101 { 1, 1, 0, 1, 0, 0 },
102 { 1, 1, 0, 1, 0, 0 },
103 { 1, 1, 0, 1, 0, 0 },
104 { 1, 1, 0, 0, 0, 0 },
105 { 1, 1, 0, 0, 0, 0 },
106 { 1, 1, 0, 0, 0, 0 },
107 { 1, 1, 0, 0, 0, 0 },
108 { 0, 1, 0, 0, 0, 0 },
109 { 0, 1, 0, 0, 0, 0 },
110 { 0, 1, 0, 1, 0, 0 },
111 { 0, 1, 0, 1, 0, 0 },
112 { 0, 1, 0, 0, 0, 0 },
113 { 0, 1, 0, 0, 0, 0 },
114 { 0, 1, 0, 0, 0, 0 },
115 { 0, 1, 0, 0, 0, 0 },
116 { 0, 1, 0, 0, 0, 0 },
117 { 0, 1, 0, 0, 0, 0 },
118 { 0, 1, 0, 1, 0, 0 },
119 { 0, 1, 0, 1, 0, 0 },
120 { 0, 1, 0, 1, 0, 0 },
121 { 0, 1, 0, 1, 0, 0 },
122 { 0, 0, 0, 0, 0, 0 },
123 { 0, 0, 0, 0, 0, 0 },
124 { 0, 0, 0, 0, 0, 0 },
125 { 0, 0, 0, 0, 0, 0 }
126 },
127
128
129 {
130 { 0, 0, 0, 1, 0, 0 },
131 { 0, 0, 0, 1, 0, 0 },
132 { 0, 1, 1, 0, 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, 0, 0, 1, 0, 0 },
138 { 0, 1, 0, 1, 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, 0, 0, 1, 0, 0 },
145 { 0, 1, 0, 0, 0, 0 },
146 { 1, 1, 0, 0, 0, 0 },
147 { 0, 1, 0, 0, 0, 0 },
148 { 0, 0, 0, 1, 0, 0 },
149 { 0, 1, 0, 1, 0, 0 },
150 { 0, 0, 0, 1, 0, 0 },
151 { 1, 0, 0, 1, 0, 0 },
152 { 1, 0, 0, 0, 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, 0 },
159 { 0, 0, 0, 1, 0, 1 },
160 { 0, 0, 0, 1, 0, 0 },
161 { 0, 0, 0, 1, 0, 0 },
162 },
163
164
165 {
166 { 1, 1, 0, 0, 0, 0 },
167 { 1, 1, 1, 1, 0, 0 },
168 { 1, 1, 0, 1, 0, 0 },
169 { 0, 1, 0, 0, 0, 0 },
170 { 0, 1, 1, 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, 0, 0, 1, 0, 0 },
180 { 0, 1, 0, 0, 0, 0 },
181 { 0, 1, 0, 1, 0, 0 },
182 { 0, 1, 1, 0, 1, 0 },
183 { 0, 0, 0, 1, 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, 0, 0, 0, 0, 0 },
188 { 0, 1, 0, 1, 0, 0 },
189 { 0, 1, 0, 0, 0, 0 },
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, 1, 0, 1 },
194 { 0, 0, 0, 0, 0, 0 },
195 { 0, 0, 0, 0, 0, 0 },
196 { 0, 0, 0, 0, 0, 0 },
197 { 0, 0, 0, 0, 0, 0 }
198 }
199};
200
201int checkboard (void)
202{
203 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
204
205
206 uint pci_slot = get_pci_slot ();
207
208 uint pci_dual = get_pci_dual ();
209 uint pci1_32 = gur->pordevsr & 0x10000;
210 uint pci1_clk_sel = gur->porpllsr & 0x8000;
211 uint pci2_clk_sel = gur->porpllsr & 0x4000;
212
213 uint pci1_speed = get_clock_freq ();
214
215 uint cpu_board_rev = get_cpu_board_revision ();
216
217 printf ("Board: CDS Version 0x%02x, PCI Slot %d\n",
218 get_board_version (), pci_slot);
219
220 printf ("CPU Board Revision %d.%d (0x%04x)\n",
221 MPC85XX_CPU_BOARD_MAJOR (cpu_board_rev),
222 MPC85XX_CPU_BOARD_MINOR (cpu_board_rev), cpu_board_rev);
223
224 printf (" PCI1: %d bit, %s MHz, %s\n",
225 (pci1_32) ? 32 : 64,
226 (pci1_speed == 33000000) ? "33" :
227 (pci1_speed == 66000000) ? "66" : "unknown",
228 pci1_clk_sel ? "sync" : "async");
229
230 if (pci_dual) {
231 printf (" PCI2: 32 bit, 66 MHz, %s\n",
232 pci2_clk_sel ? "sync" : "async");
233 } else {
234 printf (" PCI2: disabled\n");
235 }
236
237
238
239
240 local_bus_init ();
241
242 return 0;
243}
244
245phys_size_t
246initdram(int board_type)
247{
248 long dram_size = 0;
249
250 puts("Initializing\n");
251
252#if defined(CONFIG_DDR_DLL)
253 {
254
255
256
257
258
259
260
261 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
262
263 gur->ddrdllcr = 0x81000000;
264 asm("sync;isync;msync");
265 udelay(200);
266 }
267#endif
268 dram_size = fsl_ddr_sdram();
269 dram_size = setup_ddr_tlbs(dram_size / 0x100000);
270 dram_size *= 0x100000;
271
272#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
273
274
275
276 ddr_enable_ecc(dram_size);
277#endif
278
279
280
281 sdram_init();
282
283 puts(" DDR: ");
284 return dram_size;
285}
286
287
288
289
290void
291local_bus_init(void)
292{
293 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
294 volatile ccsr_lbc_t *lbc = (void *)(CONFIG_SYS_MPC85xx_LBC_ADDR);
295
296 uint clkdiv;
297 uint lbc_hz;
298 sys_info_t sysinfo;
299 uint temp_lbcdll;
300
301
302
303
304
305
306
307
308
309
310 get_sys_info(&sysinfo);
311 clkdiv = lbc->lcrr & LCRR_CLKDIV;
312 lbc_hz = sysinfo.freqSystemBus / 1000000 / clkdiv;
313
314 if (lbc_hz < 66) {
315 lbc->lcrr |= 0x80000000;
316
317 } else if (lbc_hz >= 133) {
318 lbc->lcrr &= (~0x80000000);
319
320 } else {
321 lbc->lcrr &= (~0x8000000);
322 udelay(200);
323
324
325
326
327
328 temp_lbcdll = gur->lbcdllcr;
329 gur->lbcdllcr = (((temp_lbcdll & 0xff) << 16) | 0x80000000);
330 asm("sync;isync;msync");
331 }
332}
333
334
335
336
337void
338sdram_init(void)
339{
340#if defined(CONFIG_SYS_OR2_PRELIM) && defined(CONFIG_SYS_BR2_PRELIM)
341
342 uint idx;
343 volatile ccsr_lbc_t *lbc = (void *)(CONFIG_SYS_MPC85xx_LBC_ADDR);
344 uint *sdram_addr = (uint *)CONFIG_SYS_LBC_SDRAM_BASE;
345 uint cpu_board_rev;
346 uint lsdmr_common;
347
348 puts(" SDRAM: ");
349
350 print_size (CONFIG_SYS_LBC_SDRAM_SIZE * 1024 * 1024, "\n");
351
352
353
354
355 lbc->or2 = CONFIG_SYS_OR2_PRELIM;
356 asm("msync");
357
358 lbc->br2 = CONFIG_SYS_BR2_PRELIM;
359 asm("msync");
360
361 lbc->lbcr = CONFIG_SYS_LBC_LBCR;
362 asm("msync");
363
364
365 lbc->lsrt = CONFIG_SYS_LBC_LSRT;
366 lbc->mrtpr = CONFIG_SYS_LBC_MRTPR;
367 asm("msync");
368
369
370
371
372 cpu_board_rev = get_cpu_board_revision();
373 lsdmr_common = CONFIG_SYS_LBC_LSDMR_COMMON;
374 if (cpu_board_rev == MPC85XX_CPU_BOARD_REV_1_0) {
375 lsdmr_common |= CONFIG_SYS_LBC_LSDMR_BSMA1617;
376 } else if (cpu_board_rev == MPC85XX_CPU_BOARD_REV_1_1) {
377 lsdmr_common |= CONFIG_SYS_LBC_LSDMR_BSMA1516;
378 } else {
379
380
381
382
383 lsdmr_common |= CONFIG_SYS_LBC_LSDMR_BSMA1617;
384 }
385
386
387
388
389 lbc->lsdmr = lsdmr_common | CONFIG_SYS_LBC_LSDMR_OP_PCHALL;
390 asm("sync;msync");
391 *sdram_addr = 0xff;
392 ppcDcbf((unsigned long) sdram_addr);
393 udelay(100);
394
395
396
397
398 for (idx = 0; idx < 8; idx++) {
399 lbc->lsdmr = lsdmr_common | CONFIG_SYS_LBC_LSDMR_OP_ARFRSH;
400 asm("sync;msync");
401 *sdram_addr = 0xff;
402 ppcDcbf((unsigned long) sdram_addr);
403 udelay(100);
404 }
405
406
407
408
409 lbc->lsdmr = lsdmr_common | CONFIG_SYS_LBC_LSDMR_OP_MRW;
410 asm("sync;msync");
411 *sdram_addr = 0xff;
412 ppcDcbf((unsigned long) sdram_addr);
413 udelay(100);
414
415
416
417
418 lbc->lsdmr = lsdmr_common | CONFIG_SYS_LBC_LSDMR_OP_NORMAL;
419 asm("sync;msync");
420 *sdram_addr = 0xff;
421 ppcDcbf((unsigned long) sdram_addr);
422 udelay(200);
423
424#endif
425}
426
427#if defined(CONFIG_PCI)
428
429
430
431void dummy_func(struct pci_controller* hose, pci_dev_t dev, struct pci_config_table *tab) { }
432
433static struct pci_config_table pci_mpc85xxcds_config_table[] = {
434 {0x10e3, 0x0513, PCI_ANY_ID, 1, 3, PCI_ANY_ID, dummy_func, {0,0,0}},
435 {0x1106, 0x0686, PCI_ANY_ID, 1, VIA_ID, 0, mpc85xx_config_via, {0,0,0}},
436 {0x1106, 0x0571, PCI_ANY_ID, 1, VIA_ID, 1,
437 mpc85xx_config_via_usbide, {0,0,0}},
438 {0x1105, 0x3038, PCI_ANY_ID, 1, VIA_ID, 2,
439 mpc85xx_config_via_usb, {0,0,0}},
440 {0x1106, 0x3038, PCI_ANY_ID, 1, VIA_ID, 3,
441 mpc85xx_config_via_usb2, {0,0,0}},
442 {0x1106, 0x3058, PCI_ANY_ID, 1, VIA_ID, 5,
443 mpc85xx_config_via_power, {0,0,0}},
444 {0x1106, 0x3068, PCI_ANY_ID, 1, VIA_ID, 6,
445 mpc85xx_config_via_ac97, {0,0,0}},
446 {},
447};
448
449static struct pci_controller hose[] = {
450 { config_table: pci_mpc85xxcds_config_table,},
451#ifdef CONFIG_MPC85XX_PCI2
452 {},
453#endif
454};
455
456#endif
457
458void
459pci_init_board(void)
460{
461#ifdef CONFIG_PCI
462 pci_mpc85xx_init(hose);
463#endif
464}
465
466#if defined(CONFIG_OF_BOARD_SETUP)
467void
468ft_pci_setup(void *blob, bd_t *bd)
469{
470 int node, tmp[2];
471 const char *path;
472
473 node = fdt_path_offset(blob, "/aliases");
474 tmp[0] = 0;
475 if (node >= 0) {
476#ifdef CONFIG_PCI1
477 path = fdt_getprop(blob, node, "pci0", NULL);
478 if (path) {
479 tmp[1] = hose[0].last_busno - hose[0].first_busno;
480 do_fixup_by_path(blob, path, "bus-range", &tmp, 8, 1);
481 }
482#endif
483#ifdef CONFIG_MPC85XX_PCI2
484 path = fdt_getprop(blob, node, "pci1", NULL);
485 if (path) {
486 tmp[1] = hose[1].last_busno - hose[1].first_busno;
487 do_fixup_by_path(blob, path, "bus-range", &tmp, 8, 1);
488 }
489#endif
490 }
491}
492#endif
493