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

TOMOYO Linux Cross Reference
Linux/arch/microblaze/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 /* SPDX-License-Identifier: GPL-2.0 */
  2 /*
  3  * Copyright (C) 2008 Michal Simek
  4  * Copyright (C) 2007 John Williams
  5  * Copyright (C) 2006 Atmark Techno, Inc.
  6  */
  7 
  8 #ifndef _ASM_MICROBLAZE_DELAY_H
  9 #define _ASM_MICROBLAZE_DELAY_H
 10 
 11 #include <linux/param.h>
 12 
 13 static inline void __delay(unsigned long loops)
 14 {
 15         asm volatile ("# __delay                \n\t"           \
 16                         "1: addi        %0, %0, -1\t\n"         \
 17                         "bneid  %0, 1b          \t\n"           \
 18                         "nop                    \t\n"
 19                         : "=r" (loops)
 20                         : "" (loops));
 21 }
 22 
 23 /*
 24  * Note that 19 * 226 == 4294 ==~ 2^32 / 10^6, so
 25  * loops = (4294 * usecs * loops_per_jiffy * HZ) / 2^32.
 26  *
 27  * The mul instruction gives us loops = (a * b) / 2^32.
 28  * We choose a = usecs * 19 * HZ and b = loops_per_jiffy * 226
 29  * because this lets us support a wide range of HZ and
 30  * loops_per_jiffy values without either a or b overflowing 2^32.
 31  * Thus we need usecs * HZ <= (2^32 - 1) / 19 = 226050910 and
 32  * loops_per_jiffy <= (2^32 - 1) / 226 = 19004280
 33  * (which corresponds to ~3800 bogomips at HZ = 100).
 34  * -- paulus
 35  */
 36 #define __MAX_UDELAY    (226050910UL/HZ)        /* maximum udelay argument */
 37 #define __MAX_NDELAY    (4294967295UL/HZ)       /* maximum ndelay argument */
 38 
 39 extern unsigned long loops_per_jiffy;
 40 
 41 static inline void __udelay(unsigned int x)
 42 {
 43 
 44         unsigned long long tmp =
 45                 (unsigned long long)x * (unsigned long long)loops_per_jiffy \
 46                         * 226LL;
 47         unsigned loops = tmp >> 32;
 48 
 49 /*
 50         __asm__("mulxuu %0,%1,%2" : "=r" (loops) :
 51                 "r" (x), "r" (loops_per_jiffy * 226));
 52 */
 53         __delay(loops);
 54 }
 55 
 56 extern void __bad_udelay(void);         /* deliberately undefined */
 57 extern void __bad_ndelay(void);         /* deliberately undefined */
 58 
 59 #define udelay(n)                                               \
 60         ({                                                      \
 61                 if (__builtin_constant_p(n)) {                  \
 62                         if ((n) / __MAX_UDELAY >= 1)            \
 63                                 __bad_udelay();                 \
 64                         else                                    \
 65                                 __udelay((n) * (19 * HZ));      \
 66                 } else {                                        \
 67                         __udelay((n) * (19 * HZ));              \
 68                 }                                               \
 69         })
 70 
 71 #define ndelay(n)                                               \
 72         ({                                                      \
 73                 if (__builtin_constant_p(n)) {                  \
 74                         if ((n) / __MAX_NDELAY >= 1)            \
 75                                 __bad_ndelay();                 \
 76                         else                                    \
 77                                 __udelay((n) * HZ);             \
 78                 } else {                                        \
 79                         __udelay((n) * HZ);                     \
 80                 }                                               \
 81         })
 82 
 83 #define muldiv(a, b, c)         (((a)*(b))/(c))
 84 
 85 #endif /* _ASM_MICROBLAZE_DELAY_H */
 86 

~ [ 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