From bc9d315400b69b00b916b92d589cbec9b7392b55 Mon Sep 17 00:00:00 2001 From: Jonathan Gray Date: Thu, 12 Sep 2019 03:17:14 +0000 Subject: Prepare for the emac/gmac "phy" property being renamed to "phy-handle" in a large number of allwinner device trees in arm-soc/for-next which is expected to be merged into linux 5.4-rc1. ok kettenis@ --- sys/arch/armv7/sunxi/sxie.c | 15 +++++++++------ sys/dev/fdt/if_dwge_fdt.c | 4 +++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/sys/arch/armv7/sunxi/sxie.c b/sys/arch/armv7/sunxi/sxie.c index 249cd2a2478..c1c4259a783 100644 --- a/sys/arch/armv7/sunxi/sxie.c +++ b/sys/arch/armv7/sunxi/sxie.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sxie.c,v 1.27 2017/12/10 04:21:55 jsg Exp $ */ +/* $OpenBSD: sxie.c,v 1.28 2019/09/12 03:17:12 jsg Exp $ */ /* * Copyright (c) 2012-2013 Patrick Wildt * Copyright (c) 2013 Artturi Alm @@ -213,7 +213,7 @@ sxie_attach(struct device *parent, struct device *self, void *aux) struct fdt_attach_args *faa = aux; struct mii_data *mii; struct ifnet *ifp; - int node, phy_supply, phy = MII_PHY_ANY; + int phy, node, phy_supply, phyloc = MII_PHY_ANY; int s; if (faa->fa_nreg < 1) @@ -233,16 +233,19 @@ sxie_attach(struct device *parent, struct device *self, void *aux) clock_enable_all(faa->fa_node); /* Lookup PHY. */ - node = OF_getnodebyphandle(OF_getpropint(faa->fa_node, "phy", 0)); + phy = OF_getpropint(faa->fa_node, "phy", 0); + if (phy == 0) + phy = OF_getpropint(faa->fa_node, "phy-handle", 0); + node = OF_getnodebyphandle(phy); if (node) { - phy = OF_getpropint(node, "reg", MII_PHY_ANY); + phyloc = OF_getpropint(node, "reg", MII_PHY_ANY); /* Power up PHY. */ phy_supply = OF_getpropint(OF_parent(node), "phy-supply", 0); if (phy_supply) regulator_enable(phy_supply); } - sc->sc_phyno = phy == MII_PHY_ANY ? 1 : phy; + sc->sc_phyno = phyloc == MII_PHY_ANY ? 1 : phyloc; sxie_socware_init(sc); sc->txf_inuse = 0; @@ -274,7 +277,7 @@ sxie_attach(struct device *parent, struct device *self, void *aux) mii->mii_statchg = sxie_miibus_statchg; ifmedia_init(&mii->mii_media, 0, sxie_ifm_change, sxie_ifm_status); - mii_attach(self, mii, 0xffffffff, phy, MII_OFFSET_ANY, 0); + mii_attach(self, mii, 0xffffffff, phyloc, MII_OFFSET_ANY, 0); if (LIST_FIRST(&mii->mii_phys) == NULL) { ifmedia_add(&mii->mii_media, IFM_ETHER | IFM_NONE, 0, NULL); diff --git a/sys/dev/fdt/if_dwge_fdt.c b/sys/dev/fdt/if_dwge_fdt.c index 9bd97597520..dd9a8617e07 100644 --- a/sys/dev/fdt/if_dwge_fdt.c +++ b/sys/dev/fdt/if_dwge_fdt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_dwge_fdt.c,v 1.10 2019/08/30 19:35:55 kettenis Exp $ */ +/* $OpenBSD: if_dwge_fdt.c,v 1.11 2019/09/12 03:17:13 jsg Exp $ */ /* * Copyright (c) 2016 Patrick Wildt * Copyright (c) 2016 Mark Kettenis @@ -113,6 +113,8 @@ dwge_fdt_attach(struct device *parent, struct device *self, void *aux) /* Lookup PHY. */ phy = OF_getpropint(faa->fa_node, "phy", 0); + if (phy == 0) + phy = OF_getpropint(faa->fa_node, "phy-handle", 0); node = OF_getnodebyphandle(phy); if (node) phyloc = OF_getpropint(node, "reg", phyloc); -- cgit v1.2.3