From 8b38a67ca2dfcae7dd940bb477c1c9118f45bc2b Mon Sep 17 00:00:00 2001 From: Armand Ciejak Date: Fri, 2 Oct 2020 09:44:48 +0200 Subject: [PATCH] eth: mcux: Replace hard-coded eth_context.clock This fixes wrong value for i.MX RT. This is one less hard-coded value in eth_N_context structures. Signed-off-by: Armand Ciejak --- drivers/ethernet/eth_mcux.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/ethernet/eth_mcux.c b/drivers/ethernet/eth_mcux.c index d866465574f..63ca1f360d2 100644 --- a/drivers/ethernet/eth_mcux.c +++ b/drivers/ethernet/eth_mcux.c @@ -71,6 +71,11 @@ enum eth_mcux_phy_state { eth_mcux_phy_state_closing }; +#ifdef CONFIG_NET_POWER_MANAGEMENT +extern uint32_t ENET_GetInstance(ENET_Type * base); +static const clock_ip_name_t enet_clocks[] = ENET_CLOCKS; +#endif + static void eth_mcux_init(const struct device *dev); static const char * @@ -1102,6 +1107,9 @@ static int eth_init(const struct device *dev) #endif #if defined(CONFIG_NET_POWER_MANAGEMENT) + const uint32_t inst = ENET_GetInstance(context->base); + + context->clock = enet_clocks[inst]; context->clock_dev = device_get_binding(context->clock_name); #endif @@ -1313,7 +1321,6 @@ static struct eth_context eth_0_context = { .base = (ENET_Type *)DT_INST_REG_ADDR(0), #if defined(CONFIG_NET_POWER_MANAGEMENT) .clock_name = DT_INST_CLOCKS_LABEL(0), - .clock = kCLOCK_Enet0, // FIXME can be either kCLOCK_Enet0 or kCLOCK_Enet2 #endif .config_func = eth_0_config_func, .phy_addr = 0U, @@ -1390,7 +1397,6 @@ static struct eth_context eth_1_context = { .base = (ENET_Type *)DT_INST_REG_ADDR(1), #if defined(CONFIG_NET_POWER_MANAGEMENT) .clock_name = DT_INST_CLOCKS_LABEL(1), - .clock = kCLOCK_Enet2, // FIXME can be either kCLOCK_Enet0 or kCLOCK_Enet2 #endif .config_func = eth_1_config_func, .phy_addr = 0U,