[U-Boot] [PATCH v8 03/10] clk: add clk_disable_all()

patrice.chotard at st.com patrice.chotard at st.com
Wed Jun 21 07:50:17 UTC 2017


From: Patrice Chotard <patrice.chotard at st.com>

Add clk_disable_all() method which Request/Disable/Free an
array of clocks that has been previously requested by
clk_request/get_by_*()

Signed-off-by: Patrice Chotard <patrice.chotard at st.com>
---
v8:	_ replace clk->dev by clk[i].dev in clk_request() param 
v7:	_ none
v6:	_ none
v5:	_ none
v4:	_ none
v3:	_ add commit message
v2:	_ create this independant path for printf() replacement

 drivers/clk/clk-uclass.c | 22 ++++++++++++++++++++++
 include/clk.h            | 10 ++++++++++
 2 files changed, 32 insertions(+)

diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index 83b6328..f6ad106 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -187,6 +187,28 @@ int clk_disable(struct clk *clk)
 	return ops->disable(clk);
 }
 
+int clk_disable_all(struct clk *clk, int count)
+{
+	int i, ret;
+
+	debug("%s(clk=%p count=%d)\n", __func__, clk, count);
+
+	for (i = 0; i < count; i++) {
+		ret = clk_request(clk[i].dev, &clk[i]);
+		if (ret && ret != -ENOSYS)
+			return ret;
+
+		ret = clk_disable(&clk[i]);
+		if (ret && ret != -ENOSYS)
+			return ret;
+
+		ret = clk_free(&clk[i]);
+		if (ret && ret != -ENOSYS)
+			return ret;
+	}
+	return 0;
+}
+
 UCLASS_DRIVER(clk) = {
 	.id		= UCLASS_CLK,
 	.name		= "clk",
diff --git a/include/clk.h b/include/clk.h
index 5a5c2ff..e04c274 100644
--- a/include/clk.h
+++ b/include/clk.h
@@ -174,6 +174,16 @@ int clk_enable(struct clk *clk);
  */
 int clk_disable(struct clk *clk);
 
+/**
+ * clk_disable_all() - Request/Disable (turn off)/Free clocks.
+ *
+ * @clk:	A clock struct array that was previously successfully
+ *		requested by clk_request/get_by_*().
+ * @count	Number of clock contained in the array
+ * @return zero on success, or -ve error code.
+ */
+int clk_disable_all(struct clk *clk, int count);
+
 int soc_clk_dump(void);
 
 #endif
-- 
1.9.1



More information about the U-Boot mailing list