From: "Guo-Fu Tseng" <cooldavid@cooldavid.org>
To: "David Miller" <davem@davemloft.net>
Cc: "Guo-Fu Tseng" <cooldavid@cooldavid.org>,
linux-netdev <netdev@vger.kernel.org>, Сtac <Taoga@yandex.ru>,
"Aries Lee" <arieslee@jmicron.com>,
Devinchiu <devinchiu@jmicron.com>,
"Hsiu-Che Chao" <hcchao@jmicron.com>,
"Ethan Hsiao" <ethanhsiao@jmicron.com>
Subject: [PATCH net-next-2.6] jme: Support WoL after shutdown
Date: Fri, 22 Oct 2010 09:33:40 +0800 [thread overview]
Message-ID: <1287711220-20075-1-git-send-email-cooldavid@cooldavid.org> (raw)
From: Guo-Fu Tseng <cooldavid@cooldavid.org>
Adding shutdown function that setup wake if wol is enabled.
Add jme_phy_on in jme_set_100m_half in case it is shutting down
or suspending when interface is down(phy_off by default).
Reported_and_helped_by: Сtac <Taoga@yandex.ru>
Signed-off-by: Guo-Fu Tseng <cooldavid@cooldavid.org>
---
drivers/net/jme.c | 43 ++++++++++++++++++++++++++++++-------------
1 files changed, 30 insertions(+), 13 deletions(-)
diff --git a/drivers/net/jme.c b/drivers/net/jme.c
index d7a975e..9f5c146 100644
--- a/drivers/net/jme.c
+++ b/drivers/net/jme.c
@@ -1629,6 +1629,7 @@ jme_set_100m_half(struct jme_adapter *jme)
{
u32 bmcr, tmp;
+ jme_phy_on(jme);
bmcr = jme_mdio_read(jme->dev, jme->mii_if.phy_id, MII_BMCR);
tmp = bmcr & ~(BMCR_ANENABLE | BMCR_SPEED100 |
BMCR_SPEED1000 | BMCR_FULLDPLX);
@@ -1664,6 +1665,21 @@ jme_phy_off(struct jme_adapter *jme)
jme_mdio_write(jme->dev, jme->mii_if.phy_id, MII_BMCR, BMCR_PDOWN);
}
+static void
+jme_powersave_phy(struct jme_adapter *jme)
+{
+ if (jme->reg_pmcs) {
+ jme_set_100m_half(jme);
+
+ if (jme->reg_pmcs & (PMCS_LFEN | PMCS_LREN))
+ jme_wait_link(jme);
+
+ jwrite32(jme, JME_PMCS, jme->reg_pmcs);
+ } else {
+ jme_phy_off(jme);
+ }
+}
+
static int
jme_close(struct net_device *netdev)
{
@@ -2991,6 +3007,16 @@ jme_remove_one(struct pci_dev *pdev)
}
+static void
+jme_shutdown(struct pci_dev *pdev)
+{
+ struct net_device *netdev = pci_get_drvdata(pdev);
+ struct jme_adapter *jme = netdev_priv(netdev);
+
+ jme_powersave_phy(jme);
+ pci_pme_active(pdev, true);
+}
+
#ifdef CONFIG_PM
static int
jme_suspend(struct pci_dev *pdev, pm_message_t state)
@@ -3028,19 +3054,9 @@ jme_suspend(struct pci_dev *pdev, pm_message_t state)
tasklet_hi_enable(&jme->rxempty_task);
pci_save_state(pdev);
- if (jme->reg_pmcs) {
- jme_set_100m_half(jme);
-
- if (jme->reg_pmcs & (PMCS_LFEN | PMCS_LREN))
- jme_wait_link(jme);
-
- jwrite32(jme, JME_PMCS, jme->reg_pmcs);
-
- pci_enable_wake(pdev, PCI_D3cold, true);
- } else {
- jme_phy_off(jme);
- }
- pci_set_power_state(pdev, PCI_D3cold);
+ jme_powersave_phy(jme);
+ pci_enable_wake(jme->pdev, PCI_D3hot, true);
+ pci_set_power_state(pdev, PCI_D3hot);
return 0;
}
@@ -3087,6 +3103,7 @@ static struct pci_driver jme_driver = {
.suspend = jme_suspend,
.resume = jme_resume,
#endif /* CONFIG_PM */
+ .shutdown = jme_shutdown,
};
static int __init
--
1.7.2.2
next reply other threads:[~2010-10-22 1:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-22 1:33 Guo-Fu Tseng [this message]
2010-10-24 22:42 ` [PATCH net-next-2.6] jme: Support WoL after shutdown David Miller
2010-10-24 22:51 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1287711220-20075-1-git-send-email-cooldavid@cooldavid.org \
--to=cooldavid@cooldavid.org \
--cc=Taoga@yandex.ru \
--cc=arieslee@jmicron.com \
--cc=davem@davemloft.net \
--cc=devinchiu@jmicron.com \
--cc=ethanhsiao@jmicron.com \
--cc=hcchao@jmicron.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).