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 12 void delay(u64 cycles) 13 { 14 u64 start = get_cntvct(); 15 16 while ((get_cntvct() - start) < cycles) 17 cpu_relax(); 18 } 19 20 void udelay(unsigned long usec) 21 { 22 delay((u64)usec * get_cntfrq() / 1000000); 23 } 24 25 void mdelay(unsigned long msecs) 26 { 27 while (msecs--) 28 udelay(1000); 29 } 30