18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * delay.h: Linux delay routines on the Sparc. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu). 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef __SPARC_DELAY_H 98c2ecf20Sopenharmony_ci#define __SPARC_DELAY_H 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <asm/cpudata.h> 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_cistatic inline void __delay(unsigned long loops) 148c2ecf20Sopenharmony_ci{ 158c2ecf20Sopenharmony_ci __asm__ __volatile__("cmp %0, 0\n\t" 168c2ecf20Sopenharmony_ci "1: bne 1b\n\t" 178c2ecf20Sopenharmony_ci "subcc %0, 1, %0\n" : 188c2ecf20Sopenharmony_ci "=&r" (loops) : 198c2ecf20Sopenharmony_ci "0" (loops) : 208c2ecf20Sopenharmony_ci "cc"); 218c2ecf20Sopenharmony_ci} 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci/* This is too messy with inline asm on the Sparc. */ 248c2ecf20Sopenharmony_civoid __udelay(unsigned long usecs, unsigned long lpj); 258c2ecf20Sopenharmony_civoid __ndelay(unsigned long nsecs, unsigned long lpj); 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci#ifdef CONFIG_SMP 288c2ecf20Sopenharmony_ci#define __udelay_val cpu_data(smp_processor_id()).udelay_val 298c2ecf20Sopenharmony_ci#else /* SMP */ 308c2ecf20Sopenharmony_ci#define __udelay_val loops_per_jiffy 318c2ecf20Sopenharmony_ci#endif /* SMP */ 328c2ecf20Sopenharmony_ci#define udelay(__usecs) __udelay(__usecs, __udelay_val) 338c2ecf20Sopenharmony_ci#define ndelay(__nsecs) __ndelay(__nsecs, __udelay_val) 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#endif /* defined(__SPARC_DELAY_H) */ 36