aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/wireless/rt2x00/Kconfig4
-rw-r--r--drivers/net/wireless/rt2x00/Makefile1
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00soc.c159
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00soc.h52
4 files changed, 216 insertions, 0 deletions
diff --git a/drivers/net/wireless/rt2x00/Kconfig b/drivers/net/wireless/rt2x00/Kconfig
index ed1f997e3521..e86895ac2d71 100644
--- a/drivers/net/wireless/rt2x00/Kconfig
+++ b/drivers/net/wireless/rt2x00/Kconfig
@@ -95,6 +95,10 @@ config RT2X00_LIB_PCI
95 tristate 95 tristate
96 select RT2X00_LIB 96 select RT2X00_LIB
97 97
98config RT2X00_LIB_SOC
99 tristate
100 select RT2X00_LIB
101
98config RT2X00_LIB_USB 102config RT2X00_LIB_USB
99 tristate 103 tristate
100 select RT2X00_LIB 104 select RT2X00_LIB
diff --git a/drivers/net/wireless/rt2x00/Makefile b/drivers/net/wireless/rt2x00/Makefile
index 13043ea97667..5b1ee4f6b8f3 100644
--- a/drivers/net/wireless/rt2x00/Makefile
+++ b/drivers/net/wireless/rt2x00/Makefile
@@ -11,6 +11,7 @@ rt2x00lib-$(CONFIG_RT2X00_LIB_HT) += rt2x00ht.o
11 11
12obj-$(CONFIG_RT2X00_LIB) += rt2x00lib.o 12obj-$(CONFIG_RT2X00_LIB) += rt2x00lib.o
13obj-$(CONFIG_RT2X00_LIB_PCI) += rt2x00pci.o 13obj-$(CONFIG_RT2X00_LIB_PCI) += rt2x00pci.o
14obj-$(CONFIG_RT2X00_LIB_SOC) += rt2x00soc.o
14obj-$(CONFIG_RT2X00_LIB_USB) += rt2x00usb.o 15obj-$(CONFIG_RT2X00_LIB_USB) += rt2x00usb.o
15obj-$(CONFIG_RT2400PCI) += rt2400pci.o 16obj-$(CONFIG_RT2400PCI) += rt2400pci.o
16obj-$(CONFIG_RT2500PCI) += rt2500pci.o 17obj-$(CONFIG_RT2500PCI) += rt2500pci.o
diff --git a/drivers/net/wireless/rt2x00/rt2x00soc.c b/drivers/net/wireless/rt2x00/rt2x00soc.c
new file mode 100644
index 000000000000..539568c48953
--- /dev/null
+++ b/drivers/net/wireless/rt2x00/rt2x00soc.c
@@ -0,0 +1,159 @@
1/*
2 Copyright (C) 2004 - 2009 rt2x00 SourceForge Project
3 <http://rt2x00.serialmonkey.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the
17 Free Software Foundation, Inc.,
18 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
21/*
22 Module: rt2x00soc
23 Abstract: rt2x00 generic soc device routines.
24 */
25
26#include <linux/bug.h>
27#include <linux/kernel.h>
28#include <linux/module.h>
29#include <linux/platform_device.h>
30
31#include "rt2x00.h"
32#include "rt2x00soc.h"
33
34static void rt2x00soc_free_reg(struct rt2x00_dev *rt2x00dev)
35{
36 kfree(rt2x00dev->rf);
37 rt2x00dev->rf = NULL;
38
39 kfree(rt2x00dev->eeprom);
40 rt2x00dev->eeprom = NULL;
41}
42
43static int rt2x00soc_alloc_reg(struct rt2x00_dev *rt2x00dev)
44{
45 struct platform_device *pdev = to_platform_device(rt2x00dev->dev);
46 struct resource *res;
47
48 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
49 if (!res)
50 return -ENODEV;
51
52 rt2x00dev->csr.base = (void __iomem *)KSEG1ADDR(res->start);
53 if (!rt2x00dev->csr.base)
54 goto exit;
55
56 rt2x00dev->eeprom = kzalloc(rt2x00dev->ops->eeprom_size, GFP_KERNEL);
57 if (!rt2x00dev->eeprom)
58 goto exit;
59
60 rt2x00dev->rf = kzalloc(rt2x00dev->ops->rf_size, GFP_KERNEL);
61 if (!rt2x00dev->rf)
62 goto exit;
63
64 return 0;
65
66exit:
67 ERROR_PROBE("Failed to allocate registers.\n");
68 rt2x00soc_free_reg(rt2x00dev);
69
70 return -ENOMEM;
71}
72
73int rt2x00soc_probe(struct platform_device *pdev,
74 const unsigned short chipset,
75 const struct rt2x00_ops *ops)
76{
77 struct ieee80211_hw *hw;
78 struct rt2x00_dev *rt2x00dev;
79 int retval;
80
81 hw = ieee80211_alloc_hw(sizeof(struct rt2x00_dev), ops->hw);
82 if (!hw) {
83 ERROR_PROBE("Failed to allocate hardware.\n");
84 return -ENOMEM;
85 }
86
87 platform_set_drvdata(pdev, hw);
88
89 rt2x00dev = hw->priv;
90 rt2x00dev->dev = &pdev->dev;
91 rt2x00dev->ops = ops;
92 rt2x00dev->hw = hw;
93 rt2x00dev->irq = platform_get_irq(pdev, 0);
94 rt2x00dev->name = pdev->dev.driver->name;
95
96 rt2x00_set_chip_rt(rt2x00dev, chipset);
97
98 retval = rt2x00soc_alloc_reg(rt2x00dev);
99 if (retval)
100 goto exit_free_device;
101
102 retval = rt2x00lib_probe_dev(rt2x00dev);
103 if (retval)
104 goto exit_free_reg;
105
106 return 0;
107
108exit_free_reg:
109 rt2x00soc_free_reg(rt2x00dev);
110
111exit_free_device:
112 ieee80211_free_hw(hw);
113
114 return retval;
115}
116
117int rt2x00soc_remove(struct platform_device *pdev)
118{
119 struct ieee80211_hw *hw = platform_get_drvdata(pdev);
120 struct rt2x00_dev *rt2x00dev = hw->priv;
121
122 /*
123 * Free all allocated data.
124 */
125 rt2x00lib_remove_dev(rt2x00dev);
126 rt2x00soc_free_reg(rt2x00dev);
127 ieee80211_free_hw(hw);
128
129 return 0;
130}
131EXPORT_SYMBOL_GPL(rt2x00soc_remove);
132
133#ifdef CONFIG_PM
134int rt2x00soc_suspend(struct platform_device *pdev, pm_message_t state)
135{
136 struct ieee80211_hw *hw = platform_get_drvdata(pdev);
137 struct rt2x00_dev *rt2x00dev = hw->priv;
138
139 return rt2x00lib_suspend(rt2x00dev, state);
140}
141EXPORT_SYMBOL_GPL(rt2x00soc_suspend);
142
143int rt2x00soc_resume(struct platform_device *pdev)
144{
145 struct ieee80211_hw *hw = platform_get_drvdata(pdev);
146 struct rt2x00_dev *rt2x00dev = hw->priv;
147
148 return rt2x00lib_resume(rt2x00dev);
149}
150EXPORT_SYMBOL_GPL(rt2x00soc_resume);
151#endif /* CONFIG_PM */
152
153/*
154 * rt2x00soc module information.
155 */
156MODULE_AUTHOR(DRV_PROJECT);
157MODULE_VERSION(DRV_VERSION);
158MODULE_DESCRIPTION("rt2x00 soc library");
159MODULE_LICENSE("GPL");
diff --git a/drivers/net/wireless/rt2x00/rt2x00soc.h b/drivers/net/wireless/rt2x00/rt2x00soc.h
new file mode 100644
index 000000000000..5cf114ac2b9c
--- /dev/null
+++ b/drivers/net/wireless/rt2x00/rt2x00soc.h
@@ -0,0 +1,52 @@
1/*
2 Copyright (C) 2004 - 2009 rt2x00 SourceForge Project
3 <http://rt2x00.serialmonkey.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the
17 Free Software Foundation, Inc.,
18 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
21/*
22 Module: rt2x00soc
23 Abstract: Data structures for the rt2x00soc module.
24 */
25
26#ifndef RT2X00SOC_H
27#define RT2X00SOC_H
28
29#define KSEG1ADDR(__ptr) __ptr
30
31#define __rt2x00soc_probe(__chipset, __ops) \
32static int __rt2x00soc_probe(struct platform_device *pdev) \
33{ \
34 return rt2x00soc_probe(pdev, (__chipset), (__ops)); \
35}
36
37/*
38 * SoC driver handlers.
39 */
40int rt2x00soc_probe(struct platform_device *pdev,
41 const unsigned short chipset,
42 const struct rt2x00_ops *ops);
43int rt2x00soc_remove(struct platform_device *pdev);
44#ifdef CONFIG_PM
45int rt2x00soc_suspend(struct platform_device *pdev, pm_message_t state);
46int rt2x00soc_resume(struct platform_device *pdev);
47#else
48#define rt2x00soc_suspend NULL
49#define rt2x00soc_resume NULL
50#endif /* CONFIG_PM */
51
52#endif /* RT2X00SOC_H */