diff options
author | Ley Foon Tan <lftan@altera.com> | 2015-06-24 05:52:44 -0400 |
---|---|---|
committer | Ley Foon Tan <lftan@altera.com> | 2015-06-24 05:52:44 -0400 |
commit | a8955cc3a504e43ecd606e9f0d9bc25de240aacb (patch) | |
tree | e3cd5caf38fd2b6e6b13e08ca1a10132fcbde6c6 /arch/nios2 | |
parent | b953c0d234bc72e8489d3bf51a276c5c4ec85345 (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.c | 15 |
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 @@ | |||
18 | #include <linux/io.h> | 18 | #include <linux/io.h> |
19 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
20 | 20 | ||
21 | #define ALTERA_TIMER_STATUS_REG 0 | 21 | #define ALTR_TIMER_COMPATIBLE "altr,timer-1.0" |
22 | |||
23 | #define ALTERA_TIMER_STATUS_REG 0 | ||
22 | #define ALTERA_TIMER_CONTROL_REG 4 | 24 | #define ALTERA_TIMER_CONTROL_REG 4 |
23 | #define ALTERA_TIMER_PERIODL_REG 8 | 25 | #define ALTERA_TIMER_PERIODL_REG 8 |
24 | #define ALTERA_TIMER_PERIODH_REG 12 | 26 | #define ALTERA_TIMER_PERIODH_REG 12 |
@@ -302,7 +304,16 @@ void read_persistent_clock(struct timespec *ts) | |||
302 | 304 | ||
303 | void __init time_init(void) | 305 | void __init time_init(void) |
304 | { | 306 | { |
307 | struct device_node *np; | ||
308 | int count = 0; | ||
309 | |||
310 | for_each_compatible_node(np, NULL, ALTR_TIMER_COMPATIBLE) | ||
311 | count++; | ||
312 | |||
313 | if (count < 2) | ||
314 | panic("%d timer is found, it needs 2 timers in system\n", count); | ||
315 | |||
305 | clocksource_of_init(); | 316 | clocksource_of_init(); |
306 | } | 317 | } |
307 | 318 | ||
308 | CLOCKSOURCE_OF_DECLARE(nios2_timer, "altr,timer-1.0", nios2_time_init); | 319 | CLOCKSOURCE_OF_DECLARE(nios2_timer, ALTR_TIMER_COMPATIBLE, nios2_time_init); |