Module Name:    src
Committed By:   jmcneill
Date:           Fri Dec  1 17:47:51 UTC 2017

Modified Files:
        src/sys/arch/arm/sunxi: sunxi_emac.c

Log Message:
More fixes for new emac bindings.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/sunxi/sunxi_emac.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_emac.c
diff -u src/sys/arch/arm/sunxi/sunxi_emac.c:1.10 src/sys/arch/arm/sunxi/sunxi_emac.c:1.11
--- src/sys/arch/arm/sunxi/sunxi_emac.c:1.10	Thu Nov 30 21:36:11 2017
+++ src/sys/arch/arm/sunxi/sunxi_emac.c	Fri Dec  1 17:47:51 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_emac.c,v 1.10 2017/11/30 21:36:11 jmcneill Exp $ */
+/* $NetBSD: sunxi_emac.c,v 1.11 2017/12/01 17:47:51 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2016-2017 Jared McNeill <jmcne...@invisible.ca>
@@ -33,7 +33,7 @@
 #include "opt_net_mpsafe.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sunxi_emac.c,v 1.10 2017/11/30 21:36:11 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_emac.c,v 1.11 2017/12/01 17:47:51 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -1310,15 +1310,27 @@ sunxi_emac_get_resources(struct sunxi_em
 	if (bus_space_map(sc->bst, addr, size, 0, &sc->bsh[_RES_SYSCON]) != 0)
 		return ENXIO;
 
-	/* Get clocks and resets. "ahb" is required, "ephy" is optional. */
-
-	if ((sc->clk_ahb = fdtbus_clock_get(phandle, "ahb")) == NULL)
+	/* The "ahb"/"stmmaceth" clock and reset is required */
+	if ((sc->clk_ahb = fdtbus_clock_get(phandle, "ahb")) == NULL &&
+	    (sc->clk_ahb = fdtbus_clock_get(phandle, "stmmaceth")) == NULL)
 		return ENXIO;
-	sc->clk_ephy = fdtbus_clock_get(phandle, "ephy");
-
-	if ((sc->rst_ahb = fdtbus_reset_get(phandle, "ahb")) == NULL)
+	if ((sc->rst_ahb = fdtbus_reset_get(phandle, "ahb")) == NULL &&
+	    (sc->rst_ahb = fdtbus_reset_get(phandle, "stmmaceth")) == NULL)
 		return ENXIO;
+
+	/* Internal PHY clock and reset are optional properties. */
+	sc->clk_ephy = fdtbus_clock_get(phandle, "ephy");
+	if (sc->clk_ephy == NULL) {
+		int phy_phandle = fdtbus_get_phandle(phandle, "phy-handle");
+		if (phy_phandle != -1)
+			sc->clk_ephy = fdtbus_clock_get_index(phy_phandle, 0);
+	}
 	sc->rst_ephy = fdtbus_reset_get(phandle, "ephy");
+	if (sc->rst_ephy == NULL) {
+		int phy_phandle = fdtbus_get_phandle(phandle, "phy-phandle");
+		if (phy_phandle != -1)
+			sc->rst_ephy = fdtbus_reset_get_index(phy_phandle, 0);
+	}
 
 	/* Regulator is optional */
 	sc->reg_phy = fdtbus_regulator_acquire(phandle, "phy-supply");
@@ -1334,8 +1346,11 @@ static int
 sunxi_emac_get_phyid(struct sunxi_emac_softc *sc)
 {
 	bus_addr_t addr;
+	int phy_phandle;
 
-	const int phy_phandle = fdtbus_get_phandle(sc->phandle, "phy");
+	phy_phandle = fdtbus_get_phandle(sc->phandle, "phy");
+	if (phy_phandle == -1)
+		phy_phandle = fdtbus_get_phandle(sc->phandle, "phy-handle");
 	if (phy_phandle == -1)
 		return MII_PHY_ANY;
 

Reply via email to