Skip to content

Commit 4247417

Browse files
Yoichi Yuasaralfbaechle
authored andcommitted
[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>
1 parent 05a96fa commit 4247417

5 files changed

Lines changed: 73 additions & 1 deletion

File tree

‎arch/mips/Kconfig‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ config MACH_DECSTATION
8282
bool "DECstations"
8383
select BOOT_ELF32
8484
select CEVT_R4K
85+
select CSRC_IOASIC
8586
select CSRC_R4K
8687
select CPU_DADDI_WORKAROUNDS if 64BIT
8788
select CPU_R4000_WORKAROUNDS if 64BIT
@@ -784,6 +785,9 @@ config CEVT_TXX9
784785
config CSRC_BCM1480
785786
bool
786787

788+
config CSRC_IOASIC
789+
bool
790+
787791
config CSRC_R4K
788792
bool
789793

‎arch/mips/dec/time.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ void __init plat_time_init(void)
165165

166166
if (!cpu_has_counter && IOASIC)
167167
/* For pre-R4k systems we use the I/O ASIC's counter. */
168-
clocksource_mips.read = dec_ioasic_hpt_read;
168+
dec_ioasic_clocksource_init();
169169

170170
/* Set up the rate of periodic DS1287 interrupts. */
171171
CMOS_WRITE(RTC_REF_CLCK_32KHZ | (16 - __ffs(HZ)), RTC_REG_A);

‎arch/mips/kernel/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ obj-$(CONFIG_CEVT_GT641XX) += cevt-gt641xx.o
1414
obj-$(CONFIG_CEVT_SB1250) += cevt-sb1250.o
1515
obj-$(CONFIG_CEVT_TXX9) += cevt-txx9.o
1616
obj-$(CONFIG_CSRC_BCM1480) += csrc-bcm1480.o
17+
obj-$(CONFIG_CSRC_IOASIC) += csrc-ioasic.o
1718
obj-$(CONFIG_CSRC_R4K) += csrc-r4k.o
1819
obj-$(CONFIG_CSRC_SB1250) += csrc-sb1250.o
1920
obj-$(CONFIG_SYNC_R4K) += sync-r4k.o

‎arch/mips/kernel/csrc-ioasic.c‎

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
}

‎include/asm-mips/dec/ioasic.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,6 @@ static inline u32 ioasic_read(unsigned int reg)
3333

3434
extern void init_ioasic_irqs(int base);
3535

36+
extern void dec_ioasic_clocksource_init(void);
37+
3638
#endif /* __ASM_DEC_IOASIC_H */

0 commit comments

Comments
 (0)