aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJoakim Zhang <qiangqing.zhang@nxp.com>2021-03-15 20:16:47 +0800
committerDavid S. Miller <davem@davemloft.net>2021-03-15 14:46:21 -0700
commitb4d45aee6635197d257f3469413837cd94fc11f4 (patch)
tree60ce8fa3f8f0cdc87aadc8926fb15aa4107940db
parentnet: stmmac: add clocks management for gmac driver (diff)
downloadwireguard-linux-b4d45aee6635197d257f3469413837cd94fc11f4.tar.xz
wireguard-linux-b4d45aee6635197d257f3469413837cd94fc11f4.zip
net: stmmac: add platform level clocks management
This patch intends to add platform level clocks management. Some platforms may have their own special clocks, they also need to be managed dynamically. If you want to manage such clocks, please implement clks_config callback. Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c10
-rw-r--r--include/linux/stmmac.h1
2 files changed, 11 insertions, 0 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 3c50846f59cd..a10704d8e3c6 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -127,9 +127,19 @@ int stmmac_bus_clks_config(struct stmmac_priv *priv, bool enabled)
clk_disable_unprepare(priv->plat->stmmac_clk);
return ret;
}
+ if (priv->plat->clks_config) {
+ ret = priv->plat->clks_config(priv->plat->bsp_priv, enabled);
+ if (ret) {
+ clk_disable_unprepare(priv->plat->stmmac_clk);
+ clk_disable_unprepare(priv->plat->pclk);
+ return ret;
+ }
+ }
} else {
clk_disable_unprepare(priv->plat->stmmac_clk);
clk_disable_unprepare(priv->plat->pclk);
+ if (priv->plat->clks_config)
+ priv->plat->clks_config(priv->plat->bsp_priv, enabled);
}
return ret;
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index 722dc167b5c9..51004ebd0540 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -184,6 +184,7 @@ struct plat_stmmacenet_data {
int (*init)(struct platform_device *pdev, void *priv);
void (*exit)(struct platform_device *pdev, void *priv);
struct mac_device_info *(*setup)(void *priv);
+ int (*clks_config)(void *priv, bool enabled);
void *bsp_priv;
struct clk *stmmac_clk;
struct clk *pclk;