]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
clk: add clk_set_parent()
authorPhilipp Tomsich <philipp.tomsich@theobroma-systems.com>
Mon, 8 Jan 2018 10:15:08 +0000 (11:15 +0100)
committerPhilipp Tomsich <philipp.tomsich@theobroma-systems.com>
Sun, 28 Jan 2018 16:12:35 +0000 (17:12 +0100)
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.

drivers/clk/clk-uclass.c
include/clk-uclass.h
include/clk.h

index fbea72091b190c43fdf411a0d96f721735264faf..20ee0c5424dde931dac8d679b0f44c138fb6c45c 100644 (file)
@@ -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);
index e7ea334c608b4f088af50524f80640bfd500d667..75933eb8841fb86bdf7efc999dfe0a4bffa68928 100644 (file)
@@ -77,6 +77,14 @@ struct clk_ops {
         * @return new rate, or -ve error code.
         */
        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.
         *
index e7ce3e8576883f8e6df0d21d19347bfd9d7047be..e463d8e60dc28c60a3394900b856d67b6d119589 100644 (file)
@@ -177,6 +177,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.
  *