Commit | Line | Data |
---|---|---|
778eeb1b SH |
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. | |
5 | * | |
6 | * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved. | |
7 | */ | |
778eeb1b | 8 | #include <linux/init.h> |
4060bbe9 | 9 | #include <linux/irqchip/mips-gic.h> |
dfa762e1 | 10 | #include <linux/time.h> |
778eeb1b | 11 | |
778eeb1b SH |
12 | static cycle_t gic_hpt_read(struct clocksource *cs) |
13 | { | |
dfa762e1 | 14 | return gic_read_count(); |
778eeb1b SH |
15 | } |
16 | ||
17 | static struct clocksource gic_clocksource = { | |
18 | .name = "GIC", | |
19 | .read = gic_hpt_read, | |
20 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, | |
21 | }; | |
22 | ||
23 | void __init gic_clocksource_init(unsigned int frequency) | |
24 | { | |
778eeb1b | 25 | /* Set clocksource mask. */ |
387904ff | 26 | gic_clocksource.mask = CLOCKSOURCE_MASK(gic_get_count_width()); |
778eeb1b SH |
27 | |
28 | /* Calculate a somewhat reasonable rating value. */ | |
29 | gic_clocksource.rating = 200 + frequency / 10000000; | |
30 | ||
31 | clocksource_register_hz(&gic_clocksource, frequency); | |
32 | } |