diff options
Diffstat (limited to 'drivers/clk/at91')
-rw-r--r-- | drivers/clk/at91/clk-slow.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/clk/at91/clk-slow.c b/drivers/clk/at91/clk-slow.c index 32f7c1b36204..2f13bd5246b5 100644 --- a/drivers/clk/at91/clk-slow.c +++ b/drivers/clk/at91/clk-slow.c | |||
@@ -70,6 +70,7 @@ struct clk_sam9x5_slow { | |||
70 | 70 | ||
71 | #define to_clk_sam9x5_slow(hw) container_of(hw, struct clk_sam9x5_slow, hw) | 71 | #define to_clk_sam9x5_slow(hw) container_of(hw, struct clk_sam9x5_slow, hw) |
72 | 72 | ||
73 | static struct clk *slow_clk; | ||
73 | 74 | ||
74 | static int clk_slow_osc_prepare(struct clk_hw *hw) | 75 | static int clk_slow_osc_prepare(struct clk_hw *hw) |
75 | { | 76 | { |
@@ -357,6 +358,8 @@ at91_clk_register_sam9x5_slow(void __iomem *sckcr, | |||
357 | clk = clk_register(NULL, &slowck->hw); | 358 | clk = clk_register(NULL, &slowck->hw); |
358 | if (IS_ERR(clk)) | 359 | if (IS_ERR(clk)) |
359 | kfree(slowck); | 360 | kfree(slowck); |
361 | else | ||
362 | slow_clk = clk; | ||
360 | 363 | ||
361 | return clk; | 364 | return clk; |
362 | } | 365 | } |
@@ -433,6 +436,8 @@ at91_clk_register_sam9260_slow(struct at91_pmc *pmc, | |||
433 | clk = clk_register(NULL, &slowck->hw); | 436 | clk = clk_register(NULL, &slowck->hw); |
434 | if (IS_ERR(clk)) | 437 | if (IS_ERR(clk)) |
435 | kfree(slowck); | 438 | kfree(slowck); |
439 | else | ||
440 | slow_clk = clk; | ||
436 | 441 | ||
437 | return clk; | 442 | return clk; |
438 | } | 443 | } |
@@ -465,3 +470,25 @@ void __init of_at91sam9260_clk_slow_setup(struct device_node *np, | |||
465 | 470 | ||
466 | of_clk_add_provider(np, of_clk_src_simple_get, clk); | 471 | of_clk_add_provider(np, of_clk_src_simple_get, clk); |
467 | } | 472 | } |
473 | |||
474 | /* | ||
475 | * FIXME: All slow clk users are not properly claiming it (get + prepare + | ||
476 | * enable) before using it. | ||
477 | * If all users properly claiming this clock decide that they don't need it | ||
478 | * anymore (or are removed), it is disabled while faulty users are still | ||
479 | * requiring it, and the system hangs. | ||
480 | * Prevent this clock from being disabled until all users are properly | ||
481 | * requesting it. | ||
482 | * Once this is done we should remove this function and the slow_clk variable. | ||
483 | */ | ||
484 | static int __init of_at91_clk_slow_retain(void) | ||
485 | { | ||
486 | if (!slow_clk) | ||
487 | return 0; | ||
488 | |||
489 | __clk_get(slow_clk); | ||
490 | clk_prepare_enable(slow_clk); | ||
491 | |||
492 | return 0; | ||
493 | } | ||
494 | arch_initcall(of_at91_clk_slow_retain); | ||