18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * timer.h:  Definitions for the timer chips on the Sparc.
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#ifndef _SPARC_TIMER_H
108c2ecf20Sopenharmony_ci#define _SPARC_TIMER_H
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <linux/clocksource.h>
138c2ecf20Sopenharmony_ci#include <linux/irqreturn.h>
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#include <asm-generic/percpu.h>
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#include <asm/cpu_type.h>  /* For SUN4M_NCPUS */
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#define SBUS_CLOCK_RATE   2000000 /* 2MHz */
208c2ecf20Sopenharmony_ci#define TIMER_VALUE_SHIFT 9
218c2ecf20Sopenharmony_ci#define TIMER_VALUE_MASK  0x3fffff
228c2ecf20Sopenharmony_ci#define TIMER_LIMIT_BIT   (1 << 31)  /* Bit 31 in Counter-Timer register */
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci/* The counter timer register has the value offset by 9 bits.
258c2ecf20Sopenharmony_ci * From sun4m manual:
268c2ecf20Sopenharmony_ci * When a counter reaches the value in the corresponding limit register,
278c2ecf20Sopenharmony_ci * the Limit bit is set and the counter is set to 500 nS (i.e. 0x00000200).
288c2ecf20Sopenharmony_ci *
298c2ecf20Sopenharmony_ci * To compensate for this add one to the value.
308c2ecf20Sopenharmony_ci */
318c2ecf20Sopenharmony_cistatic inline unsigned int timer_value(unsigned int value)
328c2ecf20Sopenharmony_ci{
338c2ecf20Sopenharmony_ci	return (value + 1) << TIMER_VALUE_SHIFT;
348c2ecf20Sopenharmony_ci}
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ciextern volatile u32 __iomem *master_l10_counter;
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ciirqreturn_t notrace timer_interrupt(int dummy, void *dev_id);
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci#ifdef CONFIG_SMP
418c2ecf20Sopenharmony_ciDECLARE_PER_CPU(struct clock_event_device, sparc32_clockevent);
428c2ecf20Sopenharmony_civoid register_percpu_ce(int cpu);
438c2ecf20Sopenharmony_ci#endif
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci#endif /* !(_SPARC_TIMER_H) */
46