]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - board/mpl/mip405/mip405.c
rename CFG_ macros to CONFIG_SYS
[karo-tx-uboot.git] / board / mpl / mip405 / mip405.c
index 090041b403f18b6627f29e411864ad9cc7aeb267..5eb90e5903aeeddaafc4246e672405b240b1ec41 100644 (file)
 #include <common.h>
 #include "mip405.h"
 #include <asm/processor.h>
-#include <405gp_i2c.h>
+#include <4xx_i2c.h>
 #include <miiphy.h>
 #include "../common/common_util.h"
 #include <i2c.h>
 #include <rtc.h>
-extern block_dev_desc_t * scsi_get_dev(int dev);
-extern block_dev_desc_t * ide_get_dev(int dev);
+
+DECLARE_GLOBAL_DATA_PTR;
 
 #undef SDRAM_DEBUG
 #define ENABLE_ECC /* for ecc boards */
@@ -89,12 +89,12 @@ extern ldiv_t ldiv (long int __numer, long int __denom);
 #endif
 
 
-#define PLD_PART_REG           PER_PLD_ADDR + 0
-#define PLD_VERS_REG           PER_PLD_ADDR + 1
-#define PLD_BOARD_CFG_REG      PER_PLD_ADDR + 2
-#define PLD_IRQ_REG            PER_PLD_ADDR + 3
-#define PLD_COM_MODE_REG       PER_PLD_ADDR + 4
-#define PLD_EXT_CONF_REG       PER_PLD_ADDR + 5
+#define PLD_PART_REG           PER_PLD_ADDR + 0
+#define PLD_VERS_REG           PER_PLD_ADDR + 1
+#define PLD_BOARD_CFG_REG      PER_PLD_ADDR + 2
+#define PLD_IRQ_REG            PER_PLD_ADDR + 3
+#define PLD_COM_MODE_REG       PER_PLD_ADDR + 4
+#define PLD_EXT_CONF_REG       PER_PLD_ADDR + 5
 
 #define MEGA_BYTE (1024*1024)
 
@@ -167,6 +167,15 @@ const sdram_t sdram_table[] = {
                3,      /* Address Mode = 3 */
                5,      /* size value */
                1},     /* ECC enabled */
+       { 0x2f, /* Rev C, 128MByte -3 Board */
+               3,      /* Case Latenty = 3 */
+               3,      /* trp 20ns / 7.5 ns datain[27] */
+               3,      /* trcd 20ns /7.5 ns (datain[29]) */
+               6,      /* tras 44ns /7.5 ns  (datain[30]) */
+               4,      /* tcpt 44 - 20ns = 24ns */
+               3,      /* Address Mode = 3 */
+               5,      /* size value */
+               1},     /* ECC enabled */
        { 0xff, /* terminator */
          0xff,
          0xff,
@@ -180,8 +189,6 @@ const sdram_t sdram_table[] = {
 void SDRAM_err (const char *s)
 {
 #ifndef SDRAM_DEBUG
-       DECLARE_GLOBAL_DATA_PTR;
-
        (void) get_clocks ();
        gd->baudrate = 9600;
        serial_init ();
@@ -232,8 +239,6 @@ void write_4hex (unsigned long val)
 
 int init_sdram (void)
 {
-       DECLARE_GLOBAL_DATA_PTR;
-
        unsigned long   tmp, baseaddr;
        unsigned short  i;
        unsigned char   trp_clocks,
@@ -245,7 +250,7 @@ int init_sdram (void)
        unsigned char   bc;
        unsigned long   sdram_tim, sdram_bank;
 
-       /*i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);*/
+       /*i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);*/
        (void) get_clocks ();
        gd->baudrate = 9600;
        serial_init ();
@@ -315,7 +320,7 @@ int init_sdram (void)
        serial_puts ("\n");
 #endif
        i = 0;
-       baseaddr = CFG_SDRAM_BASE;
+       baseaddr = CONFIG_SYS_SDRAM_BASE;
        while (sdram_table[i].sz != 0xff) {
                if (sdram_table[i].boardtype == bc)
                        break;
@@ -460,7 +465,7 @@ int init_sdram (void)
        return (0);
 }
 
-int board_pre_init (void)
+int board_early_init_f (void)
 {
        init_sdram ();
 
@@ -550,7 +555,8 @@ void get_pcbrev_var(unsigned char *pcbrev, unsigned char *var)
                tmp >>= 1;
        }
        rc++;
-       if((((bc>>4) & 0xf)==0x1) /* Rev B PCB with */
+       if((  (((bc>>4) & 0xf)==0x2) /* Rev C PCB or */
+          || (((bc>>4) & 0xf)==0x1)) /* Rev B PCB with */
                && (rc==0x1))     /* Population Option 1 is a -3 */
                rc=3;
        *pcbrev=(bc >> 4) & 0xf;
@@ -575,15 +581,15 @@ void get_pcbrev_var(unsigned char *pcbrev, unsigned char *var)
 
 int checkboard (void)
 {
-       unsigned char s[50];
+       char s[50];
        unsigned char bc, var;
        int i;
        backup_t *b = (backup_t *) s;
 
        puts ("Board: ");
        get_pcbrev_var(&bc,&var);
-       i = getenv_r ("serial#", s, 32);
-       if ((i == 0) || strncmp (s, BOARD_NAME,sizeof(BOARD_NAME))) {
+       i = getenv_r ("serial#", (char *)s, 32);
+       if ((i == 0) || strncmp ((char *)s, BOARD_NAME,sizeof(BOARD_NAME))) {
                get_backup_values (b);
                if (strncmp (b->signature, "MPL\0", 4) != 0) {
                        puts ("### No HW ID - assuming " BOARD_NAME);
@@ -614,7 +620,7 @@ int checkboard (void)
 /* ------------------------------------------------------------------------- */
 static int test_dram (unsigned long ramsize);
 
-long int initdram (int board_type)
+phys_size_t initdram (int board_type)
 {
 
        unsigned long bank_reg[4], tmp, bank_size;
@@ -667,9 +673,15 @@ static int test_dram (unsigned long ramsize)
 /* used to check if the time in RTC is valid */
 static unsigned long start;
 static struct rtc_time tm;
+extern flash_info_t flash_info[];      /* info for FLASH chips */
 
 int misc_init_r (void)
 {
+       /* adjust flash start and size as well as the offset */
+       gd->bd->bi_flashstart=0-flash_info[0].size;
+       gd->bd->bi_flashsize=flash_info[0].size-CONFIG_SYS_MONITOR_LEN;
+       gd->bd->bi_flashoffset=0;
+
        /* check, if RTC is running */
        rtc_get (&tm);
        start=get_timer(0);
@@ -692,6 +704,18 @@ void print_mip405_rev (void)
                        var, pcbrev + 'A', part & 0x7F, vers);
 }
 
+
+#ifdef CONFIG_POST
+/*
+ * Returns 1 if keys pressed to start the power-on long-running tests
+ * Called from board_init_f().
+ */
+int post_hotkeys_pressed(void)
+{
+       return 0;       /* No hotkeys supported */
+}
+#endif
+
 extern void mem_test_reloc(void);
 extern int mk_date (char *, struct rtc_time *);
 
@@ -699,15 +723,15 @@ int last_stage_init (void)
 {
        unsigned long stop;
        struct rtc_time newtm;
-       unsigned char *s;
+       char *s;
        mem_test_reloc();
        /* write correct LED configuration */
-       if (miiphy_write (0x1, 0x14, 0x2402) != 0) {
+       if (miiphy_write("ppc_4xx_eth0", 0x1, 0x14, 0x2402) != 0) {
                printf ("Error writing to the PHY\n");
        }
        /* since LED/CFG2 is not connected on the -2,
         * write to correct capability information */
-       if (miiphy_write (0x1, 0x4, 0x01E1) != 0) {
+       if (miiphy_write("ppc_4xx_eth0", 0x1, 0x4, 0x01E1) != 0) {
                printf ("Error writing to the PHY\n");
        }
        print_mip405_rev ();