sunxi: driver refresh for 3.13
[openwrt.git] / target / linux / sunxi / patches-3.13 / 151-8-stmmac-fixup-8.patch
1 From db88f10ad6a84c5bcb71bf51f0988a4bb1733bea Mon Sep 17 00:00:00 2001
2 From: Srinivas Kandagatla <srinivas.kandagatla@st.com>
3 Date: Thu, 16 Jan 2014 10:52:52 +0000
4 Subject: [PATCH] net: stmmac: restore pinstate in pm resume.
5
6 This patch adds code to restore default pinstate of the pins when it
7 comes back from low power state. Without this patch the state of the
8 pins would be unknown and the driver would not work.
9
10 This patch also adds code to put the pins in to sleep state when the
11 driver enters low power state.
12
13 Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@st.com>
14 Acked-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
15 Signed-off-by: David S. Miller <davem@davemloft.net>
16 ---
17  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 3 +++
18  1 file changed, 3 insertions(+)
19
20 diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
21 index c1298a0..df7d8d6 100644
22 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
23 +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
24 @@ -43,6 +43,7 @@
25  #include <linux/dma-mapping.h>
26  #include <linux/slab.h>
27  #include <linux/prefetch.h>
28 +#include <linux/pinctrl/consumer.h>
29  #ifdef CONFIG_STMMAC_DEBUG_FS
30  #include <linux/debugfs.h>
31  #include <linux/seq_file.h>
32 @@ -2864,6 +2865,7 @@ int stmmac_suspend(struct net_device *ndev)
33                 priv->hw->mac->pmt(priv->ioaddr, priv->wolopts);
34         else {
35                 stmmac_set_mac(priv->ioaddr, false);
36 +               pinctrl_pm_select_sleep_state(priv->device);
37                 /* Disable clock in case of PWM is off */
38                 clk_disable_unprepare(priv->stmmac_clk);
39         }
40 @@ -2890,6 +2892,7 @@ int stmmac_resume(struct net_device *ndev)
41         if (device_may_wakeup(priv->device)) {
42                 priv->hw->mac->pmt(priv->ioaddr, 0);
43         } else {
44 +               pinctrl_pm_select_default_state(priv->device);
45                 /* enable the clk prevously disabled */
46                 clk_prepare_enable(priv->stmmac_clk);
47                 /* reset the phy so that it's ready */
48 -- 
49 1.8.5.5
50