Re: [U-Boot] [PATCH v8] fdt: rework fdt_fixup_ethernet() to use env instead of bd_t

2008-08-20 Thread Wolfgang Denk
Dear Kumar Gala,

In message [EMAIL PROTECTED] you wrote:
 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 [EMAIL PROTECTED]
 ---
 
 Bump the array sizes to cover a vast number of ethernet mac addresses
 at Wolfgang's request.
 
 - k
 
  common/fdt_support.c  |   68 +++-
  cpu/74xx_7xx/cpu.c|2 +-
  cpu/mpc512x/cpu.c |2 +-
  cpu/mpc8260/cpu.c |2 +-
  cpu/mpc83xx/fdt.c |2 +-
  cpu/mpc85xx/fdt.c |2 +-
  cpu/mpc86xx/fdt.c |2 +-
  cpu/mpc8xx/fdt.c  |2 +-
  cpu/ppc4xx/fdt.c  |2 +-
  include/fdt_support.h |2 +-
  10 files changed, 36 insertions(+), 50 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH, MD: Wolfgang Denk  Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [EMAIL PROTECTED]
Murder is contrary to the laws of man and God.
-- M-5 Computer, The Ultimate Computer, stardate 4731.3
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v8] fdt: rework fdt_fixup_ethernet() to use env instead of bd_t

2008-08-19 Thread Kumar Gala
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 [EMAIL PROTECTED]
---

Bump the array sizes to cover a vast number of ethernet mac addresses
at Wolfgang's request.

- k

 common/fdt_support.c  |   68 +++-
 cpu/74xx_7xx/cpu.c|2 +-
 cpu/mpc512x/cpu.c |2 +-
 cpu/mpc8260/cpu.c |2 +-
 cpu/mpc83xx/fdt.c |2 +-
 cpu/mpc85xx/fdt.c |2 +-
 cpu/mpc86xx/fdt.c |2 +-
 cpu/mpc8xx/fdt.c  |2 +-
 cpu/ppc4xx/fdt.c  |2 +-
 include/fdt_support.h |2 +-
 10 files changed, 36 insertions(+), 50 deletions(-)

diff --git a/common/fdt_support.c b/common/fdt_support.c
index 93b144e..e57ac0a 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -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)
diff --git a/cpu/74xx_7xx/cpu.c b/cpu/74xx_7xx/cpu.c
index ea43c9a..c007abc 100644
--- a/cpu/74xx_7xx/cpu.c
+++ b/cpu/74xx_7xx/cpu.c
@@ -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
 /* - */
diff --git a/cpu/mpc512x/cpu.c b/cpu/mpc512x/cpu.c
index 703e188..1f39ac4 100644
--- a/cpu/mpc512x/cpu.c
+++ b/cpu/mpc512x/cpu.c
@@ -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
diff --git a/cpu/mpc8260/cpu.c b/cpu/mpc8260/cpu.c
index 4d5d141..efb8ed6 100644
--- a/cpu/mpc8260/cpu.c
+++ b/cpu/mpc8260/cpu.c
@@ -307,7 +307,7 @@ void ft_cpu_setup (void *blob, bd_t *bd)
 
 #if defined(CONFIG_HAS_ETH0) ||