/*
 *  File Name       : linux/include/asm-arm/arch-mp200/preempt.h
 *  Function        : timing support for preempt-stats patch
 *  Release Version : Ver 1.00
 *  Release Date    : 2006/02/17
 *
 *  Copyright (C) NEC Electronics Corporation 2006
 *
 *
 *  This program is free software;you can redistribute it and/or modify it under the terms of
 *  the GNU General Public License as published by Free Softwere Foundation; either version 2
 *  of License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 *  without even the implied warrnty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *  See the GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License along with this program;
 *  If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 *  MA 02111-1307, USA.
 *
 */

#ifndef __ASM_ARCH_MP200_PREEMPT_H
#define __ASM_ARCH_MP200_PREEMPT_H

#include <asm/arch/timer.h>

#define TICKS_PER_USEC_12M	12
#define TICKS_PER_USEC_32K	1

#if CONFIG_MP200_CLOCK > 1000
#define TICKS_PER_USEC		TICKS_PER_USEC_12M
#else
#define TICKS_PER_USEC		TICKS_PER_USEC_32K
#endif

#define readclock_init()

#define readclock()		mp200_system_timer_read(TIMER_KFI)

#define clock_to_usecs(x)				\
({							\
	unsigned int ret;				\
	if (ticks_per_usec == TICKS_PER_USEC_32K) {	\
		ret = COUNT_TO_USEC_32K(x);		\
	} else {					\
		ret = COUNT_TO_USEC_12M(x);		\
	}						\
	ret;						\
})

#define INTERRUPTS_ENABLED(x)	(!((x) & PSR_I_BIT))

static inline unsigned long clock_diff(unsigned long start, unsigned long stop)
{
	return (stop - start);
}

#endif				/* __ASM_ARCH_MP200_PREEMPT_H */
