Staging: rtl8187se: convert to net_device_ops
[pandora-kernel.git] / drivers / staging / rtl8187se / r8180_pm.c
1 /*
2    Power management interface routines.
3    Written by Mariusz Matuszek.
4    This code is currently just a placeholder for later work and
5    does not do anything useful.
6
7    This is part of rtl8180 OpenSource driver.
8    Copyright (C) Andrea Merello 2004  <andreamrl@tiscali.it>
9    Released under the terms of GPL (General Public Licence)
10 */
11
12 #ifdef CONFIG_RTL8180_PM
13
14
15 #include "r8180_hw.h"
16 #include "r8180_pm.h"
17 #include "r8180.h"
18
19 int rtl8180_save_state (struct pci_dev *dev, u32 state)
20 {
21         printk(KERN_NOTICE "r8180 save state call (state %u).\n", state);
22         return(-EAGAIN);
23 }
24
25 int rtl8180_suspend (struct pci_dev *pdev, pm_message_t state)
26 {
27         struct net_device *dev = pci_get_drvdata(pdev);
28 //      struct r8180_priv *priv = ieee80211_priv(dev);
29
30         if (!netif_running(dev))
31                 goto out_pci_suspend;
32
33         if (dev->netdev_ops->ndo_stop)
34                 dev->netdev_ops->ndo_stop(dev);
35
36         netif_device_detach(dev);
37
38 out_pci_suspend:
39         pci_save_state(pdev);
40         pci_disable_device(pdev);
41         pci_set_power_state(pdev,pci_choose_state(pdev,state));
42         return 0;
43 }
44
45 int rtl8180_resume (struct pci_dev *pdev)
46 {
47         struct net_device *dev = pci_get_drvdata(pdev);
48 //      struct r8180_priv *priv = ieee80211_priv(dev);
49         int err;
50         u32 val;
51
52         pci_set_power_state(pdev, PCI_D0);
53
54         err = pci_enable_device(pdev);
55         if(err) {
56                 printk(KERN_ERR "%s: pci_enable_device failed on resume\n",
57                                 dev->name);
58
59                 return err;
60         }
61         pci_restore_state(pdev);
62         /*
63          * Suspend/Resume resets the PCI configuration space, so we have to
64          * re-disable the RETRY_TIMEOUT register (0x41) to keep PCI Tx retries
65          * from interfering with C3 CPU state. pci_restore_state won't help
66          * here since it only restores the first 64 bytes pci config header.
67          */
68         pci_read_config_dword(pdev, 0x40, &val);
69         if ((val & 0x0000ff00) != 0)
70                 pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);
71
72         if(!netif_running(dev))
73                 goto out;
74
75         if (dev->netdev_ops->ndo_open)
76                 dev->netdev_ops->ndo_open(dev);
77         netif_device_attach(dev);
78 out:
79         return 0;
80 }
81
82
83 int rtl8180_enable_wake (struct pci_dev *dev, u32 state, int enable)
84 {
85         printk(KERN_NOTICE "r8180 enable wake call (state %u, enable %d).\n",
86                state, enable);
87         return(-EAGAIN);
88 }
89
90
91
92 #endif //CONFIG_RTL8180_PM