-/* $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 <patrick@blueri.se>
* Copyright (c) 2016 Mark Kettenis <kettenis@openbsd.org>
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)
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);
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:
-/* $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 $ */
/*-
};
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;
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)) {
-/* $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 $ */
/*-
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*);