Commit e12aa828ff42bae894e4eb7350d4dbf46eb19084

Authored by Andrew Bresticker
Committed by Ralf Baechle
1 parent a7057270c2

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>

Showing 2 changed files with 35 additions and 7 deletions Side-by-side Diff

drivers/clocksource/Kconfig
... ... @@ -226,6 +226,7 @@
226 226 config CLKSRC_MIPS_GIC
227 227 bool
228 228 depends on MIPS_GIC
  229 + select CLKSRC_OF
229 230  
230 231 endmenu
drivers/clocksource/mips-gic-timer.c
... ... @@ -11,6 +11,7 @@
11 11 #include <linux/interrupt.h>
12 12 #include <linux/irqchip/mips-gic.h>
13 13 #include <linux/notifier.h>
  14 +#include <linux/of_irq.h>
14 15 #include <linux/percpu.h>
15 16 #include <linux/smp.h>
16 17 #include <linux/time.h>
... ... @@ -101,8 +102,6 @@
101 102 if (!cpu_has_counter || !gic_frequency)
102 103 return -ENXIO;
103 104  
104   - gic_timer_irq = MIPS_GIC_IRQ_BASE +
105   - GIC_LOCAL_TO_HWIRQ(GIC_LOCAL_INT_COMPARE);
106 105 setup_percpu_irq(gic_timer_irq, &gic_compare_irqaction);
107 106  
108 107 register_cpu_notifier(&gic_cpu_nb);
109 108  
110 109  
111 110  
112 111  
... ... @@ -123,18 +122,46 @@
123 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 127 /* Set clocksource mask. */
131 128 gic_clocksource.mask = CLOCKSOURCE_MASK(gic_get_count_width());
132 129  
133 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 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);