diff options
author | Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> | 2013-09-22 12:17:28 -0400 |
---|---|---|
committer | Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> | 2013-09-29 15:06:58 -0400 |
commit | ea25a900f593cd34347ec884b3acac09ffe07667 (patch) | |
tree | aa19580c8a00702f20349895ddbc5aa4d7ed6ff0 | |
parent | 4db7634336156254b179b66f6a9fe90d75c44ee4 (diff) |
clk: nomadik: move src init out of nomadik_clk_init
nomadik_clk_init currently also maps system reset controller base address
used by clocks and registers a reboot notifier. To allow further cleanup of
nomadik clk setup, this moves system reset controller setup from
nomadik_clk_init to its own function.
Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Mike Turquette <mturquette@linaro.org>
-rw-r--r-- | drivers/clk/clk-nomadik.c | 144 |
1 files changed, 74 insertions, 70 deletions
diff --git a/drivers/clk/clk-nomadik.c b/drivers/clk/clk-nomadik.c index 4d978a3c88f7..06b29c264dbe 100644 --- a/drivers/clk/clk-nomadik.c +++ b/drivers/clk/clk-nomadik.c | |||
@@ -62,6 +62,79 @@ static DEFINE_SPINLOCK(src_lock); | |||
62 | /* Base address of the SRC */ | 62 | /* Base address of the SRC */ |
63 | static void __iomem *src_base; | 63 | static void __iomem *src_base; |
64 | 64 | ||
65 | static int nomadik_clk_reboot_handler(struct notifier_block *this, | ||
66 | unsigned long code, | ||
67 | void *unused) | ||
68 | { | ||
69 | u32 val; | ||
70 | |||
71 | /* The main chrystal need to be enabled for reboot to work */ | ||
72 | val = readl(src_base + SRC_XTALCR); | ||
73 | val &= ~SRC_XTALCR_MXTALOVER; | ||
74 | val |= SRC_XTALCR_MXTALEN; | ||
75 | pr_crit("force-enabling MXTALO\n"); | ||
76 | writel(val, src_base + SRC_XTALCR); | ||
77 | return NOTIFY_OK; | ||
78 | } | ||
79 | |||
80 | static struct notifier_block nomadik_clk_reboot_notifier = { | ||
81 | .notifier_call = nomadik_clk_reboot_handler, | ||
82 | }; | ||
83 | |||
84 | static const struct of_device_id nomadik_src_match[] __initconst = { | ||
85 | { .compatible = "stericsson,nomadik-src" }, | ||
86 | { /* sentinel */ } | ||
87 | }; | ||
88 | |||
89 | static void nomadik_src_init(void) | ||
90 | { | ||
91 | struct device_node *np; | ||
92 | u32 val; | ||
93 | |||
94 | np = of_find_matching_node(NULL, nomadik_src_match); | ||
95 | if (!np) { | ||
96 | pr_crit("no matching node for SRC, aborting clock init\n"); | ||
97 | return; | ||
98 | } | ||
99 | src_base = of_iomap(np, 0); | ||
100 | if (!src_base) { | ||
101 | pr_err("%s: must have src parent node with REGS (%s)\n", | ||
102 | __func__, np->name); | ||
103 | return; | ||
104 | } | ||
105 | |||
106 | /* Set all timers to use the 2.4 MHz TIMCLK */ | ||
107 | val = readl(src_base + SRC_CR); | ||
108 | val |= SRC_CR_T0_ENSEL; | ||
109 | val |= SRC_CR_T1_ENSEL; | ||
110 | val |= SRC_CR_T2_ENSEL; | ||
111 | val |= SRC_CR_T3_ENSEL; | ||
112 | val |= SRC_CR_T4_ENSEL; | ||
113 | val |= SRC_CR_T5_ENSEL; | ||
114 | val |= SRC_CR_T6_ENSEL; | ||
115 | val |= SRC_CR_T7_ENSEL; | ||
116 | writel(val, src_base + SRC_CR); | ||
117 | |||
118 | val = readl(src_base + SRC_XTALCR); | ||
119 | pr_info("SXTALO is %s\n", | ||
120 | (val & SRC_XTALCR_SXTALDIS) ? "disabled" : "enabled"); | ||
121 | pr_info("MXTAL is %s\n", | ||
122 | (val & SRC_XTALCR_MXTALSTAT) ? "enabled" : "disabled"); | ||
123 | if (of_property_read_bool(np, "disable-sxtalo")) { | ||
124 | /* The machine uses an external oscillator circuit */ | ||
125 | val |= SRC_XTALCR_SXTALDIS; | ||
126 | pr_info("disabling SXTALO\n"); | ||
127 | } | ||
128 | if (of_property_read_bool(np, "disable-mxtalo")) { | ||
129 | /* Disable this too: also run by external oscillator */ | ||
130 | val |= SRC_XTALCR_MXTALOVER; | ||
131 | val &= ~SRC_XTALCR_MXTALEN; | ||
132 | pr_info("disabling MXTALO\n"); | ||
133 | } | ||
134 | writel(val, src_base + SRC_XTALCR); | ||
135 | register_reboot_notifier(&nomadik_clk_reboot_notifier); | ||
136 | } | ||
137 | |||
65 | /** | 138 | /** |
66 | * struct clk_pll1 - Nomadik PLL1 clock | 139 | * struct clk_pll1 - Nomadik PLL1 clock |
67 | * @hw: corresponding clock hardware entry | 140 | * @hw: corresponding clock hardware entry |
@@ -487,11 +560,6 @@ static void __init of_nomadik_src_clk_setup(struct device_node *np) | |||
487 | of_clk_add_provider(np, of_clk_src_simple_get, clk); | 560 | of_clk_add_provider(np, of_clk_src_simple_get, clk); |
488 | } | 561 | } |
489 | 562 | ||
490 | static const struct of_device_id nomadik_src_match[] __initconst = { | ||
491 | { .compatible = "stericsson,nomadik-src" }, | ||
492 | { /* sentinel */ } | ||
493 | }; | ||
494 | |||
495 | static const struct of_device_id nomadik_src_clk_match[] __initconst = { | 563 | static const struct of_device_id nomadik_src_clk_match[] __initconst = { |
496 | { | 564 | { |
497 | .compatible = "fixed-clock", | 565 | .compatible = "fixed-clock", |
@@ -516,72 +584,8 @@ static const struct of_device_id nomadik_src_clk_match[] __initconst = { | |||
516 | { /* sentinel */ } | 584 | { /* sentinel */ } |
517 | }; | 585 | }; |
518 | 586 | ||
519 | static int nomadik_clk_reboot_handler(struct notifier_block *this, | ||
520 | unsigned long code, | ||
521 | void *unused) | ||
522 | { | ||
523 | u32 val; | ||
524 | |||
525 | /* The main chrystal need to be enabled for reboot to work */ | ||
526 | val = readl(src_base + SRC_XTALCR); | ||
527 | val &= ~SRC_XTALCR_MXTALOVER; | ||
528 | val |= SRC_XTALCR_MXTALEN; | ||
529 | pr_crit("force-enabling MXTALO\n"); | ||
530 | writel(val, src_base + SRC_XTALCR); | ||
531 | return NOTIFY_OK; | ||
532 | } | ||
533 | |||
534 | static struct notifier_block nomadik_clk_reboot_notifier = { | ||
535 | .notifier_call = nomadik_clk_reboot_handler, | ||
536 | }; | ||
537 | |||
538 | void __init nomadik_clk_init(void) | 587 | void __init nomadik_clk_init(void) |
539 | { | 588 | { |
540 | struct device_node *np; | 589 | nomadik_src_init(); |
541 | u32 val; | ||
542 | |||
543 | np = of_find_matching_node(NULL, nomadik_src_match); | ||
544 | if (!np) { | ||
545 | pr_crit("no matching node for SRC, aborting clock init\n"); | ||
546 | return; | ||
547 | } | ||
548 | src_base = of_iomap(np, 0); | ||
549 | if (!src_base) { | ||
550 | pr_err("%s: must have src parent node with REGS (%s)\n", | ||
551 | __func__, np->name); | ||
552 | return; | ||
553 | } | ||
554 | |||
555 | /* Set all timers to use the 2.4 MHz TIMCLK */ | ||
556 | val = readl(src_base + SRC_CR); | ||
557 | val |= SRC_CR_T0_ENSEL; | ||
558 | val |= SRC_CR_T1_ENSEL; | ||
559 | val |= SRC_CR_T2_ENSEL; | ||
560 | val |= SRC_CR_T3_ENSEL; | ||
561 | val |= SRC_CR_T4_ENSEL; | ||
562 | val |= SRC_CR_T5_ENSEL; | ||
563 | val |= SRC_CR_T6_ENSEL; | ||
564 | val |= SRC_CR_T7_ENSEL; | ||
565 | writel(val, src_base + SRC_CR); | ||
566 | |||
567 | val = readl(src_base + SRC_XTALCR); | ||
568 | pr_info("SXTALO is %s\n", | ||
569 | (val & SRC_XTALCR_SXTALDIS) ? "disabled" : "enabled"); | ||
570 | pr_info("MXTAL is %s\n", | ||
571 | (val & SRC_XTALCR_MXTALSTAT) ? "enabled" : "disabled"); | ||
572 | if (of_property_read_bool(np, "disable-sxtalo")) { | ||
573 | /* The machine uses an external oscillator circuit */ | ||
574 | val |= SRC_XTALCR_SXTALDIS; | ||
575 | pr_info("disabling SXTALO\n"); | ||
576 | } | ||
577 | if (of_property_read_bool(np, "disable-mxtalo")) { | ||
578 | /* Disable this too: also run by external oscillator */ | ||
579 | val |= SRC_XTALCR_MXTALOVER; | ||
580 | val &= ~SRC_XTALCR_MXTALEN; | ||
581 | pr_info("disabling MXTALO\n"); | ||
582 | } | ||
583 | writel(val, src_base + SRC_XTALCR); | ||
584 | register_reboot_notifier(&nomadik_clk_reboot_notifier); | ||
585 | |||
586 | of_clk_init(nomadik_src_clk_match); | 590 | of_clk_init(nomadik_src_clk_match); |
587 | } | 591 | } |