diff options
author | Tero Kristo <t-kristo@ti.com> | 2014-12-16 11:20:47 -0500 |
---|---|---|
committer | Michael Turquette <mturquette@linaro.org> | 2015-01-30 13:54:49 -0500 |
commit | 7c18a65cb5295484261274b931dd4a3da88695d2 (patch) | |
tree | 89f6f51c0fba2309cb23f83523a9a86ab6834ab5 /drivers/clk/ti | |
parent | c82f8957b48c628a74bf5dd8ee64e33fc70d7b8f (diff) |
clk: ti: mux: add support for legacy mux 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>
Diffstat (limited to 'drivers/clk/ti')
-rw-r--r-- | drivers/clk/ti/clk.c | 3 | ||||
-rw-r--r-- | drivers/clk/ti/clock.h | 4 | ||||
-rw-r--r-- | drivers/clk/ti/mux.c | 70 |
3 files changed, 75 insertions, 2 deletions
diff --git a/drivers/clk/ti/clk.c b/drivers/clk/ti/clk.c index a8958f1ba8a3..215f681053d0 100644 --- a/drivers/clk/ti/clk.c +++ b/drivers/clk/ti/clk.c | |||
@@ -211,6 +211,9 @@ struct clk __init *ti_clk_register_clk(struct ti_clk *setup) | |||
211 | clk = clk_register_fixed_rate(NULL, setup->name, NULL, | 211 | clk = clk_register_fixed_rate(NULL, setup->name, NULL, |
212 | CLK_IS_ROOT, fixed->frequency); | 212 | CLK_IS_ROOT, fixed->frequency); |
213 | break; | 213 | break; |
214 | case TI_CLK_MUX: | ||
215 | clk = ti_clk_register_mux(setup); | ||
216 | break; | ||
214 | case TI_CLK_FIXED_FACTOR: | 217 | case TI_CLK_FIXED_FACTOR: |
215 | fixed_factor = setup->data; | 218 | fixed_factor = setup->data; |
216 | 219 | ||
diff --git a/drivers/clk/ti/clock.h b/drivers/clk/ti/clock.h index 6ee6c6e43ede..c06bbf4c9f95 100644 --- a/drivers/clk/ti/clock.h +++ b/drivers/clk/ti/clock.h | |||
@@ -153,6 +153,10 @@ struct ti_clk_dpll { | |||
153 | u8 recal_st_bit; | 153 | u8 recal_st_bit; |
154 | }; | 154 | }; |
155 | 155 | ||
156 | struct clk *ti_clk_register_mux(struct ti_clk *setup); | ||
157 | |||
158 | struct clk_hw *ti_clk_build_component_mux(struct ti_clk_mux *setup); | ||
159 | |||
156 | void ti_clk_patch_legacy_clks(struct ti_clk **patch); | 160 | void ti_clk_patch_legacy_clks(struct ti_clk **patch); |
157 | struct clk *ti_clk_register_clk(struct ti_clk *setup); | 161 | struct clk *ti_clk_register_clk(struct ti_clk *setup); |
158 | int ti_clk_register_legacy_clks(struct ti_clk_alias *clks); | 162 | int ti_clk_register_legacy_clks(struct ti_clk_alias *clks); |
diff --git a/drivers/clk/ti/mux.c b/drivers/clk/ti/mux.c index e9d650e51287..728e253606bc 100644 --- a/drivers/clk/ti/mux.c +++ b/drivers/clk/ti/mux.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/of.h> | 21 | #include <linux/of.h> |
22 | #include <linux/of_address.h> | 22 | #include <linux/of_address.h> |
23 | #include <linux/clk/ti.h> | 23 | #include <linux/clk/ti.h> |
24 | #include "clock.h" | ||
24 | 25 | ||
25 | #undef pr_fmt | 26 | #undef pr_fmt |
26 | #define pr_fmt(fmt) "%s: " fmt, __func__ | 27 | #define pr_fmt(fmt) "%s: " fmt, __func__ |
@@ -144,6 +145,39 @@ static struct clk *_register_mux(struct device *dev, const char *name, | |||
144 | return clk; | 145 | return clk; |
145 | } | 146 | } |
146 | 147 | ||
148 | struct clk *ti_clk_register_mux(struct ti_clk *setup) | ||
149 | { | ||
150 | struct ti_clk_mux *mux; | ||
151 | u32 flags; | ||
152 | u8 mux_flags = 0; | ||
153 | struct clk_omap_reg *reg_setup; | ||
154 | u32 reg; | ||
155 | u32 mask; | ||
156 | |||
157 | reg_setup = (struct clk_omap_reg *)® | ||
158 | |||
159 | mux = setup->data; | ||
160 | flags = CLK_SET_RATE_NO_REPARENT; | ||
161 | |||
162 | mask = mux->num_parents; | ||
163 | if (!(mux->flags & CLKF_INDEX_STARTS_AT_ONE)) | ||
164 | mask--; | ||
165 | |||
166 | mask = (1 << fls(mask)) - 1; | ||
167 | reg_setup->index = mux->module; | ||
168 | reg_setup->offset = mux->reg; | ||
169 | |||
170 | if (mux->flags & CLKF_INDEX_STARTS_AT_ONE) | ||
171 | mux_flags |= CLK_MUX_INDEX_ONE; | ||
172 | |||
173 | if (mux->flags & CLKF_SET_RATE_PARENT) | ||
174 | flags |= CLK_SET_RATE_PARENT; | ||
175 | |||
176 | return _register_mux(NULL, setup->name, mux->parents, mux->num_parents, | ||
177 | flags, (void __iomem *)reg, mux->bit_shift, mask, | ||
178 | mux_flags, NULL, NULL); | ||
179 | } | ||
180 | |||
147 | /** | 181 | /** |
148 | * of_mux_clk_setup - Setup function for simple mux rate clock | 182 | * of_mux_clk_setup - Setup function for simple mux rate clock |
149 | * @node: DT node for the clock | 183 | * @node: DT node for the clock |
@@ -194,8 +228,9 @@ static void of_mux_clk_setup(struct device_node *node) | |||
194 | 228 | ||
195 | mask = (1 << fls(mask)) - 1; | 229 | mask = (1 << fls(mask)) - 1; |
196 | 230 | ||
197 | clk = _register_mux(NULL, node->name, parent_names, num_parents, flags, | 231 | clk = _register_mux(NULL, node->name, parent_names, num_parents, |
198 | reg, shift, mask, clk_mux_flags, NULL, NULL); | 232 | flags, reg, shift, mask, clk_mux_flags, NULL, |
233 | NULL); | ||
199 | 234 | ||
200 | if (!IS_ERR(clk)) | 235 | if (!IS_ERR(clk)) |
201 | of_clk_add_provider(node, of_clk_src_simple_get, clk); | 236 | of_clk_add_provider(node, of_clk_src_simple_get, clk); |
@@ -205,6 +240,37 @@ cleanup: | |||
205 | } | 240 | } |
206 | CLK_OF_DECLARE(mux_clk, "ti,mux-clock", of_mux_clk_setup); | 241 | CLK_OF_DECLARE(mux_clk, "ti,mux-clock", of_mux_clk_setup); |
207 | 242 | ||
243 | struct clk_hw *ti_clk_build_component_mux(struct ti_clk_mux *setup) | ||
244 | { | ||
245 | struct clk_mux *mux; | ||
246 | struct clk_omap_reg *reg; | ||
247 | int num_parents; | ||
248 | |||
249 | if (!setup) | ||
250 | return NULL; | ||
251 | |||
252 | mux = kzalloc(sizeof(*mux), GFP_KERNEL); | ||
253 | if (!mux) | ||
254 | return ERR_PTR(-ENOMEM); | ||
255 | |||
256 | reg = (struct clk_omap_reg *)&mux->reg; | ||
257 | |||
258 | mux->shift = setup->bit_shift; | ||
259 | |||
260 | reg->index = setup->module; | ||
261 | reg->offset = setup->reg; | ||
262 | |||
263 | if (setup->flags & CLKF_INDEX_STARTS_AT_ONE) | ||
264 | mux->flags |= CLK_MUX_INDEX_ONE; | ||
265 | |||
266 | num_parents = setup->num_parents; | ||
267 | |||
268 | mux->mask = num_parents - 1; | ||
269 | mux->mask = (1 << fls(mux->mask)) - 1; | ||
270 | |||
271 | return &mux->hw; | ||
272 | } | ||
273 | |||
208 | static void __init of_ti_composite_mux_clk_setup(struct device_node *node) | 274 | static void __init of_ti_composite_mux_clk_setup(struct device_node *node) |
209 | { | 275 | { |
210 | struct clk_mux *mux; | 276 | struct clk_mux *mux; |