0001
0002
0003
0004
0005
0006
0007 #ifndef _SPARC64_TIMER_H
0008 #define _SPARC64_TIMER_H
0009
0010 #include <uapi/asm/asi.h>
0011 #include <linux/types.h>
0012 #include <linux/init.h>
0013
0014
0015
0016
0017 struct sparc64_tick_ops {
0018 unsigned long ticks_per_nsec_quotient;
0019 unsigned long offset;
0020 unsigned long long (*get_tick)(void);
0021 int (*add_compare)(unsigned long);
0022 unsigned long softint_mask;
0023 void (*disable_irq)(void);
0024
0025 void (*init_tick)(void);
0026 unsigned long (*add_tick)(unsigned long);
0027 unsigned long (*get_frequency)(void);
0028 unsigned long frequency;
0029
0030 char *name;
0031 };
0032
0033 extern struct sparc64_tick_ops *tick_ops;
0034
0035 unsigned long sparc64_get_clock_tick(unsigned int cpu);
0036 void setup_sparc64_timer(void);
0037 void __init time_init(void);
0038
0039 #define TICK_PRIV_BIT BIT(63)
0040 #define TICKCMP_IRQ_BIT BIT(63)
0041
0042 #define HBIRD_STICKCMP_ADDR 0x1fe0000f060UL
0043 #define HBIRD_STICK_ADDR 0x1fe0000f070UL
0044
0045 #define GET_TICK_NINSTR 13
0046 struct get_tick_patch {
0047 unsigned int addr;
0048 unsigned int tick[GET_TICK_NINSTR];
0049 unsigned int stick[GET_TICK_NINSTR];
0050 };
0051
0052 extern struct get_tick_patch __get_tick_patch;
0053 extern struct get_tick_patch __get_tick_patch_end;
0054
0055 static inline unsigned long get_tick(void)
0056 {
0057 unsigned long tick, tmp1, tmp2;
0058
0059 __asm__ __volatile__(
0060
0061 "661:\n"
0062 " mov 0x1fe, %1\n"
0063 " sllx %1, 0x20, %1\n"
0064 " sethi %%hi(0xf000), %2\n"
0065 " or %2, 0x70, %2\n"
0066 " or %1, %2, %1\n"
0067 " add %1, 8, %2\n"
0068 " ldxa [%2]%3, %0\n"
0069 " ldxa [%1]%3, %1\n"
0070 " ldxa [%2]%3, %2\n"
0071 " sub %2, %0, %0\n"
0072 " brnz,pn %0, 661b\n"
0073 " sllx %2, 32, %2\n"
0074 " or %2, %1, %0\n"
0075
0076 " sllx %0, 1, %0\n"
0077 " srlx %0, 1, %0\n"
0078
0079 " .section .get_tick_patch, \"ax\"\n"
0080 " .word 661b\n"
0081
0082 " ba 1f\n"
0083 " rd %%tick, %0\n"
0084 " .skip 4 * (%4 - 2)\n"
0085 "1:\n"
0086
0087 " ba 1f\n"
0088 " rd %%asr24, %0\n"
0089 " .skip 4 * (%4 - 2)\n"
0090 "1:\n"
0091
0092 " .previous\n"
0093 : "=&r" (tick), "=&r" (tmp1), "=&r" (tmp2)
0094 : "i" (ASI_PHYS_BYPASS_EC_E), "i" (GET_TICK_NINSTR));
0095
0096 return tick;
0097 }
0098
0099 #endif