git: 4047cec13239 - stable/14 - scmi: Implement scmi_clknode_recalc_freq method

From: Andrew Turner <andrew_at_FreeBSD.org>
Date: Mon, 02 Sep 2024 08:50:41 UTC
The branch stable/14 has been updated by andrew:

URL: https://cgit.FreeBSD.org/src/commit/?id=4047cec13239e2bfa5b4fbd98de56bdb214e15bc

commit 4047cec13239e2bfa5b4fbd98de56bdb214e15bc
Author:     Cristian Marussi <cristian.marussi@arm.com>
AuthorDate: 2023-12-10 22:14:21 +0000
Commit:     Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2024-09-02 08:46:27 +0000

    scmi: Implement scmi_clknode_recalc_freq method
    
    Allow the SCMI clock frequency to be queried back, useful for testing
    the IRQ path via sysctl access.
    
    Reviewed by:    andrew
    Sponsored by:   Arm Ltd
    Differential Revision:  https://reviews.freebsd.org/D43038
    
    (cherry picked from commit ecd8cc84dcee7d08be8663f721f0502dc5b65808)
---
 sys/dev/firmware/arm/scmi_clk.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/sys/dev/firmware/arm/scmi_clk.c b/sys/dev/firmware/arm/scmi_clk.c
index 30d630c8ef57..48259d81a60a 100644
--- a/sys/dev/firmware/arm/scmi_clk.c
+++ b/sys/dev/firmware/arm/scmi_clk.c
@@ -56,7 +56,7 @@ struct scmi_clknode_softc {
 	int		clock_id;
 };
 
-static int __unused
+static int
 scmi_clk_get_rate(struct scmi_clk_softc *sc, int clk_id, uint64_t *rate)
 {
 	struct scmi_clk_rate_get_out out;
@@ -155,8 +155,18 @@ scmi_clknode_init(struct clknode *clk, device_t dev)
 static int
 scmi_clknode_recalc_freq(struct clknode *clk, uint64_t *freq)
 {
+	struct scmi_clknode_softc *clk_sc;
+	struct scmi_clk_softc *sc;
+	uint64_t rate;
+	int ret;
 
-	return (0);
+	clk_sc = clknode_get_softc(clk);
+	sc = device_get_softc(clk_sc->dev);
+	ret = scmi_clk_get_rate(sc, clk_sc->clock_id, &rate);
+	if (ret == 0)
+		*freq = rate;
+
+	return (ret);
 }
 
 static int