[cobalt] add diag.sh to report boot status on the front-led of the machine
[openwrt.git] / package / mac80211 / patches / 301-rt2x00-Add-rt2x00soc-bus-module.patch
1 From ff22aa7443c57f49f9fdaf703aa7035c1b13d7f4 Mon Sep 17 00:00:00 2001
2 From: Ivo van Doorn <IvDoorn@gmail.com>
3 Date: Sun, 26 Apr 2009 15:49:55 +0200
4 Subject: [PATCH 1/4] rt2x00: Add rt2x00soc bus module
5
6 Add new library module for SoC drivers.
7 This is needed to fully support the platform
8 driver part of rt2800pci.
9
10 Based on original patch from Felix.
11
12 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
13 Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
14 ---
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
22
23 --- a/drivers/net/wireless/rt2x00/Makefile
24 +++ b/drivers/net/wireless/rt2x00/Makefile
25 @@ -12,6 +12,7 @@ rt2x00lib-$(CONFIG_RT2X00_LIB_HT) += rt2
26
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
33 --- /dev/null
34 +++ b/drivers/net/wireless/rt2x00/rt2x00soc.c
35 @@ -0,0 +1,159 @@
36 +/*
37 + Copyright (C) 2004 - 2009 rt2x00 SourceForge Project
38 + <http://rt2x00.serialmonkey.com>
39 +
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.
44 +
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.
49 +
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.
54 + */
55 +
56 +/*
57 + Module: rt2x00soc
58 + Abstract: rt2x00 generic soc device routines.
59 + */
60 +
61 +#include <linux/bug.h>
62 +#include <linux/kernel.h>
63 +#include <linux/module.h>
64 +#include <linux/platform_device.h>
65 +
66 +#include "rt2x00.h"
67 +#include "rt2x00soc.h"
68 +
69 +static void rt2x00soc_free_reg(struct rt2x00_dev *rt2x00dev)
70 +{
71 + kfree(rt2x00dev->rf);
72 + rt2x00dev->rf = NULL;
73 +
74 + kfree(rt2x00dev->eeprom);
75 + rt2x00dev->eeprom = NULL;
76 +}
77 +
78 +static int rt2x00soc_alloc_reg(struct rt2x00_dev *rt2x00dev)
79 +{
80 + struct platform_device *pdev = to_platform_device(rt2x00dev->dev);
81 + struct resource *res;
82 +
83 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
84 + if (!res)
85 + return -ENODEV;
86 +
87 + rt2x00dev->csr.base = (void __iomem *)KSEG1ADDR(res->start);
88 + if (!rt2x00dev->csr.base)
89 + goto exit;
90 +
91 + rt2x00dev->eeprom = kzalloc(rt2x00dev->ops->eeprom_size, GFP_KERNEL);
92 + if (!rt2x00dev->eeprom)
93 + goto exit;
94 +
95 + rt2x00dev->rf = kzalloc(rt2x00dev->ops->rf_size, GFP_KERNEL);
96 + if (!rt2x00dev->rf)
97 + goto exit;
98 +
99 + return 0;
100 +
101 +exit:
102 + ERROR_PROBE("Failed to allocate registers.\n");
103 + rt2x00soc_free_reg(rt2x00dev);
104 +
105 + return -ENOMEM;
106 +}
107 +
108 +int rt2x00soc_probe(struct platform_device *pdev,
109 + const unsigned short chipset,
110 + const struct rt2x00_ops *ops)
111 +{
112 + struct ieee80211_hw *hw;
113 + struct rt2x00_dev *rt2x00dev;
114 + int retval;
115 +
116 + hw = ieee80211_alloc_hw(sizeof(struct rt2x00_dev), ops->hw);
117 + if (!hw) {
118 + ERROR_PROBE("Failed to allocate hardware.\n");
119 + return -ENOMEM;
120 + }
121 +
122 + platform_set_drvdata(pdev, hw);
123 +
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;
130 +
131 + rt2x00_set_chip_rt(rt2x00dev, chipset);
132 +
133 + retval = rt2x00soc_alloc_reg(rt2x00dev);
134 + if (retval)
135 + goto exit_free_device;
136 +
137 + retval = rt2x00lib_probe_dev(rt2x00dev);
138 + if (retval)
139 + goto exit_free_reg;
140 +
141 + return 0;
142 +
143 +exit_free_reg:
144 + rt2x00soc_free_reg(rt2x00dev);
145 +
146 +exit_free_device:
147 + ieee80211_free_hw(hw);
148 +
149 + return retval;
150 +}
151 +
152 +int rt2x00soc_remove(struct platform_device *pdev)
153 +{
154 + struct ieee80211_hw *hw = platform_get_drvdata(pdev);
155 + struct rt2x00_dev *rt2x00dev = hw->priv;
156 +
157 + /*
158 + * Free all allocated data.
159 + */
160 + rt2x00lib_remove_dev(rt2x00dev);
161 + rt2x00soc_free_reg(rt2x00dev);
162 + ieee80211_free_hw(hw);
163 +
164 + return 0;
165 +}
166 +EXPORT_SYMBOL_GPL(rt2x00soc_remove);
167 +
168 +#ifdef CONFIG_PM
169 +int rt2x00soc_suspend(struct platform_device *pdev, pm_message_t state)
170 +{
171 + struct ieee80211_hw *hw = platform_get_drvdata(pdev);
172 + struct rt2x00_dev *rt2x00dev = hw->priv;
173 +
174 + return rt2x00lib_suspend(rt2x00dev, state);
175 +}
176 +EXPORT_SYMBOL_GPL(rt2x00soc_suspend);
177 +
178 +int rt2x00soc_resume(struct platform_device *pdev)
179 +{
180 + struct ieee80211_hw *hw = platform_get_drvdata(pdev);
181 + struct rt2x00_dev *rt2x00dev = hw->priv;
182 +
183 + return rt2x00lib_resume(rt2x00dev);
184 +}
185 +EXPORT_SYMBOL_GPL(rt2x00soc_resume);
186 +#endif /* CONFIG_PM */
187 +
188 +/*
189 + * rt2x00soc module information.
190 + */
191 +MODULE_AUTHOR(DRV_PROJECT);
192 +MODULE_VERSION(DRV_VERSION);
193 +MODULE_DESCRIPTION("rt2x00 soc library");
194 +MODULE_LICENSE("GPL");
195 --- /dev/null
196 +++ b/drivers/net/wireless/rt2x00/rt2x00soc.h
197 @@ -0,0 +1,52 @@
198 +/*
199 + Copyright (C) 2004 - 2009 rt2x00 SourceForge Project
200 + <http://rt2x00.serialmonkey.com>
201 +
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.
206 +
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.
211 +
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.
216 + */
217 +
218 +/*
219 + Module: rt2x00soc
220 + Abstract: Data structures for the rt2x00soc module.
221 + */
222 +
223 +#ifndef RT2X00SOC_H
224 +#define RT2X00SOC_H
225 +
226 +#define KSEG1ADDR(__ptr) __ptr
227 +
228 +#define __rt2x00soc_probe(__chipset, __ops) \
229 +static int __rt2x00soc_probe(struct platform_device *pdev) \
230 +{ \
231 + return rt2x00soc_probe(pdev, (__chipset), (__ops)); \
232 +}
233 +
234 +/*
235 + * SoC driver handlers.
236 + */
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);
241 +#ifdef CONFIG_PM
242 +int rt2x00soc_suspend(struct platform_device *pdev, pm_message_t state);
243 +int rt2x00soc_resume(struct platform_device *pdev);
244 +#else
245 +#define rt2x00soc_suspend NULL
246 +#define rt2x00soc_resume NULL
247 +#endif /* CONFIG_PM */
248 +
249 +#endif /* RT2X00SOC_H */
This page took 0.058523 seconds and 5 git commands to generate.