3 @@ -329,6 +329,7 @@ RT2X00_LIB_FIRMWARE=
11 --- a/drivers/net/wireless/ralink/rt2x00/Kconfig
12 +++ b/drivers/net/wireless/ralink/rt2x00/Kconfig
13 @@ -69,6 +69,7 @@ config RT2800PCI
14 select RT2X00_LIB_MMIO
16 select RT2X00_LIB_FIRMWARE
17 + select RT2X00_LIB_EEPROM
18 select RT2X00_LIB_CRYPTO
20 depends on EEPROM_93CX6
21 @@ -215,6 +216,7 @@ config RT2800SOC
22 select RT2X00_LIB_MMIO
23 select RT2X00_LIB_CRYPTO
24 select RT2X00_LIB_FIRMWARE
25 + select RT2X00_LIB_EEPROM
27 select RT2800_LIB_MMIO
29 @@ -265,6 +267,9 @@ config RT2X00_LIB_FIRMWARE
30 config RT2X00_LIB_CRYPTO
33 +config RT2X00_LIB_EEPROM
36 config RT2X00_LIB_LEDS
38 default y if (RT2X00_LIB=y && LEDS_CLASS=y) || (RT2X00_LIB=m && LEDS_CLASS!=n)
39 --- a/drivers/net/wireless/ralink/rt2x00/Makefile
40 +++ b/drivers/net/wireless/ralink/rt2x00/Makefile
41 @@ -7,6 +7,7 @@ rt2x00lib-$(CPTCFG_RT2X00_LIB_DEBUGFS) +
42 rt2x00lib-$(CPTCFG_RT2X00_LIB_CRYPTO) += rt2x00crypto.o
43 rt2x00lib-$(CPTCFG_RT2X00_LIB_FIRMWARE) += rt2x00firmware.o
44 rt2x00lib-$(CPTCFG_RT2X00_LIB_LEDS) += rt2x00leds.o
45 +rt2x00lib-$(CPTCFG_RT2X00_LIB_EEPROM) += rt2x00eeprom.o
47 obj-$(CPTCFG_RT2X00_LIB) += rt2x00lib.o
48 obj-$(CPTCFG_RT2X00_LIB_MMIO) += rt2x00mmio.o
49 --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.h
50 +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.h
51 @@ -46,6 +46,8 @@ struct rt2800_drv_data {
58 void (*register_read)(struct rt2x00_dev *rt2x00dev,
59 const unsigned int offset, u32 *value);
60 @@ -179,6 +181,15 @@ static inline int rt2800_read_eeprom(str
62 const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
64 + if (rt2x00dev->eeprom_file) {
65 + memcpy(rt2x00dev->eeprom, rt2x00dev->eeprom_file->data,
70 + if (!rt2800ops->read_eeprom)
73 return rt2800ops->read_eeprom(rt2x00dev);
76 --- a/drivers/net/wireless/ralink/rt2x00/rt2800soc.c
77 +++ b/drivers/net/wireless/ralink/rt2x00/rt2800soc.c
78 @@ -102,19 +102,6 @@ static int rt2800soc_set_device_state(st
82 -static int rt2800soc_read_eeprom(struct rt2x00_dev *rt2x00dev)
84 - void __iomem *base_addr = ioremap(0x1F040000, EEPROM_SIZE);
89 - memcpy_fromio(rt2x00dev->eeprom, base_addr, EEPROM_SIZE);
95 /* Firmware functions */
96 static char *rt2800soc_get_firmware_name(struct rt2x00_dev *rt2x00dev)
98 @@ -178,7 +165,6 @@ static const struct rt2800_ops rt2800soc
99 .register_multiread = rt2x00mmio_register_multiread,
100 .register_multiwrite = rt2x00mmio_register_multiwrite,
101 .regbusy_read = rt2x00mmio_regbusy_read,
102 - .read_eeprom = rt2800soc_read_eeprom,
103 .hwcrypt_disabled = rt2800soc_hwcrypt_disabled,
104 .drv_write_firmware = rt2800soc_write_firmware,
105 .drv_init_registers = rt2800mmio_init_registers,
106 --- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h
107 +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
108 @@ -697,6 +697,7 @@ enum rt2x00_capability_flags {
111 REQUIRE_DELAYED_RFKILL,
112 + REQUIRE_EEPROM_FILE,
116 @@ -968,6 +969,11 @@ struct rt2x00_dev {
117 const struct firmware *fw;
122 + const struct firmware *eeprom_file;
125 * FIFO for storing tx status reports between isr and tasklet.
127 DECLARE_KFIFO_PTR(txstatus_fifo, u32);
128 --- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
129 +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
130 @@ -1335,6 +1335,10 @@ int rt2x00lib_probe_dev(struct rt2x00_de
131 INIT_DELAYED_WORK(&rt2x00dev->autowakeup_work, rt2x00lib_autowakeup);
132 INIT_WORK(&rt2x00dev->sleep_work, rt2x00lib_sleep);
134 + retval = rt2x00lib_load_eeprom_file(rt2x00dev);
139 * Let the driver probe the device to detect the capabilities.
141 @@ -1475,6 +1479,11 @@ void rt2x00lib_remove_dev(struct rt2x00_
142 * Free the driver data.
144 kfree(rt2x00dev->drv_data);
147 + * Free EEPROM image.
149 + rt2x00lib_free_eeprom_file(rt2x00dev);
151 EXPORT_SYMBOL_GPL(rt2x00lib_remove_dev);
154 +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c
157 + Copyright (C) 2004 - 2009 Ivo van Doorn <IvDoorn@gmail.com>
158 + Copyright (C) 2004 - 2009 Gertjan van Wingerde <gwingerde@gmail.com>
159 + <http://rt2x00.serialmonkey.com>
161 + This program is free software; you can redistribute it and/or modify
162 + it under the terms of the GNU General Public License as published by
163 + the Free Software Foundation; either version 2 of the License, or
164 + (at your option) any later version.
166 + This program is distributed in the hope that it will be useful,
167 + but WITHOUT ANY WARRANTY; without even the implied warranty of
168 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
169 + GNU General Public License for more details.
171 + You should have received a copy of the GNU General Public License
172 + along with this program; if not, write to the
173 + Free Software Foundation, Inc.,
174 + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
179 + Abstract: rt2x00 eeprom file loading routines.
182 +#include <linux/kernel.h>
183 +#include <linux/module.h>
186 +#include "rt2x00lib.h"
189 +rt2x00lib_get_eeprom_file_name(struct rt2x00_dev *rt2x00dev)
191 + struct rt2x00_platform_data *pdata = rt2x00dev->dev->platform_data;
193 + if (pdata && pdata->eeprom_file_name)
194 + return pdata->eeprom_file_name;
199 +static int rt2x00lib_request_eeprom_file(struct rt2x00_dev *rt2x00dev)
201 + const struct firmware *ee;
202 + const char *ee_name;
205 + ee_name = rt2x00lib_get_eeprom_file_name(rt2x00dev);
207 + rt2x00_err(rt2x00dev,
208 + "Invalid EEPROM filename.\n"
209 + "Please file bug report to %s.\n", DRV_PROJECT);
213 + rt2x00_info(rt2x00dev, "Loading EEPROM data from '%s'.\n", ee_name);
215 + retval = request_firmware(&ee, ee_name, rt2x00dev->dev);
217 + rt2x00_err(rt2x00dev, "Failed to request EEPROM.\n");
221 + if (!ee || !ee->size || !ee->data) {
222 + rt2x00_err(rt2x00dev, "Failed to read EEPROM file.\n");
227 + if (ee->size != rt2x00dev->ops->eeprom_size) {
228 + rt2x00_err(rt2x00dev,
229 + "EEPROM file size is invalid, it should be %d bytes\n",
230 + rt2x00dev->ops->eeprom_size);
232 + goto err_release_ee;
235 + rt2x00dev->eeprom_file = ee;
239 + release_firmware(ee);
244 +int rt2x00lib_load_eeprom_file(struct rt2x00_dev *rt2x00dev)
248 + if (!rt2x00lib_get_eeprom_file_name(rt2x00dev))
251 + set_bit(REQUIRE_EEPROM_FILE, &rt2x00dev->cap_flags);
253 + if (!rt2x00dev->eeprom_file) {
254 + retval = rt2x00lib_request_eeprom_file(rt2x00dev);
262 +void rt2x00lib_free_eeprom_file(struct rt2x00_dev *rt2x00dev)
264 + release_firmware(rt2x00dev->eeprom_file);
265 + rt2x00dev->eeprom_file = NULL;
267 --- a/drivers/net/wireless/ralink/rt2x00/rt2x00lib.h
268 +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00lib.h
269 @@ -320,6 +320,22 @@ static inline void rt2x00lib_free_firmwa
270 #endif /* CPTCFG_RT2X00_LIB_FIRMWARE */
273 + * EEPROM file handlers.
275 +#ifdef CPTCFG_RT2X00_LIB_EEPROM
276 +int rt2x00lib_load_eeprom_file(struct rt2x00_dev *rt2x00dev);
277 +void rt2x00lib_free_eeprom_file(struct rt2x00_dev *rt2x00dev);
279 +static inline int rt2x00lib_load_eeprom_file(struct rt2x00_dev *rt2x00dev)
283 +static inline void rt2x00lib_free_eeprom_file(struct rt2x00_dev *rt2x00dev)
286 +#endif /* CPTCFG_RT2X00_LIB_EEPROM */
291 #ifdef CPTCFG_RT2X00_LIB_DEBUGFS
292 --- a/drivers/net/wireless/ralink/rt2x00/rt2x00soc.c
293 +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00soc.c
294 @@ -92,6 +92,7 @@ int rt2x00soc_probe(struct platform_devi
296 rt2x00dev->irq = platform_get_irq(pdev, 0);
297 rt2x00dev->name = pdev->dev.driver->name;
298 + set_bit(REQUIRE_EEPROM_FILE, &rt2x00dev->cap_flags);
300 rt2x00_set_chip_intf(rt2x00dev, RT2X00_CHIP_INTF_SOC);