Weak symbols don't work as expected when you want to override them from within the same static library. This patch changes the arch_ndelay() function so that instead of having a weak generic implementation, the choice between generic implementation and an arch-specific override is explicitly made by Kconfig. Let's also drop the "arch_" prefix and just call this ndelay(). Change-Id: Ie4fe2734e0683fa3537e2ebcabfe067e7499463a Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/87776 Reviewed-by: Yu-Ping Wu <yupingso@google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Subrata Banik <subratabanik@google.com> Reviewed-by: Jakub "Kuba" Czapiga <czapiga@google.com>
54 lines
1.1 KiB
C
54 lines
1.1 KiB
C
/* SPDX-License-Identifier: BSD-3-Clause */
|
|
|
|
#ifndef LIBPAYLOAD_DELAY_H
|
|
#define LIBPAYLOAD_DELAY_H
|
|
|
|
#include <stdint.h>
|
|
|
|
#define NSECS_PER_SEC 1000000000
|
|
#define USECS_PER_SEC 1000000
|
|
#define MSECS_PER_SEC 1000
|
|
#define NSECS_PER_MSEC (NSECS_PER_SEC / MSECS_PER_SEC)
|
|
#define NSECS_PER_USEC (NSECS_PER_SEC / USECS_PER_SEC)
|
|
#define USECS_PER_MSEC (USECS_PER_SEC / MSECS_PER_SEC)
|
|
|
|
unsigned int get_cpu_speed(void);
|
|
|
|
/**
|
|
* Delay for a specified number of nanoseconds.
|
|
*
|
|
* @param ns Number of nanoseconds to delay for.
|
|
*/
|
|
void ndelay(uint64_t n);
|
|
|
|
/**
|
|
* Delay for a specified number of microseconds.
|
|
*
|
|
* @param us Number of microseconds to delay for.
|
|
*/
|
|
static inline void udelay(unsigned int us)
|
|
{
|
|
ndelay((uint64_t)us * NSECS_PER_USEC);
|
|
}
|
|
|
|
/**
|
|
* Delay for a specified number of milliseconds.
|
|
*
|
|
* @param ms Number of milliseconds to delay for.
|
|
*/
|
|
static inline void mdelay(unsigned int ms)
|
|
{
|
|
ndelay((uint64_t)ms * NSECS_PER_MSEC);
|
|
}
|
|
|
|
/**
|
|
* Delay for a specified number of seconds.
|
|
*
|
|
* @param s Number of seconds to delay for.
|
|
*/
|
|
static inline void delay(unsigned int s)
|
|
{
|
|
ndelay((uint64_t)s * NSECS_PER_SEC);
|
|
}
|
|
|
|
#endif /* LIBPAYLOAD_DELAY_H */
|