Source-Changes-HG archive

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

[src/netbsd-9]: src/sys/arch/arm/sunxi Pull up following revision(s) (request...



details:   https://anonhg.NetBSD.org/src/rev/fc52a9e0a55e
branches:  netbsd-9
changeset: 843455:fc52a9e0a55e
user:      martin <martin%NetBSD.org@localhost>
date:      Fri Nov 01 18:14:45 2019 +0000

description:
Pull up following revision(s) (requested by bad in ticket #389):

        sys/arch/arm/sunxi/sunxi_gmac.c: revision 1.7

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 6a0624ecff9c -r fc52a9e0a55e sys/arch/arm/sunxi/sunxi_gmac.c
--- a/sys/arch/arm/sunxi/sunxi_gmac.c   Fri Nov 01 18:12:26 2019 +0000
+++ b/sys/arch/arm/sunxi/sunxi_gmac.c   Fri Nov 01 18:14:45 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.6.2.1 2019/11/01 18:14:45 martin 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.6.2.1 2019/11/01 18:14:45 martin 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