Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[wrt350n-kernel.git] / arch / m68knommu / platform / 68328 / timers.c
blobb3c7224afbcf428b28716e0c7a1ca25cd73390ed
1 /***************************************************************************/
3 /*
4 * linux/arch/m68knommu/platform/68328/timers.c
6 * Copyright (C) 1993 Hamish Macdonald
7 * Copyright (C) 1999 D. Jeff Dionne
8 * Copyright (C) 2001 Georges Menie, Ken Desmet
10 * This file is subject to the terms and conditions of the GNU General Public
11 * License. See the file COPYING in the main directory of this archive
12 * for more details.
15 /***************************************************************************/
17 #include <linux/types.h>
18 #include <linux/kernel.h>
19 #include <linux/mm.h>
20 #include <linux/interrupt.h>
21 #include <linux/irq.h>
22 #include <linux/clocksource.h>
23 #include <asm/setup.h>
24 #include <asm/system.h>
25 #include <asm/pgtable.h>
26 #include <asm/machdep.h>
27 #include <asm/MC68VZ328.h>
29 /***************************************************************************/
31 #if defined(CONFIG_DRAGEN2)
32 /* with a 33.16 MHz clock, this will give usec resolution to the time functions */
33 #define CLOCK_SOURCE TCTL_CLKSOURCE_SYSCLK
34 #define CLOCK_PRE 7
35 #define TICKS_PER_JIFFY 41450
37 #elif defined(CONFIG_XCOPILOT_BUGS)
39 * The only thing I know is that CLK32 is not available on Xcopilot
40 * I have little idea about what frequency SYSCLK has on Xcopilot.
41 * The values for prescaler and compare registers were simply
42 * taken from the original source
44 #define CLOCK_SOURCE TCTL_CLKSOURCE_SYSCLK
45 #define CLOCK_PRE 2
46 #define TICKS_PER_JIFFY 0xd7e4
48 #else
49 /* default to using the 32Khz clock */
50 #define CLOCK_SOURCE TCTL_CLKSOURCE_32KHZ
51 #define CLOCK_PRE 31
52 #define TICKS_PER_JIFFY 10
53 #endif
55 static u32 m68328_tick_cnt;
57 /***************************************************************************/
59 static irqreturn_t hw_tick(int irq, void *dummy)
61 /* Reset Timer1 */
62 TSTAT &= 0;
64 m68328_tick_cnt += TICKS_PER_JIFFY;
65 return arch_timer_interrupt(irq, dummy);
68 /***************************************************************************/
70 <<<<<<< HEAD:arch/m68knommu/platform/68328/timers.c
71 static irqreturn_t hw_tick(int irq, void *dummy)
73 /* Reset Timer1 */
74 TSTAT &= 0;
76 return arch_timer_interrupt(irq, dummy);
79 /***************************************************************************/
81 =======
82 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/m68knommu/platform/68328/timers.c
83 static struct irqaction m68328_timer_irq = {
84 .name = "timer",
85 .flags = IRQF_DISABLED | IRQF_TIMER,
86 .handler = hw_tick,
89 /***************************************************************************/
91 static cycle_t m68328_read_clk(void)
93 unsigned long flags;
94 u32 cycles;
96 local_irq_save(flags);
97 cycles = m68328_tick_cnt + TCN;
98 local_irq_restore(flags);
100 return cycles;
103 /***************************************************************************/
105 static struct clocksource m68328_clk = {
106 .name = "timer",
107 .rating = 250,
108 .read = m68328_read_clk,
109 .shift = 20,
110 .mask = CLOCKSOURCE_MASK(32),
111 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
114 /***************************************************************************/
116 void hw_timer_init(void)
118 /* disable timer 1 */
119 TCTL = 0;
121 /* set ISR */
122 setup_irq(TMR_IRQ_NUM, &m68328_timer_irq);
124 /* Restart mode, Enable int, Set clock source */
125 TCTL = TCTL_OM | TCTL_IRQEN | CLOCK_SOURCE;
126 TPRER = CLOCK_PRE;
127 TCMP = TICKS_PER_JIFFY;
129 /* Enable timer 1 */
130 TCTL |= TCTL_TEN;
131 m68328_clk.mult = clocksource_hz2mult(TICKS_PER_JIFFY*HZ, m68328_clk.shift);
132 clocksource_register(&m68328_clk);
135 /***************************************************************************/
137 void m68328_timer_gettod(int *year, int *mon, int *day, int *hour, int *min, int *sec)
139 long now = RTCTIME;
141 *year = *mon = *day = 1;
142 *hour = (now >> 24) % 24;
143 *min = (now >> 16) % 60;
144 *sec = now % 60;
147 /***************************************************************************/