OSDN Git Service

net: stmmac: add platform level clocks management
authorJoakim Zhang <qiangqing.zhang@nxp.com>
Mon, 15 Mar 2021 12:16:47 +0000 (20:16 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 15 Mar 2021 21:46:21 +0000 (14:46 -0700)
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>
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
include/linux/stmmac.h

index 3c50846..a10704d 100644 (file)
@@ -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;
index 722dc16..51004eb 100644 (file)
@@ -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;