Linux 3.15-rc1
[linux/fpc-iii.git] / arch / mips / kernel / csrc-gic.c
blobe026209011178342a6c98bbd709366fb8f3d06d8
1 /*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
6 * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.
7 */
8 #include <linux/init.h>
9 #include <linux/time.h>
11 #include <asm/gic.h>
13 static cycle_t gic_hpt_read(struct clocksource *cs)
15 return gic_read_count();
18 static struct clocksource gic_clocksource = {
19 .name = "GIC",
20 .read = gic_hpt_read,
21 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
24 void __init gic_clocksource_init(unsigned int frequency)
26 unsigned int config, bits;
28 /* Calculate the clocksource mask. */
29 GICREAD(GIC_REG(SHARED, GIC_SH_CONFIG), config);
30 bits = 32 + ((config & GIC_SH_CONFIG_COUNTBITS_MSK) >>
31 (GIC_SH_CONFIG_COUNTBITS_SHF - 2));
33 /* Set clocksource mask. */
34 gic_clocksource.mask = CLOCKSOURCE_MASK(bits);
36 /* Calculate a somewhat reasonable rating value. */
37 gic_clocksource.rating = 200 + frequency / 10000000;
39 clocksource_register_hz(&gic_clocksource, frequency);