mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: barebox@lists.infradead.org
Cc: sha@pengutronix.de
Subject: [PATCH 1/2] smc91111: fix odering of mac address read from EEPROM
Date: Mon,  1 Feb 2010 11:31:02 +0100	[thread overview]
Message-ID: <1265020263-21417-2-git-send-email-mkl@pengutronix.de> (raw)
In-Reply-To: <1265020263-21417-1-git-send-email-mkl@pengutronix.de>

On my little endian PXA270, the ethernet address is byte swapped:

correct ethernet address: 00:50:c2:80:a7:bd
broken  ethernet address: 50:00:80:c2:bd:a7

The correct value is what the sticker on the baoard and the linux driver
says. This patch fixes the problem by reading the ethaddr byte-wise from
the eeprom.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/smc91111.c |   23 +++++++++--------------
 1 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/drivers/net/smc91111.c b/drivers/net/smc91111.c
index 0df664a..9b41c67 100644
--- a/drivers/net/smc91111.c
+++ b/drivers/net/smc91111.c
@@ -1166,22 +1166,17 @@ static int smc91c111_eth_rx(struct eth_device *edev)
 static int smc91c111_get_ethaddr(struct eth_device *edev, unsigned char *m)
 {
 	struct smc91c111_priv *priv = (struct smc91c111_priv *)edev->priv;
-	unsigned address[3];
+	int valid = 0;
+	int i;
 
 	SMC_SELECT_BANK(priv, 1);
-	address[0] = SMC_inw(priv, ADDR0_REG);
-	address[1] = SMC_inw(priv, ADDR0_REG + 2);
-	address[2] = SMC_inw(priv, ADDR0_REG + 4);
-
-	if (address[0] + address[1] + address[2] == 0)
-		return -1;	/* no eeprom, no mac */
-
-	m[0] = address[0] >> 8;
-	m[1] = address[0];
-	m[2] = address[1] >> 8;
-	m[3] = address[1];
-	m[4] = address[2] >> 8;
-	m[5] = address[2];
+
+	for (i = 0; i < 6; ++i)
+		valid += m[i] = SMC_inb(priv, (ADDR0_REG + i));
+
+	/* no eeprom, no mac */
+	if (!valid)
+		return -1;
 
 	return 0;
 }
-- 
1.6.6.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2010-02-01 10:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-01 10:31 [PATCH 0/2] smc91111 mac address and cfi flash fixes Marc Kleine-Budde
2010-02-01 10:31 ` Marc Kleine-Budde [this message]
2010-02-01 10:31   ` [PATCH 2/2] cfi_flash: fix alignment problem Marc Kleine-Budde
2010-02-01 15:31 ` [PATCH 0/2] smc91111 mac address and cfi flash fixes Sascha Hauer

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=1265020263-21417-2-git-send-email-mkl@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=sha@pengutronix.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