]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - board/pn62/pn62.c
General help message cleanup
[karo-tx-uboot.git] / board / pn62 / pn62.c
index 9b1fc00e30ded66c934d941a76c38e3fd6e87362..676f8d34f2a5c693604b14d8eb21fcd91be8beca 100644 (file)
 
 #include <common.h>
 #include <mpc824x.h>
+#include <net.h>
 #include <pci.h>
+#include <netdev.h>
 
 #include "pn62.h"
 
+DECLARE_GLOBAL_DATA_PTR;
 
 static int get_serial_number (char *string, int size);
-static int get_mac_address (int id, u8 * mac, char *string, int size);
+static void get_mac_address(int id, u8 *mac);
 
 #ifdef CONFIG_SHOW_BOOT_PROGRESS
 void show_boot_progress (int phase)
@@ -74,57 +77,28 @@ int checkboard (void)
        return 0;
 }
 
-long int initdram (int board_type)
+phys_size_t initdram (int board_type)
 {
-       int i, cnt;
-       volatile uchar *base = CFG_SDRAM_BASE;
-       volatile ulong *addr;
-       ulong save[32];
-       ulong val, ret = 0;
+       long size;
+       long new_bank0_end;
+       long mear1;
+       long emear1;
 
        show_startup_phase (2);
 
-       for (i = 0, cnt = (CFG_MAX_RAM_SIZE / sizeof (long)) >> 1; cnt > 0;
-                cnt >>= 1) {
-               addr = (volatile ulong *) base + cnt;
-               save[i++] = *addr;
-               *addr = ~cnt;
-       }
-
-       addr = (volatile ulong *) base;
-       save[i] = *addr;
-       *addr = 0;
+       size = get_ram_size(CONFIG_SYS_SDRAM_BASE, CONFIG_SYS_MAX_RAM_SIZE);
 
-       if (*addr != 0) {
-               *addr = save[i];
-               goto Done;
-       }
-
-       for (cnt = 1; cnt <= CFG_MAX_RAM_SIZE / sizeof (long); cnt <<= 1) {
-               addr = (volatile ulong *) base + cnt;
-               val = *addr;
-               *addr = save[--i];
-               if (val != ~cnt) {
-                       ulong new_bank0_end = cnt * sizeof (long) - 1;
-                       ulong mear1 = mpc824x_mpc107_getreg (MEAR1);
-                       ulong emear1 = mpc824x_mpc107_getreg (EMEAR1);
-
-                       mear1 = (mear1 & 0xFFFFFF00) |
-                                       ((new_bank0_end & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT);
-                       emear1 = (emear1 & 0xFFFFFF00) |
-                                       ((new_bank0_end & MICR_ADDR_MASK) >> MICR_EADDR_SHIFT);
-                       mpc824x_mpc107_setreg (MEAR1, mear1);
-                       mpc824x_mpc107_setreg (EMEAR1, emear1);
-
-                       ret = cnt * sizeof (long);
-                       goto Done;
-               }
-       }
+       new_bank0_end = size - 1;
+       mear1 = mpc824x_mpc107_getreg (MEAR1);
+       emear1 = mpc824x_mpc107_getreg (EMEAR1);
+       mear1 = (mear1 & 0xFFFFFF00) |
+               ((new_bank0_end & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT);
+       emear1 = (emear1 & 0xFFFFFF00) |
+               ((new_bank0_end & MICR_ADDR_MASK) >> MICR_EADDR_SHIFT);
+       mpc824x_mpc107_setreg (MEAR1, mear1);
+       mpc824x_mpc107_setreg (EMEAR1, emear1);
 
-       ret = CFG_MAX_RAM_SIZE;
-  Done:
-       show_startup_phase (3);
-       return ret;
+       return (size);
 }
 
 /*
@@ -151,8 +125,6 @@ void pci_init_board (void)
 
 int misc_init_r (void)
 {
-       DECLARE_GLOBAL_DATA_PTR;
-
        char str[20];
        u8 mac[6];
 
@@ -167,18 +139,18 @@ int misc_init_r (void)
        }
        show_startup_phase (9);
 
-       if (getenv ("ethaddr") == NULL &&
-               get_mac_address (0, mac, str, sizeof (str)) > 0) {
-               setenv ("ethaddr", str);
-               memcpy (gd->bd->bi_enetaddr, mac, 6);
+       if (!eth_getenv_enetaddr("ethaddr", mac)) {
+               get_mac_address(0, mac);
+               eth_setenv_enetaddr("ethaddr", mac);
        }
        show_startup_phase (10);
 
-       if (getenv ("eth1addr") == NULL &&
-               get_mac_address (1, mac, str, sizeof (str)) > 0) {
-               setenv ("eth1addr", str);
-               memcpy (gd->bd->bi_enet1addr, mac, 6);
+#ifdef CONFIG_HAS_ETH1
+       if (!eth_getenv_enetaddr("eth1addr", mac)) {
+               get_mac_address(1, mac);
+               eth_setenv_enetaddr("eth1addr", mac);
        }
+#endif /* CONFIG_HAS_ETH1 */
        show_startup_phase (11);
 
        /* Tell everybody that U-Boot is up and runnig */
@@ -194,7 +166,7 @@ static int get_serial_number (char *string, int size)
        if (size < I2155X_VPD_SN_SIZE)
                size = I2155X_VPD_SN_SIZE;
        for (i = 0; i < (size - 1); i++) {
-               i2155x_read_vpd (I2155X_VPD_SN_START + i, 1, &c);
+               i2155x_read_vpd (I2155X_VPD_SN_START + i, 1, (uchar *)&c);
                if (c == '\0')
                        break;
                string[i] = c;
@@ -204,13 +176,12 @@ static int get_serial_number (char *string, int size)
        return i;
 }
 
-static int get_mac_address (int id, u8 * mac, char *string, int size)
+static void get_mac_address(int id, u8 *mac)
 {
-       if (size < 6 * 3)
-               return -1;
-
        i2155x_read_vpd (I2155X_VPD_MAC0_START + 6 * id, 6, mac);
-       return sprintf (string, "%02x:%02x:%02x:%02x:%02x:%02x",
-                               mac[0], mac[1], mac[2],
-                               mac[3], mac[4], mac[5]);
+}
+
+int board_eth_init(bd_t *bis)
+{
+       return pci_eth_init(bis);
 }