Skip to content

Commit

Permalink
net: ethernet: stmmac: Add support for syscfg clock
Browse files Browse the repository at this point in the history
Add optional support for syscfg clock in dwmac-stm32.c
Now Syscfg clock is activated automatically when syscfg
registers are used

Signed-off-by: Christophe Roullier <christophe.roullier@st.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Christophe Roullier authored and David S. Miller committed Nov 8, 2019
1 parent d408bef commit caee317
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,18 +155,14 @@ static int stm32mp1_clk_prepare(struct stm32_dwmac *dwmac, bool prepare)
ret = clk_prepare_enable(dwmac->syscfg_clk);
if (ret)
return ret;

if (dwmac->clk_eth_ck) {
ret = clk_prepare_enable(dwmac->clk_eth_ck);
if (ret) {
clk_disable_unprepare(dwmac->syscfg_clk);
ret = clk_prepare_enable(dwmac->clk_eth_ck);
if (ret) {
clk_disable_unprepare(dwmac->syscfg_clk);
return ret;
}
}
} else {
clk_disable_unprepare(dwmac->syscfg_clk);
if (dwmac->clk_eth_ck)
clk_disable_unprepare(dwmac->clk_eth_ck);
clk_disable_unprepare(dwmac->clk_eth_ck);
}
return ret;
}
Expand Down Expand Up @@ -320,12 +316,10 @@ static int stm32mp1_parse_data(struct stm32_dwmac *dwmac,
return PTR_ERR(dwmac->clk_ethstp);
}

/* Clock for sysconfig */
/* Optional Clock for sysconfig */
dwmac->syscfg_clk = devm_clk_get(dev, "syscfg-clk");
if (IS_ERR(dwmac->syscfg_clk)) {
dev_err(dev, "No syscfg clock provided...\n");
return PTR_ERR(dwmac->syscfg_clk);
}
if (IS_ERR(dwmac->syscfg_clk))
dwmac->syscfg_clk = NULL;

/* Get IRQ information early to have an ability to ask for deferred
* probe if needed before we went too far with resource allocation.
Expand Down Expand Up @@ -437,8 +431,7 @@ static int stm32mp1_suspend(struct stm32_dwmac *dwmac)

clk_disable_unprepare(dwmac->clk_tx);
clk_disable_unprepare(dwmac->syscfg_clk);
if (dwmac->clk_eth_ck)
clk_disable_unprepare(dwmac->clk_eth_ck);
clk_disable_unprepare(dwmac->clk_eth_ck);

return ret;
}
Expand Down

0 comments on commit caee317

Please sign in to comment.