2 +++ b/drivers/net/wireless/rt2x00/rt2x00eeprom.c
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>
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.
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.
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.
27 + Abstract: rt2x00 eeprom file loading routines.
30 +#include <linux/kernel.h>
31 +#include <linux/module.h>
34 +#include "rt2x00lib.h"
36 +static int rt2x00lib_request_eeprom_file(struct rt2x00_dev *rt2x00dev)
38 + const struct firmware *ee;
42 + ee_name = rt2x00dev->ops->lib->get_eeprom_file_name(rt2x00dev);
44 + rt2x00_err(rt2x00dev,
45 + "Invalid EEPROM filename.\n"
46 + "Please file bug report to %s.\n", DRV_PROJECT);
50 + rt2x00_info(rt2x00dev, "Loading EEPROM data from '%s'.\n", ee_name);
52 + retval = request_firmware(&ee, ee_name, rt2x00dev->dev);
54 + rt2x00_err(rt2x00dev, "Failed to request EEPROM.\n");
58 + if (!ee || !ee->size || !ee->data) {
59 + rt2x00_err(rt2x00dev, "Failed to read EEPROM file.\n");
64 + if (ee->size != rt2x00dev->ops->eeprom_size) {
65 + rt2x00_err(rt2x00dev,
66 + "EEPROM file size is invalid, it should be %d bytes\n",
67 + rt2x00dev->ops->eeprom_size);
69 + goto err_release_ee;
72 + rt2x00dev->eeprom_file = ee;
76 + release_firmware(ee);
81 +int rt2x00lib_load_eeprom_file(struct rt2x00_dev *rt2x00dev)
85 + if (!test_bit(REQUIRE_EEPROM_FILE, &rt2x00dev->cap_flags))
88 + if (!rt2x00dev->eeprom_file) {
89 + retval = rt2x00lib_request_eeprom_file(rt2x00dev);
97 +void rt2x00lib_free_eeprom_file(struct rt2x00_dev *rt2x00dev)
99 + release_firmware(rt2x00dev->eeprom_file);
100 + rt2x00dev->eeprom_file = NULL;
102 --- a/drivers/net/wireless/rt2x00/rt2x00.h
103 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
104 @@ -550,6 +550,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);
111 * Device initialization/deinitialization handlers.
112 @@ -706,6 +707,7 @@ enum rt2x00_capability_flags {
116 + REQUIRE_EEPROM_FILE,
120 @@ -975,6 +977,11 @@ struct rt2x00_dev {
121 const struct firmware *fw;
126 + const struct firmware *eeprom_file;
129 * FIFO for storing tx status reports between isr and tasklet.
131 DECLARE_KFIFO_PTR(txstatus_fifo, u32);
132 --- a/drivers/net/wireless/rt2x00/rt2x00lib.h
133 +++ b/drivers/net/wireless/rt2x00/rt2x00lib.h
134 @@ -322,6 +322,22 @@ static inline void rt2x00lib_free_firmwa
135 #endif /* CPTCFG_RT2X00_LIB_FIRMWARE */
138 + * EEPROM file handlers.
140 +#ifdef CPTCFG_RT2X00_LIB_EEPROM
141 +int rt2x00lib_load_eeprom_file(struct rt2x00_dev *rt2x00dev);
142 +void rt2x00lib_free_eeprom_file(struct rt2x00_dev *rt2x00dev);
144 +static inline int rt2x00lib_load_eeprom_file(struct rt2x00_dev *rt2x00dev)
148 +static inline void rt2x00lib_free_eeprom_file(struct rt2x00_dev *rt2x00dev)
151 +#endif /* CPTCFG_RT2X00_LIB_EEPROM */
156 #ifdef CPTCFG_RT2X00_LIB_DEBUGFS
157 --- a/drivers/net/wireless/rt2x00/Kconfig
158 +++ b/drivers/net/wireless/rt2x00/Kconfig
159 @@ -69,6 +69,7 @@ config RT2800PCI
160 select RT2X00_LIB_PCI if PCI
161 select RT2X00_LIB_SOC if SOC_RT288X || SOC_RT305X
162 select RT2X00_LIB_FIRMWARE
163 + select RT2X00_LIB_EEPROM
164 select RT2X00_LIB_CRYPTO
166 depends on EEPROM_93CX6
167 @@ -244,6 +245,9 @@ config RT2X00_LIB_FIRMWARE
168 config RT2X00_LIB_CRYPTO
171 +config RT2X00_LIB_EEPROM
174 config RT2X00_LIB_LEDS
175 depends on !BACKPORT_KERNEL_2_6_25
177 --- a/drivers/net/wireless/rt2x00/Makefile
178 +++ b/drivers/net/wireless/rt2x00/Makefile
179 @@ -7,6 +7,7 @@ rt2x00lib-$(CPTCFG_RT2X00_LIB_DEBUGFS) +
180 rt2x00lib-$(CPTCFG_RT2X00_LIB_CRYPTO) += rt2x00crypto.o
181 rt2x00lib-$(CPTCFG_RT2X00_LIB_FIRMWARE) += rt2x00firmware.o
182 rt2x00lib-$(CPTCFG_RT2X00_LIB_LEDS) += rt2x00leds.o
183 +rt2x00lib-$(CPTCFG_RT2X00_LIB_EEPROM) += rt2x00eeprom.o
185 obj-$(CPTCFG_RT2X00_LIB) += rt2x00lib.o
186 obj-$(CPTCFG_RT2X00_LIB_MMIO) += rt2x00mmio.o
187 --- a/drivers/net/wireless/rt2x00/rt2800pci.c
188 +++ b/drivers/net/wireless/rt2x00/rt2800pci.c
189 @@ -90,25 +90,11 @@ static void rt2800pci_mcu_status(struct
190 rt2x00mmio_register_write(rt2x00dev, H2M_MAILBOX_CID, ~0);
193 -#if defined(CONFIG_SOC_RT288X) || defined(CONFIG_SOC_RT305X)
194 static int rt2800pci_read_eeprom_soc(struct rt2x00_dev *rt2x00dev)
196 - void __iomem *base_addr = ioremap(0x1F040000, EEPROM_SIZE);
201 - memcpy_fromio(rt2x00dev->eeprom, base_addr, EEPROM_SIZE);
203 - iounmap(base_addr);
204 + memcpy(rt2x00dev->eeprom, rt2x00dev->eeprom_file->data, EEPROM_SIZE);
208 -static inline int rt2800pci_read_eeprom_soc(struct rt2x00_dev *rt2x00dev)
212 -#endif /* CONFIG_SOC_RT288X || CONFIG_SOC_RT305X */
215 static void rt2800pci_eepromregister_read(struct eeprom_93cx6 *eeprom)
216 @@ -332,6 +318,20 @@ static int rt2800pci_write_firmware(stru
220 + * EEPROM file functions.
222 +static char *rt2800pci_get_eeprom_file_name(struct rt2x00_dev *rt2x00dev)
224 + struct rt2x00_platform_data *pdata;
226 + pdata = rt2x00dev->dev->platform_data;
228 + return pdata->eeprom_file_name;
234 * Initialization functions.
236 static bool rt2800pci_get_entry_state(struct queue_entry *entry)
237 @@ -1160,6 +1160,7 @@ static const struct rt2x00lib_ops rt2800
238 .get_firmware_name = rt2800pci_get_firmware_name,
239 .check_firmware = rt2800_check_firmware,
240 .load_firmware = rt2800_load_firmware,
241 + .get_eeprom_file_name = rt2800pci_get_eeprom_file_name,
242 .initialize = rt2x00mmio_initialize,
243 .uninitialize = rt2x00mmio_uninitialize,
244 .get_entry_state = rt2800pci_get_entry_state,
245 --- a/drivers/net/wireless/rt2x00/rt2x00dev.c
246 +++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
247 @@ -1325,6 +1325,10 @@ int rt2x00lib_probe_dev(struct rt2x00_de
248 INIT_DELAYED_WORK(&rt2x00dev->autowakeup_work, rt2x00lib_autowakeup);
249 INIT_WORK(&rt2x00dev->sleep_work, rt2x00lib_sleep);
251 + retval = rt2x00lib_load_eeprom_file(rt2x00dev);
256 * Let the driver probe the device to detect the capabilities.
258 @@ -1455,6 +1459,11 @@ void rt2x00lib_remove_dev(struct rt2x00_
260 if (rt2x00dev->drv_data)
261 kfree(rt2x00dev->drv_data);
264 + * Free EEPROM image.
266 + rt2x00lib_free_eeprom_file(rt2x00dev);
268 EXPORT_SYMBOL_GPL(rt2x00lib_remove_dev);
270 --- a/drivers/net/wireless/rt2x00/rt2x00soc.c
271 +++ b/drivers/net/wireless/rt2x00/rt2x00soc.c
272 @@ -94,6 +94,7 @@ int rt2x00soc_probe(struct platform_devi
274 rt2x00dev->irq = platform_get_irq(pdev, 0);
275 rt2x00dev->name = pdev->dev.driver->name;
276 + set_bit(REQUIRE_EEPROM_FILE, &rt2x00dev->cap_flags);
278 rt2x00_set_chip_intf(rt2x00dev, RT2X00_CHIP_INTF_SOC);
282 @@ -272,6 +272,7 @@ RT2X00_LIB_FIRMWARE=