aboutsummaryrefslogtreecommitdiff
path: root/arch/nios2
diff options
context:
space:
mode:
authorLey Foon Tan2015-06-24 17:52:44 +0800
committerLey Foon Tan2015-06-24 17:52:44 +0800
commita8955cc3a504e43ecd606e9f0d9bc25de240aacb (patch)
treee3cd5caf38fd2b6e6b13e08ca1a10132fcbde6c6 /arch/nios2
parentb953c0d234bc72e8489d3bf51a276c5c4ec85345 (diff)
nios2: check number of timer instances
Display error message if number of timers is less than 2. Signed-off-by: Ley Foon Tan <lftan@altera.com>
Diffstat (limited to 'arch/nios2')
-rw-r--r--arch/nios2/kernel/time.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/arch/nios2/kernel/time.c b/arch/nios2/kernel/time.c
index 7f4547418ee1..bea8839d56d8 100644
--- a/arch/nios2/kernel/time.c
+++ b/arch/nios2/kernel/time.c
@@ -18,7 +18,9 @@
#include <linux/io.h>
#include <linux/slab.h>
-#define ALTERA_TIMER_STATUS_REG 0
+#define ALTR_TIMER_COMPATIBLE "altr,timer-1.0"
+
+#define ALTERA_TIMER_STATUS_REG 0
#define ALTERA_TIMER_CONTROL_REG 4
#define ALTERA_TIMER_PERIODL_REG 8
#define ALTERA_TIMER_PERIODH_REG 12
@@ -302,7 +304,16 @@ void read_persistent_clock(struct timespec *ts)
void __init time_init(void)
{
+ struct device_node *np;
+ int count = 0;
+
+ for_each_compatible_node(np, NULL, ALTR_TIMER_COMPATIBLE)
+ count++;
+
+ if (count < 2)
+ panic("%d timer is found, it needs 2 timers in system\n", count);
+
clocksource_of_init();
}
-CLOCKSOURCE_OF_DECLARE(nios2_timer, "altr,timer-1.0", nios2_time_init);
+CLOCKSOURCE_OF_DECLARE(nios2_timer, ALTR_TIMER_COMPATIBLE, nios2_time_init);