From 77594d7fbf01f2b2c968271951d41edb515428f4 Mon Sep 17 00:00:00 2001 From: Patrice Chotard Date: Fri, 22 Feb 2019 15:04:44 +0100 Subject: [PATCH] board: stm32f746-disco: Get MII/RMII phy_mode from DT This is needed to make ethernet work on stm32f746-eval which uses MII mode. Signed-off-by: Patrice Chotard Acked-by: Joe Hershberger --- board/st/stm32f746-disco/stm32f746-disco.c | 23 ++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/board/st/stm32f746-disco/stm32f746-disco.c b/board/st/stm32f746-disco/stm32f746-disco.c index 7c9b1ad82a..e89ed2153b 100644 --- a/board/st/stm32f746-disco/stm32f746-disco.c +++ b/board/st/stm32f746-disco/stm32f746-disco.c @@ -7,6 +7,8 @@ #include #include #include +#include +#include #include #include #include @@ -123,8 +125,25 @@ int board_init(void) gd->bd->bi_boot_params = gd->bd->bi_dram[0].start + 0x100; #ifdef CONFIG_ETH_DESIGNWARE - /* Set >RMII mode */ - STM32_SYSCFG->pmc |= SYSCFG_PMC_MII_RMII_SEL; + const char *phy_mode; + int node; + + node = fdt_node_offset_by_compatible(gd->fdt_blob, 0, "st,stm32-dwmac"); + if (node < 0) + return -1; + + phy_mode = fdt_getprop(gd->fdt_blob, node, "phy-mode", NULL); + + switch (phy_get_interface_by_name(phy_mode)) { + case PHY_INTERFACE_MODE_RMII: + STM32_SYSCFG->pmc |= SYSCFG_PMC_MII_RMII_SEL; + break; + case PHY_INTERFACE_MODE_MII: + STM32_SYSCFG->pmc &= ~SYSCFG_PMC_MII_RMII_SEL; + break; + default: + printf("PHY interface %s not supported !\n", phy_mode); + } #endif #if defined(CONFIG_CMD_BMP) -- 2.25.1