ath9k: add a temporary uci option for setting the channel bandwidth
[openwrt.git] / package / mac80211 / patches / 603-rt2x00-introduce-rt2x00eeprom.patch
1 --- /dev/null
2 +++ b/drivers/net/wireless/rt2x00/rt2x00eeprom.c
3 @@ -0,0 +1,98 @@
4 +/*
5 + Copyright (C) 2004 - 2009 Ivo van Doorn <IvDoorn@gmail.com>
6 + Copyright (C) 2004 - 2009 Gertjan van Wingerde <gwingerde@gmail.com>
7 + <http://rt2x00.serialmonkey.com>
8 +
9 + This program is free software; you can redistribute it and/or modify
10 + it under the terms of the GNU General Public License as published by
11 + the Free Software Foundation; either version 2 of the License, or
12 + (at your option) any later version.
13 +
14 + This program is distributed in the hope that it will be useful,
15 + but WITHOUT ANY WARRANTY; without even the implied warranty of
16 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 + GNU General Public License for more details.
18 +
19 + You should have received a copy of the GNU General Public License
20 + along with this program; if not, write to the
21 + Free Software Foundation, Inc.,
22 + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 + */
24 +
25 +/*
26 + Module: rt2x00lib
27 + Abstract: rt2x00 eeprom file loading routines.
28 + */
29 +
30 +#include <linux/kernel.h>
31 +#include <linux/module.h>
32 +
33 +#include "rt2x00.h"
34 +#include "rt2x00lib.h"
35 +
36 +static int rt2x00lib_request_eeprom_file(struct rt2x00_dev *rt2x00dev)
37 +{
38 + const struct firmware *ee;
39 + char *ee_name;
40 + int retval;
41 +
42 + ee_name = rt2x00dev->ops->lib->get_eeprom_file_name(rt2x00dev);
43 + if (!ee_name) {
44 + ERROR(rt2x00dev,
45 + "Invalid EEPROM filename.\n"
46 + "Please file bug report to %s.\n", DRV_PROJECT);
47 + return -EINVAL;
48 + }
49 +
50 + INFO(rt2x00dev, "Loading EEPROM data from '%s'.\n", ee_name);
51 +
52 + retval = request_firmware(&ee, ee_name, rt2x00dev->dev);
53 + if (retval) {
54 + ERROR(rt2x00dev, "Failed to request EEPROM.\n");
55 + return retval;
56 + }
57 +
58 + if (!ee || !ee->size || !ee->data) {
59 + ERROR(rt2x00dev, "Failed to read EEPROM file.\n");
60 + retval = -ENOENT;
61 + goto err_exit;
62 + }
63 +
64 + if (ee->size != rt2x00dev->ops->eeprom_size) {
65 + ERROR(rt2x00dev,
66 + "EEPROM file size is invalid, it should be %d bytes\n",
67 + rt2x00dev->ops->eeprom_size);
68 + retval = -EINVAL;
69 + goto err_release_ee;
70 + }
71 +
72 + rt2x00dev->eeprom_file = ee;
73 + return 0;
74 +
75 +err_release_ee:
76 + release_firmware(ee);
77 +err_exit:
78 + return retval;
79 +}
80 +
81 +int rt2x00lib_load_eeprom_file(struct rt2x00_dev *rt2x00dev)
82 +{
83 + int retval;
84 +
85 + if (!test_bit(REQUIRE_EEPROM_FILE, &rt2x00dev->cap_flags))
86 + return 0;
87 +
88 + if (!rt2x00dev->eeprom_file) {
89 + retval = rt2x00lib_request_eeprom_file(rt2x00dev);
90 + if (retval)
91 + return retval;
92 + }
93 +
94 + return 0;
95 +}
96 +
97 +void rt2x00lib_free_eeprom_file(struct rt2x00_dev *rt2x00dev)
98 +{
99 + release_firmware(rt2x00dev->eeprom_file);
100 + rt2x00dev->eeprom_file = NULL;
101 +}
102 --- a/drivers/net/wireless/rt2x00/rt2x00.h
103 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
104 @@ -538,6 +538,7 @@ struct rt2x00lib_ops {
105 const u8 *data, const size_t len);
106 int (*load_firmware) (struct rt2x00_dev *rt2x00dev,
107 const u8 *data, const size_t len);
108 + char *(*get_eeprom_file_name) (struct rt2x00_dev *rt2x00dev);
109
110 /*
111 * Device initialization/deinitialization handlers.
112 @@ -684,6 +685,7 @@ enum rt2x00_capability_flags {
113 REQUIRE_SW_SEQNO,
114 REQUIRE_HT_TX_DESC,
115 REQUIRE_PS_AUTOWAKE,
116 + REQUIRE_EEPROM_FILE,
117
118 /*
119 * Capabilities
120 @@ -939,6 +941,11 @@ struct rt2x00_dev {
121 const struct firmware *fw;
122
123 /*
124 + * EEPROM image.
125 + */
126 + const struct firmware *eeprom_file;
127 +
128 + /*
129 * FIFO for storing tx status reports between isr and tasklet.
130 */
131 DECLARE_KFIFO_PTR(txstatus_fifo, u32);
132 --- a/drivers/net/wireless/rt2x00/rt2x00lib.h
133 +++ b/drivers/net/wireless/rt2x00/rt2x00lib.h
134 @@ -309,6 +309,22 @@ static inline void rt2x00lib_free_firmwa
135 #endif /* CONFIG_RT2X00_LIB_FIRMWARE */
136
137 /*
138 + * EEPROM file handlers.
139 + */
140 +#ifdef CONFIG_RT2X00_LIB_EEPROM
141 +int rt2x00lib_load_eeprom_file(struct rt2x00_dev *rt2x00dev);
142 +void rt2x00lib_free_eeprom_file(struct rt2x00_dev *rt2x00dev);
143 +#else
144 +static inline int rt2x00lib_load_eeprom_file(struct rt2x00_dev *rt2x00dev)
145 +{
146 + return 0;
147 +}
148 +static inline void rt2x00lib_free_eeprom_file(struct rt2x00_dev *rt2x00dev)
149 +{
150 +}
151 +#endif /* CONFIG_RT2X00_LIB_EEPROM_FILE */
152 +
153 +/*
154 * Debugfs handlers.
155 */
156 #ifdef CONFIG_RT2X00_LIB_DEBUGFS
157 --- a/drivers/net/wireless/rt2x00/Kconfig
158 +++ b/drivers/net/wireless/rt2x00/Kconfig
159 @@ -60,6 +60,7 @@ config RT2800PCI
160 select RT2X00_LIB_PCI if PCI
161 select RT2X00_LIB_SOC if RALINK_RT288X || RALINK_RT305X
162 select RT2X00_LIB_FIRMWARE
163 + select RT2X00_LIB_EEPROM
164 select RT2X00_LIB_CRYPTO
165 select CRC_CCITT
166 select EEPROM_93CX6
167 @@ -204,6 +205,9 @@ config RT2X00_LIB_FIRMWARE
168 config RT2X00_LIB_CRYPTO
169 boolean
170
171 +config RT2X00_LIB_EEPROM
172 + boolean
173 +
174 config RT2X00_LIB_LEDS
175 boolean
176 default y if (RT2X00_LIB=y && LEDS_CLASS=y) || (RT2X00_LIB=m && LEDS_CLASS!=n)
177 --- a/drivers/net/wireless/rt2x00/Makefile
178 +++ b/drivers/net/wireless/rt2x00/Makefile
179 @@ -7,6 +7,7 @@ rt2x00lib-$(CONFIG_RT2X00_LIB_DEBUGFS) +
180 rt2x00lib-$(CONFIG_RT2X00_LIB_CRYPTO) += rt2x00crypto.o
181 rt2x00lib-$(CONFIG_RT2X00_LIB_FIRMWARE) += rt2x00firmware.o
182 rt2x00lib-$(CONFIG_RT2X00_LIB_LEDS) += rt2x00leds.o
183 +rt2x00lib-$(CONFIG_RT2X00_LIB_EEPROM) += rt2x00eeprom.o
184
185 obj-$(CONFIG_RT2X00_LIB) += rt2x00lib.o
186 obj-$(CONFIG_RT2X00_LIB_PCI) += rt2x00pci.o
187 --- a/drivers/net/wireless/rt2x00/rt2800pci.c
188 +++ b/drivers/net/wireless/rt2x00/rt2800pci.c
189 @@ -84,20 +84,10 @@ static void rt2800pci_mcu_status(struct
190 rt2x00pci_register_write(rt2x00dev, H2M_MAILBOX_CID, ~0);
191 }
192
193 -#if defined(CONFIG_RALINK_RT288X) || defined(CONFIG_RALINK_RT305X)
194 static void rt2800pci_read_eeprom_soc(struct rt2x00_dev *rt2x00dev)
195 {
196 - void __iomem *base_addr = ioremap(0x1F040000, EEPROM_SIZE);
197 -
198 - memcpy_fromio(rt2x00dev->eeprom, base_addr, EEPROM_SIZE);
199 -
200 - iounmap(base_addr);
201 + memcpy(rt2x00dev->eeprom, rt2x00dev->eeprom_file->data, EEPROM_SIZE);
202 }
203 -#else
204 -static inline void rt2800pci_read_eeprom_soc(struct rt2x00_dev *rt2x00dev)
205 -{
206 -}
207 -#endif /* CONFIG_RALINK_RT288X || CONFIG_RALINK_RT305X */
208
209 #ifdef CONFIG_PCI
210 static void rt2800pci_eepromregister_read(struct eeprom_93cx6 *eeprom)
211 @@ -315,6 +305,20 @@ static int rt2800pci_write_firmware(stru
212 }
213
214 /*
215 + * EEPROM file functions.
216 + */
217 +static char *rt2800pci_get_eeprom_file_name(struct rt2x00_dev *rt2x00dev)
218 +{
219 + struct rt2x00_platform_data *pdata;
220 +
221 + pdata = rt2x00dev->dev->platform_data;
222 + if (pdata)
223 + return pdata->eeprom_file_name;
224 +
225 + return NULL;
226 +}
227 +
228 +/*
229 * Initialization functions.
230 */
231 static bool rt2800pci_get_entry_state(struct queue_entry *entry)
232 @@ -1057,6 +1061,7 @@ static const struct rt2x00lib_ops rt2800
233 .get_firmware_name = rt2800pci_get_firmware_name,
234 .check_firmware = rt2800_check_firmware,
235 .load_firmware = rt2800_load_firmware,
236 + .get_eeprom_file_name = rt2800pci_get_eeprom_file_name,
237 .initialize = rt2x00pci_initialize,
238 .uninitialize = rt2x00pci_uninitialize,
239 .get_entry_state = rt2800pci_get_entry_state,
240 --- a/drivers/net/wireless/rt2x00/rt2x00dev.c
241 +++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
242 @@ -1122,6 +1122,10 @@ int rt2x00lib_probe_dev(struct rt2x00_de
243 INIT_WORK(&rt2x00dev->intf_work, rt2x00lib_intf_scheduled);
244 INIT_DELAYED_WORK(&rt2x00dev->autowakeup_work, rt2x00lib_autowakeup);
245
246 + retval = rt2x00lib_load_eeprom_file(rt2x00dev);
247 + if (retval)
248 + goto exit;
249 +
250 /*
251 * Let the driver probe the device to detect the capabilities.
252 */
253 @@ -1223,6 +1227,11 @@ void rt2x00lib_remove_dev(struct rt2x00_
254 * Free queue structures.
255 */
256 rt2x00queue_free(rt2x00dev);
257 +
258 + /*
259 + * Free EEPROM image.
260 + */
261 + rt2x00lib_free_eeprom_file(rt2x00dev);
262 }
263 EXPORT_SYMBOL_GPL(rt2x00lib_remove_dev);
264
265 --- a/drivers/net/wireless/rt2x00/rt2x00soc.c
266 +++ b/drivers/net/wireless/rt2x00/rt2x00soc.c
267 @@ -94,6 +94,7 @@ int rt2x00soc_probe(struct platform_devi
268 rt2x00dev->hw = hw;
269 rt2x00dev->irq = platform_get_irq(pdev, 0);
270 rt2x00dev->name = pdev->dev.driver->name;
271 + set_bit(REQUIRE_EEPROM_FILE, &rt2x00dev->cap_flags);
272
273 rt2x00_set_chip_intf(rt2x00dev, RT2X00_CHIP_INTF_SOC);
274
This page took 0.056417 seconds and 5 git commands to generate.