]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
ks8851: suspend resume support
authorArce, Abraham <x0066660@ti.com>
Thu, 28 Oct 2010 18:57:20 +0000 (18:57 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 8 Nov 2010 21:50:06 +0000 (13:50 -0800)
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 <x0066660@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ks8851.c

index 51919fcd50c26e2c0c6b8c23ba393887eca50254..0fa4a9887ba2668e42cd328ad150148af0fd88fb 100644 (file)
@@ -1545,6 +1545,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;
@@ -1679,6 +1710,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)