344a73ddd3e50b98e9167b7301cf6795b9fa7e16
[deliverable/linux.git] / drivers / net / wireless / rt2x00 / rt2800pci.c
1 /*
2 Copyright (C) 2009 - 2010 Ivo van Doorn <IvDoorn@gmail.com>
3 Copyright (C) 2009 Alban Browaeys <prahal@yahoo.com>
4 Copyright (C) 2009 Felix Fietkau <nbd@openwrt.org>
5 Copyright (C) 2009 Luis Correia <luis.f.correia@gmail.com>
6 Copyright (C) 2009 Mattias Nissler <mattias.nissler@gmx.de>
7 Copyright (C) 2009 Mark Asselstine <asselsm@gmail.com>
8 Copyright (C) 2009 Xose Vazquez Perez <xose.vazquez@gmail.com>
9 Copyright (C) 2009 Bart Zolnierkiewicz <bzolnier@gmail.com>
10 <http://rt2x00.serialmonkey.com>
11
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the
24 Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 */
27
28 /*
29 Module: rt2800pci
30 Abstract: rt2800pci device specific routines.
31 Supported chipsets: RT2800E & RT2800ED.
32 */
33
34 #include <linux/delay.h>
35 #include <linux/etherdevice.h>
36 #include <linux/init.h>
37 #include <linux/kernel.h>
38 #include <linux/module.h>
39 #include <linux/pci.h>
40 #include <linux/platform_device.h>
41 #include <linux/eeprom_93cx6.h>
42
43 #include "rt2x00.h"
44 #include "rt2x00mmio.h"
45 #include "rt2x00pci.h"
46 #include "rt2x00soc.h"
47 #include "rt2800lib.h"
48 #include "rt2800mmio.h"
49 #include "rt2800.h"
50 #include "rt2800pci.h"
51
52 /*
53 * Allow hardware encryption to be disabled.
54 */
55 static bool modparam_nohwcrypt = false;
56 module_param_named(nohwcrypt, modparam_nohwcrypt, bool, S_IRUGO);
57 MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption.");
58
59 static bool rt2800pci_hwcrypt_disabled(struct rt2x00_dev *rt2x00dev)
60 {
61 return modparam_nohwcrypt;
62 }
63
64 static void rt2800pci_mcu_status(struct rt2x00_dev *rt2x00dev, const u8 token)
65 {
66 unsigned int i;
67 u32 reg;
68
69 /*
70 * SOC devices don't support MCU requests.
71 */
72 if (rt2x00_is_soc(rt2x00dev))
73 return;
74
75 for (i = 0; i < 200; i++) {
76 rt2x00mmio_register_read(rt2x00dev, H2M_MAILBOX_CID, &reg);
77
78 if ((rt2x00_get_field32(reg, H2M_MAILBOX_CID_CMD0) == token) ||
79 (rt2x00_get_field32(reg, H2M_MAILBOX_CID_CMD1) == token) ||
80 (rt2x00_get_field32(reg, H2M_MAILBOX_CID_CMD2) == token) ||
81 (rt2x00_get_field32(reg, H2M_MAILBOX_CID_CMD3) == token))
82 break;
83
84 udelay(REGISTER_BUSY_DELAY);
85 }
86
87 if (i == 200)
88 rt2x00_err(rt2x00dev, "MCU request failed, no response from hardware\n");
89
90 rt2x00mmio_register_write(rt2x00dev, H2M_MAILBOX_STATUS, ~0);
91 rt2x00mmio_register_write(rt2x00dev, H2M_MAILBOX_CID, ~0);
92 }
93
94 #if defined(CONFIG_SOC_RT288X) || defined(CONFIG_SOC_RT305X)
95 static int rt2800pci_read_eeprom_soc(struct rt2x00_dev *rt2x00dev)
96 {
97 void __iomem *base_addr = ioremap(0x1F040000, EEPROM_SIZE);
98
99 if (!base_addr)
100 return -ENOMEM;
101
102 memcpy_fromio(rt2x00dev->eeprom, base_addr, EEPROM_SIZE);
103
104 iounmap(base_addr);
105 return 0;
106 }
107 #else
108 static inline int rt2800pci_read_eeprom_soc(struct rt2x00_dev *rt2x00dev)
109 {
110 return -ENOMEM;
111 }
112 #endif /* CONFIG_SOC_RT288X || CONFIG_SOC_RT305X */
113
114 #ifdef CONFIG_PCI
115 static void rt2800pci_eepromregister_read(struct eeprom_93cx6 *eeprom)
116 {
117 struct rt2x00_dev *rt2x00dev = eeprom->data;
118 u32 reg;
119
120 rt2x00mmio_register_read(rt2x00dev, E2PROM_CSR, &reg);
121
122 eeprom->reg_data_in = !!rt2x00_get_field32(reg, E2PROM_CSR_DATA_IN);
123 eeprom->reg_data_out = !!rt2x00_get_field32(reg, E2PROM_CSR_DATA_OUT);
124 eeprom->reg_data_clock =
125 !!rt2x00_get_field32(reg, E2PROM_CSR_DATA_CLOCK);
126 eeprom->reg_chip_select =
127 !!rt2x00_get_field32(reg, E2PROM_CSR_CHIP_SELECT);
128 }
129
130 static void rt2800pci_eepromregister_write(struct eeprom_93cx6 *eeprom)
131 {
132 struct rt2x00_dev *rt2x00dev = eeprom->data;
133 u32 reg = 0;
134
135 rt2x00_set_field32(&reg, E2PROM_CSR_DATA_IN, !!eeprom->reg_data_in);
136 rt2x00_set_field32(&reg, E2PROM_CSR_DATA_OUT, !!eeprom->reg_data_out);
137 rt2x00_set_field32(&reg, E2PROM_CSR_DATA_CLOCK,
138 !!eeprom->reg_data_clock);
139 rt2x00_set_field32(&reg, E2PROM_CSR_CHIP_SELECT,
140 !!eeprom->reg_chip_select);
141
142 rt2x00mmio_register_write(rt2x00dev, E2PROM_CSR, reg);
143 }
144
145 static int rt2800pci_read_eeprom_pci(struct rt2x00_dev *rt2x00dev)
146 {
147 struct eeprom_93cx6 eeprom;
148 u32 reg;
149
150 rt2x00mmio_register_read(rt2x00dev, E2PROM_CSR, &reg);
151
152 eeprom.data = rt2x00dev;
153 eeprom.register_read = rt2800pci_eepromregister_read;
154 eeprom.register_write = rt2800pci_eepromregister_write;
155 switch (rt2x00_get_field32(reg, E2PROM_CSR_TYPE))
156 {
157 case 0:
158 eeprom.width = PCI_EEPROM_WIDTH_93C46;
159 break;
160 case 1:
161 eeprom.width = PCI_EEPROM_WIDTH_93C66;
162 break;
163 default:
164 eeprom.width = PCI_EEPROM_WIDTH_93C86;
165 break;
166 }
167 eeprom.reg_data_in = 0;
168 eeprom.reg_data_out = 0;
169 eeprom.reg_data_clock = 0;
170 eeprom.reg_chip_select = 0;
171
172 eeprom_93cx6_multiread(&eeprom, EEPROM_BASE, rt2x00dev->eeprom,
173 EEPROM_SIZE / sizeof(u16));
174
175 return 0;
176 }
177
178 static int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev)
179 {
180 return rt2800_efuse_detect(rt2x00dev);
181 }
182
183 static inline int rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
184 {
185 return rt2800_read_eeprom_efuse(rt2x00dev);
186 }
187 #else
188 static inline int rt2800pci_read_eeprom_pci(struct rt2x00_dev *rt2x00dev)
189 {
190 return -EOPNOTSUPP;
191 }
192
193 static inline int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev)
194 {
195 return 0;
196 }
197
198 static inline int rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
199 {
200 return -EOPNOTSUPP;
201 }
202 #endif /* CONFIG_PCI */
203
204 /*
205 * Firmware functions
206 */
207 static char *rt2800pci_get_firmware_name(struct rt2x00_dev *rt2x00dev)
208 {
209 /*
210 * Chip rt3290 use specific 4KB firmware named rt3290.bin.
211 */
212 if (rt2x00_rt(rt2x00dev, RT3290))
213 return FIRMWARE_RT3290;
214 else
215 return FIRMWARE_RT2860;
216 }
217
218 static int rt2800pci_write_firmware(struct rt2x00_dev *rt2x00dev,
219 const u8 *data, const size_t len)
220 {
221 u32 reg;
222
223 /*
224 * enable Host program ram write selection
225 */
226 reg = 0;
227 rt2x00_set_field32(&reg, PBF_SYS_CTRL_HOST_RAM_WRITE, 1);
228 rt2x00mmio_register_write(rt2x00dev, PBF_SYS_CTRL, reg);
229
230 /*
231 * Write firmware to device.
232 */
233 rt2x00mmio_register_multiwrite(rt2x00dev, FIRMWARE_IMAGE_BASE,
234 data, len);
235
236 rt2x00mmio_register_write(rt2x00dev, PBF_SYS_CTRL, 0x00000);
237 rt2x00mmio_register_write(rt2x00dev, PBF_SYS_CTRL, 0x00001);
238
239 rt2x00mmio_register_write(rt2x00dev, H2M_BBP_AGENT, 0);
240 rt2x00mmio_register_write(rt2x00dev, H2M_MAILBOX_CSR, 0);
241
242 return 0;
243 }
244
245 /*
246 * Device state switch handlers.
247 */
248 static int rt2800pci_enable_radio(struct rt2x00_dev *rt2x00dev)
249 {
250 int retval;
251
252 /* Wait for DMA, ignore error until we initialize queues. */
253 rt2800_wait_wpdma_ready(rt2x00dev);
254
255 if (unlikely(rt2800mmio_init_queues(rt2x00dev)))
256 return -EIO;
257
258 retval = rt2800_enable_radio(rt2x00dev);
259 if (retval)
260 return retval;
261
262 /* After resume MCU_BOOT_SIGNAL will trash these. */
263 rt2x00mmio_register_write(rt2x00dev, H2M_MAILBOX_STATUS, ~0);
264 rt2x00mmio_register_write(rt2x00dev, H2M_MAILBOX_CID, ~0);
265
266 rt2800_mcu_request(rt2x00dev, MCU_SLEEP, TOKEN_RADIO_OFF, 0xff, 0x02);
267 rt2800pci_mcu_status(rt2x00dev, TOKEN_RADIO_OFF);
268
269 rt2800_mcu_request(rt2x00dev, MCU_WAKEUP, TOKEN_WAKEUP, 0, 0);
270 rt2800pci_mcu_status(rt2x00dev, TOKEN_WAKEUP);
271
272 return retval;
273 }
274
275 static void rt2800pci_disable_radio(struct rt2x00_dev *rt2x00dev)
276 {
277 if (rt2x00_is_soc(rt2x00dev)) {
278 rt2800_disable_radio(rt2x00dev);
279 rt2x00mmio_register_write(rt2x00dev, PWR_PIN_CFG, 0);
280 rt2x00mmio_register_write(rt2x00dev, TX_PIN_CFG, 0);
281 }
282 }
283
284 static int rt2800pci_set_state(struct rt2x00_dev *rt2x00dev,
285 enum dev_state state)
286 {
287 if (state == STATE_AWAKE) {
288 rt2800_mcu_request(rt2x00dev, MCU_WAKEUP, TOKEN_WAKEUP,
289 0, 0x02);
290 rt2800pci_mcu_status(rt2x00dev, TOKEN_WAKEUP);
291 } else if (state == STATE_SLEEP) {
292 rt2x00mmio_register_write(rt2x00dev, H2M_MAILBOX_STATUS,
293 0xffffffff);
294 rt2x00mmio_register_write(rt2x00dev, H2M_MAILBOX_CID,
295 0xffffffff);
296 rt2800_mcu_request(rt2x00dev, MCU_SLEEP, TOKEN_SLEEP,
297 0xff, 0x01);
298 }
299
300 return 0;
301 }
302
303 static int rt2800pci_set_device_state(struct rt2x00_dev *rt2x00dev,
304 enum dev_state state)
305 {
306 int retval = 0;
307
308 switch (state) {
309 case STATE_RADIO_ON:
310 retval = rt2800pci_enable_radio(rt2x00dev);
311 break;
312 case STATE_RADIO_OFF:
313 /*
314 * After the radio has been disabled, the device should
315 * be put to sleep for powersaving.
316 */
317 rt2800pci_disable_radio(rt2x00dev);
318 rt2800pci_set_state(rt2x00dev, STATE_SLEEP);
319 break;
320 case STATE_RADIO_IRQ_ON:
321 case STATE_RADIO_IRQ_OFF:
322 rt2800mmio_toggle_irq(rt2x00dev, state);
323 break;
324 case STATE_DEEP_SLEEP:
325 case STATE_SLEEP:
326 case STATE_STANDBY:
327 case STATE_AWAKE:
328 retval = rt2800pci_set_state(rt2x00dev, state);
329 break;
330 default:
331 retval = -ENOTSUPP;
332 break;
333 }
334
335 if (unlikely(retval))
336 rt2x00_err(rt2x00dev, "Device failed to enter state %d (%d)\n",
337 state, retval);
338
339 return retval;
340 }
341
342 /*
343 * Device probe functions.
344 */
345 static int rt2800pci_read_eeprom(struct rt2x00_dev *rt2x00dev)
346 {
347 int retval;
348
349 if (rt2x00_is_soc(rt2x00dev))
350 retval = rt2800pci_read_eeprom_soc(rt2x00dev);
351 else if (rt2800pci_efuse_detect(rt2x00dev))
352 retval = rt2800pci_read_eeprom_efuse(rt2x00dev);
353 else
354 retval = rt2800pci_read_eeprom_pci(rt2x00dev);
355
356 return retval;
357 }
358
359 #ifdef CONFIG_PCI
360 static const struct ieee80211_ops rt2800pci_mac80211_ops = {
361 .tx = rt2x00mac_tx,
362 .start = rt2x00mac_start,
363 .stop = rt2x00mac_stop,
364 .add_interface = rt2x00mac_add_interface,
365 .remove_interface = rt2x00mac_remove_interface,
366 .config = rt2x00mac_config,
367 .configure_filter = rt2x00mac_configure_filter,
368 .set_key = rt2x00mac_set_key,
369 .sw_scan_start = rt2x00mac_sw_scan_start,
370 .sw_scan_complete = rt2x00mac_sw_scan_complete,
371 .get_stats = rt2x00mac_get_stats,
372 .get_tkip_seq = rt2800_get_tkip_seq,
373 .set_rts_threshold = rt2800_set_rts_threshold,
374 .sta_add = rt2x00mac_sta_add,
375 .sta_remove = rt2x00mac_sta_remove,
376 .bss_info_changed = rt2x00mac_bss_info_changed,
377 .conf_tx = rt2800_conf_tx,
378 .get_tsf = rt2800_get_tsf,
379 .rfkill_poll = rt2x00mac_rfkill_poll,
380 .ampdu_action = rt2800_ampdu_action,
381 .flush = rt2x00mac_flush,
382 .get_survey = rt2800_get_survey,
383 .get_ringparam = rt2x00mac_get_ringparam,
384 .tx_frames_pending = rt2x00mac_tx_frames_pending,
385 };
386
387 static const struct rt2800_ops rt2800pci_rt2800_ops = {
388 .register_read = rt2x00mmio_register_read,
389 .register_read_lock = rt2x00mmio_register_read, /* same for PCI */
390 .register_write = rt2x00mmio_register_write,
391 .register_write_lock = rt2x00mmio_register_write, /* same for PCI */
392 .register_multiread = rt2x00mmio_register_multiread,
393 .register_multiwrite = rt2x00mmio_register_multiwrite,
394 .regbusy_read = rt2x00mmio_regbusy_read,
395 .read_eeprom = rt2800pci_read_eeprom,
396 .hwcrypt_disabled = rt2800pci_hwcrypt_disabled,
397 .drv_write_firmware = rt2800pci_write_firmware,
398 .drv_init_registers = rt2800mmio_init_registers,
399 .drv_get_txwi = rt2800mmio_get_txwi,
400 };
401
402 static const struct rt2x00lib_ops rt2800pci_rt2x00_ops = {
403 .irq_handler = rt2800mmio_interrupt,
404 .txstatus_tasklet = rt2800mmio_txstatus_tasklet,
405 .pretbtt_tasklet = rt2800mmio_pretbtt_tasklet,
406 .tbtt_tasklet = rt2800mmio_tbtt_tasklet,
407 .rxdone_tasklet = rt2800mmio_rxdone_tasklet,
408 .autowake_tasklet = rt2800mmio_autowake_tasklet,
409 .probe_hw = rt2800_probe_hw,
410 .get_firmware_name = rt2800pci_get_firmware_name,
411 .check_firmware = rt2800_check_firmware,
412 .load_firmware = rt2800_load_firmware,
413 .initialize = rt2x00mmio_initialize,
414 .uninitialize = rt2x00mmio_uninitialize,
415 .get_entry_state = rt2800mmio_get_entry_state,
416 .clear_entry = rt2800mmio_clear_entry,
417 .set_device_state = rt2800pci_set_device_state,
418 .rfkill_poll = rt2800_rfkill_poll,
419 .link_stats = rt2800_link_stats,
420 .reset_tuner = rt2800_reset_tuner,
421 .link_tuner = rt2800_link_tuner,
422 .gain_calibration = rt2800_gain_calibration,
423 .vco_calibration = rt2800_vco_calibration,
424 .start_queue = rt2800mmio_start_queue,
425 .kick_queue = rt2800mmio_kick_queue,
426 .stop_queue = rt2800mmio_stop_queue,
427 .flush_queue = rt2x00mmio_flush_queue,
428 .write_tx_desc = rt2800mmio_write_tx_desc,
429 .write_tx_data = rt2800_write_tx_data,
430 .write_beacon = rt2800_write_beacon,
431 .clear_beacon = rt2800_clear_beacon,
432 .fill_rxdone = rt2800mmio_fill_rxdone,
433 .config_shared_key = rt2800_config_shared_key,
434 .config_pairwise_key = rt2800_config_pairwise_key,
435 .config_filter = rt2800_config_filter,
436 .config_intf = rt2800_config_intf,
437 .config_erp = rt2800_config_erp,
438 .config_ant = rt2800_config_ant,
439 .config = rt2800_config,
440 .sta_add = rt2800_sta_add,
441 .sta_remove = rt2800_sta_remove,
442 };
443
444 static const struct rt2x00_ops rt2800pci_ops = {
445 .name = KBUILD_MODNAME,
446 .drv_data_size = sizeof(struct rt2800_drv_data),
447 .max_ap_intf = 8,
448 .eeprom_size = EEPROM_SIZE,
449 .rf_size = RF_SIZE,
450 .tx_queues = NUM_TX_QUEUES,
451 .queue_init = rt2800mmio_queue_init,
452 .lib = &rt2800pci_rt2x00_ops,
453 .drv = &rt2800pci_rt2800_ops,
454 .hw = &rt2800pci_mac80211_ops,
455 #ifdef CONFIG_RT2X00_LIB_DEBUGFS
456 .debugfs = &rt2800_rt2x00debug,
457 #endif /* CONFIG_RT2X00_LIB_DEBUGFS */
458 };
459
460 /*
461 * RT2800pci module information.
462 */
463 static DEFINE_PCI_DEVICE_TABLE(rt2800pci_device_table) = {
464 { PCI_DEVICE(0x1814, 0x0601) },
465 { PCI_DEVICE(0x1814, 0x0681) },
466 { PCI_DEVICE(0x1814, 0x0701) },
467 { PCI_DEVICE(0x1814, 0x0781) },
468 { PCI_DEVICE(0x1814, 0x3090) },
469 { PCI_DEVICE(0x1814, 0x3091) },
470 { PCI_DEVICE(0x1814, 0x3092) },
471 { PCI_DEVICE(0x1432, 0x7708) },
472 { PCI_DEVICE(0x1432, 0x7727) },
473 { PCI_DEVICE(0x1432, 0x7728) },
474 { PCI_DEVICE(0x1432, 0x7738) },
475 { PCI_DEVICE(0x1432, 0x7748) },
476 { PCI_DEVICE(0x1432, 0x7758) },
477 { PCI_DEVICE(0x1432, 0x7768) },
478 { PCI_DEVICE(0x1462, 0x891a) },
479 { PCI_DEVICE(0x1a3b, 0x1059) },
480 #ifdef CONFIG_RT2800PCI_RT3290
481 { PCI_DEVICE(0x1814, 0x3290) },
482 #endif
483 #ifdef CONFIG_RT2800PCI_RT33XX
484 { PCI_DEVICE(0x1814, 0x3390) },
485 #endif
486 #ifdef CONFIG_RT2800PCI_RT35XX
487 { PCI_DEVICE(0x1432, 0x7711) },
488 { PCI_DEVICE(0x1432, 0x7722) },
489 { PCI_DEVICE(0x1814, 0x3060) },
490 { PCI_DEVICE(0x1814, 0x3062) },
491 { PCI_DEVICE(0x1814, 0x3562) },
492 { PCI_DEVICE(0x1814, 0x3592) },
493 { PCI_DEVICE(0x1814, 0x3593) },
494 { PCI_DEVICE(0x1814, 0x359f) },
495 #endif
496 #ifdef CONFIG_RT2800PCI_RT53XX
497 { PCI_DEVICE(0x1814, 0x5360) },
498 { PCI_DEVICE(0x1814, 0x5362) },
499 { PCI_DEVICE(0x1814, 0x5390) },
500 { PCI_DEVICE(0x1814, 0x5392) },
501 { PCI_DEVICE(0x1814, 0x539a) },
502 { PCI_DEVICE(0x1814, 0x539b) },
503 { PCI_DEVICE(0x1814, 0x539f) },
504 #endif
505 { 0, }
506 };
507 #endif /* CONFIG_PCI */
508
509 MODULE_AUTHOR(DRV_PROJECT);
510 MODULE_VERSION(DRV_VERSION);
511 MODULE_DESCRIPTION("Ralink RT2800 PCI & PCMCIA Wireless LAN driver.");
512 MODULE_SUPPORTED_DEVICE("Ralink RT2860 PCI & PCMCIA chipset based cards");
513 #ifdef CONFIG_PCI
514 MODULE_FIRMWARE(FIRMWARE_RT2860);
515 MODULE_DEVICE_TABLE(pci, rt2800pci_device_table);
516 #endif /* CONFIG_PCI */
517 MODULE_LICENSE("GPL");
518
519 #if defined(CONFIG_SOC_RT288X) || defined(CONFIG_SOC_RT305X)
520 static const struct ieee80211_ops rt2800soc_mac80211_ops = {
521 .tx = rt2x00mac_tx,
522 .start = rt2x00mac_start,
523 .stop = rt2x00mac_stop,
524 .add_interface = rt2x00mac_add_interface,
525 .remove_interface = rt2x00mac_remove_interface,
526 .config = rt2x00mac_config,
527 .configure_filter = rt2x00mac_configure_filter,
528 .set_key = rt2x00mac_set_key,
529 .sw_scan_start = rt2x00mac_sw_scan_start,
530 .sw_scan_complete = rt2x00mac_sw_scan_complete,
531 .get_stats = rt2x00mac_get_stats,
532 .get_tkip_seq = rt2800_get_tkip_seq,
533 .set_rts_threshold = rt2800_set_rts_threshold,
534 .sta_add = rt2x00mac_sta_add,
535 .sta_remove = rt2x00mac_sta_remove,
536 .bss_info_changed = rt2x00mac_bss_info_changed,
537 .conf_tx = rt2800_conf_tx,
538 .get_tsf = rt2800_get_tsf,
539 .rfkill_poll = rt2x00mac_rfkill_poll,
540 .ampdu_action = rt2800_ampdu_action,
541 .flush = rt2x00mac_flush,
542 .get_survey = rt2800_get_survey,
543 .get_ringparam = rt2x00mac_get_ringparam,
544 .tx_frames_pending = rt2x00mac_tx_frames_pending,
545 };
546
547 static const struct rt2800_ops rt2800soc_rt2800_ops = {
548 .register_read = rt2x00mmio_register_read,
549 .register_read_lock = rt2x00mmio_register_read, /* same for SoCs */
550 .register_write = rt2x00mmio_register_write,
551 .register_write_lock = rt2x00mmio_register_write, /* same for SoCs */
552 .register_multiread = rt2x00mmio_register_multiread,
553 .register_multiwrite = rt2x00mmio_register_multiwrite,
554 .regbusy_read = rt2x00mmio_regbusy_read,
555 .read_eeprom = rt2800pci_read_eeprom,
556 .hwcrypt_disabled = rt2800pci_hwcrypt_disabled,
557 .drv_write_firmware = rt2800pci_write_firmware,
558 .drv_init_registers = rt2800mmio_init_registers,
559 .drv_get_txwi = rt2800mmio_get_txwi,
560 };
561
562 static const struct rt2x00lib_ops rt2800soc_rt2x00_ops = {
563 .irq_handler = rt2800mmio_interrupt,
564 .txstatus_tasklet = rt2800mmio_txstatus_tasklet,
565 .pretbtt_tasklet = rt2800mmio_pretbtt_tasklet,
566 .tbtt_tasklet = rt2800mmio_tbtt_tasklet,
567 .rxdone_tasklet = rt2800mmio_rxdone_tasklet,
568 .autowake_tasklet = rt2800mmio_autowake_tasklet,
569 .probe_hw = rt2800_probe_hw,
570 .get_firmware_name = rt2800pci_get_firmware_name,
571 .check_firmware = rt2800_check_firmware,
572 .load_firmware = rt2800_load_firmware,
573 .initialize = rt2x00mmio_initialize,
574 .uninitialize = rt2x00mmio_uninitialize,
575 .get_entry_state = rt2800mmio_get_entry_state,
576 .clear_entry = rt2800mmio_clear_entry,
577 .set_device_state = rt2800pci_set_device_state,
578 .rfkill_poll = rt2800_rfkill_poll,
579 .link_stats = rt2800_link_stats,
580 .reset_tuner = rt2800_reset_tuner,
581 .link_tuner = rt2800_link_tuner,
582 .gain_calibration = rt2800_gain_calibration,
583 .vco_calibration = rt2800_vco_calibration,
584 .start_queue = rt2800mmio_start_queue,
585 .kick_queue = rt2800mmio_kick_queue,
586 .stop_queue = rt2800mmio_stop_queue,
587 .flush_queue = rt2x00mmio_flush_queue,
588 .write_tx_desc = rt2800mmio_write_tx_desc,
589 .write_tx_data = rt2800_write_tx_data,
590 .write_beacon = rt2800_write_beacon,
591 .clear_beacon = rt2800_clear_beacon,
592 .fill_rxdone = rt2800mmio_fill_rxdone,
593 .config_shared_key = rt2800_config_shared_key,
594 .config_pairwise_key = rt2800_config_pairwise_key,
595 .config_filter = rt2800_config_filter,
596 .config_intf = rt2800_config_intf,
597 .config_erp = rt2800_config_erp,
598 .config_ant = rt2800_config_ant,
599 .config = rt2800_config,
600 .sta_add = rt2800_sta_add,
601 .sta_remove = rt2800_sta_remove,
602 };
603
604 static const struct rt2x00_ops rt2800soc_ops = {
605 .name = KBUILD_MODNAME,
606 .drv_data_size = sizeof(struct rt2800_drv_data),
607 .max_ap_intf = 8,
608 .eeprom_size = EEPROM_SIZE,
609 .rf_size = RF_SIZE,
610 .tx_queues = NUM_TX_QUEUES,
611 .queue_init = rt2800mmio_queue_init,
612 .lib = &rt2800soc_rt2x00_ops,
613 .drv = &rt2800soc_rt2800_ops,
614 .hw = &rt2800soc_mac80211_ops,
615 #ifdef CONFIG_RT2X00_LIB_DEBUGFS
616 .debugfs = &rt2800_rt2x00debug,
617 #endif /* CONFIG_RT2X00_LIB_DEBUGFS */
618 };
619
620 static int rt2800soc_probe(struct platform_device *pdev)
621 {
622 return rt2x00soc_probe(pdev, &rt2800soc_ops);
623 }
624
625 static struct platform_driver rt2800soc_driver = {
626 .driver = {
627 .name = "rt2800_wmac",
628 .owner = THIS_MODULE,
629 .mod_name = KBUILD_MODNAME,
630 },
631 .probe = rt2800soc_probe,
632 .remove = rt2x00soc_remove,
633 .suspend = rt2x00soc_suspend,
634 .resume = rt2x00soc_resume,
635 };
636 #endif /* CONFIG_SOC_RT288X || CONFIG_SOC_RT305X */
637
638 #ifdef CONFIG_PCI
639 static int rt2800pci_probe(struct pci_dev *pci_dev,
640 const struct pci_device_id *id)
641 {
642 return rt2x00pci_probe(pci_dev, &rt2800pci_ops);
643 }
644
645 static struct pci_driver rt2800pci_driver = {
646 .name = KBUILD_MODNAME,
647 .id_table = rt2800pci_device_table,
648 .probe = rt2800pci_probe,
649 .remove = rt2x00pci_remove,
650 .suspend = rt2x00pci_suspend,
651 .resume = rt2x00pci_resume,
652 };
653 #endif /* CONFIG_PCI */
654
655 static int __init rt2800pci_init(void)
656 {
657 int ret = 0;
658
659 #if defined(CONFIG_SOC_RT288X) || defined(CONFIG_SOC_RT305X)
660 ret = platform_driver_register(&rt2800soc_driver);
661 if (ret)
662 return ret;
663 #endif
664 #ifdef CONFIG_PCI
665 ret = pci_register_driver(&rt2800pci_driver);
666 if (ret) {
667 #if defined(CONFIG_SOC_RT288X) || defined(CONFIG_SOC_RT305X)
668 platform_driver_unregister(&rt2800soc_driver);
669 #endif
670 return ret;
671 }
672 #endif
673
674 return ret;
675 }
676
677 static void __exit rt2800pci_exit(void)
678 {
679 #ifdef CONFIG_PCI
680 pci_unregister_driver(&rt2800pci_driver);
681 #endif
682 #if defined(CONFIG_SOC_RT288X) || defined(CONFIG_SOC_RT305X)
683 platform_driver_unregister(&rt2800soc_driver);
684 #endif
685 }
686
687 module_init(rt2800pci_init);
688 module_exit(rt2800pci_exit);
This page took 0.051736 seconds and 4 git commands to generate.