summaryrefslogtreecommitdiff
path: root/post
diff options
context:
space:
mode:
authorStefan Roese <sr@denx.de>2007-10-25 12:24:59 +0200
committerStefan Roese <sr@denx.de>2007-10-31 21:20:51 +0100
commit7d47cee2cc57f907380f2c06f5b6c683d03e423a (patch)
treef19cda7667d3ef36bdf3e0bbe816dd1084f5dfff /post
parentf10493c6d77a1e07a6c2ff4d772937a5e7359d6a (diff)
downloadu-boot-7d47cee2cc57f907380f2c06f5b6c683d03e423a.tar.gz
u-boot-7d47cee2cc57f907380f2c06f5b6c683d03e423a.tar.bz2
u-boot-7d47cee2cc57f907380f2c06f5b6c683d03e423a.zip
ppc4xx: Fix POST ethernet test for Haleakala
The POST ethernet test needed to be changed to dynamically determine the count of ethernet devices. This code is cloned from the 4xx ethernet driver. Signed-off-by: Stefan Roese <sr@denx.de>
Diffstat (limited to 'post')
-rw-r--r--post/cpu/ppc4xx/ether.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/post/cpu/ppc4xx/ether.c b/post/cpu/ppc4xx/ether.c
index ab23ca5a3d..45f292b92f 100644
--- a/post/cpu/ppc4xx/ether.c
+++ b/post/cpu/ppc4xx/ether.c
@@ -52,6 +52,28 @@
DECLARE_GLOBAL_DATA_PTR;
+/*
+ * Get count of EMAC devices (doesn't have to be the max. possible number
+ * supported by the cpu)
+ *
+ * CONFIG_BOARD_EMAC_COUNT added so now a "dynamic" way to configure the
+ * EMAC count is possible. As it is needed for the Kilauea/Haleakala
+ * 405EX/405EXr eval board, using the same binary.
+ */
+#if defined(CONFIG_BOARD_EMAC_COUNT)
+#define LAST_EMAC_NUM board_emac_count()
+#else /* CONFIG_BOARD_EMAC_COUNT */
+#if defined(CONFIG_HAS_ETH3)
+#define LAST_EMAC_NUM 4
+#elif defined(CONFIG_HAS_ETH2)
+#define LAST_EMAC_NUM 3
+#elif defined(CONFIG_HAS_ETH1)
+#define LAST_EMAC_NUM 2
+#else
+#define LAST_EMAC_NUM 1
+#endif
+#endif /* CONFIG_BOARD_EMAC_COUNT */
+
#if defined(CONFIG_440SPE) || defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
#define SDR0_MFR_ETH_CLK_SEL_V(n) ((0x01<<27) / (n+1))
#endif
@@ -65,6 +87,8 @@ static volatile mal_desc_t rx __cacheline_aligned;
static char *tx_buf;
static char *rx_buf;
+int board_emac_count(void);
+
static void ether_post_init (int devnum, int hw_addr)
{
int i;
@@ -372,6 +396,7 @@ Done:
int ether_post_test (int flags)
{
int res = 0;
+ int i;
/* Allocate tx & rx packet buffers */
tx_buf = malloc (PKTSIZE_ALIGN + CFG_CACHELINE_SIZE);
@@ -383,13 +408,10 @@ int ether_post_test (int flags)
goto out_free;
}
- /* EMAC0 */
- if (test_ctlr (0, 0))
- res = -1;
-
- /* EMAC1 */
- if (test_ctlr (1, 0x100))
- res = -1;
+ for (i = 0; i < LAST_EMAC_NUM; i++) {
+ if (test_ctlr (i, i*0x100))
+ res = -1;
+ }
out_free:
free (tx_buf);