blob: 43f5b9f5a0b0a5078a1d36c723de318bb62725c9 [file] [log] [blame]
Pavel Roskinb884c872006-04-07 04:10:57 -04001/* orinoco_pci.h
Andrey Borzenkovd14c7c12009-01-25 23:08:43 +03002 *
Pavel Roskinb884c872006-04-07 04:10:57 -04003 * Common code for all Orinoco drivers for PCI devices, including
4 * both native PCI and PCMCIA-to-PCI bridges.
5 *
6 * Copyright (C) 2005, Pavel Roskin.
David Kilroy47445cb2009-02-04 23:05:48 +00007 * See main.c for license.
Pavel Roskinb884c872006-04-07 04:10:57 -04008 */
9
10#ifndef _ORINOCO_PCI_H
11#define _ORINOCO_PCI_H
12
13#include <linux/netdevice.h>
14
15/* Driver specific data */
16struct orinoco_pci_card {
17 void __iomem *bridge_io;
18 void __iomem *attr_io;
19};
20
Pavel Roskin95047dd2006-05-01 02:13:30 -040021#ifdef CONFIG_PM
Pavel Roskinb884c872006-04-07 04:10:57 -040022static int orinoco_pci_suspend(struct pci_dev *pdev, pm_message_t state)
23{
David Kilroya2608362009-06-18 23:21:23 +010024 struct orinoco_private *priv = pci_get_drvdata(pdev);
Pavel Roskinb884c872006-04-07 04:10:57 -040025
David Kilroy6415f7d2009-06-18 23:21:30 +010026 orinoco_down(priv);
David Kilroya2608362009-06-18 23:21:23 +010027 free_irq(pdev->irq, priv);
Pavel Roskinb884c872006-04-07 04:10:57 -040028 pci_save_state(pdev);
29 pci_disable_device(pdev);
30 pci_set_power_state(pdev, PCI_D3hot);
31
32 return 0;
33}
34
35static int orinoco_pci_resume(struct pci_dev *pdev)
36{
David Kilroya2608362009-06-18 23:21:23 +010037 struct orinoco_private *priv = pci_get_drvdata(pdev);
38 struct net_device *dev = priv->ndev;
Pavel Roskinb884c872006-04-07 04:10:57 -040039 int err;
40
Yijing Wang1ca01512013-06-27 20:53:42 +080041 pci_set_power_state(pdev, PCI_D0);
John W. Linville02e0e5e2006-11-07 20:53:48 -050042 err = pci_enable_device(pdev);
43 if (err) {
44 printk(KERN_ERR "%s: pci_enable_device failed on resume\n",
45 dev->name);
46 return err;
47 }
Pavel Roskinb884c872006-04-07 04:10:57 -040048 pci_restore_state(pdev);
49
Thomas Gleixner1fb9df52006-07-01 19:29:39 -070050 err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED,
David Kilroya2608362009-06-18 23:21:23 +010051 dev->name, priv);
Pavel Roskinb884c872006-04-07 04:10:57 -040052 if (err) {
53 printk(KERN_ERR "%s: cannot re-allocate IRQ on resume\n",
54 dev->name);
55 pci_disable_device(pdev);
56 return -EBUSY;
57 }
58
David Kilroy6415f7d2009-06-18 23:21:30 +010059 err = orinoco_up(priv);
Pavel Roskinb884c872006-04-07 04:10:57 -040060
David Kilroy6415f7d2009-06-18 23:21:30 +010061 return err;
Pavel Roskinb884c872006-04-07 04:10:57 -040062}
Pavel Roskin95047dd2006-05-01 02:13:30 -040063#else
64#define orinoco_pci_suspend NULL
65#define orinoco_pci_resume NULL
66#endif
Pavel Roskinb884c872006-04-07 04:10:57 -040067
68#endif /* _ORINOCO_PCI_H */