[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20210315121648.10408-3-qiangqing.zhang@nxp.com>
Date: Mon, 15 Mar 2021 20:16:47 +0800
From: Joakim Zhang <qiangqing.zhang@....com>
To: peppe.cavallaro@...com, alexandre.torgue@...com,
joabreu@...opsys.com, davem@...emloft.net, kuba@...nel.org,
f.fainelli@...il.com, andrew@...n.ch
Cc: netdev@...r.kernel.org, linux-imx@....com
Subject: [PATCH V3 repost net-next 2/3] 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@...n.ch>
Signed-off-by: Joakim Zhang <qiangqing.zhang@....com>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 10 ++++++++++
include/linux/stmmac.h | 1 +
2 files changed, 11 insertions(+)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 2a80db92e731..b2c64c5dabde 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 a302982de2d7..5ab2a8138149 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -183,6 +183,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;
--
2.17.1
Powered by blists - more mailing lists