2 * linux/include/asm-arm/arch-shark/time.h
6 * Uses the real time clock because you can't run
7 * the timer with level triggered interrupts and
8 * you can't run the shark with edge triggered
9 * inetrrupts (loses ints and hangs).
11 * derived from linux/drivers/char/rtc.c and:
12 * linux/include/asm-arm/arch-ebsa110/time.h
13 * Copyright (c) 1996,1997,1998 Russell King.
17 #include <linux/mc146818rtc.h>
21 extern void get_rtc_time(struct rtc_time *rtc_tm);
22 extern void set_rtc_irq_bit(unsigned char bit);
23 extern unsigned long epoch;
25 static void timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
28 CMOS_READ(RTC_INTR_FLAGS);
34 static unsigned int divisor;
37 divisor = DIVISOR - 1;
47 * Set up timer interrupt, and return the current time in seconds.
49 static inline void setup_timer(void)
51 struct rtc_time r_time;
57 * Set the clock to 128 Hz, we already have a valid
65 * Check that the input was really a power of 2.
68 panic("Please set HZ to a power of 2!");
72 val = CMOS_READ(RTC_FREQ_SELECT) & 0xf0;
74 CMOS_WRITE(val, RTC_FREQ_SELECT);
76 set_rtc_irq_bit(RTC_PIE);
78 get_rtc_time(&r_time);
79 xtime.tv_sec = mktime(r_time.tm_year+epoch, r_time.tm_mon+1, r_time.tm_mday,
80 r_time.tm_hour, r_time.tm_min, r_time.tm_sec);
82 timer_irq.handler = timer_interrupt;
83 setup_arm_irq(IRQ_TIMER, &timer_irq);