blob: 593239274f980d5c56226051c562591c56b2b401 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Jesper Nilssondaa00b92008-01-28 16:40:21 +01002/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 * 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 Nilssondaa00b92008-01-28 16:40:21 +010021 * Johan Adolfsson
Linus Torvalds1da177e2005-04-16 15:20:36 -070022 *
23 */
24
Linus Torvalds1da177e2005-04-16 15:20:36 -070025#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 Starvik21783c92005-07-27 11:44:40 -070032#include <linux/profile.h>
Ingo Molnare6017572017-02-01 16:36:40 +010033#include <linux/sched/clock.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Jesper Nilsson9c75fc82012-04-05 11:52:55 +020035
36#define D(x)
Linus Torvalds1da177e2005-04-16 15:20:36 -070037
38#define TICK_SIZE tick
39
Linus Torvalds1da177e2005-04-16 15:20:36 -070040extern unsigned long loops_per_jiffy; /* init/main.c */
41unsigned long loops_per_usec;
42
Mikael Starvik21783c92005-07-27 11:44:40 -070043extern void cris_profile_sample(struct pt_regs* regs);
44
45void
46cris_do_profile(struct pt_regs* regs)
47{
48
Jesper Nilsson0188e602007-11-14 17:01:00 -080049#ifdef CONFIG_SYSTEM_PROFILER
Mikael Starvik21783c92005-07-27 11:44:40 -070050 cris_profile_sample(regs);
51#endif
52
Jesper Nilsson0188e602007-11-14 17:01:00 -080053#ifdef CONFIG_PROFILING
Jesper Nilssonc2610382008-01-31 17:56:24 +010054 profile_tick(CPU_PROFILING);
Mikael Starvik21783c92005-07-27 11:44:40 -070055#endif
56}
57
Rabin Vincentd3dad472015-03-09 18:51:31 +010058#ifndef CONFIG_GENERIC_SCHED_CLOCK
Jesper Nilssondaa00b92008-01-28 16:40:21 +010059unsigned long long sched_clock(void)
60{
Jesper Nilsson60dbd662010-07-30 17:33:07 +020061 return (unsigned long long)jiffies * (NSEC_PER_SEC / HZ) +
Jesper Nilssondaa00b92008-01-28 16:40:21 +010062 get_ns_in_jiffie();
63}
Rabin Vincentd3dad472015-03-09 18:51:31 +010064#endif
Jesper Nilssondaa00b92008-01-28 16:40:21 +010065
Linus Torvalds1da177e2005-04-16 15:20:36 -070066static 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);