Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Jesper Nilsson | daa00b9 | 2008-01-28 16:40:21 +0100 | [diff] [blame] | 2 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * linux/arch/cris/kernel/time.c |
| 4 | * |
| 5 | * Copyright (C) 1991, 1992, 1995 Linus Torvalds |
| 6 | * Copyright (C) 1999, 2000, 2001 Axis Communications AB |
| 7 | * |
| 8 | * 1994-07-02 Alan Modra |
| 9 | * fixed set_rtc_mmss, fixed time.year for >= 2000, new mktime |
| 10 | * 1995-03-26 Markus Kuhn |
| 11 | * fixed 500 ms bug at call to set_rtc_mmss, fixed DS12887 |
| 12 | * precision CMOS clock update |
| 13 | * 1996-05-03 Ingo Molnar |
| 14 | * fixed time warps in do_[slow|fast]_gettimeoffset() |
| 15 | * 1997-09-10 Updated NTP code according to technical memorandum Jan '96 |
| 16 | * "A Kernel Model for Precision Timekeeping" by Dave Mills |
| 17 | * |
| 18 | * Linux/CRIS specific code: |
| 19 | * |
| 20 | * Authors: Bjorn Wesen |
Jesper Nilsson | daa00b9 | 2008-01-28 16:40:21 +0100 | [diff] [blame] | 21 | * Johan Adolfsson |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | * |
| 23 | */ |
| 24 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | #include <linux/errno.h> |
| 26 | #include <linux/module.h> |
| 27 | #include <linux/param.h> |
| 28 | #include <linux/jiffies.h> |
| 29 | #include <linux/bcd.h> |
| 30 | #include <linux/timex.h> |
| 31 | #include <linux/init.h> |
Mikael Starvik | 21783c9 | 2005-07-27 11:44:40 -0700 | [diff] [blame] | 32 | #include <linux/profile.h> |
Ingo Molnar | e601757 | 2017-02-01 16:36:40 +0100 | [diff] [blame] | 33 | #include <linux/sched/clock.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
Jesper Nilsson | 9c75fc8 | 2012-04-05 11:52:55 +0200 | [diff] [blame] | 35 | |
| 36 | #define D(x) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | |
| 38 | #define TICK_SIZE tick |
| 39 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | extern unsigned long loops_per_jiffy; /* init/main.c */ |
| 41 | unsigned long loops_per_usec; |
| 42 | |
Mikael Starvik | 21783c9 | 2005-07-27 11:44:40 -0700 | [diff] [blame] | 43 | extern void cris_profile_sample(struct pt_regs* regs); |
| 44 | |
| 45 | void |
| 46 | cris_do_profile(struct pt_regs* regs) |
| 47 | { |
| 48 | |
Jesper Nilsson | 0188e60 | 2007-11-14 17:01:00 -0800 | [diff] [blame] | 49 | #ifdef CONFIG_SYSTEM_PROFILER |
Mikael Starvik | 21783c9 | 2005-07-27 11:44:40 -0700 | [diff] [blame] | 50 | cris_profile_sample(regs); |
| 51 | #endif |
| 52 | |
Jesper Nilsson | 0188e60 | 2007-11-14 17:01:00 -0800 | [diff] [blame] | 53 | #ifdef CONFIG_PROFILING |
Jesper Nilsson | c261038 | 2008-01-31 17:56:24 +0100 | [diff] [blame] | 54 | profile_tick(CPU_PROFILING); |
Mikael Starvik | 21783c9 | 2005-07-27 11:44:40 -0700 | [diff] [blame] | 55 | #endif |
| 56 | } |
| 57 | |
Rabin Vincent | d3dad47 | 2015-03-09 18:51:31 +0100 | [diff] [blame] | 58 | #ifndef CONFIG_GENERIC_SCHED_CLOCK |
Jesper Nilsson | daa00b9 | 2008-01-28 16:40:21 +0100 | [diff] [blame] | 59 | unsigned long long sched_clock(void) |
| 60 | { |
Jesper Nilsson | 60dbd66 | 2010-07-30 17:33:07 +0200 | [diff] [blame] | 61 | return (unsigned long long)jiffies * (NSEC_PER_SEC / HZ) + |
Jesper Nilsson | daa00b9 | 2008-01-28 16:40:21 +0100 | [diff] [blame] | 62 | get_ns_in_jiffie(); |
| 63 | } |
Rabin Vincent | d3dad47 | 2015-03-09 18:51:31 +0100 | [diff] [blame] | 64 | #endif |
Jesper Nilsson | daa00b9 | 2008-01-28 16:40:21 +0100 | [diff] [blame] | 65 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | static int |
| 67 | __init init_udelay(void) |
| 68 | { |
| 69 | loops_per_usec = (loops_per_jiffy * HZ) / 1000000; |
| 70 | return 0; |
| 71 | } |
| 72 | |
| 73 | __initcall(init_udelay); |