117-net-macb-add-function-to-disable-all-macb-clocks.patch 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. From 935d9aae15ee245a1bc6e322cbef02566a8996cc Mon Sep 17 00:00:00 2001
  2. From: Claudiu Beznea <[email protected]>
  3. Date: Wed, 9 Dec 2020 15:03:34 +0200
  4. Subject: [PATCH 117/247] net: macb: add function to disable all macb clocks
  5. Add function to disable all macb clocks.
  6. Signed-off-by: Claudiu Beznea <[email protected]>
  7. Suggested-by: Andrew Lunn <[email protected]>
  8. Signed-off-by: David S. Miller <[email protected]>
  9. ---
  10. drivers/net/ethernet/cadence/macb_main.c | 38 +++++++++++++-----------
  11. 1 file changed, 21 insertions(+), 17 deletions(-)
  12. --- a/drivers/net/ethernet/cadence/macb_main.c
  13. +++ b/drivers/net/ethernet/cadence/macb_main.c
  14. @@ -3603,6 +3603,20 @@ static void macb_probe_queues(void __iom
  15. *num_queues = hweight32(*queue_mask);
  16. }
  17. +static void macb_clks_disable(struct clk *pclk, struct clk *hclk, struct clk *tx_clk,
  18. + struct clk *rx_clk, struct clk *tsu_clk)
  19. +{
  20. + struct clk_bulk_data clks[] = {
  21. + { .clk = tsu_clk, },
  22. + { .clk = rx_clk, },
  23. + { .clk = pclk, },
  24. + { .clk = hclk, },
  25. + { .clk = tx_clk },
  26. + };
  27. +
  28. + clk_bulk_disable_unprepare(ARRAY_SIZE(clks), clks);
  29. +}
  30. +
  31. static int macb_clk_init(struct platform_device *pdev, struct clk **pclk,
  32. struct clk **hclk, struct clk **tx_clk,
  33. struct clk **rx_clk, struct clk **tsu_clk)
  34. @@ -4665,11 +4679,7 @@ err_out_free_netdev:
  35. free_netdev(dev);
  36. err_disable_clocks:
  37. - clk_disable_unprepare(tx_clk);
  38. - clk_disable_unprepare(hclk);
  39. - clk_disable_unprepare(pclk);
  40. - clk_disable_unprepare(rx_clk);
  41. - clk_disable_unprepare(tsu_clk);
  42. + macb_clks_disable(pclk, hclk, tx_clk, rx_clk, tsu_clk);
  43. pm_runtime_disable(&pdev->dev);
  44. pm_runtime_set_suspended(&pdev->dev);
  45. pm_runtime_dont_use_autosuspend(&pdev->dev);
  46. @@ -4694,11 +4704,8 @@ static int macb_remove(struct platform_d
  47. pm_runtime_disable(&pdev->dev);
  48. pm_runtime_dont_use_autosuspend(&pdev->dev);
  49. if (!pm_runtime_suspended(&pdev->dev)) {
  50. - clk_disable_unprepare(bp->tx_clk);
  51. - clk_disable_unprepare(bp->hclk);
  52. - clk_disable_unprepare(bp->pclk);
  53. - clk_disable_unprepare(bp->rx_clk);
  54. - clk_disable_unprepare(bp->tsu_clk);
  55. + macb_clks_disable(bp->pclk, bp->hclk, bp->tx_clk,
  56. + bp->rx_clk, bp->tsu_clk);
  57. pm_runtime_set_suspended(&pdev->dev);
  58. }
  59. phylink_destroy(bp->phylink);
  60. @@ -4877,13 +4884,10 @@ static int __maybe_unused macb_runtime_s
  61. struct net_device *netdev = dev_get_drvdata(dev);
  62. struct macb *bp = netdev_priv(netdev);
  63. - if (!(device_may_wakeup(dev))) {
  64. - clk_disable_unprepare(bp->tx_clk);
  65. - clk_disable_unprepare(bp->hclk);
  66. - clk_disable_unprepare(bp->pclk);
  67. - clk_disable_unprepare(bp->rx_clk);
  68. - }
  69. - clk_disable_unprepare(bp->tsu_clk);
  70. + if (!(device_may_wakeup(dev)))
  71. + macb_clks_disable(bp->pclk, bp->hclk, bp->tx_clk, bp->rx_clk, bp->tsu_clk);
  72. + else
  73. + macb_clks_disable(NULL, NULL, NULL, NULL, bp->tsu_clk);
  74. return 0;
  75. }