Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2001, 2002, MontaVista Software Inc. |
| 3 | * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net |
| 4 | * Copyright (c) 2003 Maciej W. Rozycki |
| 5 | * |
| 6 | * include/asm-mips/time.h |
| 7 | * header file for the new style time.c file and time services. |
| 8 | * |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 9 | * This program is free software; you can redistribute it and/or modify it |
| 10 | * under the terms of the GNU General Public License as published by the |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | * Free Software Foundation; either version 2 of the License, or (at your |
| 12 | * option) any later version. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | */ |
| 14 | #ifndef _ASM_TIME_H |
| 15 | #define _ASM_TIME_H |
| 16 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #include <linux/rtc.h> |
Atsushi Nemoto | 53c2df2 | 2005-11-03 01:01:15 +0900 | [diff] [blame] | 18 | #include <linux/spinlock.h> |
Ralf Baechle | 93c846f | 2007-10-19 08:13:08 +0100 | [diff] [blame] | 19 | #include <linux/clockchips.h> |
Atsushi Nemoto | 0059856 | 2006-11-12 00:10:28 +0900 | [diff] [blame] | 20 | #include <linux/clocksource.h> |
Atsushi Nemoto | 53c2df2 | 2005-11-03 01:01:15 +0900 | [diff] [blame] | 21 | |
| 22 | extern spinlock_t rtc_lock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | |
| 24 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | * board specific routines required by time_init(). |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | */ |
Ralf Baechle | 4b55048 | 2007-10-11 23:46:08 +0100 | [diff] [blame] | 27 | extern void plat_time_init(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | |
| 29 | /* |
| 30 | * mips_hpt_frequency - must be set if you intend to use an R4k-compatible |
Yoichi Yuasa | c966234 | 2007-12-09 21:19:36 +0900 | [diff] [blame] | 31 | * counter as a timer interrupt source. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | */ |
| 33 | extern unsigned int mips_hpt_frequency; |
| 34 | |
Ralf Baechle | 91a2fcc | 2007-10-11 23:46:09 +0100 | [diff] [blame] | 35 | /* |
| 36 | * The performance counter IRQ on MIPS is a close relative to the timer IRQ |
| 37 | * so it lives here. |
| 38 | */ |
| 39 | extern int (*perf_irq)(void); |
Andrew Bresticker | a669efc | 2014-09-18 14:47:12 -0700 | [diff] [blame] | 40 | extern int __weak get_c0_perfcount_int(void); |
Ralf Baechle | 91a2fcc | 2007-10-11 23:46:09 +0100 | [diff] [blame] | 41 | |
Ralf Baechle | 7bcf771 | 2007-10-11 23:46:09 +0100 | [diff] [blame] | 42 | /* |
| 43 | * Initialize the calling CPU's compare interrupt as clockevent device |
| 44 | */ |
Bjorn Helgaas | ec0b9d3 | 2015-07-12 18:11:38 -0500 | [diff] [blame] | 45 | extern unsigned int get_c0_compare_int(void); |
Manuel Lauss | 779e7d4 | 2008-12-21 09:26:22 +0100 | [diff] [blame] | 46 | extern int r4k_clockevent_init(void); |
Manuel Lauss | 779e7d4 | 2008-12-21 09:26:22 +0100 | [diff] [blame] | 47 | |
Ralf Baechle | 5aa85c9 | 2007-11-21 16:39:44 +0000 | [diff] [blame] | 48 | static inline int mips_clockevent_init(void) |
Ralf Baechle | 42f7754 | 2007-10-18 17:48:11 +0100 | [diff] [blame] | 49 | { |
Andrew Bresticker | e4752db | 2014-10-20 12:04:04 -0700 | [diff] [blame] | 50 | #ifdef CONFIG_CEVT_R4K |
Manuel Lauss | 779e7d4 | 2008-12-21 09:26:22 +0100 | [diff] [blame] | 51 | return r4k_clockevent_init(); |
| 52 | #else |
Ralf Baechle | 5aa85c9 | 2007-11-21 16:39:44 +0000 | [diff] [blame] | 53 | return -ENXIO; |
Ralf Baechle | 42f7754 | 2007-10-18 17:48:11 +0100 | [diff] [blame] | 54 | #endif |
Manuel Lauss | 779e7d4 | 2008-12-21 09:26:22 +0100 | [diff] [blame] | 55 | } |
Ralf Baechle | 7bcf771 | 2007-10-11 23:46:09 +0100 | [diff] [blame] | 56 | |
Ralf Baechle | 940f6b4 | 2007-11-24 22:33:28 +0000 | [diff] [blame] | 57 | /* |
| 58 | * Initialize the count register as a clocksource |
| 59 | */ |
Manuel Lauss | 779e7d4 | 2008-12-21 09:26:22 +0100 | [diff] [blame] | 60 | extern int init_r4k_clocksource(void); |
Manuel Lauss | 779e7d4 | 2008-12-21 09:26:22 +0100 | [diff] [blame] | 61 | |
Ralf Baechle | 69e634f | 2008-03-12 13:58:10 +0000 | [diff] [blame] | 62 | static inline int init_mips_clocksource(void) |
Ralf Baechle | 940f6b4 | 2007-11-24 22:33:28 +0000 | [diff] [blame] | 63 | { |
Steven J. Hill | f7886e8 | 2013-10-07 11:32:54 +0100 | [diff] [blame] | 64 | #ifdef CONFIG_CSRC_R4K |
Manuel Lauss | 779e7d4 | 2008-12-21 09:26:22 +0100 | [diff] [blame] | 65 | return init_r4k_clocksource(); |
| 66 | #else |
Ralf Baechle | 69e634f | 2008-03-12 13:58:10 +0000 | [diff] [blame] | 67 | return 0; |
Ralf Baechle | 940f6b4 | 2007-11-24 22:33:28 +0000 | [diff] [blame] | 68 | #endif |
Manuel Lauss | 779e7d4 | 2008-12-21 09:26:22 +0100 | [diff] [blame] | 69 | } |
Ralf Baechle | 940f6b4 | 2007-11-24 22:33:28 +0000 | [diff] [blame] | 70 | |
Thomas Gleixner | e3a4fab | 2009-11-11 14:05:34 +0000 | [diff] [blame] | 71 | static inline void clockevent_set_clock(struct clock_event_device *cd, |
| 72 | unsigned int clock) |
| 73 | { |
| 74 | clockevents_calc_mult_shift(cd, clock, 4); |
| 75 | } |
Ralf Baechle | 93c846f | 2007-10-19 08:13:08 +0100 | [diff] [blame] | 76 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | #endif /* _ASM_TIME_H */ |