Marc Singer | 638b266 | 2006-05-16 11:41:28 +0100 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * arch/arm/mach-lh7a40x/time.c |
| 3 | * |
| 4 | * Copyright (C) 2004 Logic Product Development |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * version 2 as published by the Free Software Foundation. |
| 9 | * |
| 10 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include <linux/module.h> |
| 12 | #include <linux/kernel.h> |
| 13 | #include <linux/interrupt.h> |
Thomas Gleixner | c75c625 | 2006-07-01 22:32:40 +0100 | [diff] [blame] | 14 | #include <linux/irq.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include <linux/time.h> |
Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 16 | #include <linux/io.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 18 | #include <mach/hardware.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include <asm/irq.h> |
| 20 | #include <asm/leds.h> |
| 21 | |
| 22 | #include <asm/mach/time.h> |
| 23 | #include "common.h" |
| 24 | |
| 25 | #if HZ < 100 |
| 26 | # define TIMER_CONTROL TIMER_CONTROL2 |
| 27 | # define TIMER_LOAD TIMER_LOAD2 |
| 28 | # define TIMER_CONSTANT (508469/HZ) |
| 29 | # define TIMER_MODE (TIMER_C_ENABLE | TIMER_C_PERIODIC | TIMER_C_508KHZ) |
| 30 | # define TIMER_EOI TIMER_EOI2 |
| 31 | # define TIMER_IRQ IRQ_T2UI |
| 32 | #else |
| 33 | # define TIMER_CONTROL TIMER_CONTROL3 |
| 34 | # define TIMER_LOAD TIMER_LOAD3 |
| 35 | # define TIMER_CONSTANT (3686400/HZ) |
| 36 | # define TIMER_MODE (TIMER_C_ENABLE | TIMER_C_PERIODIC) |
| 37 | # define TIMER_EOI TIMER_EOI3 |
| 38 | # define TIMER_IRQ IRQ_T3UI |
| 39 | #endif |
| 40 | |
| 41 | static irqreturn_t |
Linus Torvalds | 0cd61b6 | 2006-10-06 10:53:39 -0700 | [diff] [blame] | 42 | lh7a40x_timer_interrupt(int irq, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | TIMER_EOI = 0; |
Linus Torvalds | 0cd61b6 | 2006-10-06 10:53:39 -0700 | [diff] [blame] | 45 | timer_tick(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | return IRQ_HANDLED; |
| 48 | } |
| 49 | |
| 50 | static struct irqaction lh7a40x_timer_irq = { |
| 51 | .name = "LHA740x Timer Tick", |
Bernhard Walle | b30faba | 2007-05-08 00:35:39 -0700 | [diff] [blame] | 52 | .flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL, |
Russell King | 09b8b5f | 2005-06-26 17:06:36 +0100 | [diff] [blame] | 53 | .handler = lh7a40x_timer_interrupt, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | }; |
| 55 | |
Marc Singer | 638b266 | 2006-05-16 11:41:28 +0100 | [diff] [blame] | 56 | static void __init lh7a40x_timer_init (void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | { |
| 58 | /* Stop/disable all timers */ |
| 59 | TIMER_CONTROL1 = 0; |
| 60 | TIMER_CONTROL2 = 0; |
| 61 | TIMER_CONTROL3 = 0; |
| 62 | |
| 63 | setup_irq (TIMER_IRQ, &lh7a40x_timer_irq); |
| 64 | |
| 65 | TIMER_LOAD = TIMER_CONSTANT; |
| 66 | TIMER_CONTROL = TIMER_MODE; |
| 67 | } |
| 68 | |
| 69 | struct sys_timer lh7a40x_timer = { |
| 70 | .init = &lh7a40x_timer_init, |
| 71 | }; |