clk: ti: use automatic clock alias generation framework
authorTero Kristo <t-kristo@ti.com>
Thu, 29 Sep 2016 09:06:40 +0000 (12:06 +0300)
committerTero Kristo <t-kristo@ti.com>
Wed, 8 Mar 2017 10:58:18 +0000 (12:58 +0200)
Generate clock aliases automatically for all TI clock drivers.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Acked-by: Tony Lindgren <tony@atomide.com>
drivers/clk/ti/apll.c
drivers/clk/ti/clk-dra7-atl.c
drivers/clk/ti/clk.c
drivers/clk/ti/composite.c
drivers/clk/ti/divider.c
drivers/clk/ti/dpll.c
drivers/clk/ti/fixed-factor.c
drivers/clk/ti/gate.c
drivers/clk/ti/interface.c
drivers/clk/ti/mux.c

index 6411e132faa2b01e25598edbdd2139b3e6185a5d..62b5db7b8fe9b581e0fbb86cb566c1b6f680736c 100644 (file)
@@ -164,7 +164,7 @@ static void __init omap_clk_register_apll(struct clk_hw *hw,
 
        ad->clk_bypass = __clk_get_hw(clk);
 
-       clk = clk_register(NULL, &clk_hw->hw);
+       clk = ti_clk_register(NULL, &clk_hw->hw, node->name);
        if (!IS_ERR(clk)) {
                of_clk_add_provider(node, of_clk_src_simple_get, clk);
                kfree(clk_hw->hw.init->parent_names);
index 45d05339d583fad8c3beee9755534eb4ebe4f0cd..13eb04f72389bbf68e26a12f71b74188910e8ab8 100644 (file)
@@ -24,6 +24,9 @@
 #include <linux/of_address.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
+#include <linux/clk/ti.h>
+
+#include "clock.h"
 
 #define DRA7_ATL_INSTANCES     4
 
@@ -171,6 +174,7 @@ static void __init of_dra7_atl_clock_setup(struct device_node *node)
        struct clk_init_data init = { NULL };
        const char **parent_names = NULL;
        struct clk *clk;
+       int ret;
 
        clk_hw = kzalloc(sizeof(*clk_hw), GFP_KERNEL);
        if (!clk_hw) {
@@ -200,9 +204,14 @@ static void __init of_dra7_atl_clock_setup(struct device_node *node)
 
        init.parent_names = parent_names;
 
-       clk = clk_register(NULL, &clk_hw->hw);
+       clk = ti_clk_register(NULL, &clk_hw->hw, node->name);
 
        if (!IS_ERR(clk)) {
+               ret = ti_clk_add_alias(NULL, clk, node->name);
+               if (ret) {
+                       clk_unregister(clk);
+                       goto cleanup;
+               }
                of_clk_add_provider(node, of_clk_src_simple_get, clk);
                kfree(parent_names);
                return;
index 193862ed27c7799e5a46495d951a05800b7de7e6..024123f421d6f59e66eec834f302b9caaff364b5 100644 (file)
@@ -298,6 +298,7 @@ struct clk __init *ti_clk_register_clk(struct ti_clk *setup)
        struct ti_clk_fixed *fixed;
        struct ti_clk_fixed_factor *fixed_factor;
        struct clk_hw *clk_hw;
+       int ret;
 
        if (setup->clk)
                return setup->clk;
@@ -308,6 +309,13 @@ struct clk __init *ti_clk_register_clk(struct ti_clk *setup)
 
                clk = clk_register_fixed_rate(NULL, setup->name, NULL, 0,
                                              fixed->frequency);
+               if (!IS_ERR(clk)) {
+                       ret = ti_clk_add_alias(NULL, clk, setup->name);
+                       if (ret) {
+                               clk_unregister(clk);
+                               clk = ERR_PTR(ret);
+                       }
+               }
                break;
        case TI_CLK_MUX:
                clk = ti_clk_register_mux(setup);
@@ -325,6 +333,13 @@ struct clk __init *ti_clk_register_clk(struct ti_clk *setup)
                                                fixed_factor->parent,
                                                0, fixed_factor->mult,
                                                fixed_factor->div);
+               if (!IS_ERR(clk)) {
+                       ret = ti_clk_add_alias(NULL, clk, setup->name);
+                       if (ret) {
+                               clk_unregister(clk);
+                               clk = ERR_PTR(ret);
+                       }
+               }
                break;
        case TI_CLK_GATE:
                clk = ti_clk_register_gate(setup);
@@ -378,9 +393,6 @@ int __init ti_clk_register_legacy_clks(struct ti_clk_alias *clks)
                                       clks->clk->name, PTR_ERR(clk));
                                return PTR_ERR(clk);
                        }
-               } else {
-                       clks->lk.clk = clk;
-                       clkdev_add(&clks->lk);
                }
                clks++;
        }
@@ -403,8 +415,6 @@ int __init ti_clk_register_legacy_clks(struct ti_clk_alias *clks)
                                }
                        } else {
                                retry = true;
-                               retry_clk->lk.clk = clk;
-                               clkdev_add(&retry_clk->lk);
                                list_del(&retry_clk->link);
                        }
                }
index 1cf70f452e1e660b594a5a92b99db21008abc28d..3f60f990cad805f6762e17fd834509f8bceebd6d 100644 (file)
@@ -126,6 +126,7 @@ struct clk *ti_clk_register_composite(struct ti_clk *setup)
        int num_parents = 1;
        const char **parent_names = NULL;
        struct clk *clk;
+       int ret;
 
        comp = setup->data;
 
@@ -150,6 +151,12 @@ struct clk *ti_clk_register_composite(struct ti_clk *setup)
                                     &ti_composite_divider_ops, gate,
                                     &ti_composite_gate_ops, 0);
 
+       ret = ti_clk_add_alias(NULL, clk, setup->name);
+       if (ret) {
+               clk_unregister(clk);
+               return ERR_PTR(ret);
+       }
+
        return clk;
 }
 #endif
@@ -163,6 +170,7 @@ static void __init _register_composite(struct clk_hw *hw,
        int num_parents = 0;
        const char **parent_names = NULL;
        int i;
+       int ret;
 
        /* Check for presence of each component clock */
        for (i = 0; i < CLK_COMPONENT_TYPE_MAX; i++) {
@@ -217,8 +225,14 @@ static void __init _register_composite(struct clk_hw *hw,
                                     _get_hw(cclk, CLK_COMPONENT_TYPE_GATE),
                                     &ti_composite_gate_ops, 0);
 
-       if (!IS_ERR(clk))
+       if (!IS_ERR(clk)) {
+               ret = ti_clk_add_alias(NULL, clk, node->name);
+               if (ret) {
+                       clk_unregister(clk);
+                       goto cleanup;
+               }
                of_clk_add_provider(node, of_clk_src_simple_get, clk);
+       }
 
 cleanup:
        /* Free component clock list entries */
index 6bb87784a0d6ef82c411bf7ba566412a4059dd20..0e8c1363879ecb8752563f8300d3c6a0ceb7e15a 100644 (file)
@@ -311,7 +311,7 @@ static struct clk *_register_divider(struct device *dev, const char *name,
        div->table = table;
 
        /* register the clock */
-       clk = clk_register(dev, &div->hw);
+       clk = ti_clk_register(dev, &div->hw, name);
 
        if (IS_ERR(clk))
                kfree(div);
index 4b9a419d8e14133d04bb405b84d79da9b6bc5be5..37624e16cf04d454eebfa9318ac2bace1779e1c1 100644 (file)
@@ -185,7 +185,7 @@ static void __init _register_dpll(struct clk_hw *hw,
        dd->clk_bypass = __clk_get_hw(clk);
 
        /* register the clock */
-       clk = clk_register(NULL, &clk_hw->hw);
+       clk = ti_clk_register(NULL, &clk_hw->hw, node->name);
 
        if (!IS_ERR(clk)) {
                omap2_init_clk_hw_omap_clocks(&clk_hw->hw);
@@ -288,7 +288,7 @@ struct clk *ti_clk_register_dpll(struct ti_clk *setup)
        if (dpll->flags & CLKF_J_TYPE)
                dd->flags |= DPLL_J_TYPE;
 
-       clk = clk_register(NULL, &clk_hw->hw);
+       clk = ti_clk_register(NULL, &clk_hw->hw, setup->name);
 
        if (!IS_ERR(clk))
                return clk;
@@ -340,7 +340,7 @@ static void _register_dpll_x2(struct device_node *node,
        init.num_parents = 1;
 
        /* register the clock */
-       clk = clk_register(NULL, &clk_hw->hw);
+       clk = ti_clk_register(NULL, &clk_hw->hw, name);
 
        if (IS_ERR(clk)) {
                kfree(clk_hw);
index 3cd40676890969b1853256d32061b8bfd29093a7..0174a51a4ba6c11dfa4cec9b2a57bc44e156ef67 100644 (file)
@@ -62,6 +62,7 @@ static void __init of_ti_fixed_factor_clk_setup(struct device_node *node)
        if (!IS_ERR(clk)) {
                of_clk_add_provider(node, of_clk_src_simple_get, clk);
                of_ti_clk_autoidle_setup(node);
+               ti_clk_add_alias(NULL, clk, clk_name);
        }
 }
 CLK_OF_DECLARE(ti_fixed_factor_clk, "ti,fixed-factor-clock",
index bc05f276f32b90039a0eed1879d7a1201930ea97..b3291dbca5edaa62e78a4fc2c8df0fb3e0b60c2a 100644 (file)
@@ -120,7 +120,7 @@ static struct clk *_register_gate(struct device *dev, const char *name,
 
        init.flags = flags;
 
-       clk = clk_register(NULL, &clk_hw->hw);
+       clk = ti_clk_register(NULL, &clk_hw->hw, name);
 
        if (IS_ERR(clk))
                kfree(clk_hw);
index e505e6f8228da6ada5ccb4beffd7aa0de78f1f1d..7927e1a2ba0272e3717f42102fddd06a48cb44db 100644 (file)
@@ -58,7 +58,7 @@ static struct clk *_register_interface(struct device *dev, const char *name,
        init.num_parents = 1;
        init.parent_names = &parent_name;
 
-       clk = clk_register(NULL, &clk_hw->hw);
+       clk = ti_clk_register(NULL, &clk_hw->hw, name);
 
        if (IS_ERR(clk))
                kfree(clk_hw);
index 44777ab6fdeb3b6f8d0fcd5386790c506f39d300..0da149ed1549c4ee4298351d4770521899e80eb7 100644 (file)
@@ -127,7 +127,7 @@ static struct clk *_register_mux(struct device *dev, const char *name,
        mux->table = table;
        mux->hw.init = &init;
 
-       clk = clk_register(dev, &mux->hw);
+       clk = ti_clk_register(dev, &mux->hw, name);
 
        if (IS_ERR(clk))
                kfree(mux);