3 * Denis Peter, MPL AG Switzerland, d.peter@mpl.ch
5 * SPDX-License-Identifier: GPL-2.0+
11 * How do I program the SDRAM Timing Register (SDRAM0_TR) for a specific SDRAM or DIMM?
13 * As an example, consider a case where PC133 memory with CAS Latency equal to 2 is being
14 * used with a 200MHz 405GP. For a typical 128Mb, PC133 SDRAM, the relevant minimum
15 * parameters from the datasheet are:
16 * Tclk = 7.5ns (CL = 2)
22 * If we are operating the 405GP with the MemClk output frequency set to 100 MHZ, the clock
23 * period is 10ns and the parameters needed for the Timing Register are:
24 * CASL = CL = 2 clock cycles
25 * PTA = Trp = 15ns / 10ns = 2 clock cycles
26 * CTP = Trc - Trcd - Trp = (60ns - 15ns - 15ns) / 10ns= 3 clock cycles
27 * LDF = 2 clock cycles (but can be extended to meet board-level timing)
28 * RFTA = Trfc = 66ns / 10ns= 7 clock cycles
29 * RCD = Trcd = 15ns / 10ns= 2 clock cycles
31 * The actual bit settings in the register would be:
40 * If Trfc is not specified in the datasheet for PC100 or PC133 memory, set RFTA = Trc
41 * instead. Figure 24 in the PC SDRAM Specification Rev. 1.7 shows refresh to active delay
42 * defined as Trc rather than Trfc.
43 * When using DIMM modules, most but not all of the required timing parameters can be read
44 * from the Serial Presence Detect (SPD) EEPROM on the module. Specifically, Trc and Trfc
45 * are not available from the EEPROM
50 #include <asm/processor.h>
51 #include <asm/ppc4xx.h>
52 #include <asm/ppc4xx-i2c.h>
54 #include "../common/common_util.h"
55 #include <stdio_dev.h>
59 DECLARE_GLOBAL_DATA_PTR;
62 #define ENABLE_ECC /* for ecc boards */
64 /* stdlib.h causes some compatibility problems; should fixe these! -- wd */
65 #ifndef __ldiv_t_defined
67 long int quot; /* Quotient */
68 long int rem; /* Remainder */
70 extern ldiv_t ldiv (long int __numer, long int __denom);
71 # define __ldiv_t_defined 1
75 #define PLD_PART_REG PER_PLD_ADDR + 0
76 #define PLD_VERS_REG PER_PLD_ADDR + 1
77 #define PLD_BOARD_CFG_REG PER_PLD_ADDR + 2
78 #define PLD_IRQ_REG PER_PLD_ADDR + 3
79 #define PLD_COM_MODE_REG PER_PLD_ADDR + 4
80 #define PLD_EXT_CONF_REG PER_PLD_ADDR + 5
82 #define MEGA_BYTE (1024*1024)
85 unsigned char boardtype; /* Board revision and Population Options */
86 unsigned char cal; /* cas Latency (will be programmend as cal-1) */
87 unsigned char trp; /* datain27 in clocks */
88 unsigned char trcd; /* datain29 in clocks */
89 unsigned char tras; /* datain30 in clocks */
90 unsigned char tctp; /* tras - trcd in clocks */
91 unsigned char am; /* Address Mod (will be programmed as am-1) */
92 unsigned char sz; /* log binary => Size = (4MByte<<sz) 5 = 128, 4 = 64, 3 = 32, 2 = 16, 1=8 */
93 unsigned char ecc; /* if true, ecc is enabled */
95 #if defined(CONFIG_TARGET_MIP405T)
96 const sdram_t sdram_table[] = {
97 { 0x0F, /* MIP405T Rev A, 64MByte -1 Board */
98 3, /* Case Latenty = 3 */
99 3, /* trp 20ns / 7.5 ns datain[27] */
100 3, /* trcd 20ns /7.5 ns (datain[29]) */
101 6, /* tras 44ns /7.5 ns (datain[30]) */
102 4, /* tcpt 44 - 20ns = 24ns */
103 2, /* Address Mode = 2 (12x9x4) */
104 3, /* size value (32MByte) */
105 0}, /* ECC disabled */
106 { 0xff, /* terminator */
116 const sdram_t sdram_table[] = {
117 { 0x0f, /* Rev A, 128MByte -1 Board */
118 3, /* Case Latenty = 3 */
119 3, /* trp 20ns / 7.5 ns datain[27] */
120 3, /* trcd 20ns /7.5 ns (datain[29]) */
121 6, /* tras 44ns /7.5 ns (datain[30]) */
122 4, /* tcpt 44 - 20ns = 24ns */
123 3, /* Address Mode = 3 */
125 1}, /* ECC enabled */
126 { 0x07, /* Rev A, 64MByte -2 Board */
127 3, /* Case Latenty = 3 */
128 3, /* trp 20ns / 7.5 ns datain[27] */
129 3, /* trcd 20ns /7.5 ns (datain[29]) */
130 6, /* tras 44ns /7.5 ns (datain[30]) */
131 4, /* tcpt 44 - 20ns = 24ns */
132 2, /* Address Mode = 2 */
134 1}, /* ECC enabled */
135 { 0x03, /* Rev A, 128MByte -4 Board */
136 3, /* Case Latenty = 3 */
137 3, /* trp 20ns / 7.5 ns datain[27] */
138 3, /* trcd 20ns /7.5 ns (datain[29]) */
139 6, /* tras 44ns /7.5 ns (datain[30]) */
140 4, /* tcpt 44 - 20ns = 24ns */
141 3, /* Address Mode = 3 */
143 1}, /* ECC enabled */
144 { 0x1f, /* Rev B, 128MByte -3 Board */
145 3, /* Case Latenty = 3 */
146 3, /* trp 20ns / 7.5 ns datain[27] */
147 3, /* trcd 20ns /7.5 ns (datain[29]) */
148 6, /* tras 44ns /7.5 ns (datain[30]) */
149 4, /* tcpt 44 - 20ns = 24ns */
150 3, /* Address Mode = 3 */
152 1}, /* ECC enabled */
153 { 0x2f, /* Rev C, 128MByte -3 Board */
154 3, /* Case Latenty = 3 */
155 3, /* trp 20ns / 7.5 ns datain[27] */
156 3, /* trcd 20ns /7.5 ns (datain[29]) */
157 6, /* tras 44ns /7.5 ns (datain[30]) */
158 4, /* tcpt 44 - 20ns = 24ns */
159 3, /* Address Mode = 3 */
161 1}, /* ECC enabled */
162 { 0xff, /* terminator */
171 #endif /*CONFIG_TARGET_MIP405T */
172 void SDRAM_err (const char *s)
175 (void) get_clocks ();
181 serial_puts ("\n enable SDRAM_DEBUG for more info\n");
186 unsigned char get_board_revcfg (void)
188 out8 (PER_BOARD_ADDR, 0);
189 return (in8 (PER_BOARD_ADDR));
195 void write_hex (unsigned char i)
202 serial_putc (cc + 55);
204 serial_putc (cc + 48);
207 serial_putc (cc + 55);
209 serial_putc (cc + 48);
212 void write_4hex (unsigned long val)
214 write_hex ((unsigned char) (val >> 24));
215 write_hex ((unsigned char) (val >> 16));
216 write_hex ((unsigned char) (val >> 8));
217 write_hex ((unsigned char) val);
223 int init_sdram (void)
225 unsigned long tmp, baseaddr;
227 unsigned char trp_clocks,
231 unsigned char cal_val;
233 unsigned long sdram_tim, sdram_bank;
235 /*i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);*/
236 (void) get_clocks ();
240 mtdcr (EBC0_CFGADDR, PB7AP);
241 mtdcr (EBC0_CFGDATA, PLD_AP);
242 mtdcr (EBC0_CFGADDR, PB7CR);
243 mtdcr (EBC0_CFGDATA, PLD_CR);
244 /* THIS IS OBSOLETE */
245 /* set up the board rev reg*/
246 mtdcr (EBC0_CFGADDR, PB5AP);
247 mtdcr (EBC0_CFGDATA, BOARD_AP);
248 mtdcr (EBC0_CFGADDR, PB5CR);
249 mtdcr (EBC0_CFGDATA, BOARD_CR);
251 /* get all informations from PLD */
252 serial_puts ("\nPLD Part 0x");
253 bc = in8 (PLD_PART_REG);
255 serial_puts ("\nPLD Vers 0x");
256 bc = in8 (PLD_VERS_REG);
258 serial_puts ("\nBoard Rev 0x");
259 bc = in8 (PLD_BOARD_CFG_REG);
264 bc = in8 (PLD_PART_REG);
265 #if defined(CONFIG_TARGET_MIP405T)
267 SDRAM_err ("U-Boot configured for a MIP405T not for a MIP405!!!\n");
269 if((bc & 0x80)==0x80)
270 SDRAM_err ("U-Boot configured for a MIP405 not for a MIP405T!!!\n");
272 /* set-up the chipselect machine */
273 mtdcr (EBC0_CFGADDR, PB0CR); /* get cs0 config reg */
274 tmp = mfdcr (EBC0_CFGDATA);
275 if ((tmp & 0x00002000) == 0) {
276 /* MPS Boot, set up the flash */
277 mtdcr (EBC0_CFGADDR, PB1AP);
278 mtdcr (EBC0_CFGDATA, FLASH_AP);
279 mtdcr (EBC0_CFGADDR, PB1CR);
280 mtdcr (EBC0_CFGDATA, FLASH_CR);
282 /* Flash boot, set up the MPS */
283 mtdcr (EBC0_CFGADDR, PB1AP);
284 mtdcr (EBC0_CFGDATA, MPS_AP);
285 mtdcr (EBC0_CFGADDR, PB1CR);
286 mtdcr (EBC0_CFGDATA, MPS_CR);
288 /* set up UART0 (CS2) and UART1 (CS3) */
289 mtdcr (EBC0_CFGADDR, PB2AP);
290 mtdcr (EBC0_CFGDATA, UART0_AP);
291 mtdcr (EBC0_CFGADDR, PB2CR);
292 mtdcr (EBC0_CFGDATA, UART0_CR);
293 mtdcr (EBC0_CFGADDR, PB3AP);
294 mtdcr (EBC0_CFGDATA, UART1_AP);
295 mtdcr (EBC0_CFGADDR, PB3CR);
296 mtdcr (EBC0_CFGDATA, UART1_CR);
297 bc = in8 (PLD_BOARD_CFG_REG);
299 serial_puts ("\nstart SDRAM Setup\n");
300 serial_puts ("\nBoard Rev: ");
305 baseaddr = CONFIG_SYS_SDRAM_BASE;
306 while (sdram_table[i].sz != 0xff) {
307 if (sdram_table[i].boardtype == bc)
311 if (sdram_table[i].boardtype != bc)
312 SDRAM_err ("No SDRAM table found for this board!!!\n");
314 serial_puts (" found table ");
318 /* since the ECC initialisation needs some time,
319 * we show that we're alive
321 if (sdram_table[i].ecc)
322 serial_puts ("\nInitializing SDRAM, Please stand by");
323 cal_val = sdram_table[i].cal - 1; /* Cas Latency */
324 trp_clocks = sdram_table[i].trp; /* 20ns / 7.5 ns datain[27] */
325 trcd_clocks = sdram_table[i].trcd; /* 20ns /7.5 ns (datain[29]) */
326 tras_clocks = sdram_table[i].tras; /* 44ns /7.5 ns (datain[30]) */
327 /* ctp = ((trp + tras) - trp - trcd) => tras - trcd */
328 /* trc_clocks is sum of trp_clocks + tras_clocks */
329 trc_clocks = trp_clocks + tras_clocks;
330 /* get SDRAM timing register */
331 mtdcr (SDRAM0_CFGADDR, SDRAM0_TR);
332 sdram_tim = mfdcr (SDRAM0_CFGDATA) & ~0x018FC01F;
333 /* insert CASL value */
334 sdram_tim |= ((unsigned long) (cal_val)) << 23;
335 /* insert PTA value */
336 sdram_tim |= ((unsigned long) (trp_clocks - 1)) << 18;
337 /* insert CTP value */
339 ((unsigned long) (trc_clocks - trp_clocks -
341 /* insert LDF (always 01) */
342 sdram_tim |= ((unsigned long) 0x01) << 14;
343 /* insert RFTA value */
344 sdram_tim |= ((unsigned long) (trc_clocks - 4)) << 2;
345 /* insert RCD value */
346 sdram_tim |= ((unsigned long) (trcd_clocks - 1)) << 0;
348 tmp = ((unsigned long) (sdram_table[i].am - 1) << 13); /* AM = 3 */
349 /* insert SZ value; */
350 tmp |= ((unsigned long) sdram_table[i].sz << 17);
351 /* get SDRAM bank 0 register */
352 mtdcr (SDRAM0_CFGADDR, SDRAM0_B0CR);
353 sdram_bank = mfdcr (SDRAM0_CFGDATA) & ~0xFFCEE001;
354 sdram_bank |= (baseaddr | tmp | 0x01);
357 serial_puts ("sdtr: ");
358 write_4hex (sdram_tim);
362 /* write SDRAM timing register */
363 mtdcr (SDRAM0_CFGADDR, SDRAM0_TR);
364 mtdcr (SDRAM0_CFGDATA, sdram_tim);
367 serial_puts ("mb0cf: ");
368 write_4hex (sdram_bank);
372 /* write SDRAM bank 0 register */
373 mtdcr (SDRAM0_CFGADDR, SDRAM0_B0CR);
374 mtdcr (SDRAM0_CFGDATA, sdram_bank);
376 if (get_bus_freq (tmp) > 110000000) { /* > 110MHz */
377 /* get SDRAM refresh interval register */
378 mtdcr (SDRAM0_CFGADDR, SDRAM0_RTR);
379 tmp = mfdcr (SDRAM0_CFGDATA) & ~0x3FF80000;
382 /* get SDRAM refresh interval register */
383 mtdcr (SDRAM0_CFGADDR, SDRAM0_RTR);
384 tmp = mfdcr (SDRAM0_CFGDATA) & ~0x3FF80000;
387 /* write SDRAM refresh interval register */
388 mtdcr (SDRAM0_CFGADDR, SDRAM0_RTR);
389 mtdcr (SDRAM0_CFGDATA, tmp);
390 /* enable ECC if used */
391 #if defined(ENABLE_ECC) && !defined(CONFIG_BOOT_PCI)
392 if (sdram_table[i].ecc) {
393 /* disable checking for all banks */
396 serial_puts ("disable ECC.. ");
398 mtdcr (SDRAM0_CFGADDR, SDRAM0_ECCCFG);
399 tmp = mfdcr (SDRAM0_CFGDATA);
400 tmp &= 0xff0fffff; /* disable all banks */
401 mtdcr (SDRAM0_CFGADDR, SDRAM0_ECCCFG);
402 /* set up SDRAM Controller with ECC enabled */
404 serial_puts ("setup SDRAM Controller.. ");
406 mtdcr (SDRAM0_CFGDATA, tmp);
407 mtdcr (SDRAM0_CFGADDR, SDRAM0_CFG);
408 tmp = (mfdcr (SDRAM0_CFGDATA) & ~0xFFE00000) | 0x90800000;
409 mtdcr (SDRAM0_CFGADDR, SDRAM0_CFG);
410 mtdcr (SDRAM0_CFGDATA, tmp);
413 serial_puts ("fill the memory..\n");
416 /* now, fill all the memory */
417 tmp = ((4 * MEGA_BYTE) << sdram_table[i].sz);
418 p = (unsigned long) 0;
419 while ((unsigned long) p < tmp) {
421 if (!((unsigned long) p % 0x00800000)) /* every 8MByte */
427 serial_puts ("enable ECC\n");
430 mtdcr (SDRAM0_CFGADDR, SDRAM0_ECCCFG);
431 tmp = mfdcr (SDRAM0_CFGDATA);
432 tmp |= 0x00800000; /* enable bank 0 */
433 mtdcr (SDRAM0_CFGDATA, tmp);
438 /* enable SDRAM controller with no ECC, 32-bit SDRAM width, 16 byte burst */
439 mtdcr (SDRAM0_CFGADDR, SDRAM0_CFG);
440 tmp = (mfdcr (SDRAM0_CFGDATA) & ~0xFFE00000) | 0x80C00000;
441 mtdcr (SDRAM0_CFGADDR, SDRAM0_CFG);
442 mtdcr (SDRAM0_CFGDATA, tmp);
449 int board_early_init_f (void)
453 /*-------------------------------------------------------------------------+
454 | Interrupt controller setup for the PIP405 board.
455 | Note: IRQ 0-15 405GP internally generated; active high; level sensitive
456 | IRQ 16 405GP internally generated; active low; level sensitive
458 | IRQ 25 (EXT IRQ 0) SouthBridge; active low; level sensitive
459 | IRQ 26 (EXT IRQ 1) NMI: active low; level sensitive
460 | IRQ 27 (EXT IRQ 2) SMI: active Low; level sensitive
461 | IRQ 28 (EXT IRQ 3) PCI SLOT 3; active low; level sensitive
462 | IRQ 29 (EXT IRQ 4) PCI SLOT 2; active low; level sensitive
463 | IRQ 30 (EXT IRQ 5) PCI SLOT 1; active low; level sensitive
464 | IRQ 31 (EXT IRQ 6) PCI SLOT 0; active low; level sensitive
465 | Note for MIP405 board:
466 | An interrupt taken for the SouthBridge (IRQ 25) indicates that
467 | the Interrupt Controller in the South Bridge has caused the
468 | interrupt. The IC must be read to determine which device
469 | caused the interrupt.
471 +-------------------------------------------------------------------------*/
472 mtdcr (UIC0SR, 0xFFFFFFFF); /* clear all ints */
473 mtdcr (UIC0ER, 0x00000000); /* disable all ints */
474 mtdcr (UIC0CR, 0x00000000); /* set all to be non-critical (for now) */
475 mtdcr (UIC0PR, 0xFFFFFF80); /* set int polarities */
476 mtdcr (UIC0TR, 0x10000000); /* set int trigger levels */
477 mtdcr (UIC0VCR, 0x00000001); /* set vect base=0,INT0 highest priority */
478 mtdcr (UIC0SR, 0xFFFFFFFF); /* clear all ints */
482 int board_early_init_r(void)
487 * since we are relocated, we can finally enable i-cache
488 * and set up the flash CS correctly
492 /* get and display boot mode */
493 mode = get_boot_mode();
495 printf("PCI Boot %s Map\n", (mode & BOOT_MPS) ?
498 printf("%s Boot\n", (mode & BOOT_MPS) ?
505 * Get some PLD Registers
508 unsigned short get_pld_parvers (void)
510 unsigned short result;
513 rc = in8 (PLD_PART_REG);
514 result = (unsigned short) rc << 8;
515 rc = in8 (PLD_VERS_REG);
521 void user_led0 (unsigned char on)
524 out8 (PLD_COM_MODE_REG, (in8 (PLD_COM_MODE_REG) | 0x4));
526 out8 (PLD_COM_MODE_REG, (in8 (PLD_COM_MODE_REG) & 0xfb));
530 void ide_set_reset (int idereset)
532 /* if reset = 1 IDE reset will be asserted */
534 out8 (PLD_COM_MODE_REG, (in8 (PLD_COM_MODE_REG) | 0x1));
537 out8 (PLD_COM_MODE_REG, (in8 (PLD_COM_MODE_REG) & 0xfe));
542 /* ------------------------------------------------------------------------- */
544 void get_pcbrev_var(unsigned char *pcbrev, unsigned char *var)
546 #if !defined(CONFIG_TARGET_MIP405T)
547 unsigned char bc,rc,tmp;
550 bc = in8 (PLD_BOARD_CFG_REG);
554 for (i = 0; i < 4; i++) {
560 if(( (((bc>>4) & 0xf)==0x2) /* Rev C PCB or */
561 || (((bc>>4) & 0xf)==0x1)) /* Rev B PCB with */
562 && (rc==0x1)) /* Population Option 1 is a -3 */
564 *pcbrev=(bc >> 4) & 0xf;
568 bc = in8 (PLD_BOARD_CFG_REG);
569 *pcbrev=(bc >> 4) & 0xf;
575 * Check Board Identity:
577 /* serial String: "MIP405_1000" OR "MIP405T_1000" */
578 #if !defined(CONFIG_TARGET_MIP405T)
579 #define BOARD_NAME "MIP405"
581 #define BOARD_NAME "MIP405T"
584 int checkboard (void)
587 unsigned char bc, var;
589 backup_t *b = (backup_t *) s;
592 get_pcbrev_var(&bc,&var);
593 i = getenv_f("serial#", (char *)s, 32);
594 if ((i == 0) || strncmp ((char *)s, BOARD_NAME,sizeof(BOARD_NAME))) {
595 get_backup_values (b);
596 if (strncmp (b->signature, "MPL\0", 4) != 0) {
597 puts ("### No HW ID - assuming " BOARD_NAME);
598 printf ("-%d Rev %c", var, 'A' + bc);
600 b->serial_name[sizeof(BOARD_NAME)-1] = 0;
601 printf ("%s-%d Rev %c SN: %s", b->serial_name, var,
602 'A' + bc, &b->serial_name[sizeof(BOARD_NAME)]);
605 s[sizeof(BOARD_NAME)-1] = 0;
606 printf ("%s-%d Rev %c SN: %s", s, var,'A' + bc,
607 &s[sizeof(BOARD_NAME)]);
609 bc = in8 (PLD_EXT_CONF_REG);
610 printf (" Boot Config: 0x%x\n", bc);
615 /* ------------------------------------------------------------------------- */
616 /* ------------------------------------------------------------------------- */
618 initdram() reads EEPROM via I2c. EEPROM contains all of
619 the necessary info for SDRAM controller configuration
621 /* ------------------------------------------------------------------------- */
622 /* ------------------------------------------------------------------------- */
623 static int test_dram (unsigned long ramsize);
628 unsigned long bank_reg[4], tmp, bank_size;
630 unsigned long TotalSize;
632 /* since the DRAM controller is allready set up, calculate the size with the
634 mtdcr (SDRAM0_CFGADDR, SDRAM0_B0CR);
635 bank_reg[0] = mfdcr (SDRAM0_CFGDATA);
636 mtdcr (SDRAM0_CFGADDR, SDRAM0_B1CR);
637 bank_reg[1] = mfdcr (SDRAM0_CFGDATA);
638 mtdcr (SDRAM0_CFGADDR, SDRAM0_B2CR);
639 bank_reg[2] = mfdcr (SDRAM0_CFGDATA);
640 mtdcr (SDRAM0_CFGADDR, SDRAM0_B3CR);
641 bank_reg[3] = mfdcr (SDRAM0_CFGDATA);
643 for (i = 0; i < 4; i++) {
644 if ((bank_reg[i] & 0x1) == 0x1) {
645 tmp = (bank_reg[i] >> 17) & 0x7;
646 bank_size = 4 << tmp;
647 TotalSize += bank_size;
650 mtdcr (SDRAM0_CFGADDR, SDRAM0_ECCCFG);
651 tmp = mfdcr (SDRAM0_CFGDATA);
657 test_dram (TotalSize * MEGA_BYTE);
658 gd->ram_size = TotalSize * MEGA_BYTE;
663 /* ------------------------------------------------------------------------- */
666 static int test_dram (unsigned long ramsize)
669 mem_test (0L, ramsize, 1);
671 /* not yet implemented */
675 /* used to check if the time in RTC is valid */
676 static unsigned long start;
677 static struct rtc_time tm;
679 int misc_init_r (void)
681 /* adjust flash start and size as well as the offset */
682 gd->bd->bi_flashstart=0-flash_info[0].size;
683 gd->bd->bi_flashsize=flash_info[0].size-CONFIG_SYS_MONITOR_LEN;
684 gd->bd->bi_flashoffset=0;
686 /* check, if RTC is running */
689 /* if MIP405 has booted from PCI, reset CCR0[24] as described in errata PCI_18 */
690 if (mfdcr(CPC0_PSR) & PSR_ROM_LOC)
691 mtspr(SPRN_CCR0, (mfspr(SPRN_CCR0) & ~0x80));
697 void print_mip405_rev (void)
699 unsigned char part, vers, pcbrev, var;
701 get_pcbrev_var(&pcbrev,&var);
702 part = in8 (PLD_PART_REG);
703 vers = in8 (PLD_VERS_REG);
704 printf ("Rev: " BOARD_NAME "-%d Rev %c PLD %d Vers %d\n",
705 var, pcbrev + 'A', part & 0x7F, vers);
709 extern int mk_date (char *, struct rtc_time *);
711 int last_stage_init (void)
714 struct rtc_time newtm;
717 /* write correct LED configuration */
718 if (miiphy_write("ppc_4xx_eth0", 0x1, 0x14, 0x2402) != 0) {
719 printf ("Error writing to the PHY\n");
721 /* since LED/CFG2 is not connected on the -2,
722 * write to correct capability information */
723 if (miiphy_write("ppc_4xx_eth0", 0x1, 0x4, 0x01E1) != 0) {
724 printf ("Error writing to the PHY\n");
727 stdio_print_current_devices ();
729 /* check if RTC time is valid */
730 stop=get_timer(start);
731 while(stop<1200) { /* we wait 1.2 sec to check if the RTC is running */
733 stop=get_timer(start);
736 if(tm.tm_sec==newtm.tm_sec) {
737 s=getenv("defaultdate");
739 mk_date ("010112001970", &newtm);
741 if(mk_date (s, &newtm)!=0) {
742 printf("RTC: Bad date format in defaultdate\n");
751 /***************************************************************************
752 * some helping routines
755 int overwrite_console (void)
757 /* return true if console should be overwritten */
758 return ((in8(PLD_EXT_CONF_REG) & 0x1) == 0);
762 /************************************************************************
764 ************************************************************************/
765 void print_mip405_info (void)
767 unsigned char part, vers, cfg, irq_reg, com_mode, ext;
769 part = in8 (PLD_PART_REG);
770 vers = in8 (PLD_VERS_REG);
771 cfg = in8 (PLD_BOARD_CFG_REG);
772 irq_reg = in8 (PLD_IRQ_REG);
773 com_mode = in8 (PLD_COM_MODE_REG);
774 ext = in8 (PLD_EXT_CONF_REG);
776 printf ("PLD Part %d version %d\n", part & 0x7F, vers);
777 printf ("Board Revision %c\n", ((cfg >> 4) & 0xf) + 'A');
778 printf ("Population Options %d %d %d %d\n", (cfg) & 0x1,
779 (cfg >> 1) & 0x1, (cfg >> 2) & 0x1, (cfg >> 3) & 0x1);
780 printf ("User LED %s\n", (com_mode & 0x4) ? "on" : "off");
781 printf ("UART Clocks %d\n", (com_mode >> 4) & 0x3);
782 #if !defined(CONFIG_TARGET_MIP405T)
783 printf ("User Config Switch %d %d %d %d %d %d %d %d\n",
784 (ext) & 0x1, (ext >> 1) & 0x1, (ext >> 2) & 0x1,
785 (ext >> 3) & 0x1, (ext >> 4) & 0x1, (ext >> 5) & 0x1,
786 (ext >> 6) & 0x1, (ext >> 7) & 0x1);
787 printf ("SER1 uses handshakes %s\n",
788 (ext & 0x80) ? "DTR/DSR" : "RTS/CTS");
790 printf ("User Config Switch %d %d %d %d %d %d %d %d\n",
791 (ext) & 0x1, (ext >> 1) & 0x1, (ext >> 2) & 0x1,
792 (ext >> 3) & 0x1, (ext >> 4) & 0x1, (ext >> 5) & 0x1,
793 (ext >> 6) & 0x1,(ext >> 7) & 0x1);
795 printf ("IDE Reset %s\n", (ext & 0x01) ? "asserted" : "not asserted");
797 printf (" PIIX INTR: %s\n", (irq_reg & 0x80) ? "inactive" : "active");
798 #if !defined(CONFIG_TARGET_MIP405T)
799 printf (" UART0 IRQ: %s\n", (irq_reg & 0x40) ? "inactive" : "active");
800 printf (" UART1 IRQ: %s\n", (irq_reg & 0x20) ? "inactive" : "active");
802 printf (" PIIX SMI: %s\n", (irq_reg & 0x10) ? "inactive" : "active");
803 printf (" PIIX INIT: %s\n", (irq_reg & 0x8) ? "inactive" : "active");
804 printf (" PIIX NMI: %s\n", (irq_reg & 0x4) ? "inactive" : "active");