1 From 18b2be31a35dc8bd216e60e3c9d8d8e7b2179aed Mon Sep 17 00:00:00 2001
2 From: Ivo van Doorn <IvDoorn@gmail.com>
3 Date: Sat, 28 Mar 2009 20:38:40 +0100
4 Subject: [PATCH 6/9] rt2x00: Add rt2x00soc bus module
6 Add new library module for SoC drivers.
7 This is needed to fully support the platform
8 driver part of rt2800pci.
10 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
11 Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
13 drivers/net/wireless/rt2x00/Kconfig | 4 +
14 drivers/net/wireless/rt2x00/Makefile | 1 +
15 drivers/net/wireless/rt2x00/rt2x00soc.c | 159 +++++++++++++++++++++++++++++++
16 drivers/net/wireless/rt2x00/rt2x00soc.h | 52 ++++++++++
17 4 files changed, 216 insertions(+), 0 deletions(-)
18 create mode 100644 drivers/net/wireless/rt2x00/rt2x00soc.c
19 create mode 100644 drivers/net/wireless/rt2x00/rt2x00soc.h
21 --- a/drivers/net/wireless/rt2x00/Makefile
22 +++ b/drivers/net/wireless/rt2x00/Makefile
23 @@ -12,6 +12,7 @@ rt2x00lib-$(CONFIG_RT2X00_LIB_HT) += rt2
25 obj-$(CONFIG_RT2X00_LIB) += rt2x00lib.o
26 obj-$(CONFIG_RT2X00_LIB_PCI) += rt2x00pci.o
27 +obj-$(CONFIG_RT2X00_LIB_SOC) += rt2x00soc.o
28 obj-$(CONFIG_RT2X00_LIB_USB) += rt2x00usb.o
29 obj-$(CONFIG_RT2400PCI) += rt2400pci.o
30 obj-$(CONFIG_RT2500PCI) += rt2500pci.o
32 +++ b/drivers/net/wireless/rt2x00/rt2x00soc.c
35 + Copyright (C) 2004 - 2009 rt2x00 SourceForge Project
36 + <http://rt2x00.serialmonkey.com>
38 + This program is free software; you can redistribute it and/or modify
39 + it under the terms of the GNU General Public License as published by
40 + the Free Software Foundation; either version 2 of the License, or
41 + (at your option) any later version.
43 + This program is distributed in the hope that it will be useful,
44 + but WITHOUT ANY WARRANTY; without even the implied warranty of
45 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
46 + GNU General Public License for more details.
48 + You should have received a copy of the GNU General Public License
49 + along with this program; if not, write to the
50 + Free Software Foundation, Inc.,
51 + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
56 + Abstract: rt2x00 generic soc device routines.
59 +#include <linux/bug.h>
60 +#include <linux/kernel.h>
61 +#include <linux/module.h>
62 +#include <linux/platform_device.h>
65 +#include "rt2x00soc.h"
67 +static void rt2x00soc_free_reg(struct rt2x00_dev *rt2x00dev)
69 + kfree(rt2x00dev->rf);
70 + rt2x00dev->rf = NULL;
72 + kfree(rt2x00dev->eeprom);
73 + rt2x00dev->eeprom = NULL;
76 +static int rt2x00soc_alloc_reg(struct rt2x00_dev *rt2x00dev)
78 + struct platform_device *pdev = to_platform_device(rt2x00dev->dev);
79 + struct resource *res;
81 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
85 + rt2x00dev->csr.base = (void __iomem *)KSEG1ADDR(res->start);
86 + if (!rt2x00dev->csr.base)
89 + rt2x00dev->eeprom = kzalloc(rt2x00dev->ops->eeprom_size, GFP_KERNEL);
90 + if (!rt2x00dev->eeprom)
93 + rt2x00dev->rf = kzalloc(rt2x00dev->ops->rf_size, GFP_KERNEL);
100 + ERROR_PROBE("Failed to allocate registers.\n");
101 + rt2x00soc_free_reg(rt2x00dev);
106 +int rt2x00soc_probe(struct platform_device *pdev,
107 + const unsigned short chipset,
108 + const struct rt2x00_ops *ops)
110 + struct ieee80211_hw *hw;
111 + struct rt2x00_dev *rt2x00dev;
114 + hw = ieee80211_alloc_hw(sizeof(struct rt2x00_dev), ops->hw);
116 + ERROR_PROBE("Failed to allocate hardware.\n");
120 + platform_set_drvdata(pdev, hw);
122 + rt2x00dev = hw->priv;
123 + rt2x00dev->dev = &pdev->dev;
124 + rt2x00dev->ops = ops;
125 + rt2x00dev->hw = hw;
126 + rt2x00dev->irq = platform_get_irq(pdev, 0);
127 + rt2x00dev->name = pdev->dev.driver->name;
129 + rt2x00_set_chip_rt(rt2x00dev, chipset);
131 + retval = rt2x00soc_alloc_reg(rt2x00dev);
133 + goto exit_free_device;
135 + retval = rt2x00lib_probe_dev(rt2x00dev);
137 + goto exit_free_reg;
142 + rt2x00soc_free_reg(rt2x00dev);
145 + ieee80211_free_hw(hw);
150 +int rt2x00soc_remove(struct platform_device *pdev)
152 + struct ieee80211_hw *hw = platform_get_drvdata(pdev);
153 + struct rt2x00_dev *rt2x00dev = hw->priv;
156 + * Free all allocated data.
158 + rt2x00lib_remove_dev(rt2x00dev);
159 + rt2x00soc_free_reg(rt2x00dev);
160 + ieee80211_free_hw(hw);
164 +EXPORT_SYMBOL_GPL(rt2x00soc_remove);
167 +int rt2x00soc_suspend(struct platform_device *pdev, pm_message_t state)
169 + struct ieee80211_hw *hw = platform_get_drvdata(pdev);
170 + struct rt2x00_dev *rt2x00dev = hw->priv;
172 + return rt2x00lib_suspend(rt2x00dev, state);
174 +EXPORT_SYMBOL_GPL(rt2x00soc_suspend);
176 +int rt2x00soc_resume(struct platform_device *pdev)
178 + struct ieee80211_hw *hw = platform_get_drvdata(pdev);
179 + struct rt2x00_dev *rt2x00dev = hw->priv;
181 + return rt2x00lib_resume(rt2x00dev);
183 +EXPORT_SYMBOL_GPL(rt2x00soc_resume);
184 +#endif /* CONFIG_PM */
187 + * rt2x00soc module information.
189 +MODULE_AUTHOR(DRV_PROJECT);
190 +MODULE_VERSION(DRV_VERSION);
191 +MODULE_DESCRIPTION("rt2x00 soc library");
192 +MODULE_LICENSE("GPL");
194 +++ b/drivers/net/wireless/rt2x00/rt2x00soc.h
197 + Copyright (C) 2004 - 2009 rt2x00 SourceForge Project
198 + <http://rt2x00.serialmonkey.com>
200 + This program is free software; you can redistribute it and/or modify
201 + it under the terms of the GNU General Public License as published by
202 + the Free Software Foundation; either version 2 of the License, or
203 + (at your option) any later version.
205 + This program is distributed in the hope that it will be useful,
206 + but WITHOUT ANY WARRANTY; without even the implied warranty of
207 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
208 + GNU General Public License for more details.
210 + You should have received a copy of the GNU General Public License
211 + along with this program; if not, write to the
212 + Free Software Foundation, Inc.,
213 + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
218 + Abstract: Data structures for the rt2x00soc module.
224 +#define KSEG1ADDR(__ptr) __ptr
226 +#define __rt2x00soc_probe(__chipset, __ops) \
227 +static int __rt2x00soc_probe(struct platform_device *pdev) \
229 + return rt2x00soc_probe(pdev, (__chipset), (__ops)); \
233 + * SoC driver handlers.
235 +int rt2x00soc_probe(struct platform_device *pdev,
236 + const unsigned short chipset,
237 + const struct rt2x00_ops *ops);
238 +int rt2x00soc_remove(struct platform_device *pdev);
240 +int rt2x00soc_suspend(struct platform_device *pdev, pm_message_t state);
241 +int rt2x00soc_resume(struct platform_device *pdev);
243 +#define rt2x00soc_suspend NULL
244 +#define rt2x00soc_resume NULL
245 +#endif /* CONFIG_PM */
247 +#endif /* RT2X00SOC_H */