[U-Boot] [PATCH 14/33] clk: introduce clk_phase get/set function & callback
Ziyuan Xu
xzy.xu at rock-chips.com
Mon May 15 06:07:08 UTC 2017
A common operation for a clock signal generator is to shift the phase of
that signal. This patch introduces a new function to the clk.h API to
dynamically adjust the phase of a clock signal. Additionally this patch
introduces support for the new function in the clock framework via the
.set_phase & .get_phase callback in struct clk_ops.
Signed-off-by: Ziyuan Xu <xzy.xu at rock-chips.com>
---
drivers/clk/clk-uclass.c | 20 ++++++++++++++++++++
include/clk-uclass.h | 17 +++++++++++++++++
include/clk.h | 20 ++++++++++++++++++++
3 files changed, 57 insertions(+)
diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index 6fcfd69..47628b1 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -165,6 +165,26 @@ ulong clk_set_rate(struct clk *clk, ulong rate)
return ops->set_rate(clk, rate);
}
+int clk_get_phase(struct clk *clk)
+{
+ struct clk_ops *ops = clk_dev_ops(clk->dev);
+
+ if (!ops->get_phase)
+ return -ENOSYS;
+
+ return ops->get_phase(clk);
+}
+
+int clk_set_phase(struct clk *clk, int degrees)
+{
+ struct clk_ops *ops = clk_dev_ops(clk->dev);
+
+ if (!ops->set_phase)
+ return -ENOSYS;
+
+ return ops->set_phase(clk, degrees);
+}
+
int clk_enable(struct clk *clk)
{
struct clk_ops *ops = clk_dev_ops(clk->dev);
diff --git a/include/clk-uclass.h b/include/clk-uclass.h
index 07c1065..0e56daa 100644
--- a/include/clk-uclass.h
+++ b/include/clk-uclass.h
@@ -77,6 +77,23 @@ struct clk_ops {
*/
ulong (*set_rate)(struct clk *clk, ulong rate);
/**
+ * clk_get_phase() - Get the phase shift of a clock signal.
+ *
+ * @clk: The clock to manipulate.
+ * @return the phase shift of a clock node in degrees,
+ * otherwise returns -ve error code.
+ */
+ int (*get_phase)(struct clk *clk);
+
+ /**
+ * clk_set_rate() - Adjust the phase shift of a clock signal.
+ *
+ * @clk: The clock to manipulate.
+ * @degrees: Numberof degrees the signal is shifted.
+ * @return 0 on success, or -ve error code.
+ */
+ int (*set_phase)(struct clk *clk, int degrees);
+ /**
* enable() - Enable a clock.
*
* @clk: The clock to manipulate.
diff --git a/include/clk.h b/include/clk.h
index 5a5c2ff..1858fef 100644
--- a/include/clk.h
+++ b/include/clk.h
@@ -157,6 +157,26 @@ ulong clk_get_rate(struct clk *clk);
ulong clk_set_rate(struct clk *clk, ulong rate);
/**
+ * clk_get_phase() - Get the phase shift of a clock signal.
+ *
+ * @clk: A clock struct that was previously successfully requested by
+ * clk_request/get_by_*().
+ * @return the phase shift of a clock node in degrees, otherwise returns
+ * -ve error code.
+ */
+int clk_get_phase(struct clk *clk);
+
+/**
+ * clk_set_rate() - Adjust the phase shift of a clock signal.
+ *
+ * @clk: A clock struct that was previously successfully requested by
+ * clk_request/get_by_*().
+ * @degrees: Numberof degrees the signal is shifted.
+ * @return 0 on success, or -ve error code.
+ */
+int clk_set_phase(struct clk *clk, int degrees);
+
+/**
* clk_enable() - Enable (turn on) a clock.
*
* @clk: A clock struct that was previously successfully requested by
--
2.7.4
More information about the U-Boot
mailing list