summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Tomsich <philipp.tomsich@theobroma-systems.com>2018-01-08 13:15:08 +0300
committerPhilipp Tomsich <philipp.tomsich@theobroma-systems.com>2018-01-28 19:12:35 +0300
commitf7d1046da18fd03a047b5f4d290a8ab8550ebf73 (patch)
tree308343715a5434f6442d81c29e8c618d06f08923
parent1a7f6d4597646662022f3e67ceaaeff7a23459e5 (diff)
downloadu-boot-f7d1046da18fd03a047b5f4d290a8ab8550ebf73.tar.xz
clk: add clk_set_parent()
Clocks may support multiple parents: this change introduces an optional operation on the clk-uclass to set a clock's parent. Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com> Tested-by: David Wu <david.wu@rock-chips.com> Series-changes: 2 - Fixed David's email address.
-rw-r--r--drivers/clk/clk-uclass.c12
-rw-r--r--include/clk-uclass.h8
-rw-r--r--include/clk.h11
3 files changed, 31 insertions, 0 deletions
diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index fbea72091b..20ee0c5424 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -188,6 +188,18 @@ ulong clk_set_rate(struct clk *clk, ulong rate)
return ops->set_rate(clk, rate);
}
+int clk_set_parent(struct clk *clk, struct clk *parent)
+{
+ const struct clk_ops *ops = clk_dev_ops(clk->dev);
+
+ debug("%s(clk=%p, parent=%p)\n", __func__, clk, parent);
+
+ if (!ops->set_parent)
+ return -ENOSYS;
+
+ return ops->set_parent(clk, parent);
+}
+
int clk_enable(struct clk *clk)
{
const struct clk_ops *ops = clk_dev_ops(clk->dev);
diff --git a/include/clk-uclass.h b/include/clk-uclass.h
index e7ea334c60..75933eb884 100644
--- a/include/clk-uclass.h
+++ b/include/clk-uclass.h
@@ -78,6 +78,14 @@ struct clk_ops {
*/
ulong (*set_rate)(struct clk *clk, ulong rate);
/**
+ * set_parent() - Set current clock parent
+ *
+ * @clk: The clock to manipulate.
+ * @parent: New clock parent.
+ * @return zero on success, or -ve error code.
+ */
+ int (*set_parent)(struct clk *clk, struct clk *parent);
+ /**
* enable() - Enable a clock.
*
* @clk: The clock to manipulate.
diff --git a/include/clk.h b/include/clk.h
index e7ce3e8576..e463d8e60d 100644
--- a/include/clk.h
+++ b/include/clk.h
@@ -178,6 +178,17 @@ ulong clk_get_rate(struct clk *clk);
ulong clk_set_rate(struct clk *clk, ulong rate);
/**
+ * clk_set_parent() - Set current clock parent.
+ *
+ * @clk: A clock struct that was previously successfully requested by
+ * clk_request/get_by_*().
+ * @parent: A clock struct that was previously successfully requested by
+ * clk_request/get_by_*().
+ * @return new rate, or -ve error code.
+ */
+int clk_set_parent(struct clk *clk, struct clk *parent);
+
+/**
* clk_enable() - Enable (turn on) a clock.
*
* @clk: A clock struct that was previously successfully requested by