X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=arch%2Farm%2Fmach-footbridge%2Ftime.c;h=2c64a0b0502e6beaac9f19596854c55add0cae8a;hb=6a77f38946aaee1cd85eeec6cf4229b204c15071;hp=e9f5708b44218368cc4615aaeb72a3f844f57158;hpb=87fc8d1bb10cd459024a742c6a10961fefcef18f;p=linux-2.6.git diff --git a/arch/arm/mach-footbridge/time.c b/arch/arm/mach-footbridge/time.c index e9f5708b4..2c64a0b05 100644 --- a/arch/arm/mach-footbridge/time.c +++ b/arch/arm/mach-footbridge/time.c @@ -19,75 +19,18 @@ #include #include -#include #include #include #include -#include - #include -#include -#include -#include #include -#include #include +#include "common.h" static int rtc_base; -#define mSEC_10_from_14 ((14318180 + 100) / 200) - -static unsigned long isa_gettimeoffset(void) -{ - int count; - - static int count_p = (mSEC_10_from_14/6); /* for the first call after boot */ - static unsigned long jiffies_p = 0; - - /* - * cache volatile jiffies temporarily; we have IRQs turned off. - */ - unsigned long jiffies_t; - - /* timer count may underflow right here */ - outb_p(0x00, 0x43); /* latch the count ASAP */ - - count = inb_p(0x40); /* read the latched count */ - - /* - * We do this guaranteed double memory access instead of a _p - * postfix in the previous port access. Wheee, hackady hack - */ - jiffies_t = jiffies; - - count |= inb_p(0x40) << 8; - - /* Detect timer underflows. If we haven't had a timer tick since - the last time we were called, and time is apparently going - backwards, the counter must have wrapped during this routine. */ - if ((jiffies_t == jiffies_p) && (count > count_p)) - count -= (mSEC_10_from_14/6); - else - jiffies_p = jiffies_t; - - count_p = count; - - count = (((mSEC_10_from_14/6)-1) - count) * (tick_nsec / 1000); - count = (count + (mSEC_10_from_14/6)/2) / (mSEC_10_from_14/6); - - return count; -} - -static irqreturn_t -isa_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs) -{ - timer_tick(regs); - - return IRQ_HANDLED; -} - static unsigned long __init get_isa_cmos_time(void) { unsigned int year, mon, day, hour, min, sec; @@ -133,8 +76,7 @@ static unsigned long __init get_isa_cmos_time(void) return mktime(year, mon, day, hour, min, sec); } -static int -set_isa_cmos_time(void) +static int set_isa_cmos_time(void) { int retval = 0; int real_seconds, real_minutes, cmos_minutes; @@ -186,34 +128,7 @@ set_isa_cmos_time(void) return retval; } - -static unsigned long timer1_latch; - -static unsigned long timer1_gettimeoffset (void) -{ - unsigned long value = timer1_latch - *CSR_TIMER1_VALUE; - - return ((tick_nsec / 1000) * value) / timer1_latch; -} - -static irqreturn_t -timer1_interrupt(int irq, void *dev_id, struct pt_regs *regs) -{ - *CSR_TIMER1_CLR = 0; - - timer_tick(regs); - - return IRQ_HANDLED; -} - -static struct irqaction footbridge_timer_irq = { - .flags = SA_INTERRUPT -}; - -/* - * Set up timer interrupt. - */ -void __init footbridge_init_time(void) +void __init isa_rtc_init(void) { if (machine_is_co285() || machine_is_personal_server()) @@ -262,35 +177,4 @@ void __init footbridge_init_time(void) } else rtc_base = 0; } - - if (machine_is_ebsa285() || - machine_is_co285() || - machine_is_personal_server()) { - gettimeoffset = timer1_gettimeoffset; - - timer1_latch = (mem_fclk_21285 + 8 * HZ) / (16 * HZ); - - *CSR_TIMER1_CLR = 0; - *CSR_TIMER1_LOAD = timer1_latch; - *CSR_TIMER1_CNTL = TIMER_CNTL_ENABLE | TIMER_CNTL_AUTORELOAD | TIMER_CNTL_DIV16; - - footbridge_timer_irq.name = "Timer1 Timer Tick"; - footbridge_timer_irq.handler = timer1_interrupt; - - setup_irq(IRQ_TIMER1, &footbridge_timer_irq); - - } else { - /* enable PIT timer */ - /* set for periodic (4) and LSB/MSB write (0x30) */ - outb(0x34, 0x43); - outb((mSEC_10_from_14/6) & 0xFF, 0x40); - outb((mSEC_10_from_14/6) >> 8, 0x40); - - gettimeoffset = isa_gettimeoffset; - - footbridge_timer_irq.name = "ISA Timer Tick"; - footbridge_timer_irq.handler = isa_timer_interrupt; - - setup_irq(IRQ_ISA_TIMER, &footbridge_timer_irq); - } }