Skip to content

Commit

Permalink
net: stmmac: dwmac-qcom-ethqos: add platform level clocks management
Browse files Browse the repository at this point in the history
Split clocks settings from init callback into clks_config callback,
which could support platform level clock management.

Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Bhupesh Sharma <bhupesh.sharma@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Bhupesh Sharma authored and David S. Miller committed Nov 18, 2021
1 parent 8ff978b commit 6c950ca
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,24 @@ static void ethqos_fix_mac_speed(void *priv, unsigned int speed)
ethqos_configure(ethqos);
}

static int ethqos_clks_config(void *priv, bool enabled)
{
struct qcom_ethqos *ethqos = priv;
int ret = 0;

if (enabled) {
ret = clk_prepare_enable(ethqos->rgmii_clk);
if (ret) {
dev_err(&ethqos->pdev->dev, "rgmii_clk enable failed\n");
return ret;
}
} else {
clk_disable_unprepare(ethqos->rgmii_clk);
}

return ret;
}

static int qcom_ethqos_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
Expand All @@ -466,6 +484,8 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
return PTR_ERR(plat_dat);
}

plat_dat->clks_config = ethqos_clks_config;

ethqos = devm_kzalloc(&pdev->dev, sizeof(*ethqos), GFP_KERNEL);
if (!ethqos) {
ret = -ENOMEM;
Expand All @@ -489,7 +509,7 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
goto err_mem;
}

ret = clk_prepare_enable(ethqos->rgmii_clk);
ret = ethqos_clks_config(ethqos, true);
if (ret)
goto err_mem;

Expand All @@ -512,7 +532,7 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
return ret;

err_clk:
clk_disable_unprepare(ethqos->rgmii_clk);
ethqos_clks_config(ethqos, false);

err_mem:
stmmac_remove_config_dt(pdev, plat_dat);
Expand All @@ -530,7 +550,7 @@ static int qcom_ethqos_remove(struct platform_device *pdev)
return -ENODEV;

ret = stmmac_pltfr_remove(pdev);
clk_disable_unprepare(ethqos->rgmii_clk);
ethqos_clks_config(ethqos, false);

return ret;
}
Expand Down

0 comments on commit 6c950ca

Please sign in to comment.