Commit 6c950ca7 authored by Bhupesh Sharma's avatar Bhupesh Sharma Committed by David S. Miller

net: stmmac: dwmac-qcom-ethqos: add platform level clocks management

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: default avatarBhupesh Sharma <bhupesh.sharma@linaro.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8ff978b8
...@@ -447,6 +447,24 @@ static void ethqos_fix_mac_speed(void *priv, unsigned int speed) ...@@ -447,6 +447,24 @@ static void ethqos_fix_mac_speed(void *priv, unsigned int speed)
ethqos_configure(ethqos); 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) static int qcom_ethqos_probe(struct platform_device *pdev)
{ {
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
...@@ -466,6 +484,8 @@ static int qcom_ethqos_probe(struct platform_device *pdev) ...@@ -466,6 +484,8 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
return PTR_ERR(plat_dat); return PTR_ERR(plat_dat);
} }
plat_dat->clks_config = ethqos_clks_config;
ethqos = devm_kzalloc(&pdev->dev, sizeof(*ethqos), GFP_KERNEL); ethqos = devm_kzalloc(&pdev->dev, sizeof(*ethqos), GFP_KERNEL);
if (!ethqos) { if (!ethqos) {
ret = -ENOMEM; ret = -ENOMEM;
...@@ -489,7 +509,7 @@ static int qcom_ethqos_probe(struct platform_device *pdev) ...@@ -489,7 +509,7 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
goto err_mem; goto err_mem;
} }
ret = clk_prepare_enable(ethqos->rgmii_clk); ret = ethqos_clks_config(ethqos, true);
if (ret) if (ret)
goto err_mem; goto err_mem;
...@@ -512,7 +532,7 @@ static int qcom_ethqos_probe(struct platform_device *pdev) ...@@ -512,7 +532,7 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
return ret; return ret;
err_clk: err_clk:
clk_disable_unprepare(ethqos->rgmii_clk); ethqos_clks_config(ethqos, false);
err_mem: err_mem:
stmmac_remove_config_dt(pdev, plat_dat); stmmac_remove_config_dt(pdev, plat_dat);
...@@ -530,7 +550,7 @@ static int qcom_ethqos_remove(struct platform_device *pdev) ...@@ -530,7 +550,7 @@ static int qcom_ethqos_remove(struct platform_device *pdev)
return -ENODEV; return -ENODEV;
ret = stmmac_pltfr_remove(pdev); ret = stmmac_pltfr_remove(pdev);
clk_disable_unprepare(ethqos->rgmii_clk); ethqos_clks_config(ethqos, false);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment