Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm/sunxi fetch PHY id from FDT. same as sunxi_ema...



details:   https://anonhg.NetBSD.org/src/rev/3d7dfbefa04a
branches:  trunk
changeset: 460725:3d7dfbefa04a
user:      bad <bad%NetBSD.org@localhost>
date:      Fri Nov 01 13:30:02 2019 +0000

description:
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

diffstat:

 sys/arch/arm/sunxi/sunxi_gmac.c |  25 ++++++++++++++++++++++---
 1 files changed, 22 insertions(+), 3 deletions(-)

diffs (53 lines):

diff -r afdfe1bdf22a -r 3d7dfbefa04a sys/arch/arm/sunxi/sunxi_gmac.c
--- a/sys/arch/arm/sunxi/sunxi_gmac.c   Fri Nov 01 13:22:08 2019 +0000
+++ b/sys/arch/arm/sunxi/sunxi_gmac.c   Fri Nov 01 13:30:02 2019 +0000
@@ -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 <jmcneill%invisible.ca@localhost>
@@ -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 @@
 }
 
 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 @@
        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),



Home | Main Index | Thread Index | Old Index