1 /* 2 * Delay loops 3 * 4 * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com> 5 * 6 * This work is licensed under the terms of the GNU LGPL, version 2. 7 */ 8 #include <libcflat.h> 9 #include <asm/processor.h> 10 #include <asm/barrier.h> 11 #include <asm/delay.h> 12 delay(u64 cycles)13void delay(u64 cycles) 14 { 15 u64 start = get_cntvct(); 16 17 while ((get_cntvct() - start) < cycles) 18 cpu_relax(); 19 } 20 udelay(unsigned long usec)21void udelay(unsigned long usec) 22 { 23 delay((u64)usec * get_cntfrq() / 1000000); 24 } 25 mdelay(unsigned long msecs)26void mdelay(unsigned long msecs) 27 { 28 while (msecs--) 29 udelay(1000); 30 } 31