diff options
author | Maxime Chevallier <maxime.chevallier@bootlin.com> | 2022-11-25 16:17:59 +0300 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2022-11-30 07:29:55 +0300 |
commit | d1a0ff5ff9efba55cc39ca520ba076943cd9a425 (patch) | |
tree | 5a3ef20ca62305e5295e2d6f9a18fb8dcc9aae60 | |
parent | 7f0c940be5c5f52b0a7acaf2b55df73337f5c7a8 (diff) | |
download | linux-d1a0ff5ff9efba55cc39ca520ba076943cd9a425.tar.xz |
net: pcs: altera-tse: use read_poll_timeout to wait for reset
Software resets on the TSE PCS don't clear registers, but rather reset
all internal state machines regarding AN, comma detection and
encoding/decoding. Use read_poll_timeout to wait for the reset to clear
instead of manually polling the register.
Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-rw-r--r-- | drivers/net/pcs/pcs-altera-tse.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/drivers/net/pcs/pcs-altera-tse.c b/drivers/net/pcs/pcs-altera-tse.c index 97a7cabff962..e86cadc391e8 100644 --- a/drivers/net/pcs/pcs-altera-tse.c +++ b/drivers/net/pcs/pcs-altera-tse.c @@ -60,7 +60,6 @@ static void tse_pcs_write(struct altera_tse_pcs *tse_pcs, int regnum, static int tse_pcs_reset(struct altera_tse_pcs *tse_pcs) { - int i = 0; u16 bmcr; /* Reset PCS block */ @@ -68,13 +67,9 @@ static int tse_pcs_reset(struct altera_tse_pcs *tse_pcs) bmcr |= BMCR_RESET; tse_pcs_write(tse_pcs, MII_BMCR, bmcr); - for (i = 0; i < SGMII_PCS_SW_RESET_TIMEOUT; i++) { - if (!(tse_pcs_read(tse_pcs, MII_BMCR) & BMCR_RESET)) - return 0; - udelay(1); - } - - return -ETIMEDOUT; + return read_poll_timeout(tse_pcs_read, bmcr, (bmcr & BMCR_RESET), + 10, SGMII_PCS_SW_RESET_TIMEOUT, 1, + tse_pcs, MII_BMCR); } static int alt_tse_pcs_validate(struct phylink_pcs *pcs, |