xref: /openbmc/linux/arch/mips/kernel/csrc-r4k.c (revision 940f6b48a130e0a33cb8bd397dd0e277166470ad)
1*940f6b48SRalf Baechle /*
2*940f6b48SRalf Baechle  * This file is subject to the terms and conditions of the GNU General Public
3*940f6b48SRalf Baechle  * License.  See the file "COPYING" in the main directory of this archive
4*940f6b48SRalf Baechle  * for more details.
5*940f6b48SRalf Baechle  *
6*940f6b48SRalf Baechle  * Copyright (C) 2007 by Ralf Baechle
7*940f6b48SRalf Baechle  */
8*940f6b48SRalf Baechle 
9*940f6b48SRalf Baechle static cycle_t c0_hpt_read(void)
10*940f6b48SRalf Baechle {
11*940f6b48SRalf Baechle 	return read_c0_count();
12*940f6b48SRalf Baechle }
13*940f6b48SRalf Baechle 
14*940f6b48SRalf Baechle static struct clocksource clocksource_mips = {
15*940f6b48SRalf Baechle 	.name		= "MIPS",
16*940f6b48SRalf Baechle 	.read		= c0_hpt_read,
17*940f6b48SRalf Baechle 	.mask		= CLOCKSOURCE_MASK(32),
18*940f6b48SRalf Baechle 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
19*940f6b48SRalf Baechle };
20*940f6b48SRalf Baechle 
21*940f6b48SRalf Baechle static void __init init_mips_clocksource(void)
22*940f6b48SRalf Baechle {
23*940f6b48SRalf Baechle 	/* Calclate a somewhat reasonable rating value */
24*940f6b48SRalf Baechle 	clocksource_mips.rating = 200 + mips_hpt_frequency / 10000000;
25*940f6b48SRalf Baechle 
26*940f6b48SRalf Baechle 	clocksource_set_clock(&clocksource_mips, mips_hpt_frequency);
27*940f6b48SRalf Baechle 
28*940f6b48SRalf Baechle 	clocksource_register(&clocksource_mips);
29*940f6b48SRalf Baechle }
30