2006-05-16 17:41:28 +07:00
|
|
|
/*
|
2005-04-17 05:20:36 +07:00
|
|
|
* arch/arm/mach-lh7a40x/time.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004 Logic Product Development
|
|
|
|
*
|
|
|
|
* 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/module.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/interrupt.h>
|
2006-07-02 04:32:40 +07:00
|
|
|
#include <linux/irq.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <linux/time.h>
|
2008-09-06 18:10:45 +07:00
|
|
|
#include <linux/io.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-08-05 22:14:15 +07:00
|
|
|
#include <mach/hardware.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <asm/irq.h>
|
|
|
|
#include <asm/leds.h>
|
|
|
|
|
|
|
|
#include <asm/mach/time.h>
|
|
|
|
#include "common.h"
|
|
|
|
|
|
|
|
#if HZ < 100
|
|
|
|
# define TIMER_CONTROL TIMER_CONTROL2
|
|
|
|
# define TIMER_LOAD TIMER_LOAD2
|
|
|
|
# define TIMER_CONSTANT (508469/HZ)
|
|
|
|
# define TIMER_MODE (TIMER_C_ENABLE | TIMER_C_PERIODIC | TIMER_C_508KHZ)
|
|
|
|
# define TIMER_EOI TIMER_EOI2
|
|
|
|
# define TIMER_IRQ IRQ_T2UI
|
|
|
|
#else
|
|
|
|
# define TIMER_CONTROL TIMER_CONTROL3
|
|
|
|
# define TIMER_LOAD TIMER_LOAD3
|
|
|
|
# define TIMER_CONSTANT (3686400/HZ)
|
|
|
|
# define TIMER_MODE (TIMER_C_ENABLE | TIMER_C_PERIODIC)
|
|
|
|
# define TIMER_EOI TIMER_EOI3
|
|
|
|
# define TIMER_IRQ IRQ_T3UI
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static irqreturn_t
|
2006-10-07 00:53:39 +07:00
|
|
|
lh7a40x_timer_interrupt(int irq, void *dev_id)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
TIMER_EOI = 0;
|
2006-10-07 00:53:39 +07:00
|
|
|
timer_tick();
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct irqaction lh7a40x_timer_irq = {
|
|
|
|
.name = "LHA740x Timer Tick",
|
2007-05-08 14:35:39 +07:00
|
|
|
.flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
|
2005-06-26 23:06:36 +07:00
|
|
|
.handler = lh7a40x_timer_interrupt,
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
2006-05-16 17:41:28 +07:00
|
|
|
static void __init lh7a40x_timer_init (void)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
/* Stop/disable all timers */
|
|
|
|
TIMER_CONTROL1 = 0;
|
|
|
|
TIMER_CONTROL2 = 0;
|
|
|
|
TIMER_CONTROL3 = 0;
|
|
|
|
|
|
|
|
setup_irq (TIMER_IRQ, &lh7a40x_timer_irq);
|
|
|
|
|
|
|
|
TIMER_LOAD = TIMER_CONSTANT;
|
|
|
|
TIMER_CONTROL = TIMER_MODE;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct sys_timer lh7a40x_timer = {
|
|
|
|
.init = &lh7a40x_timer_init,
|
|
|
|
};
|