sunxi: initial 3.13 support
[openwrt/staging/yousong.git] / target / linux / sunxi / patches-3.13 / 190-stmmac-enable-main-clock-when-probing.patch
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
5
6 Signed-off-by: Chen-Yu Tsai <wens@csie.org>
7 ---
8 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 24 +++++++++++++----------
9 1 file changed, 14 insertions(+), 10 deletions(-)
10
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;
18
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__);
22 + goto error_clk_get;
23 + }
24 + clk_prepare_enable(priv->stmmac_clk);
25 +
26 /* Init MAC and get the capabilities */
27 ret = stmmac_hw_init(priv);
28 if (ret)
29 - goto error_free_netdev;
30 + goto error_hw_init;
31
32 ndev->netdev_ops = &stmmac_netdev_ops;
33
34 @@ -2723,12 +2730,6 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device,
35 goto error_netdev_register;
36 }
37
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__);
41 - goto error_clk_get;
42 - }
43 -
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,
48 }
49 }
50
51 + clk_disable_unprepare(priv->stmmac_clk);
52 +
53 return priv;
54
55 error_mdio_register:
56 - clk_put(priv->stmmac_clk);
57 -error_clk_get:
58 unregister_netdev(ndev);
59 error_netdev_register:
60 netif_napi_del(&priv->napi);
61 -error_free_netdev:
62 +error_hw_init:
63 + clk_disable_unprepare(priv->stmmac_clk);
64 + clk_put(priv->stmmac_clk);
65 +error_clk_get:
66 free_netdev(ndev);
67
68 return NULL;
69 --
70 1.8.5.1
71