From a6602e1600a1909935d0c3648eddd3a0738ba87d Mon Sep 17 00:00:00 2001 From: adrian Date: Thu, 20 Jan 2011 07:03:20 +0000 Subject: [PATCH] Add another HAL function which waits for a register for a configurable amount. This will be used by some future code. --- sys/dev/ath/ath_hal/ah.c | 10 ++++++++-- sys/dev/ath/ath_hal/ah_internal.h | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/sys/dev/ath/ath_hal/ah.c b/sys/dev/ath/ath_hal/ah.c index cff9613616a1..8ac55f5f8b9d 100644 --- a/sys/dev/ath/ath_hal/ah.c +++ b/sys/dev/ath/ath_hal/ah.c @@ -197,9 +197,16 @@ HAL_BOOL ath_hal_wait(struct ath_hal *ah, u_int reg, uint32_t mask, uint32_t val) { #define AH_TIMEOUT 1000 + return ath_hal_waitfor(ah, reg, mask, val, AH_TIMEOUT); +#undef AH_TIMEOUT +} + +HAL_BOOL +ath_hal_waitfor(struct ath_hal *ah, u_int reg, uint32_t mask, uint32_t val, uint32_t timeout) +{ int i; - for (i = 0; i < AH_TIMEOUT; i++) { + for (i = 0; i < timeout; i++) { if ((OS_REG_READ(ah, reg) & mask) == val) return AH_TRUE; OS_DELAY(10); @@ -208,7 +215,6 @@ ath_hal_wait(struct ath_hal *ah, u_int reg, uint32_t mask, uint32_t val) "%s: timeout on reg 0x%x: 0x%08x & 0x%08x != 0x%08x\n", __func__, reg, OS_REG_READ(ah, reg), mask, val); return AH_FALSE; -#undef AH_TIMEOUT } /* diff --git a/sys/dev/ath/ath_hal/ah_internal.h b/sys/dev/ath/ath_hal/ah_internal.h index 2765c422c53e..207143efe6d2 100644 --- a/sys/dev/ath/ath_hal/ah_internal.h +++ b/sys/dev/ath/ath_hal/ah_internal.h @@ -471,6 +471,8 @@ extern int ath_hal_additional_swba_backoff; /* in TU's */ /* wait for the register contents to have the specified value */ extern HAL_BOOL ath_hal_wait(struct ath_hal *, u_int reg, uint32_t mask, uint32_t val); +extern HAL_BOOL ath_hal_waitfor(struct ath_hal *, u_int reg, + uint32_t mask, uint32_t val, uint32_t timeout); /* return the first n bits in val reversed */ extern uint32_t ath_hal_reverseBits(uint32_t val, uint32_t n);