public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] ne2000: take MAC address from config if available
@ 2008-11-28 16:16 Daniel Mack
  2008-11-29  5:27 ` Ben Warren
  0 siblings, 1 reply; 8+ messages in thread
From: Daniel Mack @ 2008-11-28 16:16 UTC (permalink / raw)
  To: u-boot

Hi,

the board I'm currently working on has an ASIX AX88796 NE2000 clone but
no EEPROM attached to it. Hence, the get_prom() routine returns zeros
only so the system won't work.

This patch takes the MAC address given by CONFIG_ETHADDR and translates
it to numeric values. This could probably go to some other, more generic
place, but I didn't find any.

Best regards,
Daniel


diff --git a/drivers/net/ne2000_base.c b/drivers/net/ne2000_base.c
index f93f932..f8480a3 100644
--- a/drivers/net/ne2000_base.c
+++ b/drivers/net/ne2000_base.c
@@ -693,6 +693,7 @@ int eth_init(bd_t *bd) {
 
 	nic.base = (u8 *) CONFIG_DRIVER_NE2000_BASE;
 
+#ifndef CONFIG_ETHADDR
 	r = get_prom(dev_addr, nic.base);
 	if (!r)
 		return -1;
@@ -703,6 +704,20 @@ int eth_init(bd_t *bd) {
 		 dev_addr[4], dev_addr[5]) ;
 	PRINTK("Set environment from HW MAC addr = \"%s\"\n", ethaddr);
 	setenv ("ethaddr", ethaddr);
+#else /* CONFIG_ETHADDR */
+#define STR(X) #X
+#define XSTR(X) STR(X)
+	strncpy(ethaddr, XSTR(CONFIG_ETHADDR), sizeof(ethaddr));
+
+	/* replace all colons by NULL characters */
+	for (r = 0; r < strlen(ethaddr); r++)
+		if (ethaddr[r] == ':')
+			ethaddr[r] = '\0';
+	
+	/* convert the string notation */
+	for (r = 0; r < 6; r++)
+		dev_addr[r] = simple_strtol(ethaddr + (r * 3), NULL, 16);
+#endif
 
 	nic.data = nic.base + DP_DATA;
 	nic.tx_buf1 = START_PG;

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-01-27 13:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-28 16:16 [U-Boot] [PATCH] ne2000: take MAC address from config if available Daniel Mack
2008-11-29  5:27 ` Ben Warren
2008-11-29 13:17   ` Daniel Mack
2008-12-03  1:01     ` Daniel Mack
2008-12-14 11:12       ` Wolfgang Denk
2008-12-14 11:39         ` Daniel Mack
2009-01-27 13:09           ` Daniel Mack
2009-01-27 13:31             ` Wolfgang Denk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox