Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #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> |
Geert Uytterhoeven | 487c719 | 2012-07-11 14:02:23 -0700 | [diff] [blame] | 30 | #include <asm/irq_regs.h> |
Yoshinori Sato | 81d423e | 2008-10-15 22:01:17 -0700 | [diff] [blame] | 31 | #include <asm/timer.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | |
| 33 | #define TICK_SIZE (tick_nsec / 1000) |
| 34 | |
Yoshinori Sato | 81d423e | 2008-10-15 22:01:17 -0700 | [diff] [blame] | 35 | void h8300_timer_tick(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | { |
Yoshinori Sato | 81d423e | 2008-10-15 22:01:17 -0700 | [diff] [blame] | 37 | if (current->pid) |
| 38 | profile_tick(CPU_PROFILING); |
Torben Hohn | daad8b5 | 2011-01-27 15:59:51 +0100 | [diff] [blame] | 39 | xtime_update(1); |
Yoshinori Sato | 81d423e | 2008-10-15 22:01:17 -0700 | [diff] [blame] | 40 | update_process_times(user_mode(get_irq_regs())); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | } |
| 42 | |
John Stultz | 12833c1 | 2010-03-03 19:57:20 -0800 | [diff] [blame] | 43 | void read_persistent_clock(struct timespec *ts) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | { |
| 45 | unsigned int year, mon, day, hour, min, sec; |
| 46 | |
| 47 | /* FIX by dqg : Set to zero for platforms that don't have tod */ |
| 48 | /* without this time is undefined and can overflow time_t, causing */ |
Simon Arlott | 5e71c60 | 2007-10-20 01:10:46 +0200 | [diff] [blame] | 49 | /* very strange errors */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | year = 1980; |
| 51 | mon = day = 1; |
| 52 | hour = min = sec = 0; |
Yoshinori Sato | 81d423e | 2008-10-15 22:01:17 -0700 | [diff] [blame] | 53 | #ifdef CONFIG_H8300_GETTOD |
| 54 | h8300_gettod (&year, &mon, &day, &hour, &min, &sec); |
| 55 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | if ((year += 1900) < 1970) |
| 57 | year += 100; |
John Stultz | 12833c1 | 2010-03-03 19:57:20 -0800 | [diff] [blame] | 58 | ts->tv_sec = mktime(year, mon, day, hour, min, sec); |
| 59 | ts->tv_nsec = 0; |
| 60 | } |
| 61 | |
| 62 | void __init time_init(void) |
| 63 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | |
Yoshinori Sato | 81d423e | 2008-10-15 22:01:17 -0700 | [diff] [blame] | 65 | h8300_timer_setup(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | } |