2
0

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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
  13. index 5d0d11eb6711..eacf907a365d 100644
  14. --- a/drivers/net/ethernet/cadence/macb_main.c
  15. +++ b/drivers/net/ethernet/cadence/macb_main.c
  16. @@ -3575,6 +3575,20 @@ static void macb_probe_queues(void __iomem *mem,
  17. *num_queues = hweight32(*queue_mask);
  18. }
  19. +static void macb_clks_disable(struct clk *pclk, struct clk *hclk, struct clk *tx_clk,
  20. + struct clk *rx_clk, struct clk *tsu_clk)
  21. +{
  22. + struct clk_bulk_data clks[] = {
  23. + { .clk = tsu_clk, },
  24. + { .clk = rx_clk, },
  25. + { .clk = pclk, },
  26. + { .clk = hclk, },
  27. + { .clk = tx_clk },
  28. + };
  29. +
  30. + clk_bulk_disable_unprepare(ARRAY_SIZE(clks), clks);
  31. +}
  32. +
  33. static int macb_clk_init(struct platform_device *pdev, struct clk **pclk,
  34. struct clk **hclk, struct clk **tx_clk,
  35. struct clk **rx_clk, struct clk **tsu_clk)
  36. @@ -4642,11 +4656,7 @@ static int macb_probe(struct platform_device *pdev)
  37. free_netdev(dev);
  38. err_disable_clocks:
  39. - clk_disable_unprepare(tx_clk);
  40. - clk_disable_unprepare(hclk);
  41. - clk_disable_unprepare(pclk);
  42. - clk_disable_unprepare(rx_clk);
  43. - clk_disable_unprepare(tsu_clk);
  44. + macb_clks_disable(pclk, hclk, tx_clk, rx_clk, tsu_clk);
  45. pm_runtime_disable(&pdev->dev);
  46. pm_runtime_set_suspended(&pdev->dev);
  47. pm_runtime_dont_use_autosuspend(&pdev->dev);
  48. @@ -4671,11 +4681,8 @@ static int macb_remove(struct platform_device *pdev)
  49. pm_runtime_disable(&pdev->dev);
  50. pm_runtime_dont_use_autosuspend(&pdev->dev);
  51. if (!pm_runtime_suspended(&pdev->dev)) {
  52. - clk_disable_unprepare(bp->tx_clk);
  53. - clk_disable_unprepare(bp->hclk);
  54. - clk_disable_unprepare(bp->pclk);
  55. - clk_disable_unprepare(bp->rx_clk);
  56. - clk_disable_unprepare(bp->tsu_clk);
  57. + macb_clks_disable(bp->pclk, bp->hclk, bp->tx_clk,
  58. + bp->rx_clk, bp->tsu_clk);
  59. pm_runtime_set_suspended(&pdev->dev);
  60. }
  61. phylink_destroy(bp->phylink);
  62. @@ -4854,13 +4861,10 @@ static int __maybe_unused macb_runtime_suspend(struct device *dev)
  63. struct net_device *netdev = dev_get_drvdata(dev);
  64. struct macb *bp = netdev_priv(netdev);
  65. - if (!(device_may_wakeup(dev))) {
  66. - clk_disable_unprepare(bp->tx_clk);
  67. - clk_disable_unprepare(bp->hclk);
  68. - clk_disable_unprepare(bp->pclk);
  69. - clk_disable_unprepare(bp->rx_clk);
  70. - }
  71. - clk_disable_unprepare(bp->tsu_clk);
  72. + if (!(device_may_wakeup(dev)))
  73. + macb_clks_disable(bp->pclk, bp->hclk, bp->tx_clk, bp->rx_clk, bp->tsu_clk);
  74. + else
  75. + macb_clks_disable(NULL, NULL, NULL, NULL, bp->tsu_clk);
  76. return 0;
  77. }
  78. --
  79. 2.32.0