aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ssb/pcihost_wrapper.c
diff options
context:
space:
mode:
authorMichael Buesch <mb@bu3sch.de>2007-09-18 15:12:50 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:51:36 -0400
commit61e115a56d1aafd6e6a8a9fee8ac099a6128ac7b (patch)
treeadd97bf6a1207a4caea3a86cf13495ad3dc477de /drivers/ssb/pcihost_wrapper.c
parent5ee3afba88f5a79d0bff07ddd87af45919259f91 (diff)
[SSB]: add Sonics Silicon Backplane bus support
SSB is an SoC bus used in a number of embedded devices. The most well-known of these devices is probably the Linksys WRT54G, but there are others as well. The bus is also used internally on the BCM43xx and BCM44xx devices from Broadcom. This patch also includes support for SSB ID tables in modules, so that SSB drivers can be loaded automatically. Signed-off-by: Michael Buesch <mb@bu3sch.de> Signed-off-by: John W. Linville <linville@tuxdriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/ssb/pcihost_wrapper.c')
-rw-r--r--drivers/ssb/pcihost_wrapper.c104
1 files changed, 104 insertions, 0 deletions
diff --git a/drivers/ssb/pcihost_wrapper.c b/drivers/ssb/pcihost_wrapper.c
new file mode 100644
index 000000000000..82a10abef640
--- /dev/null
+++ b/drivers/ssb/pcihost_wrapper.c
@@ -0,0 +1,104 @@
1/*
2 * Sonics Silicon Backplane
3 * PCI Hostdevice wrapper
4 *
5 * Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>
6 * Copyright (c) 2005 Stefano Brivio <st3@riseup.net>
7 * Copyright (c) 2005 Danny van Dyk <kugelfang@gentoo.org>
8 * Copyright (c) 2005 Andreas Jaggi <andreas.jaggi@waterwave.ch>
9 * Copyright (c) 2005-2007 Michael Buesch <mbuesch@freenet.de>
10 *
11 * Licensed under the GNU/GPL. See COPYING for details.
12 */
13
14#include <linux/pci.h>
15#include <linux/ssb/ssb.h>
16
17
18#ifdef CONFIG_PM
19static int ssb_pcihost_suspend(struct pci_dev *dev, pm_message_t state)
20{
21 pci_save_state(dev);
22 pci_disable_device(dev);
23 pci_set_power_state(dev, pci_choose_state(dev, state));
24
25 return 0;
26}
27
28static int ssb_pcihost_resume(struct pci_dev *dev)
29{
30 int err;
31
32 pci_set_power_state(dev, 0);
33 err = pci_enable_device(dev);
34 if (err)
35 return err;
36 pci_restore_state(dev);
37
38 return 0;
39}
40#else /* CONFIG_PM */
41# define ssb_pcihost_suspend NULL
42# define ssb_pcihost_resume NULL
43#endif /* CONFIG_PM */
44
45static int ssb_pcihost_probe(struct pci_dev *dev,
46 const struct pci_device_id *id)
47{
48 struct ssb_bus *ssb;
49 int err = -ENOMEM;
50 const char *name;
51
52 ssb = kzalloc(sizeof(*ssb), GFP_KERNEL);
53 if (!ssb)
54 goto out;
55 err = pci_enable_device(dev);
56 if (err)
57 goto err_kfree_ssb;
58 name = dev->dev.bus_id;
59 if (dev->driver && dev->driver->name)
60 name = dev->driver->name;
61 err = pci_request_regions(dev, name);
62 if (err)
63 goto err_pci_disable;
64 pci_set_master(dev);
65
66 err = ssb_bus_pcibus_register(ssb, dev);
67 if (err)
68 goto err_pci_release_regions;
69
70 pci_set_drvdata(dev, ssb);
71
72out:
73 return err;
74
75err_pci_release_regions:
76 pci_release_regions(dev);
77err_pci_disable:
78 pci_disable_device(dev);
79err_kfree_ssb:
80 kfree(ssb);
81 return err;
82}
83
84static void ssb_pcihost_remove(struct pci_dev *dev)
85{
86 struct ssb_bus *ssb = pci_get_drvdata(dev);
87
88 ssb_bus_unregister(ssb);
89 pci_release_regions(dev);
90 pci_disable_device(dev);
91 kfree(ssb);
92 pci_set_drvdata(dev, NULL);
93}
94
95int ssb_pcihost_register(struct pci_driver *driver)
96{
97 driver->probe = ssb_pcihost_probe;
98 driver->remove = ssb_pcihost_remove;
99 driver->suspend = ssb_pcihost_suspend;
100 driver->resume = ssb_pcihost_resume;
101
102 return pci_register_driver(driver);
103}
104EXPORT_SYMBOL(ssb_pcihost_register);