[PATCH v2 7/7] clk: compat: add clk (un)prepare and associated functions
Casey Connolly
casey.connolly at linaro.org
Wed Apr 1 16:34:08 CEST 2026
Introduce clk_prepare/prepare_enable as well as unprepare and bulk
associated functions. These are just stubs but will be used with
CCF_FULL.
Signed-off-by: Casey Connolly <casey.connolly at linaro.org>
---
drivers/clk/clk-uclass.c | 7 +++++
include/clk.h | 68 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 75 insertions(+)
diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index 095329e25f15..e960d2ad2383 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -837,8 +837,15 @@ struct clk *devm_clk_get(struct udevice *dev, const char *id)
return clk;
}
+int clk_prepare(struct clk *clk)
+{
+ return 0;
+}
+
+void clk_unprepare(struct clk *clk) { }
+
int clk_uclass_post_probe(struct udevice *dev)
{
/*
* when a clock provider is probed. Call clk_set_defaults()
diff --git a/include/clk.h b/include/clk.h
index 0520032f692c..6ae033259cb1 100644
--- a/include/clk.h
+++ b/include/clk.h
@@ -514,8 +514,35 @@ long clk_set_rate(struct clk *clk, ulong rate);
* Return: new rate, or -ve error code.
*/
int clk_set_parent(struct clk *clk, struct clk *parent);
+/**
+ * clk_prepare - prepare a clock source
+ * @clk: clock source
+ *
+ * This prepares the clock source for use.
+ *
+ * Must not be called from within atomic context.
+ *
+ * U-Boot: this is a no-op unless CCF_FULL is enabled.
+ */
+int clk_prepare(struct clk *clk);
+
+int clk_prepare_bulk(struct clk_bulk *clks);
+
+/**
+ * clk_unprepare - undo preparation of a clock source
+ * @clk: clock source
+ *
+ * This undoes a previously prepared clock. The caller must balance
+ * the number of prepare and unprepare calls.
+ *
+ * Must not be called from within atomic context.
+ */
+void clk_unprepare(struct clk *clk);
+
+int clk_unprepare_bulk(struct clk_bulk *clks);
+
/**
* clk_enable() - Enable (turn on) a clock.
* @clk: A clock struct that was previously successfully requested by
* clk_request/get_by_*().
@@ -550,8 +577,49 @@ int clk_disable(struct clk *clk);
* Return: zero on success, or -ve error code.
*/
int clk_disable_bulk(struct clk_bulk *bulk);
+static inline int clk_prepare_enable(struct clk *clk)
+{
+ int ret;
+
+ ret = clk_prepare(clk);
+ if (!ret)
+ ret = clk_enable(clk);
+
+ return ret;
+}
+
+static inline int clk_disable_unprepare(struct clk *clk)
+{
+ int ret;
+
+ ret = clk_disable(clk);
+ if (!ret)
+ clk_unprepare(clk);
+ return ret;
+}
+
+static inline int clk_prepare_enable_bulk(struct clk_bulk *clks)
+{
+ int ret;
+
+ ret = clk_prepare_bulk(clks);
+ if (!ret)
+ ret = clk_enable_bulk(clks);
+ return ret;
+}
+
+static inline int clk_disable_unprepare_bulk(struct clk_bulk *clks)
+{
+ int ret;
+
+ ret = clk_disable_bulk(clks);
+ if (!ret)
+ ret = clk_unprepare_bulk(clks);
+ return ret;
+}
+
/**
* clk_is_match - check if two clk's point to the same hardware clock
* @p: clk compared against q
* @q: clk compared against p
--
2.51.0
More information about the U-Boot
mailing list