diff options
-rw-r--r-- | drivers/net/smsc911x.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/drivers/net/smsc911x.c b/drivers/net/smsc911x.c index 5113b26fc2d9..9a8528c5bb5e 100644 --- a/drivers/net/smsc911x.c +++ b/drivers/net/smsc911x.c | |||
@@ -2109,12 +2109,58 @@ out_0: | |||
2109 | return retval; | 2109 | return retval; |
2110 | } | 2110 | } |
2111 | 2111 | ||
2112 | #ifdef CONFIG_PM | ||
2113 | /* This implementation assumes the devices remains powered on its VDDVARIO | ||
2114 | * pins during suspend. */ | ||
2115 | |||
2116 | static int smsc911x_suspend(struct platform_device *pdev, pm_message_t state) | ||
2117 | { | ||
2118 | struct net_device *dev = platform_get_drvdata(pdev); | ||
2119 | struct smsc911x_data *pdata = netdev_priv(dev); | ||
2120 | |||
2121 | /* enable wake on LAN, energy detection and the external PME | ||
2122 | * signal. */ | ||
2123 | smsc911x_reg_write(pdata, PMT_CTRL, | ||
2124 | PMT_CTRL_PM_MODE_D1_ | PMT_CTRL_WOL_EN_ | | ||
2125 | PMT_CTRL_ED_EN_ | PMT_CTRL_PME_EN_); | ||
2126 | |||
2127 | return 0; | ||
2128 | } | ||
2129 | |||
2130 | static int smsc911x_resume(struct platform_device *pdev) | ||
2131 | { | ||
2132 | struct net_device *dev = platform_get_drvdata(pdev); | ||
2133 | struct smsc911x_data *pdata = netdev_priv(dev); | ||
2134 | unsigned int to = 100; | ||
2135 | |||
2136 | /* Note 3.11 from the datasheet: | ||
2137 | * "When the LAN9220 is in a power saving state, a write of any | ||
2138 | * data to the BYTE_TEST register will wake-up the device." | ||
2139 | */ | ||
2140 | smsc911x_reg_write(pdata, BYTE_TEST, 0); | ||
2141 | |||
2142 | /* poll the READY bit in PMT_CTRL. Any other access to the device is | ||
2143 | * forbidden while this bit isn't set. Try for 100ms and return -EIO | ||
2144 | * if it failed. */ | ||
2145 | while (!(smsc911x_reg_read(pdata, PMT_CTRL) & PMT_CTRL_READY_) && --to) | ||
2146 | udelay(1000); | ||
2147 | |||
2148 | return (to == 0) ? -EIO : 0; | ||
2149 | } | ||
2150 | |||
2151 | #else | ||
2152 | #define smsc911x_suspend NULL | ||
2153 | #define smsc911x_resume NULL | ||
2154 | #endif | ||
2155 | |||
2112 | static struct platform_driver smsc911x_driver = { | 2156 | static struct platform_driver smsc911x_driver = { |
2113 | .probe = smsc911x_drv_probe, | 2157 | .probe = smsc911x_drv_probe, |
2114 | .remove = smsc911x_drv_remove, | 2158 | .remove = smsc911x_drv_remove, |
2115 | .driver = { | 2159 | .driver = { |
2116 | .name = SMSC_CHIPNAME, | 2160 | .name = SMSC_CHIPNAME, |
2117 | }, | 2161 | }, |
2162 | .suspend = smsc911x_suspend, | ||
2163 | .resume = smsc911x_resume, | ||
2118 | }; | 2164 | }; |
2119 | 2165 | ||
2120 | /* Entry point for loading the module */ | 2166 | /* Entry point for loading the module */ |