diff options
author | Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> | 2008-04-23 20:48:40 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2008-04-28 12:14:32 -0400 |
commit | 4247417d8457b326ede001cb74af8570b5aa302b (patch) | |
tree | d52e4b8e5c7a8fe6d353234984d6414c9982b987 /arch/mips/kernel | |
parent | 05a96fae433a662e12879b543a6838b6c2129402 (diff) |
[MIPS] add DECstation I/O ASIC clocksource
Add DECstation I/O ASIC clocksource
Signed-off-by: Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/kernel')
-rw-r--r-- | arch/mips/kernel/Makefile | 1 | ||||
-rw-r--r-- | arch/mips/kernel/csrc-ioasic.c | 65 |
2 files changed, 66 insertions, 0 deletions
diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile index 87067e8fee9e..00ac35e501b3 100644 --- a/arch/mips/kernel/Makefile +++ b/arch/mips/kernel/Makefile | |||
@@ -14,6 +14,7 @@ obj-$(CONFIG_CEVT_GT641XX) += cevt-gt641xx.o | |||
14 | obj-$(CONFIG_CEVT_SB1250) += cevt-sb1250.o | 14 | obj-$(CONFIG_CEVT_SB1250) += cevt-sb1250.o |
15 | obj-$(CONFIG_CEVT_TXX9) += cevt-txx9.o | 15 | obj-$(CONFIG_CEVT_TXX9) += cevt-txx9.o |
16 | obj-$(CONFIG_CSRC_BCM1480) += csrc-bcm1480.o | 16 | obj-$(CONFIG_CSRC_BCM1480) += csrc-bcm1480.o |
17 | obj-$(CONFIG_CSRC_IOASIC) += csrc-ioasic.o | ||
17 | obj-$(CONFIG_CSRC_R4K) += csrc-r4k.o | 18 | obj-$(CONFIG_CSRC_R4K) += csrc-r4k.o |
18 | obj-$(CONFIG_CSRC_SB1250) += csrc-sb1250.o | 19 | obj-$(CONFIG_CSRC_SB1250) += csrc-sb1250.o |
19 | obj-$(CONFIG_SYNC_R4K) += sync-r4k.o | 20 | obj-$(CONFIG_SYNC_R4K) += sync-r4k.o |
diff --git a/arch/mips/kernel/csrc-ioasic.c b/arch/mips/kernel/csrc-ioasic.c new file mode 100644 index 000000000000..1d5f63cf8997 --- /dev/null +++ b/arch/mips/kernel/csrc-ioasic.c | |||
@@ -0,0 +1,65 @@ | |||
1 | /* | ||
2 | * DEC I/O ASIC's counter clocksource | ||
3 | * | ||
4 | * Copyright (C) 2008 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | #include <linux/clocksource.h> | ||
21 | #include <linux/init.h> | ||
22 | |||
23 | #include <asm/ds1287.h> | ||
24 | #include <asm/time.h> | ||
25 | #include <asm/dec/ioasic.h> | ||
26 | #include <asm/dec/ioasic_addrs.h> | ||
27 | |||
28 | static cycle_t dec_ioasic_hpt_read(void) | ||
29 | { | ||
30 | return ioasic_read(IO_REG_FCTR); | ||
31 | } | ||
32 | |||
33 | static struct clocksource clocksource_dec = { | ||
34 | .name = "dec-ioasic", | ||
35 | .read = dec_ioasic_hpt_read, | ||
36 | .mask = CLOCKSOURCE_MASK(32), | ||
37 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, | ||
38 | }; | ||
39 | |||
40 | void __init dec_ioasic_clocksource_init(void) | ||
41 | { | ||
42 | unsigned int freq; | ||
43 | u32 start, end; | ||
44 | int i = HZ / 10; | ||
45 | |||
46 | |||
47 | while (!ds1287_timer_state()) | ||
48 | ; | ||
49 | |||
50 | start = dec_ioasic_hpt_read(); | ||
51 | |||
52 | while (i--) | ||
53 | while (!ds1287_timer_state()) | ||
54 | ; | ||
55 | |||
56 | end = dec_ioasic_hpt_read(); | ||
57 | |||
58 | freq = (end - start) * 10; | ||
59 | printk(KERN_INFO "I/O ASIC clock frequency %dHz\n", freq); | ||
60 | |||
61 | clocksource_dec.rating = 200 + freq / 10000000; | ||
62 | clocksource_set_clock(&clocksource_dec, freq); | ||
63 | |||
64 | clocksource_register(&clocksource_dec); | ||
65 | } | ||