2005-06-23 22:01:26 -07:00
/*
* This file is subject to the terms and conditions of the GNU General Public
* License . See the file " COPYING " in the main directory of this archive
* for more details .
*
2013-10-17 02:42:26 +04:00
* Copyright ( C ) 2001 - 2013 Tensilica Inc .
2005-06-23 22:01:26 -07:00
*/
# ifndef _XTENSA_TIMEX_H
# define _XTENSA_TIMEX_H
# include <asm/processor.h>
# include <linux/stringify.h>
2006-12-10 02:18:48 -08:00
# define _INTLEVEL(x) XCHAL_INT ## x ## _LEVEL
# define INTLEVEL(x) _INTLEVEL(x)
2013-03-10 12:07:14 +04:00
# if XCHAL_NUM_TIMERS > 0 && \
INTLEVEL ( XCHAL_TIMER0_INTERRUPT ) < = XCHAL_EXCM_LEVEL
2005-06-23 22:01:26 -07:00
# define LINUX_TIMER 0
2006-12-10 02:18:48 -08:00
# define LINUX_TIMER_INT XCHAL_TIMER0_INTERRUPT
2013-03-10 12:07:14 +04:00
# elif XCHAL_NUM_TIMERS > 1 && \
INTLEVEL ( XCHAL_TIMER1_INTERRUPT ) < = XCHAL_EXCM_LEVEL
2005-06-23 22:01:26 -07:00
# define LINUX_TIMER 1
2006-12-10 02:18:48 -08:00
# define LINUX_TIMER_INT XCHAL_TIMER1_INTERRUPT
2013-03-10 12:07:14 +04:00
# elif XCHAL_NUM_TIMERS > 2 && \
INTLEVEL ( XCHAL_TIMER2_INTERRUPT ) < = XCHAL_EXCM_LEVEL
2005-06-23 22:01:26 -07:00
# define LINUX_TIMER 2
2006-12-10 02:18:48 -08:00
# define LINUX_TIMER_INT XCHAL_TIMER2_INTERRUPT
2005-06-23 22:01:26 -07:00
# else
# error "Bad timer number for Linux configurations!"
# endif
2013-06-17 11:29:43 +03:00
extern unsigned long ccount_freq ;
2005-06-23 22:01:26 -07:00
typedef unsigned long long cycles_t ;
# define get_cycles() (0)
2013-10-17 02:42:26 +04:00
void local_timer_setup ( unsigned cpu ) ;
2005-06-23 22:01:26 -07:00
/*
* Register access .
*/
2012-10-15 03:55:38 +04:00
# define WSR_CCOUNT(r) asm volatile ("wsr %0, ccount" :: "a" (r))
# define RSR_CCOUNT(r) asm volatile ("rsr %0, ccount" : "=a" (r))
# define WSR_CCOMPARE(x,r) asm volatile ("wsr %0,"__stringify(SREG_CCOMPARE)"+"__stringify(x) :: "a"(r))
# define RSR_CCOMPARE(x,r) asm volatile ("rsr %0,"__stringify(SREG_CCOMPARE)"+"__stringify(x) : "=a"(r))
2005-06-23 22:01:26 -07:00
static inline unsigned long get_ccount ( void )
{
unsigned long ccount ;
RSR_CCOUNT ( ccount ) ;
return ccount ;
}
static inline void set_ccount ( unsigned long ccount )
{
WSR_CCOUNT ( ccount ) ;
}
static inline unsigned long get_linux_timer ( void )
{
unsigned ccompare ;
RSR_CCOMPARE ( LINUX_TIMER , ccompare ) ;
return ccompare ;
}
static inline void set_linux_timer ( unsigned long ccompare )
{
WSR_CCOMPARE ( LINUX_TIMER , ccompare ) ;
}
# endif /* _XTENSA_TIMEX_H */