2 +++ b/arch/arm/plat-fa/include/plat/time.h
5 + * Copyright (c) 2010 Gabor Juhos <juhosg@openwrt.org>
7 + * This program is free software; you can redistribute it and/or modify
8 + * it under the terms of the GNU General Public License as published by
9 + * the Free Software Foundation; either version 2 of the License, or
10 + * (at your option) any later version.
20 +int __init fa_timer_init(unsigned int mapbase, unsigned int irq,
21 + unsigned int timer, unsigned int freq);
23 +#endif /* _FA_TIME_H */
25 +++ b/arch/arm/plat-fa/time.c
28 + * Copyright (C) 2001-2006 Storlink, Corp.
29 + * Copyright (C) 2008-2009 Paulius Zaleckas <paulius.zaleckas@teltonika.lt>
30 + * Copyright (c) 2010 Gabor Juhos <juhosg@openwrt.org>
32 + * This program is free software; you can redistribute it and/or modify
33 + * it under the terms of the GNU General Public License as published by
34 + * the Free Software Foundation; either version 2 of the License, or
35 + * (at your option) any later version.
38 +#include <linux/init.h>
39 +#include <linux/interrupt.h>
40 +#include <linux/irq.h>
41 +#include <linux/io.h>
43 +#include <asm/mach/time.h>
44 +#include <plat/time.h>
47 + * Register definitions for the timers
49 +#define TIMER_COUNT(_base, _tmr) ((_base) + 0x00 + (_tmr) * 0x10)
50 +#define TIMER_LOAD(_base, _tmr) ((_base) + 0x04 + (_tmr) * 0x10)
51 +#define TIMER_MATCH1(_base, _tmr) ((_base) + 0x08 + (_tmr) * 0x10)
52 +#define TIMER_MATCH2(_base, _tmr) ((_base) + 0x0c + (_tmr) * 0x10)
54 +#define TIMER_CR(_base) ((_base) + 0x30)
55 +#define TIMER_STATUS(_base) ((_base) + 0x34)
56 +#define TIMER_MASK(_base) ((_base) + 0x38)
58 +#define TIMER_SIZE 0x3c
60 +#define TIMER_CR_ENABLE(x) (1 << ((x) * 3))
61 +#define TIMER_CR_CLOCK(x) (1 << ((x) * 3 + 1))
62 +#define TIMER_CR_INT(x) (1 << ((x) * 3 + 2))
63 +#define TIMER_CR_DOWN(x) (1 << ((x) * 3 + 9))
65 +#define TIMER_MASK_MATCH1(x) (1 << ((x) * 3))
66 +#define TIMER_MASK_MATCH2(x) (1 << ((x) * 3 + 1))
67 +#define TIMER_MASK_OF(x) (1 << ((x) * 3 + 2))
69 +#define TIMER_MASK_ALL 0x7ff
72 + * IRQ handler for the timer
74 +static irqreturn_t fa_timer_interrupt(int irq, void *dev_id)
80 +static struct irqaction fa_timer_irq = {
81 + .name = "Timer Tick",
82 + .flags = IRQF_DISABLED | IRQF_TIMER,
83 + .handler = fa_timer_interrupt,
86 +int __init fa_timer_init(unsigned int mapbase, unsigned int irq,
87 + unsigned int timer, unsigned int freq)
91 + base = ioremap(mapbase, TIMER_SIZE);
95 + /* disable timers, clear status and mask all interrupts */
96 + __raw_writel(0, TIMER_CR(base));
97 + __raw_writel(0, TIMER_STATUS(base));
98 + __raw_writel(TIMER_MASK_ALL, TIMER_MASK(base));
101 + * Make irqs happen for the system timer
103 + setup_irq(irq, &fa_timer_irq);
105 + /* Setup the timer */
106 + __raw_writel(freq / HZ, TIMER_COUNT(base, timer));
107 + __raw_writel(freq / HZ, TIMER_LOAD(base, timer));
108 + __raw_writel(0, TIMER_MATCH1(base, timer));
109 + __raw_writel(0, TIMER_MATCH2(base, timer));
111 + /* Enable interrupt and start the timer */
112 + __raw_writel(TIMER_MASK_ALL & ~TIMER_MASK_OF(timer),
115 + __raw_writel(TIMER_CR_ENABLE(timer) |
116 + TIMER_CR_INT(timer) |
117 + TIMER_CR_DOWN(timer),
124 --- a/arch/arm/plat-fa/Kconfig
125 +++ b/arch/arm/plat-fa/Kconfig
133 --- a/arch/arm/plat-fa/Makefile
134 +++ b/arch/arm/plat-fa/Makefile
139 +obj-$(CONFIG_PLAT_FA_TIME) += time.o