Skip to contentSkip to conversation

dm9000 EEPROM reading bugfix

PATCH New David Brownell 4 participants 8 messages Apr 12, 2009 – Apr 27, 2009 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dm9000 EEPROM reading bugfix

From: David Brownell <[email protected]>

Make the U-Boot dm9000 driver read addresses from EEPROM just like Linux does ... read six bytes, instead of reading twelve bytes then discarding every one.

Using the right Ethernet address is a big win.

---
 drivers/net/dm9000x.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/dm9000x.c +6 -6
@@ -113,7 +113,7 @@ void eth_halt(void);
 static int dm9000_probe(void);
 static u16 phy_read(int);
 static void phy_write(int, u16);
-u16 read_srom_word(int);
+static void read_srom_word(int, u8 *);
 static u8 DM9000_ior(int);
 static void DM9000_iow(int reg, u8 value);
 
@@ -348,8 +348,8 @@ eth_init(bd_t * bd)
 	/* Set Node address */
 	if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
 #if !defined(CONFIG_AT91SAM9261EK)
-		for (i = 0; i < 6; i++)
-			enetaddr[i] = read_srom_word(i);
+		for (i = 0; i < 3; i++)
+			read_srom_word(i, enetaddr + 2 * i);
 		eth_setenv_enetaddr("ethaddr", enetaddr);
 #endif
 	}
@@ -541,14 +541,14 @@ eth_rx(void)
 /*
   Read a word data from SROM
 */
-u16
-read_srom_word(int offset)
+static void read_srom_word(int offset, u8 *to)
 {
 	DM9000_iow(DM9000_EPAR, offset);
 	DM9000_iow(DM9000_EPCR, 0x4);
 	udelay(8000);
 	DM9000_iow(DM9000_EPCR, 0x0);
-	return (DM9000_ior(DM9000_EPDRL) + (DM9000_ior(DM9000_EPDRH) << 8));
+	to[0] = DM9000_ior(DM9000_EPDRL);
+	to[1] = DM9000_ior(DM9000_EPDRH);
 }
 
 void
#1 lore raw

PATCH 1/1 dm9000 EEPROM reading bugfix

Quoted 2 lines · David Brownell

... read six bytes, instead of reading twelve
bytes then discarding every one.

Urgh, editing goof. Should read "discarding every other one".

#2 lore raw

PATCH 1/1 dm9000 EEPROM reading bugfix

Quoted 5 lines · David Brownell
Quoted 2 lines · David Brownell

... read six bytes, instead of reading twelve
bytes then discarding every one.

Urgh, editing goof. Should read "discarding every other one".

please send a new version

Best Regards,
J.

#3 lore raw

PATCH 1/1 dm9000 EEPROM reading bugfix

From: David Brownell <[email protected]>

Make the U-Boot dm9000 driver read addresses from EEPROM just like Linux does ... read six bytes, instead of reading twelve bytes and then discarding every other one.

Using the right Ethernet address is a big win.

---
 drivers/net/dm9000x.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/dm9000x.c +6 -6
@@ -113,7 +113,7 @@ void eth_halt(void);
 static int dm9000_probe(void);
 static u16 phy_read(int);
 static void phy_write(int, u16);
-u16 read_srom_word(int);
+static void read_srom_word(int, u8 *);
 static u8 DM9000_ior(int);
 static void DM9000_iow(int reg, u8 value);
 
@@ -348,8 +348,8 @@ eth_init(bd_t * bd)
 	/* Set Node address */
 	if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
 #if !defined(CONFIG_AT91SAM9261EK)
-		for (i = 0; i < 6; i++)
-			enetaddr[i] = read_srom_word(i);
+		for (i = 0; i < 3; i++)
+			read_srom_word(i, enetaddr + 2 * i);
 		eth_setenv_enetaddr("ethaddr", enetaddr);
 #endif
 	}
@@ -541,14 +541,14 @@ eth_rx(void)
 /*
   Read a word data from SROM
 */
-u16
-read_srom_word(int offset)
+static void read_srom_word(int offset, u8 *to)
 {
 	DM9000_iow(DM9000_EPAR, offset);
 	DM9000_iow(DM9000_EPCR, 0x4);
 	udelay(8000);
 	DM9000_iow(DM9000_EPCR, 0x0);
-	return (DM9000_ior(DM9000_EPDRL) + (DM9000_ior(DM9000_EPDRH) << 8));
+	to[0] = DM9000_ior(DM9000_EPDRL);
+	to[1] = DM9000_ior(DM9000_EPDRH);
 }
 
 void
#4 lore raw

PATCH 1/1 dm9000 EEPROM reading bugfix

Quoted 9 lines · David Brownell

From: David Brownell <[email protected]>

Make the U-Boot dm9000 driver read addresses from EEPROM just like Linux does ... read six bytes, instead of reading twelve bytes and then discarding every other one.

Using the right Ethernet address is a big win.

look fine for me

Ben any comments?

Best Regards,
J.

#5 lore raw

PATCH 1/1 dm9000 EEPROM reading bugfix

Quoted 10 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 8 lines · David Brownell

From: David Brownell <[email protected]>

Make the U-Boot dm9000 driver read addresses from EEPROM just like Linux does ... read six bytes, instead of reading twelve bytes and then discarding every other one.

Using the right Ethernet address is a big win.

:)

Quoted 9 lines
Quoted 2 lines

look fine for me

Ben any comments?

Best Regards,
J.

I'll apply to net/next

regards,
Ben

#6 lore raw

PATCH 1/1 dm9000 EEPROM reading bugfix

In reply to David Brownell

Wolfgang,

Quoted 54 lines · David Brownell

From: David Brownell <[email protected]>

Make the U-Boot dm9000 driver read addresses from EEPROM just like Linux does ... read six bytes, instead of reading twelve bytes and then discarding every other one.

Using the right Ethernet address is a big win.

---
 drivers/net/dm9000x.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/dm9000x.c +6 -6
@@ -113,7 +113,7 @@ void eth_halt(void);
 static int dm9000_probe(void);
 static u16 phy_read(int);
 static void phy_write(int, u16);
-u16 read_srom_word(int);
+static void read_srom_word(int, u8 *);
 static u8 DM9000_ior(int);
 static void DM9000_iow(int reg, u8 value);
 
@@ -348,8 +348,8 @@ eth_init(bd_t * bd)
 	/* Set Node address */
 	if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
 #if !defined(CONFIG_AT91SAM9261EK)
-		for (i = 0; i < 6; i++)
-			enetaddr[i] = read_srom_word(i);
+		for (i = 0; i < 3; i++)
+			read_srom_word(i, enetaddr + 2 * i);
 		eth_setenv_enetaddr("ethaddr", enetaddr);
 #endif
 	}
@@ -541,14 +541,14 @@ eth_rx(void)
 /*
   Read a word data from SROM
 */
-u16
-read_srom_word(int offset)
+static void read_srom_word(int offset, u8 *to)
 {
 	DM9000_iow(DM9000_EPAR, offset);
 	DM9000_iow(DM9000_EPCR, 0x4);
 	udelay(8000);
 	DM9000_iow(DM9000_EPCR, 0x0);
-	return (DM9000_ior(DM9000_EPDRL) + (DM9000_ior(DM9000_EPDRH) << 8));
+	to[0] = DM9000_ior(DM9000_EPDRL);
+	to[1] = DM9000_ior(DM9000_EPDRH);
 }
 
 void
Quoted 1 line

____

Please apply this directly. I incorrectly looked at it as a feature rather than a bug fix.

regards,
Ben

#7 lore raw

PATCH 1/1 dm9000 EEPROM reading bugfix

In reply to David Brownell

Dear David Brownell,

Quoted 6 lines · In message <[email protected]> you wrote:

From: David Brownell <[email protected]>

Make the U-Boot dm9000 driver read addresses from EEPROM just like Linux does ... read six bytes, instead of reading twelve bytes and then discarding every other one.

Quoted 6 lines

Using the right Ethernet address is a big win.

---
 drivers/net/dm9000x.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I have a very small mind and must live with it.    -- Edsger Dijkstra