diff options
author | Mike Turquette <mturquette@linaro.org> | 2012-11-10 18:58:41 -0500 |
---|---|---|
committer | Paul Walmsley <paul@pwsan.com> | 2012-11-12 15:55:50 -0500 |
commit | 32cc002116b866151ca24c6e9110ba8a93754753 (patch) | |
tree | 4a7d3f08bf774ed72d37bd0de541d9dac5e3083e /arch/arm | |
parent | f5dd3bb53ca45f3b47c6889e5920c562f5a37359 (diff) |
ARM: OMAP4: clock: Convert to common clk
Convert all OMAP4 specific platform files to use COMMON clk
and keep all the changes under the CONFIG_COMMON_CLK macro check
so it does not break any existing code. At a later point switch
to COMMON clk and get rid of all old/legacy code.
This converts all apis which will be called directly from COMMON
clk to take a struct clk_hw parameter, and all the internal platform
apis to take a struct clk_hw_omap parameter.
Changes are based off the original patch from Mike Turquette.
Signed-off-by: Rajendra Nayak <rnayak@ti.com>
[paul@pwsan.com: created new omap2_clksel_find_parent_index() rather than
modifying omap2_init_clksel_parent(); moved clkhwops_iclk_wait to
clkt_iclk.c to fix OMAP4-only builds; added clk-provider.h include to clock.h
to try to fix some 3430-builds]
[mturquette@ti.com: squash patch for omap2_clkops_{en,dis}able_clkdm;
omap2_dflt_clk_is_enabled should not enable clocks]
Signed-off-by: Mike Turquette <mturquette@ti.com>
[paul@pwsan.com: fix compiler warning; update to apply; added kerneldoc on
non-trivial new functions; added the dpll3xxx clockdomain modifications]
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/mach-omap2/clkt_clksel.c | 184 | ||||
-rw-r--r-- | arch/arm/mach-omap2/clkt_dpll.c | 54 | ||||
-rw-r--r-- | arch/arm/mach-omap2/clkt_iclk.c | 14 | ||||
-rw-r--r-- | arch/arm/mach-omap2/clock.c | 294 | ||||
-rw-r--r-- | arch/arm/mach-omap2/clock.h | 77 | ||||
-rw-r--r-- | arch/arm/mach-omap2/dpll3xxx.c | 226 | ||||
-rw-r--r-- | arch/arm/mach-omap2/dpll44xx.c | 38 |
7 files changed, 868 insertions, 19 deletions
diff --git a/arch/arm/mach-omap2/clkt_clksel.c b/arch/arm/mach-omap2/clkt_clksel.c index 53646facda45..03ceb2efd532 100644 --- a/arch/arm/mach-omap2/clkt_clksel.c +++ b/arch/arm/mach-omap2/clkt_clksel.c | |||
@@ -41,7 +41,11 @@ | |||
41 | 41 | ||
42 | #include <linux/kernel.h> | 42 | #include <linux/kernel.h> |
43 | #include <linux/errno.h> | 43 | #include <linux/errno.h> |
44 | #ifdef CONFIG_COMMON_CLK | ||
45 | #include <linux/clk-provider.h> | ||
46 | #else | ||
44 | #include <linux/clk.h> | 47 | #include <linux/clk.h> |
48 | #endif | ||
45 | #include <linux/io.h> | 49 | #include <linux/io.h> |
46 | #include <linux/bug.h> | 50 | #include <linux/bug.h> |
47 | 51 | ||
@@ -58,11 +62,18 @@ | |||
58 | * the element associated with the supplied parent clock address. | 62 | * the element associated with the supplied parent clock address. |
59 | * Returns a pointer to the struct clksel on success or NULL on error. | 63 | * Returns a pointer to the struct clksel on success or NULL on error. |
60 | */ | 64 | */ |
65 | #ifdef CONFIG_COMMON_CLK | ||
66 | static const struct clksel *_get_clksel_by_parent(struct clk_hw_omap *clk, | ||
67 | #else | ||
61 | static const struct clksel *_get_clksel_by_parent(struct clk *clk, | 68 | static const struct clksel *_get_clksel_by_parent(struct clk *clk, |
69 | #endif | ||
62 | struct clk *src_clk) | 70 | struct clk *src_clk) |
63 | { | 71 | { |
64 | const struct clksel *clks; | 72 | const struct clksel *clks; |
65 | 73 | ||
74 | if (!src_clk) | ||
75 | return NULL; | ||
76 | |||
66 | for (clks = clk->clksel; clks->parent; clks++) | 77 | for (clks = clk->clksel; clks->parent; clks++) |
67 | if (clks->parent == src_clk) | 78 | if (clks->parent == src_clk) |
68 | break; /* Found the requested parent */ | 79 | break; /* Found the requested parent */ |
@@ -70,7 +81,11 @@ static const struct clksel *_get_clksel_by_parent(struct clk *clk, | |||
70 | if (!clks->parent) { | 81 | if (!clks->parent) { |
71 | /* This indicates a data problem */ | 82 | /* This indicates a data problem */ |
72 | WARN(1, "clock: %s: could not find parent clock %s in clksel array\n", | 83 | WARN(1, "clock: %s: could not find parent clock %s in clksel array\n", |
84 | #ifdef CONFIG_COMMON_CLK | ||
85 | __clk_get_name(clk->hw.clk), __clk_get_name(src_clk)); | ||
86 | #else | ||
73 | __clk_get_name(clk), __clk_get_name(src_clk)); | 87 | __clk_get_name(clk), __clk_get_name(src_clk)); |
88 | #endif | ||
74 | return NULL; | 89 | return NULL; |
75 | } | 90 | } |
76 | 91 | ||
@@ -92,6 +107,7 @@ static const struct clksel *_get_clksel_by_parent(struct clk *clk, | |||
92 | * success (in this latter case, the corresponding register bitfield | 107 | * success (in this latter case, the corresponding register bitfield |
93 | * value is passed back in the variable pointed to by @field_val) | 108 | * value is passed back in the variable pointed to by @field_val) |
94 | */ | 109 | */ |
110 | #ifndef CONFIG_COMMON_CLK | ||
95 | static u8 _get_div_and_fieldval(struct clk *src_clk, struct clk *clk, | 111 | static u8 _get_div_and_fieldval(struct clk *src_clk, struct clk *clk, |
96 | u32 *field_val) | 112 | u32 *field_val) |
97 | { | 113 | { |
@@ -134,6 +150,7 @@ static u8 _get_div_and_fieldval(struct clk *src_clk, struct clk *clk, | |||
134 | 150 | ||
135 | return max_div; | 151 | return max_div; |
136 | } | 152 | } |
153 | #endif | ||
137 | 154 | ||
138 | /** | 155 | /** |
139 | * _write_clksel_reg() - program a clock's clksel register in hardware | 156 | * _write_clksel_reg() - program a clock's clksel register in hardware |
@@ -148,7 +165,11 @@ static u8 _get_div_and_fieldval(struct clk *src_clk, struct clk *clk, | |||
148 | * take into account any time the hardware might take to switch the | 165 | * take into account any time the hardware might take to switch the |
149 | * clock source. | 166 | * clock source. |
150 | */ | 167 | */ |
168 | #ifdef CONFIG_COMMON_CLK | ||
169 | static void _write_clksel_reg(struct clk_hw_omap *clk, u32 field_val) | ||
170 | #else | ||
151 | static void _write_clksel_reg(struct clk *clk, u32 field_val) | 171 | static void _write_clksel_reg(struct clk *clk, u32 field_val) |
172 | #endif | ||
152 | { | 173 | { |
153 | u32 v; | 174 | u32 v; |
154 | 175 | ||
@@ -171,13 +192,22 @@ static void _write_clksel_reg(struct clk *clk, u32 field_val) | |||
171 | * before calling. Returns 0 on error or returns the actual integer divisor | 192 | * before calling. Returns 0 on error or returns the actual integer divisor |
172 | * upon success. | 193 | * upon success. |
173 | */ | 194 | */ |
195 | #ifdef CONFIG_COMMON_CLK | ||
196 | static u32 _clksel_to_divisor(struct clk_hw_omap *clk, u32 field_val) | ||
197 | #else | ||
174 | static u32 _clksel_to_divisor(struct clk *clk, u32 field_val) | 198 | static u32 _clksel_to_divisor(struct clk *clk, u32 field_val) |
199 | #endif | ||
175 | { | 200 | { |
176 | const struct clksel *clks; | 201 | const struct clksel *clks; |
177 | const struct clksel_rate *clkr; | 202 | const struct clksel_rate *clkr; |
178 | struct clk *parent; | 203 | struct clk *parent; |
179 | 204 | ||
205 | #ifdef CONFIG_COMMON_CLK | ||
206 | parent = __clk_get_parent(clk->hw.clk); | ||
207 | #else | ||
180 | parent = __clk_get_parent(clk); | 208 | parent = __clk_get_parent(clk); |
209 | #endif | ||
210 | |||
181 | clks = _get_clksel_by_parent(clk, parent); | 211 | clks = _get_clksel_by_parent(clk, parent); |
182 | if (!clks) | 212 | if (!clks) |
183 | return 0; | 213 | return 0; |
@@ -193,7 +223,12 @@ static u32 _clksel_to_divisor(struct clk *clk, u32 field_val) | |||
193 | if (!clkr->div) { | 223 | if (!clkr->div) { |
194 | /* This indicates a data error */ | 224 | /* This indicates a data error */ |
195 | WARN(1, "clock: %s: could not find fieldval %d for parent %s\n", | 225 | WARN(1, "clock: %s: could not find fieldval %d for parent %s\n", |
226 | #ifdef CONFIG_COMMON_CLK | ||
227 | __clk_get_name(clk->hw.clk), field_val, | ||
228 | __clk_get_name(parent)); | ||
229 | #else | ||
196 | __clk_get_name(clk), field_val, __clk_get_name(parent)); | 230 | __clk_get_name(clk), field_val, __clk_get_name(parent)); |
231 | #endif | ||
197 | return 0; | 232 | return 0; |
198 | } | 233 | } |
199 | 234 | ||
@@ -210,7 +245,11 @@ static u32 _clksel_to_divisor(struct clk *clk, u32 field_val) | |||
210 | * register field value _before_ left-shifting (i.e., LSB is at bit | 245 | * register field value _before_ left-shifting (i.e., LSB is at bit |
211 | * 0); or returns 0xFFFFFFFF (~0) upon error. | 246 | * 0); or returns 0xFFFFFFFF (~0) upon error. |
212 | */ | 247 | */ |
248 | #ifdef CONFIG_COMMON_CLK | ||
249 | static u32 _divisor_to_clksel(struct clk_hw_omap *clk, u32 div) | ||
250 | #else | ||
213 | static u32 _divisor_to_clksel(struct clk *clk, u32 div) | 251 | static u32 _divisor_to_clksel(struct clk *clk, u32 div) |
252 | #endif | ||
214 | { | 253 | { |
215 | const struct clksel *clks; | 254 | const struct clksel *clks; |
216 | const struct clksel_rate *clkr; | 255 | const struct clksel_rate *clkr; |
@@ -219,7 +258,11 @@ static u32 _divisor_to_clksel(struct clk *clk, u32 div) | |||
219 | /* should never happen */ | 258 | /* should never happen */ |
220 | WARN_ON(div == 0); | 259 | WARN_ON(div == 0); |
221 | 260 | ||
261 | #ifdef CONFIG_COMMON_CLK | ||
262 | parent = __clk_get_parent(clk->hw.clk); | ||
263 | #else | ||
222 | parent = __clk_get_parent(clk); | 264 | parent = __clk_get_parent(clk); |
265 | #endif | ||
223 | clks = _get_clksel_by_parent(clk, parent); | 266 | clks = _get_clksel_by_parent(clk, parent); |
224 | if (!clks) | 267 | if (!clks) |
225 | return ~0; | 268 | return ~0; |
@@ -234,7 +277,12 @@ static u32 _divisor_to_clksel(struct clk *clk, u32 div) | |||
234 | 277 | ||
235 | if (!clkr->div) { | 278 | if (!clkr->div) { |
236 | pr_err("clock: %s: could not find divisor %d for parent %s\n", | 279 | pr_err("clock: %s: could not find divisor %d for parent %s\n", |
280 | #ifdef CONFIG_COMMON_CLK | ||
281 | __clk_get_name(clk->hw.clk), div, | ||
282 | __clk_get_name(parent)); | ||
283 | #else | ||
237 | __clk_get_name(clk), div, __clk_get_name(parent)); | 284 | __clk_get_name(clk), div, __clk_get_name(parent)); |
285 | #endif | ||
238 | return ~0; | 286 | return ~0; |
239 | } | 287 | } |
240 | 288 | ||
@@ -249,7 +297,11 @@ static u32 _divisor_to_clksel(struct clk *clk, u32 div) | |||
249 | * into the hardware, convert it into the actual divisor value, and | 297 | * into the hardware, convert it into the actual divisor value, and |
250 | * return it; or return 0 on error. | 298 | * return it; or return 0 on error. |
251 | */ | 299 | */ |
300 | #ifdef CONFIG_COMMON_CLK | ||
301 | static u32 _read_divisor(struct clk_hw_omap *clk) | ||
302 | #else | ||
252 | static u32 _read_divisor(struct clk *clk) | 303 | static u32 _read_divisor(struct clk *clk) |
304 | #endif | ||
253 | { | 305 | { |
254 | u32 v; | 306 | u32 v; |
255 | 307 | ||
@@ -277,7 +329,12 @@ static u32 _read_divisor(struct clk *clk) | |||
277 | * | 329 | * |
278 | * Returns the rounded clock rate or returns 0xffffffff on error. | 330 | * Returns the rounded clock rate or returns 0xffffffff on error. |
279 | */ | 331 | */ |
332 | #ifdef CONFIG_COMMON_CLK | ||
333 | u32 omap2_clksel_round_rate_div(struct clk_hw_omap *clk, | ||
334 | unsigned long target_rate, | ||
335 | #else | ||
280 | u32 omap2_clksel_round_rate_div(struct clk *clk, unsigned long target_rate, | 336 | u32 omap2_clksel_round_rate_div(struct clk *clk, unsigned long target_rate, |
337 | #endif | ||
281 | u32 *new_div) | 338 | u32 *new_div) |
282 | { | 339 | { |
283 | unsigned long test_rate; | 340 | unsigned long test_rate; |
@@ -288,9 +345,14 @@ u32 omap2_clksel_round_rate_div(struct clk *clk, unsigned long target_rate, | |||
288 | unsigned long parent_rate; | 345 | unsigned long parent_rate; |
289 | const char *clk_name; | 346 | const char *clk_name; |
290 | 347 | ||
348 | #ifdef CONFIG_COMMON_CLK | ||
349 | parent = __clk_get_parent(clk->hw.clk); | ||
350 | clk_name = __clk_get_name(clk->hw.clk); | ||
351 | #else | ||
291 | parent = __clk_get_parent(clk); | 352 | parent = __clk_get_parent(clk); |
292 | parent_rate = __clk_get_rate(parent); | ||
293 | clk_name = __clk_get_name(clk); | 353 | clk_name = __clk_get_name(clk); |
354 | #endif | ||
355 | parent_rate = __clk_get_rate(parent); | ||
294 | 356 | ||
295 | if (!clk->clksel || !clk->clksel_mask) | 357 | if (!clk->clksel || !clk->clksel_mask) |
296 | return ~0; | 358 | return ~0; |
@@ -340,6 +402,63 @@ u32 omap2_clksel_round_rate_div(struct clk *clk, unsigned long target_rate, | |||
340 | * (i.e., those used in struct clk field function pointers, etc.) | 402 | * (i.e., those used in struct clk field function pointers, etc.) |
341 | */ | 403 | */ |
342 | 404 | ||
405 | #ifdef CONFIG_COMMON_CLK | ||
406 | /** | ||
407 | * omap2_clksel_find_parent_index() - return the array index of the current | ||
408 | * hardware parent of @hw | ||
409 | * @hw: struct clk_hw * to find the current hardware parent of | ||
410 | * | ||
411 | * Given a struct clk_hw pointer @hw to the 'hw' member of a struct | ||
412 | * clk_hw_omap record representing a source-selectable hardware clock, | ||
413 | * read the hardware register and determine what its parent is | ||
414 | * currently set to. Intended to be called only by the common clock | ||
415 | * framework struct clk_hw_ops.get_parent function pointer. Return | ||
416 | * the array index of this parent clock upon success -- there is no | ||
417 | * way to return an error, so if we encounter an error, just WARN() | ||
418 | * and pretend that we know that we're doing. | ||
419 | */ | ||
420 | u8 omap2_clksel_find_parent_index(struct clk_hw *hw) | ||
421 | { | ||
422 | struct clk_hw_omap *clk = to_clk_hw_omap(hw); | ||
423 | const struct clksel *clks; | ||
424 | const struct clksel_rate *clkr; | ||
425 | u32 r, found = 0; | ||
426 | struct clk *parent; | ||
427 | const char *clk_name; | ||
428 | int ret = 0, f = 0; | ||
429 | |||
430 | parent = __clk_get_parent(hw->clk); | ||
431 | clk_name = __clk_get_name(hw->clk); | ||
432 | |||
433 | /* XXX should be able to return an error */ | ||
434 | WARN((!clk->clksel || !clk->clksel_mask), | ||
435 | "clock: %s: attempt to call on a non-clksel clock", clk_name); | ||
436 | |||
437 | r = __raw_readl(clk->clksel_reg) & clk->clksel_mask; | ||
438 | r >>= __ffs(clk->clksel_mask); | ||
439 | |||
440 | for (clks = clk->clksel; clks->parent && !found; clks++) { | ||
441 | for (clkr = clks->rates; clkr->div && !found; clkr++) { | ||
442 | if (!(clkr->flags & cpu_mask)) | ||
443 | continue; | ||
444 | |||
445 | if (clkr->val == r) { | ||
446 | found = 1; | ||
447 | ret = f; | ||
448 | } | ||
449 | } | ||
450 | f++; | ||
451 | } | ||
452 | |||
453 | /* This indicates a data error */ | ||
454 | WARN(!found, "clock: %s: init parent: could not find regval %0x\n", | ||
455 | clk_name, r); | ||
456 | |||
457 | return ret; | ||
458 | } | ||
459 | |||
460 | #else | ||
461 | |||
343 | /** | 462 | /** |
344 | * omap2_init_clksel_parent() - set a clksel clk's parent field from the hdwr | 463 | * omap2_init_clksel_parent() - set a clksel clk's parent field from the hdwr |
345 | * @clk: OMAP clock struct ptr to use | 464 | * @clk: OMAP clock struct ptr to use |
@@ -393,6 +512,8 @@ void omap2_init_clksel_parent(struct clk *clk) | |||
393 | return; | 512 | return; |
394 | } | 513 | } |
395 | 514 | ||
515 | #endif | ||
516 | |||
396 | /** | 517 | /** |
397 | * omap2_clksel_recalc() - function ptr to pass via struct clk .recalc field | 518 | * omap2_clksel_recalc() - function ptr to pass via struct clk .recalc field |
398 | * @clk: struct clk * | 519 | * @clk: struct clk * |
@@ -402,6 +523,28 @@ void omap2_init_clksel_parent(struct clk *clk) | |||
402 | * function. Returns the clock's current rate, based on its parent's rate | 523 | * function. Returns the clock's current rate, based on its parent's rate |
403 | * and its current divisor setting in the hardware. | 524 | * and its current divisor setting in the hardware. |
404 | */ | 525 | */ |
526 | #ifdef CONFIG_COMMON_CLK | ||
527 | unsigned long omap2_clksel_recalc(struct clk_hw *hw, unsigned long parent_rate) | ||
528 | { | ||
529 | unsigned long rate; | ||
530 | u32 div = 0; | ||
531 | struct clk_hw_omap *clk = to_clk_hw_omap(hw); | ||
532 | |||
533 | if (!parent_rate) | ||
534 | return 0; | ||
535 | |||
536 | div = _read_divisor(clk); | ||
537 | if (!div) | ||
538 | rate = parent_rate; | ||
539 | else | ||
540 | rate = parent_rate / div; | ||
541 | |||
542 | pr_debug("%s: recalc'd %s's rate to %lu (div %d)\n", __func__, | ||
543 | __clk_get_name(hw->clk), rate, div); | ||
544 | |||
545 | return rate; | ||
546 | } | ||
547 | #else | ||
405 | unsigned long omap2_clksel_recalc(struct clk *clk) | 548 | unsigned long omap2_clksel_recalc(struct clk *clk) |
406 | { | 549 | { |
407 | unsigned long rate; | 550 | unsigned long rate; |
@@ -420,6 +563,7 @@ unsigned long omap2_clksel_recalc(struct clk *clk) | |||
420 | 563 | ||
421 | return rate; | 564 | return rate; |
422 | } | 565 | } |
566 | #endif | ||
423 | 567 | ||
424 | /** | 568 | /** |
425 | * omap2_clksel_round_rate() - find rounded rate for the given clock and rate | 569 | * omap2_clksel_round_rate() - find rounded rate for the given clock and rate |
@@ -432,8 +576,15 @@ unsigned long omap2_clksel_recalc(struct clk *clk) | |||
432 | * | 576 | * |
433 | * Returns the rounded clock rate or returns 0xffffffff on error. | 577 | * Returns the rounded clock rate or returns 0xffffffff on error. |
434 | */ | 578 | */ |
579 | #ifdef CONFIG_COMMON_CLK | ||
580 | long omap2_clksel_round_rate(struct clk_hw *hw, unsigned long target_rate, | ||
581 | unsigned long *parent_rate) | ||
582 | { | ||
583 | struct clk_hw_omap *clk = to_clk_hw_omap(hw); | ||
584 | #else | ||
435 | long omap2_clksel_round_rate(struct clk *clk, unsigned long target_rate) | 585 | long omap2_clksel_round_rate(struct clk *clk, unsigned long target_rate) |
436 | { | 586 | { |
587 | #endif | ||
437 | u32 new_div; | 588 | u32 new_div; |
438 | 589 | ||
439 | return omap2_clksel_round_rate_div(clk, target_rate, &new_div); | 590 | return omap2_clksel_round_rate_div(clk, target_rate, &new_div); |
@@ -454,8 +605,15 @@ long omap2_clksel_round_rate(struct clk *clk, unsigned long target_rate) | |||
454 | * is changed, they will all be affected without any notification. | 605 | * is changed, they will all be affected without any notification. |
455 | * Returns -EINVAL upon error, or 0 upon success. | 606 | * Returns -EINVAL upon error, or 0 upon success. |
456 | */ | 607 | */ |
608 | #ifdef CONFIG_COMMON_CLK | ||
609 | int omap2_clksel_set_rate(struct clk_hw *hw, unsigned long rate, | ||
610 | unsigned long parent_rate) | ||
611 | { | ||
612 | struct clk_hw_omap *clk = to_clk_hw_omap(hw); | ||
613 | #else | ||
457 | int omap2_clksel_set_rate(struct clk *clk, unsigned long rate) | 614 | int omap2_clksel_set_rate(struct clk *clk, unsigned long rate) |
458 | { | 615 | { |
616 | #endif | ||
459 | u32 field_val, validrate, new_div = 0; | 617 | u32 field_val, validrate, new_div = 0; |
460 | 618 | ||
461 | if (!clk->clksel || !clk->clksel_mask) | 619 | if (!clk->clksel || !clk->clksel_mask) |
@@ -471,11 +629,16 @@ int omap2_clksel_set_rate(struct clk *clk, unsigned long rate) | |||
471 | 629 | ||
472 | _write_clksel_reg(clk, field_val); | 630 | _write_clksel_reg(clk, field_val); |
473 | 631 | ||
474 | clk->rate = __clk_get_rate(__clk_get_parent(clk)) / new_div; | 632 | #ifdef CONFIG_COMMON_CLK |
475 | 633 | pr_debug("clock: %s: set rate to %ld\n", __clk_get_name(hw->clk), | |
634 | __clk_get_rate(hw->clk)); | ||
635 | #else | ||
476 | pr_debug("clock: %s: set rate to %ld\n", __clk_get_name(clk), | 636 | pr_debug("clock: %s: set rate to %ld\n", __clk_get_name(clk), |
477 | __clk_get_rate(clk)); | 637 | __clk_get_rate(clk)); |
478 | 638 | ||
639 | clk->rate = __clk_get_rate(__clk_get_parent(clk)) / new_div; | ||
640 | #endif | ||
641 | |||
479 | return 0; | 642 | return 0; |
480 | } | 643 | } |
481 | 644 | ||
@@ -499,6 +662,18 @@ int omap2_clksel_set_rate(struct clk *clk, unsigned long rate) | |||
499 | * affected without any notification. Returns -EINVAL upon error, or | 662 | * affected without any notification. Returns -EINVAL upon error, or |
500 | * 0 upon success. | 663 | * 0 upon success. |
501 | */ | 664 | */ |
665 | #ifdef CONFIG_COMMON_CLK | ||
666 | int omap2_clksel_set_parent(struct clk_hw *hw, u8 field_val) | ||
667 | { | ||
668 | struct clk_hw_omap *clk = to_clk_hw_omap(hw); | ||
669 | |||
670 | if (!clk->clksel || !clk->clksel_mask) | ||
671 | return -EINVAL; | ||
672 | |||
673 | _write_clksel_reg(clk, field_val); | ||
674 | return 0; | ||
675 | } | ||
676 | #else | ||
502 | int omap2_clksel_set_parent(struct clk *clk, struct clk *new_parent) | 677 | int omap2_clksel_set_parent(struct clk *clk, struct clk *new_parent) |
503 | { | 678 | { |
504 | u32 field_val = 0; | 679 | u32 field_val = 0; |
@@ -510,7 +685,6 @@ int omap2_clksel_set_parent(struct clk *clk, struct clk *new_parent) | |||
510 | parent_div = _get_div_and_fieldval(new_parent, clk, &field_val); | 685 | parent_div = _get_div_and_fieldval(new_parent, clk, &field_val); |
511 | if (!parent_div) | 686 | if (!parent_div) |
512 | return -EINVAL; | 687 | return -EINVAL; |
513 | |||
514 | _write_clksel_reg(clk, field_val); | 688 | _write_clksel_reg(clk, field_val); |
515 | 689 | ||
516 | clk_reparent(clk, new_parent); | 690 | clk_reparent(clk, new_parent); |
@@ -520,7 +694,6 @@ int omap2_clksel_set_parent(struct clk *clk, struct clk *new_parent) | |||
520 | 694 | ||
521 | if (parent_div > 0) | 695 | if (parent_div > 0) |
522 | __clk_get_rate(clk) /= parent_div; | 696 | __clk_get_rate(clk) /= parent_div; |
523 | |||
524 | pr_debug("clock: %s: set parent to %s (new rate %ld)\n", | 697 | pr_debug("clock: %s: set parent to %s (new rate %ld)\n", |
525 | __clk_get_name(clk), | 698 | __clk_get_name(clk), |
526 | __clk_get_name(__clk_get_parent(clk)), | 699 | __clk_get_name(__clk_get_parent(clk)), |
@@ -528,3 +701,4 @@ int omap2_clksel_set_parent(struct clk *clk, struct clk *new_parent) | |||
528 | 701 | ||
529 | return 0; | 702 | return 0; |
530 | } | 703 | } |
704 | #endif | ||
diff --git a/arch/arm/mach-omap2/clkt_dpll.c b/arch/arm/mach-omap2/clkt_dpll.c index 8463cc356245..f343389fc6e8 100644 --- a/arch/arm/mach-omap2/clkt_dpll.c +++ b/arch/arm/mach-omap2/clkt_dpll.c | |||
@@ -16,7 +16,11 @@ | |||
16 | 16 | ||
17 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
18 | #include <linux/errno.h> | 18 | #include <linux/errno.h> |
19 | #ifdef CONFIG_COMMON_CLK | ||
20 | #include <linux/clk-provider.h> | ||
21 | #else | ||
19 | #include <linux/clk.h> | 22 | #include <linux/clk.h> |
23 | #endif | ||
20 | #include <linux/io.h> | 24 | #include <linux/io.h> |
21 | 25 | ||
22 | #include <asm/div64.h> | 26 | #include <asm/div64.h> |
@@ -76,7 +80,11 @@ | |||
76 | * (assuming that it is counting N upwards), or -2 if the enclosing loop | 80 | * (assuming that it is counting N upwards), or -2 if the enclosing loop |
77 | * should skip to the next iteration (again assuming N is increasing). | 81 | * should skip to the next iteration (again assuming N is increasing). |
78 | */ | 82 | */ |
83 | #ifdef CONFIG_COMMON_CLK | ||
84 | static int _dpll_test_fint(struct clk_hw_omap *clk, u8 n) | ||
85 | #else | ||
79 | static int _dpll_test_fint(struct clk *clk, u8 n) | 86 | static int _dpll_test_fint(struct clk *clk, u8 n) |
87 | #endif | ||
80 | { | 88 | { |
81 | struct dpll_data *dd; | 89 | struct dpll_data *dd; |
82 | long fint, fint_min, fint_max; | 90 | long fint, fint_min, fint_max; |
@@ -85,7 +93,11 @@ static int _dpll_test_fint(struct clk *clk, u8 n) | |||
85 | dd = clk->dpll_data; | 93 | dd = clk->dpll_data; |
86 | 94 | ||
87 | /* DPLL divider must result in a valid jitter correction val */ | 95 | /* DPLL divider must result in a valid jitter correction val */ |
96 | #ifdef CONFIG_COMMON_CLK | ||
97 | fint = __clk_get_rate(__clk_get_parent(clk->hw.clk)) / n; | ||
98 | #else | ||
88 | fint = __clk_get_rate(__clk_get_parent(clk)) / n; | 99 | fint = __clk_get_rate(__clk_get_parent(clk)) / n; |
100 | #endif | ||
89 | 101 | ||
90 | if (cpu_is_omap24xx()) { | 102 | if (cpu_is_omap24xx()) { |
91 | /* Should not be called for OMAP2, so warn if it is called */ | 103 | /* Should not be called for OMAP2, so warn if it is called */ |
@@ -186,15 +198,24 @@ static int _dpll_test_mult(int *m, int n, unsigned long *new_rate, | |||
186 | } | 198 | } |
187 | 199 | ||
188 | /* Public functions */ | 200 | /* Public functions */ |
189 | 201 | #ifdef CONFIG_COMMON_CLK | |
202 | u8 omap2_init_dpll_parent(struct clk_hw *hw) | ||
203 | { | ||
204 | struct clk_hw_omap *clk = to_clk_hw_omap(hw); | ||
205 | #else | ||
190 | void omap2_init_dpll_parent(struct clk *clk) | 206 | void omap2_init_dpll_parent(struct clk *clk) |
191 | { | 207 | { |
208 | #endif | ||
192 | u32 v; | 209 | u32 v; |
193 | struct dpll_data *dd; | 210 | struct dpll_data *dd; |
194 | 211 | ||
195 | dd = clk->dpll_data; | 212 | dd = clk->dpll_data; |
196 | if (!dd) | 213 | if (!dd) |
214 | #ifdef CONFIG_COMMON_CLK | ||
215 | return -EINVAL; | ||
216 | #else | ||
197 | return; | 217 | return; |
218 | #endif | ||
198 | 219 | ||
199 | v = __raw_readl(dd->control_reg); | 220 | v = __raw_readl(dd->control_reg); |
200 | v &= dd->enable_mask; | 221 | v &= dd->enable_mask; |
@@ -204,18 +225,34 @@ void omap2_init_dpll_parent(struct clk *clk) | |||
204 | if (cpu_is_omap24xx()) { | 225 | if (cpu_is_omap24xx()) { |
205 | if (v == OMAP2XXX_EN_DPLL_LPBYPASS || | 226 | if (v == OMAP2XXX_EN_DPLL_LPBYPASS || |
206 | v == OMAP2XXX_EN_DPLL_FRBYPASS) | 227 | v == OMAP2XXX_EN_DPLL_FRBYPASS) |
228 | #ifdef CONFIG_COMMON_CLK | ||
229 | return 1; | ||
230 | #else | ||
207 | clk_reparent(clk, dd->clk_bypass); | 231 | clk_reparent(clk, dd->clk_bypass); |
232 | #endif | ||
208 | } else if (cpu_is_omap34xx()) { | 233 | } else if (cpu_is_omap34xx()) { |
209 | if (v == OMAP3XXX_EN_DPLL_LPBYPASS || | 234 | if (v == OMAP3XXX_EN_DPLL_LPBYPASS || |
210 | v == OMAP3XXX_EN_DPLL_FRBYPASS) | 235 | v == OMAP3XXX_EN_DPLL_FRBYPASS) |
236 | #ifdef CONFIG_COMMON_CLK | ||
237 | return 1; | ||
238 | #else | ||
211 | clk_reparent(clk, dd->clk_bypass); | 239 | clk_reparent(clk, dd->clk_bypass); |
240 | #endif | ||
212 | } else if (soc_is_am33xx() || cpu_is_omap44xx()) { | 241 | } else if (soc_is_am33xx() || cpu_is_omap44xx()) { |
213 | if (v == OMAP4XXX_EN_DPLL_LPBYPASS || | 242 | if (v == OMAP4XXX_EN_DPLL_LPBYPASS || |
214 | v == OMAP4XXX_EN_DPLL_FRBYPASS || | 243 | v == OMAP4XXX_EN_DPLL_FRBYPASS || |
215 | v == OMAP4XXX_EN_DPLL_MNBYPASS) | 244 | v == OMAP4XXX_EN_DPLL_MNBYPASS) |
245 | #ifdef CONFIG_COMMON_CLK | ||
246 | return 1; | ||
247 | #else | ||
216 | clk_reparent(clk, dd->clk_bypass); | 248 | clk_reparent(clk, dd->clk_bypass); |
249 | #endif | ||
217 | } | 250 | } |
251 | #ifdef CONFIG_COMMON_CLK | ||
252 | return 0; | ||
253 | #else | ||
218 | return; | 254 | return; |
255 | #endif | ||
219 | } | 256 | } |
220 | 257 | ||
221 | /** | 258 | /** |
@@ -232,7 +269,11 @@ void omap2_init_dpll_parent(struct clk *clk) | |||
232 | * locked, or the appropriate bypass rate if the DPLL is bypassed, or 0 | 269 | * locked, or the appropriate bypass rate if the DPLL is bypassed, or 0 |
233 | * if the clock @clk is not a DPLL. | 270 | * if the clock @clk is not a DPLL. |
234 | */ | 271 | */ |
272 | #ifdef CONFIG_COMMON_CLK | ||
273 | unsigned long omap2_get_dpll_rate(struct clk_hw_omap *clk) | ||
274 | #else | ||
235 | u32 omap2_get_dpll_rate(struct clk *clk) | 275 | u32 omap2_get_dpll_rate(struct clk *clk) |
276 | #endif | ||
236 | { | 277 | { |
237 | long long dpll_clk; | 278 | long long dpll_clk; |
238 | u32 dpll_mult, dpll_div, v; | 279 | u32 dpll_mult, dpll_div, v; |
@@ -288,8 +329,15 @@ u32 omap2_get_dpll_rate(struct clk *clk) | |||
288 | * (expensive) function again. Returns ~0 if the target rate cannot | 329 | * (expensive) function again. Returns ~0 if the target rate cannot |
289 | * be rounded, or the rounded rate upon success. | 330 | * be rounded, or the rounded rate upon success. |
290 | */ | 331 | */ |
332 | #ifdef CONFIG_COMMON_CLK | ||
333 | long omap2_dpll_round_rate(struct clk_hw *hw, unsigned long target_rate, | ||
334 | unsigned long *parent_rate) | ||
335 | { | ||
336 | struct clk_hw_omap *clk = to_clk_hw_omap(hw); | ||
337 | #else | ||
291 | long omap2_dpll_round_rate(struct clk *clk, unsigned long target_rate) | 338 | long omap2_dpll_round_rate(struct clk *clk, unsigned long target_rate) |
292 | { | 339 | { |
340 | #endif | ||
293 | int m, n, r, scaled_max_m; | 341 | int m, n, r, scaled_max_m; |
294 | unsigned long scaled_rt_rp; | 342 | unsigned long scaled_rt_rp; |
295 | unsigned long new_rate = 0; | 343 | unsigned long new_rate = 0; |
@@ -303,7 +351,11 @@ long omap2_dpll_round_rate(struct clk *clk, unsigned long target_rate) | |||
303 | dd = clk->dpll_data; | 351 | dd = clk->dpll_data; |
304 | 352 | ||
305 | ref_rate = __clk_get_rate(dd->clk_ref); | 353 | ref_rate = __clk_get_rate(dd->clk_ref); |
354 | #ifdef CONFIG_COMMON_CLK | ||
355 | clk_name = __clk_get_name(hw->clk); | ||
356 | #else | ||
306 | clk_name = __clk_get_name(clk); | 357 | clk_name = __clk_get_name(clk); |
358 | #endif | ||
307 | pr_debug("clock: %s: starting DPLL round_rate, target rate %ld\n", | 359 | pr_debug("clock: %s: starting DPLL round_rate, target rate %ld\n", |
308 | clk_name, target_rate); | 360 | clk_name, target_rate); |
309 | 361 | ||
diff --git a/arch/arm/mach-omap2/clkt_iclk.c b/arch/arm/mach-omap2/clkt_iclk.c index fe774a09dd0c..3b661ba73fc2 100644 --- a/arch/arm/mach-omap2/clkt_iclk.c +++ b/arch/arm/mach-omap2/clkt_iclk.c | |||
@@ -11,7 +11,11 @@ | |||
11 | #undef DEBUG | 11 | #undef DEBUG |
12 | 12 | ||
13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
14 | #ifdef CONFIG_COMMON_CLK | ||
15 | #include <linux/clk-provider.h> | ||
16 | #else | ||
14 | #include <linux/clk.h> | 17 | #include <linux/clk.h> |
18 | #endif | ||
15 | #include <linux/io.h> | 19 | #include <linux/io.h> |
16 | 20 | ||
17 | 21 | ||
@@ -48,6 +52,14 @@ void omap2_clkt_iclk_deny_idle(struct clk *clk) | |||
48 | 52 | ||
49 | /* Public data */ | 53 | /* Public data */ |
50 | 54 | ||
55 | #ifdef CONFIG_COMMON_CLK | ||
56 | const struct clk_hw_omap_ops clkhwops_iclk_wait = { | ||
57 | .allow_idle = omap2_clkt_iclk_allow_idle, | ||
58 | .deny_idle = omap2_clkt_iclk_deny_idle, | ||
59 | .find_idlest = omap2_clk_dflt_find_idlest, | ||
60 | .find_companion = omap2_clk_dflt_find_companion, | ||
61 | }; | ||
62 | #else | ||
51 | const struct clkops clkops_omap2_iclk_dflt_wait = { | 63 | const struct clkops clkops_omap2_iclk_dflt_wait = { |
52 | .enable = omap2_dflt_clk_enable, | 64 | .enable = omap2_dflt_clk_enable, |
53 | .disable = omap2_dflt_clk_disable, | 65 | .disable = omap2_dflt_clk_disable, |
@@ -77,4 +89,4 @@ const struct clkops clkops_omap2_mdmclk_dflt_wait = { | |||
77 | .allow_idle = omap2_clkt_iclk_allow_idle, | 89 | .allow_idle = omap2_clkt_iclk_allow_idle, |
78 | .deny_idle = omap2_clkt_iclk_deny_idle, | 90 | .deny_idle = omap2_clkt_iclk_deny_idle, |
79 | }; | 91 | }; |
80 | 92 | #endif | |
diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c index e381d991092c..72d7105b3c7d 100644 --- a/arch/arm/mach-omap2/clock.c +++ b/arch/arm/mach-omap2/clock.c | |||
@@ -20,7 +20,11 @@ | |||
20 | #include <linux/errno.h> | 20 | #include <linux/errno.h> |
21 | #include <linux/err.h> | 21 | #include <linux/err.h> |
22 | #include <linux/delay.h> | 22 | #include <linux/delay.h> |
23 | #ifdef CONFIG_COMMON_CLK | ||
24 | #include <linux/clk-provider.h> | ||
25 | #else | ||
23 | #include <linux/clk.h> | 26 | #include <linux/clk.h> |
27 | #endif | ||
24 | #include <linux/io.h> | 28 | #include <linux/io.h> |
25 | #include <linux/bitops.h> | 29 | #include <linux/bitops.h> |
26 | 30 | ||
@@ -57,7 +61,33 @@ static bool clkdm_control = true; | |||
57 | 61 | ||
58 | static LIST_HEAD(clocks); | 62 | static LIST_HEAD(clocks); |
59 | static DEFINE_MUTEX(clocks_mutex); | 63 | static DEFINE_MUTEX(clocks_mutex); |
64 | #ifndef CONFIG_COMMON_CLK | ||
60 | static DEFINE_SPINLOCK(clockfw_lock); | 65 | static DEFINE_SPINLOCK(clockfw_lock); |
66 | #endif | ||
67 | |||
68 | #ifdef CONFIG_COMMON_CLK | ||
69 | |||
70 | /* | ||
71 | * Used for clocks that have the same value as the parent clock, | ||
72 | * divided by some factor | ||
73 | */ | ||
74 | unsigned long omap_fixed_divisor_recalc(struct clk_hw *hw, | ||
75 | unsigned long parent_rate) | ||
76 | { | ||
77 | struct clk_hw_omap *oclk; | ||
78 | |||
79 | if (!hw) { | ||
80 | pr_warn("%s: hw is NULL\n", __func__); | ||
81 | return -EINVAL; | ||
82 | } | ||
83 | |||
84 | oclk = to_clk_hw_omap(hw); | ||
85 | |||
86 | WARN_ON(!oclk->fixed_div); | ||
87 | |||
88 | return parent_rate / oclk->fixed_div; | ||
89 | } | ||
90 | #endif | ||
61 | 91 | ||
62 | /* | 92 | /* |
63 | * OMAP2+ specific clock functions | 93 | * OMAP2+ specific clock functions |
@@ -109,7 +139,11 @@ static int _wait_idlest_generic(void __iomem *reg, u32 mask, u8 idlest, | |||
109 | * belong in the clock code and will be moved in the medium term to | 139 | * belong in the clock code and will be moved in the medium term to |
110 | * module-dependent code. No return value. | 140 | * module-dependent code. No return value. |
111 | */ | 141 | */ |
142 | #ifdef CONFIG_COMMON_CLK | ||
143 | static void _omap2_module_wait_ready(struct clk_hw_omap *clk) | ||
144 | #else | ||
112 | static void _omap2_module_wait_ready(struct clk *clk) | 145 | static void _omap2_module_wait_ready(struct clk *clk) |
146 | #endif | ||
113 | { | 147 | { |
114 | void __iomem *companion_reg, *idlest_reg; | 148 | void __iomem *companion_reg, *idlest_reg; |
115 | u8 other_bit, idlest_bit, idlest_val, idlest_reg_id; | 149 | u8 other_bit, idlest_bit, idlest_val, idlest_reg_id; |
@@ -124,12 +158,15 @@ static void _omap2_module_wait_ready(struct clk *clk) | |||
124 | } | 158 | } |
125 | 159 | ||
126 | clk->ops->find_idlest(clk, &idlest_reg, &idlest_bit, &idlest_val); | 160 | clk->ops->find_idlest(clk, &idlest_reg, &idlest_bit, &idlest_val); |
127 | |||
128 | r = cm_split_idlest_reg(idlest_reg, &prcm_mod, &idlest_reg_id); | 161 | r = cm_split_idlest_reg(idlest_reg, &prcm_mod, &idlest_reg_id); |
129 | if (r) { | 162 | if (r) { |
130 | /* IDLEST register not in the CM module */ | 163 | /* IDLEST register not in the CM module */ |
131 | _wait_idlest_generic(idlest_reg, (1 << idlest_bit), idlest_val, | 164 | _wait_idlest_generic(idlest_reg, (1 << idlest_bit), idlest_val, |
165 | #ifdef CONFIG_COMMON_CLK | ||
166 | __clk_get_name(clk->hw.clk)); | ||
167 | #else | ||
132 | clk->name); | 168 | clk->name); |
169 | #endif | ||
133 | } else { | 170 | } else { |
134 | cm_wait_module_ready(prcm_mod, idlest_reg_id, idlest_bit); | 171 | cm_wait_module_ready(prcm_mod, idlest_reg_id, idlest_bit); |
135 | }; | 172 | }; |
@@ -145,15 +182,25 @@ static void _omap2_module_wait_ready(struct clk *clk) | |||
145 | * clockdomain pointer, and save it into the struct clk. Intended to be | 182 | * clockdomain pointer, and save it into the struct clk. Intended to be |
146 | * called during clk_register(). No return value. | 183 | * called during clk_register(). No return value. |
147 | */ | 184 | */ |
185 | #ifdef CONFIG_COMMON_CLK | ||
186 | void omap2_init_clk_clkdm(struct clk_hw *hw) | ||
187 | { | ||
188 | struct clk_hw_omap *clk = to_clk_hw_omap(hw); | ||
189 | #else | ||
148 | void omap2_init_clk_clkdm(struct clk *clk) | 190 | void omap2_init_clk_clkdm(struct clk *clk) |
149 | { | 191 | { |
192 | #endif | ||
150 | struct clockdomain *clkdm; | 193 | struct clockdomain *clkdm; |
151 | const char *clk_name; | 194 | const char *clk_name; |
152 | 195 | ||
153 | if (!clk->clkdm_name) | 196 | if (!clk->clkdm_name) |
154 | return; | 197 | return; |
155 | 198 | ||
199 | #ifdef CONFIG_COMMON_CLK | ||
200 | clk_name = __clk_get_name(hw->clk); | ||
201 | #else | ||
156 | clk_name = __clk_get_name(clk); | 202 | clk_name = __clk_get_name(clk); |
203 | #endif | ||
157 | 204 | ||
158 | clkdm = clkdm_lookup(clk->clkdm_name); | 205 | clkdm = clkdm_lookup(clk->clkdm_name); |
159 | if (clkdm) { | 206 | if (clkdm) { |
@@ -200,8 +247,12 @@ void __init omap2_clk_disable_clkdm_control(void) | |||
200 | * associate this type of code with per-module data structures to | 247 | * associate this type of code with per-module data structures to |
201 | * avoid this issue, and remove the casts. No return value. | 248 | * avoid this issue, and remove the casts. No return value. |
202 | */ | 249 | */ |
203 | void omap2_clk_dflt_find_companion(struct clk *clk, void __iomem **other_reg, | 250 | #ifdef CONFIG_COMMON_CLK |
204 | u8 *other_bit) | 251 | void omap2_clk_dflt_find_companion(struct clk_hw_omap *clk, |
252 | #else | ||
253 | void omap2_clk_dflt_find_companion(struct clk *clk, | ||
254 | #endif | ||
255 | void __iomem **other_reg, u8 *other_bit) | ||
205 | { | 256 | { |
206 | u32 r; | 257 | u32 r; |
207 | 258 | ||
@@ -229,8 +280,12 @@ void omap2_clk_dflt_find_companion(struct clk *clk, void __iomem **other_reg, | |||
229 | * register address ID (e.g., that CM_FCLKEN2 corresponds to | 280 | * register address ID (e.g., that CM_FCLKEN2 corresponds to |
230 | * CM_IDLEST2). This is not true for all modules. No return value. | 281 | * CM_IDLEST2). This is not true for all modules. No return value. |
231 | */ | 282 | */ |
232 | void omap2_clk_dflt_find_idlest(struct clk *clk, void __iomem **idlest_reg, | 283 | #ifdef CONFIG_COMMON_CLK |
233 | u8 *idlest_bit, u8 *idlest_val) | 284 | void omap2_clk_dflt_find_idlest(struct clk_hw_omap *clk, |
285 | #else | ||
286 | void omap2_clk_dflt_find_idlest(struct clk *clk, | ||
287 | #endif | ||
288 | void __iomem **idlest_reg, u8 *idlest_bit, u8 *idlest_val) | ||
234 | { | 289 | { |
235 | u32 r; | 290 | u32 r; |
236 | 291 | ||
@@ -252,6 +307,225 @@ void omap2_clk_dflt_find_idlest(struct clk *clk, void __iomem **idlest_reg, | |||
252 | 307 | ||
253 | } | 308 | } |
254 | 309 | ||
310 | #ifdef CONFIG_COMMON_CLK | ||
311 | /** | ||
312 | * omap2_dflt_clk_enable - enable a clock in the hardware | ||
313 | * @hw: struct clk_hw * of the clock to enable | ||
314 | * | ||
315 | * Enable the clock @hw in the hardware. We first call into the OMAP | ||
316 | * clockdomain code to "enable" the corresponding clockdomain if this | ||
317 | * is the first enabled user of the clockdomain. Then program the | ||
318 | * hardware to enable the clock. Then wait for the IP block that uses | ||
319 | * this clock to leave idle (if applicable). Returns the error value | ||
320 | * from clkdm_clk_enable() if it terminated with an error, or -EINVAL | ||
321 | * if @hw has a null clock enable_reg, or zero upon success. | ||
322 | */ | ||
323 | int omap2_dflt_clk_enable(struct clk_hw *hw) | ||
324 | { | ||
325 | struct clk_hw_omap *clk; | ||
326 | u32 v; | ||
327 | int ret = 0; | ||
328 | |||
329 | clk = to_clk_hw_omap(hw); | ||
330 | |||
331 | if (clkdm_control && clk->clkdm) { | ||
332 | ret = clkdm_clk_enable(clk->clkdm, hw->clk); | ||
333 | if (ret) { | ||
334 | WARN(1, "%s: could not enable %s's clockdomain %s: %d\n", | ||
335 | __func__, __clk_get_name(hw->clk), | ||
336 | clk->clkdm->name, ret); | ||
337 | return ret; | ||
338 | } | ||
339 | } | ||
340 | |||
341 | if (unlikely(clk->enable_reg == NULL)) { | ||
342 | pr_err("%s: %s missing enable_reg\n", __func__, | ||
343 | __clk_get_name(hw->clk)); | ||
344 | ret = -EINVAL; | ||
345 | goto err; | ||
346 | } | ||
347 | |||
348 | /* FIXME should not have INVERT_ENABLE bit here */ | ||
349 | v = __raw_readl(clk->enable_reg); | ||
350 | if (clk->flags & INVERT_ENABLE) | ||
351 | v &= ~(1 << clk->enable_bit); | ||
352 | else | ||
353 | v |= (1 << clk->enable_bit); | ||
354 | __raw_writel(v, clk->enable_reg); | ||
355 | v = __raw_readl(clk->enable_reg); /* OCP barrier */ | ||
356 | |||
357 | if (clk->ops && clk->ops->find_idlest) | ||
358 | _omap2_module_wait_ready(clk); | ||
359 | |||
360 | return 0; | ||
361 | |||
362 | err: | ||
363 | if (clkdm_control && clk->clkdm) | ||
364 | clkdm_clk_disable(clk->clkdm, hw->clk); | ||
365 | return ret; | ||
366 | } | ||
367 | |||
368 | /** | ||
369 | * omap2_dflt_clk_disable - disable a clock in the hardware | ||
370 | * @hw: struct clk_hw * of the clock to disable | ||
371 | * | ||
372 | * Disable the clock @hw in the hardware, and call into the OMAP | ||
373 | * clockdomain code to "disable" the corresponding clockdomain if all | ||
374 | * clocks/hwmods in that clockdomain are now disabled. No return | ||
375 | * value. | ||
376 | */ | ||
377 | void omap2_dflt_clk_disable(struct clk_hw *hw) | ||
378 | { | ||
379 | struct clk_hw_omap *clk; | ||
380 | u32 v; | ||
381 | |||
382 | clk = to_clk_hw_omap(hw); | ||
383 | if (!clk->enable_reg) { | ||
384 | /* | ||
385 | * 'independent' here refers to a clock which is not | ||
386 | * controlled by its parent. | ||
387 | */ | ||
388 | pr_err("%s: independent clock %s has no enable_reg\n", | ||
389 | __func__, __clk_get_name(hw->clk)); | ||
390 | return; | ||
391 | } | ||
392 | |||
393 | v = __raw_readl(clk->enable_reg); | ||
394 | if (clk->flags & INVERT_ENABLE) | ||
395 | v |= (1 << clk->enable_bit); | ||
396 | else | ||
397 | v &= ~(1 << clk->enable_bit); | ||
398 | __raw_writel(v, clk->enable_reg); | ||
399 | /* No OCP barrier needed here since it is a disable operation */ | ||
400 | |||
401 | if (clkdm_control && clk->clkdm) | ||
402 | clkdm_clk_disable(clk->clkdm, hw->clk); | ||
403 | } | ||
404 | |||
405 | /** | ||
406 | * omap2_clkops_enable_clkdm - increment usecount on clkdm of @hw | ||
407 | * @hw: struct clk_hw * of the clock being enabled | ||
408 | * | ||
409 | * Increment the usecount of the clockdomain of the clock pointed to | ||
410 | * by @hw; if the usecount is 1, the clockdomain will be "enabled." | ||
411 | * Only needed for clocks that don't use omap2_dflt_clk_enable() as | ||
412 | * their enable function pointer. Passes along the return value of | ||
413 | * clkdm_clk_enable(), -EINVAL if @hw is not associated with a | ||
414 | * clockdomain, or 0 if clock framework-based clockdomain control is | ||
415 | * not implemented. | ||
416 | */ | ||
417 | int omap2_clkops_enable_clkdm(struct clk_hw *hw) | ||
418 | { | ||
419 | struct clk_hw_omap *clk; | ||
420 | int ret = 0; | ||
421 | |||
422 | clk = to_clk_hw_omap(hw); | ||
423 | |||
424 | if (unlikely(!clk->clkdm)) { | ||
425 | pr_err("%s: %s: no clkdm set ?!\n", __func__, | ||
426 | __clk_get_name(hw->clk)); | ||
427 | return -EINVAL; | ||
428 | } | ||
429 | |||
430 | if (unlikely(clk->enable_reg)) | ||
431 | pr_err("%s: %s: should use dflt_clk_enable ?!\n", __func__, | ||
432 | __clk_get_name(hw->clk)); | ||
433 | |||
434 | if (!clkdm_control) { | ||
435 | pr_err("%s: %s: clkfw-based clockdomain control disabled ?!\n", | ||
436 | __func__, __clk_get_name(hw->clk)); | ||
437 | return 0; | ||
438 | } | ||
439 | |||
440 | ret = clkdm_clk_enable(clk->clkdm, hw->clk); | ||
441 | WARN(ret, "%s: could not enable %s's clockdomain %s: %d\n", | ||
442 | __func__, __clk_get_name(hw->clk), clk->clkdm->name, ret); | ||
443 | |||
444 | return ret; | ||
445 | } | ||
446 | |||
447 | /** | ||
448 | * omap2_clkops_disable_clkdm - decrement usecount on clkdm of @hw | ||
449 | * @hw: struct clk_hw * of the clock being disabled | ||
450 | * | ||
451 | * Decrement the usecount of the clockdomain of the clock pointed to | ||
452 | * by @hw; if the usecount is 0, the clockdomain will be "disabled." | ||
453 | * Only needed for clocks that don't use omap2_dflt_clk_disable() as their | ||
454 | * disable function pointer. No return value. | ||
455 | */ | ||
456 | void omap2_clkops_disable_clkdm(struct clk_hw *hw) | ||
457 | { | ||
458 | struct clk_hw_omap *clk; | ||
459 | |||
460 | clk = to_clk_hw_omap(hw); | ||
461 | |||
462 | if (unlikely(!clk->clkdm)) { | ||
463 | pr_err("%s: %s: no clkdm set ?!\n", __func__, | ||
464 | __clk_get_name(hw->clk)); | ||
465 | return; | ||
466 | } | ||
467 | |||
468 | if (unlikely(clk->enable_reg)) | ||
469 | pr_err("%s: %s: should use dflt_clk_disable ?!\n", __func__, | ||
470 | __clk_get_name(hw->clk)); | ||
471 | |||
472 | if (!clkdm_control) { | ||
473 | pr_err("%s: %s: clkfw-based clockdomain control disabled ?!\n", | ||
474 | __func__, __clk_get_name(hw->clk)); | ||
475 | return; | ||
476 | } | ||
477 | |||
478 | clkdm_clk_disable(clk->clkdm, hw->clk); | ||
479 | } | ||
480 | |||
481 | /** | ||
482 | * omap2_dflt_clk_is_enabled - is clock enabled in the hardware? | ||
483 | * @hw: struct clk_hw * to check | ||
484 | * | ||
485 | * Return 1 if the clock represented by @hw is enabled in the | ||
486 | * hardware, or 0 otherwise. Intended for use in the struct | ||
487 | * clk_ops.is_enabled function pointer. | ||
488 | */ | ||
489 | int omap2_dflt_clk_is_enabled(struct clk_hw *hw) | ||
490 | { | ||
491 | struct clk_hw_omap *clk = to_clk_hw_omap(hw); | ||
492 | u32 v; | ||
493 | |||
494 | v = __raw_readl(clk->enable_reg); | ||
495 | |||
496 | if (clk->flags & INVERT_ENABLE) | ||
497 | v ^= BIT(clk->enable_bit); | ||
498 | |||
499 | v &= BIT(clk->enable_bit); | ||
500 | |||
501 | return v ? 1 : 0; | ||
502 | } | ||
503 | |||
504 | static int __initdata mpurate; | ||
505 | |||
506 | /* | ||
507 | * By default we use the rate set by the bootloader. | ||
508 | * You can override this with mpurate= cmdline option. | ||
509 | */ | ||
510 | static int __init omap_clk_setup(char *str) | ||
511 | { | ||
512 | get_option(&str, &mpurate); | ||
513 | |||
514 | if (!mpurate) | ||
515 | return 1; | ||
516 | |||
517 | if (mpurate < 1000) | ||
518 | mpurate *= 1000000; | ||
519 | |||
520 | return 1; | ||
521 | } | ||
522 | __setup("mpurate=", omap_clk_setup); | ||
523 | |||
524 | const struct clk_hw_omap_ops clkhwops_wait = { | ||
525 | .find_idlest = omap2_clk_dflt_find_idlest, | ||
526 | .find_companion = omap2_clk_dflt_find_companion, | ||
527 | }; | ||
528 | #else | ||
255 | int omap2_dflt_clk_enable(struct clk *clk) | 529 | int omap2_dflt_clk_enable(struct clk *clk) |
256 | { | 530 | { |
257 | u32 v; | 531 | u32 v; |
@@ -482,6 +756,8 @@ void omap2_clk_disable_unused(struct clk *clk) | |||
482 | } | 756 | } |
483 | #endif | 757 | #endif |
484 | 758 | ||
759 | #endif /* CONFIG_COMMON_CLK */ | ||
760 | |||
485 | /** | 761 | /** |
486 | * omap2_clk_switch_mpurate_at_boot - switch ARM MPU rate by boot-time argument | 762 | * omap2_clk_switch_mpurate_at_boot - switch ARM MPU rate by boot-time argument |
487 | * @mpurate_ck_name: clk name of the clock to change rate | 763 | * @mpurate_ck_name: clk name of the clock to change rate |
@@ -512,13 +788,15 @@ int __init omap2_clk_switch_mpurate_at_boot(const char *mpurate_ck_name) | |||
512 | r = clk_set_rate(mpurate_ck, mpurate); | 788 | r = clk_set_rate(mpurate_ck, mpurate); |
513 | if (IS_ERR_VALUE(r)) { | 789 | if (IS_ERR_VALUE(r)) { |
514 | WARN(1, "clock: %s: unable to set MPU rate to %d: %d\n", | 790 | WARN(1, "clock: %s: unable to set MPU rate to %d: %d\n", |
515 | mpurate_ck->name, mpurate, r); | 791 | mpurate_ck_name, mpurate, r); |
516 | clk_put(mpurate_ck); | 792 | clk_put(mpurate_ck); |
517 | return -EINVAL; | 793 | return -EINVAL; |
518 | } | 794 | } |
519 | 795 | ||
520 | calibrate_delay(); | 796 | calibrate_delay(); |
797 | #ifndef CONFIG_COMMON_CLK | ||
521 | recalculate_root_clocks(); | 798 | recalculate_root_clocks(); |
799 | #endif | ||
522 | 800 | ||
523 | clk_put(mpurate_ck); | 801 | clk_put(mpurate_ck); |
524 | 802 | ||
@@ -564,8 +842,8 @@ void __init omap2_clk_print_new_rates(const char *hfclkin_ck_name, | |||
564 | (clk_get_rate(mpu_ck) / 1000000)); | 842 | (clk_get_rate(mpu_ck) / 1000000)); |
565 | } | 843 | } |
566 | 844 | ||
845 | #ifndef CONFIG_COMMON_CLK | ||
567 | /* Common data */ | 846 | /* Common data */ |
568 | |||
569 | int clk_enable(struct clk *clk) | 847 | int clk_enable(struct clk *clk) |
570 | { | 848 | { |
571 | unsigned long flags; | 849 | unsigned long flags; |
@@ -1072,4 +1350,4 @@ err_out: | |||
1072 | late_initcall(clk_debugfs_init); | 1350 | late_initcall(clk_debugfs_init); |
1073 | 1351 | ||
1074 | #endif /* defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS) */ | 1352 | #endif /* defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS) */ |
1075 | 1353 | #endif /* CONFIG_COMMON_CLK */ | |
diff --git a/arch/arm/mach-omap2/clock.h b/arch/arm/mach-omap2/clock.h index 697e044156dd..5a4f4fe42b9b 100644 --- a/arch/arm/mach-omap2/clock.h +++ b/arch/arm/mach-omap2/clock.h | |||
@@ -397,6 +397,7 @@ extern const struct clkops clkops_null; | |||
397 | 397 | ||
398 | extern struct clk dummy_ck; | 398 | extern struct clk dummy_ck; |
399 | 399 | ||
400 | #endif /* CONFIG_COMMON_CLK */ | ||
400 | 401 | ||
401 | /* CM_CLKSEL2_PLL.CORE_CLK_SRC bits (2XXX) */ | 402 | /* CM_CLKSEL2_PLL.CORE_CLK_SRC bits (2XXX) */ |
402 | #define CORE_CLK_SRC_32K 0x0 | 403 | #define CORE_CLK_SRC_32K 0x0 |
@@ -427,11 +428,36 @@ extern struct clk dummy_ck; | |||
427 | /* DPLL Type and DCO Selection Flags */ | 428 | /* DPLL Type and DCO Selection Flags */ |
428 | #define DPLL_J_TYPE 0x1 | 429 | #define DPLL_J_TYPE 0x1 |
429 | 430 | ||
431 | #ifndef CONFIG_COMMON_CLK | ||
430 | int omap2_clk_enable(struct clk *clk); | 432 | int omap2_clk_enable(struct clk *clk); |
431 | void omap2_clk_disable(struct clk *clk); | 433 | void omap2_clk_disable(struct clk *clk); |
432 | long omap2_clk_round_rate(struct clk *clk, unsigned long rate); | 434 | long omap2_clk_round_rate(struct clk *clk, unsigned long rate); |
433 | int omap2_clk_set_rate(struct clk *clk, unsigned long rate); | 435 | int omap2_clk_set_rate(struct clk *clk, unsigned long rate); |
434 | int omap2_clk_set_parent(struct clk *clk, struct clk *new_parent); | 436 | int omap2_clk_set_parent(struct clk *clk, struct clk *new_parent); |
437 | #endif /* CONFIG_COMMON_CLK */ | ||
438 | |||
439 | #ifdef CONFIG_COMMON_CLK | ||
440 | long omap2_dpll_round_rate(struct clk_hw *hw, unsigned long target_rate, | ||
441 | unsigned long *parent_rate); | ||
442 | unsigned long omap3_dpll_recalc(struct clk_hw *hw, unsigned long parent_rate); | ||
443 | int omap3_noncore_dpll_enable(struct clk_hw *hw); | ||
444 | void omap3_noncore_dpll_disable(struct clk_hw *hw); | ||
445 | int omap3_noncore_dpll_set_rate(struct clk_hw *hw, unsigned long rate, | ||
446 | unsigned long parent_rate); | ||
447 | u32 omap3_dpll_autoidle_read(struct clk_hw_omap *clk); | ||
448 | void omap3_dpll_allow_idle(struct clk_hw_omap *clk); | ||
449 | void omap3_dpll_deny_idle(struct clk_hw_omap *clk); | ||
450 | unsigned long omap3_clkoutx2_recalc(struct clk_hw *hw, | ||
451 | unsigned long parent_rate); | ||
452 | int omap4_dpllmx_gatectrl_read(struct clk_hw_omap *clk); | ||
453 | void omap4_dpllmx_allow_gatectrl(struct clk_hw_omap *clk); | ||
454 | void omap4_dpllmx_deny_gatectrl(struct clk_hw_omap *clk); | ||
455 | unsigned long omap4_dpll_regm4xen_recalc(struct clk_hw *hw, | ||
456 | unsigned long parent_rate); | ||
457 | long omap4_dpll_regm4xen_round_rate(struct clk_hw *hw, | ||
458 | unsigned long target_rate, | ||
459 | unsigned long *parent_rate); | ||
460 | #else | ||
435 | long omap2_dpll_round_rate(struct clk *clk, unsigned long target_rate); | 461 | long omap2_dpll_round_rate(struct clk *clk, unsigned long target_rate); |
436 | unsigned long omap3_dpll_recalc(struct clk *clk); | 462 | unsigned long omap3_dpll_recalc(struct clk *clk); |
437 | unsigned long omap3_clkoutx2_recalc(struct clk *clk); | 463 | unsigned long omap3_clkoutx2_recalc(struct clk *clk); |
@@ -446,17 +472,33 @@ void omap4_dpllmx_allow_gatectrl(struct clk *clk); | |||
446 | void omap4_dpllmx_deny_gatectrl(struct clk *clk); | 472 | void omap4_dpllmx_deny_gatectrl(struct clk *clk); |
447 | long omap4_dpll_regm4xen_round_rate(struct clk *clk, unsigned long target_rate); | 473 | long omap4_dpll_regm4xen_round_rate(struct clk *clk, unsigned long target_rate); |
448 | unsigned long omap4_dpll_regm4xen_recalc(struct clk *clk); | 474 | unsigned long omap4_dpll_regm4xen_recalc(struct clk *clk); |
475 | #endif | ||
449 | 476 | ||
450 | #ifdef CONFIG_OMAP_RESET_CLOCKS | 477 | #ifdef CONFIG_OMAP_RESET_CLOCKS |
451 | void omap2_clk_disable_unused(struct clk *clk); | 478 | void omap2_clk_disable_unused(struct clk *clk); |
452 | #else | 479 | #else |
453 | #define omap2_clk_disable_unused NULL | 480 | #define omap2_clk_disable_unused NULL |
454 | #endif | 481 | #endif |
455 | 482 | #ifdef CONFIG_COMMON_CLK | |
483 | void omap2_init_clk_clkdm(struct clk_hw *clk); | ||
484 | #else | ||
456 | void omap2_init_clk_clkdm(struct clk *clk); | 485 | void omap2_init_clk_clkdm(struct clk *clk); |
486 | #endif | ||
457 | void __init omap2_clk_disable_clkdm_control(void); | 487 | void __init omap2_clk_disable_clkdm_control(void); |
458 | 488 | ||
459 | /* clkt_clksel.c public functions */ | 489 | /* clkt_clksel.c public functions */ |
490 | #ifdef CONFIG_COMMON_CLK | ||
491 | u32 omap2_clksel_round_rate_div(struct clk_hw_omap *clk, | ||
492 | unsigned long target_rate, | ||
493 | u32 *new_div); | ||
494 | u8 omap2_clksel_find_parent_index(struct clk_hw *hw); | ||
495 | unsigned long omap2_clksel_recalc(struct clk_hw *hw, unsigned long parent_rate); | ||
496 | long omap2_clksel_round_rate(struct clk_hw *hw, unsigned long target_rate, | ||
497 | unsigned long *parent_rate); | ||
498 | int omap2_clksel_set_rate(struct clk_hw *hw, unsigned long rate, | ||
499 | unsigned long parent_rate); | ||
500 | int omap2_clksel_set_parent(struct clk_hw *hw, u8 field_val); | ||
501 | #else | ||
460 | u32 omap2_clksel_round_rate_div(struct clk *clk, unsigned long target_rate, | 502 | u32 omap2_clksel_round_rate_div(struct clk *clk, unsigned long target_rate, |
461 | u32 *new_div); | 503 | u32 *new_div); |
462 | void omap2_init_clksel_parent(struct clk *clk); | 504 | void omap2_init_clksel_parent(struct clk *clk); |
@@ -464,20 +506,38 @@ unsigned long omap2_clksel_recalc(struct clk *clk); | |||
464 | long omap2_clksel_round_rate(struct clk *clk, unsigned long target_rate); | 506 | long omap2_clksel_round_rate(struct clk *clk, unsigned long target_rate); |
465 | int omap2_clksel_set_rate(struct clk *clk, unsigned long rate); | 507 | int omap2_clksel_set_rate(struct clk *clk, unsigned long rate); |
466 | int omap2_clksel_set_parent(struct clk *clk, struct clk *new_parent); | 508 | int omap2_clksel_set_parent(struct clk *clk, struct clk *new_parent); |
509 | #endif | ||
467 | 510 | ||
468 | /* clkt_iclk.c public functions */ | 511 | /* clkt_iclk.c public functions */ |
469 | extern void omap2_clkt_iclk_allow_idle(struct clk *clk); | 512 | extern void omap2_clkt_iclk_allow_idle(struct clk *clk); |
470 | extern void omap2_clkt_iclk_deny_idle(struct clk *clk); | 513 | extern void omap2_clkt_iclk_deny_idle(struct clk *clk); |
471 | 514 | ||
515 | #ifdef CONFIG_COMMON_CLK | ||
516 | u8 omap2_init_dpll_parent(struct clk_hw *hw); | ||
517 | unsigned long omap2_get_dpll_rate(struct clk_hw_omap *clk); | ||
518 | #else | ||
472 | u32 omap2_get_dpll_rate(struct clk *clk); | 519 | u32 omap2_get_dpll_rate(struct clk *clk); |
473 | void omap2_init_dpll_parent(struct clk *clk); | 520 | void omap2_init_dpll_parent(struct clk *clk); |
521 | #endif | ||
474 | 522 | ||
523 | #ifdef CONFIG_COMMON_CLK | ||
524 | int omap2_dflt_clk_enable(struct clk_hw *hw); | ||
525 | void omap2_dflt_clk_disable(struct clk_hw *hw); | ||
526 | int omap2_dflt_clk_is_enabled(struct clk_hw *hw); | ||
527 | void omap2_clk_dflt_find_companion(struct clk_hw_omap *clk, | ||
528 | void __iomem **other_reg, | ||
529 | u8 *other_bit); | ||
530 | void omap2_clk_dflt_find_idlest(struct clk_hw_omap *clk, | ||
531 | void __iomem **idlest_reg, | ||
532 | u8 *idlest_bit, u8 *idlest_val); | ||
533 | #else | ||
475 | int omap2_dflt_clk_enable(struct clk *clk); | 534 | int omap2_dflt_clk_enable(struct clk *clk); |
476 | void omap2_dflt_clk_disable(struct clk *clk); | 535 | void omap2_dflt_clk_disable(struct clk *clk); |
477 | void omap2_clk_dflt_find_companion(struct clk *clk, void __iomem **other_reg, | 536 | void omap2_clk_dflt_find_companion(struct clk *clk, void __iomem **other_reg, |
478 | u8 *other_bit); | 537 | u8 *other_bit); |
479 | void omap2_clk_dflt_find_idlest(struct clk *clk, void __iomem **idlest_reg, | 538 | void omap2_clk_dflt_find_idlest(struct clk *clk, void __iomem **idlest_reg, |
480 | u8 *idlest_bit, u8 *idlest_val); | 539 | u8 *idlest_bit, u8 *idlest_val); |
540 | #endif | ||
481 | int omap2_clk_switch_mpurate_at_boot(const char *mpurate_ck_name); | 541 | int omap2_clk_switch_mpurate_at_boot(const char *mpurate_ck_name); |
482 | void omap2_clk_print_new_rates(const char *hfclkin_ck_name, | 542 | void omap2_clk_print_new_rates(const char *hfclkin_ck_name, |
483 | const char *core_ck_name, | 543 | const char *core_ck_name, |
@@ -496,6 +556,13 @@ extern const struct clksel_rate gpt_sys_rates[]; | |||
496 | extern const struct clksel_rate gfx_l3_rates[]; | 556 | extern const struct clksel_rate gfx_l3_rates[]; |
497 | extern const struct clksel_rate dsp_ick_rates[]; | 557 | extern const struct clksel_rate dsp_ick_rates[]; |
498 | 558 | ||
559 | #ifdef CONFIG_COMMON_CLK | ||
560 | extern const struct clk_hw_omap_ops clkhwops_omap3_dpll; | ||
561 | extern const struct clk_hw_omap_ops clkhwops_iclk_wait; | ||
562 | extern const struct clk_hw_omap_ops clkhwops_wait; | ||
563 | extern const struct clk_hw_omap_ops clkhwops_omap4_dpllmx; | ||
564 | #endif | ||
565 | |||
499 | extern const struct clkops clkops_omap2_iclk_dflt_wait; | 566 | extern const struct clkops clkops_omap2_iclk_dflt_wait; |
500 | extern const struct clkops clkops_omap2_iclk_dflt; | 567 | extern const struct clkops clkops_omap2_iclk_dflt; |
501 | extern const struct clkops clkops_omap2_iclk_idle_only; | 568 | extern const struct clkops clkops_omap2_iclk_idle_only; |
@@ -513,11 +580,17 @@ extern const struct clksel_rate div_1_3_rates[]; | |||
513 | extern const struct clksel_rate div_1_4_rates[]; | 580 | extern const struct clksel_rate div_1_4_rates[]; |
514 | extern const struct clksel_rate div31_1to31_rates[]; | 581 | extern const struct clksel_rate div31_1to31_rates[]; |
515 | 582 | ||
583 | #ifndef CONFIG_COMMON_CLK | ||
516 | /* clocks shared between various OMAP SoCs */ | 584 | /* clocks shared between various OMAP SoCs */ |
517 | extern struct clk virt_19200000_ck; | 585 | extern struct clk virt_19200000_ck; |
518 | extern struct clk virt_26000000_ck; | 586 | extern struct clk virt_26000000_ck; |
587 | #endif | ||
519 | 588 | ||
520 | extern int am33xx_clk_init(void); | 589 | extern int am33xx_clk_init(void); |
521 | 590 | ||
522 | #endif /* CONFIG_COMMON_CLK */ | 591 | #ifdef CONFIG_COMMON_CLK |
592 | extern int omap2_clkops_enable_clkdm(struct clk_hw *hw); | ||
593 | extern void omap2_clkops_disable_clkdm(struct clk_hw *hw); | ||
594 | #endif | ||
595 | |||
523 | #endif | 596 | #endif |
diff --git a/arch/arm/mach-omap2/dpll3xxx.c b/arch/arm/mach-omap2/dpll3xxx.c index eacf51f2bc27..f72dedb4eee8 100644 --- a/arch/arm/mach-omap2/dpll3xxx.c +++ b/arch/arm/mach-omap2/dpll3xxx.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/clkdev.h> | 29 | #include <linux/clkdev.h> |
30 | 30 | ||
31 | #include "soc.h" | 31 | #include "soc.h" |
32 | #include "clockdomain.h" | ||
32 | #include "clock.h" | 33 | #include "clock.h" |
33 | #include "cm2xxx_3xxx.h" | 34 | #include "cm2xxx_3xxx.h" |
34 | #include "cm-regbits-34xx.h" | 35 | #include "cm-regbits-34xx.h" |
@@ -42,7 +43,11 @@ | |||
42 | /* Private functions */ | 43 | /* Private functions */ |
43 | 44 | ||
44 | /* _omap3_dpll_write_clken - write clken_bits arg to a DPLL's enable bits */ | 45 | /* _omap3_dpll_write_clken - write clken_bits arg to a DPLL's enable bits */ |
46 | #ifdef CONFIG_COMMON_CLK | ||
47 | static void _omap3_dpll_write_clken(struct clk_hw_omap *clk, u8 clken_bits) | ||
48 | #else | ||
45 | static void _omap3_dpll_write_clken(struct clk *clk, u8 clken_bits) | 49 | static void _omap3_dpll_write_clken(struct clk *clk, u8 clken_bits) |
50 | #endif | ||
46 | { | 51 | { |
47 | const struct dpll_data *dd; | 52 | const struct dpll_data *dd; |
48 | u32 v; | 53 | u32 v; |
@@ -56,7 +61,11 @@ static void _omap3_dpll_write_clken(struct clk *clk, u8 clken_bits) | |||
56 | } | 61 | } |
57 | 62 | ||
58 | /* _omap3_wait_dpll_status: wait for a DPLL to enter a specific state */ | 63 | /* _omap3_wait_dpll_status: wait for a DPLL to enter a specific state */ |
64 | #ifdef CONFIG_COMMON_CLK | ||
65 | static int _omap3_wait_dpll_status(struct clk_hw_omap *clk, u8 state) | ||
66 | #else | ||
59 | static int _omap3_wait_dpll_status(struct clk *clk, u8 state) | 67 | static int _omap3_wait_dpll_status(struct clk *clk, u8 state) |
68 | #endif | ||
60 | { | 69 | { |
61 | const struct dpll_data *dd; | 70 | const struct dpll_data *dd; |
62 | int i = 0; | 71 | int i = 0; |
@@ -64,7 +73,11 @@ static int _omap3_wait_dpll_status(struct clk *clk, u8 state) | |||
64 | const char *clk_name; | 73 | const char *clk_name; |
65 | 74 | ||
66 | dd = clk->dpll_data; | 75 | dd = clk->dpll_data; |
76 | #ifdef CONFIG_COMMON_CLK | ||
77 | clk_name = __clk_get_name(clk->hw.clk); | ||
78 | #else | ||
67 | clk_name = __clk_get_name(clk); | 79 | clk_name = __clk_get_name(clk); |
80 | #endif | ||
68 | 81 | ||
69 | state <<= __ffs(dd->idlest_mask); | 82 | state <<= __ffs(dd->idlest_mask); |
70 | 83 | ||
@@ -88,7 +101,11 @@ static int _omap3_wait_dpll_status(struct clk *clk, u8 state) | |||
88 | } | 101 | } |
89 | 102 | ||
90 | /* From 3430 TRM ES2 4.7.6.2 */ | 103 | /* From 3430 TRM ES2 4.7.6.2 */ |
104 | #ifdef CONFIG_COMMON_CLK | ||
105 | static u16 _omap3_dpll_compute_freqsel(struct clk_hw_omap *clk, u8 n) | ||
106 | #else | ||
91 | static u16 _omap3_dpll_compute_freqsel(struct clk *clk, u8 n) | 107 | static u16 _omap3_dpll_compute_freqsel(struct clk *clk, u8 n) |
108 | #endif | ||
92 | { | 109 | { |
93 | unsigned long fint; | 110 | unsigned long fint; |
94 | u16 f = 0; | 111 | u16 f = 0; |
@@ -133,14 +150,22 @@ static u16 _omap3_dpll_compute_freqsel(struct clk *clk, u8 n) | |||
133 | * locked successfully, return 0; if the DPLL did not lock in the time | 150 | * locked successfully, return 0; if the DPLL did not lock in the time |
134 | * allotted, or DPLL3 was passed in, return -EINVAL. | 151 | * allotted, or DPLL3 was passed in, return -EINVAL. |
135 | */ | 152 | */ |
153 | #ifdef CONFIG_COMMON_CLK | ||
154 | static int _omap3_noncore_dpll_lock(struct clk_hw_omap *clk) | ||
155 | #else | ||
136 | static int _omap3_noncore_dpll_lock(struct clk *clk) | 156 | static int _omap3_noncore_dpll_lock(struct clk *clk) |
157 | #endif | ||
137 | { | 158 | { |
138 | const struct dpll_data *dd; | 159 | const struct dpll_data *dd; |
139 | u8 ai; | 160 | u8 ai; |
140 | u8 state = 1; | 161 | u8 state = 1; |
141 | int r = 0; | 162 | int r = 0; |
142 | 163 | ||
164 | #ifdef CONFIG_COMMON_CLK | ||
165 | pr_debug("clock: locking DPLL %s\n", __clk_get_name(clk->hw.clk)); | ||
166 | #else | ||
143 | pr_debug("clock: locking DPLL %s\n", __clk_get_name(clk)); | 167 | pr_debug("clock: locking DPLL %s\n", __clk_get_name(clk)); |
168 | #endif | ||
144 | 169 | ||
145 | dd = clk->dpll_data; | 170 | dd = clk->dpll_data; |
146 | state <<= __ffs(dd->idlest_mask); | 171 | state <<= __ffs(dd->idlest_mask); |
@@ -178,7 +203,11 @@ done: | |||
178 | * DPLL3 was passed in, or the DPLL does not support low-power bypass, | 203 | * DPLL3 was passed in, or the DPLL does not support low-power bypass, |
179 | * return -EINVAL. | 204 | * return -EINVAL. |
180 | */ | 205 | */ |
206 | #ifdef CONFIG_COMMON_CLK | ||
207 | static int _omap3_noncore_dpll_bypass(struct clk_hw_omap *clk) | ||
208 | #else | ||
181 | static int _omap3_noncore_dpll_bypass(struct clk *clk) | 209 | static int _omap3_noncore_dpll_bypass(struct clk *clk) |
210 | #endif | ||
182 | { | 211 | { |
183 | int r; | 212 | int r; |
184 | u8 ai; | 213 | u8 ai; |
@@ -187,7 +216,11 @@ static int _omap3_noncore_dpll_bypass(struct clk *clk) | |||
187 | return -EINVAL; | 216 | return -EINVAL; |
188 | 217 | ||
189 | pr_debug("clock: configuring DPLL %s for low-power bypass\n", | 218 | pr_debug("clock: configuring DPLL %s for low-power bypass\n", |
219 | #ifdef CONFIG_COMMON_CLK | ||
220 | __clk_get_name(clk->hw.clk)); | ||
221 | #else | ||
190 | __clk_get_name(clk)); | 222 | __clk_get_name(clk)); |
223 | #endif | ||
191 | 224 | ||
192 | ai = omap3_dpll_autoidle_read(clk); | 225 | ai = omap3_dpll_autoidle_read(clk); |
193 | 226 | ||
@@ -210,14 +243,22 @@ static int _omap3_noncore_dpll_bypass(struct clk *clk) | |||
210 | * code. If DPLL3 was passed in, or the DPLL does not support | 243 | * code. If DPLL3 was passed in, or the DPLL does not support |
211 | * low-power stop, return -EINVAL; otherwise, return 0. | 244 | * low-power stop, return -EINVAL; otherwise, return 0. |
212 | */ | 245 | */ |
246 | #ifdef CONFIG_COMMON_CLK | ||
247 | static int _omap3_noncore_dpll_stop(struct clk_hw_omap *clk) | ||
248 | #else | ||
213 | static int _omap3_noncore_dpll_stop(struct clk *clk) | 249 | static int _omap3_noncore_dpll_stop(struct clk *clk) |
250 | #endif | ||
214 | { | 251 | { |
215 | u8 ai; | 252 | u8 ai; |
216 | 253 | ||
217 | if (!(clk->dpll_data->modes & (1 << DPLL_LOW_POWER_STOP))) | 254 | if (!(clk->dpll_data->modes & (1 << DPLL_LOW_POWER_STOP))) |
218 | return -EINVAL; | 255 | return -EINVAL; |
219 | 256 | ||
257 | #ifdef CONFIG_COMMON_CLK | ||
258 | pr_debug("clock: stopping DPLL %s\n", __clk_get_name(clk->hw.clk)); | ||
259 | #else | ||
220 | pr_debug("clock: stopping DPLL %s\n", __clk_get_name(clk)); | 260 | pr_debug("clock: stopping DPLL %s\n", __clk_get_name(clk)); |
261 | #endif | ||
221 | 262 | ||
222 | ai = omap3_dpll_autoidle_read(clk); | 263 | ai = omap3_dpll_autoidle_read(clk); |
223 | 264 | ||
@@ -241,11 +282,19 @@ static int _omap3_noncore_dpll_stop(struct clk *clk) | |||
241 | * XXX This code is not needed for 3430/AM35xx; can it be optimized | 282 | * XXX This code is not needed for 3430/AM35xx; can it be optimized |
242 | * out in non-multi-OMAP builds for those chips? | 283 | * out in non-multi-OMAP builds for those chips? |
243 | */ | 284 | */ |
285 | #ifdef CONFIG_COMMON_CLK | ||
286 | static void _lookup_dco(struct clk_hw_omap *clk, u8 *dco, u16 m, u8 n) | ||
287 | #else | ||
244 | static void _lookup_dco(struct clk *clk, u8 *dco, u16 m, u8 n) | 288 | static void _lookup_dco(struct clk *clk, u8 *dco, u16 m, u8 n) |
289 | #endif | ||
245 | { | 290 | { |
246 | unsigned long fint, clkinp; /* watch out for overflow */ | 291 | unsigned long fint, clkinp; /* watch out for overflow */ |
247 | 292 | ||
293 | #ifdef CONFIG_COMMON_CLK | ||
294 | clkinp = __clk_get_rate(__clk_get_parent(clk->hw.clk)); | ||
295 | #else | ||
248 | clkinp = __clk_get_rate(__clk_get_parent(clk)); | 296 | clkinp = __clk_get_rate(__clk_get_parent(clk)); |
297 | #endif | ||
249 | fint = (clkinp / n) * m; | 298 | fint = (clkinp / n) * m; |
250 | 299 | ||
251 | if (fint < 1000000000) | 300 | if (fint < 1000000000) |
@@ -266,12 +315,20 @@ static void _lookup_dco(struct clk *clk, u8 *dco, u16 m, u8 n) | |||
266 | * XXX This code is not needed for 3430/AM35xx; can it be optimized | 315 | * XXX This code is not needed for 3430/AM35xx; can it be optimized |
267 | * out in non-multi-OMAP builds for those chips? | 316 | * out in non-multi-OMAP builds for those chips? |
268 | */ | 317 | */ |
318 | #ifdef CONFIG_COMMON_CLK | ||
319 | static void _lookup_sddiv(struct clk_hw_omap *clk, u8 *sd_div, u16 m, u8 n) | ||
320 | #else | ||
269 | static void _lookup_sddiv(struct clk *clk, u8 *sd_div, u16 m, u8 n) | 321 | static void _lookup_sddiv(struct clk *clk, u8 *sd_div, u16 m, u8 n) |
322 | #endif | ||
270 | { | 323 | { |
271 | unsigned long clkinp, sd; /* watch out for overflow */ | 324 | unsigned long clkinp, sd; /* watch out for overflow */ |
272 | int mod1, mod2; | 325 | int mod1, mod2; |
273 | 326 | ||
327 | #ifdef CONFIG_COMMON_CLK | ||
328 | clkinp = __clk_get_rate(__clk_get_parent(clk->hw.clk)); | ||
329 | #else | ||
274 | clkinp = __clk_get_rate(__clk_get_parent(clk)); | 330 | clkinp = __clk_get_rate(__clk_get_parent(clk)); |
331 | #endif | ||
275 | 332 | ||
276 | /* | 333 | /* |
277 | * target sigma-delta to near 250MHz | 334 | * target sigma-delta to near 250MHz |
@@ -298,7 +355,12 @@ static void _lookup_sddiv(struct clk *clk, u8 *sd_div, u16 m, u8 n) | |||
298 | * Program the DPLL with the supplied M, N values, and wait for the DPLL to | 355 | * Program the DPLL with the supplied M, N values, and wait for the DPLL to |
299 | * lock.. Returns -EINVAL upon error, or 0 upon success. | 356 | * lock.. Returns -EINVAL upon error, or 0 upon success. |
300 | */ | 357 | */ |
358 | #ifdef CONFIG_COMMON_CLK | ||
359 | static int omap3_noncore_dpll_program(struct clk_hw_omap *clk, u16 m, u8 n, | ||
360 | u16 freqsel) | ||
361 | #else | ||
301 | static int omap3_noncore_dpll_program(struct clk *clk, u16 m, u8 n, u16 freqsel) | 362 | static int omap3_noncore_dpll_program(struct clk *clk, u16 m, u8 n, u16 freqsel) |
363 | #endif | ||
302 | { | 364 | { |
303 | struct dpll_data *dd = clk->dpll_data; | 365 | struct dpll_data *dd = clk->dpll_data; |
304 | u8 dco, sd_div; | 366 | u8 dco, sd_div; |
@@ -355,8 +417,14 @@ static int omap3_noncore_dpll_program(struct clk *clk, u16 m, u8 n, u16 freqsel) | |||
355 | * | 417 | * |
356 | * Recalculate and propagate the DPLL rate. | 418 | * Recalculate and propagate the DPLL rate. |
357 | */ | 419 | */ |
420 | #ifdef CONFIG_COMMON_CLK | ||
421 | unsigned long omap3_dpll_recalc(struct clk_hw *hw, unsigned long parent_rate) | ||
422 | { | ||
423 | struct clk_hw_omap *clk = to_clk_hw_omap(hw); | ||
424 | #else | ||
358 | unsigned long omap3_dpll_recalc(struct clk *clk) | 425 | unsigned long omap3_dpll_recalc(struct clk *clk) |
359 | { | 426 | { |
427 | #endif | ||
360 | return omap2_get_dpll_rate(clk); | 428 | return omap2_get_dpll_rate(clk); |
361 | } | 429 | } |
362 | 430 | ||
@@ -376,8 +444,14 @@ unsigned long omap3_dpll_recalc(struct clk *clk) | |||
376 | * support low-power stop, or if the DPLL took too long to enter | 444 | * support low-power stop, or if the DPLL took too long to enter |
377 | * bypass or lock, return -EINVAL; otherwise, return 0. | 445 | * bypass or lock, return -EINVAL; otherwise, return 0. |
378 | */ | 446 | */ |
447 | #ifdef CONFIG_COMMON_CLK | ||
448 | int omap3_noncore_dpll_enable(struct clk_hw *hw) | ||
449 | { | ||
450 | struct clk_hw_omap *clk = to_clk_hw_omap(hw); | ||
451 | #else | ||
379 | int omap3_noncore_dpll_enable(struct clk *clk) | 452 | int omap3_noncore_dpll_enable(struct clk *clk) |
380 | { | 453 | { |
454 | #endif | ||
381 | int r; | 455 | int r; |
382 | struct dpll_data *dd; | 456 | struct dpll_data *dd; |
383 | struct clk *parent; | 457 | struct clk *parent; |
@@ -386,15 +460,34 @@ int omap3_noncore_dpll_enable(struct clk *clk) | |||
386 | if (!dd) | 460 | if (!dd) |
387 | return -EINVAL; | 461 | return -EINVAL; |
388 | 462 | ||
463 | #ifdef CONFIG_COMMON_CLK | ||
464 | if (clk->clkdm) { | ||
465 | r = clkdm_clk_enable(clk->clkdm, hw->clk); | ||
466 | if (r) { | ||
467 | WARN(1, | ||
468 | "%s: could not enable %s's clockdomain %s: %d\n", | ||
469 | __func__, __clk_get_name(hw->clk), | ||
470 | clk->clkdm->name, r); | ||
471 | return r; | ||
472 | } | ||
473 | } | ||
474 | |||
475 | parent = __clk_get_parent(hw->clk); | ||
476 | |||
477 | if (__clk_get_rate(hw->clk) == __clk_get_rate(dd->clk_bypass)) { | ||
478 | #else | ||
389 | parent = __clk_get_parent(clk); | 479 | parent = __clk_get_parent(clk); |
390 | 480 | ||
391 | if (__clk_get_rate(clk) == __clk_get_rate(dd->clk_bypass)) { | 481 | if (__clk_get_rate(clk) == __clk_get_rate(dd->clk_bypass)) { |
482 | #endif | ||
392 | WARN_ON(parent != dd->clk_bypass); | 483 | WARN_ON(parent != dd->clk_bypass); |
393 | r = _omap3_noncore_dpll_bypass(clk); | 484 | r = _omap3_noncore_dpll_bypass(clk); |
394 | } else { | 485 | } else { |
395 | WARN_ON(parent != dd->clk_ref); | 486 | WARN_ON(parent != dd->clk_ref); |
396 | r = _omap3_noncore_dpll_lock(clk); | 487 | r = _omap3_noncore_dpll_lock(clk); |
397 | } | 488 | } |
489 | |||
490 | #ifndef CONFIG_COMMON_CLK | ||
398 | /* | 491 | /* |
399 | *FIXME: this is dubious - if clk->rate has changed, what about | 492 | *FIXME: this is dubious - if clk->rate has changed, what about |
400 | * propagating? | 493 | * propagating? |
@@ -402,6 +495,7 @@ int omap3_noncore_dpll_enable(struct clk *clk) | |||
402 | if (!r) | 495 | if (!r) |
403 | clk->rate = (clk->recalc) ? clk->recalc(clk) : | 496 | clk->rate = (clk->recalc) ? clk->recalc(clk) : |
404 | omap2_get_dpll_rate(clk); | 497 | omap2_get_dpll_rate(clk); |
498 | #endif | ||
405 | 499 | ||
406 | return r; | 500 | return r; |
407 | } | 501 | } |
@@ -413,9 +507,21 @@ int omap3_noncore_dpll_enable(struct clk *clk) | |||
413 | * Instructs a non-CORE DPLL to enter low-power stop. This function is | 507 | * Instructs a non-CORE DPLL to enter low-power stop. This function is |
414 | * intended for use in struct clkops. No return value. | 508 | * intended for use in struct clkops. No return value. |
415 | */ | 509 | */ |
510 | #ifdef CONFIG_COMMON_CLK | ||
511 | void omap3_noncore_dpll_disable(struct clk_hw *hw) | ||
512 | { | ||
513 | struct clk_hw_omap *clk = to_clk_hw_omap(hw); | ||
514 | |||
515 | _omap3_noncore_dpll_stop(clk); | ||
516 | if (clk->clkdm) | ||
517 | clkdm_clk_disable(clk->clkdm, hw->clk); | ||
518 | #else | ||
416 | void omap3_noncore_dpll_disable(struct clk *clk) | 519 | void omap3_noncore_dpll_disable(struct clk *clk) |
417 | { | 520 | { |
418 | _omap3_noncore_dpll_stop(clk); | 521 | _omap3_noncore_dpll_stop(clk); |
522 | if (clk->clkdm) | ||
523 | clkdm_clk_disable(clk->clkdm, clk); | ||
524 | #endif | ||
419 | } | 525 | } |
420 | 526 | ||
421 | 527 | ||
@@ -432,6 +538,77 @@ void omap3_noncore_dpll_disable(struct clk *clk) | |||
432 | * target rate if it hasn't been done already, then program and lock | 538 | * target rate if it hasn't been done already, then program and lock |
433 | * the DPLL. Returns -EINVAL upon error, or 0 upon success. | 539 | * the DPLL. Returns -EINVAL upon error, or 0 upon success. |
434 | */ | 540 | */ |
541 | #ifdef CONFIG_COMMON_CLK | ||
542 | int omap3_noncore_dpll_set_rate(struct clk_hw *hw, unsigned long rate, | ||
543 | unsigned long parent_rate) | ||
544 | { | ||
545 | struct clk_hw_omap *clk = to_clk_hw_omap(hw); | ||
546 | struct clk *new_parent = NULL; | ||
547 | u16 freqsel = 0; | ||
548 | struct dpll_data *dd; | ||
549 | int ret; | ||
550 | |||
551 | if (!hw || !rate) | ||
552 | return -EINVAL; | ||
553 | |||
554 | dd = clk->dpll_data; | ||
555 | if (!dd) | ||
556 | return -EINVAL; | ||
557 | |||
558 | __clk_prepare(dd->clk_bypass); | ||
559 | clk_enable(dd->clk_bypass); | ||
560 | __clk_prepare(dd->clk_ref); | ||
561 | clk_enable(dd->clk_ref); | ||
562 | |||
563 | if (__clk_get_rate(dd->clk_bypass) == rate && | ||
564 | (dd->modes & (1 << DPLL_LOW_POWER_BYPASS))) { | ||
565 | pr_debug("%s: %s: set rate: entering bypass.\n", | ||
566 | __func__, __clk_get_name(hw->clk)); | ||
567 | |||
568 | ret = _omap3_noncore_dpll_bypass(clk); | ||
569 | if (!ret) | ||
570 | new_parent = dd->clk_bypass; | ||
571 | } else { | ||
572 | if (dd->last_rounded_rate != rate) | ||
573 | rate = __clk_round_rate(hw->clk, rate); | ||
574 | |||
575 | if (dd->last_rounded_rate == 0) | ||
576 | return -EINVAL; | ||
577 | |||
578 | /* No freqsel on OMAP4 and OMAP3630 */ | ||
579 | if (!cpu_is_omap44xx() && !cpu_is_omap3630()) { | ||
580 | freqsel = _omap3_dpll_compute_freqsel(clk, | ||
581 | dd->last_rounded_n); | ||
582 | if (!freqsel) | ||
583 | WARN_ON(1); | ||
584 | } | ||
585 | |||
586 | pr_debug("%s: %s: set rate: locking rate to %lu.\n", | ||
587 | __func__, __clk_get_name(hw->clk), rate); | ||
588 | |||
589 | ret = omap3_noncore_dpll_program(clk, dd->last_rounded_m, | ||
590 | dd->last_rounded_n, freqsel); | ||
591 | if (!ret) | ||
592 | new_parent = dd->clk_ref; | ||
593 | } | ||
594 | /* | ||
595 | * FIXME - this is all wrong. common code handles reparenting and | ||
596 | * migrating prepare/enable counts. dplls should be a multiplexer | ||
597 | * clock and this should be a set_parent operation so that all of that | ||
598 | * stuff is inherited for free | ||
599 | */ | ||
600 | |||
601 | if (!ret) | ||
602 | __clk_reparent(hw->clk, new_parent); | ||
603 | |||
604 | clk_disable(dd->clk_ref); | ||
605 | __clk_unprepare(dd->clk_ref); | ||
606 | clk_disable(dd->clk_bypass); | ||
607 | __clk_unprepare(dd->clk_bypass); | ||
608 | |||
609 | return 0; | ||
610 | } | ||
611 | #else | ||
435 | int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate) | 612 | int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate) |
436 | { | 613 | { |
437 | struct clk *new_parent = NULL; | 614 | struct clk *new_parent = NULL; |
@@ -509,6 +686,7 @@ int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate) | |||
509 | 686 | ||
510 | return 0; | 687 | return 0; |
511 | } | 688 | } |
689 | #endif | ||
512 | 690 | ||
513 | /* DPLL autoidle read/set code */ | 691 | /* DPLL autoidle read/set code */ |
514 | 692 | ||
@@ -520,7 +698,11 @@ int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate) | |||
520 | * -EINVAL if passed a null pointer or if the struct clk does not | 698 | * -EINVAL if passed a null pointer or if the struct clk does not |
521 | * appear to refer to a DPLL. | 699 | * appear to refer to a DPLL. |
522 | */ | 700 | */ |
701 | #ifdef CONFIG_COMMON_CLK | ||
702 | u32 omap3_dpll_autoidle_read(struct clk_hw_omap *clk) | ||
703 | #else | ||
523 | u32 omap3_dpll_autoidle_read(struct clk *clk) | 704 | u32 omap3_dpll_autoidle_read(struct clk *clk) |
705 | #endif | ||
524 | { | 706 | { |
525 | const struct dpll_data *dd; | 707 | const struct dpll_data *dd; |
526 | u32 v; | 708 | u32 v; |
@@ -549,7 +731,11 @@ u32 omap3_dpll_autoidle_read(struct clk *clk) | |||
549 | * OMAP3430. The DPLL will enter low-power stop when its downstream | 731 | * OMAP3430. The DPLL will enter low-power stop when its downstream |
550 | * clocks are gated. No return value. | 732 | * clocks are gated. No return value. |
551 | */ | 733 | */ |
734 | #ifdef CONFIG_COMMON_CLK | ||
735 | void omap3_dpll_allow_idle(struct clk_hw_omap *clk) | ||
736 | #else | ||
552 | void omap3_dpll_allow_idle(struct clk *clk) | 737 | void omap3_dpll_allow_idle(struct clk *clk) |
738 | #endif | ||
553 | { | 739 | { |
554 | const struct dpll_data *dd; | 740 | const struct dpll_data *dd; |
555 | u32 v; | 741 | u32 v; |
@@ -560,8 +746,10 @@ void omap3_dpll_allow_idle(struct clk *clk) | |||
560 | dd = clk->dpll_data; | 746 | dd = clk->dpll_data; |
561 | 747 | ||
562 | if (!dd->autoidle_reg) { | 748 | if (!dd->autoidle_reg) { |
749 | #ifndef CONFIG_COMMON_CLK | ||
563 | pr_debug("clock: DPLL %s: autoidle not supported\n", | 750 | pr_debug("clock: DPLL %s: autoidle not supported\n", |
564 | __clk_get_name(clk)); | 751 | __clk_get_name(clk)); |
752 | #endif | ||
565 | return; | 753 | return; |
566 | } | 754 | } |
567 | 755 | ||
@@ -583,7 +771,11 @@ void omap3_dpll_allow_idle(struct clk *clk) | |||
583 | * | 771 | * |
584 | * Disable DPLL automatic idle control. No return value. | 772 | * Disable DPLL automatic idle control. No return value. |
585 | */ | 773 | */ |
774 | #ifdef CONFIG_COMMON_CLK | ||
775 | void omap3_dpll_deny_idle(struct clk_hw_omap *clk) | ||
776 | #else | ||
586 | void omap3_dpll_deny_idle(struct clk *clk) | 777 | void omap3_dpll_deny_idle(struct clk *clk) |
778 | #endif | ||
587 | { | 779 | { |
588 | const struct dpll_data *dd; | 780 | const struct dpll_data *dd; |
589 | u32 v; | 781 | u32 v; |
@@ -594,8 +786,10 @@ void omap3_dpll_deny_idle(struct clk *clk) | |||
594 | dd = clk->dpll_data; | 786 | dd = clk->dpll_data; |
595 | 787 | ||
596 | if (!dd->autoidle_reg) { | 788 | if (!dd->autoidle_reg) { |
789 | #ifndef CONFIG_COMMON_CLK | ||
597 | pr_debug("clock: DPLL %s: autoidle not supported\n", | 790 | pr_debug("clock: DPLL %s: autoidle not supported\n", |
598 | __clk_get_name(clk)); | 791 | __clk_get_name(clk)); |
792 | #endif | ||
599 | return; | 793 | return; |
600 | } | 794 | } |
601 | 795 | ||
@@ -615,6 +809,27 @@ void omap3_dpll_deny_idle(struct clk *clk) | |||
615 | * Using parent clock DPLL data, look up DPLL state. If locked, set our | 809 | * Using parent clock DPLL data, look up DPLL state. If locked, set our |
616 | * rate to the dpll_clk * 2; otherwise, just use dpll_clk. | 810 | * rate to the dpll_clk * 2; otherwise, just use dpll_clk. |
617 | */ | 811 | */ |
812 | #ifdef CONFIG_COMMON_CLK | ||
813 | unsigned long omap3_clkoutx2_recalc(struct clk_hw *hw, | ||
814 | unsigned long parent_rate) | ||
815 | { | ||
816 | const struct dpll_data *dd; | ||
817 | unsigned long rate; | ||
818 | u32 v; | ||
819 | struct clk_hw_omap *pclk = NULL; | ||
820 | struct clk *parent; | ||
821 | |||
822 | /* Walk up the parents of clk, looking for a DPLL */ | ||
823 | do { | ||
824 | do { | ||
825 | parent = __clk_get_parent(hw->clk); | ||
826 | hw = __clk_get_hw(parent); | ||
827 | } while (hw && (__clk_get_flags(hw->clk) & CLK_IS_BASIC)); | ||
828 | if (!hw) | ||
829 | break; | ||
830 | pclk = to_clk_hw_omap(hw); | ||
831 | } while (pclk && !pclk->dpll_data); | ||
832 | #else | ||
618 | unsigned long omap3_clkoutx2_recalc(struct clk *clk) | 833 | unsigned long omap3_clkoutx2_recalc(struct clk *clk) |
619 | { | 834 | { |
620 | const struct dpll_data *dd; | 835 | const struct dpll_data *dd; |
@@ -628,6 +843,8 @@ unsigned long omap3_clkoutx2_recalc(struct clk *clk) | |||
628 | while (pclk && !pclk->dpll_data) | 843 | while (pclk && !pclk->dpll_data) |
629 | pclk = __clk_get_parent(pclk); | 844 | pclk = __clk_get_parent(pclk); |
630 | 845 | ||
846 | parent_rate = __clk_get_rate(__clk_get_parent(clk)); | ||
847 | #endif | ||
631 | /* clk does not have a DPLL as a parent? error in the clock data */ | 848 | /* clk does not have a DPLL as a parent? error in the clock data */ |
632 | if (!pclk) { | 849 | if (!pclk) { |
633 | WARN_ON(1); | 850 | WARN_ON(1); |
@@ -638,7 +855,6 @@ unsigned long omap3_clkoutx2_recalc(struct clk *clk) | |||
638 | 855 | ||
639 | WARN_ON(!dd->enable_mask); | 856 | WARN_ON(!dd->enable_mask); |
640 | 857 | ||
641 | parent_rate = __clk_get_rate(__clk_get_parent(clk)); | ||
642 | v = __raw_readl(dd->control_reg) & dd->enable_mask; | 858 | v = __raw_readl(dd->control_reg) & dd->enable_mask; |
643 | v >>= __ffs(dd->enable_mask); | 859 | v >>= __ffs(dd->enable_mask); |
644 | if ((v != OMAP3XXX_EN_DPLL_LOCKED) || (dd->flags & DPLL_J_TYPE)) | 860 | if ((v != OMAP3XXX_EN_DPLL_LOCKED) || (dd->flags & DPLL_J_TYPE)) |
@@ -649,7 +865,12 @@ unsigned long omap3_clkoutx2_recalc(struct clk *clk) | |||
649 | } | 865 | } |
650 | 866 | ||
651 | /* OMAP3/4 non-CORE DPLL clkops */ | 867 | /* OMAP3/4 non-CORE DPLL clkops */ |
652 | 868 | #ifdef CONFIG_COMMON_CLK | |
869 | const struct clk_hw_omap_ops clkhwops_omap3_dpll = { | ||
870 | .allow_idle = omap3_dpll_allow_idle, | ||
871 | .deny_idle = omap3_dpll_deny_idle, | ||
872 | }; | ||
873 | #else | ||
653 | const struct clkops clkops_omap3_noncore_dpll_ops = { | 874 | const struct clkops clkops_omap3_noncore_dpll_ops = { |
654 | .enable = omap3_noncore_dpll_enable, | 875 | .enable = omap3_noncore_dpll_enable, |
655 | .disable = omap3_noncore_dpll_disable, | 876 | .disable = omap3_noncore_dpll_disable, |
@@ -661,3 +882,4 @@ const struct clkops clkops_omap3_core_dpll_ops = { | |||
661 | .allow_idle = omap3_dpll_allow_idle, | 882 | .allow_idle = omap3_dpll_allow_idle, |
662 | .deny_idle = omap3_dpll_deny_idle, | 883 | .deny_idle = omap3_dpll_deny_idle, |
663 | }; | 884 | }; |
885 | #endif | ||
diff --git a/arch/arm/mach-omap2/dpll44xx.c b/arch/arm/mach-omap2/dpll44xx.c index 5854da168a9c..aa75a3c10026 100644 --- a/arch/arm/mach-omap2/dpll44xx.c +++ b/arch/arm/mach-omap2/dpll44xx.c | |||
@@ -21,7 +21,11 @@ | |||
21 | #include "cm-regbits-44xx.h" | 21 | #include "cm-regbits-44xx.h" |
22 | 22 | ||
23 | /* Supported only on OMAP4 */ | 23 | /* Supported only on OMAP4 */ |
24 | #ifdef CONFIG_COMMON_CLK | ||
25 | int omap4_dpllmx_gatectrl_read(struct clk_hw_omap *clk) | ||
26 | #else | ||
24 | int omap4_dpllmx_gatectrl_read(struct clk *clk) | 27 | int omap4_dpllmx_gatectrl_read(struct clk *clk) |
28 | #endif | ||
25 | { | 29 | { |
26 | u32 v; | 30 | u32 v; |
27 | u32 mask; | 31 | u32 mask; |
@@ -40,7 +44,11 @@ int omap4_dpllmx_gatectrl_read(struct clk *clk) | |||
40 | return v; | 44 | return v; |
41 | } | 45 | } |
42 | 46 | ||
47 | #ifdef CONFIG_COMMON_CLK | ||
48 | void omap4_dpllmx_allow_gatectrl(struct clk_hw_omap *clk) | ||
49 | #else | ||
43 | void omap4_dpllmx_allow_gatectrl(struct clk *clk) | 50 | void omap4_dpllmx_allow_gatectrl(struct clk *clk) |
51 | #endif | ||
44 | { | 52 | { |
45 | u32 v; | 53 | u32 v; |
46 | u32 mask; | 54 | u32 mask; |
@@ -58,7 +66,11 @@ void omap4_dpllmx_allow_gatectrl(struct clk *clk) | |||
58 | __raw_writel(v, clk->clksel_reg); | 66 | __raw_writel(v, clk->clksel_reg); |
59 | } | 67 | } |
60 | 68 | ||
69 | #ifdef CONFIG_COMMON_CLK | ||
70 | void omap4_dpllmx_deny_gatectrl(struct clk_hw_omap *clk) | ||
71 | #else | ||
61 | void omap4_dpllmx_deny_gatectrl(struct clk *clk) | 72 | void omap4_dpllmx_deny_gatectrl(struct clk *clk) |
73 | #endif | ||
62 | { | 74 | { |
63 | u32 v; | 75 | u32 v; |
64 | u32 mask; | 76 | u32 mask; |
@@ -76,10 +88,17 @@ void omap4_dpllmx_deny_gatectrl(struct clk *clk) | |||
76 | __raw_writel(v, clk->clksel_reg); | 88 | __raw_writel(v, clk->clksel_reg); |
77 | } | 89 | } |
78 | 90 | ||
91 | #ifdef CONFIG_COMMON_CLK | ||
92 | const struct clk_hw_omap_ops clkhwops_omap4_dpllmx = { | ||
93 | .allow_idle = omap4_dpllmx_allow_gatectrl, | ||
94 | .deny_idle = omap4_dpllmx_deny_gatectrl, | ||
95 | }; | ||
96 | #else | ||
79 | const struct clkops clkops_omap4_dpllmx_ops = { | 97 | const struct clkops clkops_omap4_dpllmx_ops = { |
80 | .allow_idle = omap4_dpllmx_allow_gatectrl, | 98 | .allow_idle = omap4_dpllmx_allow_gatectrl, |
81 | .deny_idle = omap4_dpllmx_deny_gatectrl, | 99 | .deny_idle = omap4_dpllmx_deny_gatectrl, |
82 | }; | 100 | }; |
101 | #endif | ||
83 | 102 | ||
84 | /** | 103 | /** |
85 | * omap4_dpll_regm4xen_recalc - compute DPLL rate, considering REGM4XEN bit | 104 | * omap4_dpll_regm4xen_recalc - compute DPLL rate, considering REGM4XEN bit |
@@ -90,8 +109,15 @@ const struct clkops clkops_omap4_dpllmx_ops = { | |||
90 | * OMAP4 ABE DPLL. Returns the DPLL's output rate (before M-dividers) | 109 | * OMAP4 ABE DPLL. Returns the DPLL's output rate (before M-dividers) |
91 | * upon success, or 0 upon error. | 110 | * upon success, or 0 upon error. |
92 | */ | 111 | */ |
112 | #ifdef CONFIG_COMMON_CLK | ||
113 | unsigned long omap4_dpll_regm4xen_recalc(struct clk_hw *hw, | ||
114 | unsigned long parent_rate) | ||
115 | { | ||
116 | struct clk_hw_omap *clk = to_clk_hw_omap(hw); | ||
117 | #else | ||
93 | unsigned long omap4_dpll_regm4xen_recalc(struct clk *clk) | 118 | unsigned long omap4_dpll_regm4xen_recalc(struct clk *clk) |
94 | { | 119 | { |
120 | #endif | ||
95 | u32 v; | 121 | u32 v; |
96 | unsigned long rate; | 122 | unsigned long rate; |
97 | struct dpll_data *dd; | 123 | struct dpll_data *dd; |
@@ -123,8 +149,16 @@ unsigned long omap4_dpll_regm4xen_recalc(struct clk *clk) | |||
123 | * M-dividers) upon success, -EINVAL if @clk is null or not a DPLL, or | 149 | * M-dividers) upon success, -EINVAL if @clk is null or not a DPLL, or |
124 | * ~0 if an error occurred in omap2_dpll_round_rate(). | 150 | * ~0 if an error occurred in omap2_dpll_round_rate(). |
125 | */ | 151 | */ |
152 | #ifdef CONFIG_COMMON_CLK | ||
153 | long omap4_dpll_regm4xen_round_rate(struct clk_hw *hw, | ||
154 | unsigned long target_rate, | ||
155 | unsigned long *parent_rate) | ||
156 | { | ||
157 | struct clk_hw_omap *clk = to_clk_hw_omap(hw); | ||
158 | #else | ||
126 | long omap4_dpll_regm4xen_round_rate(struct clk *clk, unsigned long target_rate) | 159 | long omap4_dpll_regm4xen_round_rate(struct clk *clk, unsigned long target_rate) |
127 | { | 160 | { |
161 | #endif | ||
128 | u32 v; | 162 | u32 v; |
129 | struct dpll_data *dd; | 163 | struct dpll_data *dd; |
130 | long r; | 164 | long r; |
@@ -140,7 +174,11 @@ long omap4_dpll_regm4xen_round_rate(struct clk *clk, unsigned long target_rate) | |||
140 | if (v) | 174 | if (v) |
141 | target_rate = target_rate / OMAP4430_REGM4XEN_MULT; | 175 | target_rate = target_rate / OMAP4430_REGM4XEN_MULT; |
142 | 176 | ||
177 | #ifdef CONFIG_COMMON_CLK | ||
178 | r = omap2_dpll_round_rate(hw, target_rate, NULL); | ||
179 | #else | ||
143 | r = omap2_dpll_round_rate(clk, target_rate); | 180 | r = omap2_dpll_round_rate(clk, target_rate); |
181 | #endif | ||
144 | if (r == ~0) | 182 | if (r == ~0) |
145 | return r; | 183 | return r; |
146 | 184 | ||