mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 3/4] net usb asix: read MAC from EEPROM on AX88772B
@ 2014-01-28 21:46 Philipp Zabel
  0 siblings, 0 replies; only message in thread
From: Philipp Zabel @ 2014-01-28 21:46 UTC (permalink / raw)
  To: barebox

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-01-28 21:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-28 21:46 [PATCH 3/4] net usb asix: read MAC from EEPROM on AX88772B Philipp Zabel

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