clk: use clk_dev_binded
authorPeng Fan <peng.fan@nxp.com>
Wed, 31 Jul 2019 07:01:26 +0000 (07:01 +0000)
committerLukasz Majewski <lukma@denx.de>
Wed, 31 Jul 2019 07:20:51 +0000 (09:20 +0200)
Preparing to support composite clk.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
drivers/clk/clk-divider.c
drivers/clk/clk-mux.c

index 6921c76a48fc149bb81a80aa5e6b1e2e80b57d19..2ed9ed6ab8c4ab1e17be696b894b653256b40f3c 100644 (file)
@@ -69,8 +69,8 @@ unsigned long divider_recalc_rate(struct clk *hw, unsigned long parent_rate,
 
 static ulong clk_divider_recalc_rate(struct clk *clk)
 {
-       struct clk_divider *divider =
-               to_clk_divider(dev_get_clk_ptr(clk->dev));
+       struct clk_divider *divider = to_clk_divider(clk_dev_binded(clk) ?
+                       dev_get_clk_ptr(clk->dev) : clk);
        unsigned long parent_rate = clk_get_parent_rate(clk);
        unsigned int val;
 
index 3c075aa09ec78b8f63cf6254188d407b38e1653f..81d1e7ebeeba3b00c3caddb0df9302c36d8e072f 100644 (file)
@@ -35,7 +35,8 @@
 int clk_mux_val_to_index(struct clk *clk, u32 *table, unsigned int flags,
                         unsigned int val)
 {
-       struct clk_mux *mux = to_clk_mux(clk);
+       struct clk_mux *mux = to_clk_mux(clk_dev_binded(clk) ?
+                       dev_get_clk_ptr(clk->dev) : clk);
        int num_parents = mux->num_parents;
 
        if (table) {
@@ -61,7 +62,8 @@ int clk_mux_val_to_index(struct clk *clk, u32 *table, unsigned int flags,
 
 static u8 clk_mux_get_parent(struct clk *clk)
 {
-       struct clk_mux *mux = to_clk_mux(clk);
+       struct clk_mux *mux = to_clk_mux(clk_dev_binded(clk) ?
+                       dev_get_clk_ptr(clk->dev) : clk);
        u32 val;
 
 #if CONFIG_IS_ENABLED(SANDBOX_CLK_CCF)