From: kettenis Date: Mon, 15 Aug 2016 18:31:28 +0000 (+0000) Subject: For some reason the RTL8211E PHY on the Banana Pi responds to both address 0 X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=e1ded2579f7776f7887f8c1e977d1901a3201e40;p=openbsd For some reason the RTL8211E PHY on the Banana Pi responds to both address 0 and 1. As a result rgephy(4) attaches twice. Prevent this from happening by passing the PHY address, which is part of the device tree, down from the bus-specific glue to the generic driver code. --- diff --git a/sys/arch/armv7/sunxi/if_dwge_fdt.c b/sys/arch/armv7/sunxi/if_dwge_fdt.c index 4b8c41f35b9..3c8aaa339a1 100644 --- a/sys/arch/armv7/sunxi/if_dwge_fdt.c +++ b/sys/arch/armv7/sunxi/if_dwge_fdt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_dwge_fdt.c,v 1.1 2016/08/13 22:07:01 kettenis Exp $ */ +/* $OpenBSD: if_dwge_fdt.c,v 1.2 2016/08/15 18:31:28 kettenis Exp $ */ /* * Copyright (c) 2016 Patrick Wildt * Copyright (c) 2016 Mark Kettenis @@ -81,7 +81,10 @@ dwge_fdt_attach(struct device *parent, struct device *self, void *aux) struct dwc_gmac_softc *sc = &fsc->sc_core; struct fdt_attach_args *faa = aux; char phy_mode[8]; + int phyloc = MII_PHY_ANY; uint32_t phy_supply; + uint32_t phy; + int node; int clock; if (faa->fa_nreg < 1) @@ -105,6 +108,12 @@ dwge_fdt_attach(struct device *parent, struct device *self, void *aux) else clock = CCMU_GMAC_RGMII; + /* lookup PHY */ + phy = OF_getpropint(faa->fa_node, "phy", 0); + node = OF_getnodebyphandle(phy); + if (node) + phyloc = OF_getpropint(node, "reg", phyloc); + /* enable clock */ sxiccmu_enablemodule(clock); delay(5000); @@ -121,7 +130,7 @@ dwge_fdt_attach(struct device *parent, struct device *self, void *aux) goto clrpwr; } - dwc_gmac_attach(sc, GMAC_MII_CLK_150_250M_DIV102); + dwc_gmac_attach(sc, GMAC_MII_CLK_150_250M_DIV102, phyloc); return; clrpwr: diff --git a/sys/dev/ic/dwc_gmac.c b/sys/dev/ic/dwc_gmac.c index 8d66ec7c669..a52f831bfa3 100644 --- a/sys/dev/ic/dwc_gmac.c +++ b/sys/dev/ic/dwc_gmac.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dwc_gmac.c,v 1.1 2016/08/13 20:35:57 kettenis Exp $ */ +/* $OpenBSD: dwc_gmac.c,v 1.2 2016/08/15 18:31:28 kettenis Exp $ */ /* $NetBSD: dwc_gmac.c,v 1.34 2015/08/21 20:12:29 jmcneill Exp $ */ /*- @@ -141,7 +141,7 @@ struct cfdriver dwge_cd = { }; void -dwc_gmac_attach(struct dwc_gmac_softc *sc, uint32_t mii_clk) +dwc_gmac_attach(struct dwc_gmac_softc *sc, uint32_t mii_clk, int phyloc) { uint8_t enaddr[ETHER_ADDR_LEN]; struct mii_data * const mii = &sc->sc_mii; @@ -228,7 +228,7 @@ dwc_gmac_attach(struct dwc_gmac_softc *sc, uint32_t mii_clk) ifmedia_init(&mii->mii_media, 0, dwc_gmac_ifmedia_upd, dwc_gmac_ifmedia_sts); - mii_attach((void *)sc, mii, 0xffffffff, MII_PHY_ANY, MII_OFFSET_ANY, + mii_attach((void *)sc, mii, 0xffffffff, phyloc, MII_OFFSET_ANY, MIIF_DOPAUSE); if (LIST_EMPTY(&mii->mii_phys)) { diff --git a/sys/dev/ic/dwc_gmac_var.h b/sys/dev/ic/dwc_gmac_var.h index e2b2d2887ca..87b63a41a38 100644 --- a/sys/dev/ic/dwc_gmac_var.h +++ b/sys/dev/ic/dwc_gmac_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dwc_gmac_var.h,v 1.1 2016/08/13 20:35:57 kettenis Exp $ */ +/* $OpenBSD: dwc_gmac_var.h,v 1.2 2016/08/15 18:31:28 kettenis Exp $ */ /* $NetBSD: dwc_gmac_var.h,v 1.6 2014/11/22 18:31:03 jmcneill Exp $ */ /*- @@ -91,5 +91,5 @@ struct dwc_gmac_softc { uint16_t sc_mii_clk; }; -void dwc_gmac_attach(struct dwc_gmac_softc*, uint32_t /*mii_clk*/); +void dwc_gmac_attach(struct dwc_gmac_softc*, uint32_t, int); int dwc_gmac_intr(struct dwc_gmac_softc*);