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
6 * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.
8 #include <linux/init.h>
9 #include <linux/time.h>
13 static cycle_t gic_hpt_read(struct clocksource *cs)
15 return gic_read_count();
18 static struct clocksource gic_clocksource = {
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);