Skip to contentSkip to conversation

Fix DM9000 MAC address handling

PATCH New Ben Warren 2 participants 3 messages Oct 22, 2009 Network drivers

lore
Share & tools
lore

Ben Warren

author
#0 lore raw

PATCH 1/1 Fix DM9000 MAC address handling

Proper behavior is to pull MAC address from NVRAM in the initialization() and stuff it in dev->address, then program the device from dev->address in the init() function.

---
 drivers/net/dm9000x.c |   27 +++++++++++++++------------
 1 files changed, 15 insertions(+), 12 deletions(-)
drivers/net/dm9000x.c +15 -12
index efe9135..d89488e 100644
@@ -284,7 +284,6 @@ static int dm9000_init(struct eth_device *dev, bd_t *bd)
 	int i, oft, lnk;
 	u8 io_mode;
 	struct board_info *db = &dm9000_info;
-	uchar enetaddr[6];
 
 	DM9000_DBG("%s\n", __func__);
 
@@ -342,20 +341,11 @@ static int dm9000_init(struct eth_device *dev, bd_t *bd)
 	/* Clear interrupt status */
 	DM9000_iow(DM9000_ISR, ISR_ROOS | ISR_ROS | ISR_PTS | ISR_PRS);
 
-	/* Set Node address */
-	if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
-#if !defined(CONFIG_DM9000_NO_SROM)
-		for (i = 0; i < 3; i++)
-			dm9000_read_srom_word(i, enetaddr + 2 * i);
-		eth_setenv_enetaddr("ethaddr", enetaddr);
-#endif
-	}
-
-	printf("MAC: %pM\n", enetaddr);
+	printf("MAC: %pM\n", dev->enetaddr);
 
 	/* fill device MAC address registers */
 	for (i = 0, oft = DM9000_PAR; i < 6; i++, oft++)
-		DM9000_iow(oft, enetaddr[i]);
+		DM9000_iow(oft, dev->enetaddr[i]);
 	for (i = 0, oft = 0x16; i < 8; i++, oft++)
 		DM9000_iow(oft, 0xff);
 
@@ -558,6 +548,16 @@ void dm9000_write_srom_word(int offset, u16 val)
 }
 #endif
 
+void dm9000_get_enetaddr(struct eth_device *dev)
+{
+#if !defined(CONFIG_DM9000_NO_SROM)
+	int i;
+	for (i = 0; i < 3; i++) {
+		dm9000_read_srom_word(i, dev->enetaddr + (2 * i));
+	}
+#endif
+}
+
 /*
    Read a byte from I/O port
 */
@@ -621,6 +621,9 @@ int dm9000_initialize(bd_t *bis)
 {
 	struct eth_device *dev = &(dm9000_info.netdev);
 
+	/* Load MAC address from EEPROM */
+	dm9000_get_enetaddr(dev);
+
 	dev->init = dm9000_init;
 	dev->halt = dm9000_halt;
 	dev->send = dm9000_send;
Signature · 1 line
1.6.0.4
#1 lore raw

PATCH 1/1 Fix DM9000 MAC address handling

Quoted 1 line · On Wednesday 21 October 2009 20:25:09 Ben Warren wrote:

+void dm9000_get_enetaddr(struct eth_device *dev)

static ?

drivers/net/dm9000x.c void dm9000_write_srom_word(int offset, u16 val) · line 557

Quoted 5 lines
drivers/net/dm9000x.c +5 -0
+#if !defined(CONFIG_DM9000_NO_SROM)
+	int i;
+	for (i = 0; i < 3; i++) {
+		dm9000_read_srom_word(i, dev->enetaddr + (2 * i));
+	}

dont need the braces ...
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20091021/bb323cc8/attachment.pgp

author
#2 lore raw

PATCH 1/1 Fix DM9000 MAC address handling

Quoted 8 lines · Mike Frysinger
Quoted 2 lines · On Wednesday 21 October 2009 20:25:09 Ben Warren wrote:

+void dm9000_get_enetaddr(struct eth_device *dev)

static ?

Yeah, this was thrown together pretty quickly...

Quoted 9 lines

drivers/net/dm9000x.c void dm9000_write_srom_word(int offset, u16 val) · line 557

Quoted 6 lines
drivers/net/dm9000x.c +5 -0
+#if !defined(CONFIG_DM9000_NO_SROM)
+	int i;
+	for (i = 0; i < 3; i++) {
+		dm9000_read_srom_word(i, dev->enetaddr + (2 * i));
+	}

dont need the braces ...

OK

Quoted 2 lines

-mike

thanks for the review,
Ben