diff options
| author | Ivo van Doorn <ivdoorn@gmail.com> | 2009-10-15 16:04:14 -0400 |
|---|---|---|
| committer | John W. Linville <linville@tuxdriver.com> | 2009-10-27 16:48:22 -0400 |
| commit | a9b3a9f7214b3acc56330c2257aeaa5fa85bf520 (patch) | |
| tree | 494dab0851de7ba2b3d34d21aac7bb78f46f89c8 | |
| parent | 5d78d34ba2d4a044983b599a697dc1d71af38c96 (diff) | |
rt2x00: Implement support for rt2800pci
Add support for the rt2860/rt3090 chipsets from Ralink.
Includes various patches from a lot of people who helped
getting this driver into the current shape.
Signed-off-by: Alban Browaeys <prahal@yahoo.com>
Signed-off-by: Benoit PAPILLAULT <benoit.papillault@free.fr>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Luis Correia <luis.f.correia@gmail.com>
Signed-off-by: Mattias Nissler <mattias.nissler@gmx.de>
Signed-off-by: Mark Asselstine <asselsm@gmail.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
| -rw-r--r-- | drivers/net/wireless/rt2x00/Kconfig | 26 | ||||
| -rw-r--r-- | drivers/net/wireless/rt2x00/Makefile | 1 | ||||
| -rw-r--r-- | drivers/net/wireless/rt2x00/rt2800pci.c | 3323 | ||||
| -rw-r--r-- | drivers/net/wireless/rt2x00/rt2800pci.h | 1960 | ||||
| -rw-r--r-- | drivers/net/wireless/rt2x00/rt2x00.h | 7 |
5 files changed, 5317 insertions, 0 deletions
diff --git a/drivers/net/wireless/rt2x00/Kconfig b/drivers/net/wireless/rt2x00/Kconfig index e86895ac2d71..390c0c7b3ac2 100644 --- a/drivers/net/wireless/rt2x00/Kconfig +++ b/drivers/net/wireless/rt2x00/Kconfig | |||
| @@ -53,6 +53,32 @@ config RT61PCI | |||
| 53 | 53 | ||
| 54 | When compiled as a module, this driver will be called rt61pci. | 54 | When compiled as a module, this driver will be called rt61pci. |
| 55 | 55 | ||
| 56 | config RT2800PCI_PCI | ||
| 57 | tristate | ||
| 58 | depends on PCI | ||
| 59 | default y | ||
| 60 | |||
| 61 | config RT2800PCI_SOC | ||
| 62 | tristate | ||
| 63 | depends on RALINK_RT288X || RALINK_RT305X | ||
| 64 | default y | ||
| 65 | |||
| 66 | config RT2800PCI | ||
| 67 | tristate "Ralink rt2800 (PCI/PCMCIA) support" | ||
| 68 | depends on (RT2800PCI_PCI || RT2800PCI_SOC) && EXPERIMENTAL | ||
| 69 | select RT2X00_LIB_PCI if RT2800PCI_PCI | ||
| 70 | select RT2X00_LIB_SOC if RT2800PCI_SOC | ||
| 71 | select RT2X00_LIB_HT | ||
| 72 | select RT2X00_LIB_FIRMWARE | ||
| 73 | select RT2X00_LIB_CRYPTO | ||
| 74 | select CRC_CCITT | ||
| 75 | select EEPROM_93CX6 | ||
| 76 | ---help--- | ||
| 77 | This adds support for rt2800 wireless chipset family. | ||
| 78 | Supported chips: RT2760, RT2790, RT2860, RT2880, RT2890 & RT3052 | ||
| 79 | |||
| 80 | When compiled as a module, this driver will be called "rt2800pci.ko". | ||
| 81 | |||
| 56 | config RT2500USB | 82 | config RT2500USB |
| 57 | tristate "Ralink rt2500 (USB) support" | 83 | tristate "Ralink rt2500 (USB) support" |
| 58 | depends on USB | 84 | depends on USB |
diff --git a/drivers/net/wireless/rt2x00/Makefile b/drivers/net/wireless/rt2x00/Makefile index 5b1ee4f6b8f3..912f5f67e159 100644 --- a/drivers/net/wireless/rt2x00/Makefile +++ b/drivers/net/wireless/rt2x00/Makefile | |||
| @@ -16,6 +16,7 @@ obj-$(CONFIG_RT2X00_LIB_USB) += rt2x00usb.o | |||
| 16 | obj-$(CONFIG_RT2400PCI) += rt2400pci.o | 16 | obj-$(CONFIG_RT2400PCI) += rt2400pci.o |
| 17 | obj-$(CONFIG_RT2500PCI) += rt2500pci.o | 17 | obj-$(CONFIG_RT2500PCI) += rt2500pci.o |
| 18 | obj-$(CONFIG_RT61PCI) += rt61pci.o | 18 | obj-$(CONFIG_RT61PCI) += rt61pci.o |
| 19 | obj-$(CONFIG_RT2800PCI) += rt2800pci.o | ||
| 19 | obj-$(CONFIG_RT2500USB) += rt2500usb.o | 20 | obj-$(CONFIG_RT2500USB) += rt2500usb.o |
| 20 | obj-$(CONFIG_RT73USB) += rt73usb.o | 21 | obj-$(CONFIG_RT73USB) += rt73usb.o |
| 21 | obj-$(CONFIG_RT2800USB) += rt2800usb.o | 22 | obj-$(CONFIG_RT2800USB) += rt2800usb.o |
diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c new file mode 100644 index 000000000000..be81788b80c7 --- /dev/null +++ b/drivers/net/wireless/rt2x00/rt2800pci.c | |||
| @@ -0,0 +1,3323 @@ | |||
| 1 | /* | ||
| 2 | Copyright (C) 2004 - 2009 rt2x00 SourceForge Project | ||
| 3 | <http://rt2x00.serialmonkey.com> | ||
| 4 | |||
| 5 | This program is free software; you can redistribute it and/or modify | ||
| 6 | it under the terms of the GNU General Public License as published by | ||
| 7 | the Free Software Foundation; either version 2 of the License, or | ||
| 8 | (at your option) any later version. | ||
| 9 | |||
| 10 | This program is distributed in the hope that it will be useful, | ||
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | GNU General Public License for more details. | ||
| 14 | |||
| 15 | You should have received a copy of the GNU General Public License | ||
| 16 | along with this program; if not, write to the | ||
| 17 | Free Software Foundation, Inc., | ||
| 18 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
| 19 | */ | ||
| 20 | |||
| 21 | /* | ||
| 22 | Module: rt2800pci | ||
| 23 | Abstract: rt2800pci device specific routines. | ||
| 24 | Supported chipsets: RT2800E & RT2800ED. | ||
| 25 | */ | ||
| 26 | |||
| 27 | #include <linux/crc-ccitt.h> | ||
| 28 | #include <linux/delay.h> | ||
| 29 | #include <linux/etherdevice.h> | ||
| 30 | #include <linux/init.h> | ||
| 31 | #include <linux/kernel.h> | ||
| 32 | #include <linux/module.h> | ||
| 33 | #include <linux/pci.h> | ||
| 34 | #include <linux/platform_device.h> | ||
| 35 | #include <linux/eeprom_93cx6.h> | ||
| 36 | |||
| 37 | #include "rt2x00.h" | ||
| 38 | #include "rt2x00pci.h" | ||
| 39 | #include "rt2x00soc.h" | ||
| 40 | #include "rt2800pci.h" | ||
| 41 | |||
| 42 | #ifdef CONFIG_RT2800PCI_PCI_MODULE | ||
| 43 | #define CONFIG_RT2800PCI_PCI | ||
| 44 | #endif | ||
| 45 | |||
| 46 | #ifdef CONFIG_RT2800PCI_WISOC_MODULE | ||
| 47 | #define CONFIG_RT2800PCI_WISOC | ||
| 48 | #endif | ||
| 49 | |||
| 50 | /* | ||
| 51 | * Allow hardware encryption to be disabled. | ||
| 52 | */ | ||
| 53 | static int modparam_nohwcrypt = 1; | ||
| 54 | module_param_named(nohwcrypt, modparam_nohwcrypt, bool, S_IRUGO); | ||
| 55 | MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption."); | ||
| 56 | |||
| 57 | /* | ||
| 58 | * Register access. | ||
| 59 | * BBP and RF register require indirect register access, | ||
| 60 | * and use the CSR registers PHY_CSR3 and PHY_CSR4 to achieve this. | ||
| 61 | * These indirect registers work with busy bits, | ||
| 62 | * and we will try maximal REGISTER_BUSY_COUNT times to access | ||
| 63 | * the register while taking a REGISTER_BUSY_DELAY us delay | ||
| 64 | * between each attampt. When the busy bit is still set at that time, | ||
| 65 | * the access attempt is considered to have failed, | ||
| 66 | * and we will print an error. | ||
| 67 | */ | ||
| 68 | #define WAIT_FOR_BBP(__dev, __reg) \ | ||
| 69 | rt2x00pci_regbusy_read((__dev), BBP_CSR_CFG, BBP_CSR_CFG_BUSY, (__reg)) | ||
| 70 | #define WAIT_FOR_RFCSR(__dev, __reg) \ | ||
| 71 | rt2x00pci_regbusy_read((__dev), RF_CSR_CFG, RF_CSR_CFG_BUSY, (__reg)) | ||
| 72 | #define WAIT_FOR_RF(__dev, __reg) \ | ||
| 73 | rt2x00pci_regbusy_read((__dev), RF_CSR_CFG0, RF_CSR_CFG0_BUSY, (__reg)) | ||
| 74 | #define WAIT_FOR_MCU(__dev, __reg) \ | ||
| 75 | rt2x00pci_regbusy_read((__dev), H2M_MAILBOX_CSR, \ | ||
| 76 | H2M_MAILBOX_CSR_OWNER, (__reg)) | ||
| 77 | |||
| 78 | static void rt2800pci_bbp_write(struct rt2x00_dev *rt2x00dev, | ||
| 79 | const unsigned int word, const u8 value) | ||
| 80 | { | ||
| 81 | u32 reg; | ||
| 82 | |||
| 83 | mutex_lock(&rt2x00dev->csr_mutex); | ||
| 84 | |||
| 85 | /* | ||
| 86 | * Wait until the BBP becomes available, afterwards we | ||
| 87 | * can safely write the new data into the register. | ||
| 88 | */ | ||
| 89 | if (WAIT_FOR_BBP(rt2x00dev, ®)) { | ||
| 90 | reg = 0; | ||
| 91 | rt2x00_set_field32(®, BBP_CSR_CFG_VALUE, value); | ||
| 92 | rt2x00_set_field32(®, BBP_CSR_CFG_REGNUM, word); | ||
| 93 | rt2x00_set_field32(®, BBP_CSR_CFG_BUSY, 1); | ||
| 94 | rt2x00_set_field32(®, BBP_CSR_CFG_READ_CONTROL, 0); | ||
| 95 | rt2x00_set_field32(®, BBP_CSR_CFG_BBP_RW_MODE, 1); | ||
| 96 | |||
| 97 | rt2x00pci_register_write(rt2x00dev, BBP_CSR_CFG, reg); | ||
| 98 | } | ||
| 99 | |||
| 100 | mutex_unlock(&rt2x00dev->csr_mutex); | ||
| 101 | } | ||
| 102 | |||
| 103 | static void rt2800pci_bbp_read(struct rt2x00_dev *rt2x00dev, | ||
| 104 | const unsigned int word, u8 *value) | ||
| 105 | { | ||
| 106 | u32 reg; | ||
| 107 | |||
| 108 | mutex_lock(&rt2x00dev->csr_mutex); | ||
| 109 | |||
| 110 | /* | ||
| 111 | * Wait until the BBP becomes available, afterwards we | ||
| 112 | * can safely write the read request into the register. | ||
| 113 | * After the data has been written, we wait until hardware | ||
| 114 | * returns the correct value, if at any time the register | ||
| 115 | * doesn't become available in time, reg will be 0xffffffff | ||
| 116 | * which means we return 0xff to the caller. | ||
| 117 | */ | ||
| 118 | if (WAIT_FOR_BBP(rt2x00dev, ®)) { | ||
| 119 | reg = 0; | ||
| 120 | rt2x00_set_field32(®, BBP_CSR_CFG_REGNUM, word); | ||
| 121 | rt2x00_set_field32(®, BBP_CSR_CFG_BUSY, 1); | ||
| 122 | rt2x00_set_field32(®, BBP_CSR_CFG_READ_CONTROL, 1); | ||
| 123 | rt2x00_set_field32(®, BBP_CSR_CFG_BBP_RW_MODE, 1); | ||
| 124 | |||
| 125 | rt2x00pci_register_write(rt2x00dev, BBP_CSR_CFG, reg); | ||
| 126 | |||
| 127 | WAIT_FOR_BBP(rt2x00dev, ®); | ||
| 128 | } | ||
