]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
fdt: rework fdt_fixup_ethernet() to use env instead of bd_t
authorKumar Gala <galak@kernel.crashing.org>
Tue, 19 Aug 2008 20:41:18 +0000 (15:41 -0500)
committerWolfgang Denk <wd@denx.de>
Thu, 21 Aug 2008 00:07:43 +0000 (02:07 +0200)
Move to using the environment variables 'ethaddr', 'eth1addr', etc..
instead of bd->bi_enetaddr, bi_enet1addr, etc.

This makes the code a bit more flexible to the number of ethernet
interfaces.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
common/fdt_support.c
cpu/74xx_7xx/cpu.c
cpu/mpc512x/cpu.c
cpu/mpc8260/cpu.c
cpu/mpc83xx/fdt.c
cpu/mpc85xx/fdt.c
cpu/mpc86xx/fdt.c
cpu/mpc8xx/fdt.c
cpu/ppc4xx/fdt.c
include/fdt_support.h

index 93b144e64cb4774a7ff6cf8978c9f915c9ba6da6..e57ac0a545322819cf7239703a5f46219eabdb4a 100644 (file)
@@ -368,55 +368,41 @@ int fdt_fixup_memory(void *blob, u64 start, u64 size)
        return 0;
 }
 
-#if defined(CONFIG_HAS_ETH0) || defined(CONFIG_HAS_ETH1) ||\
-    defined(CONFIG_HAS_ETH2) || defined(CONFIG_HAS_ETH3)
-
-void fdt_fixup_ethernet(void *fdt, bd_t *bd)
+void fdt_fixup_ethernet(void *fdt)
 {
-       int node;
+       int node, i, j;
+       char enet[16], *tmp, *end;
+       char mac[16] = "ethaddr";
        const char *path;
+       unsigned char mac_addr[6];
 
        node = fdt_path_offset(fdt, "/aliases");
-       if (node >= 0) {
-#if defined(CONFIG_HAS_ETH0)
-               path = fdt_getprop(fdt, node, "ethernet0", NULL);
-               if (path) {
-                       do_fixup_by_path(fdt, path, "mac-address",
-                               bd->bi_enetaddr, 6, 0);
-                       do_fixup_by_path(fdt, path, "local-mac-address",
-                               bd->bi_enetaddr, 6, 1);
-               }
-#endif
-#if defined(CONFIG_HAS_ETH1)
-               path = fdt_getprop(fdt, node, "ethernet1", NULL);
-               if (path) {
-                       do_fixup_by_path(fdt, path, "mac-address",
-                               bd->bi_enet1addr, 6, 0);
-                       do_fixup_by_path(fdt, path, "local-mac-address",
-                               bd->bi_enet1addr, 6, 1);
-               }
-#endif
-#if defined(CONFIG_HAS_ETH2)
-               path = fdt_getprop(fdt, node, "ethernet2", NULL);
-               if (path) {
-                       do_fixup_by_path(fdt, path, "mac-address",
-                               bd->bi_enet2addr, 6, 0);
-                       do_fixup_by_path(fdt, path, "local-mac-address",
-                               bd->bi_enet2addr, 6, 1);
+       if (node < 0)
+               return;
+
+       i = 0;
+       while ((tmp = getenv(mac)) != NULL) {
+               sprintf(enet, "ethernet%d", i);
+               path = fdt_getprop(fdt, node, enet, NULL);
+               if (!path) {
+                       debug("No alias for %s\n", enet);
+                       sprintf(mac, "eth%daddr", ++i);
+                       continue;
                }
-#endif
-#if defined(CONFIG_HAS_ETH3)
-               path = fdt_getprop(fdt, node, "ethernet3", NULL);
-               if (path) {
-                       do_fixup_by_path(fdt, path, "mac-address",
-                               bd->bi_enet3addr, 6, 0);
-                       do_fixup_by_path(fdt, path, "local-mac-address",
-                               bd->bi_enet3addr, 6, 1);
+
+               for (j = 0; j < 6; j++) {
+                       mac_addr[j] = tmp ? simple_strtoul(tmp, &end, 16) : 0;
+                       if (tmp)
+                               tmp = (*end) ? end+1 : end;
                }
-#endif
+
+               do_fixup_by_path(fdt, path, "mac-address", &mac_addr, 6, 0);
+               do_fixup_by_path(fdt, path, "local-mac-address",
+                               &mac_addr, 6, 1);
+
+               sprintf(mac, "eth%daddr", ++i);
        }
 }
-#endif
 
 #ifdef CONFIG_HAS_FSL_DR_USB
 void fdt_fixup_dr_usb(void *blob, bd_t *bd)
index ea43c9a9bf96e843e150b1e8b4df8e0b6699aa9b..c007abc98655e66d758abb7fc13b9633d3e77378 100644 (file)
@@ -314,7 +314,7 @@ void ft_cpu_setup(void *blob, bd_t *bd)
 
        fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
 
-       fdt_fixup_ethernet(blob, bd);
+       fdt_fixup_ethernet(blob);
 }
 #endif
 /* ------------------------------------------------------------------------- */
index 703e1889c3b3152dcf88ca3cb045915d77521e7c..1f39ac4c173f06338c469c486e2919435e6f4b80 100644 (file)
@@ -191,7 +191,7 @@ void ft_cpu_setup(void *blob, bd_t *bd)
 #endif
        ft_clock_setup(blob, bd);
 #ifdef CONFIG_HAS_ETH0
-       fdt_fixup_ethernet(blob, bd);
+       fdt_fixup_ethernet(blob);
 #endif
 }
 #endif
index 4d5d141ea2667820a31e58ddbf107c82d17fd523..efb8ed6f4e8d60f674b13ee263a03f077ff7a2b5 100644 (file)
@@ -307,7 +307,7 @@ void ft_cpu_setup (void *blob, bd_t *bd)
 
 #if defined(CONFIG_HAS_ETH0) || defined(CONFIG_HAS_ETH1) ||\
     defined(CONFIG_HAS_ETH2) || defined(CONFIG_HAS_ETH3)
-       fdt_fixup_ethernet(blob, bd);
+       fdt_fixup_ethernet(blob);
 #endif
 
        do_fixup_by_path_u32(blob, cpu_path, "bus-frequency", bd->bi_busfreq, 1);
index fda85c15d0e572e63828f6a16b28a1dc33d12375..39bd9dc7d52822f36afe4075ae2c84f0bbe9f91a 100644 (file)
@@ -53,7 +53,7 @@ void ft_cpu_setup(void *blob, bd_t *bd)
 
 #if defined(CONFIG_HAS_ETH0) || defined(CONFIG_HAS_ETH1) ||\
     defined(CONFIG_HAS_ETH2) || defined(CONFIG_HAS_ETH3)
-       fdt_fixup_ethernet(blob, bd);
+       fdt_fixup_ethernet(blob);
 #endif
 
        do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
index c159934c5b24630e6c906a748e3dead91e0a9252..bc1550d7c260352bdcc0a78984757f87b495dc58 100644 (file)
@@ -212,7 +212,7 @@ void ft_cpu_setup(void *blob, bd_t *bd)
 
 #if defined(CONFIG_HAS_ETH0) || defined(CONFIG_HAS_ETH1) ||\
     defined(CONFIG_HAS_ETH2) || defined(CONFIG_HAS_ETH3)
-       fdt_fixup_ethernet(blob, bd);
+       fdt_fixup_ethernet(blob);
 #endif
 
        do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
index 80a5c78a79436c2c98721b9666b21008a82fbcfc..12d90520317b74e83cb62278bbc1e5293900ff67 100644 (file)
@@ -25,7 +25,7 @@ void ft_cpu_setup(void *blob, bd_t *bd)
 
 #if defined(CONFIG_HAS_ETH0) || defined(CONFIG_HAS_ETH1) \
     || defined(CONFIG_HAS_ETH2) || defined(CONFIG_HAS_ETH3)
-       fdt_fixup_ethernet(blob, bd);
+       fdt_fixup_ethernet(blob);
 #endif
 
 #ifdef CFG_NS16550
index 567094a96b065dd06c26f7ca409a70446a817ff6..7130983ff222f19e17d59c395af6fc5fe3a72ac1 100644 (file)
@@ -40,7 +40,7 @@ void ft_cpu_setup(void *blob, bd_t *bd)
                gd->brg_clk, 1);
 
        /* Fixup ethernet MAC addresses */
-       fdt_fixup_ethernet(blob, bd);
+       fdt_fixup_ethernet(blob);
 
        fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
 }
index 0323dc52fe59fe7b222326af9dd0176f0db721be..a97484fa74ee34123126fcdf89888fabfd3f5740 100644 (file)
@@ -130,7 +130,7 @@ void ft_cpu_setup(void *blob, bd_t *bd)
         * Fixup all ethernet nodes
         * Note: aliases in the dts are required for this
         */
-       fdt_fixup_ethernet(blob, bd);
+       fdt_fixup_ethernet(blob);
 
        /*
         * Fixup all available PCIe nodes by setting the device_type property
index a7c6326e128bff22acf46010b10933210f6c6bdf..f2f2cd5532c457bf22a5a6bba969b85126316646 100644 (file)
@@ -45,7 +45,7 @@ void do_fixup_by_compat(void *fdt, const char *compat,
 void do_fixup_by_compat_u32(void *fdt, const char *compat,
                            const char *prop, u32 val, int create);
 int fdt_fixup_memory(void *blob, u64 start, u64 size);
-void fdt_fixup_ethernet(void *fdt, bd_t *bd);
+void fdt_fixup_ethernet(void *fdt);
 int fdt_find_and_setprop(void *fdt, const char *node, const char *prop,
                         const void *val, int len, int create);
 void fdt_fixup_qe_firmware(void *fdt);