summaryrefslogtreecommitdiff
path: root/include/clk.h
diff options
context:
space:
mode:
authorDario Binacchi <dariobin@libero.it>2020-12-30 00:06:31 +0100
committerLokesh Vutla <lokeshvutla@ti.com>2021-01-12 10:58:04 +0530
commit2983ad55a13e9afcdf1a3d8f55eea038c0a0e8a3 (patch)
treed586303823a6aa0aa980451e53610dc20e7e66b5 /include/clk.h
parent6337d53fdf45df764bc9946d927172397f183d37 (diff)
clk: add clk_round_rate()
It returns the rate which will be set if you ask clk_set_rate() to set that rate. It provides a way to query exactly what rate you'll get if you call clk_set_rate() with that same argument. So essentially, clk_round_rate() and clk_set_rate() are equivalent except the former does not modify the clock hardware in any way. Signed-off-by: Dario Binacchi <dariobin@libero.it> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Sean Anderson <seanga2@gmail.com>
Diffstat (limited to 'include/clk.h')
-rw-r--r--include/clk.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/include/clk.h b/include/clk.h
index a62e2efa2c..ca6b85fa6f 100644
--- a/include/clk.h
+++ b/include/clk.h
@@ -367,6 +367,29 @@ struct clk *clk_get_parent(struct clk *clk);
long long clk_get_parent_rate(struct clk *clk);
/**
+ * clk_round_rate() - Adjust a rate to the exact rate a clock can provide
+ *
+ * This answers the question "if I were to pass @rate to clk_set_rate(),
+ * what clock rate would I end up with?" without changing the hardware
+ * in any way. In other words:
+ *
+ * rate = clk_round_rate(clk, r);
+ *
+ * and:
+ *
+ * rate = clk_set_rate(clk, r);
+ *
+ * are equivalent except the former does not modify the clock hardware
+ * in any way.
+ *
+ * @clk: A clock struct that was previously successfully requested by
+ * clk_request/get_by_*().
+ * @rate: desired clock rate in Hz.
+ * @return rounded rate in Hz, or -ve error code.
+ */
+ulong clk_round_rate(struct clk *clk, ulong rate);
+
+/**
* clk_set_rate() - Set current clock rate.
*
* @clk: A clock struct that was previously successfully requested by
@@ -482,6 +505,11 @@ static inline long long clk_get_parent_rate(struct clk *clk)
return -ENOSYS;
}
+static inline ulong clk_round_rate(struct clk *clk, ulong rate)
+{
+ return -ENOSYS;
+}
+
static inline ulong clk_set_rate(struct clk *clk, ulong rate)
{
return -ENOSYS;