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#include <common.h>
28#include "ocotea.h"
29#include <asm/processor.h>
30#include <spd_sdram.h>
31#include <ppc4xx_enet.h>
32
33DECLARE_GLOBAL_DATA_PTR;
34
35#define BOOT_SMALL_FLASH 32
36#define FLASH_ONBD_N 2
37#define FLASH_SRAM_SEL 1
38
39long int fixed_sdram (void);
40void fpga_init (void);
41
42int board_early_init_f (void)
43{
44 unsigned long mfr;
45 unsigned char *fpga_base = (unsigned char *) CONFIG_SYS_FPGA_BASE;
46 unsigned char switch_status;
47 unsigned long cs0_base;
48 unsigned long cs0_size;
49 unsigned long cs0_twt;
50 unsigned long cs2_base;
51 unsigned long cs2_size;
52 unsigned long cs2_twt;
53
54
55
56
57 mtebc(xbcfg, EBC_CFG_LE_UNLOCK |
58 EBC_CFG_PTD_ENABLE | EBC_CFG_RTC_64PERCLK |
59 EBC_CFG_ATC_PREVIOUS | EBC_CFG_DTC_PREVIOUS |
60 EBC_CFG_CTC_PREVIOUS | EBC_CFG_EMC_NONDEFAULT |
61 EBC_CFG_PME_DISABLE | EBC_CFG_PR_32);
62
63
64
65
66 mtebc(pb7ap, EBC_BXAP_BME_DISABLED|EBC_BXAP_TWT_ENCODE(7)|
67 EBC_BXAP_BCE_DISABLE|
68 EBC_BXAP_CSN_ENCODE(1)|EBC_BXAP_OEN_ENCODE(1)|
69 EBC_BXAP_WBN_ENCODE(1)|EBC_BXAP_WBF_ENCODE(1)|
70 EBC_BXAP_TH_ENCODE(1)|EBC_BXAP_RE_DISABLED|
71 EBC_BXAP_BEM_WRITEONLY|
72 EBC_BXAP_PEN_DISABLED);
73 mtebc(pb7cr, EBC_BXCR_BAS_ENCODE(0x48300000)|
74 EBC_BXCR_BS_1MB|EBC_BXCR_BU_RW|EBC_BXCR_BW_8BIT);
75
76
77 switch_status = *fpga_base;
78
79 if (switch_status & 0x40) {
80 cs0_base = 0xFFE00000;
81 cs0_size = EBC_BXCR_BS_2MB;
82 cs0_twt = 8;
83 cs2_base = 0xFF800000;
84 cs2_size = EBC_BXCR_BS_4MB;
85 cs2_twt = 10;
86 } else {
87 cs0_base = 0xFFC00000;
88 cs0_size = EBC_BXCR_BS_4MB;
89 cs0_twt = 10;
90 cs2_base = 0xFF800000;
91 cs2_size = EBC_BXCR_BS_2MB;
92 cs2_twt = 8;
93 }
94
95
96
97
98 mtebc(pb0ap, EBC_BXAP_BME_DISABLED|EBC_BXAP_TWT_ENCODE(cs0_twt)|
99 EBC_BXAP_BCE_DISABLE|
100 EBC_BXAP_CSN_ENCODE(1)|EBC_BXAP_OEN_ENCODE(1)|
101 EBC_BXAP_WBN_ENCODE(1)|EBC_BXAP_WBF_ENCODE(1)|
102 EBC_BXAP_TH_ENCODE(1)|EBC_BXAP_RE_DISABLED|
103 EBC_BXAP_BEM_WRITEONLY|
104 EBC_BXAP_PEN_DISABLED);
105 mtebc(pb0cr, EBC_BXCR_BAS_ENCODE(cs0_base)|
106 cs0_size|EBC_BXCR_BU_RW|EBC_BXCR_BW_8BIT);
107
108
109
110
111 mtebc(pb1ap, EBC_BXAP_BME_DISABLED|EBC_BXAP_TWT_ENCODE(10)|
112 EBC_BXAP_BCE_DISABLE|
113 EBC_BXAP_CSN_ENCODE(1)|EBC_BXAP_OEN_ENCODE(1)|
114 EBC_BXAP_WBN_ENCODE(1)|EBC_BXAP_WBF_ENCODE(1)|
115 EBC_BXAP_TH_ENCODE(1)|EBC_BXAP_RE_DISABLED|
116 EBC_BXAP_BEM_WRITEONLY|
117 EBC_BXAP_PEN_DISABLED);
118 mtebc(pb1cr, EBC_BXCR_BAS_ENCODE(0x48000000)|
119 EBC_BXCR_BS_1MB|EBC_BXCR_BU_RW|EBC_BXCR_BW_8BIT);
120
121
122
123
124 mtebc(pb2ap, EBC_BXAP_BME_DISABLED|EBC_BXAP_TWT_ENCODE(cs2_twt)|
125 EBC_BXAP_BCE_DISABLE|
126 EBC_BXAP_CSN_ENCODE(1)|EBC_BXAP_OEN_ENCODE(1)|
127 EBC_BXAP_WBN_ENCODE(1)|EBC_BXAP_WBF_ENCODE(1)|
128 EBC_BXAP_TH_ENCODE(1)|EBC_BXAP_RE_DISABLED|
129 EBC_BXAP_BEM_WRITEONLY|
130 EBC_BXAP_PEN_DISABLED);
131 mtebc(pb2cr, EBC_BXCR_BAS_ENCODE(cs2_base)|
132 cs2_size|EBC_BXCR_BU_RW|EBC_BXCR_BW_8BIT);
133
134
135
136
137 mtebc(pb7ap, EBC_BXAP_BME_DISABLED|EBC_BXAP_TWT_ENCODE(7)|
138 EBC_BXAP_BCE_DISABLE|
139 EBC_BXAP_CSN_ENCODE(1)|EBC_BXAP_OEN_ENCODE(1)|
140 EBC_BXAP_WBN_ENCODE(1)|EBC_BXAP_WBF_ENCODE(1)|
141 EBC_BXAP_TH_ENCODE(1)|EBC_BXAP_RE_DISABLED|
142 EBC_BXAP_BEM_WRITEONLY|
143 EBC_BXAP_PEN_DISABLED);
144 mtebc(pb7cr, EBC_BXCR_BAS_ENCODE(0x48300000)|
145 EBC_BXCR_BS_1MB|EBC_BXCR_BU_RW|EBC_BXCR_BW_8BIT);
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162 mtdcr (uic1sr, 0xffffffff);
163 mtdcr (uic1er, 0x00000000);
164 mtdcr (uic1cr, 0x00000009);
165 mtdcr (uic1pr, 0xfffffe13);
166 mtdcr (uic1tr, 0x01c00008);
167 mtdcr (uic1vr, 0x00000001);
168 mtdcr (uic1sr, 0xffffffff);
169
170 mtdcr (uic2sr, 0xffffffff);
171 mtdcr (uic2er, 0x00000000);
172 mtdcr (uic2cr, 0x00000000);
173 mtdcr (uic2pr, 0xffffe0ff);
174 mtdcr (uic2tr, 0x00ffc000);
175 mtdcr (uic2vr, 0x00000001);
176 mtdcr (uic2sr, 0xffffffff);
177
178 mtdcr (uic3sr, 0xffffffff);
179 mtdcr (uic3er, 0x00000000);
180 mtdcr (uic3cr, 0x00000000);
181 mtdcr (uic3pr, 0xffffffff);
182 mtdcr (uic3tr, 0x00ff8c0f);
183 mtdcr (uic3vr, 0x00000001);
184 mtdcr (uic3sr, 0xffffffff);
185
186 mtdcr (uic0sr, 0xfc000000);
187 mtdcr (uic0er, 0x00000000);
188 mtdcr (uic0cr, 0x00000000);
189 mtdcr (uic0pr, 0xfc000000);
190 mtdcr (uic0tr, 0x00000000);
191 mtdcr (uic0vr, 0x00000001);
192 mfsdr (sdr_mfr, mfr);
193 mfr &= ~SDR0_MFR_ECS_MASK;
194
195 fpga_init();
196
197 return 0;
198}
199
200
201int checkboard (void)
202{
203 char *s = getenv ("serial#");
204
205 printf ("Board: Ocotea - AMCC PPC440GX Evaluation Board");
206 if (s != NULL) {
207 puts (", serial# ");
208 puts (s);
209 }
210 putc ('\n');
211
212 return (0);
213}
214
215
216phys_size_t initdram (int board_type)
217{
218 long dram_size = 0;
219
220#if defined(CONFIG_SPD_EEPROM)
221 dram_size = spd_sdram ();
222#else
223 dram_size = fixed_sdram ();
224#endif
225 return dram_size;
226}
227
228
229#if !defined(CONFIG_SPD_EEPROM)
230
231
232
233
234
235
236
237long int fixed_sdram (void)
238{
239 uint reg;
240
241
242
243
244 mtsdram (mem_uabba, 0x00000000);
245 mtsdram (mem_slio, 0x00000000);
246 mtsdram (mem_devopt, 0x00000000);
247 mtsdram (mem_wddctr, 0x00000000);
248 mtsdram (mem_clktr, 0x40000000);
249
250
251
252
253
254
255
256 mtsdram (mem_b0cr, 0x000a4001);
257 mtsdram (mem_tr0, 0x410a4012);
258
259 mtsdram (mem_tr1, 0x8080082f);
260 mtsdram (mem_rtr, 0x08200000);
261 mtsdram (mem_cfg1, 0x00000000);
262 udelay (400);
263
264
265
266
267 mtsdram (mem_cfg0, 0x86000000);
268 for (;;) {
269 mfsdram (mem_mcsts, reg);
270 if (reg & 0x80000000)
271 break;
272 }
273
274 return (128 * 1024 * 1024);
275}
276#endif
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291#if defined(CONFIG_PCI)
292int pci_pre_init(struct pci_controller * hose )
293{
294 unsigned long strap;
295
296
297
298
299
300 mfsdr(sdr_sdstp1, strap);
301 if( (strap & SDR0_SDSTP1_PAE_MASK) == 0 ){
302 printf("PCI: SDR0_STRP1[%08lX] - PCI Arbiter disabled.\n",strap);
303 return 0;
304 }
305
306 return 1;
307}
308#endif
309
310
311
312
313
314
315
316
317
318#if defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_TARGET_INIT)
319void pci_target_init(struct pci_controller * hose )
320{
321
322
323
324 out32r( PCIX0_PIM0SA, 0 );
325 out32r( PCIX0_PIM1SA, 0 );
326 out32r( PCIX0_PIM2SA, 0 );
327 out32r( PCIX0_EROMBA, 0 );
328
329
330
331
332
333 out32r( PCIX0_PIM0LAL, CONFIG_SYS_SDRAM_BASE );
334 out32r( PCIX0_PIM0LAH, 0 );
335 out32r( PCIX0_PIM0SA, ~(gd->ram_size - 1) | 1 );
336
337 out32r( PCIX0_BAR0, 0 );
338
339
340
341
342 out16r( PCIX0_SBSYSVID, CONFIG_SYS_PCI_SUBSYS_VENDORID );
343 out16r( PCIX0_SBSYSID, CONFIG_SYS_PCI_SUBSYS_DEVICEID );
344
345 out16r( PCIX0_CMD, in16r(PCIX0_CMD) | PCI_COMMAND_MEMORY );
346}
347#endif
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365#if defined(CONFIG_PCI)
366int is_pci_host(struct pci_controller *hose)
367{
368
369 return(1);
370}
371#endif
372
373
374void fpga_init(void)
375{
376 unsigned long group;
377 unsigned long sdr0_pfc0;
378 unsigned long sdr0_pfc1;
379 unsigned long sdr0_cust0;
380 unsigned long pvr;
381
382 mfsdr (sdr_pfc0, sdr0_pfc0);
383 mfsdr (sdr_pfc1, sdr0_pfc1);
384 group = SDR0_PFC1_EPS_DECODE(sdr0_pfc1);
385 pvr = get_pvr ();
386
387 sdr0_pfc0 = (sdr0_pfc0 & ~SDR0_PFC0_GEIE_MASK) | SDR0_PFC0_GEIE_TRE;
388 if ( ((pvr == PVR_440GX_RA) || (pvr == PVR_440GX_RB)) && ((group == 4) || (group == 5))) {
389 sdr0_pfc0 = (sdr0_pfc0 & ~SDR0_PFC0_TRE_MASK) | SDR0_PFC0_TRE_DISABLE;
390 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_CTEMS_MASK) | SDR0_PFC1_CTEMS_EMS;
391 out8(FPGA_REG2, (in8(FPGA_REG2) & ~FPGA_REG2_EXT_INTFACE_MASK) |
392 FPGA_REG2_EXT_INTFACE_ENABLE);
393 mtsdr (sdr_pfc0, sdr0_pfc0);
394 mtsdr (sdr_pfc1, sdr0_pfc1);
395 } else {
396 sdr0_pfc0 = (sdr0_pfc0 & ~SDR0_PFC0_TRE_MASK) | SDR0_PFC0_TRE_ENABLE;
397 switch (group)
398 {
399 case 0:
400 case 1:
401 case 2:
402
403 out8(FPGA_REG2, (in8(FPGA_REG2) & ~FPGA_REG2_EXT_INTFACE_MASK) |
404 FPGA_REG2_EXT_INTFACE_ENABLE);
405 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_CTEMS_MASK) | SDR0_PFC1_CTEMS_EMS;
406 mtsdr (sdr_pfc0, sdr0_pfc0);
407 mtsdr (sdr_pfc1, sdr0_pfc1);
408 break;
409 case 3:
410 case 4:
411 case 5:
412 case 6:
413
414 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_CTEMS_MASK) | SDR0_PFC1_CTEMS_CPUTRACE;
415 mtsdr (sdr_pfc0, sdr0_pfc0);
416 mtsdr (sdr_pfc1, sdr0_pfc1);
417 out8(FPGA_REG2, (in8(FPGA_REG2) & ~FPGA_REG2_EXT_INTFACE_MASK) |
418 FPGA_REG2_EXT_INTFACE_DISABLE);
419 break;
420 }
421 }
422
423
424 mfsdr(sdr_pfc1, sdr0_pfc1);
425 mfsdr(sdr_cust0, sdr0_cust0);
426 if ( (SDR0_PFC1_EPS_DECODE(sdr0_pfc1) == 4) &&
427 ((SDR0_CUST0_RGMII2_DECODE(sdr0_cust0) == RGMII_FER_GMII) ||
428 (SDR0_CUST0_RGMII2_DECODE(sdr0_cust0) == RGMII_FER_TBI)))
429 {
430 if ((in8(FPGA_REG0) & FPGA_REG0_ECLS_MASK) == FPGA_REG0_ECLS_VER1)
431 {
432 out8(FPGA_REG3, (in8(FPGA_REG3) & ~FPGA_REG3_ENET_MASK1) |
433 FPGA_REG3_ENET_GROUP7);
434 }
435 else
436 {
437 if (SDR0_CUST0_RGMII2_DECODE(sdr0_cust0) == RGMII_FER_GMII)
438 {
439 out8(FPGA_REG3, (in8(FPGA_REG3) & ~FPGA_REG3_ENET_MASK2) |
440 FPGA_REG3_ENET_GROUP7);
441 }
442 else
443 {
444 out8(FPGA_REG3, (in8(FPGA_REG3) & ~FPGA_REG3_ENET_MASK2) |
445 FPGA_REG3_ENET_GROUP8);
446 }
447 }
448 }
449 else
450 {
451 if ((in8(FPGA_REG0) & FPGA_REG0_ECLS_MASK) == FPGA_REG0_ECLS_VER1)
452 {
453 out8(FPGA_REG3, (in8(FPGA_REG3) & ~FPGA_REG3_ENET_MASK1) |
454 FPGA_REG3_ENET_ENCODE1(SDR0_PFC1_EPS_DECODE(sdr0_pfc1)));
455 }
456 else
457 {
458 out8(FPGA_REG3, (in8(FPGA_REG3) & ~FPGA_REG3_ENET_MASK2) |
459 FPGA_REG3_ENET_ENCODE2(SDR0_PFC1_EPS_DECODE(sdr0_pfc1)));
460 }
461 }
462 out8(FPGA_REG4, FPGA_REG4_GPHY_MODE10 |
463 FPGA_REG4_GPHY_MODE100 | FPGA_REG4_GPHY_MODE1000 |
464 FPGA_REG4_GPHY_FRC_DPLX | FPGA_REG4_CONNECT_PHYS);
465
466
467 if (SDR0_PFC1_EPS_DECODE(sdr0_pfc1) >= 3)
468 {
469 if ((in8(FPGA_REG0) & FPGA_REG0_ECLS_MASK) == FPGA_REG0_ECLS_VER1)
470 {
471 out8(FPGA_REG3, in8(FPGA_REG3) & ~FPGA_REG3_GIGABIT_RESET_DISABLE);
472 udelay(10000);
473 out8(FPGA_REG3, in8(FPGA_REG3) | FPGA_REG3_GIGABIT_RESET_DISABLE);
474 }
475 else
476 {
477 out8(FPGA_REG2, in8(FPGA_REG2) & ~FPGA_REG2_GIGABIT_RESET_DISABLE);
478 udelay(10000);
479 out8(FPGA_REG2, in8(FPGA_REG2) | FPGA_REG2_GIGABIT_RESET_DISABLE);
480 }
481 }
482
483
484
485
486 if ((in8(FPGA_REG0) & FPGA_REG0_ECLS_MASK) == FPGA_REG0_ECLS_VER2) {
487 out8(FPGA_REG2, in8(FPGA_REG2) & ~FPGA_REG2_SMII_RESET_DISABLE);
488 udelay(10000);
489 out8(FPGA_REG2, in8(FPGA_REG2) | FPGA_REG2_SMII_RESET_DISABLE);
490 }
491
492
493 out8(FPGA_REG3, (in8(FPGA_REG3) & ~FPGA_REG3_STAT_MASK) |
494 FPGA_REG3_STAT_LED8_DISAB | FPGA_REG3_STAT_LED4_DISAB |
495 FPGA_REG3_STAT_LED2_DISAB | FPGA_REG3_STAT_LED1_DISAB);
496
497 return;
498}
499
500#ifdef CONFIG_POST
501
502
503
504
505int post_hotkeys_pressed(void)
506{
507
508 return (ctrlc());
509}
510#endif
511