@@ -240,6 +240,7 @@ config KEYSTONE_TIMER
config INTEGRATOR_AP_TIMER
bool "Integrator-ap timer driver" if COMPILE_TEST
select CLKSRC_MMIO
+ select TIMER_OF
help
Enables support for the Integrator-ap timer.
@@ -14,6 +14,7 @@
#include <linux/interrupt.h>
#include <linux/sched_clock.h>
+#include "timer-of.h"
#include "timer-sp.h"
static void __iomem * sched_clk_base;
@@ -160,6 +161,12 @@ static int integrator_clockevent_init(unsigned long inrate,
return 0;
}
+static struct timer_of to[] = {
+ { .flags = TIMER_OF_TYPE_CS, },
+ { .flags = TIMER_OF_TYPE_CE, },
+ { /* sentinel */ }
+};
+
static int __init integrator_ap_timer_init_of(struct device_node *node)
{
const char *path;
@@ -169,6 +176,7 @@ static int __init integrator_ap_timer_init_of(struct device_node *node)
struct clk *clk;
unsigned long rate;
struct device_node *alias_node;
+ struct timer_of *to = node->data;
base = of_io_request_and_map(node, 0, "integrator-timer");
if (IS_ERR(base))
@@ -183,6 +191,17 @@ static int __init integrator_ap_timer_init_of(struct device_node *node)
rate = clk_get_rate(clk);
writel(0, base + TIMER_CTRL);
+ if (timer_of_is_clocksource(to))
+ /* The primary timer lacks IRQ, use as clocksource */
+ return integrator_clocksource_init(rate, base);
+
+ if (timer_of_is_clockevent(to)) {
+ /* The secondary timer will drive the clock event */
+ irq = irq_of_parse_and_map(node, 0);
+ return integrator_clockevent_init(rate, base, irq);
+ }
+
+ /* DT ABI compatibility below */
err = of_property_read_string(of_aliases,
"arm,timer-primary", &path);
if (err) {
@@ -227,4 +246,4 @@ static int __init integrator_ap_timer_init_of(struct device_node *node)
}
TIMER_OF_DECLARE(integrator_ap_timer, "arm,integrator-timer",
- integrator_ap_timer_init_of, NULL);
+ integrator_ap_timer_init_of, to);