Module Name: src
Committed By: bad
Date: Fri Nov 1 13:30:02 UTC 2019
Modified Files:
src/sys/arch/arm/sunxi: sunxi_gmac.c
Log Message:
fetch PHY id from FDT. same as sunxi_emac.c.
prevents PHY 0 of RTL8211E from wrongly attaching on e.g. Bananpi M1.
requested by jmcneill@, patch by martin@.
XXX pullup-9
To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sunxi/sunxi_gmac.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/arm/sunxi/sunxi_gmac.c
diff -u src/sys/arch/arm/sunxi/sunxi_gmac.c:1.6 src/sys/arch/arm/sunxi/sunxi_gmac.c:1.7
--- src/sys/arch/arm/sunxi/sunxi_gmac.c:1.6 Sun Jul 21 08:24:32 2019
+++ src/sys/arch/arm/sunxi/sunxi_gmac.c Fri Nov 1 13:30:02 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_gmac.c,v 1.6 2019/07/21 08:24:32 mrg Exp $ */
+/* $NetBSD: sunxi_gmac.c,v 1.7 2019/11/01 13:30:02 bad Exp $ */
/*-
* Copyright (c) 2017 Jared McNeill <[email protected]>
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sunxi_gmac.c,v 1.6 2019/07/21 08:24:32 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_gmac.c,v 1.7 2019/11/01 13:30:02 bad Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -94,6 +94,24 @@ sunxi_gmac_intr(void *arg)
}
static int
+sunxi_gmac_get_phyid(int phandle)
+{
+ bus_addr_t addr;
+ int phy_phandle;
+
+ phy_phandle = fdtbus_get_phandle(phandle, "phy");
+ if (phy_phandle == -1)
+ phy_phandle = fdtbus_get_phandle(phandle, "phy-handle");
+ if (phy_phandle == -1)
+ return MII_PHY_ANY;
+
+ if (fdtbus_get_reg(phy_phandle, 0, &addr, NULL) != 0)
+ return MII_PHY_ANY;
+
+ return (int)addr;
+}
+
+static int
sunxi_gmac_match(device_t parent, cfdata_t cf, void *aux)
{
struct fdt_attach_args * const faa = aux;
@@ -192,7 +210,8 @@ sunxi_gmac_attach(device_t parent, devic
if (sunxi_gmac_reset(phandle) != 0)
aprint_error_dev(self, "PHY reset failed\n");
- dwc_gmac_attach(sc, MII_PHY_ANY, GMAC_MII_CLK_150_250M_DIV102);
+ dwc_gmac_attach(sc, sunxi_gmac_get_phyid(phandle),
+ GMAC_MII_CLK_150_250M_DIV102);
}
CFATTACH_DECL_NEW(sunxi_gmac, sizeof(struct dwc_gmac_softc),