From patchwork Sun Oct 24 23:14:22 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Guo-Fu Tseng X-Patchwork-Id: 69057 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 17139B70A5 for ; Mon, 25 Oct 2010 10:14:46 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750916Ab0JXXOf (ORCPT ); Sun, 24 Oct 2010 19:14:35 -0400 Received: from cooldavid.org ([114.33.45.68]:44670 "EHLO cooldavid.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750788Ab0JXXOe (ORCPT ); Sun, 24 Oct 2010 19:14:34 -0400 Received: from kh (kh.cooldavid.org [114.33.146.108]) by cooldavid.org (Postfix) with SMTP id EC512F08C; Mon, 25 Oct 2010 07:39:18 +0800 (CST) Received: by kh (sSMTP sendmail emulation); Mon, 25 Oct 2010 07:14:27 +0800 From: "Guo-Fu Tseng" To: "David Miller" Cc: Guo-Fu Tseng , "linux-netdev" , "Ctac" , "Aries Lee" , "Devinchiu" , "Hsiu-Che Chao" , "Ethan Hsiao" Subject: [PATCH v2 net-2.6] jme: Support WoL after shutdown Date: Mon, 25 Oct 2010 07:14:22 +0800 Message-Id: <1287962062-30714-1-git-send-email-cooldavid@cooldavid.org> X-Mailer: git-send-email 1.7.2.2 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Guo-Fu Tseng 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). v2 updates: Removed CONFIG_PM ifdef for jme_set_100m_half and jme_wait_link. It would be nice if it can be applied to net-2.6 along with other patches sent few days ago. If it is not appropriate, please ignore the net-2.6 request, and apply it to net-next-2.6 as previous patch. :) Reported-and-helped-by: Сtac Signed-off-by: Guo-Fu Tseng --- drivers/net/jme.c | 45 ++++++++++++++++++++++++++++++--------------- 1 files changed, 30 insertions(+), 15 deletions(-) diff --git a/drivers/net/jme.c b/drivers/net/jme.c index d7a975e..d85edf3 100644 --- a/drivers/net/jme.c +++ b/drivers/net/jme.c @@ -1623,12 +1623,12 @@ err_out: return rc; } -#ifdef CONFIG_PM static void 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); @@ -1656,7 +1656,6 @@ jme_wait_link(struct jme_adapter *jme) phylink = jme_linkstat_from_phy(jme); } } -#endif static inline void jme_phy_off(struct jme_adapter *jme) @@ -1664,6 +1663,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 +3005,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 +3052,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 +3101,7 @@ static struct pci_driver jme_driver = { .suspend = jme_suspend, .resume = jme_resume, #endif /* CONFIG_PM */ + .shutdown = jme_shutdown, }; static int __init