190-stmmac-enable-main-clock-when-probing.patch 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. From 133a9b75e2b0c48cd1d8f93b0ee61089821c32d9 Mon Sep 17 00:00:00 2001
  2. From: Chen-Yu Tsai <[email protected]>
  3. Date: Sat, 7 Dec 2013 01:29:34 +0800
  4. Subject: [PATCH] net: stmmac: Enable stmmac main clock when probing hardware
  5. Signed-off-by: Chen-Yu Tsai <[email protected]>
  6. ---
  7. drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 24 +++++++++++++----------
  8. 1 file changed, 14 insertions(+), 10 deletions(-)
  9. --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
  10. +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
  11. @@ -2680,10 +2680,17 @@ struct stmmac_priv *stmmac_dvr_probe(str
  12. if ((phyaddr >= 0) && (phyaddr <= 31))
  13. priv->plat->phy_addr = phyaddr;
  14. + priv->stmmac_clk = clk_get(priv->device, STMMAC_RESOURCE_NAME);
  15. + if (IS_ERR(priv->stmmac_clk)) {
  16. + pr_warn("%s: warning: cannot get CSR clock\n", __func__);
  17. + goto error_clk_get;
  18. + }
  19. + clk_prepare_enable(priv->stmmac_clk);
  20. +
  21. /* Init MAC and get the capabilities */
  22. ret = stmmac_hw_init(priv);
  23. if (ret)
  24. - goto error_free_netdev;
  25. + goto error_hw_init;
  26. ndev->netdev_ops = &stmmac_netdev_ops;
  27. @@ -2721,12 +2728,6 @@ struct stmmac_priv *stmmac_dvr_probe(str
  28. goto error_netdev_register;
  29. }
  30. - priv->stmmac_clk = clk_get(priv->device, STMMAC_RESOURCE_NAME);
  31. - if (IS_ERR(priv->stmmac_clk)) {
  32. - pr_warn("%s: warning: cannot get CSR clock\n", __func__);
  33. - goto error_clk_get;
  34. - }
  35. -
  36. /* If a specific clk_csr value is passed from the platform
  37. * this means that the CSR Clock Range selection cannot be
  38. * changed at run-time and it is fixed. Viceversa the driver'll try to
  39. @@ -2751,15 +2752,18 @@ struct stmmac_priv *stmmac_dvr_probe(str
  40. }
  41. }
  42. + clk_disable_unprepare(priv->stmmac_clk);
  43. +
  44. return priv;
  45. error_mdio_register:
  46. - clk_put(priv->stmmac_clk);
  47. -error_clk_get:
  48. unregister_netdev(ndev);
  49. error_netdev_register:
  50. netif_napi_del(&priv->napi);
  51. -error_free_netdev:
  52. +error_hw_init:
  53. + clk_disable_unprepare(priv->stmmac_clk);
  54. + clk_put(priv->stmmac_clk);
  55. +error_clk_get:
  56. free_netdev(ndev);
  57. return NULL;