diff --git a/arch/arm/src/samv7/sam_emac.c b/arch/arm/src/samv7/sam_emac.c index c470f530f22..9a8fe99c9ec 100644 --- a/arch/arm/src/samv7/sam_emac.c +++ b/arch/arm/src/samv7/sam_emac.c @@ -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 */ diff --git a/arch/arm/src/samv7/sam_ethernet.h b/arch/arm/src/samv7/sam_ethernet.h index 29c7b6efd7a..829e5b04aaa 100644 --- a/arch/arm/src/samv7/sam_ethernet.h +++ b/arch/arm/src/samv7/sam_ethernet.h @@ -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