From c40bafe06bc8ceea3c51be2aa88f8aa9cdf3926d Mon Sep 17 00:00:00 2001 From: patrick Date: Wed, 28 Jul 2021 13:43:11 +0000 Subject: [PATCH] The clocks for the Rockchip Ethernet controller need to be enabled much earlier. So far we haven't noticed this, as we had the assumption that all clocks are enabled anyway. On the NanoPi R4S this does not seem to be the case, so we need to bring the clock enable code closer to the other bringup code. ok kettenis@ --- sys/dev/fdt/if_dwge.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/sys/dev/fdt/if_dwge.c b/sys/dev/fdt/if_dwge.c index e79411022ea..5695d85fd50 100644 --- a/sys/dev/fdt/if_dwge.c +++ b/sys/dev/fdt/if_dwge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_dwge.c,v 1.9 2021/05/07 19:03:01 kettenis Exp $ */ +/* $OpenBSD: if_dwge.c,v 1.10 2021/07/28 13:43:11 patrick Exp $ */ /* * Copyright (c) 2008, 2019 Mark Kettenis * Copyright (c) 2017 Patrick Wildt @@ -370,9 +370,19 @@ dwge_attach(struct device *parent, struct device *self, void *aux) pinctrl_byname(faa->fa_node, "default"); - /* Enable clock. */ + /* Enable clocks. */ + clock_set_assigned(faa->fa_node); clock_enable(faa->fa_node, "stmmaceth"); reset_deassert(faa->fa_node, "stmmaceth"); + if (OF_is_compatible(faa->fa_node, "rockchip,rk3288-gmac") || + OF_is_compatible(faa->fa_node, "rockchip,rk3308-mac") || + OF_is_compatible(faa->fa_node, "rockchip,rk3328-gmac") || + OF_is_compatible(faa->fa_node, "rockchip,rk3399-gmac")) { + clock_enable(faa->fa_node, "mac_clk_rx"); + clock_enable(faa->fa_node, "mac_clk_tx"); + clock_enable(faa->fa_node, "aclk_mac"); + clock_enable(faa->fa_node, "pclk_mac"); + } delay(5000); version = dwge_read(sc, GMAC_VERSION); @@ -429,13 +439,10 @@ dwge_attach(struct device *parent, struct device *self, void *aux) /* Do hardware specific initializations. */ if (OF_is_compatible(faa->fa_node, "allwinner,sun7i-a20-gmac")) dwge_setup_allwinner(sc); - else if (OF_is_compatible(faa->fa_node, "rockchip,rk3288-gmac")) - dwge_setup_rockchip(sc); - else if (OF_is_compatible(faa->fa_node, "rockchip,rk3308-mac")) - dwge_setup_rockchip(sc); - else if (OF_is_compatible(faa->fa_node, "rockchip,rk3328-gmac")) - dwge_setup_rockchip(sc); - else if (OF_is_compatible(faa->fa_node, "rockchip,rk3399-gmac")) + if (OF_is_compatible(faa->fa_node, "rockchip,rk3288-gmac") || + OF_is_compatible(faa->fa_node, "rockchip,rk3308-mac") || + OF_is_compatible(faa->fa_node, "rockchip,rk3328-gmac") || + OF_is_compatible(faa->fa_node, "rockchip,rk3399-gmac")) dwge_setup_rockchip(sc); if (OF_getpropbool(faa->fa_node, "snps,force_thresh_dma_mode")) @@ -1492,12 +1499,6 @@ dwge_setup_rockchip(struct dwge_softc *sc) if (rm == NULL) return; - clock_set_assigned(sc->sc_node); - clock_enable(sc->sc_node, "mac_clk_rx"); - clock_enable(sc->sc_node, "mac_clk_tx"); - clock_enable(sc->sc_node, "aclk_mac"); - clock_enable(sc->sc_node, "pclk_mac"); - tx_delay = OF_getpropint(sc->sc_node, "tx_delay", 0x30); rx_delay = OF_getpropint(sc->sc_node, "rx_delay", 0x10); -- 2.20.1