Blame view

arch/arm64/kernel/time.c 1.47 KB
caab277b1   Thomas Gleixner   treewide: Replace...
1
  // SPDX-License-Identifier: GPL-2.0-only
985c0679d   Marc Zyngier   arm64: Generic ti...
2
3
4
5
6
7
  /*
   * Based on arch/arm/kernel/time.c
   *
   * Copyright (C) 1991, 1992, 1995  Linus Torvalds
   * Modifications for ARM (C) 1994-2001 Russell King
   * Copyright (C) 2012 ARM Ltd.
985c0679d   Marc Zyngier   arm64: Generic ti...
8
   */
9358d755b   Lorenzo Pieralisi   arm64: kernel: in...
9
  #include <linux/clockchips.h>
985c0679d   Marc Zyngier   arm64: Generic ti...
10
11
12
13
14
15
16
17
18
19
20
21
22
  #include <linux/export.h>
  #include <linux/kernel.h>
  #include <linux/interrupt.h>
  #include <linux/time.h>
  #include <linux/init.h>
  #include <linux/sched.h>
  #include <linux/smp.h>
  #include <linux/timex.h>
  #include <linux/errno.h>
  #include <linux/profile.h>
  #include <linux/syscore_ops.h>
  #include <linux/timer.h>
  #include <linux/irq.h>
1aee5d7a8   Mark Rutland   arm64: move from ...
23
  #include <linux/delay.h>
0583fe478   Rob Herring   ARM: convert arm/...
24
  #include <linux/clocksource.h>
d91771848   Geert Uytterhoeven   arm64: time: Repl...
25
  #include <linux/of_clk.h>
b09ca1ecf   Hanjun Guo   clocksource / arc...
26
  #include <linux/acpi.h>
985c0679d   Marc Zyngier   arm64: Generic ti...
27

1aee5d7a8   Mark Rutland   arm64: move from ...
28
  #include <clocksource/arm_arch_timer.h>
985c0679d   Marc Zyngier   arm64: Generic ti...
29
30
31
  
  #include <asm/thread_info.h>
  #include <asm/stacktrace.h>
e0685fa22   Steven Price   arm64: Retrieve s...
32
  #include <asm/paravirt.h>
985c0679d   Marc Zyngier   arm64: Generic ti...
33

985c0679d   Marc Zyngier   arm64: Generic ti...
34
35
36
37
38
39
  unsigned long profile_pc(struct pt_regs *regs)
  {
  	struct stackframe frame;
  
  	if (!in_lock_functions(regs->pc))
  		return regs->pc;
f3dcbe67e   Dave Martin   arm64: stacktrace...
40
  	start_backtrace(&frame, regs->regs[29], regs->pc);
985c0679d   Marc Zyngier   arm64: Generic ti...
41
  	do {
fe13f95b7   AKASHI Takahiro   arm64: pass a tas...
42
  		int ret = unwind_frame(NULL, &frame);
985c0679d   Marc Zyngier   arm64: Generic ti...
43
44
45
46
47
48
49
  		if (ret < 0)
  			return 0;
  	} while (in_lock_functions(frame.pc));
  
  	return frame.pc;
  }
  EXPORT_SYMBOL(profile_pc);
985c0679d   Marc Zyngier   arm64: Generic ti...
50
51
52
  
  void __init time_init(void)
  {
1aee5d7a8   Mark Rutland   arm64: move from ...
53
  	u32 arch_timer_rate;
bc3ee18a7   Chanho Min   arm64: init: Move...
54
  	of_clk_init(NULL);
ba5d08c0e   Daniel Lezcano   clocksource/drive...
55
  	timer_probe();
1aee5d7a8   Mark Rutland   arm64: move from ...
56

9358d755b   Lorenzo Pieralisi   arm64: kernel: in...
57
  	tick_setup_hrtimer_broadcast();
1aee5d7a8   Mark Rutland   arm64: move from ...
58
  	arch_timer_rate = arch_timer_get_rate();
0583fe478   Rob Herring   ARM: convert arm/...
59
60
61
  	if (!arch_timer_rate)
  		panic("Unable to initialise architected timer.
  ");
1aee5d7a8   Mark Rutland   arm64: move from ...
62

1aee5d7a8   Mark Rutland   arm64: move from ...
63
64
  	/* Calibrate the delay loop directly */
  	lpj_fine = arch_timer_rate / HZ;
e0685fa22   Steven Price   arm64: Retrieve s...
65
66
  
  	pv_time_init();
985c0679d   Marc Zyngier   arm64: Generic ti...
67
  }