2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 1995-2004 Russell King
|
|
|
|
*
|
|
|
|
* Delay routines, using a pre-computed "loops_per_second" value.
|
|
|
|
*/
|
|
|
|
#ifndef __ASM_ARM_DELAY_H
|
|
|
|
#define __ASM_ARM_DELAY_H
|
|
|
|
|
2012-07-06 22:47:17 +08:00
|
|
|
#include <asm/memory.h>
|
2006-03-21 01:10:09 +08:00
|
|
|
#include <asm/param.h> /* HZ */
|
|
|
|
|
2012-07-06 22:47:17 +08:00
|
|
|
#define MAX_UDELAY_MS 2
|
|
|
|
#define UDELAY_MULT ((UL(2199023) * HZ) >> 11)
|
|
|
|
#define UDELAY_SHIFT 30
|
|
|
|
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
|
2012-09-22 01:51:44 +08:00
|
|
|
struct delay_timer {
|
|
|
|
unsigned long (*read_current_timer)(void);
|
|
|
|
unsigned long freq;
|
|
|
|
};
|
|
|
|
|
2012-07-06 22:47:17 +08:00
|
|
|
extern struct arm_delay_ops {
|
|
|
|
void (*delay)(unsigned long);
|
|
|
|
void (*const_udelay)(unsigned long);
|
|
|
|
void (*udelay)(unsigned long);
|
2013-02-18 23:36:13 +08:00
|
|
|
bool const_clock;
|
2012-07-06 22:47:17 +08:00
|
|
|
} arm_delay_ops;
|
|
|
|
|
|
|
|
#define __delay(n) arm_delay_ops.delay(n)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This function intentionally does not exist; if you see references to
|
|
|
|
* it, it means that you're calling udelay() with an out of range value.
|
|
|
|
*
|
|
|
|
* With currently imposed limits, this means that we support a max delay
|
2006-03-21 01:10:09 +08:00
|
|
|
* of 2000us. Further limits: HZ<=1000 and bogomips<=3355
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
extern void __bad_udelay(void);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* division by multiplication: you don't have to worry about
|
|
|
|
* loss of precision.
|
|
|
|
*
|
2012-07-06 22:47:17 +08:00
|
|
|
* Use only for very small delays ( < 2 msec). Should probably use a
|
2005-04-17 06:20:36 +08:00
|
|
|
* lookup table, really, as the multiplications take much too long with
|
|
|
|
* short delays. This is a "reasonable" implementation, though (and the
|
|
|
|
* first constant multiplications gets optimized away if the delay is
|
|
|
|
* a constant)
|
|
|
|
*/
|
2012-07-06 22:47:17 +08:00
|
|
|
#define __udelay(n) arm_delay_ops.udelay(n)
|
|
|
|
#define __const_udelay(n) arm_delay_ops.const_udelay(n)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-03-21 01:10:09 +08:00
|
|
|
#define udelay(n) \
|
|
|
|
(__builtin_constant_p(n) ? \
|
|
|
|
((n) > (MAX_UDELAY_MS * 1000) ? __bad_udelay() : \
|
2012-07-06 22:47:17 +08:00
|
|
|
__const_udelay((n) * UDELAY_MULT)) : \
|
2005-04-17 06:20:36 +08:00
|
|
|
__udelay(n))
|
|
|
|
|
2012-07-06 22:47:17 +08:00
|
|
|
/* Loop-based definitions for assembly code. */
|
|
|
|
extern void __loop_delay(unsigned long loops);
|
|
|
|
extern void __loop_udelay(unsigned long usecs);
|
|
|
|
extern void __loop_const_udelay(unsigned long);
|
|
|
|
|
2012-09-22 01:51:44 +08:00
|
|
|
/* Delay-loop timer registration. */
|
|
|
|
#define ARCH_HAS_READ_CURRENT_TIMER
|
|
|
|
extern void register_current_timer_delay(const struct delay_timer *timer);
|
|
|
|
|
2012-07-06 22:47:17 +08:00
|
|
|
#endif /* __ASSEMBLY__ */
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif /* defined(_ARM_DELAY_H) */
|
|
|
|
|