Commit bc057e03 authored by Guo-Fu Tseng's avatar Guo-Fu Tseng Committed by David S. Miller

jme: Cleanup PM operations after using new PM API

	1. Using enum name instead of numeric value.
	2. device_set_wakeup_enable expect bool argument
	   adding !!() to the argument to be passed.
	3. Remove non-jme-hardware related operations from
	   jme_clear_pm()
	4. Reuse jme_clear_pm() in jme_resume() and jme_powersave_phy()
Signed-off-by: default avatarGuo-Fu Tseng <cooldavid@cooldavid.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent aab6fb82
...@@ -271,9 +271,7 @@ jme_reset_mac_processor(struct jme_adapter *jme) ...@@ -271,9 +271,7 @@ jme_reset_mac_processor(struct jme_adapter *jme)
static inline void static inline void
jme_clear_pm(struct jme_adapter *jme) jme_clear_pm(struct jme_adapter *jme)
{ {
jwrite32(jme, JME_PMCS, 0xFFFF0000 | jme->reg_pmcs); jwrite32(jme, JME_PMCS, PMCS_STMASK | jme->reg_pmcs);
pci_set_power_state(jme->pdev, PCI_D0);
device_set_wakeup_enable(&jme->pdev->dev, false);
} }
static int static int
...@@ -1817,11 +1815,9 @@ jme_powersave_phy(struct jme_adapter *jme) ...@@ -1817,11 +1815,9 @@ jme_powersave_phy(struct jme_adapter *jme)
{ {
if (jme->reg_pmcs) { if (jme->reg_pmcs) {
jme_set_100m_half(jme); jme_set_100m_half(jme);
if (jme->reg_pmcs & (PMCS_LFEN | PMCS_LREN)) if (jme->reg_pmcs & (PMCS_LFEN | PMCS_LREN))
jme_wait_link(jme); jme_wait_link(jme);
jme_clear_pm(jme);
jwrite32(jme, JME_PMCS, jme->reg_pmcs);
} else { } else {
jme_phy_off(jme); jme_phy_off(jme);
} }
...@@ -2529,8 +2525,7 @@ jme_set_wol(struct net_device *netdev, ...@@ -2529,8 +2525,7 @@ jme_set_wol(struct net_device *netdev,
jme->reg_pmcs |= PMCS_MFEN; jme->reg_pmcs |= PMCS_MFEN;
jwrite32(jme, JME_PMCS, jme->reg_pmcs); jwrite32(jme, JME_PMCS, jme->reg_pmcs);
device_set_wakeup_enable(&jme->pdev->dev, !!(jme->reg_pmcs));
device_set_wakeup_enable(&jme->pdev->dev, jme->reg_pmcs);
return 0; return 0;
} }
...@@ -3058,6 +3053,9 @@ jme_init_one(struct pci_dev *pdev, ...@@ -3058,6 +3053,9 @@ jme_init_one(struct pci_dev *pdev,
jme->mii_if.mdio_write = jme_mdio_write; jme->mii_if.mdio_write = jme_mdio_write;
jme_clear_pm(jme); jme_clear_pm(jme);
pci_set_power_state(jme->pdev, PCI_D0);
device_set_wakeup_enable(&pdev->dev, true);
jme_set_phyfifo_5level(jme); jme_set_phyfifo_5level(jme);
jme->pcirev = pdev->revision; jme->pcirev = pdev->revision;
if (!jme->fpgaver) if (!jme->fpgaver)
...@@ -3136,7 +3134,8 @@ jme_shutdown(struct pci_dev *pdev) ...@@ -3136,7 +3134,8 @@ jme_shutdown(struct pci_dev *pdev)
} }
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
static int jme_suspend(struct device *dev) static int
jme_suspend(struct device *dev)
{ {
struct pci_dev *pdev = to_pci_dev(dev); struct pci_dev *pdev = to_pci_dev(dev);
struct net_device *netdev = pci_get_drvdata(pdev); struct net_device *netdev = pci_get_drvdata(pdev);
...@@ -3175,14 +3174,14 @@ static int jme_suspend(struct device *dev) ...@@ -3175,14 +3174,14 @@ static int jme_suspend(struct device *dev)
return 0; return 0;
} }
static int jme_resume(struct device *dev) static int
jme_resume(struct device *dev)
{ {
struct pci_dev *pdev = to_pci_dev(dev); struct pci_dev *pdev = to_pci_dev(dev);
struct net_device *netdev = pci_get_drvdata(pdev); struct net_device *netdev = pci_get_drvdata(pdev);
struct jme_adapter *jme = netdev_priv(netdev); struct jme_adapter *jme = netdev_priv(netdev);
jwrite32(jme, JME_PMCS, 0xFFFF0000 | jme->reg_pmcs); jme_clear_pm(jme);
jme_phy_on(jme); jme_phy_on(jme);
if (test_bit(JME_FLAG_SSET, &jme->flags)) if (test_bit(JME_FLAG_SSET, &jme->flags))
jme_set_settings(netdev, &jme->old_ecmd); jme_set_settings(netdev, &jme->old_ecmd);
......
...@@ -852,6 +852,7 @@ enum jme_ghc_txmac_clk { ...@@ -852,6 +852,7 @@ enum jme_ghc_txmac_clk {
* Power management control and status register * Power management control and status register
*/ */
enum jme_pmcs_bit_masks { enum jme_pmcs_bit_masks {
PMCS_STMASK = 0xFFFF0000,
PMCS_WF7DET = 0x80000000, PMCS_WF7DET = 0x80000000,
PMCS_WF6DET = 0x40000000, PMCS_WF6DET = 0x40000000,
PMCS_WF5DET = 0x20000000, PMCS_WF5DET = 0x20000000,
...@@ -863,6 +864,7 @@ enum jme_pmcs_bit_masks { ...@@ -863,6 +864,7 @@ enum jme_pmcs_bit_masks {
PMCS_LFDET = 0x00040000, PMCS_LFDET = 0x00040000,
PMCS_LRDET = 0x00020000, PMCS_LRDET = 0x00020000,
PMCS_MFDET = 0x00010000, PMCS_MFDET = 0x00010000,
PMCS_ENMASK = 0x0000FFFF,
PMCS_WF7EN = 0x00008000, PMCS_WF7EN = 0x00008000,
PMCS_WF6EN = 0x00004000, PMCS_WF6EN = 0x00004000,
PMCS_WF5EN = 0x00002000, PMCS_WF5EN = 0x00002000,
......
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