1
2
3
4
5
6
7
8
9
10
11
12#include <common.h>
13#include <pci.h>
14#include <asm/processor.h>
15#include <asm/mmu.h>
16#include <asm/immap_85xx.h>
17#include <fsl_ddr_sdram.h>
18#include <ioports.h>
19#include <spd_sdram.h>
20#include <miiphy.h>
21#include <libfdt.h>
22#include <fdt_support.h>
23#include <asm/fsl_lbc.h>
24
25#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
26extern void ddr_enable_ecc(unsigned int dram_size);
27#endif
28
29
30void local_bus_init(void);
31
32
33
34
35
36
37
38
39
40const iop_conf_t iop_conf_tab[4][32] = {
41
42
43 {
44 { 0, 1, 0, 1, 0, 0 },
45 { 0, 1, 0, 0, 0, 0 },
46 { 0, 1, 0, 1, 0, 0 },
47 { 0, 1, 0, 1, 0, 0 },
48 { 0, 1, 0, 0, 0, 0 },
49 { 0, 1, 0, 0, 0, 0 },
50 { 0, 1, 0, 1, 0, 0 },
51 { 0, 1, 0, 1, 0, 0 },
52 { 0, 1, 0, 1, 0, 0 },
53 { 0, 1, 0, 1, 0, 0 },
54 { 0, 1, 0, 1, 0, 0 },
55 { 0, 1, 0, 1, 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, 0, 0, 0 },
61 { 0, 1, 0, 0, 0, 0 },
62 { 0, 1, 0, 0, 0, 0 },
63 { 0, 1, 0, 0, 0, 0 },
64 { 0, 1, 0, 0, 0, 0 },
65 { 0, 1, 0, 0, 0, 0 },
66 { 0, 1, 1, 1, 0, 0 },
67 { 0, 1, 1, 0, 0, 0 },
68 { 0, 0, 0, 1, 0, 0 },
69 { 0, 1, 1, 1, 0, 0 },
70 { 0, 0, 0, 1, 0, 0 },
71 { 0, 0, 0, 1, 0, 0 },
72 { 0, 0, 0, 1, 0, 0 },
73 { 0, 0, 0, 1, 0, 0 },
74 { 1, 0, 0, 0, 0, 0 },
75 { 0, 0, 0, 1, 0, 0 }
76 },
77
78
79 {
80 { 1, 1, 0, 1, 0, 0 },
81 { 1, 1, 0, 0, 0, 0 },
82 { 1, 1, 1, 1, 0, 0 },
83 { 1, 1, 0, 0, 0, 0 },
84 { 1, 1, 0, 0, 0, 0 },
85 { 1, 1, 0, 0, 0, 0 },
86 { 1, 1, 0, 1, 0, 0 },
87 { 1, 1, 0, 1, 0, 0 },
88 { 1, 1, 0, 1, 0, 0 },
89 { 1, 1, 0, 1, 0, 0 },
90 { 1, 1, 0, 0, 0, 0 },
91 { 1, 1, 0, 0, 0, 0 },
92 { 1, 1, 0, 0, 0, 0 },
93 { 1, 1, 0, 0, 0, 0 },
94 { 0, 1, 0, 0, 0, 0 },
95 { 0, 1, 0, 0, 0, 0 },
96 { 0, 1, 0, 1, 0, 0 },
97 { 0, 1, 0, 1, 0, 0 },
98 { 0, 1, 0, 0, 0, 0 },
99 { 0, 1, 0, 0, 0, 0 },
100 { 0, 1, 0, 0, 0, 0 },
101 { 0, 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, 1, 0, 0 },
107 { 0, 1, 0, 1, 0, 0 },
108 { 0, 0, 0, 0, 0, 0 },
109 { 0, 0, 0, 0, 0, 0 },
110 { 0, 0, 0, 0, 0, 0 },
111 { 0, 0, 0, 0, 0, 0 }
112 },
113
114
115 {
116 { 0, 0, 0, 1, 0, 0 },
117 { 0, 0, 0, 1, 0, 0 },
118 { 0, 1, 1, 0, 0, 0 },
119 { 0, 0, 0, 1, 0, 0 },
120 { 0, 0, 0, 1, 0, 0 },
121 { 0, 0, 0, 1, 0, 0 },
122 { 0, 0, 0, 1, 0, 0 },
123 { 0, 0, 0, 1, 0, 0 },
124 { 0, 1, 0, 1, 0, 0 },
125 { 0, 1, 0, 0, 0, 0 },
126 { 0, 1, 0, 0, 0, 0 },
127 { 0, 1, 0, 0, 0, 0 },
128 { 1, 1, 0, 0, 0, 0 },
129 { 1, 1, 0, 0, 0, 0 },
130 { 0, 0, 0, 1, 0, 0 },
131 { 0, 1, 0, 0, 0, 0 },
132 { 1, 1, 0, 0, 0, 0 },
133 { 0, 1, 0, 0, 0, 0 },
134 { 0, 0, 0, 1, 0, 0 },
135 { 0, 1, 0, 1, 0, 0 },
136 { 0, 0, 0, 1, 0, 0 },
137 { 1, 0, 0, 1, 0, 0 },
138 { 1, 0, 0, 0, 0, 0 },
139 { 0, 0, 0, 1, 0, 0 },
140 { 0, 0, 0, 1, 0, 0 },
141 { 0, 0, 0, 1, 0, 0 },
142 { 0, 0, 0, 1, 0, 0 },
143 { 0, 0, 0, 1, 0, 0 },
144 { 0, 0, 0, 1, 0, 0 },
145 { 0, 0, 0, 1, 0, 1 },
146 { 0, 0, 0, 1, 0, 0 },
147 { 0, 0, 0, 1, 0, 0 },
148 },
149
150
151 {
152 { 1, 1, 0, 0, 0, 0 },
153 { 1, 1, 1, 1, 0, 0 },
154 { 1, 1, 0, 1, 0, 0 },
155 { 0, 1, 0, 0, 0, 0 },
156 { 0, 1, 1, 1, 0, 0 },
157 { 0, 0, 0, 1, 0, 0 },
158 { 0, 0, 0, 1, 0, 0 },
159 { 0, 0, 0, 1, 0, 0 },
160 { 0, 0, 0, 1, 0, 0 },
161 { 0, 0, 0, 1, 0, 0 },
162 { 0, 0, 0, 1, 0, 0 },
163 { 0, 0, 0, 1, 0, 0 },
164 { 0, 0, 0, 1, 0, 0 },
165 { 0, 0, 0, 1, 0, 0 },
166 { 0, 1, 0, 0, 0, 0 },
167 { 0, 1, 0, 1, 0, 0 },
168 { 0, 1, 1, 0, 1, 0 },
169 { 0, 0, 0, 1, 0, 0 },
170 { 0, 0, 0, 0, 0, 0 },
171 { 0, 0, 0, 0, 0, 0 },
172 { 0, 0, 0, 0, 0, 0 },
173 { 0, 0, 0, 0, 0, 0 },
174 { 0, 1, 0, 1, 0, 0 },
175 { 0, 1, 0, 0, 0, 0 },
176 { 0, 0, 0, 1, 0, 1 },
177 { 0, 0, 0, 1, 0, 1 },
178 { 0, 0, 0, 1, 0, 1 },
179 { 0, 0, 0, 1, 0, 1 },
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 }
185};
186
187
188
189
190
191typedef struct bcsr_ {
192 volatile unsigned char bcsr0;
193 volatile unsigned char bcsr1;
194 volatile unsigned char bcsr2;
195 volatile unsigned char bcsr3;
196 volatile unsigned char bcsr4;
197 volatile unsigned char bcsr5;
198} bcsr_t;
199
200void reset_phy (void)
201{
202#if defined(CONFIG_ETHER_ON_FCC)
203 volatile bcsr_t *bcsr = (bcsr_t *) CONFIG_SYS_BCSR;
204#endif
205
206
207
208#if (CONFIG_ETHER_INDEX == 2)
209 bcsr->bcsr2 &= ~FETH2_RST;
210 udelay(2);
211 bcsr->bcsr2 |= FETH2_RST;
212 udelay(1000);
213#elif (CONFIG_ETHER_INDEX == 3)
214 bcsr->bcsr3 &= ~FETH3_RST;
215 udelay(2);
216 bcsr->bcsr3 |= FETH3_RST;
217 udelay(1000);
218#endif
219#if defined(CONFIG_MII) && defined(CONFIG_ETHER_ON_FCC)
220
221 miiphy_reset("FCC1", 0x0);
222
223
224 bb_miiphy_write(NULL, 0, MII_MIPSCR, 0xf028);
225
226 bb_miiphy_write(NULL, 0x02, MII_BMCR,
227 BMCR_ANENABLE | BMCR_ANRESTART);
228#endif
229}
230
231
232int checkboard (void)
233{
234 puts("Board: ADS\n");
235
236#ifdef CONFIG_PCI
237 printf("PCI1: 32 bit, %d MHz (compiled)\n",
238 CONFIG_SYS_CLK_FREQ / 1000000);
239#else
240 printf("PCI1: disabled\n");
241#endif
242
243
244
245
246 local_bus_init();
247
248 return 0;
249}
250
251
252
253
254
255void
256local_bus_init(void)
257{
258 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
259 volatile fsl_lbc_t *lbc = LBC_BASE_ADDR;
260
261 uint clkdiv;
262 uint lbc_hz;
263 sys_info_t sysinfo;
264
265
266
267
268
269
270
271
272
273
274 get_sys_info(&sysinfo);
275 clkdiv = lbc->lcrr & LCRR_CLKDIV;
276 lbc_hz = sysinfo.freq_systembus / 1000000 / clkdiv;
277
278 if (lbc_hz < 66) {
279 lbc->lcrr = CONFIG_SYS_LBC_LCRR | LCRR_DBYP;
280
281 } else if (lbc_hz >= 133) {
282 lbc->lcrr = CONFIG_SYS_LBC_LCRR & (~LCRR_DBYP);
283
284 } else {
285
286
287
288
289 uint pvr = get_pvr();
290 uint temp_lbcdll = 0;
291
292 if (pvr == PVR_85xx_REV1) {
293
294 lbc->lcrr = 0x10000004;
295 }
296
297 lbc->lcrr = CONFIG_SYS_LBC_LCRR & (~LCRR_DBYP);
298 udelay(200);
299
300
301
302
303
304 temp_lbcdll = gur->lbcdllcr;
305 gur->lbcdllcr = (((temp_lbcdll & 0xff) << 16) | 0x80000000);
306 asm("sync;isync;msync");
307 }
308}
309
310
311
312
313
314void lbc_sdram_init(void)
315{
316 volatile fsl_lbc_t *lbc = LBC_BASE_ADDR;
317 uint *sdram_addr = (uint *)CONFIG_SYS_LBC_SDRAM_BASE;
318
319 puts("LBC SDRAM: ");
320 print_size(CONFIG_SYS_LBC_SDRAM_SIZE * 1024 * 1024,
321 "\n ");
322
323
324
325
326 set_lbc_or(2, CONFIG_SYS_OR2_PRELIM);
327 set_lbc_br(2, CONFIG_SYS_BR2_PRELIM);
328 lbc->lbcr = CONFIG_SYS_LBC_LBCR;
329 asm("msync");
330
331 lbc->lsrt = CONFIG_SYS_LBC_LSRT;
332 lbc->mrtpr = CONFIG_SYS_LBC_MRTPR;
333 asm("sync");
334
335
336
337
338 lbc->lsdmr = CONFIG_SYS_LBC_LSDMR_1;
339 asm("sync");
340 *sdram_addr = 0xff;
341 ppcDcbf((unsigned long) sdram_addr);
342 udelay(100);
343
344 lbc->lsdmr = CONFIG_SYS_LBC_LSDMR_2;
345 asm("sync");
346 *sdram_addr = 0xff;
347 ppcDcbf((unsigned long) sdram_addr);
348 udelay(100);
349
350 lbc->lsdmr = CONFIG_SYS_LBC_LSDMR_3;
351 asm("sync");
352 *sdram_addr = 0xff;
353 ppcDcbf((unsigned long) sdram_addr);
354 udelay(100);
355
356 lbc->lsdmr = CONFIG_SYS_LBC_LSDMR_4;
357 asm("sync");
358 *sdram_addr = 0xff;
359 ppcDcbf((unsigned long) sdram_addr);
360 udelay(100);
361
362 lbc->lsdmr = CONFIG_SYS_LBC_LSDMR_5;
363 asm("sync");
364 *sdram_addr = 0xff;
365 ppcDcbf((unsigned long) sdram_addr);
366 udelay(100);
367}
368
369#if !defined(CONFIG_SPD_EEPROM)
370
371
372
373phys_size_t fixed_sdram(void)
374{
375 #ifndef CONFIG_SYS_RAMBOOT
376 volatile ccsr_ddr_t *ddr = (void *)(CONFIG_SYS_FSL_DDR_ADDR);
377
378 ddr->cs0_bnds = CONFIG_SYS_DDR_CS0_BNDS;
379 ddr->cs0_config = CONFIG_SYS_DDR_CS0_CONFIG;
380 ddr->timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1;
381 ddr->timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2;
382 ddr->sdram_mode = CONFIG_SYS_DDR_MODE;
383 ddr->sdram_interval = CONFIG_SYS_DDR_INTERVAL;
384 #if defined (CONFIG_DDR_ECC)
385 ddr->err_disable = 0x0000000D;
386 ddr->err_sbe = 0x00ff0000;
387 #endif
388 asm("sync;isync;msync");
389 udelay(500);
390 #if defined (CONFIG_DDR_ECC)
391
392 ddr->sdram_cfg = (CONFIG_SYS_DDR_CONTROL | 0x20000000);
393 #else
394 ddr->sdram_cfg = CONFIG_SYS_DDR_CONTROL;
395 #endif
396 asm("sync; isync; msync");
397 udelay(500);
398 #endif
399 return CONFIG_SYS_SDRAM_SIZE * 1024 * 1024;
400}
401#endif
402
403
404#if defined(CONFIG_PCI)
405
406
407
408
409#ifndef CONFIG_PCI_PNP
410static struct pci_config_table pci_mpc85xxads_config_table[] = {
411 { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
412 PCI_IDSEL_NUMBER, PCI_ANY_ID,
413 pci_cfgfunc_config_device, { PCI_ENET0_IOADDR,
414 PCI_ENET0_MEMADDR,
415 PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER
416 } },
417 { }
418};
419#endif
420
421
422static struct pci_controller hose = {
423#ifndef CONFIG_PCI_PNP
424 config_table: pci_mpc85xxads_config_table,
425#endif
426};
427
428#endif
429
430
431void
432pci_init_board(void)
433{
434#ifdef CONFIG_PCI
435 pci_mpc85xx_init(&hose);
436#endif
437}
438
439
440#if defined(CONFIG_OF_BOARD_SETUP)
441int ft_board_setup(void *blob, bd_t *bd)
442{
443 int node, tmp[2];
444 const char *path;
445
446 ft_cpu_setup(blob, bd);
447
448 node = fdt_path_offset(blob, "/aliases");
449 tmp[0] = 0;
450 if (node >= 0) {
451#ifdef CONFIG_PCI
452 path = fdt_getprop(blob, node, "pci0", NULL);
453 if (path) {
454 tmp[1] = hose.last_busno - hose.first_busno;
455 do_fixup_by_path(blob, path, "bus-range", &tmp, 8, 1);
456 }
457#endif
458 }
459
460 return 0;
461}
462#endif
463