Commit 543876c9 authored by Giuseppe Cavallaro's avatar Giuseppe Cavallaro Committed by David S. Miller

stmmac: review the wake-up support

If the PM support is available this is passed
through the platform instead to be hard-coded
in the core files.
WoL on Magic Frame can be enabled by using
the ethtool support.
Signed-off-by: default avatarGiuseppe Cavallaro <peppe.cavallaro@st.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 77555ee7
...@@ -238,7 +238,6 @@ struct mac_device_info { ...@@ -238,7 +238,6 @@ struct mac_device_info {
struct stmmac_ops *mac; struct stmmac_ops *mac;
struct stmmac_desc_ops *desc; struct stmmac_desc_ops *desc;
struct stmmac_dma_ops *dma; struct stmmac_dma_ops *dma;
unsigned int pmt; /* support Power-Down */
struct mii_regs mii; /* MII register Addresses */ struct mii_regs mii; /* MII register Addresses */
struct mac_link link; struct mac_link link;
}; };
......
...@@ -239,7 +239,6 @@ struct mac_device_info *dwmac1000_setup(void __iomem *ioaddr) ...@@ -239,7 +239,6 @@ struct mac_device_info *dwmac1000_setup(void __iomem *ioaddr)
mac->mac = &dwmac1000_ops; mac->mac = &dwmac1000_ops;
mac->dma = &dwmac1000_dma_ops; mac->dma = &dwmac1000_dma_ops;
mac->pmt = PMT_SUPPORTED;
mac->link.port = GMAC_CONTROL_PS; mac->link.port = GMAC_CONTROL_PS;
mac->link.duplex = GMAC_CONTROL_DM; mac->link.duplex = GMAC_CONTROL_DM;
mac->link.speed = GMAC_CONTROL_FES; mac->link.speed = GMAC_CONTROL_FES;
......
...@@ -193,7 +193,6 @@ struct mac_device_info *dwmac100_setup(void __iomem *ioaddr) ...@@ -193,7 +193,6 @@ struct mac_device_info *dwmac100_setup(void __iomem *ioaddr)
mac->mac = &dwmac100_ops; mac->mac = &dwmac100_ops;
mac->dma = &dwmac100_dma_ops; mac->dma = &dwmac100_dma_ops;
mac->pmt = PMT_NOT_SUPPORTED;
mac->link.port = MAC_CONTROL_PS; mac->link.port = MAC_CONTROL_PS;
mac->link.duplex = MAC_CONTROL_F; mac->link.duplex = MAC_CONTROL_F;
mac->link.speed = 0; mac->link.speed = 0;
......
...@@ -322,7 +322,7 @@ static void stmmac_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) ...@@ -322,7 +322,7 @@ static void stmmac_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
struct stmmac_priv *priv = netdev_priv(dev); struct stmmac_priv *priv = netdev_priv(dev);
spin_lock_irq(&priv->lock); spin_lock_irq(&priv->lock);
if (priv->wolenabled == PMT_SUPPORTED) { if (device_can_wakeup(priv->device)) {
wol->supported = WAKE_MAGIC; wol->supported = WAKE_MAGIC;
wol->wolopts = priv->wolopts; wol->wolopts = priv->wolopts;
} }
...@@ -334,16 +334,20 @@ static int stmmac_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) ...@@ -334,16 +334,20 @@ static int stmmac_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
struct stmmac_priv *priv = netdev_priv(dev); struct stmmac_priv *priv = netdev_priv(dev);
u32 support = WAKE_MAGIC; u32 support = WAKE_MAGIC;
if (priv->wolenabled == PMT_NOT_SUPPORTED) if (!device_can_wakeup(priv->device))
return -EINVAL; return -EINVAL;
if (wol->wolopts & ~support) if (wol->wolopts & ~support)
return -EINVAL; return -EINVAL;
if (wol->wolopts == 0) if (wol->wolopts) {
device_set_wakeup_enable(priv->device, 0); pr_info("stmmac: wakeup enable\n");
else
device_set_wakeup_enable(priv->device, 1); device_set_wakeup_enable(priv->device, 1);
enable_irq_wake(dev->irq);
} else {
device_set_wakeup_enable(priv->device, 0);
disable_irq_wake(dev->irq);
}
spin_lock_irq(&priv->lock); spin_lock_irq(&priv->lock);
priv->wolopts = wol->wolopts; priv->wolopts = wol->wolopts;
......
...@@ -1568,9 +1568,8 @@ static int stmmac_mac_device_setup(struct net_device *dev) ...@@ -1568,9 +1568,8 @@ static int stmmac_mac_device_setup(struct net_device *dev)
priv->hw = device; priv->hw = device;
priv->wolenabled = priv->hw->pmt; /* PMT supported */ if (device_can_wakeup(priv->device))
if (priv->wolenabled == PMT_SUPPORTED) priv->wolopts = WAKE_MAGIC; /* Magic Frame as default */
priv->wolopts = WAKE_MAGIC; /* Magic Frame */
return 0; return 0;
} }
...@@ -1709,6 +1708,12 @@ static int stmmac_dvr_probe(struct platform_device *pdev) ...@@ -1709,6 +1708,12 @@ static int stmmac_dvr_probe(struct platform_device *pdev)
priv->enh_desc = plat_dat->enh_desc; priv->enh_desc = plat_dat->enh_desc;
priv->ioaddr = addr; priv->ioaddr = addr;
/* PMT module is not integrated in all the MAC devices. */
if (plat_dat->pmt) {
pr_info("\tPMT module supported\n");
device_set_wakeup_capable(&pdev->dev, 1);
}
platform_set_drvdata(pdev, ndev); platform_set_drvdata(pdev, ndev);
/* Set the I/O base addr */ /* Set the I/O base addr */
...@@ -1836,13 +1841,11 @@ static int stmmac_suspend(struct platform_device *pdev, pm_message_t state) ...@@ -1836,13 +1841,11 @@ static int stmmac_suspend(struct platform_device *pdev, pm_message_t state)
stmmac_mac_disable_tx(priv->ioaddr); stmmac_mac_disable_tx(priv->ioaddr);
if (device_may_wakeup(&(pdev->dev))) { /* Enable Power down mode by programming the PMT regs */
/* Enable Power down mode by programming the PMT regs */ if (device_can_wakeup(priv->device))
if (priv->wolenabled == PMT_SUPPORTED) priv->hw->mac->pmt(priv->ioaddr, priv->wolopts);
priv->hw->mac->pmt(priv->ioaddr, priv->wolopts); else
} else {
stmmac_mac_disable_rx(priv->ioaddr); stmmac_mac_disable_rx(priv->ioaddr);
}
} else { } else {
priv->shutdown = 1; priv->shutdown = 1;
/* Although this can appear slightly redundant it actually /* Although this can appear slightly redundant it actually
...@@ -1877,9 +1880,8 @@ static int stmmac_resume(struct platform_device *pdev) ...@@ -1877,9 +1880,8 @@ static int stmmac_resume(struct platform_device *pdev)
* is received. Anyway, it's better to manually clear * is received. Anyway, it's better to manually clear
* this bit because it can generate problems while resuming * this bit because it can generate problems while resuming
* from another devices (e.g. serial console). */ * from another devices (e.g. serial console). */
if (device_may_wakeup(&(pdev->dev))) if (device_can_wakeup(priv->device))
if (priv->wolenabled == PMT_SUPPORTED) priv->hw->mac->pmt(priv->ioaddr, 0);
priv->hw->mac->pmt(priv->ioaddr, 0);
netif_device_attach(dev); netif_device_attach(dev);
......
...@@ -37,6 +37,7 @@ struct plat_stmmacenet_data { ...@@ -37,6 +37,7 @@ struct plat_stmmacenet_data {
int enh_desc; int enh_desc;
int tx_coe; int tx_coe;
int bugged_jumbo; int bugged_jumbo;
int pmt;
void (*fix_mac_speed)(void *priv, unsigned int speed); void (*fix_mac_speed)(void *priv, unsigned int speed);
void (*bus_setup)(void __iomem *ioaddr); void (*bus_setup)(void __iomem *ioaddr);
#ifdef CONFIG_STM_DRIVERS #ifdef CONFIG_STM_DRIVERS
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment