Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Dec 2007 11:54:20 +0100 (CET)
From:      =?iso-8859-1?Q?Bj=F6rn_K=F6nig?= <bkoenig@alpha-tierchen.de>
To:        ticso@cicely.de
Cc:        freebsd-arm@freebsd.org
Subject:   Re: MMC cards support
Message-ID:  <51020.192.168.1.2.1197975260.squirrel@webmail.alpha-tierchen.de>

index | next in thread | raw e-mail

[-- Attachment #1 --]
Bernd Walter wrote:

> Don't remember the patch, but whoever is commiting this should please
> keep in mind that the driver should relocate the MAC into the first
> register set and wipe out the other sets, otherwise we end with two
> configured MAC if the MAC is changed via ifconfig into the first set.

Here it is. I picked up your thoughts and added appropriate code quickly.

Björn

[-- Attachment #2 --]
--- src/sys/arm/at91/if_ate.c.orig	2007-12-02 15:19:37.000000000 +0100
+++ src/sys/arm/at91/if_ate.c	2007-12-18 11:51:07.000000000 +0100
@@ -170,7 +170,7 @@
 	struct sysctl_ctx_list *sctx;
 	struct sysctl_oid *soid;
 	int err;
-	u_char eaddr[6];
+	u_char eaddr[ETHER_ADDR_LEN];
 
 	sc->dev = dev;
 	err = ate_activate(dev);
@@ -586,24 +586,38 @@
 static int
 ate_get_mac(struct ate_softc *sc, u_char *eaddr)
 {
+	bus_size_t sa_low_reg[] = { ETH_SA1L, ETH_SA2L, ETH_SA3L, ETH_SA4L };
+	bus_size_t sa_high_reg[] = { ETH_SA1H, ETH_SA2H, ETH_SA3H, ETH_SA4H };
 	uint32_t low, high;
+	int i;
 
 	/*
 	 * The boot loader setup the MAC with an address, if one is set in
-	 * the loader.  The TSC loader will also set the MAC address in a
-	 * similar way.  Grab the MAC address from the SA1[HL] registers.
+	 * the loader. Grab one MAC address from the SA[1-4][HL] registers.
 	 */
-	low = RD4(sc, ETH_SA1L);
-	high =  RD4(sc, ETH_SA1H);
-	if ((low | (high & 0xffff)) == 0)
-		return (ENXIO);
-	eaddr[0] = low & 0xff;
-	eaddr[1] = (low >> 8) & 0xff;
-	eaddr[2] = (low >> 16) & 0xff;
-	eaddr[3] = (low >> 24) & 0xff;
-	eaddr[4] = high & 0xff;
-	eaddr[5] = (high >> 8) & 0xff;
-	return (0);
+	for (i = 0; i < 4; i++) {
+		low = RD4(sc, sa_low_reg[i]);
+		high = RD4(sc, sa_high_reg[i]);
+		if ((low | (high & 0xffff)) != 0) {
+			eaddr[0] = low & 0xff;
+			eaddr[1] = (low >> 8) & 0xff;
+			eaddr[2] = (low >> 16) & 0xff;
+			eaddr[3] = (low >> 24) & 0xff;
+			eaddr[4] = high & 0xff;
+			eaddr[5] = (high >> 8) & 0xff;
+			if (i > 0) {
+				WR4(sc, sa_low_reg[0], low);
+				WR4(sc, sa_high_reg[0], high);
+			}
+			for (i = 1; i < 4; i++) {
+				WR4(sc, sa_low_reg[i], 0);
+				WR4(sc, sa_high_reg[i], 0);
+			}
+			return (0);
+		}
+	}
+
+	return (ENXIO);
 }
 
 static void
home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?51020.192.168.1.2.1197975260.squirrel>