aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTero Kristo <t-kristo@ti.com>2014-12-16 11:20:52 -0500
committerMichael Turquette <mturquette@linaro.org>2015-01-30 13:55:15 -0500
commitb26bcf9be64e26d8a0972d6df1c2105cc5076cf1 (patch)
tree6265a4f29e8bde0b38ac46bd9414b74968b298a9
parented405a2350646a940966f471ae705fa2d81eee65 (diff)
clk: ti: composite: add support for legacy composite clock init
Legacy clock data is initialized slightly differently compared to DT clocks, thus add support for this. Signed-off-by: Tero Kristo <t-kristo@ti.com> Acked-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Michael Turquette <mturquette@linaro.org>
-rw-r--r--drivers/clk/ti/clk.c3
-rw-r--r--drivers/clk/ti/clock.h1
-rw-r--r--drivers/clk/ti/composite.c46
3 files changed, 46 insertions, 4 deletions
diff --git a/drivers/clk/ti/clk.c b/drivers/clk/ti/clk.c
index f41a7576a3ff..546dae405402 100644
--- a/drivers/clk/ti/clk.c
+++ b/drivers/clk/ti/clk.c
@@ -217,6 +217,9 @@ struct clk __init *ti_clk_register_clk(struct ti_clk *setup)
217 case TI_CLK_DIVIDER: 217 case TI_CLK_DIVIDER:
218 clk = ti_clk_register_divider(setup); 218 clk = ti_clk_register_divider(setup);
219 break; 219 break;
220 case TI_CLK_COMPOSITE:
221 clk = ti_clk_register_composite(setup);
222 break;
220 case TI_CLK_FIXED_FACTOR: 223 case TI_CLK_FIXED_FACTOR:
221 fixed_factor = setup->data; 224 fixed_factor = setup->data;
222 225
diff --git a/drivers/clk/ti/clock.h b/drivers/clk/ti/clock.h
index 578b73b2edf1..404158d2d7f8 100644
--- a/drivers/clk/ti/clock.h
+++ b/drivers/clk/ti/clock.h
@@ -158,6 +158,7 @@ struct clk *ti_clk_register_gate(struct ti_clk *setup);
158struct clk *ti_clk_register_interface(struct ti_clk *setup); 158struct clk *ti_clk_register_interface(struct ti_clk *setup);
159struct clk *ti_clk_register_mux(struct ti_clk *setup); 159struct clk *ti_clk_register_mux(struct ti_clk *setup);
160struct clk *ti_clk_register_divider(struct ti_clk *setup); 160struct clk *ti_clk_register_divider(struct ti_clk *setup);
161struct clk *ti_clk_register_composite(struct ti_clk *setup);
161struct clk *ti_clk_register_dpll(struct ti_clk *setup); 162struct clk *ti_clk_register_dpll(struct ti_clk *setup);
162 163
163struct clk_hw *ti_clk_build_component_div(struct ti_clk_divider *setup); 164struct clk_hw *ti_clk_build_component_div(struct ti_clk_divider *setup);
diff --git a/drivers/clk/ti/composite.c b/drivers/clk/ti/composite.c
index 19d8980ba458..3a9665fce041 100644
--- a/drivers/clk/ti/composite.c
+++ b/drivers/clk/ti/composite.c
@@ -23,6 +23,8 @@
23#include <linux/clk/ti.h> 23#include <linux/clk/ti.h>
24#include <linux/list.h> 24#include <linux/list.h>
25 25
26#include "clock.h"
27
26#undef pr_fmt 28#undef pr_fmt
27#define pr_fmt(fmt) "%s: " fmt, __func__ 29#define pr_fmt(fmt) "%s: " fmt, __func__
28 30
@@ -116,8 +118,44 @@ static inline struct clk_hw *_get_hw(struct clk_hw_omap_comp *clk, int idx)
116 118
117#define to_clk_hw_comp(_hw) container_of(_hw, struct clk_hw_omap_comp, hw) 119#define to_clk_hw_comp(_hw) container_of(_hw, struct clk_hw_omap_comp, hw)
118 120
119static void __init ti_clk_register_composite(struct clk_hw *hw, 121struct clk *ti_clk_register_composite(struct ti_clk *setup)
120 struct device_node *node) 122{
123 struct ti_clk_composite *comp;
124 struct clk_hw *gate;
125 struct clk_hw *mux;
126 struct clk_hw *div;
127 int num_parents = 1;
128 const char **parent_names = NULL;
129 struct clk *clk;
130
131 comp = setup->data;
132
133 div = ti_clk_build_component_div(comp->divider);
134 gate = ti_clk_build_component_gate(comp->gate);
135 mux = ti_clk_build_component_mux(comp->mux);
136
137 if (div)
138 parent_names = &comp->divider->parent;
139
140 if (gate)
141 parent_names = &comp->gate->parent;
142
143 if (mux) {
144 num_parents = comp->mux->num_parents;
145 parent_names = comp->mux->parents;
146 }
147
148 clk = clk_register_composite(NULL, setup->name,
149 parent_names, num_parents, mux,
150 &ti_clk_mux_ops, div,
151 &ti_composite_divider_ops, gate,
152 &ti_composite_gate_ops, 0);
153
154 return clk;
155}
156
157static void __init _register_composite(struct clk_hw *hw,
158 struct device_node *node)
121{ 159{
122 struct clk *clk; 160 struct clk *clk;
123 struct clk_hw_omap_comp *cclk = to_clk_hw_comp(hw); 161 struct clk_hw_omap_comp *cclk = to_clk_hw_comp(hw);
@@ -136,7 +174,7 @@ static void __init ti_clk_register_composite(struct clk_hw *hw,
136 pr_debug("component %s not ready for %s, retry\n", 174 pr_debug("component %s not ready for %s, retry\n",
137 cclk->comp_nodes[i]->name, node->name); 175 cclk->comp_nodes[i]->name, node->name);
138 if (!ti_clk_retry_init(node, hw, 176 if (!ti_clk_retry_init(node, hw,
139 ti_clk_register_composite)) 177 _register_composite))
140 return; 178 return;
141 179
142 goto cleanup; 180 goto cleanup;
@@ -216,7 +254,7 @@ static void __init of_ti_composite_clk_setup(struct device_node *node)
216 for (i = 0; i < num_clks; i++) 254 for (i = 0; i < num_clks; i++)
217 cclk->comp_nodes[i] = _get_component_node(node, i); 255 cclk->comp_nodes[i] = _get_component_node(node, i);
218 256
219 ti_clk_register_composite(&cclk->hw, node); 257 _register_composite(&cclk->hw, node);
220} 258}
221CLK_OF_DECLARE(ti_composite_clock, "ti,composite-clock", 259CLK_OF_DECLARE(ti_composite_clock, "ti,composite-clock",
222 of_ti_composite_clk_setup); 260 of_ti_composite_clk_setup);