Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * Copyright (C) 2001, 2002, MontaVista Software Inc.
0004  * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
0005  * Copyright (c) 2003  Maciej W. Rozycki
0006  *
0007  * include/asm-mips/time.h
0008  *     header file for the new style time.c file and time services.
0009  */
0010 #ifndef _ASM_TIME_H
0011 #define _ASM_TIME_H
0012 
0013 #include <linux/rtc.h>
0014 #include <linux/spinlock.h>
0015 #include <linux/clockchips.h>
0016 #include <linux/clocksource.h>
0017 
0018 extern spinlock_t rtc_lock;
0019 
0020 /*
0021  * board specific routines required by time_init().
0022  */
0023 extern void plat_time_init(void);
0024 
0025 /*
0026  * mips_hpt_frequency - must be set if you intend to use an R4k-compatible
0027  * counter as a timer interrupt source.
0028  */
0029 extern unsigned int mips_hpt_frequency;
0030 
0031 /*
0032  * The performance counter IRQ on MIPS is a close relative to the timer IRQ
0033  * so it lives here.
0034  */
0035 extern int (*perf_irq)(void);
0036 extern int __weak get_c0_perfcount_int(void);
0037 
0038 /*
0039  * Initialize the calling CPU's compare interrupt as clockevent device
0040  */
0041 extern unsigned int get_c0_compare_int(void);
0042 extern int r4k_clockevent_init(void);
0043 
0044 static inline int mips_clockevent_init(void)
0045 {
0046 #ifdef CONFIG_CEVT_R4K
0047     return r4k_clockevent_init();
0048 #else
0049     return -ENXIO;
0050 #endif
0051 }
0052 
0053 /*
0054  * Initialize the count register as a clocksource
0055  */
0056 extern int init_r4k_clocksource(void);
0057 
0058 static inline int init_mips_clocksource(void)
0059 {
0060 #ifdef CONFIG_CSRC_R4K
0061     return init_r4k_clocksource();
0062 #else
0063     return 0;
0064 #endif
0065 }
0066 
0067 static inline void clockevent_set_clock(struct clock_event_device *cd,
0068                     unsigned int clock)
0069 {
0070     clockevents_calc_mult_shift(cd, clock, 4);
0071 }
0072 
0073 #endif /* _ASM_TIME_H */