diff options
author | Florian Fainelli <f.fainelli@gmail.com> | 2018-08-03 14:08:44 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-08-03 15:11:43 -0400 |
commit | 54226116add4dcfe6391ffb810225f78c9c3d245 (patch) | |
tree | c150ad21f083744ab24abba28f44dcd9c477c907 | |
parent | 9e85e22713d6fed4873057493d6307c08b1d86a6 (diff) |
net: systemport: Create helper to set MPD
Create a helper function to turn on/off MPD, this will be used to avoid
duplicating code as we are going to add additional types of wake-up
types.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/broadcom/bcmsysport.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c index 7faad9e1a6f9..284581c9680e 100644 --- a/drivers/net/ethernet/broadcom/bcmsysport.c +++ b/drivers/net/ethernet/broadcom/bcmsysport.c | |||
@@ -1041,17 +1041,25 @@ static int bcm_sysport_poll(struct napi_struct *napi, int budget) | |||
1041 | return work_done; | 1041 | return work_done; |
1042 | } | 1042 | } |
1043 | 1043 | ||
1044 | static void bcm_sysport_resume_from_wol(struct bcm_sysport_priv *priv) | 1044 | static void mpd_enable_set(struct bcm_sysport_priv *priv, bool enable) |
1045 | { | 1045 | { |
1046 | u32 reg; | 1046 | u32 reg; |
1047 | 1047 | ||
1048 | reg = umac_readl(priv, UMAC_MPD_CTRL); | ||
1049 | if (enable) | ||
1050 | reg |= MPD_EN; | ||
1051 | else | ||
1052 | reg &= ~MPD_EN; | ||
1053 | umac_writel(priv, reg, UMAC_MPD_CTRL); | ||
1054 | } | ||
1055 | |||
1056 | static void bcm_sysport_resume_from_wol(struct bcm_sysport_priv *priv) | ||
1057 | { | ||
1048 | /* Stop monitoring MPD interrupt */ | 1058 | /* Stop monitoring MPD interrupt */ |
1049 | intrl2_0_mask_set(priv, INTRL2_0_MPD); | 1059 | intrl2_0_mask_set(priv, INTRL2_0_MPD); |
1050 | 1060 | ||
1051 | /* Clear the MagicPacket detection logic */ | 1061 | /* Clear the MagicPacket detection logic */ |
1052 | reg = umac_readl(priv, UMAC_MPD_CTRL); | 1062 | mpd_enable_set(priv, false); |
1053 | reg &= ~MPD_EN; | ||
1054 | umac_writel(priv, reg, UMAC_MPD_CTRL); | ||
1055 | 1063 | ||
1056 | netif_dbg(priv, wol, priv->netdev, "resumed from WOL\n"); | 1064 | netif_dbg(priv, wol, priv->netdev, "resumed from WOL\n"); |
1057 | } | 1065 | } |
@@ -2447,9 +2455,7 @@ static int bcm_sysport_suspend_to_wol(struct bcm_sysport_priv *priv) | |||
2447 | 2455 | ||
2448 | /* Do not leave the UniMAC RBUF matching only MPD packets */ | 2456 | /* Do not leave the UniMAC RBUF matching only MPD packets */ |
2449 | if (!timeout) { | 2457 | if (!timeout) { |
2450 | reg = umac_readl(priv, UMAC_MPD_CTRL); | 2458 | mpd_enable_set(priv, false); |
2451 | reg &= ~MPD_EN; | ||
2452 | umac_writel(priv, reg, UMAC_MPD_CTRL); | ||
2453 | netif_err(priv, wol, ndev, "failed to enter WOL mode\n"); | 2459 | netif_err(priv, wol, ndev, "failed to enter WOL mode\n"); |
2454 | return -ETIMEDOUT; | 2460 | return -ETIMEDOUT; |
2455 | } | 2461 | } |