162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public 362306a36Sopenharmony_ci * License. See the file "COPYING" in the main directory of this archive 462306a36Sopenharmony_ci * for more details. 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci * Copyright (C) 2001 - 2013 Tensilica Inc. 762306a36Sopenharmony_ci */ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#ifndef _XTENSA_TIMEX_H 1062306a36Sopenharmony_ci#define _XTENSA_TIMEX_H 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci#include <asm/processor.h> 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci#if XCHAL_NUM_TIMERS > 0 && \ 1562306a36Sopenharmony_ci XTENSA_INT_LEVEL(XCHAL_TIMER0_INTERRUPT) <= XCHAL_EXCM_LEVEL 1662306a36Sopenharmony_ci# define LINUX_TIMER 0 1762306a36Sopenharmony_ci# define LINUX_TIMER_INT XCHAL_TIMER0_INTERRUPT 1862306a36Sopenharmony_ci#elif XCHAL_NUM_TIMERS > 1 && \ 1962306a36Sopenharmony_ci XTENSA_INT_LEVEL(XCHAL_TIMER1_INTERRUPT) <= XCHAL_EXCM_LEVEL 2062306a36Sopenharmony_ci# define LINUX_TIMER 1 2162306a36Sopenharmony_ci# define LINUX_TIMER_INT XCHAL_TIMER1_INTERRUPT 2262306a36Sopenharmony_ci#elif XCHAL_NUM_TIMERS > 2 && \ 2362306a36Sopenharmony_ci XTENSA_INT_LEVEL(XCHAL_TIMER2_INTERRUPT) <= XCHAL_EXCM_LEVEL 2462306a36Sopenharmony_ci# define LINUX_TIMER 2 2562306a36Sopenharmony_ci# define LINUX_TIMER_INT XCHAL_TIMER2_INTERRUPT 2662306a36Sopenharmony_ci#else 2762306a36Sopenharmony_ci# error "Bad timer number for Linux configurations!" 2862306a36Sopenharmony_ci#endif 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ciextern unsigned long ccount_freq; 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_civoid local_timer_setup(unsigned cpu); 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ci/* 3562306a36Sopenharmony_ci * Register access. 3662306a36Sopenharmony_ci */ 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_cistatic inline unsigned long get_ccount (void) 3962306a36Sopenharmony_ci{ 4062306a36Sopenharmony_ci return xtensa_get_sr(ccount); 4162306a36Sopenharmony_ci} 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_cistatic inline void set_ccount (unsigned long ccount) 4462306a36Sopenharmony_ci{ 4562306a36Sopenharmony_ci xtensa_set_sr(ccount, ccount); 4662306a36Sopenharmony_ci} 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_cistatic inline unsigned long get_linux_timer (void) 4962306a36Sopenharmony_ci{ 5062306a36Sopenharmony_ci return xtensa_get_sr(SREG_CCOMPARE + LINUX_TIMER); 5162306a36Sopenharmony_ci} 5262306a36Sopenharmony_ci 5362306a36Sopenharmony_cistatic inline void set_linux_timer (unsigned long ccompare) 5462306a36Sopenharmony_ci{ 5562306a36Sopenharmony_ci xtensa_set_sr(ccompare, SREG_CCOMPARE + LINUX_TIMER); 5662306a36Sopenharmony_ci} 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_ci#include <asm-generic/timex.h> 5962306a36Sopenharmony_ci 6062306a36Sopenharmony_ci#endif /* _XTENSA_TIMEX_H */ 61