1 From 62866e98737e77c87f9dec99edea76ab54360770 Mon Sep 17 00:00:00 2001
2 From: Chen-Yu Tsai <wens@csie.org>
3 Date: Fri, 17 Jan 2014 21:24:40 +0800
4 Subject: [PATCH] net: stmmac: Enable stmmac main clock when probing hardware
6 The stmmac driver does not enable the main clock during the probe phase.
7 If the clock was not enabled by the boot loader or was disabled by the
8 kernel, hardware features and the MDIO bus would not be probed properly.
10 Signed-off-by: Chen-Yu Tsai <wens@csie.org>
11 Signed-off-by: David S. Miller <davem@davemloft.net>
13 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 26 +++++++++++------------
14 1 file changed, 13 insertions(+), 13 deletions(-)
16 diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
17 index cddcf76..0d2c4cb 100644
18 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
19 +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
20 @@ -1680,8 +1680,6 @@ static int stmmac_open(struct net_device *dev)
21 struct stmmac_priv *priv = netdev_priv(dev);
24 - clk_prepare_enable(priv->stmmac_clk);
26 stmmac_check_ether_addr(priv);
28 if (priv->pcs != STMMAC_PCS_RGMII && priv->pcs != STMMAC_PCS_TBI &&
29 @@ -1819,7 +1817,6 @@ static int stmmac_release(struct net_device *dev)
30 #ifdef CONFIG_STMMAC_DEBUG_FS
33 - clk_disable_unprepare(priv->stmmac_clk);
35 stmmac_release_ptp(priv);
37 @@ -2727,10 +2724,18 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device,
38 if ((phyaddr >= 0) && (phyaddr <= 31))
39 priv->plat->phy_addr = phyaddr;
41 + priv->stmmac_clk = devm_clk_get(priv->device, STMMAC_RESOURCE_NAME);
42 + if (IS_ERR(priv->stmmac_clk)) {
43 + dev_warn(priv->device, "%s: warning: cannot get CSR clock\n",
47 + clk_prepare_enable(priv->stmmac_clk);
49 /* Init MAC and get the capabilities */
50 ret = stmmac_hw_init(priv);
52 - goto error_free_netdev;
55 ndev->netdev_ops = &stmmac_netdev_ops;
57 @@ -2768,12 +2773,6 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device,
58 goto error_netdev_register;
61 - priv->stmmac_clk = clk_get(priv->device, STMMAC_RESOURCE_NAME);
62 - if (IS_ERR(priv->stmmac_clk)) {
63 - pr_warn("%s: warning: cannot get CSR clock\n", __func__);
67 /* If a specific clk_csr value is passed from the platform
68 * this means that the CSR Clock Range selection cannot be
69 * changed at run-time and it is fixed. Viceversa the driver'll try to
70 @@ -2801,12 +2800,12 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device,
74 - clk_put(priv->stmmac_clk);
76 unregister_netdev(ndev);
77 error_netdev_register:
78 netif_napi_del(&priv->napi);
81 + clk_disable_unprepare(priv->stmmac_clk);
86 @@ -2833,6 +2832,7 @@ int stmmac_dvr_remove(struct net_device *ndev)
87 stmmac_mdio_unregister(ndev);
88 netif_carrier_off(ndev);
89 unregister_netdev(ndev);
90 + clk_disable_unprepare(priv->stmmac_clk);