git: bb2e1d6c69d8 - stable/13 - dwc: Use mii_fdt function

Emmanuel Vadot manu at FreeBSD.org
Thu Jul 22 16:51:10 UTC 2021


The branch stable/13 has been updated by manu:

URL: https://cgit.FreeBSD.org/src/commit/?id=bb2e1d6c69d85d19eca76f61dace9fa57b941a25

commit bb2e1d6c69d85d19eca76f61dace9fa57b941a25
Author:     Emmanuel Vadot <manu at FreeBSD.org>
AuthorDate: 2021-04-11 19:34:57 +0000
Commit:     Emmanuel Vadot <manu at FreeBSD.org>
CommitDate: 2021-07-22 16:48:11 +0000

    dwc: Use mii_fdt function
    
    Use the helper function to get phy mode and configure dwc accordingly.
    
    Reviewed by:    ian
    
    (cherry picked from commit f77d8d10115b0863cc3dfd6e1746c02847d6569d)
---
 sys/dev/dwc/if_dwc.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/sys/dev/dwc/if_dwc.c b/sys/dev/dwc/if_dwc.c
index 776d0d0dc392..429e250f48e8 100644
--- a/sys/dev/dwc/if_dwc.c
+++ b/sys/dev/dwc/if_dwc.c
@@ -69,6 +69,7 @@ __FBSDID("$FreeBSD$");
 #include <dev/mii/miivar.h>
 #include <dev/ofw/ofw_bus.h>
 #include <dev/ofw/ofw_bus_subr.h>
+#include <dev/mii/mii_fdt.h>
 
 #ifdef EXT_RESOURCES
 #include <dev/extres/clk/clk.h>
@@ -1559,7 +1560,6 @@ dwc_attach(device_t dev)
 	struct ifnet *ifp;
 	int error, i;
 	uint32_t reg;
-	char *phy_mode;
 	phandle_t node;
 	uint32_t txpbl, rxpbl, pbl;
 	bool nopblx8 = false;
@@ -1574,12 +1574,19 @@ dwc_attach(device_t dev)
 	sc->mactype = IF_DWC_MAC_TYPE(dev);
 
 	node = ofw_bus_get_node(dev);
-	if (OF_getprop_alloc(node, "phy-mode", (void **)&phy_mode)) {
-		if (strcmp(phy_mode, "rgmii") == 0)
+	switch (mii_fdt_get_contype(node)) {
+	case MII_CONTYPE_RGMII:
+	case MII_CONTYPE_RGMII_ID:
+	case MII_CONTYPE_RGMII_RXID:
+	case MII_CONTYPE_RGMII_TXID:
 			sc->phy_mode = PHY_MODE_RGMII;
-		if (strcmp(phy_mode, "rmii") == 0)
+			break;
+	case MII_CONTYPE_RMII:
 			sc->phy_mode = PHY_MODE_RMII;
-		OF_prop_free(phy_mode);
+			break;
+	default:
+		device_printf(dev, "Unsupported MII type\n");
+		return (ENXIO);
 	}
 
 	if (OF_getencprop(node, "snps,pbl", &pbl, sizeof(uint32_t)) <= 0)


More information about the dev-commits-src-branches mailing list