PERFORCE change 89497 for review
Warner Losh
imp at FreeBSD.org
Wed Jan 11 00:00:02 PST 2006
http://perforce.freebsd.org/chv.cgi?CH=89497
Change 89497 by imp at imp_hammer on 2006/01/11 07:59:48
Keep momentum: write a little code to grab the MAC address that the
boot loader left behind in the SA1[LH] registers. We never set it,
and respect what's there. If the boot loader isn't going to
do this for us, then we'll need to find out some other way of being
notified about the address. Since I don't think TS needs this extra
functionality, defer doing it.
Affected files ...
.. //depot/projects/arm/src/sys/arm/at91/if_ate.c#19 edit
Differences ...
==== //depot/projects/arm/src/sys/arm/at91/if_ate.c#19 (text+ko) ====
@@ -129,6 +129,7 @@
static void ate_deactivate(device_t dev);
static int ate_ifmedia_upd(struct ifnet *ifp);
static void ate_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr);
+static void ate_get_mac(struct ate_softc *sc, u_char *eaddr);
/*
* The AT91 family of products has the ethernet called EMAC. However,
@@ -161,6 +162,8 @@
ATE_LOCK_INIT(sc);
callout_init_mtx(&sc->tick_ch, &sc->sc_mtx, 0);
+ ate_get_mac(sc, eaddr);
+
if (mii_phy_probe(dev, &sc->miibus, ate_ifmedia_upd, ate_ifmedia_sts)) {
device_printf(dev, "Cannot find my PHY.\n");
err = ENXIO;
@@ -348,6 +351,11 @@
struct mii_data *mii;
int active;
+ /*
+ * The KB920x boot loader tests ETH_SR & ETH_SR_LINK and will ask
+ * the MII if there's a link if this bit is clear. Not sure if we
+ * should do the same thing ehre or not.
+ */
ATE_ASSERT_LOCKED(sc);
if (sc->miibus != NULL) {
mii = device_get_softc(sc->miibus);
@@ -410,6 +418,25 @@
callout_reset(&sc->tick_ch, hz, ate_tick, sc);
}
+static void
+ate_get_mac(struct ate_softc *sc, u_char *eaddr)
+{
+ uint32_t low, high;
+
+ /*
+ * The KB920x loaders will 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.
+ */
+ low = RD4(sc, ETH_SA1L);
+ high = RD4(sc, ETH_SA1H);
+ eaddr[0] = (high >> 8) & 0xff;
+ eaddr[1] = high & 0xff;
+ eaddr[2] = (low >> 24) & 0xff;
+ eaddr[3] = (low >> 16) & 0xff;
+ eaddr[4] = (low >> 8) & 0xff;
+ eaddr[5] = low & 0xff;
+}
static void
ate_intr(void *xsc)
@@ -452,11 +479,16 @@
WR4(sc, ETH_CTL, RD4(sc, ETH_CTL) | ETH_CTL_TE);
+ /*
+ * Boot loader fills in MAC address. If that's not the case, then
+ * we should set SA1L and SA1H here to the appropriate value. Note:
+ * the byte order is big endian, not little endian, so we have some
+ * swapping to do. Again, if we need it (which I don't think we do).
+ */
+
/* XXX need to setup multicast filters */
/* XXX need to setup rx buffers and assoc structures */
/* XXX need to enable appropriate interrupt masks */
- /* XXX need to program station address, or is that
- * XXX added by upper layers? */
/*
* Set 'running' flag, and clear output active flag
More information about the p4-projects
mailing list