[U-Boot-Users] [PATCH v2] Add mechanisms for CPU and board-specific Ethernet initialization

2008-06-10 Thread Ben Warren
This patch is the first step in cleaning up net/eth.c, by moving Ethernet
initialization to CPU or board-specific code.  Initial implementation is
only on the Freescale TSEC controller, but others will be added soon.

Signed-off-by: Ben Warren [EMAIL PROTECTED]
---

When we discussed this a few months ago, I was planning on defining the 
cpu_eth_init() and board_eth_init() functions as weak with no aliases, but in
my testing this did not result in them being NULL, hence the default function.

 board/atum8548/atum8548.c |   18 +++
 board/freescale/mpc8313erdb/mpc8313erdb.c |   12 ++
 board/freescale/mpc8315erdb/mpc8315erdb.c |   12 ++
 board/freescale/mpc8349emds/mpc8349emds.c |   12 ++
 board/freescale/mpc8349itx/mpc8349itx.c   |   12 ++
 board/freescale/mpc837xemds/mpc837xemds.c |   12 ++
 board/freescale/mpc837xerdb/mpc837xerdb.c |   13 +++
 board/freescale/mpc8540ads/mpc8540ads.c   |   22 ++
 board/freescale/mpc8541cds/mpc8541cds.c   |   12 ++
 board/freescale/mpc8544ds/mpc8544ds.c |   18 +++
 board/freescale/mpc8548cds/mpc8548cds.c   |   18 +++
 board/freescale/mpc8555cds/mpc8555cds.c   |   12 ++
 board/freescale/mpc8560ads/mpc8560ads.c   |   12 ++
 board/freescale/mpc8568mds/mpc8568mds.c   |   12 ++
 board/freescale/mpc8641hpcn/mpc8641hpcn.c |   18 +++
 board/mpc8540eval/mpc8540eval.c   |   22 ++
 board/pm854/pm854.c   |   22 ++
 board/pm856/pm856.c   |   12 ++
 board/sbc8349/sbc8349.c   |   12 ++
 board/sbc8548/sbc8548.c   |   18 +++
 board/sbc8560/sbc8560.c   |9 +++
 board/sbc8641d/sbc8641d.c |   18 +++
 board/stxgp3/stxgp3.c |   12 ++
 board/stxssa/stxssa.c |   12 ++
 board/tqm834x/tqm834x.c   |   12 ++
 board/tqm85xx/tqm85xx.c   |   22 ++
 include/netdev.h  |   34 +
 net/eth.c |   26 -
 28 files changed, 430 insertions(+), 16 deletions(-)
 create mode 100644 include/netdev.h

diff --git a/board/atum8548/atum8548.c b/board/atum8548/atum8548.c
index 2f6ae29..d6bd8ae 100644
--- a/board/atum8548/atum8548.c
+++ b/board/atum8548/atum8548.c
@@ -34,6 +34,7 @@
 #include miiphy.h
 #include libfdt.h
 #include fdt_support.h
+#include netdev.h
 
 #if defined(CONFIG_DDR_ECC)  !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
 extern void ddr_enable_ecc(unsigned int dram_size);
@@ -417,3 +418,20 @@ ft_board_setup(void *blob, bd_t *bd)
}
 }
 #endif
+
+int board_eth_init(bd_t *bis)
+{
+#if defined(CONFIG_TSEC1)
+   tsec_initialize(bis, 0, CONFIG_TSEC1_NAME);
+#endif
+#if defined(CONFIG_TSEC2)
+   tsec_initialize(bis, 1, CONFIG_TSEC2_NAME);
+#endif
+#if defined(CONFIG_TSEC3)
+   tsec_initialize(bis, 2, CONFIG_TSEC3_NAME);
+#endif
+#if defined(CONFIG_TSEC4)
+   tsec_initialize(bis, 3, CONFIG_TSEC4_NAME);
+#endif
+   return 0;
+}
diff --git a/board/freescale/mpc8313erdb/mpc8313erdb.c 
b/board/freescale/mpc8313erdb/mpc8313erdb.c
index 7cbdb7b..00abb6b 100644
--- a/board/freescale/mpc8313erdb/mpc8313erdb.c
+++ b/board/freescale/mpc8313erdb/mpc8313erdb.c
@@ -29,6 +29,7 @@
 #include pci.h
 #include mpc83xx.h
 #include vsc7385.h
+#include netdev.h
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -128,3 +129,14 @@ void ft_board_setup(void *blob, bd_t *bd)
 #endif
 }
 #endif
+
+int board_eth_init(bd_t *bis)
+{
+#if defined(CONFIG_TSEC1)
+   tsec_initialize(bis, 0, CONFIG_TSEC1_NAME);
+#endif
+#if defined(CONFIG_TSEC2)
+   tsec_initialize(bis, 1, CONFIG_TSEC2_NAME);
+#endif
+   return 0;
+}
diff --git a/board/freescale/mpc8315erdb/mpc8315erdb.c 
b/board/freescale/mpc8315erdb/mpc8315erdb.c
index 7af36dd..136b0aa 100644
--- a/board/freescale/mpc8315erdb/mpc8315erdb.c
+++ b/board/freescale/mpc8315erdb/mpc8315erdb.c
@@ -30,6 +30,7 @@
 #endif
 #include pci.h
 #include mpc83xx.h
+#include netdev.h
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -130,3 +131,14 @@ void ft_board_setup(void *blob, bd_t *bd)
 #endif
 }
 #endif
+
+int board_eth_init(bd_t *bis)
+{
+#if defined(CONFIG_TSEC1)
+   tsec_initialize(bis, 0, CONFIG_TSEC1_NAME);
+#endif
+#if defined(CONFIG_TSEC2)
+   tsec_initialize(bis, 1, CONFIG_TSEC2_NAME);
+#endif
+   return 0;
+}
diff --git a/board/freescale/mpc8349emds/mpc8349emds.c 
b/board/freescale/mpc8349emds/mpc8349emds.c
index 6c82596..59ace6c 100644
--- a/board/freescale/mpc8349emds/mpc8349emds.c
+++ b/board/freescale/mpc8349emds/mpc8349emds.c
@@ -30,6 +30,7 @@
 #include spi.h
 #include miiphy.h
 #include spd_sdram.h
+#include netdev.h
 
 #if defined(CONFIG_OF_LIBFDT)
 #include libfdt.h
@@ -287,3 +288,14 @@ void ft_board_setup(void *blob, 

Re: [U-Boot-Users] [PATCH v2] Add mechanisms for CPU and board-specific Ethernet initialization

2008-06-10 Thread Jon Loeliger
On Tue, 2008-06-10 at 07:03 -0700, Ben Warren wrote:
 +#if defined(CONFIG_TSEC1)
 +   tsec_initialize(bis, 0, CONFIG_TSEC1_NAME);
 +#endif
 +#if defined(CONFIG_TSEC2)
 +   tsec_initialize(bis, 1, CONFIG_TSEC2_NAME);
 +#endif
 +#if defined(CONFIG_MPC85XX_FEC)
 +   tsec_initialize(bis, 2, CONFIG_MPC85XX_FEC_NAME);
 +#else
 +#if defined(CONFIG_TSEC3)
 +   tsec_initialize(bis, 2, CONFIG_TSEC3_NAME);
 +#endif
 +#if defined(CONFIG_TSEC4)
 +   tsec_initialize(bis, 3, CONFIG_TSEC4_NAME);
 +#endif
 +#endif
 +   return 0;
 +}

So, why not make a new function in tsec.c called something
like tsec_initialize_all(bis) with essentially the above
#ifdef-series and make all of the individual board functions
just be like:

+int board_eth_init(bd_t *bis)
+{
+   tsec_initialize_all(bis);
+   return 0;
+}

Just a notion.  Haven't actually thought about it...

jdl




-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
___
U-Boot-Users mailing list
U-Boot-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/u-boot-users


Re: [U-Boot-Users] [PATCH v2] Add mechanisms for CPU and board-specific Ethernet initialization

2008-06-10 Thread Ben Warren
Jon Loeliger wrote:
 On Tue, 2008-06-10 at 07:03 -0700, Ben Warren wrote:
   
 +#if defined(CONFIG_TSEC1)
 +   tsec_initialize(bis, 0, CONFIG_TSEC1_NAME);
 +#endif
 +#if defined(CONFIG_TSEC2)
 +   tsec_initialize(bis, 1, CONFIG_TSEC2_NAME);
 +#endif
 +#if defined(CONFIG_MPC85XX_FEC)
 +   tsec_initialize(bis, 2, CONFIG_MPC85XX_FEC_NAME);
 +#else
 +#if defined(CONFIG_TSEC3)
 +   tsec_initialize(bis, 2, CONFIG_TSEC3_NAME);
 +#endif
 +#if defined(CONFIG_TSEC4)
 +   tsec_initialize(bis, 3, CONFIG_TSEC4_NAME);
 +#endif
 +#endif
 +   return 0;
 +}
 

 So, why not make a new function in tsec.c called something
 like tsec_initialize_all(bis) with essentially the above
 #ifdef-series and make all of the individual board functions
 just be like:

 +int board_eth_init(bd_t *bis)
 +{
 +   tsec_initialize_all(bis);
 +   return 0;
 +}

   
I'd prefer to abstract index information away from the drivers.  That 
way if you guys come up with a chip that has 8 TSECs, the driver doesn't 
have to change.  Next release cycle I'm planning on bringing in PHY lib 
support, in which case we'll want to pass specific info to each instance 
of the TSEC.  That said, what you're suggesting would be a good 
candidate for a cpu_eth_init() function, that can be overridden by 
board_eth_init() if desired.  Ya man, I dig it.  I'll play around with 
that tonight.
 Just a notion.  Haven't actually thought about it...

   
Please keep not thinking.  It's more interesting than most peoples' 
fully-baked discussion :)
 jdl

   
cheers,
Ben

-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
___
U-Boot-Users mailing list
U-Boot-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/u-boot-users