Skip to content

Commit

Permalink
ethernet: ensure RMII clock before PHY reset
Browse files Browse the repository at this point in the history
Closes #6821
  • Loading branch information
suda-morris committed May 25, 2021
1 parent d743f85 commit fc60e09
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions components/ethernet/emac_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1109,8 +1109,6 @@ esp_err_t esp_eth_init_internal(eth_config_t *config)
goto _verify_err;
}

emac_config.emac_phy_power_enable(true);

//before set emac reg must enable clk
periph_module_enable(PERIPH_EMAC_MODULE);

Expand Down Expand Up @@ -1145,10 +1143,6 @@ esp_err_t esp_eth_init_internal(eth_config_t *config)
}
}

emac_enable_clk(true);
REG_SET_FIELD(EMAC_EX_PHYINF_CONF_REG, EMAC_EX_PHY_INTF_SEL, EMAC_EX_PHY_INTF_RMII);
emac_dma_init();

if (emac_config.clock_mode == ETH_CLOCK_GPIO0_IN) {
// external clock on GPIO0
REG_SET_BIT(EMAC_EX_CLK_CTRL_REG, EMAC_EX_EXT_OSC_EN);
Expand All @@ -1166,6 +1160,12 @@ esp_err_t esp_eth_init_internal(eth_config_t *config)
REG_CLR_BIT(EMAC_EX_OSCCLK_CONF_REG, EMAC_EX_OSC_CLK_SEL);
}

emac_config.emac_phy_power_enable(true);

emac_enable_clk(true);
REG_SET_FIELD(EMAC_EX_PHYINF_CONF_REG, EMAC_EX_PHY_INTF_SEL, EMAC_EX_PHY_INTF_RMII);
emac_dma_init();

emac_config.emac_gpio_config();

emac_hw_init();
Expand Down

0 comments on commit fc60e09

Please sign in to comment.