diff options
author | Giuseppe Cavallaro <peppe.cavallaro@st.com> | 2010-09-25 00:27:41 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-09-25 00:27:41 -0400 |
commit | 543876c92837a8b208b5c99ec225c1f5a581900e (patch) | |
tree | 7a183a1bc3e8974b994e4bad1861ddd0f33ac7e7 /drivers/net/stmmac | |
parent | 77555ee7228234257957fd54daa0b69178906320 (diff) |
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: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/stmmac')
-rw-r--r-- | drivers/net/stmmac/common.h | 1 | ||||
-rw-r--r-- | drivers/net/stmmac/dwmac1000_core.c | 1 | ||||
-rw-r--r-- | drivers/net/stmmac/dwmac100_core.c | 1 | ||||
-rw-r--r-- | drivers/net/stmmac/stmmac_ethtool.c | 14 | ||||
-rw-r--r-- | drivers/net/stmmac/stmmac_main.c | 26 |
5 files changed, 23 insertions, 20 deletions
diff --git a/drivers/net/stmmac/common.h b/drivers/net/stmmac/common.h index 673ef86a063f..dec7ce40c27a 100644 --- a/drivers/net/stmmac/common.h +++ b/drivers/net/stmmac/common.h | |||
@@ -238,7 +238,6 @@ struct mac_device_info { | |||
238 | struct stmmac_ops *mac; | 238 | struct stmmac_ops *mac; |
239 | struct stmmac_desc_ops *desc; | 239 | struct stmmac_desc_ops *desc; |
240 | struct stmmac_dma_ops *dma; | 240 | struct stmmac_dma_ops *dma; |
241 | unsigned int pmt; /* support Power-Down */ | ||
242 | struct mii_regs mii; /* MII register Addresses */ | 241 | struct mii_regs mii; /* MII register Addresses */ |
243 | struct mac_link link; | 242 | struct mac_link link; |
244 | }; | 243 | }; |
diff --git a/drivers/net/stmmac/dwmac1000_core.c b/drivers/net/stmmac/dwmac1000_core.c index c18c85993179..65667b692024 100644 --- a/drivers/net/stmmac/dwmac1000_core.c +++ b/drivers/net/stmmac/dwmac1000_core.c | |||
@@ -239,7 +239,6 @@ struct mac_device_info *dwmac1000_setup(void __iomem *ioaddr) | |||
239 | mac->mac = &dwmac1000_ops; | 239 | mac->mac = &dwmac1000_ops; |
240 | mac->dma = &dwmac1000_dma_ops; | 240 | mac->dma = &dwmac1000_dma_ops; |
241 | 241 | ||
242 | mac->pmt = PMT_SUPPORTED; | ||
243 | mac->link.port = GMAC_CONTROL_PS; | 242 | mac->link.port = GMAC_CONTROL_PS; |
244 | mac->link.duplex = GMAC_CONTROL_DM; | 243 | mac->link.duplex = GMAC_CONTROL_DM; |
245 | mac->link.speed = GMAC_CONTROL_FES; | 244 | mac->link.speed = GMAC_CONTROL_FES; |
diff --git a/drivers/net/stmmac/dwmac100_core.c b/drivers/net/stmmac/dwmac100_core.c index 58a914b27003..94eeccf3a8a0 100644 --- a/drivers/net/stmmac/dwmac100_core.c +++ b/drivers/net/stmmac/dwmac100_core.c | |||
@@ -193,7 +193,6 @@ struct mac_device_info *dwmac100_setup(void __iomem *ioaddr) | |||
193 | mac->mac = &dwmac100_ops; | 193 | mac->mac = &dwmac100_ops; |
194 | mac->dma = &dwmac100_dma_ops; | 194 | mac->dma = &dwmac100_dma_ops; |
195 | 195 | ||
196 | mac->pmt = PMT_NOT_SUPPORTED; | ||
197 | mac->link.port = MAC_CONTROL_PS; | 196 | mac->link.port = MAC_CONTROL_PS; |
198 | mac->link.duplex = MAC_CONTROL_F; | 197 | mac->link.duplex = MAC_CONTROL_F; |
199 | mac->link.speed = 0; | 198 | mac->link.speed = 0; |
diff --git a/drivers/net/stmmac/stmmac_ethtool.c b/drivers/net/stmmac/stmmac_ethtool.c index b32c16ae55c6..25a7e385f8ec 100644 --- a/drivers/net/stmmac/stmmac_ethtool.c +++ b/drivers/net/stmmac/stmmac_ethtool.c | |||
@@ -322,7 +322,7 @@ static void stmmac_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) | |||
322 | struct stmmac_priv *priv = netdev_priv(dev); | 322 | struct stmmac_priv *priv = netdev_priv(dev); |
323 | 323 | ||
324 | spin_lock_irq(&priv->lock); | 324 | spin_lock_irq(&priv->lock); |
325 | if (priv->wolenabled == PMT_SUPPORTED) { | 325 | if (device_can_wakeup(priv->device)) { |
326 | wol->supported = WAKE_MAGIC; | 326 | wol->supported = WAKE_MAGIC; |
327 | wol->wolopts = priv->wolopts; | 327 | wol->wolopts = priv->wolopts; |
328 | } | 328 | } |
@@ -334,16 +334,20 @@ static int stmmac_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) | |||
334 | struct stmmac_priv *priv = netdev_priv(dev); | 334 | struct stmmac_priv *priv = netdev_priv(dev); |
335 | u32 support = WAKE_MAGIC; | 335 | u32 support = WAKE_MAGIC; |
336 | 336 | ||
337 | if (priv->wolenabled == PMT_NOT_SUPPORTED) | 337 | if (!device_can_wakeup(priv->device)) |
338 | return -EINVAL; | 338 | return -EINVAL; |
339 | 339 | ||
340 | if (wol->wolopts & ~support) | 340 | if (wol->wolopts & ~support) |
341 | return -EINVAL; | 341 | return -EINVAL; |
342 | 342 | ||
343 | if (wol->wolopts == 0) | 343 | if (wol->wolopts) { |
344 | device_set_wakeup_enable(priv->device, 0); | 344 | pr_info("stmmac: wakeup enable\n"); |
345 | else | ||
346 | device_set_wakeup_enable(priv->device, 1); | 345 | device_set_wakeup_enable(priv->device, 1); |
346 | enable_irq_wake(dev->irq); | ||
347 | } else { | ||
348 | device_set_wakeup_enable(priv->device, 0); | ||
349 | disable_irq_wake(dev->irq); | ||
350 | } | ||
347 | 351 | ||
348 | spin_lock_irq(&priv->lock); | 352 | spin_lock_irq(&priv->lock); |
349 | priv->wolopts = wol->wolopts; | 353 | priv->wolopts = wol->wolopts; |
diff --git a/drivers/net/stmmac/stmmac_main.c b/drivers/net/stmmac/stmmac_main.c index a908f7201aae..823b9e6431d5 100644 --- a/drivers/net/stmmac/stmmac_main.c +++ b/drivers/net/stmmac/stmmac_main.c | |||
@@ -1568,9 +1568,8 @@ static int stmmac_mac_device_setup(struct net_device *dev) | |||
1568 | 1568 | ||
1569 | priv->hw = device; | 1569 | priv->hw = device; |
1570 | 1570 | ||
1571 | priv->wolenabled = priv->hw->pmt; /* PMT supported */ | 1571 | if (device_can_wakeup(priv->device)) |
1572 | if (priv->wolenabled == PMT_SUPPORTED) | 1572 | priv->wolopts = WAKE_MAGIC; /* Magic Frame as default */ |
1573 | priv->wolopts = WAKE_MAGIC; /* Magic Frame */ | ||
1574 | 1573 | ||
1575 | return 0; | 1574 | return 0; |
1576 | } | 1575 | } |
@@ -1709,6 +1708,12 @@ static int stmmac_dvr_probe(struct platform_device *pdev) | |||
1709 | priv->enh_desc = plat_dat->enh_desc; | 1708 | priv->enh_desc = plat_dat->enh_desc; |
1710 | priv->ioaddr = addr; | 1709 | priv->ioaddr = addr; |
1711 | 1710 | ||
1711 | /* PMT module is not integrated in all the MAC devices. */ | ||
1712 | if (plat_dat->pmt) { | ||
1713 | pr_info("\tPMT module supported\n"); | ||
1714 | device_set_wakeup_capable(&pdev->dev, 1); | ||
1715 | } | ||
1716 | |||
1712 | platform_set_drvdata(pdev, ndev); | 1717 | platform_set_drvdata(pdev, ndev); |
1713 | 1718 | ||
1714 | /* Set the I/O base addr */ | 1719 | /* Set the I/O base addr */ |
@@ -1836,13 +1841,11 @@ static int stmmac_suspend(struct platform_device *pdev, pm_message_t state) | |||
1836 | 1841 | ||
1837 | stmmac_mac_disable_tx(priv->ioaddr); | 1842 | stmmac_mac_disable_tx(priv->ioaddr); |
1838 | 1843 | ||
1839 | if (device_may_wakeup(&(pdev->dev))) { | 1844 | /* Enable Power down mode by programming the PMT regs */ |
1840 | /* Enable Power down mode by programming the PMT regs */ | 1845 | if (device_can_wakeup(priv->device)) |
1841 | if (priv->wolenabled == PMT_SUPPORTED) | 1846 | priv->hw->mac->pmt(priv->ioaddr, priv->wolopts); |
1842 | priv->hw->mac->pmt(priv->ioaddr, priv->wolopts); | 1847 | else |
1843 | } else { | ||
1844 | stmmac_mac_disable_rx(priv->ioaddr); | 1848 | stmmac_mac_disable_rx(priv->ioaddr); |
1845 | } | ||
1846 | } else { | 1849 | } else { |
1847 | priv->shutdown = 1; | 1850 | priv->shutdown = 1; |
1848 | /* Although this can appear slightly redundant it actually | 1851 | /* Although this can appear slightly redundant it actually |
@@ -1877,9 +1880,8 @@ static int stmmac_resume(struct platform_device *pdev) | |||
1877 | * is received. Anyway, it's better to manually clear | 1880 | * is received. Anyway, it's better to manually clear |
1878 | * this bit because it can generate problems while resuming | 1881 | * this bit because it can generate problems while resuming |
1879 | * from another devices (e.g. serial console). */ | 1882 | * from another devices (e.g. serial console). */ |
1880 | if (device_may_wakeup(&(pdev->dev))) | 1883 | if (device_can_wakeup(priv->device)) |
1881 | if (priv->wolenabled == PMT_SUPPORTED) | 1884 | priv->hw->mac->pmt(priv->ioaddr, 0); |
1882 | priv->hw->mac->pmt(priv->ioaddr, 0); | ||
1883 | 1885 | ||
1884 | netif_device_attach(dev); | 1886 | netif_device_attach(dev); |
1885 | 1887 | ||