Path: blob/master/arch/blackfin/include/asm/delay.h
15126 views
/*1* delay.h - delay functions2*3* Copyright (c) 2004-2007 Analog Devices Inc.4*5* Licensed under the GPL-2 or later.6*/78#ifndef __ASM_DELAY_H__9#define __ASM_DELAY_H__1011#include <mach/anomaly.h>1213static inline void __delay(unsigned long loops)14{15__asm__ __volatile__ (16"LSETUP(1f, 1f) LC0 = %0;"17"1: NOP;"18:19: "a" (loops)20: "LT0", "LB0", "LC0"21);22}2324#include <linux/param.h> /* needed for HZ */2526/*27* close approximation borrowed from m68knommu to avoid 64-bit math28*/2930#define HZSCALE (268435456 / (1000000/HZ))3132static inline unsigned long __to_delay(unsigned long scale)33{34extern unsigned long loops_per_jiffy;35return (((scale * HZSCALE) >> 11) * (loops_per_jiffy >> 11)) >> 6;36}3738static inline void udelay(unsigned long usecs)39{40__delay(__to_delay(usecs));41}4243static inline void ndelay(unsigned long nsecs)44{45__delay(__to_delay(1) * nsecs / 1000);46}4748#define ndelay ndelay4950#endif515253