162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * timer.h: Definitions for the timer chips on the Sparc. 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) 662306a36Sopenharmony_ci */ 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#ifndef _SPARC_TIMER_H 1062306a36Sopenharmony_ci#define _SPARC_TIMER_H 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci#include <linux/clocksource.h> 1362306a36Sopenharmony_ci#include <linux/irqreturn.h> 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ci#include <asm-generic/percpu.h> 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci#include <asm/cpu_type.h> /* For SUN4M_NCPUS */ 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ci#define SBUS_CLOCK_RATE 2000000 /* 2MHz */ 2062306a36Sopenharmony_ci#define TIMER_VALUE_SHIFT 9 2162306a36Sopenharmony_ci#define TIMER_VALUE_MASK 0x3fffff 2262306a36Sopenharmony_ci#define TIMER_LIMIT_BIT (1 << 31) /* Bit 31 in Counter-Timer register */ 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ci/* The counter timer register has the value offset by 9 bits. 2562306a36Sopenharmony_ci * From sun4m manual: 2662306a36Sopenharmony_ci * When a counter reaches the value in the corresponding limit register, 2762306a36Sopenharmony_ci * the Limit bit is set and the counter is set to 500 nS (i.e. 0x00000200). 2862306a36Sopenharmony_ci * 2962306a36Sopenharmony_ci * To compensate for this add one to the value. 3062306a36Sopenharmony_ci */ 3162306a36Sopenharmony_cistatic inline unsigned int timer_value(unsigned int value) 3262306a36Sopenharmony_ci{ 3362306a36Sopenharmony_ci return (value + 1) << TIMER_VALUE_SHIFT; 3462306a36Sopenharmony_ci} 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ciextern volatile u32 __iomem *master_l10_counter; 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ciirqreturn_t notrace timer_interrupt(int dummy, void *dev_id); 3962306a36Sopenharmony_ci 4062306a36Sopenharmony_ci#ifdef CONFIG_SMP 4162306a36Sopenharmony_ciDECLARE_PER_CPU(struct clock_event_device, sparc32_clockevent); 4262306a36Sopenharmony_civoid register_percpu_ce(int cpu); 4362306a36Sopenharmony_ci#endif 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_ci#endif /* !(_SPARC_TIMER_H) */ 46