1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* timer.h: System timer definitions for sun5.
4 * Copyright (C) 1997, 2008 David S. Miller (davem@davemloft.net)
7 #ifndef _SPARC64_TIMER_H
8 #define _SPARC64_TIMER_H
10 #include <linux/types.h>
11 #include <linux/init.h>
13 /* The most frequently accessed fields should be first,
14 * to fit into the same cacheline.
16 struct sparc64_tick_ops
{
17 unsigned long ticks_per_nsec_quotient
;
19 unsigned long long (*get_tick
)(void);
20 int (*add_compare
)(unsigned long);
21 unsigned long softint_mask
;
22 void (*disable_irq
)(void);
24 void (*init_tick
)(void);
25 unsigned long (*add_tick
)(unsigned long);
26 unsigned long (*get_frequency
)(void);
27 unsigned long frequency
;
32 extern struct sparc64_tick_ops
*tick_ops
;
34 unsigned long sparc64_get_clock_tick(unsigned int cpu
);
35 void setup_sparc64_timer(void);
36 void __init
time_init(void);
38 #define TICK_PRIV_BIT BIT(63)
39 #define TICKCMP_IRQ_BIT BIT(63)
41 #define HBIRD_STICKCMP_ADDR 0x1fe0000f060UL
42 #define HBIRD_STICK_ADDR 0x1fe0000f070UL
44 #define GET_TICK_NINSTR 13
45 struct get_tick_patch
{
47 unsigned int tick
[GET_TICK_NINSTR
];
48 unsigned int stick
[GET_TICK_NINSTR
];
51 extern struct get_tick_patch __get_tick_patch
;
52 extern struct get_tick_patch __get_tick_patch_end
;
54 static inline unsigned long get_tick(void)
56 unsigned long tick
, tmp1
, tmp2
;
59 /* read hbtick 13 instructions */
62 " sllx %1, 0x20, %1\n"
63 " sethi %%hi(0xf000), %2\n"
65 " or %1, %2, %1\n" /* %1 = HBIRD_STICK_ADDR */
70 " sub %2, %0, %0\n" /* don't modify %xcc */
71 " brnz,pn %0, 661b\n" /* restart to save one register */
74 /* Common/not patched code */
76 " srlx %0, 1, %0\n" /* Clear TICK_PRIV_BIT */
77 /* Beginning of patch section */
78 " .section .get_tick_patch, \"ax\"\n"
80 /* read tick 2 instructions and 11 skipped */
83 " .skip 4 * (%4 - 2)\n"
85 /* read stick 2 instructions and 11 skipped */
88 " .skip 4 * (%4 - 2)\n"
90 /* End of patch section */
92 : "=&r" (tick
), "=&r" (tmp1
), "=&r" (tmp2
)
93 : "i" (ASI_PHYS_BYPASS_EC_E
), "i" (GET_TICK_NINSTR
));
98 #endif /* _SPARC64_TIMER_H */