blob: 7f2d6cfbb4b6091b2f6c7523ca004582b766349e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/h8300/kernel/time.c
3 *
4 * Yoshinori Sato <ysato@users.sourceforge.jp>
5 *
6 * Copied/hacked from:
7 *
8 * linux/arch/m68k/kernel/time.c
9 *
10 * Copyright (C) 1991, 1992, 1995 Linus Torvalds
11 *
12 * This file contains the m68k-specific time handling details.
13 * Most of the stuff is located in the machine specific files.
14 *
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
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <linux/errno.h>
20#include <linux/module.h>
21#include <linux/sched.h>
22#include <linux/kernel.h>
23#include <linux/param.h>
24#include <linux/string.h>
25#include <linux/mm.h>
26#include <linux/timex.h>
27#include <linux/profile.h>
28
29#include <asm/io.h>
Yoshinori Sato81d423e2008-10-15 22:01:17 -070030#include <asm/timer.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070031
32#define TICK_SIZE (tick_nsec / 1000)
33
Yoshinori Sato81d423e2008-10-15 22:01:17 -070034void h8300_timer_tick(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070035{
Yoshinori Sato81d423e2008-10-15 22:01:17 -070036 if (current->pid)
37 profile_tick(CPU_PROFILING);
38 write_seqlock(&xtime_lock);
Atsushi Nemoto3171a032006-09-29 02:00:32 -070039 do_timer(1);
Yoshinori Sato81d423e2008-10-15 22:01:17 -070040 write_sequnlock(&xtime_lock);
41 update_process_times(user_mode(get_irq_regs()));
Linus Torvalds1da177e2005-04-16 15:20:36 -070042}
43
Yoshinori Sato81d423e2008-10-15 22:01:17 -070044void __init time_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070045{
46 unsigned int year, mon, day, hour, min, sec;
47
48 /* FIX by dqg : Set to zero for platforms that don't have tod */
49 /* without this time is undefined and can overflow time_t, causing */
Simon Arlott5e71c602007-10-20 01:10:46 +020050 /* very strange errors */
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 year = 1980;
52 mon = day = 1;
53 hour = min = sec = 0;
Yoshinori Sato81d423e2008-10-15 22:01:17 -070054#ifdef CONFIG_H8300_GETTOD
55 h8300_gettod (&year, &mon, &day, &hour, &min, &sec);
56#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 if ((year += 1900) < 1970)
58 year += 100;
59 xtime.tv_sec = mktime(year, mon, day, hour, min, sec);
60 xtime.tv_nsec = 0;
61
Yoshinori Sato81d423e2008-10-15 22:01:17 -070062 h8300_timer_setup();
Linus Torvalds1da177e2005-04-16 15:20:36 -070063}