diff options
author | Andrew Bresticker <abrestic@chromium.org> | 2014-11-12 14:43:39 -0500 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2014-11-24 01:45:30 -0500 |
commit | e12aa828ff42bae894e4eb7350d4dbf46eb19084 (patch) | |
tree | 21f3a16bcb5d20bb591c6a13915a50bb40576509 /drivers/clocksource/mips-gic-timer.c | |
parent | a7057270c280a5904d747f40e53b5402e7dddc0e (diff) |
clocksource: mips-gic: Add device-tree support
Parse the GIC timer frequency and interrupt from the device-tree.
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Pawel Moll <pawel.moll@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Ian Campbell <ijc+devicetree@hellion.org.uk>
Cc: Kumar Gala <galak@codeaurora.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Jason Cooper <jason@lakedaemon.net>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: John Crispin <blogic@openwrt.org>
Cc: David Daney <ddaney.cavm@gmail.com>
Cc: Qais Yousef <qais.yousef@imgtec.com>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: linux-mips@linux-mips.org
Cc: devicetree@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/8421/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'drivers/clocksource/mips-gic-timer.c')
-rw-r--r-- | drivers/clocksource/mips-gic-timer.c | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/drivers/clocksource/mips-gic-timer.c b/drivers/clocksource/mips-gic-timer.c index a749c812e255..3bd31b1321f6 100644 --- a/drivers/clocksource/mips-gic-timer.c +++ b/drivers/clocksource/mips-gic-timer.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/interrupt.h> | 11 | #include <linux/interrupt.h> |
12 | #include <linux/irqchip/mips-gic.h> | 12 | #include <linux/irqchip/mips-gic.h> |
13 | #include <linux/notifier.h> | 13 | #include <linux/notifier.h> |
14 | #include <linux/of_irq.h> | ||
14 | #include <linux/percpu.h> | 15 | #include <linux/percpu.h> |
15 | #include <linux/smp.h> | 16 | #include <linux/smp.h> |
16 | #include <linux/time.h> | 17 | #include <linux/time.h> |
@@ -101,8 +102,6 @@ static int gic_clockevent_init(void) | |||
101 | if (!cpu_has_counter || !gic_frequency) | 102 | if (!cpu_has_counter || !gic_frequency) |
102 | return -ENXIO; | 103 | return -ENXIO; |
103 | 104 | ||
104 | gic_timer_irq = MIPS_GIC_IRQ_BASE + | ||
105 | GIC_LOCAL_TO_HWIRQ(GIC_LOCAL_INT_COMPARE); | ||
106 | setup_percpu_irq(gic_timer_irq, &gic_compare_irqaction); | 105 | setup_percpu_irq(gic_timer_irq, &gic_compare_irqaction); |
107 | 106 | ||
108 | register_cpu_notifier(&gic_cpu_nb); | 107 | register_cpu_notifier(&gic_cpu_nb); |
@@ -123,17 +122,45 @@ static struct clocksource gic_clocksource = { | |||
123 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, | 122 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, |
124 | }; | 123 | }; |
125 | 124 | ||
126 | void __init gic_clocksource_init(unsigned int frequency) | 125 | static void __init __gic_clocksource_init(void) |
127 | { | 126 | { |
128 | gic_frequency = frequency; | ||
129 | |||
130 | /* Set clocksource mask. */ | 127 | /* Set clocksource mask. */ |
131 | gic_clocksource.mask = CLOCKSOURCE_MASK(gic_get_count_width()); | 128 | gic_clocksource.mask = CLOCKSOURCE_MASK(gic_get_count_width()); |
132 | 129 | ||
133 | /* Calculate a somewhat reasonable rating value. */ | 130 | /* Calculate a somewhat reasonable rating value. */ |
134 | gic_clocksource.rating = 200 + frequency / 10000000; | 131 | gic_clocksource.rating = 200 + gic_frequency / 10000000; |
135 | 132 | ||
136 | clocksource_register_hz(&gic_clocksource, frequency); | 133 | clocksource_register_hz(&gic_clocksource, gic_frequency); |
137 | 134 | ||
138 | gic_clockevent_init(); | 135 | gic_clockevent_init(); |
139 | } | 136 | } |
137 | |||
138 | void __init gic_clocksource_init(unsigned int frequency) | ||
139 | { | ||
140 | gic_frequency = frequency; | ||
141 | gic_timer_irq = MIPS_GIC_IRQ_BASE + | ||
142 | GIC_LOCAL_TO_HWIRQ(GIC_LOCAL_INT_COMPARE); | ||
143 | |||
144 | __gic_clocksource_init(); | ||
145 | } | ||
146 | |||
147 | static void __init gic_clocksource_of_init(struct device_node *node) | ||
148 | { | ||
149 | if (WARN_ON(!gic_present || !node->parent || | ||
150 | !of_device_is_compatible(node->parent, "mti,gic"))) | ||
151 | return; | ||
152 | |||
153 | if (of_property_read_u32(node, "clock-frequency", &gic_frequency)) { | ||
154 | pr_err("GIC frequency not specified.\n"); | ||
155 | return; | ||
156 | } | ||
157 | gic_timer_irq = irq_of_parse_and_map(node, 0); | ||
158 | if (!gic_timer_irq) { | ||
159 | pr_err("GIC timer IRQ not specified.\n"); | ||
160 | return; | ||
161 | } | ||
162 | |||
163 | __gic_clocksource_init(); | ||
164 | } | ||
165 | CLOCKSOURCE_OF_DECLARE(mips_gic_timer, "mti,gic-timer", | ||
166 | gic_clocksource_of_init); | ||