summaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-epxa10db/time.c
blob: 1b991f3cc3c6a51adee517c270e6cca55ff0ce2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
 *  linux/arch/arm/mach-epxa10db/time.c
 *
 *  Copyright (C) 2000 Deep Blue Solutions
 *  Copyright (C) 2001 Altera Corporation
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/sched.h>

#include <asm/hardware.h>
#include <asm/system.h>
#include <asm/leds.h>

#include <asm/mach/time.h>

#define TIMER00_TYPE (volatile unsigned int*)
#include <asm/arch/timer00.h>

static int epxa10db_set_rtc(void)
{
	return 1;
}

static int epxa10db_rtc_init(void)
{
	set_rtc = epxa10db_set_rtc;

	return 0;
}

__initcall(epxa10db_rtc_init);


/*
 * IRQ handler for the timer
 */
static irqreturn_t
epxa10db_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
{
	write_seqlock(&xtime_lock);

	// ...clear the interrupt
	*TIMER0_CR(IO_ADDRESS(EXC_TIMER00_BASE))|=TIMER0_CR_CI_MSK;

	timer_tick(regs);
	write_sequnlock(&xtime_lock);

	return IRQ_HANDLED;
}

static struct irqaction epxa10db_timer_irq = {
	.name		= "Excalibur Timer Tick",
	.flags		= SA_INTERRUPT,
	.handler	= epxa10db_timer_interrupt
};

/*
 * Set up timer interrupt, and return the current time in seconds.
 */
static void __init epxa10db_timer_init(void)
{
	/* Start the timer */
	*TIMER0_LIMIT(IO_ADDRESS(EXC_TIMER00_BASE))=(unsigned int)(EXC_AHB2_CLK_FREQUENCY/200);
	*TIMER0_PRESCALE(IO_ADDRESS(EXC_TIMER00_BASE))=1;
	*TIMER0_CR(IO_ADDRESS(EXC_TIMER00_BASE))=TIMER0_CR_IE_MSK | TIMER0_CR_S_MSK;

	setup_irq(IRQ_TIMER0, &epxa10db_timer_irq);
}

struct sys_timer epxa10db_timer = {
	.init		= epxa10db_timer_init,
};