From a8f7c3a4b2055bff9edb64b347044fa426de2851 Mon Sep 17 00:00:00 2001
From: br
Date: Mon, 29 Jul 2019 14:58:29 +0000
Subject: [PATCH] Find the correct node of PHY chip using "phy-handle" property
of ethernet MAC node.
This fixes operation on Terasic DE10-Pro (Intel Stratix 10 GX/SX
FPGA Development Kit).
Sponsored by: DARPA, AFRL
---
sys/dev/mii/micphy.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/sys/dev/mii/micphy.c b/sys/dev/mii/micphy.c
index 4f829c8b04f8..9ebb72f5b413 100644
--- a/sys/dev/mii/micphy.c
+++ b/sys/dev/mii/micphy.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2014 Ruslan Bukin
+ * Copyright (c) 2014,2019 Ruslan Bukin
* All rights reserved.
*
* This software was developed by SRI International and the University of
@@ -32,7 +32,7 @@
__FBSDID("$FreeBSD$");
/*
- * Micrel KSZ9021 Gigabit Ethernet Transceiver
+ * Micrel KSZ8081/KSZ9021/KSZ9031 Gigabit Ethernet Transceiver
*/
#include
@@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$");
#include
#include
#include
+#include
#define MII_KSZPHY_EXTREG 0x0b
#define KSZPHY_EXTREG_WRITE (1 << 15)
@@ -251,6 +252,7 @@ micphy_probe(device_t dev)
static int
micphy_attach(device_t dev)
{
+ mii_fdt_phy_config_t *cfg;
struct mii_softc *sc;
phandle_t node;
device_t miibus;
@@ -271,10 +273,12 @@ micphy_attach(device_t dev)
if ((node = ofw_bus_get_node(parent)) == -1)
return (ENXIO);
+ cfg = mii_fdt_get_config(dev);
+
if (sc->mii_mpd_model == MII_MODEL_MICREL_KSZ9031)
- ksz9031_load_values(sc, node);
+ ksz9031_load_values(sc, cfg->phynode);
else
- ksz9021_load_values(sc, node);
+ ksz9021_load_values(sc, cfg->phynode);
return (0);
}