summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorPatrick Wildt <patrick@cvs.openbsd.org>2021-11-05 15:18:25 +0000
committerPatrick Wildt <patrick@cvs.openbsd.org>2021-11-05 15:18:25 +0000
commitde5bde5cca9c9295d61f6f3c192ed974d780b38d (patch)
tree555ee3c890abc00a414d23248b4821df2d4ecfed /sys
parent925700305d0a674ecf31fbb39d7525cd7bc2a7f0 (diff)
Newer i.MX device trees store the skew information in the PHY's node, which
we can access through the phy-handle. If there's no reference, keep doing what we have been doing so far. ok kettenis@
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/fdt/if_fec.c68
1 files changed, 39 insertions, 29 deletions
diff --git a/sys/dev/fdt/if_fec.c b/sys/dev/fdt/if_fec.c
index 61d6e024739..693c75c2911 100644
--- a/sys/dev/fdt/if_fec.c
+++ b/sys/dev/fdt/if_fec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_fec.c,v 1.12 2021/10/24 17:52:26 mpi Exp $ */
+/* $OpenBSD: if_fec.c,v 1.13 2021/11/05 15:18:24 patrick Exp $ */
/*
* Copyright (c) 2012-2013,2019 Patrick Wildt <patrick@blueri.se>
*
@@ -510,20 +510,25 @@ fec_phy_init(struct fec_softc *sc, struct mii_softc *child)
uint32_t rxc, rxdv, txc, txen;
uint32_t rxd0, rxd1, rxd2, rxd3;
uint32_t txd0, txd1, txd2, txd3;
- uint32_t val;
-
- rxc = OF_getpropint(sc->sc_node, "rxc-skew-ps", 1400) / 200;
- rxdv = OF_getpropint(sc->sc_node, "rxdv-skew-ps", 1400) / 200;
- txc = OF_getpropint(sc->sc_node, "txc-skew-ps", 1400) / 200;
- txen = OF_getpropint(sc->sc_node, "txen-skew-ps", 1400) / 200;
- rxd0 = OF_getpropint(sc->sc_node, "rxd0-skew-ps", 1400) / 200;
- rxd1 = OF_getpropint(sc->sc_node, "rxd1-skew-ps", 1400) / 200;
- rxd2 = OF_getpropint(sc->sc_node, "rxd2-skew-ps", 1400) / 200;
- rxd3 = OF_getpropint(sc->sc_node, "rxd3-skew-ps", 1400) / 200;
- txd0 = OF_getpropint(sc->sc_node, "txd0-skew-ps", 1400) / 200;
- txd1 = OF_getpropint(sc->sc_node, "txd1-skew-ps", 1400) / 200;
- txd2 = OF_getpropint(sc->sc_node, "txd2-skew-ps", 1400) / 200;
- txd3 = OF_getpropint(sc->sc_node, "txd3-skew-ps", 1400) / 200;
+ uint32_t val, phy;
+ int node;
+
+ node = sc->sc_node;
+ phy = OF_getpropint(sc->sc_node, "phy-handle", 0);
+ if (phy)
+ node = OF_getnodebyphandle(phy);
+ rxc = OF_getpropint(node, "rxc-skew-ps", 1400) / 200;
+ rxdv = OF_getpropint(node, "rxdv-skew-ps", 1400) / 200;
+ txc = OF_getpropint(node, "txc-skew-ps", 1400) / 200;
+ txen = OF_getpropint(node, "txen-skew-ps", 1400) / 200;
+ rxd0 = OF_getpropint(node, "rxd0-skew-ps", 1400) / 200;
+ rxd1 = OF_getpropint(node, "rxd1-skew-ps", 1400) / 200;
+ rxd2 = OF_getpropint(node, "rxd2-skew-ps", 1400) / 200;
+ rxd3 = OF_getpropint(node, "rxd3-skew-ps", 1400) / 200;
+ txd0 = OF_getpropint(node, "txd0-skew-ps", 1400) / 200;
+ txd1 = OF_getpropint(node, "txd1-skew-ps", 1400) / 200;
+ txd2 = OF_getpropint(node, "txd2-skew-ps", 1400) / 200;
+ txd3 = OF_getpropint(node, "txd3-skew-ps", 1400) / 200;
val = ((rxc & 0xf) << 12) | ((rxdv & 0xf) << 8) |
((txc & 0xf) << 4) | ((txen & 0xf) << 0);
@@ -546,20 +551,25 @@ fec_phy_init(struct fec_softc *sc, struct mii_softc *child)
uint32_t rxc, rxdv, txc, txen;
uint32_t rxd0, rxd1, rxd2, rxd3;
uint32_t txd0, txd1, txd2, txd3;
- uint32_t val;
-
- rxc = OF_getpropint(sc->sc_node, "rxc-skew-ps", 900) / 60;
- rxdv = OF_getpropint(sc->sc_node, "rxdv-skew-ps", 420) / 60;
- txc = OF_getpropint(sc->sc_node, "txc-skew-ps", 900) / 60;
- txen = OF_getpropint(sc->sc_node, "txen-skew-ps", 420) / 60;
- rxd0 = OF_getpropint(sc->sc_node, "rxd0-skew-ps", 420) / 60;
- rxd1 = OF_getpropint(sc->sc_node, "rxd1-skew-ps", 420) / 60;
- rxd2 = OF_getpropint(sc->sc_node, "rxd2-skew-ps", 420) / 60;
- rxd3 = OF_getpropint(sc->sc_node, "rxd3-skew-ps", 420) / 60;
- txd0 = OF_getpropint(sc->sc_node, "txd0-skew-ps", 420) / 60;
- txd1 = OF_getpropint(sc->sc_node, "txd1-skew-ps", 420) / 60;
- txd2 = OF_getpropint(sc->sc_node, "txd2-skew-ps", 420) / 60;
- txd3 = OF_getpropint(sc->sc_node, "txd3-skew-ps", 420) / 60;
+ uint32_t val, phy;
+ int node;
+
+ node = sc->sc_node;
+ phy = OF_getpropint(sc->sc_node, "phy-handle", 0);
+ if (phy)
+ node = OF_getnodebyphandle(phy);
+ rxc = OF_getpropint(node, "rxc-skew-ps", 900) / 60;
+ rxdv = OF_getpropint(node, "rxdv-skew-ps", 420) / 60;
+ txc = OF_getpropint(node, "txc-skew-ps", 900) / 60;
+ txen = OF_getpropint(node, "txen-skew-ps", 420) / 60;
+ rxd0 = OF_getpropint(node, "rxd0-skew-ps", 420) / 60;
+ rxd1 = OF_getpropint(node, "rxd1-skew-ps", 420) / 60;
+ rxd2 = OF_getpropint(node, "rxd2-skew-ps", 420) / 60;
+ rxd3 = OF_getpropint(node, "rxd3-skew-ps", 420) / 60;
+ txd0 = OF_getpropint(node, "txd0-skew-ps", 420) / 60;
+ txd1 = OF_getpropint(node, "txd1-skew-ps", 420) / 60;
+ txd2 = OF_getpropint(node, "txd2-skew-ps", 420) / 60;
+ txd3 = OF_getpropint(node, "txd3-skew-ps", 420) / 60;
val = ((rxdv & 0xf) << 4) || ((txen & 0xf) << 0);
fec_miibus_writereg(dev, phy, 0x0d, 0x0002);