From patchwork Fri Oct 29 04:57:20 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Arce, Abraham" X-Patchwork-Id: 69555 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 44E24B70DF for ; Fri, 29 Oct 2010 15:57:34 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751887Ab0J2E5a (ORCPT ); Fri, 29 Oct 2010 00:57:30 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:46328 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751078Ab0J2E53 convert rfc822-to-8bit (ORCPT ); Fri, 29 Oct 2010 00:57:29 -0400 Received: from dlep35.itg.ti.com ([157.170.170.118]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id o9T4vTq7008703 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 28 Oct 2010 23:57:29 -0500 Received: from dlep26.itg.ti.com (localhost [127.0.0.1]) by dlep35.itg.ti.com (8.13.7/8.13.7) with ESMTP id o9T4vPEx029966 for ; Thu, 28 Oct 2010 23:57:26 -0500 (CDT) Received: from dlee73.ent.ti.com (localhost [127.0.0.1]) by dlep26.itg.ti.com (8.13.8/8.13.8) with ESMTP id o9T4vL2u011825 for ; Thu, 28 Oct 2010 23:57:21 -0500 (CDT) Received: from dlee03.ent.ti.com ([157.170.170.18]) by dlee73.ent.ti.com ([157.170.170.88]) with mapi; Thu, 28 Oct 2010 23:57:21 -0500 From: "Arce, Abraham" To: "netdev@vger.kernel.org" Date: Thu, 28 Oct 2010 23:57:20 -0500 Subject: [PATCH] ks8851: suspend resume support Thread-Topic: [PATCH] ks8851: suspend resume support Thread-Index: Act3JcRWcWcCHZoKQj+CqzXARJFVWw== Message-ID: <27F9C60D11D683428E133F85D2BB4A530468882D59@dlee03.ent.ti.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add suspend/resume support using default open/stop interface methods to do hardware dependant operations. On suspend, same low power state (soft power mode) will be kept, the following blocks will be disabled: - Internal PLL Clock - Tx/Rx PHY - MAC - SPI Interface Signed-off-by: Abraham Arce --- drivers/net/ks8851.c | 33 +++++++++++++++++++++++++++++++++ 1 files changed, 33 insertions(+), 0 deletions(-) diff --git a/drivers/net/ks8851.c b/drivers/net/ks8851.c index 8a178bc..9d40e33 100644 --- a/drivers/net/ks8851.c +++ b/drivers/net/ks8851.c @@ -1570,6 +1570,37 @@ static int ks8851_read_selftest(struct ks8851_net *ks) /* driver bus management functions */ +#ifdef CONFIG_PM +static int ks8851_suspend(struct spi_device *spi, pm_message_t state) +{ + struct ks8851_net *ks = dev_get_drvdata(&spi->dev); + struct net_device *dev = ks->netdev; + + if (netif_running(dev)) { + netif_device_detach(dev); + ks8851_net_stop(dev); + } + + return 0; +} + +static int ks8851_resume(struct spi_device *spi) +{ + struct ks8851_net *ks = dev_get_drvdata(&spi->dev); + struct net_device *dev = ks->netdev; + + if (netif_running(dev)) { + ks8851_net_open(dev); + netif_device_attach(dev); + } + + return 0; +} +#else +#define ks8851_suspend NULL +#define ks8851_resume NULL +#endif + static int __devinit ks8851_probe(struct spi_device *spi) { struct net_device *ndev; @@ -1710,6 +1741,8 @@ static struct spi_driver ks8851_driver = { }, .probe = ks8851_probe, .remove = __devexit_p(ks8851_remove), + .suspend = ks8851_suspend, + .resume = ks8851_resume, }; static int __init ks8851_init(void)