3851b936835680cb827581e551798377f2c460a1
[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         dev->stop(dev);
34
35         netif_device_detach(dev);
36
37 out_pci_suspend:
38         pci_save_state(pdev);
39         pci_disable_device(pdev);
40         pci_set_power_state(pdev,pci_choose_state(pdev,state));
41         return 0;
42 }
43
44 int rtl8180_resume (struct pci_dev *pdev)
45 {
46         struct net_device *dev = pci_get_drvdata(pdev);
47 //      struct r8180_priv *priv = ieee80211_priv(dev);
48         int err;
49         u32 val;
50
51         pci_set_power_state(pdev, PCI_D0);
52
53         err = pci_enable_device(pdev);
54         if(err) {
55                 printk(KERN_ERR "%s: pci_enable_device failed on resume\n",
56                                 dev->name);
57
58                 return err;
59         }
60         pci_restore_state(pdev);
61         /*
62          * Suspend/Resume resets the PCI configuration space, so we have to
63          * re-disable the RETRY_TIMEOUT register (0x41) to keep PCI Tx retries
64          * from interfering with C3 CPU state. pci_restore_state won't help
65          * here since it only restores the first 64 bytes pci config header.
66          */
67         pci_read_config_dword(pdev, 0x40, &val);
68         if ((val & 0x0000ff00) != 0)
69                 pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);
70
71         if(!netif_running(dev))
72                 goto out;
73
74         dev->open(dev);
75         netif_device_attach(dev);
76 out:
77         return 0;
78 }
79
80
81 int rtl8180_enable_wake (struct pci_dev *dev, u32 state, int enable)
82 {
83         printk(KERN_NOTICE "r8180 enable wake call (state %u, enable %d).\n",
84                state, enable);
85         return(-EAGAIN);
86 }
87
88
89
90 #endif //CONFIG_RTL8180_PM