diff options
author | Brad Smith <brad@cvs.openbsd.org> | 2005-10-17 03:03:25 +0000 |
---|---|---|
committer | Brad Smith <brad@cvs.openbsd.org> | 2005-10-17 03:03:25 +0000 |
commit | a4bc1708742c2b2fc8818297716852fb3f2e1564 (patch) | |
tree | 19e8aea8e5b7c3a4a243476aaafcba5a108fe425 | |
parent | 86b78d94d28490f29f3a3d44550cdc00fe951d8c (diff) |
Start using the unused sc_variant to identify the GMAC vendor and chipset
model to the MI part of the driver. On Apple systems only attach the PHY to
location 0, unless using a K2 GMAC, then use location 1.
Tested by drahn@ and kettenis@
-rw-r--r-- | sys/dev/ic/gem.c | 19 | ||||
-rw-r--r-- | sys/dev/ic/gemvar.h | 17 | ||||
-rw-r--r-- | sys/dev/pci/if_gem_pci.c | 17 |
3 files changed, 45 insertions, 8 deletions
diff --git a/sys/dev/ic/gem.c b/sys/dev/ic/gem.c index d168a4b21c6..de52c03abb5 100644 --- a/sys/dev/ic/gem.c +++ b/sys/dev/ic/gem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gem.c,v 1.45 2005/10/11 23:58:36 brad Exp $ */ +/* $OpenBSD: gem.c,v 1.46 2005/10/17 03:03:24 brad Exp $ */ /* $NetBSD: gem.c,v 1.1 2001/09/16 00:11:43 eeh Exp $ */ /* @@ -240,8 +240,12 @@ gem_config(sc) gem_mifinit(sc); - mii_attach(&sc->sc_dev, mii, 0xffffffff, - MII_PHY_ANY, MII_OFFSET_ANY, 0); + if (sc->sc_tcvr == -1) + mii_attach(&sc->sc_dev, mii, 0xffffffff, MII_PHY_ANY, + MII_OFFSET_ANY, 0); + else + mii_attach(&sc->sc_dev, mii, 0xffffffff, sc->sc_tcvr, + MII_OFFSET_ANY, 0); child = LIST_FIRST(&mii->mii_phys); if (child == NULL) { @@ -1152,6 +1156,15 @@ gem_mifinit(sc) bus_space_tag_t t = sc->sc_bustag; bus_space_handle_t mif = sc->sc_h; + if (GEM_IS_APPLE(sc)) { + if (sc->sc_variant == GEM_APPLE_K2_GMAC) + sc->sc_tcvr = 1; + else + sc->sc_tcvr = 0; + } else { + sc->sc_tcvr = -1; + } + /* Configure the MIF in frame mode */ sc->sc_mif_config = bus_space_read_4(t, mif, GEM_MIF_CONFIG); sc->sc_mif_config &= ~GEM_MIF_CONFIG_BB_ENA; diff --git a/sys/dev/ic/gemvar.h b/sys/dev/ic/gemvar.h index 2c9c862778f..f761f87e60c 100644 --- a/sys/dev/ic/gemvar.h +++ b/sys/dev/ic/gemvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: gemvar.h,v 1.10 2005/08/01 05:45:03 brad Exp $ */ +/* $OpenBSD: gemvar.h,v 1.11 2005/10/17 03:03:24 brad Exp $ */ /* $NetBSD: gemvar.h,v 1.1 2001/09/16 00:11:43 eeh Exp $ */ /* @@ -142,12 +142,18 @@ struct gem_softc { int sc_phys[2]; /* MII instance -> PHY map */ int sc_mif_config; /* Selected MII reg setting */ + u_int sc_tcvr; int sc_pci; /* XXXXX -- PCI buses are LE. */ u_int sc_variant; /* which GEM are we dealing with? */ -#define GEM_UNKNOWN 0 /* don't know */ -#define GEM_SUN_GEM 1 /* Sun GEM variant */ -#define GEM_APPLE_GMAC 2 /* Apple GMAC variant */ +#define GEM_UNKNOWN 0 /* don't know */ +#define GEM_SUN_GEM 1 /* Sun GEM variant */ +#define GEM_SUN_ERI 2 /* Sun ERI variant */ +#define GEM_APPLE_K2_GMAC 3 /* Apple K2 GMAC variant */ +#define GEM_APPLE_PANGEA_GMAC 4 /* Apple Pangea GMAC variant */ +#define GEM_APPLE_SHASTA_GMAC 5 /* Apple Shasta GMAC variant */ +#define GEM_APPLE_UNINORTHGMAC 6 /* Apple UniNorth GMAC variant */ +#define GEM_APPLE_UNINORTH2GMAC 7 /* Apple UniNorth 2 GMAC variant */ u_int sc_flags; /* */ #define GEM_GIGABIT 0x0001 /* has a gigabit PHY */ @@ -271,6 +277,9 @@ do { \ GEM_CDRXSYNC((sc), (x), BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE); \ } while (0) +#define GEM_IS_APPLE(sc) \ + ((sc)->sc_variant >= GEM_APPLE_K2_GMAC && (sc)->sc_variant <= GEM_APPLE_UNINORTH2GMAC) + #ifdef _KERNEL void gem_attach(struct gem_softc *, const u_int8_t *); int gem_activate(struct device *, enum devact); diff --git a/sys/dev/pci/if_gem_pci.c b/sys/dev/pci/if_gem_pci.c index 3ecd8e33c88..dc7010e1f1c 100644 --- a/sys/dev/pci/if_gem_pci.c +++ b/sys/dev/pci/if_gem_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_gem_pci.c,v 1.19 2005/10/01 19:08:57 brad Exp $ */ +/* $OpenBSD: if_gem_pci.c,v 1.20 2005/10/17 03:03:24 brad Exp $ */ /* $NetBSD: if_gem_pci.c,v 1.1 2001/09/16 00:11:42 eeh Exp $ */ /* @@ -141,6 +141,21 @@ gem_attach_pci(parent, self, aux) sc->sc_pci = 1; /* XXXXX should all be done in bus_dma. */ + if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_SUN_GEMNETWORK) + sc->sc_variant = GEM_SUN_GEM; + else if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_SUN_ERINETWORK) + sc->sc_variant = GEM_SUN_ERI; + else if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_APPLE_K2_GMAC) + sc->sc_variant = GEM_APPLE_K2_GMAC; + else if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_APPLE_PANGEA_GMAC) + sc->sc_variant = GEM_APPLE_PANGEA_GMAC; + else if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_APPLE_SHASTA_GMAC) + sc->sc_variant = GEM_APPLE_SHASTA_GMAC; + else if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_APPLE_UNINORTHGMAC) + sc->sc_variant = GEM_APPLE_UNINORTHGMAC; + else if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_APPLE_UNINORTH2GMAC) + sc->sc_variant = GEM_APPLE_UNINORTH2GMAC; + #define PCI_GEM_BASEADDR 0x10 if (pci_mapreg_map(pa, PCI_GEM_BASEADDR, type, 0, &gsc->gsc_memt, &gsc->gsc_memh, NULL, NULL, 0) != 0) |