Linux Audio

Check our new training course

Loading...
Note: File does not exist in v3.1.
 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 */
 8#include <linux/init.h>
 9#include <linux/time.h>
10
11#include <asm/gic.h>
12
13static cycle_t gic_hpt_read(struct clocksource *cs)
14{
15	return gic_read_count();
16}
17
18static struct clocksource gic_clocksource = {
19	.name	= "GIC",
20	.read	= gic_hpt_read,
21	.flags	= CLOCK_SOURCE_IS_CONTINUOUS,
22};
23
24void __init gic_clocksource_init(unsigned int frequency)
25{
26	unsigned int config, bits;
27
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));
32
33	/* Set clocksource mask. */
34	gic_clocksource.mask = CLOCKSOURCE_MASK(bits);
35
36	/* Calculate a somewhat reasonable rating value. */
37	gic_clocksource.rating = 200 + frequency / 10000000;
38
39	clocksource_register_hz(&gic_clocksource, frequency);
40}