1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

cpu/sam0_eth: clean up init()

- don't enable PHY twice
 - properly set NCFGR register
 - sam0_read_phy() does not return a signed value
This commit is contained in:
Benjamin Valentin 2023-05-30 15:41:24 +02:00
parent 84a3078a93
commit faf8be39c6

View File

@ -159,7 +159,7 @@ static void _init_desc_buf(void)
GMAC->TBQB.reg = (uint32_t) tx_desc;
}
int sam0_read_phy(uint8_t phy, uint8_t addr)
unsigned sam0_read_phy(uint8_t phy, uint8_t addr)
{
GMAC->MAN.reg = GMAC_MAN_REGA(addr) | GMAC_MAN_PHYA(phy)
| GMAC_MAN_CLTTO | GMAC_MAN_WTN(0x2)
@ -353,9 +353,6 @@ int sam0_eth_init(void)
memset(rx_desc, 0, sizeof(rx_desc));
memset(tx_desc, 0, sizeof(tx_desc));
/* Enable PHY */
gpio_set(sam_gmac_config[0].rst_pin);
/* Initialize buffers descriptor */
_init_desc_buf();
/* Disable RX and TX */
@ -373,9 +370,9 @@ int sam0_eth_init(void)
/* Set TxBase-100-FD by default */
/* TODO: implement auto negotiation */
GMAC->NCFGR.reg |= (GMAC_NCFGR_SPD | GMAC_NCFGR_FD | GMAC_NCFGR_MTIHEN |
GMAC_NCFGR_RXCOEN | GMAC_NCFGR_MAXFS | GMAC_NCFGR_CAF |
GMAC_NCFGR_LFERD | GMAC_NCFGR_RFCS | GMAC_NCFGR_CLK(3));
GMAC->NCFGR.reg = GMAC_NCFGR_SPD | GMAC_NCFGR_FD | GMAC_NCFGR_MTIHEN
| GMAC_NCFGR_RXCOEN | GMAC_NCFGR_MAXFS | GMAC_NCFGR_CAF
| GMAC_NCFGR_LFERD | GMAC_NCFGR_RFCS | GMAC_NCFGR_CLK(3);
/* Enable all multicast addresses */
GMAC->HRB.reg = 0xffffffff;