/*1* This file is subject to the terms and conditions of the GNU General Public2* License. See the file "COPYING" in the main directory of this archive3* for more details.4*5* Copyright (C) 1994 by Waldorf Electronics6* Copyright (C) 1995 - 2000, 01, 03 by Ralf Baechle7* Copyright (C) 1999, 2000 Silicon Graphics, Inc.8* Copyright (C) 2007 Maciej W. Rozycki9*/10#include <linux/module.h>11#include <linux/param.h>12#include <linux/smp.h>1314#include <asm/compiler.h>15#include <asm/war.h>1617inline void __delay(unsigned int loops)18{19__asm__ __volatile__ (20" .set noreorder \n"21" .align 3 \n"22"1: bnez %0, 1b \n"23" subu %0, 1 \n"24" .set reorder \n"25: "=r" (loops)26: "0" (loops));27}28EXPORT_SYMBOL(__delay);2930/*31* Division by multiplication: you don't have to worry about32* loss of precision.33*34* Use only for very small delays ( < 1 msec). Should probably use a35* lookup table, really, as the multiplications take much too long with36* short delays. This is a "reasonable" implementation, though (and the37* first constant multiplications gets optimized away if the delay is38* a constant)39*/4041void __udelay(unsigned long us)42{43unsigned int lpj = raw_current_cpu_data.udelay_val;4445__delay((us * 0x000010c7ull * HZ * lpj) >> 32);46}47EXPORT_SYMBOL(__udelay);4849void __ndelay(unsigned long ns)50{51unsigned int lpj = raw_current_cpu_data.udelay_val;5253__delay((ns * 0x00000005ull * HZ * lpj) >> 32);54}55EXPORT_SYMBOL(__ndelay);565758