From c5a172a5fd636c12467429e3f7910e53773979c6 Mon Sep 17 00:00:00 2001
From: Stefan Roese <sr@denx.de>
Date: Tue, 14 Aug 2007 14:41:55 +0200
Subject: [PATCH] POST: Add option for external ethernet loopback test

When CFG_POST_ETHER_EXT_LOOPBACK is defined, the ethernet POST
is not done using an internal loopback connection, but by assuming
that an external loopback connector is plugged into the board.

Signed-off-by: Stefan Roese <sr@denx.de>
---
 post/cpu/ppc4xx/ether.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/post/cpu/ppc4xx/ether.c b/post/cpu/ppc4xx/ether.c
index 391c815d7ae..ab23ca5a3db 100644
--- a/post/cpu/ppc4xx/ether.c
+++ b/post/cpu/ppc4xx/ether.c
@@ -68,10 +68,10 @@ static char *rx_buf;
 static void ether_post_init (int devnum, int hw_addr)
 {
 	int i;
-	unsigned mode_reg;
 #if defined(CONFIG_440GX) || \
     defined(CONFIG_440EPX) || defined(CONFIG_440GRX) || \
     defined(CONFIG_440SP) || defined(CONFIG_440SPE)
+	unsigned mode_reg;
 	sys_info_t sysinfo;
 #endif
 #if defined(CONFIG_440EPX) || defined(CONFIG_440GRX) || defined(CONFIG_440SPE)
@@ -185,10 +185,17 @@ static void ether_post_init (int devnum, int hw_addr)
 	mtdcr (malrxcasr, (MAL_TXRX_CASR >> devnum));
 
 	/* set internal loopback mode */
+#ifdef CFG_POST_ETHER_EXT_LOOPBACK
+	out32 (EMAC_M1 + hw_addr, EMAC_M1_FDE | 0 |
+	       EMAC_M1_RFS_4K | EMAC_M1_TX_FIFO_2K |
+	       EMAC_M1_MF_100MBPS | EMAC_M1_IST |
+	       in32 (EMAC_M1));
+#else
 	out32 (EMAC_M1 + hw_addr, EMAC_M1_FDE | EMAC_M1_ILE |
 	       EMAC_M1_RFS_4K | EMAC_M1_TX_FIFO_2K |
 	       EMAC_M1_MF_100MBPS | EMAC_M1_IST |
 	       in32 (EMAC_M1));
+#endif
 
 	/* set transmit enable & receive enable */
 	out32 (EMAC_M0 + hw_addr, EMAC_M0_TXE | EMAC_M0_RXE);
-- 
GitLab