wanzongshun | 7ec80dd | 2008-12-03 03:55:38 +0100 | [diff] [blame^] | 1 | /* |
| 2 | * linux/arch/arm/mach-w90x900/time.c |
| 3 | * |
| 4 | * Based on linux/arch/arm/plat-s3c24xx/time.c by Ben Dooks |
| 5 | * |
| 6 | * Copyright (c) 2008 Nuvoton technology corporation |
| 7 | * All rights reserved. |
| 8 | * |
| 9 | * Wan ZongShun <mcuos.com@gmail.com> |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License as published by |
| 13 | * the Free Software Foundation; either version 2 of the License, or |
| 14 | * (at your option) any later version. |
| 15 | * |
| 16 | */ |
| 17 | |
| 18 | #include <linux/kernel.h> |
| 19 | #include <linux/sched.h> |
| 20 | #include <linux/init.h> |
| 21 | #include <linux/interrupt.h> |
| 22 | #include <linux/err.h> |
| 23 | #include <linux/clk.h> |
| 24 | #include <linux/io.h> |
| 25 | #include <linux/leds.h> |
| 26 | |
| 27 | #include <asm/mach-types.h> |
| 28 | #include <asm/mach/irq.h> |
| 29 | #include <asm/mach/time.h> |
| 30 | |
| 31 | #include <mach/system.h> |
| 32 | #include <mach/map.h> |
| 33 | #include <mach/regs-timer.h> |
| 34 | |
| 35 | static unsigned long w90x900_gettimeoffset(void) |
| 36 | { |
| 37 | return 0; |
| 38 | } |
| 39 | |
| 40 | /*IRQ handler for the timer*/ |
| 41 | |
| 42 | static irqreturn_t |
| 43 | w90x900_timer_interrupt(int irq, void *dev_id) |
| 44 | { |
| 45 | timer_tick(); |
| 46 | __raw_writel(0x01, REG_TISR); /* clear TIF0 */ |
| 47 | return IRQ_HANDLED; |
| 48 | } |
| 49 | |
| 50 | static struct irqaction w90x900_timer_irq = { |
| 51 | .name = "w90x900 Timer Tick", |
| 52 | .flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL, |
| 53 | .handler = w90x900_timer_interrupt, |
| 54 | }; |
| 55 | |
| 56 | /*Set up timer reg.*/ |
| 57 | |
| 58 | static void w90x900_timer_setup(void) |
| 59 | { |
| 60 | __raw_writel(0, REG_TCSR0); |
| 61 | __raw_writel(0, REG_TCSR1); |
| 62 | __raw_writel(0, REG_TCSR2); |
| 63 | __raw_writel(0, REG_TCSR3); |
| 64 | __raw_writel(0, REG_TCSR4); |
| 65 | __raw_writel(0x1F, REG_TISR); |
| 66 | __raw_writel(15000000/(100 * 100), REG_TICR0); |
| 67 | __raw_writel(0x68000063, REG_TCSR0); |
| 68 | } |
| 69 | |
| 70 | static void __init w90x900_timer_init(void) |
| 71 | { |
| 72 | w90x900_timer_setup(); |
| 73 | setup_irq(IRQ_TIMER0, &w90x900_timer_irq); |
| 74 | } |
| 75 | |
| 76 | struct sys_timer w90x900_timer = { |
| 77 | .init = w90x900_timer_init, |
| 78 | .offset = w90x900_gettimeoffset, |
| 79 | .resume = w90x900_timer_setup |
| 80 | }; |