Skip to content

Commit

Permalink
Merge tag 'nios2-v4.2' of git://git.rocketboards.org/linux-socfpga-next
Browse files Browse the repository at this point in the history
Pull nios2 update from Ley Foon Tan:
 "Check number of timer instances"

* tag 'nios2-v4.2' of git://git.rocketboards.org/linux-socfpga-next:
  nios2: check number of timer instances
  • Loading branch information
torvalds committed Jul 3, 2015
2 parents 9a3c284 + a8955cc commit 31351f7
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions arch/nios2/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,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
Expand Down Expand Up @@ -304,7 +306,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);

0 comments on commit 31351f7

Please sign in to comment.