PageRenderTime 11ms CodeModel.GetById 8ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/Ethereal-msm8939-beta9/arch/metag/kernel/clock.c

https://bitbucket.org/MilosStamenkovic95/etherealos
C | 53 lines | 20 code | 7 blank | 26 comment | 2 complexity | eaeba3c33d5b54e188981590abe0d409 MD5 | raw file
 1/*
 2 * arch/metag/kernel/clock.c
 3 *
 4 * Copyright (C) 2012 Imagination Technologies Ltd.
 5 *
 6 * This program is free software; you can redistribute it and/or modify
 7 * it under the terms of the GNU General Public License version 2 as
 8 * published by the Free Software Foundation.
 9 */
10
11#include <linux/delay.h>
12#include <linux/io.h>
13
14#include <asm/param.h>
15#include <asm/clock.h>
16
17struct meta_clock_desc _meta_clock;
18
19/* Default machine get_core_freq callback. */
20static unsigned long get_core_freq_default(void)
21{
22#ifdef CONFIG_METAG_META21
23	/*
24	 * Meta 2 cores divide down the core clock for the Meta timers, so we
25	 * can estimate the core clock from the divider.
26	 */
27	return (metag_in32(EXPAND_TIMER_DIV) + 1) * 1000000;
28#else
29	/*
30	 * On Meta 1 we don't know the core clock, but assuming the Meta timer
31	 * is correct it can be estimated based on loops_per_jiffy.
32	 */
33	return (loops_per_jiffy * HZ * 5) >> 1;
34#endif
35}
36
37/**
38 * setup_meta_clocks() - Set up the Meta clock.
39 * @desc:	Clock descriptor usually provided by machine description
40 *
41 * Ensures all callbacks are valid.
42 */
43void __init setup_meta_clocks(struct meta_clock_desc *desc)
44{
45	/* copy callbacks */
46	if (desc)
47		_meta_clock = *desc;
48
49	/* set fallback functions */
50	if (!_meta_clock.get_core_freq)
51		_meta_clock.get_core_freq = get_core_freq_default;
52}
53