9
0
Fork 0

e1000: Add a "poll register" function

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Andrey Smirnov 2016-06-01 21:58:49 -07:00 committed by Sascha Hauer
parent 72f02e6c0b
commit 91d3dd2fd8
2 changed files with 20 additions and 0 deletions

View File

@ -2144,5 +2144,9 @@ int32_t e1000_read_eeprom(struct e1000_hw *hw, uint16_t offset,
int32_t e1000_swfw_sync_acquire(struct e1000_hw *hw, uint16_t mask);
int32_t e1000_swfw_sync_release(struct e1000_hw *hw, uint16_t mask);
int e1000_poll_reg(struct e1000_hw *hw, uint32_t reg,
uint32_t mask, uint32_t value,
uint64_t timeout);
#endif /* _E1000_HW_H_ */

View File

@ -52,3 +52,19 @@ void e1000_write_flush(struct e1000_hw *hw)
{
e1000_read_reg(hw, E1000_STATUS);
}
int e1000_poll_reg(struct e1000_hw *hw, uint32_t reg, uint32_t mask,
uint32_t value, uint64_t timeout)
{
const uint64_t start = get_time_ns();
do {
const uint32_t v = e1000_read_reg(hw, reg);
if ((v & mask) == value)
return 0;
} while (!is_timeout(start, timeout));
return -ETIMEDOUT;
}