From 5c0b7abe786d7b4370ed1dd7ef323a3091d9620c Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Fri, 22 Feb 2013 16:38:53 -0800 Subject: libpayload: Generalize and redistribute timekeeping code The timekeeping code in libpayload was dependent on rdtsc, and when it was split up by arch, that code was duplicated even though it was mostly the same. This change factors out actually reading the count from the timer and the speed of the timer and puts the definitions of ndelay, udelay, mdelay and delay into generic code. Then, in x86, the timer_hz and timer_get_raw_value functions which used to be in depthcharge were moved over to libpayload's arch/x86/timer.c. In ARM where there isn't a single, canonical timer, those functions are omitted with the intention that they'll be implemented by a specific timer driver chosen elsewhere. Change-Id: I9c919bed712ace941f417c1d58679d667b2d8269 Signed-off-by: Gabe Black Reviewed-on: http://review.coreboot.org/2717 Tested-by: build bot (Jenkins) Reviewed-by: Ronald G. Minnich --- payloads/libpayload/arch/armv7/timer.c | 47 ---------------------------------- 1 file changed, 47 deletions(-) (limited to 'payloads/libpayload/arch/armv7') diff --git a/payloads/libpayload/arch/armv7/timer.c b/payloads/libpayload/arch/armv7/timer.c index 24b0a0fa34..9449c9feff 100644 --- a/payloads/libpayload/arch/armv7/timer.c +++ b/payloads/libpayload/arch/armv7/timer.c @@ -52,50 +52,3 @@ unsigned int get_cpu_speed(void) return cpu_khz; } - -static inline void _delay(unsigned long long delta) -{ - /* FIXME */ -} - -/** - * Delay for a specified number of nanoseconds. - * - * @param n Number of nanoseconds to delay for. - */ -void ndelay(unsigned int n) -{ - _delay((unsigned long long)n * cpu_khz / 1000000); -} - -/** - * Delay for a specified number of microseconds. - * - * @param n Number of microseconds to delay for. - */ -void udelay(unsigned int n) -{ - _delay((unsigned long long)n * cpu_khz / 1000); -} - -/** - * Delay for a specified number of milliseconds. - * - * @param m Number of milliseconds to delay for. - */ -void mdelay(unsigned int m) -{ - _delay((unsigned long long)m * cpu_khz); -} - -/** - * Delay for a specified number of seconds. - * - * @param s Number of seconds to delay for. - */ -void delay(unsigned int s) -{ - int i; - for (i=0; i<1000; i++) - _delay((unsigned long long)s * cpu_khz); -} -- cgit v1.2.3