1 From 671e062837669b6d4a5e75d7d08ff485a7510e80 Mon Sep 17 00:00:00 2001
2 From: Ivo van Doorn <IvDoorn@gmail.com>
3 Date: Sat, 8 Aug 2009 23:42:51 +0200
4 Subject: [PATCH 1/3] 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 Based on original patch from Felix.
12 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
13 Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
15 drivers/net/wireless/rt2x00/Kconfig | 4 +
16 drivers/net/wireless/rt2x00/Makefile | 1 +
17 drivers/net/wireless/rt2x00/rt2x00soc.c | 159 +++++++++++++++++++++++++++++++
18 drivers/net/wireless/rt2x00/rt2x00soc.h | 52 ++++++++++
19 4 files changed, 216 insertions(+), 0 deletions(-)
20 create mode 100644 drivers/net/wireless/rt2x00/rt2x00soc.c
21 create mode 100644 drivers/net/wireless/rt2x00/rt2x00soc.h
23 --- a/drivers/net/wireless/rt2x00/Makefile
24 +++ b/drivers/net/wireless/rt2x00/Makefile
25 @@ -11,6 +11,7 @@ rt2x00lib-$(CONFIG_RT2X00_LIB_HT) += rt2
27 obj-$(CONFIG_RT2X00_LIB) += rt2x00lib.o
28 obj-$(CONFIG_RT2X00_LIB_PCI) += rt2x00pci.o
29 +obj-$(CONFIG_RT2X00_LIB_SOC) += rt2x00soc.o
30 obj-$(CONFIG_RT2X00_LIB_USB) += rt2x00usb.o
31 obj-$(CONFIG_RT2400PCI) += rt2400pci.o
32 obj-$(CONFIG_RT2500PCI) += rt2500pci.o
34 +++ b/drivers/net/wireless/rt2x00/rt2x00soc.c
37 + Copyright (C) 2004 - 2009 rt2x00 SourceForge Project
38 + <http://rt2x00.serialmonkey.com>
40 + This program is free software; you can redistribute it and/or modify
41 + it under the terms of the GNU General Public License as published by
42 + the Free Software Foundation; either version 2 of the License, or
43 + (at your option) any later version.
45 + This program is distributed in the hope that it will be useful,
46 + but WITHOUT ANY WARRANTY; without even the implied warranty of
47 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48 + GNU General Public License for more details.
50 + You should have received a copy of the GNU General Public License
51 + along with this program; if not, write to the
52 + Free Software Foundation, Inc.,
53 + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
58 + Abstract: rt2x00 generic soc device routines.
61 +#include <linux/bug.h>
62 +#include <linux/kernel.h>
63 +#include <linux/module.h>
64 +#include <linux/platform_device.h>
67 +#include "rt2x00soc.h"
69 +static void rt2x00soc_free_reg(struct rt2x00_dev *rt2x00dev)
71 + kfree(rt2x00dev->rf);
72 + rt2x00dev->rf = NULL;
74 + kfree(rt2x00dev->eeprom);
75 + rt2x00dev->eeprom = NULL;
78 +static int rt2x00soc_alloc_reg(struct rt2x00_dev *rt2x00dev)
80 + struct platform_device *pdev = to_platform_device(rt2x00dev->dev);
81 + struct resource *res;
83 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
87 + rt2x00dev->csr.base = (void __iomem *)KSEG1ADDR(res->start);
88 + if (!rt2x00dev->csr.base)
91 + rt2x00dev->eeprom = kzalloc(rt2x00dev->ops->eeprom_size, GFP_KERNEL);
92 + if (!rt2x00dev->eeprom)
95 + rt2x00dev->rf = kzalloc(rt2x00dev->ops->rf_size, GFP_KERNEL);
102 + ERROR_PROBE("Failed to allocate registers.\n");
103 + rt2x00soc_free_reg(rt2x00dev);
108 +int rt2x00soc_probe(struct platform_device *pdev,
109 + const unsigned short chipset,
110 + const struct rt2x00_ops *ops)
112 + struct ieee80211_hw *hw;
113 + struct rt2x00_dev *rt2x00dev;
116 + hw = ieee80211_alloc_hw(sizeof(struct rt2x00_dev), ops->hw);
118 + ERROR_PROBE("Failed to allocate hardware.\n");
122 + platform_set_drvdata(pdev, hw);
124 + rt2x00dev = hw->priv;
125 + rt2x00dev->dev = &pdev->dev;
126 + rt2x00dev->ops = ops;
127 + rt2x00dev->hw = hw;
128 + rt2x00dev->irq = platform_get_irq(pdev, 0);
129 + rt2x00dev->name = pdev->dev.driver->name;
131 + rt2x00_set_chip_rt(rt2x00dev, chipset);
133 + retval = rt2x00soc_alloc_reg(rt2x00dev);
135 + goto exit_free_device;
137 + retval = rt2x00lib_probe_dev(rt2x00dev);
139 + goto exit_free_reg;
144 + rt2x00soc_free_reg(rt2x00dev);
147 + ieee80211_free_hw(hw);
152 +int rt2x00soc_remove(struct platform_device *pdev)
154 + struct ieee80211_hw *hw = platform_get_drvdata(pdev);
155 + struct rt2x00_dev *rt2x00dev = hw->priv;
158 + * Free all allocated data.
160 + rt2x00lib_remove_dev(rt2x00dev);
161 + rt2x00soc_free_reg(rt2x00dev);
162 + ieee80211_free_hw(hw);
166 +EXPORT_SYMBOL_GPL(rt2x00soc_remove);
169 +int rt2x00soc_suspend(struct platform_device *pdev, pm_message_t state)
171 + struct ieee80211_hw *hw = platform_get_drvdata(pdev);
172 + struct rt2x00_dev *rt2x00dev = hw->priv;
174 + return rt2x00lib_suspend(rt2x00dev, state);
176 +EXPORT_SYMBOL_GPL(rt2x00soc_suspend);
178 +int rt2x00soc_resume(struct platform_device *pdev)
180 + struct ieee80211_hw *hw = platform_get_drvdata(pdev);
181 + struct rt2x00_dev *rt2x00dev = hw->priv;
183 + return rt2x00lib_resume(rt2x00dev);
185 +EXPORT_SYMBOL_GPL(rt2x00soc_resume);
186 +#endif /* CONFIG_PM */
189 + * rt2x00soc module information.
191 +MODULE_AUTHOR(DRV_PROJECT);
192 +MODULE_VERSION(DRV_VERSION);
193 +MODULE_DESCRIPTION("rt2x00 soc library");
194 +MODULE_LICENSE("GPL");
196 +++ b/drivers/net/wireless/rt2x00/rt2x00soc.h
199 + Copyright (C) 2004 - 2009 rt2x00 SourceForge Project
200 + <http://rt2x00.serialmonkey.com>
202 + This program is free software; you can redistribute it and/or modify
203 + it under the terms of the GNU General Public License as published by
204 + the Free Software Foundation; either version 2 of the License, or
205 + (at your option) any later version.
207 + This program is distributed in the hope that it will be useful,
208 + but WITHOUT ANY WARRANTY; without even the implied warranty of
209 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
210 + GNU General Public License for more details.
212 + You should have received a copy of the GNU General Public License
213 + along with this program; if not, write to the
214 + Free Software Foundation, Inc.,
215 + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
220 + Abstract: Data structures for the rt2x00soc module.
226 +#define KSEG1ADDR(__ptr) __ptr
228 +#define __rt2x00soc_probe(__chipset, __ops) \
229 +static int __rt2x00soc_probe(struct platform_device *pdev) \
231 + return rt2x00soc_probe(pdev, (__chipset), (__ops)); \
235 + * SoC driver handlers.
237 +int rt2x00soc_probe(struct platform_device *pdev,
238 + const unsigned short chipset,
239 + const struct rt2x00_ops *ops);
240 +int rt2x00soc_remove(struct platform_device *pdev);
242 +int rt2x00soc_suspend(struct platform_device *pdev, pm_message_t state);
243 +int rt2x00soc_resume(struct platform_device *pdev);
245 +#define rt2x00soc_suspend NULL
246 +#define rt2x00soc_resume NULL
247 +#endif /* CONFIG_PM */
249 +#endif /* RT2X00SOC_H */