IB/srp: Let srp_abort() return FAST_IO_FAIL if TL offline
[linux/fpc-iii.git] / arch / metag / kernel / clock.c
blobdefc84056f185e0deaef01dbdec1e8cecc599417
1 /*
2 * arch/metag/kernel/clock.c
4 * Copyright (C) 2012 Imagination Technologies Ltd.
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 */
11 #include <linux/delay.h>
12 #include <linux/io.h>
14 #include <asm/param.h>
15 #include <asm/clock.h>
17 struct meta_clock_desc _meta_clock;
19 /* Default machine get_core_freq callback. */
20 static unsigned long get_core_freq_default(void)
22 #ifdef CONFIG_METAG_META21
24 * Meta 2 cores divide down the core clock for the Meta timers, so we
25 * can estimate the core clock from the divider.
27 return (metag_in32(EXPAND_TIMER_DIV) + 1) * 1000000;
28 #else
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.
33 return (loops_per_jiffy * HZ * 5) >> 1;
34 #endif
37 /**
38 * setup_meta_clocks() - Set up the Meta clock.
39 * @desc: Clock descriptor usually provided by machine description
41 * Ensures all callbacks are valid.
43 void __init setup_meta_clocks(struct meta_clock_desc *desc)
45 /* copy callbacks */
46 if (desc)
47 _meta_clock = *desc;
49 /* set fallback functions */
50 if (!_meta_clock.get_core_freq)
51 _meta_clock.get_core_freq = get_core_freq_default;