1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- #ifndef __WAIT_BIT_H
- #define __WAIT_BIT_H
- #include <common.h>
- #include <console.h>
- #include <linux/errno.h>
- #include <asm/io.h>
- static inline int wait_for_bit(const char *prefix, const u32 *reg,
- const u32 mask, const bool set,
- const unsigned int timeout_ms,
- const bool breakable)
- {
- u32 val;
- unsigned long start = get_timer(0);
- while (1) {
- val = readl(reg);
- if (!set)
- val = ~val;
- if ((val & mask) == mask)
- return 0;
- if (get_timer(start) > timeout_ms)
- break;
- if (breakable && ctrlc()) {
- puts("Abort\n");
- return -EINTR;
- }
- udelay(1);
- }
- debug("%s: Timeout (reg=%p mask=%08x wait_set=%i)\n", prefix, reg, mask,
- set);
- return -ETIMEDOUT;
- }
- #endif
|