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);
45 + "Invalid EEPROM filename.\n"
46 + "Please file bug report to %s.\n", DRV_PROJECT);
50 + INFO(rt2x00dev, "Loading EEPROM data from '%s'.\n", ee_name);
52 + retval = request_firmware(&ee, ee_name, rt2x00dev->dev);
54 + ERROR(rt2x00dev, "Failed to request EEPROM.\n");
58 + if (!ee || !ee->size || !ee->data) {
59 + ERROR(rt2x00dev, "Failed to read EEPROM file.\n");
64 + if (ee->size != rt2x00dev->ops->eeprom_size) {
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 @@ -560,6 +560,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 @@ -713,6 +714,7 @@ enum rt2x00_capability_flags {
116 + REQUIRE_EEPROM_FILE,
120 @@ -968,6 +970,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 /* CONFIG_RT2X00_LIB_FIRMWARE */
138 + * EEPROM file handlers.
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);
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 /* CONFIG_RT2X00_LIB_EEPROM_FILE */
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
167 @@ -204,6 +205,9 @@ config RT2X00_LIB_FIRMWARE
168 config RT2X00_LIB_CRYPTO
171 +config RT2X00_LIB_EEPROM
174 config RT2X00_LIB_LEDS
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
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);
193 -#if defined(CONFIG_RALINK_RT288X) || defined(CONFIG_RALINK_RT305X)
194 static void rt2800pci_read_eeprom_soc(struct rt2x00_dev *rt2x00dev)
196 - void __iomem *base_addr = ioremap(0x1F040000, EEPROM_SIZE);
198 - memcpy_fromio(rt2x00dev->eeprom, base_addr, EEPROM_SIZE);
200 - iounmap(base_addr);
201 + memcpy(rt2x00dev->eeprom, rt2x00dev->eeprom_file->data, EEPROM_SIZE);
204 -static inline void rt2800pci_read_eeprom_soc(struct rt2x00_dev *rt2x00dev)
207 -#endif /* CONFIG_RALINK_RT288X || CONFIG_RALINK_RT305X */
210 static void rt2800pci_eepromregister_read(struct eeprom_93cx6 *eeprom)
211 @@ -311,6 +301,20 @@ static int rt2800pci_write_firmware(stru
215 + * EEPROM file functions.
217 +static char *rt2800pci_get_eeprom_file_name(struct rt2x00_dev *rt2x00dev)
219 + struct rt2x00_platform_data *pdata;
221 + pdata = rt2x00dev->dev->platform_data;
223 + return pdata->eeprom_file_name;
229 * Initialization functions.
231 static bool rt2800pci_get_entry_state(struct queue_entry *entry)
232 @@ -1052,6 +1056,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 @@ -1165,6 +1165,10 @@ int rt2x00lib_probe_dev(struct rt2x00_de
243 BIT(NL80211_IFTYPE_MESH_POINT) |
244 BIT(NL80211_IFTYPE_WDS);
246 + retval = rt2x00lib_load_eeprom_file(rt2x00dev);
253 @@ -1288,6 +1292,11 @@ void rt2x00lib_remove_dev(struct rt2x00_
255 if (rt2x00dev->drv_data)
256 kfree(rt2x00dev->drv_data);
259 + * Free EEPROM image.
261 + rt2x00lib_free_eeprom_file(rt2x00dev);
263 EXPORT_SYMBOL_GPL(rt2x00lib_remove_dev);
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
269 rt2x00dev->irq = platform_get_irq(pdev, 0);
270 rt2x00dev->name = pdev->dev.driver->name;
271 + set_bit(REQUIRE_EEPROM_FILE, &rt2x00dev->cap_flags);
273 rt2x00_set_chip_intf(rt2x00dev, RT2X00_CHIP_INTF_SOC);