diff options
author | Gabor Juhos <juhosg@openwrt.org> | 2013-10-17 03:42:34 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2013-10-18 14:07:00 -0400 |
commit | fe7ef7c60c33fd339f40320fae76bc56d368dae5 (patch) | |
tree | ec3d4ccfce6ac49150d3e0560776093fae062791 /drivers/net/wireless | |
parent | 0b0ee990f402b357422cc7c5cc12915490610e3e (diff) |
rt2x00: rt2800pci: move SoC specific code into a separate module
The PCI and SoC specific drivers are using separate
code now so it is not reasonable to use the same
module for both drivers anymore.
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r-- | drivers/net/wireless/rt2x00/Kconfig | 21 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/Makefile | 1 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2800pci.c | 244 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2800soc.c | 263 |
4 files changed, 284 insertions, 245 deletions
diff --git a/drivers/net/wireless/rt2x00/Kconfig b/drivers/net/wireless/rt2x00/Kconfig index e86324931b63..006b8bcb2e31 100644 --- a/drivers/net/wireless/rt2x00/Kconfig +++ b/drivers/net/wireless/rt2x00/Kconfig | |||
@@ -58,12 +58,11 @@ config RT61PCI | |||
58 | 58 | ||
59 | config RT2800PCI | 59 | config RT2800PCI |
60 | tristate "Ralink rt27xx/rt28xx/rt30xx (PCI/PCIe/PCMCIA) support" | 60 | tristate "Ralink rt27xx/rt28xx/rt30xx (PCI/PCIe/PCMCIA) support" |
61 | depends on PCI || SOC_RT288X || SOC_RT305X | 61 | depends on PCI |
62 | select RT2800_LIB | 62 | select RT2800_LIB |
63 | select RT2800_LIB_MMIO | 63 | select RT2800_LIB_MMIO |
64 | select RT2X00_LIB_MMIO | 64 | select RT2X00_LIB_MMIO |
65 | select RT2X00_LIB_PCI if PCI | 65 | select RT2X00_LIB_PCI |
66 | select RT2X00_LIB_SOC if SOC_RT288X || SOC_RT305X | ||
67 | select RT2X00_LIB_FIRMWARE | 66 | select RT2X00_LIB_FIRMWARE |
68 | select RT2X00_LIB_CRYPTO | 67 | select RT2X00_LIB_CRYPTO |
69 | select CRC_CCITT | 68 | select CRC_CCITT |
@@ -200,6 +199,22 @@ config RT2800USB_UNKNOWN | |||
200 | 199 | ||
201 | endif | 200 | endif |
202 | 201 | ||
202 | config RT2800SOC | ||
203 | tristate "Ralink WiSoC support" | ||
204 | depends on SOC_RT288X || SOC_RT305X | ||
205 | select RT2X00_LIB_SOC | ||
206 | select RT2X00_LIB_MMIO | ||
207 | select RT2X00_LIB_CRYPTO | ||
208 | select RT2X00_LIB_FIRMWARE | ||
209 | select RT2800_LIB | ||
210 | select RT2800_LIB_MMIO | ||
211 | ---help--- | ||
212 | This adds support for Ralink WiSoC devices. | ||
213 | Supported chips: RT2880, RT3050, RT3052, RT3350, RT3352. | ||
214 | |||
215 | When compiled as a module, this driver will be called rt2800soc. | ||
216 | |||
217 | |||
203 | config RT2800_LIB | 218 | config RT2800_LIB |
204 | tristate | 219 | tristate |
205 | 220 | ||
diff --git a/drivers/net/wireless/rt2x00/Makefile b/drivers/net/wireless/rt2x00/Makefile index d11e3562ab46..24a66015a495 100644 --- a/drivers/net/wireless/rt2x00/Makefile +++ b/drivers/net/wireless/rt2x00/Makefile | |||
@@ -22,3 +22,4 @@ obj-$(CONFIG_RT2800PCI) += rt2800pci.o | |||
22 | obj-$(CONFIG_RT2500USB) += rt2500usb.o | 22 | obj-$(CONFIG_RT2500USB) += rt2500usb.o |
23 | obj-$(CONFIG_RT73USB) += rt73usb.o | 23 | obj-$(CONFIG_RT73USB) += rt73usb.o |
24 | obj-$(CONFIG_RT2800USB) += rt2800usb.o | 24 | obj-$(CONFIG_RT2800USB) += rt2800usb.o |
25 | obj-$(CONFIG_RT2800SOC) += rt2800soc.o | ||
diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c index 488d1c449349..260d2fdadc76 100644 --- a/drivers/net/wireless/rt2x00/rt2800pci.c +++ b/drivers/net/wireless/rt2x00/rt2800pci.c | |||
@@ -37,13 +37,11 @@ | |||
37 | #include <linux/kernel.h> | 37 | #include <linux/kernel.h> |
38 | #include <linux/module.h> | 38 | #include <linux/module.h> |
39 | #include <linux/pci.h> | 39 | #include <linux/pci.h> |
40 | #include <linux/platform_device.h> | ||
41 | #include <linux/eeprom_93cx6.h> | 40 | #include <linux/eeprom_93cx6.h> |
42 | 41 | ||
43 | #include "rt2x00.h" | 42 | #include "rt2x00.h" |
44 | #include "rt2x00mmio.h" | 43 | #include "rt2x00mmio.h" |
45 | #include "rt2x00pci.h" | 44 | #include "rt2x00pci.h" |
46 | #include "rt2x00soc.h" | ||
47 | #include "rt2800lib.h" | 45 | #include "rt2800lib.h" |
48 | #include "rt2800mmio.h" | 46 | #include "rt2800mmio.h" |
49 | #include "rt2800.h" | 47 | #include "rt2800.h" |
@@ -56,7 +54,6 @@ static bool modparam_nohwcrypt = false; | |||
56 | module_param_named(nohwcrypt, modparam_nohwcrypt, bool, S_IRUGO); | 54 | module_param_named(nohwcrypt, modparam_nohwcrypt, bool, S_IRUGO); |
57 | MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption."); | 55 | MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption."); |
58 | 56 | ||
59 | #ifdef CONFIG_PCI | ||
60 | static bool rt2800pci_hwcrypt_disabled(struct rt2x00_dev *rt2x00dev) | 57 | static bool rt2800pci_hwcrypt_disabled(struct rt2x00_dev *rt2x00dev) |
61 | { | 58 | { |
62 | return modparam_nohwcrypt; | 59 | return modparam_nohwcrypt; |
@@ -449,230 +446,15 @@ static DEFINE_PCI_DEVICE_TABLE(rt2800pci_device_table) = { | |||
449 | #endif | 446 | #endif |
450 | { 0, } | 447 | { 0, } |
451 | }; | 448 | }; |
452 | #endif /* CONFIG_PCI */ | ||
453 | 449 | ||
454 | MODULE_AUTHOR(DRV_PROJECT); | 450 | MODULE_AUTHOR(DRV_PROJECT); |
455 | MODULE_VERSION(DRV_VERSION); | 451 | MODULE_VERSION(DRV_VERSION); |
456 | MODULE_DESCRIPTION("Ralink RT2800 PCI & PCMCIA Wireless LAN driver."); | 452 | MODULE_DESCRIPTION("Ralink RT2800 PCI & PCMCIA Wireless LAN driver."); |
457 | MODULE_SUPPORTED_DEVICE("Ralink RT2860 PCI & PCMCIA chipset based cards"); | 453 | MODULE_SUPPORTED_DEVICE("Ralink RT2860 PCI & PCMCIA chipset based cards"); |
458 | #ifdef CONFIG_PCI | ||
459 | MODULE_FIRMWARE(FIRMWARE_RT2860); | 454 | MODULE_FIRMWARE(FIRMWARE_RT2860); |
460 | MODULE_DEVICE_TABLE(pci, rt2800pci_device_table); | 455 | MODULE_DEVICE_TABLE(pci, rt2800pci_device_table); |
461 | #endif /* CONFIG_PCI */ | ||
462 | MODULE_LICENSE("GPL"); | 456 | MODULE_LICENSE("GPL"); |
463 | 457 | ||
464 | #if defined(CONFIG_SOC_RT288X) || defined(CONFIG_SOC_RT305X) | ||
465 | static bool rt2800soc_hwcrypt_disabled(struct rt2x00_dev *rt2x00dev) | ||
466 | { | ||
467 | return modparam_nohwcrypt; | ||
468 | } | ||
469 | |||
470 | static void rt2800soc_disable_radio(struct rt2x00_dev *rt2x00dev) | ||
471 | { | ||
472 | rt2800_disable_radio(rt2x00dev); | ||
473 | rt2x00mmio_register_write(rt2x00dev, PWR_PIN_CFG, 0); | ||
474 | rt2x00mmio_register_write(rt2x00dev, TX_PIN_CFG, 0); | ||
475 | } | ||
476 | |||
477 | static int rt2800soc_set_device_state(struct rt2x00_dev *rt2x00dev, | ||
478 | enum dev_state state) | ||
479 | { | ||
480 | int retval = 0; | ||
481 | |||
482 | switch (state) { | ||
483 | case STATE_RADIO_ON: | ||
484 | retval = rt2800mmio_enable_radio(rt2x00dev); | ||
485 | break; | ||
486 | |||
487 | case STATE_RADIO_OFF: | ||
488 | rt2800soc_disable_radio(rt2x00dev); | ||
489 | break; | ||
490 | |||
491 | case STATE_RADIO_IRQ_ON: | ||
492 | case STATE_RADIO_IRQ_OFF: | ||
493 | rt2800mmio_toggle_irq(rt2x00dev, state); | ||
494 | break; | ||
495 | |||
496 | case STATE_DEEP_SLEEP: | ||
497 | case STATE_SLEEP: | ||
498 | case STATE_STANDBY: | ||
499 | case STATE_AWAKE: | ||
500 | /* These states are not supported, but don't report an error */ | ||
501 | retval = 0; | ||
502 | break; | ||
503 | |||
504 | default: | ||
505 | retval = -ENOTSUPP; | ||
506 | break; | ||
507 | } | ||
508 | |||
509 | if (unlikely(retval)) | ||
510 | rt2x00_err(rt2x00dev, "Device failed to enter state %d (%d)\n", | ||
511 | state, retval); | ||
512 | |||
513 | return retval; | ||
514 | } | ||
515 | |||
516 | static int rt2800soc_read_eeprom(struct rt2x00_dev *rt2x00dev) | ||
517 | { | ||
518 | void __iomem *base_addr = ioremap(0x1F040000, EEPROM_SIZE); | ||
519 | |||
520 | if (!base_addr) | ||
521 | return -ENOMEM; | ||
522 | |||
523 | memcpy_fromio(rt2x00dev->eeprom, base_addr, EEPROM_SIZE); | ||
524 | |||
525 | iounmap(base_addr); | ||
526 | return 0; | ||
527 | } | ||
528 | |||
529 | /* Firmware functions */ | ||
530 | static char *rt2800soc_get_firmware_name(struct rt2x00_dev *rt2x00dev) | ||
531 | { | ||
532 | WARN_ON_ONCE(1); | ||
533 | return NULL; | ||
534 | } | ||
535 | |||
536 | static int rt2800soc_load_firmware(struct rt2x00_dev *rt2x00dev, | ||
537 | const u8 *data, const size_t len) | ||
538 | { | ||
539 | WARN_ON_ONCE(1); | ||
540 | return 0; | ||
541 | } | ||
542 | |||
543 | static int rt2800soc_check_firmware(struct rt2x00_dev *rt2x00dev, | ||
544 | const u8 *data, const size_t len) | ||
545 | { | ||
546 | WARN_ON_ONCE(1); | ||
547 | return 0; | ||
548 | } | ||
549 | |||
550 | static int rt2800soc_write_firmware(struct rt2x00_dev *rt2x00dev, | ||
551 | const u8 *data, const size_t len) | ||
552 | { | ||
553 | WARN_ON_ONCE(1); | ||
554 | return 0; | ||
555 | } | ||
556 | |||
557 | static const struct ieee80211_ops rt2800soc_mac80211_ops = { | ||
558 | .tx = rt2x00mac_tx, | ||
559 | .start = rt2x00mac_start, | ||
560 | .stop = rt2x00mac_stop, | ||
561 | .add_interface = rt2x00mac_add_interface, | ||
562 | .remove_interface = rt2x00mac_remove_interface, | ||
563 | .config = rt2x00mac_config, | ||
564 | .configure_filter = rt2x00mac_configure_filter, | ||
565 | .set_key = rt2x00mac_set_key, | ||
566 | .sw_scan_start = rt2x00mac_sw_scan_start, | ||
567 | .sw_scan_complete = rt2x00mac_sw_scan_complete, | ||
568 | .get_stats = rt2x00mac_get_stats, | ||
569 | .get_tkip_seq = rt2800_get_tkip_seq, | ||
570 | .set_rts_threshold = rt2800_set_rts_threshold, | ||
571 | .sta_add = rt2x00mac_sta_add, | ||
572 | .sta_remove = rt2x00mac_sta_remove, | ||
573 | .bss_info_changed = rt2x00mac_bss_info_changed, | ||
574 | .conf_tx = rt2800_conf_tx, | ||
575 | .get_tsf = rt2800_get_tsf, | ||
576 | .rfkill_poll = rt2x00mac_rfkill_poll, | ||
577 | .ampdu_action = rt2800_ampdu_action, | ||
578 | .flush = rt2x00mac_flush, | ||
579 | .get_survey = rt2800_get_survey, | ||
580 | .get_ringparam = rt2x00mac_get_ringparam, | ||
581 | .tx_frames_pending = rt2x00mac_tx_frames_pending, | ||
582 | }; | ||
583 | |||
584 | static const struct rt2800_ops rt2800soc_rt2800_ops = { | ||
585 | .register_read = rt2x00mmio_register_read, | ||
586 | .register_read_lock = rt2x00mmio_register_read, /* same for SoCs */ | ||
587 | .register_write = rt2x00mmio_register_write, | ||
588 | .register_write_lock = rt2x00mmio_register_write, /* same for SoCs */ | ||
589 | .register_multiread = rt2x00mmio_register_multiread, | ||
590 | .register_multiwrite = rt2x00mmio_register_multiwrite, | ||
591 | .regbusy_read = rt2x00mmio_regbusy_read, | ||
592 | .read_eeprom = rt2800soc_read_eeprom, | ||
593 | .hwcrypt_disabled = rt2800soc_hwcrypt_disabled, | ||
594 | .drv_write_firmware = rt2800soc_write_firmware, | ||
595 | .drv_init_registers = rt2800mmio_init_registers, | ||
596 | .drv_get_txwi = rt2800mmio_get_txwi, | ||
597 | }; | ||
598 | |||
599 | static const struct rt2x00lib_ops rt2800soc_rt2x00_ops = { | ||
600 | .irq_handler = rt2800mmio_interrupt, | ||
601 | .txstatus_tasklet = rt2800mmio_txstatus_tasklet, | ||
602 | .pretbtt_tasklet = rt2800mmio_pretbtt_tasklet, | ||
603 | .tbtt_tasklet = rt2800mmio_tbtt_tasklet, | ||
604 | .rxdone_tasklet = rt2800mmio_rxdone_tasklet, | ||
605 | .autowake_tasklet = rt2800mmio_autowake_tasklet, | ||
606 | .probe_hw = rt2800_probe_hw, | ||
607 | .get_firmware_name = rt2800soc_get_firmware_name, | ||
608 | .check_firmware = rt2800soc_check_firmware, | ||
609 | .load_firmware = rt2800soc_load_firmware, | ||
610 | .initialize = rt2x00mmio_initialize, | ||
611 | .uninitialize = rt2x00mmio_uninitialize, | ||
612 | .get_entry_state = rt2800mmio_get_entry_state, | ||
613 | .clear_entry = rt2800mmio_clear_entry, | ||
614 | .set_device_state = rt2800soc_set_device_state, | ||
615 | .rfkill_poll = rt2800_rfkill_poll, | ||
616 | .link_stats = rt2800_link_stats, | ||
617 | .reset_tuner = rt2800_reset_tuner, | ||
618 | .link_tuner = rt2800_link_tuner, | ||
619 | .gain_calibration = rt2800_gain_calibration, | ||
620 | .vco_calibration = rt2800_vco_calibration, | ||
621 | .start_queue = rt2800mmio_start_queue, | ||
622 | .kick_queue = rt2800mmio_kick_queue, | ||
623 | .stop_queue = rt2800mmio_stop_queue, | ||
624 | .flush_queue = rt2x00mmio_flush_queue, | ||
625 | .write_tx_desc = rt2800mmio_write_tx_desc, | ||
626 | .write_tx_data = rt2800_write_tx_data, | ||
627 | .write_beacon = rt2800_write_beacon, | ||
628 | .clear_beacon = rt2800_clear_beacon, | ||
629 | .fill_rxdone = rt2800mmio_fill_rxdone, | ||
630 | .config_shared_key = rt2800_config_shared_key, | ||
631 | .config_pairwise_key = rt2800_config_pairwise_key, | ||
632 | .config_filter = rt2800_config_filter, | ||
633 | .config_intf = rt2800_config_intf, | ||
634 | .config_erp = rt2800_config_erp, | ||
635 | .config_ant = rt2800_config_ant, | ||
636 | .config = rt2800_config, | ||
637 | .sta_add = rt2800_sta_add, | ||
638 | .sta_remove = rt2800_sta_remove, | ||
639 | }; | ||
640 | |||
641 | static const struct rt2x00_ops rt2800soc_ops = { | ||
642 | .name = KBUILD_MODNAME, | ||
643 | .drv_data_size = sizeof(struct rt2800_drv_data), | ||
644 | .max_ap_intf = 8, | ||
645 | .eeprom_size = EEPROM_SIZE, | ||
646 | .rf_size = RF_SIZE, | ||
647 | .tx_queues = NUM_TX_QUEUES, | ||
648 | .queue_init = rt2800mmio_queue_init, | ||
649 | .lib = &rt2800soc_rt2x00_ops, | ||
650 | .drv = &rt2800soc_rt2800_ops, | ||
651 | .hw = &rt2800soc_mac80211_ops, | ||
652 | #ifdef CONFIG_RT2X00_LIB_DEBUGFS | ||
653 | .debugfs = &rt2800_rt2x00debug, | ||
654 | #endif /* CONFIG_RT2X00_LIB_DEBUGFS */ | ||
655 | }; | ||
656 | |||
657 | static int rt2800soc_probe(struct platform_device *pdev) | ||
658 | { | ||
659 | return rt2x00soc_probe(pdev, &rt2800soc_ops); | ||
660 | } | ||
661 | |||
662 | static struct platform_driver rt2800soc_driver = { | ||
663 | .driver = { | ||
664 | .name = "rt2800_wmac", | ||
665 | .owner = THIS_MODULE, | ||
666 | .mod_name = KBUILD_MODNAME, | ||
667 | }, | ||
668 | .probe = rt2800soc_probe, | ||
669 | .remove = rt2x00soc_remove, | ||
670 | .suspend = rt2x00soc_suspend, | ||
671 | .resume = rt2x00soc_resume, | ||
672 | }; | ||
673 | #endif /* CONFIG_SOC_RT288X || CONFIG_SOC_RT305X */ | ||
674 | |||
675 | #ifdef CONFIG_PCI | ||
676 | static int rt2800pci_probe(struct pci_dev *pci_dev, | 458 | static int rt2800pci_probe(struct pci_dev *pci_dev, |
677 | const struct pci_device_id *id) | 459 | const struct pci_device_id *id) |
678 | { | 460 | { |
@@ -687,38 +469,16 @@ static struct pci_driver rt2800pci_driver = { | |||
687 | .suspend = rt2x00pci_suspend, | 469 | .suspend = rt2x00pci_suspend, |
688 | .resume = rt2x00pci_resume, | 470 | .resume = rt2x00pci_resume, |
689 | }; | 471 | }; |
690 | #endif /* CONFIG_PCI */ | 472 | |
691 | 473 | ||
692 | static int __init rt2800pci_init(void) | 474 | static int __init rt2800pci_init(void) |
693 | { | 475 | { |
694 | int ret = 0; | 476 | return pci_register_driver(&rt2800pci_driver); |
695 | |||
696 | #if defined(CONFIG_SOC_RT288X) || defined(CONFIG_SOC_RT305X) | ||
697 | ret = platform_driver_register(&rt2800soc_driver); | ||
698 | if (ret) | ||
699 | return ret; | ||
700 | #endif | ||
701 | #ifdef CONFIG_PCI | ||
702 | ret = pci_register_driver(&rt2800pci_driver); | ||
703 | if (ret) { | ||
704 | #if defined(CONFIG_SOC_RT288X) || defined(CONFIG_SOC_RT305X) | ||
705 | platform_driver_unregister(&rt2800soc_driver); | ||
706 | #endif | ||
707 | return ret; | ||
708 | } | ||
709 | #endif | ||
710 | |||
711 | return ret; | ||
712 | } | 477 | } |
713 | 478 | ||
714 | static void __exit rt2800pci_exit(void) | 479 | static void __exit rt2800pci_exit(void) |
715 | { | 480 | { |
716 | #ifdef CONFIG_PCI | ||
717 | pci_unregister_driver(&rt2800pci_driver); | 481 | pci_unregister_driver(&rt2800pci_driver); |
718 | #endif | ||
719 | #if defined(CONFIG_SOC_RT288X) || defined(CONFIG_SOC_RT305X) | ||
720 | platform_driver_unregister(&rt2800soc_driver); | ||
721 | #endif | ||
722 | } | 482 | } |
723 | 483 | ||
724 | module_init(rt2800pci_init); | 484 | module_init(rt2800pci_init); |
diff --git a/drivers/net/wireless/rt2x00/rt2800soc.c b/drivers/net/wireless/rt2x00/rt2800soc.c new file mode 100644 index 000000000000..1359227ca411 --- /dev/null +++ b/drivers/net/wireless/rt2x00/rt2800soc.c | |||
@@ -0,0 +1,263 @@ | |||
1 | /* Copyright (C) 2009 - 2010 Ivo van Doorn <IvDoorn@gmail.com> | ||
2 | * Copyright (C) 2009 Alban Browaeys <prahal@yahoo.com> | ||
3 | * Copyright (C) 2009 Felix Fietkau <nbd@openwrt.org> | ||
4 | * Copyright (C) 2009 Luis Correia <luis.f.correia@gmail.com> | ||
5 | * Copyright (C) 2009 Mattias Nissler <mattias.nissler@gmx.de> | ||
6 | * Copyright (C) 2009 Mark Asselstine <asselsm@gmail.com> | ||
7 | * Copyright (C) 2009 Xose Vazquez Perez <xose.vazquez@gmail.com> | ||
8 | * Copyright (C) 2009 Bart Zolnierkiewicz <bzolnier@gmail.com> | ||
9 | * <http://rt2x00.serialmonkey.com> | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or | ||
14 | * (at your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, | ||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
19 | * GNU General Public License for more details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License | ||
22 | * along with this program; if not, write to the | ||
23 | * Free Software Foundation, Inc., | ||
24 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
25 | */ | ||
26 | |||
27 | /* Module: rt2800soc | ||
28 | * Abstract: rt2800 WiSoC specific routines. | ||
29 | */ | ||
30 | |||
31 | #include <linux/etherdevice.h> | ||
32 | #include <linux/init.h> | ||
33 | #include <linux/kernel.h> | ||
34 | #include <linux/module.h> | ||
35 | #include <linux/platform_device.h> | ||
36 | |||
37 | #include "rt2x00.h" | ||
38 | #include "rt2x00mmio.h" | ||
39 | #include "rt2x00soc.h" | ||
40 | #include "rt2800.h" | ||
41 | #include "rt2800lib.h" | ||
42 | #include "rt2800mmio.h" | ||
43 | |||
44 | /* Allow hardware encryption to be disabled. */ | ||
45 | static bool modparam_nohwcrypt; | ||
46 | module_param_named(nohwcrypt, modparam_nohwcrypt, bool, S_IRUGO); | ||
47 | MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption."); | ||
48 | |||
49 | static bool rt2800soc_hwcrypt_disabled(struct rt2x00_dev *rt2x00dev) | ||
50 | { | ||
51 | return modparam_nohwcrypt; | ||
52 | } | ||
53 | |||
54 | static void rt2800soc_disable_radio(struct rt2x00_dev *rt2x00dev) | ||
55 | { | ||
56 | rt2800_disable_radio(rt2x00dev); | ||
57 | rt2x00mmio_register_write(rt2x00dev, PWR_PIN_CFG, 0); | ||
58 | rt2x00mmio_register_write(rt2x00dev, TX_PIN_CFG, 0); | ||
59 | } | ||
60 | |||
61 | static int rt2800soc_set_device_state(struct rt2x00_dev *rt2x00dev, | ||
62 | enum dev_state state) | ||
63 | { | ||
64 | int retval = 0; | ||
65 | |||
66 | switch (state) { | ||
67 | case STATE_RADIO_ON: | ||
68 | retval = rt2800mmio_enable_radio(rt2x00dev); | ||
69 | break; | ||
70 | |||
71 | case STATE_RADIO_OFF: | ||
72 | rt2800soc_disable_radio(rt2x00dev); | ||
73 | break; | ||
74 | |||
75 | case STATE_RADIO_IRQ_ON: | ||
76 | case STATE_RADIO_IRQ_OFF: | ||
77 | rt2800mmio_toggle_irq(rt2x00dev, state); | ||
78 | break; | ||
79 | |||
80 | case STATE_DEEP_SLEEP: | ||
81 | case STATE_SLEEP: | ||
82 | case STATE_STANDBY: | ||
83 | case STATE_AWAKE: | ||
84 | /* These states are not supported, but don't report an error */ | ||
85 | retval = 0; | ||
86 | break; | ||
87 | |||
88 | default: | ||
89 | retval = -ENOTSUPP; | ||
90 | break; | ||
91 | } | ||
92 | |||
93 | if (unlikely(retval)) | ||
94 | rt2x00_err(rt2x00dev, "Device failed to enter state %d (%d)\n", | ||
95 | state, retval); | ||
96 | |||
97 | return retval; | ||
98 | } | ||
99 | |||
100 | static int rt2800soc_read_eeprom(struct rt2x00_dev *rt2x00dev) | ||
101 | { | ||
102 | void __iomem *base_addr = ioremap(0x1F040000, EEPROM_SIZE); | ||
103 | |||
104 | if (!base_addr) | ||
105 | return -ENOMEM; | ||
106 | |||
107 | memcpy_fromio(rt2x00dev->eeprom, base_addr, EEPROM_SIZE); | ||
108 | |||
109 | iounmap(base_addr); | ||
110 | return 0; | ||
111 | } | ||
112 | |||
113 | /* Firmware functions */ | ||
114 | static char *rt2800soc_get_firmware_name(struct rt2x00_dev *rt2x00dev) | ||
115 | { | ||
116 | WARN_ON_ONCE(1); | ||
117 | return NULL; | ||
118 | } | ||
119 | |||
120 | static int rt2800soc_load_firmware(struct rt2x00_dev *rt2x00dev, | ||
121 | const u8 *data, const size_t len) | ||
122 | { | ||
123 | WARN_ON_ONCE(1); | ||
124 | return 0; | ||
125 | } | ||
126 | |||
127 | static int rt2800soc_check_firmware(struct rt2x00_dev *rt2x00dev, | ||
128 | const u8 *data, const size_t len) | ||
129 | { | ||
130 | WARN_ON_ONCE(1); | ||
131 | return 0; | ||
132 | } | ||
133 | |||
134 | static int rt2800soc_write_firmware(struct rt2x00_dev *rt2x00dev, | ||
135 | const u8 *data, const size_t len) | ||
136 | { | ||
137 | WARN_ON_ONCE(1); | ||
138 | return 0; | ||
139 | } | ||
140 | |||
141 | static const struct ieee80211_ops rt2800soc_mac80211_ops = { | ||
142 | .tx = rt2x00mac_tx, | ||
143 | .start = rt2x00mac_start, | ||
144 | .stop = rt2x00mac_stop, | ||
145 | .add_interface = rt2x00mac_add_interface, | ||
146 | .remove_interface = rt2x00mac_remove_interface, | ||
147 | .config = rt2x00mac_config, | ||
148 | .configure_filter = rt2x00mac_configure_filter, | ||
149 | .set_key = rt2x00mac_set_key, | ||
150 | .sw_scan_start = rt2x00mac_sw_scan_start, | ||
151 | .sw_scan_complete = rt2x00mac_sw_scan_complete, | ||
152 | .get_stats = rt2x00mac_get_stats, | ||
153 | .get_tkip_seq = rt2800_get_tkip_seq, | ||
154 | .set_rts_threshold = rt2800_set_rts_threshold, | ||
155 | .sta_add = rt2x00mac_sta_add, | ||
156 | .sta_remove = rt2x00mac_sta_remove, | ||
157 | .bss_info_changed = rt2x00mac_bss_info_changed, | ||
158 | .conf_tx = rt2800_conf_tx, | ||
159 | .get_tsf = rt2800_get_tsf, | ||
160 | .rfkill_poll = rt2x00mac_rfkill_poll, | ||
161 | .ampdu_action = rt2800_ampdu_action, | ||
162 | .flush = rt2x00mac_flush, | ||
163 | .get_survey = rt2800_get_survey, | ||
164 | .get_ringparam = rt2x00mac_get_ringparam, | ||
165 | .tx_frames_pending = rt2x00mac_tx_frames_pending, | ||
166 | }; | ||
167 | |||
168 | static const struct rt2800_ops rt2800soc_rt2800_ops = { | ||
169 | .register_read = rt2x00mmio_register_read, | ||
170 | .register_read_lock = rt2x00mmio_register_read, /* same for SoCs */ | ||
171 | .register_write = rt2x00mmio_register_write, | ||
172 | .register_write_lock = rt2x00mmio_register_write, /* same for SoCs */ | ||
173 | .register_multiread = rt2x00mmio_register_multiread, | ||
174 | .register_multiwrite = rt2x00mmio_register_multiwrite, | ||
175 | .regbusy_read = rt2x00mmio_regbusy_read, | ||
176 | .read_eeprom = rt2800soc_read_eeprom, | ||
177 | .hwcrypt_disabled = rt2800soc_hwcrypt_disabled, | ||
178 | .drv_write_firmware = rt2800soc_write_firmware, | ||
179 | .drv_init_registers = rt2800mmio_init_registers, | ||
180 | .drv_get_txwi = rt2800mmio_get_txwi, | ||
181 | }; | ||
182 | |||
183 | static const struct rt2x00lib_ops rt2800soc_rt2x00_ops = { | ||
184 | .irq_handler = rt2800mmio_interrupt, | ||
185 | .txstatus_tasklet = rt2800mmio_txstatus_tasklet, | ||
186 | .pretbtt_tasklet = rt2800mmio_pretbtt_tasklet, | ||
187 | .tbtt_tasklet = rt2800mmio_tbtt_tasklet, | ||
188 | .rxdone_tasklet = rt2800mmio_rxdone_tasklet, | ||
189 | .autowake_tasklet = rt2800mmio_autowake_tasklet, | ||
190 | .probe_hw = rt2800_probe_hw, | ||
191 | .get_firmware_name = rt2800soc_get_firmware_name, | ||
192 | .check_firmware = rt2800soc_check_firmware, | ||
193 | .load_firmware = rt2800soc_load_firmware, | ||
194 | .initialize = rt2x00mmio_initialize, | ||
195 | .uninitialize = rt2x00mmio_uninitialize, | ||
196 | .get_entry_state = rt2800mmio_get_entry_state, | ||
197 | .clear_entry = rt2800mmio_clear_entry, | ||
198 | .set_device_state = rt2800soc_set_device_state, | ||
199 | .rfkill_poll = rt2800_rfkill_poll, | ||
200 | .link_stats = rt2800_link_stats, | ||
201 | .reset_tuner = rt2800_reset_tuner, | ||
202 | .link_tuner = rt2800_link_tuner, | ||
203 | .gain_calibration = rt2800_gain_calibration, | ||
204 | .vco_calibration = rt2800_vco_calibration, | ||
205 | .start_queue = rt2800mmio_start_queue, | ||
206 | .kick_queue = rt2800mmio_kick_queue, | ||
207 | .stop_queue = rt2800mmio_stop_queue, | ||
208 | .flush_queue = rt2x00mmio_flush_queue, | ||
209 | .write_tx_desc = rt2800mmio_write_tx_desc, | ||
210 | .write_tx_data = rt2800_write_tx_data, | ||
211 | .write_beacon = rt2800_write_beacon, | ||
212 | .clear_beacon = rt2800_clear_beacon, | ||
213 | .fill_rxdone = rt2800mmio_fill_rxdone, | ||
214 | .config_shared_key = rt2800_config_shared_key, | ||
215 | .config_pairwise_key = rt2800_config_pairwise_key, | ||
216 | .config_filter = rt2800_config_filter, | ||
217 | .config_intf = rt2800_config_intf, | ||
218 | .config_erp = rt2800_config_erp, | ||
219 | .config_ant = rt2800_config_ant, | ||
220 | .config = rt2800_config, | ||
221 | .sta_add = rt2800_sta_add, | ||
222 | .sta_remove = rt2800_sta_remove, | ||
223 | }; | ||
224 | |||
225 | static const struct rt2x00_ops rt2800soc_ops = { | ||
226 | .name = KBUILD_MODNAME, | ||
227 | .drv_data_size = sizeof(struct rt2800_drv_data), | ||
228 | .max_ap_intf = 8, | ||
229 | .eeprom_size = EEPROM_SIZE, | ||
230 | .rf_size = RF_SIZE, | ||
231 | .tx_queues = NUM_TX_QUEUES, | ||
232 | .queue_init = rt2800mmio_queue_init, | ||
233 | .lib = &rt2800soc_rt2x00_ops, | ||
234 | .drv = &rt2800soc_rt2800_ops, | ||
235 | .hw = &rt2800soc_mac80211_ops, | ||
236 | #ifdef CONFIG_RT2X00_LIB_DEBUGFS | ||
237 | .debugfs = &rt2800_rt2x00debug, | ||
238 | #endif /* CONFIG_RT2X00_LIB_DEBUGFS */ | ||
239 | }; | ||
240 | |||
241 | static int rt2800soc_probe(struct platform_device *pdev) | ||
242 | { | ||
243 | return rt2x00soc_probe(pdev, &rt2800soc_ops); | ||
244 | } | ||
245 | |||
246 | static struct platform_driver rt2800soc_driver = { | ||
247 | .driver = { | ||
248 | .name = "rt2800_wmac", | ||
249 | .owner = THIS_MODULE, | ||
250 | .mod_name = KBUILD_MODNAME, | ||
251 | }, | ||
252 | .probe = rt2800soc_probe, | ||
253 | .remove = rt2x00soc_remove, | ||
254 | .suspend = rt2x00soc_suspend, | ||
255 | .resume = rt2x00soc_resume, | ||
256 | }; | ||
257 | |||
258 | module_platform_driver(rt2800soc_driver); | ||
259 | |||
260 | MODULE_AUTHOR(DRV_PROJECT); | ||
261 | MODULE_VERSION(DRV_VERSION); | ||
262 | MODULE_DESCRIPTION("Ralink WiSoC Wireless LAN driver."); | ||
263 | MODULE_LICENSE("GPL"); | ||