1*b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 2a439fe51SSam Ravnborg /* 3a439fe51SSam Ravnborg * delay.h: Linux delay routines on the Sparc. 4a439fe51SSam Ravnborg * 5a439fe51SSam Ravnborg * Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu). 6a439fe51SSam Ravnborg */ 7a439fe51SSam Ravnborg 8a439fe51SSam Ravnborg #ifndef __SPARC_DELAY_H 9a439fe51SSam Ravnborg #define __SPARC_DELAY_H 10a439fe51SSam Ravnborg 11a439fe51SSam Ravnborg #include <asm/cpudata.h> 12a439fe51SSam Ravnborg __delay(unsigned long loops)13a439fe51SSam Ravnborgstatic inline void __delay(unsigned long loops) 14a439fe51SSam Ravnborg { 15a439fe51SSam Ravnborg __asm__ __volatile__("cmp %0, 0\n\t" 16a439fe51SSam Ravnborg "1: bne 1b\n\t" 17a439fe51SSam Ravnborg "subcc %0, 1, %0\n" : 18a439fe51SSam Ravnborg "=&r" (loops) : 19a439fe51SSam Ravnborg "0" (loops) : 20a439fe51SSam Ravnborg "cc"); 21a439fe51SSam Ravnborg } 22a439fe51SSam Ravnborg 23a439fe51SSam Ravnborg /* This is too messy with inline asm on the Sparc. */ 24f05a6865SSam Ravnborg void __udelay(unsigned long usecs, unsigned long lpj); 25f05a6865SSam Ravnborg void __ndelay(unsigned long nsecs, unsigned long lpj); 26a439fe51SSam Ravnborg 27a439fe51SSam Ravnborg #ifdef CONFIG_SMP 28a439fe51SSam Ravnborg #define __udelay_val cpu_data(smp_processor_id()).udelay_val 29a439fe51SSam Ravnborg #else /* SMP */ 30a439fe51SSam Ravnborg #define __udelay_val loops_per_jiffy 31a439fe51SSam Ravnborg #endif /* SMP */ 32a439fe51SSam Ravnborg #define udelay(__usecs) __udelay(__usecs, __udelay_val) 33a439fe51SSam Ravnborg #define ndelay(__nsecs) __ndelay(__nsecs, __udelay_val) 34a439fe51SSam Ravnborg 35a439fe51SSam Ravnborg #endif /* defined(__SPARC_DELAY_H) */ 36