sunxi: driver refresh for 3.13
[openwrt.git] / target / linux / sunxi / patches-3.13 / 151-6-stmmac-fixup-6.patch
1 From 623997fb90eab7a135c2c68a332c8450a488baca Mon Sep 17 00:00:00 2001
2 From: Srinivas Kandagatla <srinivas.kandagatla@st.com>
3 Date: Thu, 16 Jan 2014 10:52:35 +0000
4 Subject: [PATCH] net: stmmac: fix power management suspend-resume case
5
6 The driver PM resume assumes that the IP is still powered up and the
7 all the register contents are not disturbed when it comes out of low
8 power suspend case. This assumption is wrong, basically the driver
9 should not consider any state of registers after it comes out of low
10 power. However driver can keep the part of the IP powered up if its a
11 wake up source. But it can not assume the register state of the IP. Also
12 its possible that SOC glue layer can take the power off the IP if its
13 not wake-up source to reduce the power consumption.
14
15 This patch re initializes hardware by calling stmmac_hw_setup function in
16 resume case.
17
18 Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@st.com>
19 Acked-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
20 Signed-off-by: David S. Miller <davem@davemloft.net>
21 ---
22  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 13 +++++++------
23  1 file changed, 7 insertions(+), 6 deletions(-)
24
25 diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
26 index 341c8dc3..742a83f 100644
27 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
28 +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
29 @@ -2887,18 +2887,19 @@ int stmmac_resume(struct net_device *ndev)
30          * this bit because it can generate problems while resuming
31          * from another devices (e.g. serial console).
32          */
33 -       if (device_may_wakeup(priv->device))
34 +       if (device_may_wakeup(priv->device)) {
35                 priv->hw->mac->pmt(priv->ioaddr, 0);
36 -       else
37 +       } else {
38                 /* enable the clk prevously disabled */
39                 clk_prepare_enable(priv->stmmac_clk);
40 +               /* reset the phy so that it's ready */
41 +               if (priv->mii)
42 +                       stmmac_mdio_reset(priv->mii);
43 +       }
44  
45         netif_device_attach(ndev);
46  
47 -       /* Enable the MAC and DMA */
48 -       stmmac_set_mac(priv->ioaddr, true);
49 -       priv->hw->dma->start_tx(priv->ioaddr);
50 -       priv->hw->dma->start_rx(priv->ioaddr);
51 +       stmmac_hw_setup(ndev);
52  
53         napi_enable(&priv->napi);
54  
55 -- 
56 1.8.5.5
57