utils.h: add poll32

Signed-off-by: Sven Peter <sven@svenpeter.dev>
This commit is contained in:
Sven Peter 2021-03-06 10:57:21 +01:00 committed by Hector Martin
parent bf3830ee6d
commit 95b1cb39fc

View file

@ -313,4 +313,16 @@ void reboot(void) __attribute__((noreturn));
reboot(); \ reboot(); \
} while (0) } while (0)
static inline int poll32(u64 addr, u32 mask, u32 target, u32 timeout)
{
while (--timeout > 0) {
u32 value = read32(addr) & mask;
if (value == target)
return 0;
udelay(1);
}
return -1;
}
#endif #endif