blob: c31f91cc1d5dbd5cd0677ed007c002313a784109 [file] [log] [blame]
Mike Frysinger9e83b982007-11-21 16:08:58 +08001/*
2 * delay.h - delay functions
3 *
4 * Copyright (c) 2004-2007 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2 or later.
7 */
8
9#ifndef __ASM_DELAY_H__
10#define __ASM_DELAY_H__
11
Bryan Wu639f6572008-08-27 10:51:02 +080012#include <mach/anomaly.h>
Bryan Wu1394f032007-05-06 14:50:22 -070013
14static inline void __delay(unsigned long loops)
15{
Michael Hennerichc8e67412009-02-04 16:49:45 +080016__asm__ __volatile__ (
Mike Frysinger9e83b982007-11-21 16:08:58 +080017 "LSETUP(1f, 1f) LC0 = %0;"
18 "1: NOP;"
19 :
20 : "a" (loops)
21 : "LT0", "LB0", "LC0"
22 );
Bryan Wu1394f032007-05-06 14:50:22 -070023}
24
25#include <linux/param.h> /* needed for HZ */
26
27/*
Michael Hennerich4e653e02009-02-04 16:49:45 +080028 * close approximation borrowed from m68knommu to avoid 64-bit math
Bryan Wu1394f032007-05-06 14:50:22 -070029 */
Michael Hennerich4e653e02009-02-04 16:49:45 +080030
31#define HZSCALE (268435456 / (1000000/HZ))
32
Bryan Wu1394f032007-05-06 14:50:22 -070033static inline void udelay(unsigned long usecs)
34{
35 extern unsigned long loops_per_jiffy;
Michael Hennerich4e653e02009-02-04 16:49:45 +080036 __delay((((usecs * HZSCALE) >> 11) * (loops_per_jiffy >> 11)) >> 6);
Bryan Wu1394f032007-05-06 14:50:22 -070037}
38
Mike Frysinger9e83b982007-11-21 16:08:58 +080039#endif