~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/xtensa/include/asm/delay.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * include/asm-xtensa/delay.h
  3  *
  4  * This file is subject to the terms and conditions of the GNU General Public
  5  * License.  See the file "COPYING" in the main directory of this archive
  6  * for more details.
  7  *
  8  * Copyright (C) 2001 - 2005 Tensilica Inc.
  9  *
 10  */
 11 
 12 #ifndef _XTENSA_DELAY_H
 13 #define _XTENSA_DELAY_H
 14 
 15 #include <asm/timex.h>
 16 #include <asm/param.h>
 17 
 18 extern unsigned long loops_per_jiffy;
 19 
 20 static inline void __delay(unsigned long loops)
 21 {
 22         if (__builtin_constant_p(loops) && loops < 2)
 23                 __asm__ __volatile__ ("nop");
 24         else if (loops >= 2)
 25                 /* 2 cycles per loop. */
 26                 __asm__ __volatile__ ("1: addi %0, %0, -2; bgeui %0, 2, 1b"
 27                                 : "+r" (loops));
 28 }
 29 
 30 /* Undefined function to get compile-time error */
 31 void __bad_udelay(void);
 32 void __bad_ndelay(void);
 33 
 34 #define __MAX_UDELAY 30000
 35 #define __MAX_NDELAY 30000
 36 
 37 static inline void __udelay(unsigned long usecs)
 38 {
 39         unsigned long start = get_ccount();
 40         unsigned long cycles = (usecs * (ccount_freq >> 15)) >> 5;
 41 
 42         /* Note: all variables are unsigned (can wrap around)! */
 43         while (((unsigned long)get_ccount()) - start < cycles)
 44                 cpu_relax();
 45 }
 46 
 47 static inline void udelay(unsigned long usec)
 48 {
 49         if (__builtin_constant_p(usec) && usec >= __MAX_UDELAY)
 50                 __bad_udelay();
 51         else
 52                 __udelay(usec);
 53 }
 54 
 55 static inline void __ndelay(unsigned long nsec)
 56 {
 57         /*
 58          * Inner shift makes sure multiplication doesn't overflow
 59          * for legitimate nsec values
 60          */
 61         unsigned long cycles = (nsec * (ccount_freq >> 15)) >> 15;
 62         __delay(cycles);
 63 }
 64 
 65 #define ndelay(n) ndelay(n)
 66 
 67 static inline void ndelay(unsigned long nsec)
 68 {
 69         if (__builtin_constant_p(nsec) && nsec >= __MAX_NDELAY)
 70                 __bad_ndelay();
 71         else
 72                 __ndelay(nsec);
 73 }
 74 
 75 #endif
 76 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php