clk: ti: generalize the init sequence of clk_hw_omap clocks
authorTero Kristo <t-kristo@ti.com>
Tue, 15 Jan 2019 09:15:15 +0000 (11:15 +0200)
committerTero Kristo <t-kristo@ti.com>
Fri, 15 Feb 2019 14:46:22 +0000 (16:46 +0200)
Add a generic API for initializing clocks of clk_hw_omap type clocks,
and convert the whole TI clock driver suite to use this for registering
the clocks. Also, get rid of the now redundant API for adding the clocks
to the OMAP HW clocks list; instead this is used directly from the
register API.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Tested-by: Keerthy <j-keerthy@ti.com>
drivers/clk/ti/apll.c
drivers/clk/ti/clk.c
drivers/clk/ti/clock.h
drivers/clk/ti/dpll.c
drivers/clk/ti/gate.c
drivers/clk/ti/interface.c

index 222f68bc3f2ae5149d188ac683c36396750a7191..015a657d33829e160f3acc18145461499c963f24 100644 (file)
@@ -165,7 +165,7 @@ static void __init omap_clk_register_apll(void *user,
 
        ad->clk_bypass = __clk_get_hw(clk);
 
-       clk = ti_clk_register(NULL, &clk_hw->hw, node->name);
+       clk = ti_clk_register_omap_hw(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);
@@ -402,7 +402,7 @@ static void __init of_omap2_apll_setup(struct device_node *node)
        if (ret)
                goto cleanup;
 
-       clk = clk_register(NULL, &clk_hw->hw);
+       clk = ti_clk_register_omap_hw(NULL, &clk_hw->hw, node->name);
        if (!IS_ERR(clk)) {
                of_clk_add_provider(node, of_clk_src_simple_get, clk);
                kfree(init);
index 122af268083347d032be3d6798acae663e6dd194..d1f948163d6adf9b9162c8dcc6a77c9df09b44e8 100644 (file)
@@ -520,20 +520,31 @@ struct clk *ti_clk_register(struct device *dev, struct clk_hw *hw,
 }
 
 /**
- * omap2_init_clk_hw_omap_clocks - initialize an OMAP clock
- * @hw: struct clk_hw * to initialize
+ * ti_clk_register_omap_hw - register a clk_hw_omap to the clock framework
+ * @dev: device for this clock
+ * @hw: hardware clock handle
+ * @con: connection ID for this clock
  *
- * Add an OMAP clock @clk to the internal list of OMAP clocks.  Used
- * temporarily for autoidle handling, until this support can be
- * integrated into the common clock framework code in some way.  No
- * return value.
+ * Registers a clk_hw_omap clock to the clock framewor, adds a clock alias
+ * for it, and adds the list to the available clk_hw_omap type clocks.
+ * Returns a handle to the registered clock if successful, ERR_PTR value
+ * in failure.
  */
-void omap2_init_clk_hw_omap_clocks(struct clk_hw *hw)
+struct clk *ti_clk_register_omap_hw(struct device *dev, struct clk_hw *hw,
+                                   const char *con)
 {
-       struct clk_hw_omap *c;
+       struct clk *clk;
+       struct clk_hw_omap *oclk;
 
-       c = to_clk_hw_omap(hw);
-       list_add(&c->node, &clk_hw_omap_clocks);
+       clk = ti_clk_register(dev, hw, con);
+       if (IS_ERR(clk))
+               return clk;
+
+       oclk = to_clk_hw_omap(hw);
+
+       list_add(&oclk->node, &clk_hw_omap_clocks);
+
+       return clk;
 }
 
 /**
index 034ff6a2be0779db535997d21a47ad0033b731fa..1c0fac59d8090fdf175a8d3baf0a1ef6e809cc49 100644 (file)
@@ -203,6 +203,8 @@ typedef void (*ti_of_clk_init_cb_t)(void *, struct device_node *);
 
 struct clk *ti_clk_register(struct device *dev, struct clk_hw *hw,
                            const char *con);
+struct clk *ti_clk_register_omap_hw(struct device *dev, struct clk_hw *hw,
+                                   const char *con);
 int ti_clk_add_alias(struct device *dev, struct clk *clk, const char *con);
 void ti_clk_add_aliases(void);
 
@@ -221,7 +223,6 @@ int ti_clk_retry_init(struct device_node *node, void *user,
                      ti_of_clk_init_cb_t func);
 int ti_clk_add_component(struct device_node *node, struct clk_hw *hw, int type);
 
-void omap2_init_clk_hw_omap_clocks(struct clk_hw *hw);
 int of_ti_clk_autoidle_setup(struct device_node *node);
 void omap2_clk_enable_init_clocks(const char **clk_names, u8 num_clocks);
 
index 6c3329bc116fb55ae20a45722b247d49a6e7ccef..659dadb23279caa755260be7b465794978f78b3a 100644 (file)
@@ -192,10 +192,9 @@ static void __init _register_dpll(void *user,
        dd->clk_bypass = __clk_get_hw(clk);
 
        /* register the clock */
-       clk = ti_clk_register(NULL, &clk_hw->hw, node->name);
+       clk = ti_clk_register_omap_hw(NULL, &clk_hw->hw, node->name);
 
        if (!IS_ERR(clk)) {
-               omap2_init_clk_hw_omap_clocks(&clk_hw->hw);
                of_clk_add_provider(node, of_clk_src_simple_get, clk);
                kfree(clk_hw->hw.init->parent_names);
                kfree(clk_hw->hw.init);
@@ -265,14 +264,12 @@ static void _register_dpll_x2(struct device_node *node,
 #endif
 
        /* register the clock */
-       clk = ti_clk_register(NULL, &clk_hw->hw, name);
+       clk = ti_clk_register_omap_hw(NULL, &clk_hw->hw, name);
 
-       if (IS_ERR(clk)) {
+       if (IS_ERR(clk))
                kfree(clk_hw);
-       } else {
-               omap2_init_clk_hw_omap_clocks(&clk_hw->hw);
+       else
                of_clk_add_provider(node, of_clk_src_simple_get, clk);
-       }
 }
 #endif
 
index 1c78fff5513c798b5e0f8e62887c5a83b1523be8..504c0e91cdc7656550407c9270f5bdf855f983bb 100644 (file)
@@ -123,7 +123,7 @@ static struct clk *_register_gate(struct device *dev, const char *name,
 
        init.flags = flags;
 
-       clk = ti_clk_register(NULL, &clk_hw->hw, name);
+       clk = ti_clk_register_omap_hw(NULL, &clk_hw->hw, name);
 
        if (IS_ERR(clk))
                kfree(clk_hw);
index 87e00c2ee957d9dab2a6bd646f36b8c21040c358..83e34429d3b10b627a31f979b9bd31627bebdcd8 100644 (file)
@@ -57,12 +57,10 @@ static struct clk *_register_interface(struct device *dev, const char *name,
        init.num_parents = 1;
        init.parent_names = &parent_name;
 
-       clk = ti_clk_register(NULL, &clk_hw->hw, name);
+       clk = ti_clk_register_omap_hw(NULL, &clk_hw->hw, name);
 
        if (IS_ERR(clk))
                kfree(clk_hw);
-       else
-               omap2_init_clk_hw_omap_clocks(&clk_hw->hw);
 
        return clk;
 }