summaryrefslogtreecommitdiff
path: root/sys/dev/fdt/if_dwqe_fdt.c
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2023-04-22 05:01:45 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2023-04-22 05:01:45 +0000
commitfecdff9b3d213972c88296b60961db77b2d3a229 (patch)
tree3a3969921c2b25fb553b3ebfb58aacfcda9709a6 /sys/dev/fdt/if_dwqe_fdt.c
parent3383e0b7ca66cbd8b3c49dd73d6f43fd683e437c (diff)
use if_baudrate and if_link_state for mac config, not mii media values
the phy code sets if_baudrate and if_link_state, so the information needed to config the mac on the chip is there anyway. it also has the benefit that the driver doesnt have to understand every type of media (eg, 1000baseTX vs 1000baseSX) because they're both the same speed and that's what matters when configuring the chip and the clocks etc. this is a step toward being able to use a fixed-link node in the device tree instead of a phy, as is found on the banana pi bpi-r2 pro on the gmac connected to a switch chip.
Diffstat (limited to 'sys/dev/fdt/if_dwqe_fdt.c')
-rw-r--r--sys/dev/fdt/if_dwqe_fdt.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/sys/dev/fdt/if_dwqe_fdt.c b/sys/dev/fdt/if_dwqe_fdt.c
index 5d441600db3..0da10556b7d 100644
--- a/sys/dev/fdt/if_dwqe_fdt.c
+++ b/sys/dev/fdt/if_dwqe_fdt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_dwqe_fdt.c,v 1.9 2023/04/07 22:55:26 dlg Exp $ */
+/* $OpenBSD: if_dwqe_fdt.c,v 1.10 2023/04/22 05:01:44 dlg Exp $ */
/*
* Copyright (c) 2008, 2019 Mark Kettenis <kettenis@openbsd.org>
* Copyright (c) 2017, 2022 Patrick Wildt <patrick@blueri.se>
@@ -349,17 +349,18 @@ void
dwqe_mii_statchg_rk3568_task(void *arg)
{
struct dwqe_softc *sc = arg;
+ struct ifnet *ifp = &sc->sc_ac.ac_if;
dwqe_mii_statchg(&sc->sc_dev);
- switch (IFM_SUBTYPE(sc->sc_mii.mii_media_active)) {
- case IFM_10_T:
+ switch (ifp->if_baudrate) {
+ case IF_Mbps(10):
clock_set_frequency(sc->sc_node, "clk_mac_speed", 2500000);
break;
- case IFM_100_TX:
+ case IF_Mbps(100):
clock_set_frequency(sc->sc_node, "clk_mac_speed", 25000000);
break;
- case IFM_1000_T:
+ case IF_Mbps(1000):
clock_set_frequency(sc->sc_node, "clk_mac_speed", 125000000);
break;
}
@@ -377,6 +378,7 @@ void
dwqe_mii_statchg_rk3588(struct device *self)
{
struct dwqe_softc *sc = (void *)self;
+ struct ifnet *ifp = &sc->sc_ac.ac_if;
struct regmap *rm;
uint32_t grf;
uint32_t gmac_clk_sel = 0;
@@ -388,14 +390,14 @@ dwqe_mii_statchg_rk3588(struct device *self)
if (rm == NULL)
return;
- switch (IFM_SUBTYPE(sc->sc_mii.mii_media_active)) {
- case IFM_10_T:
+ switch (ifp->if_baudrate) {
+ case IF_Mbps(10):
gmac_clk_sel = sc->sc_clk_sel_2_5;
break;
- case IFM_100_TX:
+ case IF_Mbps(100):
gmac_clk_sel = sc->sc_clk_sel_25;
break;
- case IFM_1000_T:
+ case IF_Mbps(1000):
gmac_clk_sel = sc->sc_clk_sel_125;
break;
}