sunxi: driver refresh for 3.13
[openwrt.git] / target / linux / sunxi / patches-3.13 / 151-9-stmmac-fixup-9.patch
1 From 89f7f2cfdd7ade55d5230501c21271690790ceda Mon Sep 17 00:00:00 2001
2 From: Srinivas Kandagatla <srinivas.kandagatla@st.com>
3 Date: Thu, 16 Jan 2014 10:53:00 +0000
4 Subject: [PATCH] net: stmmac: notify the PM core of a wakeup event.
5
6 In PM_SUSPEND_FREEZE and WOL(Wakeup On Lan) case, when the driver gets a
7 wakeup event, either the driver or platform specific PM code should notify
8 the pm core about it, so that the system can wakeup from low power.
9
10 In cases where there is no involvement of platform specific PM, it
11 becomes driver responsibility to notify the PM core to wakeup the
12 system.
13
14 Without this WOL with PM_SUSPEND_FREEZE does not work on STi based SOCs.
15
16 Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@st.com>
17 Acked-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
18 Signed-off-by: David S. Miller <davem@davemloft.net>
19 ---
20  drivers/net/ethernet/stmicro/stmmac/stmmac.h      | 1 +
21  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 9 +++++++--
22  2 files changed, 8 insertions(+), 2 deletions(-)
23
24 diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
25 index 027f1dd..73709e9 100644
26 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
27 +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
28 @@ -105,6 +105,7 @@ struct stmmac_priv {
29         unsigned int default_addend;
30         u32 adv_ts;
31         int use_riwt;
32 +       int irq_wake;
33         spinlock_t ptp_lock;
34  };
35  
36 diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
37 index df7d8d6..cddcf76 100644
38 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
39 +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
40 @@ -2320,6 +2320,9 @@ static irqreturn_t stmmac_interrupt(int irq, void *dev_id)
41         struct net_device *dev = (struct net_device *)dev_id;
42         struct stmmac_priv *priv = netdev_priv(dev);
43  
44 +       if (priv->irq_wake)
45 +               pm_wakeup_event(priv->device, 0);
46 +
47         if (unlikely(!dev)) {
48                 pr_err("%s: invalid dev pointer\n", __func__);
49                 return IRQ_NONE;
50 @@ -2861,9 +2864,10 @@ int stmmac_suspend(struct net_device *ndev)
51         stmmac_clear_descriptors(priv);
52  
53         /* Enable Power down mode by programming the PMT regs */
54 -       if (device_may_wakeup(priv->device))
55 +       if (device_may_wakeup(priv->device)) {
56                 priv->hw->mac->pmt(priv->ioaddr, priv->wolopts);
57 -       else {
58 +               priv->irq_wake = 1;
59 +       } else {
60                 stmmac_set_mac(priv->ioaddr, false);
61                 pinctrl_pm_select_sleep_state(priv->device);
62                 /* Disable clock in case of PWM is off */
63 @@ -2891,6 +2895,7 @@ int stmmac_resume(struct net_device *ndev)
64          */
65         if (device_may_wakeup(priv->device)) {
66                 priv->hw->mac->pmt(priv->ioaddr, 0);
67 +               priv->irq_wake = 0;
68         } else {
69                 pinctrl_pm_select_default_state(priv->device);
70                 /* enable the clk prevously disabled */
71 -- 
72 1.8.5.5
73