1 From 133a9b75e2b0c48cd1d8f93b0ee61089821c32d9 Mon Sep 17 00:00:00 2001
2 From: Chen-Yu Tsai <wens@csie.org>
3 Date: Sat, 7 Dec 2013 01:29:34 +0800
4 Subject: [PATCH] net: stmmac: Enable stmmac main clock when probing hardware
6 Signed-off-by: Chen-Yu Tsai <wens@csie.org>
8 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 24 +++++++++++++----------
9 1 file changed, 14 insertions(+), 10 deletions(-)
11 diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
12 index 8a7a23a..4d75cba 100644
13 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
14 +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
15 @@ -2682,10 +2682,17 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device,
16 if ((phyaddr >= 0) && (phyaddr <= 31))
17 priv->plat->phy_addr = phyaddr;
19 + priv->stmmac_clk = clk_get(priv->device, STMMAC_RESOURCE_NAME);
20 + if (IS_ERR(priv->stmmac_clk)) {
21 + pr_warn("%s: warning: cannot get CSR clock\n", __func__);
24 + clk_prepare_enable(priv->stmmac_clk);
26 /* Init MAC and get the capabilities */
27 ret = stmmac_hw_init(priv);
29 - goto error_free_netdev;
32 ndev->netdev_ops = &stmmac_netdev_ops;
34 @@ -2723,12 +2730,6 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device,
35 goto error_netdev_register;
38 - priv->stmmac_clk = clk_get(priv->device, STMMAC_RESOURCE_NAME);
39 - if (IS_ERR(priv->stmmac_clk)) {
40 - pr_warn("%s: warning: cannot get CSR clock\n", __func__);
44 /* If a specific clk_csr value is passed from the platform
45 * this means that the CSR Clock Range selection cannot be
46 * changed at run-time and it is fixed. Viceversa the driver'll try to
47 @@ -2753,15 +2754,18 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device,
51 + clk_disable_unprepare(priv->stmmac_clk);
56 - clk_put(priv->stmmac_clk);
58 unregister_netdev(ndev);
59 error_netdev_register:
60 netif_napi_del(&priv->napi);
63 + clk_disable_unprepare(priv->stmmac_clk);
64 + clk_put(priv->stmmac_clk);