From: Daniel Mack <daniel@caiaq.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] ne2000: take MAC address from config if available
Date: Sat, 29 Nov 2008 14:17:28 +0100 [thread overview]
Message-ID: <20081129131728.GA23785@buzzloop.caiaq.de> (raw)
In-Reply-To: <f8328f7c0811282127g767c767ek3778eada51ae8b0d@mail.gmail.com>
Hi Ben,
On Fri, Nov 28, 2008 at 09:27:37PM -0800, Ben Warren wrote:
> > 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.
> >
>
> CONFIG_ETHADDR is bad and shouldn't be used unless you only ever plan on
> building one board. No new board ports will be accepted that define it.
I agree it's a hack, but in order to boot the board from ethernet, there
is need for something, even if it's not perfect.
> What would be better here, although it's still not very good, would be to
> have something like CONFIG_NE2000_NOPROM, and if defined, make a
> 'getenv("ethaddr")' call and program the hardware with the return value
> (with proper error checking, of course).
I agree. See the patch below.
Thanks,
Daniel
This patch adds CONFIG_NE2000_NOPROM as configuration variable and reads
the 'ethaddr' setting from environment to set up the adapter.
Signed-off-by: Daniel Mack <daniel@caiaq.de>
diff --git a/drivers/net/ne2000_base.c b/drivers/net/ne2000_base.c
index f93f932..86c1380 100644
--- a/drivers/net/ne2000_base.c
+++ b/drivers/net/ne2000_base.c
@@ -669,7 +669,6 @@ void uboot_push_tx_done(int key, int val) {
int eth_init(bd_t *bd) {
int r;
u8 dev_addr[6];
- char ethaddr[20];
PRINTK("### eth_init\n");
@@ -693,16 +692,35 @@ int eth_init(bd_t *bd) {
nic.base = (u8 *) CONFIG_DRIVER_NE2000_BASE;
- r = get_prom(dev_addr, nic.base);
- if (!r)
- return -1;
+#ifndef CONFIG_NE2000_NOPROM
+ {
+ char ethaddr[20];
+ r = get_prom(dev_addr, nic.base);
+ if (!r)
+ return -1;
+
+ sprintf (ethaddr, "%02X:%02X:%02X:%02X:%02X:%02X",
+ dev_addr[0], dev_addr[1],
+ dev_addr[2], dev_addr[3],
+ dev_addr[4], dev_addr[5]) ;
+ PRINTK("Set environment from HW MAC addr = \"%s\"\n", ethaddr);
+ setenv ("ethaddr", ethaddr);
+ }
+#else /* CONFIG_NE2000_NOPROM */
+ {
+ char *s = getenv("ethaddr");
- sprintf (ethaddr, "%02X:%02X:%02X:%02X:%02X:%02X",
- dev_addr[0], dev_addr[1],
- dev_addr[2], dev_addr[3],
- dev_addr[4], dev_addr[5]) ;
- PRINTK("Set environment from HW MAC addr = \"%s\"\n", ethaddr);
- setenv ("ethaddr", ethaddr);
+ if (!s) {
+ printf ("CONFIG_NE2000_NOPROM set but no "
+ "ethaddr given in environment.\n");
+ return -1;
+ }
+
+ /* convert the string notation */
+ for (r = 0; r < 6; r++)
+ dev_addr[r] = simple_strtol(s + (r * 3), NULL, 16);
+ }
+#endif
nic.data = nic.base + DP_DATA;
nic.tx_buf1 = START_PG;
next prev parent reply other threads:[~2008-11-29 13:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081129131728.GA23785@buzzloop.caiaq.de \
--to=daniel@caiaq.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox