Merge branch 'for-5.1' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq
[linux-2.6-block.git] / arch / arm64 / kernel / time.c
CommitLineData
985c0679
MZ
1/*
2 * Based on arch/arm/kernel/time.c
3 *
4 * Copyright (C) 1991, 1992, 1995 Linus Torvalds
5 * Modifications for ARM (C) 1994-2001 Russell King
6 * Copyright (C) 2012 ARM Ltd.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
9358d755 21#include <linux/clockchips.h>
985c0679
MZ
22#include <linux/export.h>
23#include <linux/kernel.h>
24#include <linux/interrupt.h>
25#include <linux/time.h>
26#include <linux/init.h>
27#include <linux/sched.h>
28#include <linux/smp.h>
29#include <linux/timex.h>
30#include <linux/errno.h>
31#include <linux/profile.h>
32#include <linux/syscore_ops.h>
33#include <linux/timer.h>
34#include <linux/irq.h>
1aee5d7a 35#include <linux/delay.h>
0583fe47 36#include <linux/clocksource.h>
bc3ee18a 37#include <linux/clk-provider.h>
b09ca1ec 38#include <linux/acpi.h>
985c0679 39
1aee5d7a 40#include <clocksource/arm_arch_timer.h>
985c0679
MZ
41
42#include <asm/thread_info.h>
43#include <asm/stacktrace.h>
44
985c0679
MZ
45unsigned long profile_pc(struct pt_regs *regs)
46{
47 struct stackframe frame;
48
49 if (!in_lock_functions(regs->pc))
50 return regs->pc;
51
52 frame.fp = regs->regs[29];
985c0679 53 frame.pc = regs->pc;
20380bb3 54#ifdef CONFIG_FUNCTION_GRAPH_TRACER
a448276c 55 frame.graph = 0;
20380bb3 56#endif
985c0679 57 do {
fe13f95b 58 int ret = unwind_frame(NULL, &frame);
985c0679
MZ
59 if (ret < 0)
60 return 0;
61 } while (in_lock_functions(frame.pc));
62
63 return frame.pc;
64}
65EXPORT_SYMBOL(profile_pc);
985c0679
MZ
66
67void __init time_init(void)
68{
1aee5d7a
MR
69 u32 arch_timer_rate;
70
bc3ee18a 71 of_clk_init(NULL);
ba5d08c0 72 timer_probe();
1aee5d7a 73
9358d755
LP
74 tick_setup_hrtimer_broadcast();
75
1aee5d7a 76 arch_timer_rate = arch_timer_get_rate();
0583fe47
RH
77 if (!arch_timer_rate)
78 panic("Unable to initialise architected timer.\n");
1aee5d7a 79
1aee5d7a
MR
80 /* Calibrate the delay loop directly */
81 lpj_fine = arch_timer_rate / HZ;
985c0679 82}