Skip to content

Commit

Permalink
Merge pull request #21172 from benpicco/cpu/sam0_common/eth-hang
Browse files Browse the repository at this point in the history
cpu/sam0_eth: fix hang with broken PHY
  • Loading branch information
dylad authored Jan 30, 2025
2 parents 287324c + c791ff2 commit 529a1e4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cpu/sam0_common/periph/eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ unsigned sam0_read_phy(uint8_t phy, uint8_t addr)
/* Wait for operation completion */
while (!(GMAC->NSR.reg & GMAC_NSR_IDLE)) {}
/* return content of shift register */
return (GMAC->MAN.reg & GMAC_MAN_DATA_Msk);
return GMAC->MAN.reg & GMAC_MAN_DATA_Msk;
}

void sam0_write_phy(uint8_t phy, uint8_t addr, uint16_t data)
Expand All @@ -158,8 +158,14 @@ void sam0_eth_poweron(void)

/* enable PHY */
gpio_set(sam_gmac_config[0].rst_pin);
_is_sleeping = false;

/* if the PHY is not idle, it's likely broken */
if (!(GMAC->NSR.reg & GMAC_NSR_IDLE)) {
DEBUG_PUTS("sam0_eth: PHY not IDLE, likely broken.");
return;
}

_is_sleeping = false;
while (MII_BMCR_RESET & sam0_read_phy(0, MII_BMCR)) {}
}

Expand Down

0 comments on commit 529a1e4

Please sign in to comment.