mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Philipp Zabel <philipp.zabel@gmail.com>
To: barebox@lists.infradead.org
Subject: [PATCH 3/4] net usb asix: read MAC from EEPROM on AX88772B
Date: Tue, 28 Jan 2014 22:46:46 +0100	[thread overview]
Message-ID: <1390945606-8619-1-git-send-email-philipp.zabel@gmail.com> (raw)

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
---
 drivers/net/usb/asix.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c
index 003ebba..085d728 100644
--- a/drivers/net/usb/asix.c
+++ b/drivers/net/usb/asix.c
@@ -132,6 +132,8 @@
 #define MARVELL_CTRL_TXDELAY	0x0002
 #define MARVELL_CTRL_RXDELAY	0x0080
 
+#define FLAG_EEPROM_MAC		(1UL << 0) /* init device MAC from eeprom */
+
 /* This structure cannot exceed sizeof(unsigned long [5]) AKA 20 bytes */
 struct asix_data {
 	u8 multi_filter[AX_MCAST_FILTER_SIZE];
@@ -364,11 +366,21 @@ static int asix_write_gpio(struct usbnet *dev, u16 value, int sleep)
 static int asix_get_ethaddr(struct eth_device *edev, unsigned char *adr)
 {
 	struct usbnet *udev = container_of(edev, struct usbnet, edev);
-	int ret;
+	int i, ret;
 
 	/* Get the MAC address */
-	if ((ret = asix_read_cmd(udev, AX_CMD_READ_NODE_ID,
-				0, 0, 6, adr)) < 0) {
+	if (udev->driver_info->data & FLAG_EEPROM_MAC) {
+		for (i = 0; i < (6 >> 1); i++) {
+			ret = asix_read_cmd(udev, AX_CMD_READ_EEPROM, 0x04 + i,
+					0, 2, adr + i * 2);
+			if (ret < 0)
+				break;
+		}
+	} else {
+		ret = asix_read_cmd(udev, AX_CMD_READ_NODE_ID, 0, 0, 6, adr);
+	}
+
+	if (ret < 0) {
 		debug("Failed to read MAC address: %d\n", ret);
 		return -1;
 	}
-- 
1.8.5.3


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

                 reply	other threads:[~2014-01-28 21:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1390945606-8619-1-git-send-email-philipp.zabel@gmail.com \
    --to=philipp.zabel@gmail.com \
    --cc=barebox@lists.infradead.org \
    /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