add phy bordinit functionality

on boardlevel one can do reset, cable-check, diagnostics, check link
quality and more on every link up
This commit is contained in:
Simon Filgis 2023-09-17 15:14:52 +02:00 committed by Xiang Xiao
parent 587f01a5e2
commit 8853e72502
2 changed files with 29 additions and 4 deletions

View File

@ -4022,6 +4022,30 @@ static int sam_phyinit(struct sam_emac_s *priv)
regval |= EMAC_NCFGR_CLK_DIV8; /* MCK divided by 8 (MCK up to 20 MHz) */
}
#ifdef CONFIG_SAMV7_EMAC0_PHYINIT
if (priv->attr->emac == EMAC0_INTF)
{
ret = sam_phy_boardinitialize(0);
if (ret < 0)
{
nerr("ERROR: Failed to initialize the PHY: %d\n", ret);
return ret;
}
}
#endif
#ifdef CONFIG_SAMV7_EMAC1_PHYINIT
if (priv->attr->emac == EMAC1_INTF)
{
ret = sam_phy_boardinitialize(1);
if (ret < 0)
{
nerr("ERROR: Failed to initialize the PHY: %d\n", ret);
return ret;
}
}
#endif
sam_putreg(priv, SAM_EMAC_NCFGR_OFFSET, regval);
/* Check the PHY Address */

View File

@ -227,13 +227,14 @@ int sam_emac_setmacaddr(int intf, uint8_t mac[6]);
* Description:
* Some boards require specialized initialization of the PHY before it can
* be used. This may include such things as configuring GPIOs, resetting
* the PHY, etc. If CONFIG_SAMV7_PHYINIT is defined in the configuration
* then the board specific logic must provide sam_phyinitialize();
* the PHY, etc. If CONFIG_SAMV7_EMAC0_PHYINIT or
* CONFIG_SAMV7_EMAC1_PHYINIT is defined in the configuration then the
* board specific logic must provide sam_phyinitialize();
* The SAMV7 Ethernet driver will call this function one time before it
* first uses the PHY.
*
* Input Parameters:
* intf - Always zero for now.
* intf - 0 for EMAC0 and 1 for EMAC1.
*
* Returned Value:
* OK on success; Negated errno on failure.
@ -242,7 +243,7 @@ int sam_emac_setmacaddr(int intf, uint8_t mac[6]);
*
****************************************************************************/
#ifdef CONFIG_SAMV7_PHYINIT
#if defined(CONFIG_SAMV7_EMAC0_PHYINIT) | defined(CONFIG_SAMV7_EMAC1_PHYINIT)
int sam_phy_boardinitialize(int intf);
#endif