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);
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 { 1, 0, 0, 0, 0, 0 },
88 { 0, 0, 0, 1, 0, 0 }
89 },
90
91
92 {
93 { 1, 1, 0, 1, 0, 0 },
94 { 1, 1, 0, 0, 0, 0 },
95 { 1, 1, 1, 1, 0, 0 },
96 { 1, 1, 0, 0, 0, 0 },
97 { 1, 1, 0, 0, 0, 0 },
98 { 1, 1, 0, 0, 0, 0 },
99 { 1, 1, 0, 1, 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, 0, 0, 0 },
104 { 1, 1, 0, 0, 0, 0 },
105 { 1, 1, 0, 0, 0, 0 },
106 { 1, 1, 0, 0, 0, 0 },
107 { 0, 1, 0, 0, 0, 0 },
108 { 0, 1, 0, 0, 0, 0 },
109 { 0, 1, 0, 1, 0, 0 },
110 { 0, 1, 0, 1, 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, 0, 0, 0 },
115 { 0, 1, 0, 0, 0, 0 },
116 { 0, 1, 0, 0, 0, 0 },
117 { 0, 1, 0, 1, 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, 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 { 1, 1, 0, 0, 0, 0 },
142 { 1, 1, 0, 0, 0, 0 },
143 { 0, 0, 0, 1, 0, 0 },
144 { 0, 1, 0, 0, 0, 0 },
145 { 1, 1, 0, 0, 0, 0 },
146 { 0, 1, 0, 0, 0, 0 },
147 { 0, 0, 0, 1, 0, 0 },
148 { 0, 1, 0, 1, 0, 0 },
149 { 0, 0, 0, 1, 0, 0 },
150 { 1, 0, 0, 1, 0, 0 },
151 { 1, 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 { 0, 1, 0, 0, 0, 0 },
169 { 0, 1, 1, 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, 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
200int checkboard (void)
201{
202 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
203 char buf[32];
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 strmhz(buf, pci1_speed),
227 pci1_clk_sel ? "sync" : "async");
228
229 if (pci_dual) {
230 printf("PCI2: 32 bit, 66 MHz, %s\n",
231 pci2_clk_sel ? "sync" : "async");
232 } else {
233 printf("PCI2: disabled\n");
234 }
235
236
237
238
239 local_bus_init ();
240
241 return 0;
242}
243
244
245
246
247void
248local_bus_init(void)
249{
250 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
251 volatile fsl_lbc_t *lbc = LBC_BASE_ADDR;
252
253 uint clkdiv;
254 uint lbc_hz;
255 sys_info_t sysinfo;
256 uint temp_lbcdll;
257
258
259
260
261
262
263
264
265
266
267 get_sys_info(&sysinfo);
268 clkdiv = lbc->lcrr & LCRR_CLKDIV;
269 lbc_hz = sysinfo.freqSystemBus / 1000000 / clkdiv;
270
271 if (lbc_hz < 66) {
272 lbc->lcrr |= LCRR_DBYP;
273
274 } else if (lbc_hz >= 133) {
275 lbc->lcrr &= (~LCRR_DBYP);
276
277 } else {
278 lbc->lcrr &= (~LCRR_DBYP);
279 udelay(200);
280
281
282
283
284
285 temp_lbcdll = gur->lbcdllcr;
286 gur->lbcdllcr = (((temp_lbcdll & 0xff) << 16) | 0x80000000);
287 asm("sync;isync;msync");
288 }
289}
290
291
292
293
294void lbc_sdram_init(void)
295{
296#if defined(CONFIG_SYS_OR2_PRELIM) && defined(CONFIG_SYS_BR2_PRELIM)
297
298 uint idx;
299 volatile fsl_lbc_t *lbc = LBC_BASE_ADDR;
300 uint *sdram_addr = (uint *)CONFIG_SYS_LBC_SDRAM_BASE;
301 uint cpu_board_rev;
302 uint lsdmr_common;
303
304 puts("LBC SDRAM: ");
305 print_size(CONFIG_SYS_LBC_SDRAM_SIZE * 1024 * 1024,
306 "\n ");
307
308
309
310
311 set_lbc_or(2, CONFIG_SYS_OR2_PRELIM);
312 set_lbc_br(2, CONFIG_SYS_BR2_PRELIM);
313 lbc->lbcr = CONFIG_SYS_LBC_LBCR;
314 asm("msync");
315
316 lbc->lsrt = CONFIG_SYS_LBC_LSRT;
317 lbc->mrtpr = CONFIG_SYS_LBC_MRTPR;
318 asm("msync");
319
320
321
322
323 cpu_board_rev = get_cpu_board_revision();
324 lsdmr_common = CONFIG_SYS_LBC_LSDMR_COMMON;
325 if (cpu_board_rev == MPC85XX_CPU_BOARD_REV_1_0) {
326 lsdmr_common |= LSDMR_BSMA1617;
327 } else if (cpu_board_rev == MPC85XX_CPU_BOARD_REV_1_1) {
328 lsdmr_common |= LSDMR_BSMA1516;
329 } else {
330
331
332
333
334 lsdmr_common |= LSDMR_BSMA1617;
335 }
336
337
338
339
340 lbc->lsdmr = lsdmr_common | LSDMR_OP_PCHALL;
341 asm("sync;msync");
342 *sdram_addr = 0xff;
343 ppcDcbf((unsigned long) sdram_addr);
344 udelay(100);
345
346
347
348
349 for (idx = 0; idx < 8; idx++) {
350 lbc->lsdmr = lsdmr_common | LSDMR_OP_ARFRSH;
351 asm("sync;msync");
352 *sdram_addr = 0xff;
353 ppcDcbf((unsigned long) sdram_addr);
354 udelay(100);
355 }
356
357
358
359
360 lbc->lsdmr = lsdmr_common | LSDMR_OP_MRW;
361 asm("sync;msync");
362 *sdram_addr = 0xff;
363 ppcDcbf((unsigned long) sdram_addr);
364 udelay(100);
365
366
367
368
369 lbc->lsdmr = lsdmr_common | LSDMR_OP_NORMAL;
370 asm("sync;msync");
371 *sdram_addr = 0xff;
372 ppcDcbf((unsigned long) sdram_addr);
373 udelay(200);
374
375#endif
376}
377
378#if defined(CONFIG_PCI)
379
380
381
382void dummy_func(struct pci_controller* hose, pci_dev_t dev, struct pci_config_table *tab) { }
383
384static struct pci_config_table pci_mpc85xxcds_config_table[] = {
385 {0x10e3, 0x0513, PCI_ANY_ID, 1, 3, PCI_ANY_ID, dummy_func, {0,0,0}},
386 {0x1106, 0x0686, PCI_ANY_ID, 1, VIA_ID, 0, mpc85xx_config_via, {0,0,0}},
387 {0x1106, 0x0571, PCI_ANY_ID, 1, VIA_ID, 1,
388 mpc85xx_config_via_usbide, {0,0,0}},
389 {0x1105, 0x3038, PCI_ANY_ID, 1, VIA_ID, 2,
390 mpc85xx_config_via_usb, {0,0,0}},
391 {0x1106, 0x3038, PCI_ANY_ID, 1, VIA_ID, 3,
392 mpc85xx_config_via_usb2, {0,0,0}},
393 {0x1106, 0x3058, PCI_ANY_ID, 1, VIA_ID, 5,
394 mpc85xx_config_via_power, {0,0,0}},
395 {0x1106, 0x3068, PCI_ANY_ID, 1, VIA_ID, 6,
396 mpc85xx_config_via_ac97, {0,0,0}},
397 {},
398};
399
400static struct pci_controller hose[] = {
401 { config_table: pci_mpc85xxcds_config_table,},
402#ifdef CONFIG_MPC85XX_PCI2
403 {},
404#endif
405};
406
407#endif
408
409void
410pci_init_board(void)
411{
412#ifdef CONFIG_PCI
413 pci_mpc85xx_init(hose);
414#endif
415}
416
417#if defined(CONFIG_OF_BOARD_SETUP)
418void
419ft_pci_setup(void *blob, bd_t *bd)
420{
421 int node, tmp[2];
422 const char *path;
423
424 node = fdt_path_offset(blob, "/aliases");
425 tmp[0] = 0;
426 if (node >= 0) {
427#ifdef CONFIG_PCI1
428 path = fdt_getprop(blob, node, "pci0", NULL);
429 if (path) {
430 tmp[1] = hose[0].last_busno - hose[0].first_busno;
431 do_fixup_by_path(blob, path, "bus-range", &tmp, 8, 1);
432 }
433#endif
434#ifdef CONFIG_MPC85XX_PCI2
435 path = fdt_getprop(blob, node, "pci1", NULL);
436 if (path) {
437 tmp[1] = hose[1].last_busno - hose[1].first_busno;
438 do_fixup_by_path(blob, path, "bus-range", &tmp, 8, 1);
439 }
440#endif
441 }
442}
443#endif
444