From 1066281edc5258689a085d0d9e15e2b0988c2cf0 Mon Sep 17 00:00:00 2001
From: Thomas Chou <thomas@wytron.com.tw>
Date: Fri, 4 Jan 2008 12:04:19 +0800
Subject: [PATCH] nios2: set MAC regs in platform_device initialization

Some dev boards does not have eerom to read eth MAC address. We can
set the MAC regs and pass it to drivers.

The previous eth MAC hooks in net drivers are removed.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
---
 linux-2.6.x/arch/nios2nommu/kernel/setup.c |   13 ++++++++++++-
 linux-2.6.x/drivers/net/dm9000.c           |    6 ------
 linux-2.6.x/drivers/net/smc91x.c           |    6 ------
 3 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/linux-2.6.x/arch/nios2nommu/kernel/setup.c b/linux-2.6.x/arch/nios2nommu/kernel/setup.c
index 476cf2f..9bb1f93 100644
--- a/linux-2.6.x/arch/nios2nommu/kernel/setup.c
+++ b/linux-2.6.x/arch/nios2nommu/kernel/setup.c
@@ -502,7 +502,6 @@ struct seq_operations cpuinfo_op = {
 // note, hardware MAC address is still undefined
 
 #if defined(CONFIG_SMC91X) && defined(na_enet)
-
 #ifndef LAN91C111_REGISTERS_OFFSET
 #define LAN91C111_REGISTERS_OFFSET 0x300
 #endif
@@ -527,6 +526,12 @@ static struct platform_device smc91x_device = {
 };
 static int __init smc91x_device_init(void)
 {
+#define SMC_DEBUG 0
+#include "../../../drivers/net/smc91x.h"
+	/* write eth hardware address to MAC */
+	void __iomem *ioaddr = (void *)(na_enet + LAN91C111_REGISTERS_OFFSET);
+	SMC_SELECT_BANK(1);
+	SMC_SET_MAC_ADDR(excalibur_enet_hwaddr);
 	/* customizes platform devices, or adds new ones */
 	platform_device_register(&smc91x_device);
 	return 0;
@@ -574,6 +579,12 @@ static struct platform_device dm9k_device = {
 };
 static int __init dm9k_device_init(void)
 {
+	/* write eth hardware address to MAC */
+	int i;
+	for (i = 0; i < 6; i++) {
+		writeb(0x10 + i, na_dm9000); /* DM9000_PAR */
+		writeb(excalibur_enet_hwaddr[i], na_dm9000 + 4);		
+	}
 	/* customizes platform devices, or adds new ones */
 	platform_device_register(&dm9k_device);
 	return 0;
diff --git a/linux-2.6.x/drivers/net/dm9000.c b/linux-2.6.x/drivers/net/dm9000.c
index 49f4af8..615d2b1 100644
--- a/linux-2.6.x/drivers/net/dm9000.c
+++ b/linux-2.6.x/drivers/net/dm9000.c
@@ -565,12 +565,6 @@ dm9000_probe(struct platform_device *pdev)
 	db->mii.mdio_read    = dm9000_phy_read;
 	db->mii.mdio_write   = dm9000_phy_write;
 
-#ifdef CONFIG_EXCALIBUR
-	{
-		extern unsigned char *excalibur_enet_hwaddr;
-		memcpy(ndev->dev_addr, excalibur_enet_hwaddr, 6);
-	}
-#else
 	/* Read SROM content */
 	for (i = 0; i < 64; i++)
 		((u16 *) db->srom)[i] = read_srom_word(db, i);
diff --git a/linux-2.6.x/drivers/net/smc91x.c b/linux-2.6.x/drivers/net/smc91x.c
index 4a89d42..95b6478 100644
--- a/linux-2.6.x/drivers/net/smc91x.c
+++ b/linux-2.6.x/drivers/net/smc91x.c
@@ -1917,12 +1917,6 @@ static int __init smc_probe(struct net_device *dev, void __iomem *ioaddr)
 	/* Get the MAC address */
 	SMC_SELECT_BANK(1);
 	SMC_GET_MAC_ADDR(dev->dev_addr);
-#ifdef CONFIG_EXCALIBUR
-	{
-		extern unsigned char *excalibur_enet_hwaddr;
-		memcpy(dev->dev_addr, excalibur_enet_hwaddr, 6);
-	}
-#endif
 
 	/* now, reset the chip, and put it into a known state */
 	smc_reset(dev);
-- 
1.5.3.3

