@@ -42,7 +42,6 @@ struct rk_priv_data {
bool clock_input;
bool integrated_phy;
- struct clk *clk_mac;
struct clk *gmac_clkin;
struct clk *mac_clk_rx;
struct clk *mac_clk_tx;
@@ -1217,11 +1216,6 @@ static int rk_gmac_clk_init(struct plat_stmmacenet_data *plat)
dev_err(dev, "cannot get clock %s\n",
"pclk_mac");
- bsp_priv->clk_mac = devm_clk_get(dev, "stmmaceth");
- if (IS_ERR(bsp_priv->clk_mac))
- dev_err(dev, "cannot get clock %s\n",
- "stmmaceth");
-
if (bsp_priv->phy_iface == PHY_INTERFACE_MODE_RMII) {
bsp_priv->clk_mac_ref = devm_clk_get(dev, "clk_mac_ref");
if (IS_ERR(bsp_priv->clk_mac_ref))
@@ -1245,7 +1239,7 @@ static int rk_gmac_clk_init(struct plat_stmmacenet_data *plat)
dev_info(dev, "clock input from PHY\n");
} else {
if (bsp_priv->phy_iface == PHY_INTERFACE_MODE_RMII)
- clk_set_rate(bsp_priv->clk_mac, 50000000);
+ clk_set_rate(plat->stmmac_clk, 50000000);
}
if (plat->phy_node && bsp_priv->integrated_phy) {
@@ -1261,8 +1255,9 @@ static int rk_gmac_clk_init(struct plat_stmmacenet_data *plat)
return 0;
}
-static int gmac_clk_enable(struct rk_priv_data *bsp_priv, bool enable)
+static int rk_gmac_clks_config(void *priv, bool enable)
{
+ struct rk_priv_data *bsp_priv = priv;
int phy_iface = bsp_priv->phy_iface;
if (enable) {
@@ -1296,10 +1291,6 @@ static int gmac_clk_enable(struct rk_priv_data *bsp_priv, bool enable)
if (!IS_ERR(bsp_priv->clk_mac_speed))
clk_prepare_enable(bsp_priv->clk_mac_speed);
- /**
- * if (!IS_ERR(bsp_priv->clk_mac))
- * clk_prepare_enable(bsp_priv->clk_mac);
- */
mdelay(5);
bsp_priv->clk_enabled = true;
}
@@ -1322,10 +1313,7 @@ static int gmac_clk_enable(struct rk_priv_data *bsp_priv, bool enable)
clk_disable_unprepare(bsp_priv->mac_clk_tx);
clk_disable_unprepare(bsp_priv->clk_mac_speed);
- /**
- * if (!IS_ERR(bsp_priv->clk_mac))
- * clk_disable_unprepare(bsp_priv->clk_mac);
- */
+
bsp_priv->clk_enabled = false;
}
}
@@ -1487,10 +1475,6 @@ static int rk_gmac_init(struct platform_device *pdev, void *priv)
if (ret)
return ret;
- ret = gmac_clk_enable(bsp_priv, true);
- if (ret)
- return ret;
-
/*rmii or rgmii*/
switch (bsp_priv->phy_iface) {
case PHY_INTERFACE_MODE_RGMII:
@@ -1519,10 +1503,8 @@ static int rk_gmac_init(struct platform_device *pdev, void *priv)
}
ret = phy_power_on(bsp_priv, true);
- if (ret) {
- gmac_clk_enable(bsp_priv, false);
+ if (ret)
return ret;
- }
if (bsp_priv->integrated_phy)
rk_gmac_integrated_phy_powerup(bsp_priv);
@@ -1538,7 +1520,6 @@ static void rk_gmac_exit(struct platform_device *pdev, void *priv)
rk_gmac_integrated_phy_powerdown(bsp_priv);
phy_power_on(bsp_priv, false);
- gmac_clk_enable(bsp_priv, false);
}
static void rk_fix_speed(void *priv, unsigned int speed)
@@ -1591,6 +1572,7 @@ static int rk_gmac_probe(struct platform_device *pdev)
plat_dat->has_gmac = true;
plat_dat->init = rk_gmac_init;
plat_dat->exit = rk_gmac_exit;
+ plat_dat->clks_config = rk_gmac_clks_config;
plat_dat->fix_mac_speed = rk_fix_speed;
plat_dat->bsp_priv = rk_gmac_setup(pdev, plat_dat, data);
@@ -1603,10 +1585,14 @@ static int rk_gmac_probe(struct platform_device *pdev)
if (ret)
goto err_remove_config_dt;
- ret = rk_gmac_init(pdev, plat_dat->bsp_priv);
+ ret = rk_gmac_clks_config(plat_dat->bsp_priv, true);
if (ret)
goto err_remove_config_dt;
+ ret = rk_gmac_init(pdev, plat_dat->bsp_priv);
+ if (ret)
+ goto err_gmac_clks_off;
+
ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
if (ret)
goto err_gmac_powerdown;
@@ -1615,6 +1601,8 @@ static int rk_gmac_probe(struct platform_device *pdev)
err_gmac_powerdown:
rk_gmac_exit(pdev, plat_dat->bsp_priv);
+err_gmac_clks_off:
+ rk_gmac_clks_config(plat_dat->bsp_priv, true);
err_remove_config_dt:
stmmac_remove_config_dt(pdev, plat_dat);
Make the stmmac core responsible for the management of the stmmaceth clock (directly) and the dwmac-rk specific clocks (via a the clks_config callback function). Signed-off-by: Michael Riesch <michael.riesch@wolfvision.net> --- .../net/ethernet/stmicro/stmmac/dwmac-rk.c | 38 +++++++------------ 1 file changed, 13 insertions(+), 25 deletions(-)