git: 06c30b2c7618 - main - mvneta: Use clkgen API on armv7

From: Kornel Dulęba <kd_at_FreeBSD.org>
Date: Wed, 07 Sep 2022 07:59:43 UTC
The branch main has been updated by kd:

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

commit 06c30b2c7618e2963ff0954d61892915ac1640fa
Author:     Albert Jakieła <aja@semihalf.com>
AuthorDate: 2022-09-06 08:33:34 +0000
Commit:     Kornel Dulęba <kd@FreeBSD.org>
CommitDate: 2022-09-07 07:44:59 +0000

    mvneta: Use clkgen API on armv7
    
    With addition of clkgen devices to the Armada38x we no longer
    need to rely on get_tclk() to get the device frequency.
    Leave it as a fallback, just in case.
    
    Reviewed by:    manu
    Obtained from:  Semihalf
    Differential Revision: https://reviews.freebsd.org/D36465
---
 sys/dev/neta/if_mvneta.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/sys/dev/neta/if_mvneta.c b/sys/dev/neta/if_mvneta.c
index eb6c9eec74ce..3e3b07259d4e 100644
--- a/sys/dev/neta/if_mvneta.c
+++ b/sys/dev/neta/if_mvneta.c
@@ -65,9 +65,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/rman.h>
 #include <machine/resource.h>
 
-#if defined(__aarch64__)
 #include <dev/extres/clk/clk.h>
-#endif
 
 #include <dev/mii/mii.h>
 #include <dev/mii/miivar.h>
@@ -532,9 +530,8 @@ mvneta_attach(device_t self)
 #if !defined(__aarch64__)
 	uint32_t reg;
 #endif
-#if defined(__aarch64__)
 	clk_t clk;
-#endif
+
 	sc = device_get_softc(self);
 	sc->dev = self;
 
@@ -556,14 +553,19 @@ mvneta_attach(device_t self)
 	MVNETA_WRITE(sc, MVNETA_PRXINIT, 0x00000001);
 	MVNETA_WRITE(sc, MVNETA_PTXINIT, 0x00000001);
 
-#if defined(__aarch64__)
 	error = clk_get_by_ofw_index(sc->dev, ofw_bus_get_node(sc->dev), 0,
 	    &clk);
 	if (error != 0) {
+#if defined(__aarch64__)
 		device_printf(sc->dev,
 			"Cannot get clock, using default frequency: %d\n",
 			A3700_TCLK_250MHZ);
 		sc->clk_freq = A3700_TCLK_250MHZ;
+#else
+		device_printf(sc->dev,
+			"Cannot get clock, using get_tclk()\n");
+		sc->clk_freq = get_tclk();
+#endif
 	} else {
 		error = clk_get_freq(clk, &sc->clk_freq);
 		if (error != 0) {
@@ -573,9 +575,6 @@ mvneta_attach(device_t self)
 			return (error);
 		}
 	}
-#else
-	sc->clk_freq = get_tclk();
-#endif
 
 #if !defined(__aarch64__)
 	/*