blob: 7780d379522f49bcebddc54ddfc57f7d1d6d1e34 [file] [log] [blame]
Jesper Nilssondaa00b92008-01-28 16:40:21 +01001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * linux/arch/cris/kernel/time.c
3 *
4 * Copyright (C) 1991, 1992, 1995 Linus Torvalds
5 * Copyright (C) 1999, 2000, 2001 Axis Communications AB
6 *
7 * 1994-07-02 Alan Modra
8 * fixed set_rtc_mmss, fixed time.year for >= 2000, new mktime
9 * 1995-03-26 Markus Kuhn
10 * fixed 500 ms bug at call to set_rtc_mmss, fixed DS12887
11 * precision CMOS clock update
12 * 1996-05-03 Ingo Molnar
13 * fixed time warps in do_[slow|fast]_gettimeoffset()
14 * 1997-09-10 Updated NTP code according to technical memorandum Jan '96
15 * "A Kernel Model for Precision Timekeeping" by Dave Mills
16 *
17 * Linux/CRIS specific code:
18 *
19 * Authors: Bjorn Wesen
Jesper Nilssondaa00b92008-01-28 16:40:21 +010020 * Johan Adolfsson
Linus Torvalds1da177e2005-04-16 15:20:36 -070021 *
22 */
23
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#include <linux/errno.h>
25#include <linux/module.h>
26#include <linux/param.h>
27#include <linux/jiffies.h>
28#include <linux/bcd.h>
29#include <linux/timex.h>
30#include <linux/init.h>
Mikael Starvik21783c92005-07-27 11:44:40 -070031#include <linux/profile.h>
Tim Schmielau4e57b682005-10-30 15:03:48 -080032#include <linux/sched.h> /* just for sched_clock() - funny that */
Linus Torvalds1da177e2005-04-16 15:20:36 -070033
Jesper Nilsson9c75fc82012-04-05 11:52:55 +020034
35#define D(x)
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
37#define TICK_SIZE tick
38
Linus Torvalds1da177e2005-04-16 15:20:36 -070039extern unsigned long loops_per_jiffy; /* init/main.c */
40unsigned long loops_per_usec;
41
Linus Torvalds1da177e2005-04-16 15:20:36 -070042int set_rtc_mmss(unsigned long nowtime)
43{
Jesper Nilsson9c75fc82012-04-05 11:52:55 +020044 D(printk(KERN_DEBUG "set_rtc_mmss(%lu)\n", nowtime));
45 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070046}
47
48/* grab the time from the RTC chip */
Jesper Nilsson9c75fc82012-04-05 11:52:55 +020049unsigned long get_cmos_time(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070050{
Jesper Nilsson9c75fc82012-04-05 11:52:55 +020051 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070052}
53
Linus Torvalds1da177e2005-04-16 15:20:36 -070054
John Stultz8eff8a52010-03-03 19:57:28 -080055int update_persistent_clock(struct timespec now)
Linus Torvalds1da177e2005-04-16 15:20:36 -070056{
John Stultz8eff8a52010-03-03 19:57:28 -080057 return set_rtc_mmss(now.tv_sec);
Linus Torvalds1da177e2005-04-16 15:20:36 -070058}
59
John Stultz8eff8a52010-03-03 19:57:28 -080060void read_persistent_clock(struct timespec *ts)
61{
Jesper Nilsson9c75fc82012-04-05 11:52:55 +020062 ts->tv_sec = 0;
John Stultz8eff8a52010-03-03 19:57:28 -080063 ts->tv_nsec = 0;
64}
65
66
Mikael Starvik21783c92005-07-27 11:44:40 -070067extern void cris_profile_sample(struct pt_regs* regs);
68
69void
70cris_do_profile(struct pt_regs* regs)
71{
72
Jesper Nilsson0188e602007-11-14 17:01:00 -080073#ifdef CONFIG_SYSTEM_PROFILER
Mikael Starvik21783c92005-07-27 11:44:40 -070074 cris_profile_sample(regs);
75#endif
76
Jesper Nilsson0188e602007-11-14 17:01:00 -080077#ifdef CONFIG_PROFILING
Jesper Nilssonc2610382008-01-31 17:56:24 +010078 profile_tick(CPU_PROFILING);
Mikael Starvik21783c92005-07-27 11:44:40 -070079#endif
80}
81
Rabin Vincentd3dad472015-03-09 18:51:31 +010082#ifndef CONFIG_GENERIC_SCHED_CLOCK
Jesper Nilssondaa00b92008-01-28 16:40:21 +010083unsigned long long sched_clock(void)
84{
Jesper Nilsson60dbd662010-07-30 17:33:07 +020085 return (unsigned long long)jiffies * (NSEC_PER_SEC / HZ) +
Jesper Nilssondaa00b92008-01-28 16:40:21 +010086 get_ns_in_jiffie();
87}
Rabin Vincentd3dad472015-03-09 18:51:31 +010088#endif
Jesper Nilssondaa00b92008-01-28 16:40:21 +010089
Linus Torvalds1da177e2005-04-16 15:20:36 -070090static int
91__init init_udelay(void)
92{
93 loops_per_usec = (loops_per_jiffy * HZ) / 1000000;
94 return 0;
95}
96
97__initcall(init_udelay);