Commit f906d0f9 authored by Vaibhav Gupta's avatar Vaibhav Gupta Committed by David S. Miller

tulip: dmfe: use generic power management

With legacy PM hooks, it was the responsibility of a driver to manage PCI
states and also the device's power state. The generic approach is to let the
PCI core handle the work.

The legacy suspend() and resume() were making use of
pci_read/write_config_dword() to enable/disable wol. Driver editing
configuration registers of a device is not recommended. Thus replace them
all with device_wakeup_enable/disable().

Compile-tested only.
Signed-off-by: default avatarVaibhav Gupta <vaibhavgupta40@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 39ea5d70
...@@ -2081,14 +2081,11 @@ static const struct pci_device_id dmfe_pci_tbl[] = { ...@@ -2081,14 +2081,11 @@ static const struct pci_device_id dmfe_pci_tbl[] = {
}; };
MODULE_DEVICE_TABLE(pci, dmfe_pci_tbl); MODULE_DEVICE_TABLE(pci, dmfe_pci_tbl);
static int __maybe_unused dmfe_suspend(struct device *dev_d)
#ifdef CONFIG_PM
static int dmfe_suspend(struct pci_dev *pci_dev, pm_message_t state)
{ {
struct net_device *dev = pci_get_drvdata(pci_dev); struct net_device *dev = dev_get_drvdata(dev_d);
struct dmfe_board_info *db = netdev_priv(dev); struct dmfe_board_info *db = netdev_priv(dev);
void __iomem *ioaddr = db->ioaddr; void __iomem *ioaddr = db->ioaddr;
u32 tmp;
/* Disable upper layer interface */ /* Disable upper layer interface */
netif_device_detach(dev); netif_device_detach(dev);
...@@ -2105,63 +2102,35 @@ static int dmfe_suspend(struct pci_dev *pci_dev, pm_message_t state) ...@@ -2105,63 +2102,35 @@ static int dmfe_suspend(struct pci_dev *pci_dev, pm_message_t state)
dmfe_free_rxbuffer(db); dmfe_free_rxbuffer(db);
/* Enable WOL */ /* Enable WOL */
pci_read_config_dword(pci_dev, 0x40, &tmp); device_wakeup_enable(dev_d);
tmp &= ~(DMFE_WOL_LINKCHANGE|DMFE_WOL_MAGICPACKET);
if (db->wol_mode & WAKE_PHY)
tmp |= DMFE_WOL_LINKCHANGE;
if (db->wol_mode & WAKE_MAGIC)
tmp |= DMFE_WOL_MAGICPACKET;
pci_write_config_dword(pci_dev, 0x40, tmp);
pci_enable_wake(pci_dev, PCI_D3hot, 1);
pci_enable_wake(pci_dev, PCI_D3cold, 1);
/* Power down device*/
pci_save_state(pci_dev);
pci_set_power_state(pci_dev, pci_choose_state (pci_dev, state));
return 0; return 0;
} }
static int dmfe_resume(struct pci_dev *pci_dev) static int __maybe_unused dmfe_resume(struct device *dev_d)
{ {
struct net_device *dev = pci_get_drvdata(pci_dev); struct net_device *dev = dev_get_drvdata(dev_d);
u32 tmp;
pci_set_power_state(pci_dev, PCI_D0);
pci_restore_state(pci_dev);
/* Re-initialize DM910X board */ /* Re-initialize DM910X board */
dmfe_init_dm910x(dev); dmfe_init_dm910x(dev);
/* Disable WOL */ /* Disable WOL */
pci_read_config_dword(pci_dev, 0x40, &tmp); device_wakeup_disable(dev_d);
tmp &= ~(DMFE_WOL_LINKCHANGE | DMFE_WOL_MAGICPACKET);
pci_write_config_dword(pci_dev, 0x40, tmp);
pci_enable_wake(pci_dev, PCI_D3hot, 0);
pci_enable_wake(pci_dev, PCI_D3cold, 0);
/* Restart upper layer interface */ /* Restart upper layer interface */
netif_device_attach(dev); netif_device_attach(dev);
return 0; return 0;
} }
#else
#define dmfe_suspend NULL static SIMPLE_DEV_PM_OPS(dmfe_pm_ops, dmfe_suspend, dmfe_resume);
#define dmfe_resume NULL
#endif
static struct pci_driver dmfe_driver = { static struct pci_driver dmfe_driver = {
.name = "dmfe", .name = "dmfe",
.id_table = dmfe_pci_tbl, .id_table = dmfe_pci_tbl,
.probe = dmfe_init_one, .probe = dmfe_init_one,
.remove = dmfe_remove_one, .remove = dmfe_remove_one,
.suspend = dmfe_suspend, .driver.pm = &dmfe_pm_ops,
.resume = dmfe_resume
}; };
MODULE_AUTHOR("Sten Wang, sten_wang@davicom.com.tw"); MODULE_AUTHOR("Sten Wang, sten_wang@davicom.com.tw");
......
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