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