Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 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: rt2800usb |
| 23 | Abstract: rt2800usb device specific routines. |
| 24 | Supported chipsets: RT2800U. |
| 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/usb.h> |
| 34 | |
| 35 | #include "rt2x00.h" |
| 36 | #include "rt2x00usb.h" |
Bartlomiej Zolnierkiewicz | 7ef5cc9 | 2009-11-04 18:35:32 +0100 | [diff] [blame] | 37 | #include "rt2800lib.h" |
Bartlomiej Zolnierkiewicz | b54f78a | 2009-11-04 18:35:54 +0100 | [diff] [blame] | 38 | #include "rt2800.h" |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 39 | #include "rt2800usb.h" |
| 40 | |
| 41 | /* |
| 42 | * Allow hardware encryption to be disabled. |
| 43 | */ |
| 44 | static int modparam_nohwcrypt = 1; |
| 45 | module_param_named(nohwcrypt, modparam_nohwcrypt, bool, S_IRUGO); |
| 46 | MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption."); |
| 47 | |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 48 | /* |
| 49 | * Firmware functions |
| 50 | */ |
| 51 | static char *rt2800usb_get_firmware_name(struct rt2x00_dev *rt2x00dev) |
| 52 | { |
| 53 | return FIRMWARE_RT2870; |
| 54 | } |
| 55 | |
| 56 | static bool rt2800usb_check_crc(const u8 *data, const size_t len) |
| 57 | { |
| 58 | u16 fw_crc; |
| 59 | u16 crc; |
| 60 | |
| 61 | /* |
| 62 | * The last 2 bytes in the firmware array are the crc checksum itself, |
| 63 | * this means that we should never pass those 2 bytes to the crc |
| 64 | * algorithm. |
| 65 | */ |
| 66 | fw_crc = (data[len - 2] << 8 | data[len - 1]); |
| 67 | |
| 68 | /* |
| 69 | * Use the crc ccitt algorithm. |
| 70 | * This will return the same value as the legacy driver which |
| 71 | * used bit ordering reversion on the both the firmware bytes |
| 72 | * before input input as well as on the final output. |
| 73 | * Obviously using crc ccitt directly is much more efficient. |
| 74 | */ |
| 75 | crc = crc_ccitt(~0, data, len - 2); |
| 76 | |
| 77 | /* |
| 78 | * There is a small difference between the crc-itu-t + bitrev and |
| 79 | * the crc-ccitt crc calculation. In the latter method the 2 bytes |
| 80 | * will be swapped, use swab16 to convert the crc to the correct |
| 81 | * value. |
| 82 | */ |
| 83 | crc = swab16(crc); |
| 84 | |
| 85 | return fw_crc == crc; |
| 86 | } |
| 87 | |
| 88 | static int rt2800usb_check_firmware(struct rt2x00_dev *rt2x00dev, |
| 89 | const u8 *data, const size_t len) |
| 90 | { |
| 91 | u16 chipset = (rt2x00_rev(&rt2x00dev->chip) >> 16) & 0xffff; |
| 92 | size_t offset = 0; |
| 93 | |
| 94 | /* |
| 95 | * Firmware files: |
| 96 | * There are 2 variations of the rt2870 firmware. |
| 97 | * a) size: 4kb |
| 98 | * b) size: 8kb |
| 99 | * Note that (b) contains 2 seperate firmware blobs of 4k |
| 100 | * within the file. The first blob is the same firmware as (a), |
| 101 | * but the second blob is for the additional chipsets. |
| 102 | */ |
| 103 | if (len != 4096 && len != 8192) |
| 104 | return FW_BAD_LENGTH; |
| 105 | |
| 106 | /* |
| 107 | * Check if we need the upper 4kb firmware data or not. |
| 108 | */ |
| 109 | if ((len == 4096) && |
| 110 | (chipset != 0x2860) && |
| 111 | (chipset != 0x2872) && |
| 112 | (chipset != 0x3070)) |
| 113 | return FW_BAD_VERSION; |
| 114 | |
| 115 | /* |
| 116 | * 8kb firmware files must be checked as if it were |
| 117 | * 2 seperate firmware files. |
| 118 | */ |
| 119 | while (offset < len) { |
| 120 | if (!rt2800usb_check_crc(data + offset, 4096)) |
| 121 | return FW_BAD_CRC; |
| 122 | |
| 123 | offset += 4096; |
| 124 | } |
| 125 | |
| 126 | return FW_OK; |
| 127 | } |
| 128 | |
| 129 | static int rt2800usb_load_firmware(struct rt2x00_dev *rt2x00dev, |
| 130 | const u8 *data, const size_t len) |
| 131 | { |
| 132 | unsigned int i; |
| 133 | int status; |
| 134 | u32 reg; |
| 135 | u32 offset; |
| 136 | u32 length; |
| 137 | u16 chipset = (rt2x00_rev(&rt2x00dev->chip) >> 16) & 0xffff; |
| 138 | |
| 139 | /* |
| 140 | * Check which section of the firmware we need. |
| 141 | */ |
Ivo van Doorn | 15e4692 | 2009-04-28 20:14:58 +0200 | [diff] [blame] | 142 | if ((chipset == 0x2860) || |
| 143 | (chipset == 0x2872) || |
| 144 | (chipset == 0x3070)) { |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 145 | offset = 0; |
| 146 | length = 4096; |
| 147 | } else { |
| 148 | offset = 4096; |
| 149 | length = 4096; |
| 150 | } |
| 151 | |
| 152 | /* |
| 153 | * Wait for stable hardware. |
| 154 | */ |
| 155 | for (i = 0; i < REGISTER_BUSY_COUNT; i++) { |
Bartlomiej Zolnierkiewicz | abbb505 | 2009-11-04 18:33:05 +0100 | [diff] [blame] | 156 | rt2800_register_read(rt2x00dev, MAC_CSR0, ®); |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 157 | if (reg && reg != ~0) |
| 158 | break; |
| 159 | msleep(1); |
| 160 | } |
| 161 | |
| 162 | if (i == REGISTER_BUSY_COUNT) { |
| 163 | ERROR(rt2x00dev, "Unstable hardware.\n"); |
| 164 | return -EBUSY; |
| 165 | } |
| 166 | |
| 167 | /* |
| 168 | * Write firmware to device. |
| 169 | */ |
| 170 | rt2x00usb_vendor_request_large_buff(rt2x00dev, USB_MULTI_WRITE, |
| 171 | USB_VENDOR_REQUEST_OUT, |
| 172 | FIRMWARE_IMAGE_BASE, |
| 173 | data + offset, length, |
| 174 | REGISTER_TIMEOUT32(length)); |
| 175 | |
Bartlomiej Zolnierkiewicz | abbb505 | 2009-11-04 18:33:05 +0100 | [diff] [blame] | 176 | rt2800_register_write(rt2x00dev, H2M_MAILBOX_CID, ~0); |
| 177 | rt2800_register_write(rt2x00dev, H2M_MAILBOX_STATUS, ~0); |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 178 | |
| 179 | /* |
| 180 | * Send firmware request to device to load firmware, |
| 181 | * we need to specify a long timeout time. |
| 182 | */ |
| 183 | status = rt2x00usb_vendor_request_sw(rt2x00dev, USB_DEVICE_MODE, |
| 184 | 0, USB_MODE_FIRMWARE, |
| 185 | REGISTER_TIMEOUT_FIRMWARE); |
| 186 | if (status < 0) { |
| 187 | ERROR(rt2x00dev, "Failed to write Firmware to device.\n"); |
| 188 | return status; |
| 189 | } |
| 190 | |
Ivo van Doorn | 15e4692 | 2009-04-28 20:14:58 +0200 | [diff] [blame] | 191 | msleep(10); |
Bartlomiej Zolnierkiewicz | abbb505 | 2009-11-04 18:33:05 +0100 | [diff] [blame] | 192 | rt2800_register_write(rt2x00dev, H2M_MAILBOX_CSR, 0); |
Ivo van Doorn | 15e4692 | 2009-04-28 20:14:58 +0200 | [diff] [blame] | 193 | |
| 194 | /* |
| 195 | * Send signal to firmware during boot time. |
| 196 | */ |
Bartlomiej Zolnierkiewicz | 4f2c532 | 2009-11-04 18:34:32 +0100 | [diff] [blame] | 197 | rt2800_mcu_request(rt2x00dev, MCU_BOOT_SIGNAL, 0xff, 0, 0); |
Ivo van Doorn | 15e4692 | 2009-04-28 20:14:58 +0200 | [diff] [blame] | 198 | |
| 199 | if ((chipset == 0x3070) || |
| 200 | (chipset == 0x3071) || |
| 201 | (chipset == 0x3572)) { |
| 202 | udelay(200); |
Bartlomiej Zolnierkiewicz | 4f2c532 | 2009-11-04 18:34:32 +0100 | [diff] [blame] | 203 | rt2800_mcu_request(rt2x00dev, MCU_CURRENT, 0, 0, 0); |
Ivo van Doorn | 15e4692 | 2009-04-28 20:14:58 +0200 | [diff] [blame] | 204 | udelay(10); |
| 205 | } |
| 206 | |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 207 | /* |
| 208 | * Wait for device to stabilize. |
| 209 | */ |
| 210 | for (i = 0; i < REGISTER_BUSY_COUNT; i++) { |
Bartlomiej Zolnierkiewicz | abbb505 | 2009-11-04 18:33:05 +0100 | [diff] [blame] | 211 | rt2800_register_read(rt2x00dev, PBF_SYS_CTRL, ®); |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 212 | if (rt2x00_get_field32(reg, PBF_SYS_CTRL_READY)) |
| 213 | break; |
| 214 | msleep(1); |
| 215 | } |
| 216 | |
| 217 | if (i == REGISTER_BUSY_COUNT) { |
| 218 | ERROR(rt2x00dev, "PBF system register not ready.\n"); |
| 219 | return -EBUSY; |
| 220 | } |
| 221 | |
| 222 | /* |
| 223 | * Initialize firmware. |
| 224 | */ |
Bartlomiej Zolnierkiewicz | abbb505 | 2009-11-04 18:33:05 +0100 | [diff] [blame] | 225 | rt2800_register_write(rt2x00dev, H2M_BBP_AGENT, 0); |
| 226 | rt2800_register_write(rt2x00dev, H2M_MAILBOX_CSR, 0); |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 227 | msleep(1); |
| 228 | |
| 229 | return 0; |
| 230 | } |
| 231 | |
| 232 | /* |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 233 | * Device state switch handlers. |
| 234 | */ |
| 235 | static void rt2800usb_toggle_rx(struct rt2x00_dev *rt2x00dev, |
| 236 | enum dev_state state) |
| 237 | { |
| 238 | u32 reg; |
| 239 | |
Bartlomiej Zolnierkiewicz | abbb505 | 2009-11-04 18:33:05 +0100 | [diff] [blame] | 240 | rt2800_register_read(rt2x00dev, MAC_SYS_CTRL, ®); |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 241 | rt2x00_set_field32(®, MAC_SYS_CTRL_ENABLE_RX, |
| 242 | (state == STATE_RADIO_RX_ON) || |
| 243 | (state == STATE_RADIO_RX_ON_LINK)); |
Bartlomiej Zolnierkiewicz | abbb505 | 2009-11-04 18:33:05 +0100 | [diff] [blame] | 244 | rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg); |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | static int rt2800usb_wait_wpdma_ready(struct rt2x00_dev *rt2x00dev) |
| 248 | { |
| 249 | unsigned int i; |
| 250 | u32 reg; |
| 251 | |
| 252 | for (i = 0; i < REGISTER_BUSY_COUNT; i++) { |
Bartlomiej Zolnierkiewicz | abbb505 | 2009-11-04 18:33:05 +0100 | [diff] [blame] | 253 | rt2800_register_read(rt2x00dev, WPDMA_GLO_CFG, ®); |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 254 | if (!rt2x00_get_field32(reg, WPDMA_GLO_CFG_TX_DMA_BUSY) && |
| 255 | !rt2x00_get_field32(reg, WPDMA_GLO_CFG_RX_DMA_BUSY)) |
| 256 | return 0; |
| 257 | |
| 258 | msleep(1); |
| 259 | } |
| 260 | |
| 261 | ERROR(rt2x00dev, "WPDMA TX/RX busy, aborting.\n"); |
| 262 | return -EACCES; |
| 263 | } |
| 264 | |
| 265 | static int rt2800usb_enable_radio(struct rt2x00_dev *rt2x00dev) |
| 266 | { |
| 267 | u32 reg; |
| 268 | u16 word; |
| 269 | |
| 270 | /* |
| 271 | * Initialize all registers. |
| 272 | */ |
| 273 | if (unlikely(rt2800usb_wait_wpdma_ready(rt2x00dev) || |
Bartlomiej Zolnierkiewicz | fcf5154 | 2009-11-04 18:36:57 +0100 | [diff] [blame] | 274 | rt2800_init_registers(rt2x00dev) || |
| 275 | rt2800_init_bbp(rt2x00dev) || |
| 276 | rt2800_init_rfcsr(rt2x00dev))) |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 277 | return -EIO; |
| 278 | |
Bartlomiej Zolnierkiewicz | abbb505 | 2009-11-04 18:33:05 +0100 | [diff] [blame] | 279 | rt2800_register_read(rt2x00dev, MAC_SYS_CTRL, ®); |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 280 | rt2x00_set_field32(®, MAC_SYS_CTRL_ENABLE_TX, 1); |
Bartlomiej Zolnierkiewicz | abbb505 | 2009-11-04 18:33:05 +0100 | [diff] [blame] | 281 | rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg); |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 282 | |
| 283 | udelay(50); |
| 284 | |
Bartlomiej Zolnierkiewicz | abbb505 | 2009-11-04 18:33:05 +0100 | [diff] [blame] | 285 | rt2800_register_read(rt2x00dev, WPDMA_GLO_CFG, ®); |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 286 | rt2x00_set_field32(®, WPDMA_GLO_CFG_TX_WRITEBACK_DONE, 1); |
| 287 | rt2x00_set_field32(®, WPDMA_GLO_CFG_ENABLE_RX_DMA, 1); |
| 288 | rt2x00_set_field32(®, WPDMA_GLO_CFG_ENABLE_TX_DMA, 1); |
Bartlomiej Zolnierkiewicz | abbb505 | 2009-11-04 18:33:05 +0100 | [diff] [blame] | 289 | rt2800_register_write(rt2x00dev, WPDMA_GLO_CFG, reg); |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 290 | |
| 291 | |
Bartlomiej Zolnierkiewicz | abbb505 | 2009-11-04 18:33:05 +0100 | [diff] [blame] | 292 | rt2800_register_read(rt2x00dev, USB_DMA_CFG, ®); |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 293 | rt2x00_set_field32(®, USB_DMA_CFG_PHY_CLEAR, 0); |
| 294 | /* Don't use bulk in aggregation when working with USB 1.1 */ |
| 295 | rt2x00_set_field32(®, USB_DMA_CFG_RX_BULK_AGG_EN, |
| 296 | (rt2x00dev->rx->usb_maxpacket == 512)); |
| 297 | rt2x00_set_field32(®, USB_DMA_CFG_RX_BULK_AGG_TIMEOUT, 128); |
Ivo van Doorn | 15e4692 | 2009-04-28 20:14:58 +0200 | [diff] [blame] | 298 | /* |
| 299 | * Total room for RX frames in kilobytes, PBF might still exceed |
| 300 | * this limit so reduce the number to prevent errors. |
| 301 | */ |
| 302 | rt2x00_set_field32(®, USB_DMA_CFG_RX_BULK_AGG_LIMIT, |
| 303 | ((RX_ENTRIES * DATA_FRAME_SIZE) / 1024) - 3); |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 304 | rt2x00_set_field32(®, USB_DMA_CFG_RX_BULK_EN, 1); |
| 305 | rt2x00_set_field32(®, USB_DMA_CFG_TX_BULK_EN, 1); |
Bartlomiej Zolnierkiewicz | abbb505 | 2009-11-04 18:33:05 +0100 | [diff] [blame] | 306 | rt2800_register_write(rt2x00dev, USB_DMA_CFG, reg); |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 307 | |
Bartlomiej Zolnierkiewicz | abbb505 | 2009-11-04 18:33:05 +0100 | [diff] [blame] | 308 | rt2800_register_read(rt2x00dev, MAC_SYS_CTRL, ®); |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 309 | rt2x00_set_field32(®, MAC_SYS_CTRL_ENABLE_TX, 1); |
| 310 | rt2x00_set_field32(®, MAC_SYS_CTRL_ENABLE_RX, 1); |
Bartlomiej Zolnierkiewicz | abbb505 | 2009-11-04 18:33:05 +0100 | [diff] [blame] | 311 | rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg); |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 312 | |
| 313 | /* |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 314 | * Initialize LED control |
| 315 | */ |
| 316 | rt2x00_eeprom_read(rt2x00dev, EEPROM_LED1, &word); |
Bartlomiej Zolnierkiewicz | 4f2c532 | 2009-11-04 18:34:32 +0100 | [diff] [blame] | 317 | rt2800_mcu_request(rt2x00dev, MCU_LED_1, 0xff, |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 318 | word & 0xff, (word >> 8) & 0xff); |
| 319 | |
| 320 | rt2x00_eeprom_read(rt2x00dev, EEPROM_LED2, &word); |
Bartlomiej Zolnierkiewicz | 4f2c532 | 2009-11-04 18:34:32 +0100 | [diff] [blame] | 321 | rt2800_mcu_request(rt2x00dev, MCU_LED_2, 0xff, |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 322 | word & 0xff, (word >> 8) & 0xff); |
| 323 | |
| 324 | rt2x00_eeprom_read(rt2x00dev, EEPROM_LED3, &word); |
Bartlomiej Zolnierkiewicz | 4f2c532 | 2009-11-04 18:34:32 +0100 | [diff] [blame] | 325 | rt2800_mcu_request(rt2x00dev, MCU_LED_3, 0xff, |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 326 | word & 0xff, (word >> 8) & 0xff); |
| 327 | |
| 328 | return 0; |
| 329 | } |
| 330 | |
| 331 | static void rt2800usb_disable_radio(struct rt2x00_dev *rt2x00dev) |
| 332 | { |
| 333 | u32 reg; |
| 334 | |
Bartlomiej Zolnierkiewicz | abbb505 | 2009-11-04 18:33:05 +0100 | [diff] [blame] | 335 | rt2800_register_read(rt2x00dev, WPDMA_GLO_CFG, ®); |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 336 | rt2x00_set_field32(®, WPDMA_GLO_CFG_ENABLE_TX_DMA, 0); |
| 337 | rt2x00_set_field32(®, WPDMA_GLO_CFG_ENABLE_RX_DMA, 0); |
Bartlomiej Zolnierkiewicz | abbb505 | 2009-11-04 18:33:05 +0100 | [diff] [blame] | 338 | rt2800_register_write(rt2x00dev, WPDMA_GLO_CFG, reg); |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 339 | |
Bartlomiej Zolnierkiewicz | abbb505 | 2009-11-04 18:33:05 +0100 | [diff] [blame] | 340 | rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, 0); |
| 341 | rt2800_register_write(rt2x00dev, PWR_PIN_CFG, 0); |
| 342 | rt2800_register_write(rt2x00dev, TX_PIN_CFG, 0); |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 343 | |
| 344 | /* Wait for DMA, ignore error */ |
| 345 | rt2800usb_wait_wpdma_ready(rt2x00dev); |
| 346 | |
| 347 | rt2x00usb_disable_radio(rt2x00dev); |
| 348 | } |
| 349 | |
| 350 | static int rt2800usb_set_state(struct rt2x00_dev *rt2x00dev, |
| 351 | enum dev_state state) |
| 352 | { |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 353 | if (state == STATE_AWAKE) |
Bartlomiej Zolnierkiewicz | 4f2c532 | 2009-11-04 18:34:32 +0100 | [diff] [blame] | 354 | rt2800_mcu_request(rt2x00dev, MCU_WAKEUP, 0xff, 0, 0); |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 355 | else |
Bartlomiej Zolnierkiewicz | 4f2c532 | 2009-11-04 18:34:32 +0100 | [diff] [blame] | 356 | rt2800_mcu_request(rt2x00dev, MCU_SLEEP, 0xff, 0, 2); |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 357 | |
| 358 | return 0; |
| 359 | } |
| 360 | |
| 361 | static int rt2800usb_set_device_state(struct rt2x00_dev *rt2x00dev, |
| 362 | enum dev_state state) |
| 363 | { |
| 364 | int retval = 0; |
| 365 | |
| 366 | switch (state) { |
| 367 | case STATE_RADIO_ON: |
| 368 | /* |
| 369 | * Before the radio can be enabled, the device first has |
| 370 | * to be woken up. After that it needs a bit of time |
Luis Correia | 4951348 | 2009-07-17 21:39:19 +0200 | [diff] [blame] | 371 | * to be fully awake and then the radio can be enabled. |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 372 | */ |
| 373 | rt2800usb_set_state(rt2x00dev, STATE_AWAKE); |
| 374 | msleep(1); |
| 375 | retval = rt2800usb_enable_radio(rt2x00dev); |
| 376 | break; |
| 377 | case STATE_RADIO_OFF: |
| 378 | /* |
Luis Correia | 4951348 | 2009-07-17 21:39:19 +0200 | [diff] [blame] | 379 | * After the radio has been disabled, the device should |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 380 | * be put to sleep for powersaving. |
| 381 | */ |
| 382 | rt2800usb_disable_radio(rt2x00dev); |
| 383 | rt2800usb_set_state(rt2x00dev, STATE_SLEEP); |
| 384 | break; |
| 385 | case STATE_RADIO_RX_ON: |
| 386 | case STATE_RADIO_RX_ON_LINK: |
| 387 | case STATE_RADIO_RX_OFF: |
| 388 | case STATE_RADIO_RX_OFF_LINK: |
| 389 | rt2800usb_toggle_rx(rt2x00dev, state); |
| 390 | break; |
| 391 | case STATE_RADIO_IRQ_ON: |
| 392 | case STATE_RADIO_IRQ_OFF: |
| 393 | /* No support, but no error either */ |
| 394 | break; |
| 395 | case STATE_DEEP_SLEEP: |
| 396 | case STATE_SLEEP: |
| 397 | case STATE_STANDBY: |
| 398 | case STATE_AWAKE: |
| 399 | retval = rt2800usb_set_state(rt2x00dev, state); |
| 400 | break; |
| 401 | default: |
| 402 | retval = -ENOTSUPP; |
| 403 | break; |
| 404 | } |
| 405 | |
| 406 | if (unlikely(retval)) |
| 407 | ERROR(rt2x00dev, "Device failed to enter state %d (%d).\n", |
| 408 | state, retval); |
| 409 | |
| 410 | return retval; |
| 411 | } |
| 412 | |
| 413 | /* |
| 414 | * TX descriptor initialization |
| 415 | */ |
| 416 | static void rt2800usb_write_tx_desc(struct rt2x00_dev *rt2x00dev, |
| 417 | struct sk_buff *skb, |
| 418 | struct txentry_desc *txdesc) |
| 419 | { |
| 420 | struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb); |
| 421 | __le32 *txi = skbdesc->desc; |
| 422 | __le32 *txwi = &txi[TXINFO_DESC_SIZE / sizeof(__le32)]; |
| 423 | u32 word; |
| 424 | |
| 425 | /* |
| 426 | * Initialize TX Info descriptor |
| 427 | */ |
| 428 | rt2x00_desc_read(txwi, 0, &word); |
| 429 | rt2x00_set_field32(&word, TXWI_W0_FRAG, |
| 430 | test_bit(ENTRY_TXD_MORE_FRAG, &txdesc->flags)); |
| 431 | rt2x00_set_field32(&word, TXWI_W0_MIMO_PS, 0); |
| 432 | rt2x00_set_field32(&word, TXWI_W0_CF_ACK, 0); |
| 433 | rt2x00_set_field32(&word, TXWI_W0_TS, |
| 434 | test_bit(ENTRY_TXD_REQ_TIMESTAMP, &txdesc->flags)); |
| 435 | rt2x00_set_field32(&word, TXWI_W0_AMPDU, |
| 436 | test_bit(ENTRY_TXD_HT_AMPDU, &txdesc->flags)); |
| 437 | rt2x00_set_field32(&word, TXWI_W0_MPDU_DENSITY, txdesc->mpdu_density); |
| 438 | rt2x00_set_field32(&word, TXWI_W0_TX_OP, txdesc->ifs); |
| 439 | rt2x00_set_field32(&word, TXWI_W0_MCS, txdesc->mcs); |
| 440 | rt2x00_set_field32(&word, TXWI_W0_BW, |
| 441 | test_bit(ENTRY_TXD_HT_BW_40, &txdesc->flags)); |
| 442 | rt2x00_set_field32(&word, TXWI_W0_SHORT_GI, |
| 443 | test_bit(ENTRY_TXD_HT_SHORT_GI, &txdesc->flags)); |
| 444 | rt2x00_set_field32(&word, TXWI_W0_STBC, txdesc->stbc); |
| 445 | rt2x00_set_field32(&word, TXWI_W0_PHYMODE, txdesc->rate_mode); |
| 446 | rt2x00_desc_write(txwi, 0, word); |
| 447 | |
| 448 | rt2x00_desc_read(txwi, 1, &word); |
| 449 | rt2x00_set_field32(&word, TXWI_W1_ACK, |
| 450 | test_bit(ENTRY_TXD_ACK, &txdesc->flags)); |
| 451 | rt2x00_set_field32(&word, TXWI_W1_NSEQ, |
| 452 | test_bit(ENTRY_TXD_GENERATE_SEQ, &txdesc->flags)); |
| 453 | rt2x00_set_field32(&word, TXWI_W1_BW_WIN_SIZE, txdesc->ba_size); |
| 454 | rt2x00_set_field32(&word, TXWI_W1_WIRELESS_CLI_ID, |
| 455 | test_bit(ENTRY_TXD_ENCRYPT, &txdesc->flags) ? |
Benoit PAPILLAULT | 1761631 | 2009-10-15 21:17:09 +0200 | [diff] [blame] | 456 | txdesc->key_idx : 0xff); |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 457 | rt2x00_set_field32(&word, TXWI_W1_MPDU_TOTAL_BYTE_COUNT, |
| 458 | skb->len - txdesc->l2pad); |
| 459 | rt2x00_set_field32(&word, TXWI_W1_PACKETID, |
Ivo van Doorn | 534aff0 | 2009-08-17 18:55:15 +0200 | [diff] [blame] | 460 | skbdesc->entry->queue->qid + 1); |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 461 | rt2x00_desc_write(txwi, 1, word); |
| 462 | |
| 463 | /* |
| 464 | * Always write 0 to IV/EIV fields, hardware will insert the IV |
| 465 | * from the IVEIV register when TXINFO_W0_WIV is set to 0. |
| 466 | * When TXINFO_W0_WIV is set to 1 it will use the IV data |
| 467 | * from the descriptor. The TXWI_W1_WIRELESS_CLI_ID indicates which |
| 468 | * crypto entry in the registers should be used to encrypt the frame. |
| 469 | */ |
| 470 | _rt2x00_desc_write(txwi, 2, 0 /* skbdesc->iv[0] */); |
| 471 | _rt2x00_desc_write(txwi, 3, 0 /* skbdesc->iv[1] */); |
| 472 | |
| 473 | /* |
| 474 | * Initialize TX descriptor |
| 475 | */ |
| 476 | rt2x00_desc_read(txi, 0, &word); |
| 477 | rt2x00_set_field32(&word, TXINFO_W0_USB_DMA_TX_PKT_LEN, |
| 478 | skb->len + TXWI_DESC_SIZE); |
| 479 | rt2x00_set_field32(&word, TXINFO_W0_WIV, |
| 480 | !test_bit(ENTRY_TXD_ENCRYPT_IV, &txdesc->flags)); |
| 481 | rt2x00_set_field32(&word, TXINFO_W0_QSEL, 2); |
| 482 | rt2x00_set_field32(&word, TXINFO_W0_SW_USE_LAST_ROUND, 0); |
| 483 | rt2x00_set_field32(&word, TXINFO_W0_USB_DMA_NEXT_VALID, 0); |
| 484 | rt2x00_set_field32(&word, TXINFO_W0_USB_DMA_TX_BURST, |
| 485 | test_bit(ENTRY_TXD_BURST, &txdesc->flags)); |
| 486 | rt2x00_desc_write(txi, 0, word); |
| 487 | } |
| 488 | |
| 489 | /* |
| 490 | * TX data initialization |
| 491 | */ |
| 492 | static void rt2800usb_write_beacon(struct queue_entry *entry) |
| 493 | { |
| 494 | struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; |
| 495 | struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb); |
| 496 | unsigned int beacon_base; |
| 497 | u32 reg; |
| 498 | |
| 499 | /* |
| 500 | * Add the descriptor in front of the skb. |
| 501 | */ |
| 502 | skb_push(entry->skb, entry->queue->desc_size); |
| 503 | memcpy(entry->skb->data, skbdesc->desc, skbdesc->desc_len); |
| 504 | skbdesc->desc = entry->skb->data; |
| 505 | |
| 506 | /* |
| 507 | * Disable beaconing while we are reloading the beacon data, |
| 508 | * otherwise we might be sending out invalid data. |
| 509 | */ |
Bartlomiej Zolnierkiewicz | abbb505 | 2009-11-04 18:33:05 +0100 | [diff] [blame] | 510 | rt2800_register_read(rt2x00dev, BCN_TIME_CFG, ®); |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 511 | rt2x00_set_field32(®, BCN_TIME_CFG_BEACON_GEN, 0); |
Bartlomiej Zolnierkiewicz | abbb505 | 2009-11-04 18:33:05 +0100 | [diff] [blame] | 512 | rt2800_register_write(rt2x00dev, BCN_TIME_CFG, reg); |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 513 | |
| 514 | /* |
| 515 | * Write entire beacon with descriptor to register. |
| 516 | */ |
| 517 | beacon_base = HW_BEACON_OFFSET(entry->entry_idx); |
| 518 | rt2x00usb_vendor_request_large_buff(rt2x00dev, USB_MULTI_WRITE, |
| 519 | USB_VENDOR_REQUEST_OUT, beacon_base, |
| 520 | entry->skb->data, entry->skb->len, |
| 521 | REGISTER_TIMEOUT32(entry->skb->len)); |
| 522 | |
| 523 | /* |
| 524 | * Clean up the beacon skb. |
| 525 | */ |
| 526 | dev_kfree_skb(entry->skb); |
| 527 | entry->skb = NULL; |
| 528 | } |
| 529 | |
| 530 | static int rt2800usb_get_tx_data_len(struct queue_entry *entry) |
| 531 | { |
| 532 | int length; |
| 533 | |
| 534 | /* |
| 535 | * The length _must_ include 4 bytes padding, |
| 536 | * it should always be multiple of 4, |
| 537 | * but it must _not_ be a multiple of the USB packet size. |
| 538 | */ |
| 539 | length = roundup(entry->skb->len + 4, 4); |
| 540 | length += (4 * !(length % entry->queue->usb_maxpacket)); |
| 541 | |
| 542 | return length; |
| 543 | } |
| 544 | |
| 545 | static void rt2800usb_kick_tx_queue(struct rt2x00_dev *rt2x00dev, |
| 546 | const enum data_queue_qid queue) |
| 547 | { |
| 548 | u32 reg; |
| 549 | |
| 550 | if (queue != QID_BEACON) { |
| 551 | rt2x00usb_kick_tx_queue(rt2x00dev, queue); |
| 552 | return; |
| 553 | } |
| 554 | |
Bartlomiej Zolnierkiewicz | abbb505 | 2009-11-04 18:33:05 +0100 | [diff] [blame] | 555 | rt2800_register_read(rt2x00dev, BCN_TIME_CFG, ®); |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 556 | if (!rt2x00_get_field32(reg, BCN_TIME_CFG_BEACON_GEN)) { |
| 557 | rt2x00_set_field32(®, BCN_TIME_CFG_TSF_TICKING, 1); |
| 558 | rt2x00_set_field32(®, BCN_TIME_CFG_TBTT_ENABLE, 1); |
| 559 | rt2x00_set_field32(®, BCN_TIME_CFG_BEACON_GEN, 1); |
Bartlomiej Zolnierkiewicz | abbb505 | 2009-11-04 18:33:05 +0100 | [diff] [blame] | 560 | rt2800_register_write(rt2x00dev, BCN_TIME_CFG, reg); |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 561 | } |
| 562 | } |
| 563 | |
| 564 | /* |
| 565 | * RX control handlers |
| 566 | */ |
| 567 | static void rt2800usb_fill_rxdone(struct queue_entry *entry, |
| 568 | struct rxdone_entry_desc *rxdesc) |
| 569 | { |
| 570 | struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; |
| 571 | struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb); |
| 572 | __le32 *rxd = (__le32 *)entry->skb->data; |
| 573 | __le32 *rxwi; |
| 574 | u32 rxd0; |
| 575 | u32 rxwi0; |
| 576 | u32 rxwi1; |
| 577 | u32 rxwi2; |
| 578 | u32 rxwi3; |
| 579 | |
| 580 | /* |
| 581 | * Copy descriptor to the skbdesc->desc buffer, making it safe from |
| 582 | * moving of frame data in rt2x00usb. |
| 583 | */ |
| 584 | memcpy(skbdesc->desc, rxd, skbdesc->desc_len); |
| 585 | rxd = (__le32 *)skbdesc->desc; |
Bartlomiej Zolnierkiewicz | d42c8d8 | 2009-11-04 18:35:47 +0100 | [diff] [blame] | 586 | rxwi = &rxd[RXINFO_DESC_SIZE / sizeof(__le32)]; |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 587 | |
| 588 | /* |
| 589 | * It is now safe to read the descriptor on all architectures. |
| 590 | */ |
| 591 | rt2x00_desc_read(rxd, 0, &rxd0); |
| 592 | rt2x00_desc_read(rxwi, 0, &rxwi0); |
| 593 | rt2x00_desc_read(rxwi, 1, &rxwi1); |
| 594 | rt2x00_desc_read(rxwi, 2, &rxwi2); |
| 595 | rt2x00_desc_read(rxwi, 3, &rxwi3); |
| 596 | |
| 597 | if (rt2x00_get_field32(rxd0, RXD_W0_CRC_ERROR)) |
| 598 | rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC; |
| 599 | |
| 600 | if (test_bit(CONFIG_SUPPORT_HW_CRYPTO, &rt2x00dev->flags)) { |
| 601 | rxdesc->cipher = rt2x00_get_field32(rxwi0, RXWI_W0_UDF); |
| 602 | rxdesc->cipher_status = |
| 603 | rt2x00_get_field32(rxd0, RXD_W0_CIPHER_ERROR); |
| 604 | } |
| 605 | |
| 606 | if (rt2x00_get_field32(rxd0, RXD_W0_DECRYPTED)) { |
| 607 | /* |
| 608 | * Hardware has stripped IV/EIV data from 802.11 frame during |
| 609 | * decryption. Unfortunately the descriptor doesn't contain |
| 610 | * any fields with the EIV/IV data either, so they can't |
| 611 | * be restored by rt2x00lib. |
| 612 | */ |
| 613 | rxdesc->flags |= RX_FLAG_IV_STRIPPED; |
| 614 | |
| 615 | if (rxdesc->cipher_status == RX_CRYPTO_SUCCESS) |
| 616 | rxdesc->flags |= RX_FLAG_DECRYPTED; |
| 617 | else if (rxdesc->cipher_status == RX_CRYPTO_FAIL_MIC) |
| 618 | rxdesc->flags |= RX_FLAG_MMIC_ERROR; |
| 619 | } |
| 620 | |
| 621 | if (rt2x00_get_field32(rxd0, RXD_W0_MY_BSS)) |
| 622 | rxdesc->dev_flags |= RXDONE_MY_BSS; |
| 623 | |
Ivo van Doorn | 0fefe0f | 2009-08-17 18:54:50 +0200 | [diff] [blame] | 624 | if (rt2x00_get_field32(rxd0, RXD_W0_L2PAD)) { |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 625 | rxdesc->dev_flags |= RXDONE_L2PAD; |
Ivo van Doorn | 0fefe0f | 2009-08-17 18:54:50 +0200 | [diff] [blame] | 626 | skbdesc->flags |= SKBDESC_L2_PADDED; |
| 627 | } |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 628 | |
| 629 | if (rt2x00_get_field32(rxwi1, RXWI_W1_SHORT_GI)) |
| 630 | rxdesc->flags |= RX_FLAG_SHORT_GI; |
| 631 | |
| 632 | if (rt2x00_get_field32(rxwi1, RXWI_W1_BW)) |
| 633 | rxdesc->flags |= RX_FLAG_40MHZ; |
| 634 | |
| 635 | /* |
| 636 | * Detect RX rate, always use MCS as signal type. |
| 637 | */ |
| 638 | rxdesc->dev_flags |= RXDONE_SIGNAL_MCS; |
| 639 | rxdesc->rate_mode = rt2x00_get_field32(rxwi1, RXWI_W1_PHYMODE); |
| 640 | rxdesc->signal = rt2x00_get_field32(rxwi1, RXWI_W1_MCS); |
| 641 | |
| 642 | /* |
| 643 | * Mask of 0x8 bit to remove the short preamble flag. |
| 644 | */ |
| 645 | if (rxdesc->rate_mode == RATE_MODE_CCK) |
| 646 | rxdesc->signal &= ~0x8; |
| 647 | |
| 648 | rxdesc->rssi = |
| 649 | (rt2x00_get_field32(rxwi2, RXWI_W2_RSSI0) + |
| 650 | rt2x00_get_field32(rxwi2, RXWI_W2_RSSI1)) / 2; |
| 651 | |
| 652 | rxdesc->noise = |
| 653 | (rt2x00_get_field32(rxwi3, RXWI_W3_SNR0) + |
| 654 | rt2x00_get_field32(rxwi3, RXWI_W3_SNR1)) / 2; |
| 655 | |
| 656 | rxdesc->size = rt2x00_get_field32(rxwi0, RXWI_W0_MPDU_TOTAL_BYTE_COUNT); |
| 657 | |
| 658 | /* |
| 659 | * Remove RXWI descriptor from start of buffer. |
| 660 | */ |
| 661 | skb_pull(entry->skb, skbdesc->desc_len); |
| 662 | skb_trim(entry->skb, rxdesc->size); |
| 663 | } |
| 664 | |
| 665 | /* |
| 666 | * Device probe functions. |
| 667 | */ |
Bartlomiej Zolnierkiewicz | 7ab7132 | 2009-11-08 14:38:54 +0100 | [diff] [blame^] | 668 | static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev) |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 669 | { |
| 670 | u16 word; |
| 671 | u8 *mac; |
| 672 | u8 default_lna_gain; |
| 673 | |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 674 | /* |
| 675 | * Start validation of the data that has been read. |
| 676 | */ |
| 677 | mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0); |
| 678 | if (!is_valid_ether_addr(mac)) { |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 679 | random_ether_addr(mac); |
Johannes Berg | e91d833 | 2009-07-15 17:21:41 +0200 | [diff] [blame] | 680 | EEPROM(rt2x00dev, "MAC: %pM\n", mac); |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 681 | } |
| 682 | |
| 683 | rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &word); |
| 684 | if (word == 0xffff) { |
| 685 | rt2x00_set_field16(&word, EEPROM_ANTENNA_RXPATH, 2); |
| 686 | rt2x00_set_field16(&word, EEPROM_ANTENNA_TXPATH, 1); |
| 687 | rt2x00_set_field16(&word, EEPROM_ANTENNA_RF_TYPE, RF2820); |
| 688 | rt2x00_eeprom_write(rt2x00dev, EEPROM_ANTENNA, word); |
| 689 | EEPROM(rt2x00dev, "Antenna: 0x%04x\n", word); |
| 690 | } else if (rt2x00_rev(&rt2x00dev->chip) < RT2883_VERSION) { |
| 691 | /* |
Bartlomiej Zolnierkiewicz | 7ab7132 | 2009-11-08 14:38:54 +0100 | [diff] [blame^] | 692 | * There is a max of 2 RX streams for RT28x0 series |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 693 | */ |
| 694 | if (rt2x00_get_field16(word, EEPROM_ANTENNA_RXPATH) > 2) |
| 695 | rt2x00_set_field16(&word, EEPROM_ANTENNA_RXPATH, 2); |
| 696 | rt2x00_eeprom_write(rt2x00dev, EEPROM_ANTENNA, word); |
| 697 | } |
| 698 | |
| 699 | rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC, &word); |
| 700 | if (word == 0xffff) { |
| 701 | rt2x00_set_field16(&word, EEPROM_NIC_HW_RADIO, 0); |
| 702 | rt2x00_set_field16(&word, EEPROM_NIC_DYNAMIC_TX_AGC, 0); |
| 703 | rt2x00_set_field16(&word, EEPROM_NIC_EXTERNAL_LNA_BG, 0); |
| 704 | rt2x00_set_field16(&word, EEPROM_NIC_EXTERNAL_LNA_A, 0); |
| 705 | rt2x00_set_field16(&word, EEPROM_NIC_CARDBUS_ACCEL, 0); |
| 706 | rt2x00_set_field16(&word, EEPROM_NIC_BW40M_SB_BG, 0); |
| 707 | rt2x00_set_field16(&word, EEPROM_NIC_BW40M_SB_A, 0); |
| 708 | rt2x00_set_field16(&word, EEPROM_NIC_WPS_PBC, 0); |
| 709 | rt2x00_set_field16(&word, EEPROM_NIC_BW40M_BG, 0); |
| 710 | rt2x00_set_field16(&word, EEPROM_NIC_BW40M_A, 0); |
| 711 | rt2x00_eeprom_write(rt2x00dev, EEPROM_NIC, word); |
| 712 | EEPROM(rt2x00dev, "NIC: 0x%04x\n", word); |
| 713 | } |
| 714 | |
| 715 | rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &word); |
| 716 | if ((word & 0x00ff) == 0x00ff) { |
| 717 | rt2x00_set_field16(&word, EEPROM_FREQ_OFFSET, 0); |
| 718 | rt2x00_set_field16(&word, EEPROM_FREQ_LED_MODE, |
| 719 | LED_MODE_TXRX_ACTIVITY); |
| 720 | rt2x00_set_field16(&word, EEPROM_FREQ_LED_POLARITY, 0); |
| 721 | rt2x00_eeprom_write(rt2x00dev, EEPROM_FREQ, word); |
| 722 | rt2x00_eeprom_write(rt2x00dev, EEPROM_LED1, 0x5555); |
| 723 | rt2x00_eeprom_write(rt2x00dev, EEPROM_LED2, 0x2221); |
| 724 | rt2x00_eeprom_write(rt2x00dev, EEPROM_LED3, 0xa9f8); |
| 725 | EEPROM(rt2x00dev, "Freq: 0x%04x\n", word); |
| 726 | } |
| 727 | |
| 728 | /* |
| 729 | * During the LNA validation we are going to use |
| 730 | * lna0 as correct value. Note that EEPROM_LNA |
| 731 | * is never validated. |
| 732 | */ |
| 733 | rt2x00_eeprom_read(rt2x00dev, EEPROM_LNA, &word); |
| 734 | default_lna_gain = rt2x00_get_field16(word, EEPROM_LNA_A0); |
| 735 | |
| 736 | rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_BG, &word); |
| 737 | if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG_OFFSET0)) > 10) |
| 738 | rt2x00_set_field16(&word, EEPROM_RSSI_BG_OFFSET0, 0); |
| 739 | if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG_OFFSET1)) > 10) |
| 740 | rt2x00_set_field16(&word, EEPROM_RSSI_BG_OFFSET1, 0); |
| 741 | rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_BG, word); |
| 742 | |
| 743 | rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &word); |
| 744 | if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG2_OFFSET2)) > 10) |
| 745 | rt2x00_set_field16(&word, EEPROM_RSSI_BG2_OFFSET2, 0); |
| 746 | if (rt2x00_get_field16(word, EEPROM_RSSI_BG2_LNA_A1) == 0x00 || |
| 747 | rt2x00_get_field16(word, EEPROM_RSSI_BG2_LNA_A1) == 0xff) |
| 748 | rt2x00_set_field16(&word, EEPROM_RSSI_BG2_LNA_A1, |
| 749 | default_lna_gain); |
| 750 | rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_BG2, word); |
| 751 | |
| 752 | rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_A, &word); |
| 753 | if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A_OFFSET0)) > 10) |
| 754 | rt2x00_set_field16(&word, EEPROM_RSSI_A_OFFSET0, 0); |
| 755 | if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A_OFFSET1)) > 10) |
| 756 | rt2x00_set_field16(&word, EEPROM_RSSI_A_OFFSET1, 0); |
| 757 | rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_A, word); |
| 758 | |
| 759 | rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, &word); |
| 760 | if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A2_OFFSET2)) > 10) |
| 761 | rt2x00_set_field16(&word, EEPROM_RSSI_A2_OFFSET2, 0); |
| 762 | if (rt2x00_get_field16(word, EEPROM_RSSI_A2_LNA_A2) == 0x00 || |
| 763 | rt2x00_get_field16(word, EEPROM_RSSI_A2_LNA_A2) == 0xff) |
| 764 | rt2x00_set_field16(&word, EEPROM_RSSI_A2_LNA_A2, |
| 765 | default_lna_gain); |
| 766 | rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_A2, word); |
| 767 | |
| 768 | return 0; |
| 769 | } |
| 770 | |
Bartlomiej Zolnierkiewicz | 7ab7132 | 2009-11-08 14:38:54 +0100 | [diff] [blame^] | 771 | static int rt2800usb_validate_eeprom(struct rt2x00_dev *rt2x00dev) |
| 772 | { |
| 773 | rt2x00usb_eeprom_read(rt2x00dev, rt2x00dev->eeprom, EEPROM_SIZE); |
| 774 | |
| 775 | return rt2800_validate_eeprom(rt2x00dev); |
| 776 | } |
| 777 | |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 778 | static int rt2800usb_init_eeprom(struct rt2x00_dev *rt2x00dev) |
| 779 | { |
| 780 | u32 reg; |
| 781 | u16 value; |
| 782 | u16 eeprom; |
| 783 | |
| 784 | /* |
| 785 | * Read EEPROM word for configuration. |
| 786 | */ |
| 787 | rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom); |
| 788 | |
| 789 | /* |
| 790 | * Identify RF chipset. |
| 791 | */ |
| 792 | value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE); |
Bartlomiej Zolnierkiewicz | abbb505 | 2009-11-04 18:33:05 +0100 | [diff] [blame] | 793 | rt2800_register_read(rt2x00dev, MAC_CSR0, ®); |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 794 | |
Bartlomiej Zolnierkiewicz | 7ab7132 | 2009-11-08 14:38:54 +0100 | [diff] [blame^] | 795 | if (rt2x00_intf_is_usb(rt2x00dev)) { |
| 796 | struct rt2x00_chip *chip = &rt2x00dev->chip; |
| 797 | |
| 798 | rt2x00_set_chip(rt2x00dev, RT2870, value, reg); |
| 799 | |
| 800 | /* |
| 801 | * The check for rt2860 is not a typo, some rt2870 hardware |
| 802 | * identifies itself as rt2860 in the CSR register. |
| 803 | */ |
| 804 | if (!rt2x00_check_rev(chip, 0xfff00000, 0x28600000) && |
| 805 | !rt2x00_check_rev(chip, 0xfff00000, 0x28700000) && |
| 806 | !rt2x00_check_rev(chip, 0xfff00000, 0x28800000) && |
| 807 | !rt2x00_check_rev(chip, 0xffff0000, 0x30700000)) { |
| 808 | ERROR(rt2x00dev, "Invalid RT chipset detected.\n"); |
| 809 | return -ENODEV; |
| 810 | } |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 811 | } |
| 812 | |
| 813 | if (!rt2x00_rf(&rt2x00dev->chip, RF2820) && |
| 814 | !rt2x00_rf(&rt2x00dev->chip, RF2850) && |
| 815 | !rt2x00_rf(&rt2x00dev->chip, RF2720) && |
| 816 | !rt2x00_rf(&rt2x00dev->chip, RF2750) && |
| 817 | !rt2x00_rf(&rt2x00dev->chip, RF3020) && |
| 818 | !rt2x00_rf(&rt2x00dev->chip, RF2020)) { |
| 819 | ERROR(rt2x00dev, "Invalid RF chipset detected.\n"); |
| 820 | return -ENODEV; |
| 821 | } |
| 822 | |
| 823 | /* |
| 824 | * Identify default antenna configuration. |
| 825 | */ |
| 826 | rt2x00dev->default_ant.tx = |
| 827 | rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH); |
| 828 | rt2x00dev->default_ant.rx = |
| 829 | rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH); |
| 830 | |
| 831 | /* |
| 832 | * Read frequency offset and RF programming sequence. |
| 833 | */ |
| 834 | rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &eeprom); |
| 835 | rt2x00dev->freq_offset = rt2x00_get_field16(eeprom, EEPROM_FREQ_OFFSET); |
| 836 | |
| 837 | /* |
| 838 | * Read external LNA informations. |
| 839 | */ |
| 840 | rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC, &eeprom); |
| 841 | |
| 842 | if (rt2x00_get_field16(eeprom, EEPROM_NIC_EXTERNAL_LNA_A)) |
| 843 | __set_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags); |
| 844 | if (rt2x00_get_field16(eeprom, EEPROM_NIC_EXTERNAL_LNA_BG)) |
| 845 | __set_bit(CONFIG_EXTERNAL_LNA_BG, &rt2x00dev->flags); |
| 846 | |
| 847 | /* |
| 848 | * Detect if this device has an hardware controlled radio. |
| 849 | */ |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 850 | if (rt2x00_get_field16(eeprom, EEPROM_NIC_HW_RADIO)) |
| 851 | __set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags); |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 852 | |
| 853 | /* |
| 854 | * Store led settings, for correct led behaviour. |
| 855 | */ |
| 856 | #ifdef CONFIG_RT2X00_LIB_LEDS |
Bartlomiej Zolnierkiewicz | f445061 | 2009-11-04 18:36:40 +0100 | [diff] [blame] | 857 | rt2800_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO); |
| 858 | rt2800_init_led(rt2x00dev, &rt2x00dev->led_assoc, LED_TYPE_ASSOC); |
| 859 | rt2800_init_led(rt2x00dev, &rt2x00dev->led_qual, LED_TYPE_QUALITY); |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 860 | |
| 861 | rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, |
| 862 | &rt2x00dev->led_mcu_reg); |
| 863 | #endif /* CONFIG_RT2X00_LIB_LEDS */ |
| 864 | |
| 865 | return 0; |
| 866 | } |
| 867 | |
| 868 | /* |
| 869 | * RF value list for rt2870 |
| 870 | * Supports: 2.4 GHz (all) & 5.2 GHz (RF2850 & RF2750) |
| 871 | */ |
| 872 | static const struct rf_channel rf_vals[] = { |
| 873 | { 1, 0x18402ecc, 0x184c0786, 0x1816b455, 0x1800510b }, |
| 874 | { 2, 0x18402ecc, 0x184c0786, 0x18168a55, 0x1800519f }, |
| 875 | { 3, 0x18402ecc, 0x184c078a, 0x18168a55, 0x1800518b }, |
| 876 | { 4, 0x18402ecc, 0x184c078a, 0x18168a55, 0x1800519f }, |
| 877 | { 5, 0x18402ecc, 0x184c078e, 0x18168a55, 0x1800518b }, |
| 878 | { 6, 0x18402ecc, 0x184c078e, 0x18168a55, 0x1800519f }, |
| 879 | { 7, 0x18402ecc, 0x184c0792, 0x18168a55, 0x1800518b }, |
| 880 | { 8, 0x18402ecc, 0x184c0792, 0x18168a55, 0x1800519f }, |
| 881 | { 9, 0x18402ecc, 0x184c0796, 0x18168a55, 0x1800518b }, |
| 882 | { 10, 0x18402ecc, 0x184c0796, 0x18168a55, 0x1800519f }, |
| 883 | { 11, 0x18402ecc, 0x184c079a, 0x18168a55, 0x1800518b }, |
| 884 | { 12, 0x18402ecc, 0x184c079a, 0x18168a55, 0x1800519f }, |
| 885 | { 13, 0x18402ecc, 0x184c079e, 0x18168a55, 0x1800518b }, |
| 886 | { 14, 0x18402ecc, 0x184c07a2, 0x18168a55, 0x18005193 }, |
| 887 | |
| 888 | /* 802.11 UNI / HyperLan 2 */ |
| 889 | { 36, 0x18402ecc, 0x184c099a, 0x18158a55, 0x180ed1a3 }, |
| 890 | { 38, 0x18402ecc, 0x184c099e, 0x18158a55, 0x180ed193 }, |
| 891 | { 40, 0x18402ec8, 0x184c0682, 0x18158a55, 0x180ed183 }, |
| 892 | { 44, 0x18402ec8, 0x184c0682, 0x18158a55, 0x180ed1a3 }, |
| 893 | { 46, 0x18402ec8, 0x184c0686, 0x18158a55, 0x180ed18b }, |
| 894 | { 48, 0x18402ec8, 0x184c0686, 0x18158a55, 0x180ed19b }, |
| 895 | { 52, 0x18402ec8, 0x184c068a, 0x18158a55, 0x180ed193 }, |
| 896 | { 54, 0x18402ec8, 0x184c068a, 0x18158a55, 0x180ed1a3 }, |
| 897 | { 56, 0x18402ec8, 0x184c068e, 0x18158a55, 0x180ed18b }, |
| 898 | { 60, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed183 }, |
| 899 | { 62, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed193 }, |
| 900 | { 64, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed1a3 }, |
| 901 | |
| 902 | /* 802.11 HyperLan 2 */ |
| 903 | { 100, 0x18402ec8, 0x184c06b2, 0x18178a55, 0x180ed783 }, |
| 904 | { 102, 0x18402ec8, 0x184c06b2, 0x18578a55, 0x180ed793 }, |
| 905 | { 104, 0x18402ec8, 0x185c06b2, 0x18578a55, 0x180ed1a3 }, |
| 906 | { 108, 0x18402ecc, 0x185c0a32, 0x18578a55, 0x180ed193 }, |
| 907 | { 110, 0x18402ecc, 0x184c0a36, 0x18178a55, 0x180ed183 }, |
| 908 | { 112, 0x18402ecc, 0x184c0a36, 0x18178a55, 0x180ed19b }, |
| 909 | { 116, 0x18402ecc, 0x184c0a3a, 0x18178a55, 0x180ed1a3 }, |
| 910 | { 118, 0x18402ecc, 0x184c0a3e, 0x18178a55, 0x180ed193 }, |
| 911 | { 120, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed183 }, |
| 912 | { 124, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed193 }, |
| 913 | { 126, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed15b }, |
| 914 | { 128, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed1a3 }, |
| 915 | { 132, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed18b }, |
| 916 | { 134, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed193 }, |
| 917 | { 136, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed19b }, |
| 918 | { 140, 0x18402ec4, 0x184c038a, 0x18178a55, 0x180ed183 }, |
| 919 | |
| 920 | /* 802.11 UNII */ |
| 921 | { 149, 0x18402ec4, 0x184c038a, 0x18178a55, 0x180ed1a7 }, |
| 922 | { 151, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed187 }, |
| 923 | { 153, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed18f }, |
| 924 | { 157, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed19f }, |
| 925 | { 159, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed1a7 }, |
| 926 | { 161, 0x18402ec4, 0x184c0392, 0x18178a55, 0x180ed187 }, |
| 927 | { 165, 0x18402ec4, 0x184c0392, 0x18178a55, 0x180ed197 }, |
| 928 | { 167, 0x18402ec4, 0x184c03d2, 0x18179855, 0x1815531f }, |
| 929 | { 169, 0x18402ec4, 0x184c03d2, 0x18179855, 0x18155327 }, |
| 930 | { 171, 0x18402ec4, 0x184c03d6, 0x18179855, 0x18155307 }, |
| 931 | { 173, 0x18402ec4, 0x184c03d6, 0x18179855, 0x1815530f }, |
| 932 | |
| 933 | /* 802.11 Japan */ |
| 934 | { 184, 0x15002ccc, 0x1500491e, 0x1509be55, 0x150c0a0b }, |
| 935 | { 188, 0x15002ccc, 0x15004922, 0x1509be55, 0x150c0a13 }, |
| 936 | { 192, 0x15002ccc, 0x15004926, 0x1509be55, 0x150c0a1b }, |
| 937 | { 196, 0x15002ccc, 0x1500492a, 0x1509be55, 0x150c0a23 }, |
| 938 | { 208, 0x15002ccc, 0x1500493a, 0x1509be55, 0x150c0a13 }, |
| 939 | { 212, 0x15002ccc, 0x1500493e, 0x1509be55, 0x150c0a1b }, |
| 940 | { 216, 0x15002ccc, 0x15004982, 0x1509be55, 0x150c0a23 }, |
| 941 | }; |
| 942 | |
| 943 | /* |
| 944 | * RF value list for rt3070 |
| 945 | * Supports: 2.4 GHz |
| 946 | */ |
| 947 | static const struct rf_channel rf_vals_3070[] = { |
| 948 | {1, 241, 2, 2 }, |
| 949 | {2, 241, 2, 7 }, |
| 950 | {3, 242, 2, 2 }, |
| 951 | {4, 242, 2, 7 }, |
| 952 | {5, 243, 2, 2 }, |
| 953 | {6, 243, 2, 7 }, |
| 954 | {7, 244, 2, 2 }, |
| 955 | {8, 244, 2, 7 }, |
| 956 | {9, 245, 2, 2 }, |
| 957 | {10, 245, 2, 7 }, |
| 958 | {11, 246, 2, 2 }, |
| 959 | {12, 246, 2, 7 }, |
| 960 | {13, 247, 2, 2 }, |
| 961 | {14, 248, 2, 4 }, |
| 962 | }; |
| 963 | |
| 964 | static int rt2800usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev) |
| 965 | { |
| 966 | struct hw_mode_spec *spec = &rt2x00dev->spec; |
| 967 | struct channel_info *info; |
| 968 | char *tx_power1; |
| 969 | char *tx_power2; |
| 970 | unsigned int i; |
| 971 | u16 eeprom; |
| 972 | |
| 973 | /* |
| 974 | * Initialize all hw fields. |
| 975 | */ |
| 976 | rt2x00dev->hw->flags = |
| 977 | IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | |
| 978 | IEEE80211_HW_SIGNAL_DBM | |
| 979 | IEEE80211_HW_SUPPORTS_PS | |
| 980 | IEEE80211_HW_PS_NULLFUNC_STACK; |
| 981 | rt2x00dev->hw->extra_tx_headroom = TXINFO_DESC_SIZE + TXWI_DESC_SIZE; |
| 982 | |
| 983 | SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev); |
| 984 | SET_IEEE80211_PERM_ADDR(rt2x00dev->hw, |
| 985 | rt2x00_eeprom_addr(rt2x00dev, |
| 986 | EEPROM_MAC_ADDR_0)); |
| 987 | |
| 988 | rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom); |
| 989 | |
| 990 | /* |
| 991 | * Initialize HT information. |
| 992 | */ |
| 993 | spec->ht.ht_supported = true; |
| 994 | spec->ht.cap = |
| 995 | IEEE80211_HT_CAP_SUP_WIDTH_20_40 | |
| 996 | IEEE80211_HT_CAP_GRN_FLD | |
| 997 | IEEE80211_HT_CAP_SGI_20 | |
| 998 | IEEE80211_HT_CAP_SGI_40 | |
| 999 | IEEE80211_HT_CAP_TX_STBC | |
| 1000 | IEEE80211_HT_CAP_RX_STBC | |
| 1001 | IEEE80211_HT_CAP_PSMP_SUPPORT; |
| 1002 | spec->ht.ampdu_factor = 3; |
| 1003 | spec->ht.ampdu_density = 4; |
| 1004 | spec->ht.mcs.tx_params = |
| 1005 | IEEE80211_HT_MCS_TX_DEFINED | |
| 1006 | IEEE80211_HT_MCS_TX_RX_DIFF | |
| 1007 | ((rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH) - 1) << |
| 1008 | IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT); |
| 1009 | |
| 1010 | switch (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH)) { |
| 1011 | case 3: |
| 1012 | spec->ht.mcs.rx_mask[2] = 0xff; |
| 1013 | case 2: |
| 1014 | spec->ht.mcs.rx_mask[1] = 0xff; |
| 1015 | case 1: |
| 1016 | spec->ht.mcs.rx_mask[0] = 0xff; |
| 1017 | spec->ht.mcs.rx_mask[4] = 0x1; /* MCS32 */ |
| 1018 | break; |
| 1019 | } |
| 1020 | |
| 1021 | /* |
| 1022 | * Initialize hw_mode information. |
| 1023 | */ |
| 1024 | spec->supported_bands = SUPPORT_BAND_2GHZ; |
| 1025 | spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM; |
| 1026 | |
| 1027 | if (rt2x00_rf(&rt2x00dev->chip, RF2820) || |
| 1028 | rt2x00_rf(&rt2x00dev->chip, RF2720)) { |
| 1029 | spec->num_channels = 14; |
| 1030 | spec->channels = rf_vals; |
| 1031 | } else if (rt2x00_rf(&rt2x00dev->chip, RF2850) || |
| 1032 | rt2x00_rf(&rt2x00dev->chip, RF2750)) { |
| 1033 | spec->supported_bands |= SUPPORT_BAND_5GHZ; |
| 1034 | spec->num_channels = ARRAY_SIZE(rf_vals); |
| 1035 | spec->channels = rf_vals; |
| 1036 | } else if (rt2x00_rf(&rt2x00dev->chip, RF3020) || |
| 1037 | rt2x00_rf(&rt2x00dev->chip, RF2020)) { |
| 1038 | spec->num_channels = ARRAY_SIZE(rf_vals_3070); |
| 1039 | spec->channels = rf_vals_3070; |
| 1040 | } |
| 1041 | |
| 1042 | /* |
| 1043 | * Create channel information array |
| 1044 | */ |
| 1045 | info = kzalloc(spec->num_channels * sizeof(*info), GFP_KERNEL); |
| 1046 | if (!info) |
| 1047 | return -ENOMEM; |
| 1048 | |
| 1049 | spec->channels_info = info; |
| 1050 | |
| 1051 | tx_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG1); |
| 1052 | tx_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG2); |
| 1053 | |
| 1054 | for (i = 0; i < 14; i++) { |
| 1055 | info[i].tx_power1 = TXPOWER_G_FROM_DEV(tx_power1[i]); |
| 1056 | info[i].tx_power2 = TXPOWER_G_FROM_DEV(tx_power2[i]); |
| 1057 | } |
| 1058 | |
| 1059 | if (spec->num_channels > 14) { |
| 1060 | tx_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A1); |
| 1061 | tx_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A2); |
| 1062 | |
| 1063 | for (i = 14; i < spec->num_channels; i++) { |
| 1064 | info[i].tx_power1 = TXPOWER_A_FROM_DEV(tx_power1[i]); |
| 1065 | info[i].tx_power2 = TXPOWER_A_FROM_DEV(tx_power2[i]); |
| 1066 | } |
| 1067 | } |
| 1068 | |
| 1069 | return 0; |
| 1070 | } |
| 1071 | |
Bartlomiej Zolnierkiewicz | 7a345d3d | 2009-11-04 18:34:53 +0100 | [diff] [blame] | 1072 | static const struct rt2800_ops rt2800usb_rt2800_ops = { |
| 1073 | .register_read = rt2x00usb_register_read, |
| 1074 | .register_write = rt2x00usb_register_write, |
| 1075 | .register_write_lock = rt2x00usb_register_write_lock, |
| 1076 | |
| 1077 | .register_multiread = rt2x00usb_register_multiread, |
| 1078 | .register_multiwrite = rt2x00usb_register_multiwrite, |
| 1079 | |
| 1080 | .regbusy_read = rt2x00usb_regbusy_read, |
| 1081 | }; |
| 1082 | |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 1083 | static int rt2800usb_probe_hw(struct rt2x00_dev *rt2x00dev) |
| 1084 | { |
| 1085 | int retval; |
| 1086 | |
Bartlomiej Zolnierkiewicz | 7a345d3d | 2009-11-04 18:34:53 +0100 | [diff] [blame] | 1087 | rt2x00dev->priv = (void *)&rt2800usb_rt2800_ops; |
| 1088 | |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 1089 | /* |
| 1090 | * Allocate eeprom data. |
| 1091 | */ |
| 1092 | retval = rt2800usb_validate_eeprom(rt2x00dev); |
| 1093 | if (retval) |
| 1094 | return retval; |
| 1095 | |
| 1096 | retval = rt2800usb_init_eeprom(rt2x00dev); |
| 1097 | if (retval) |
| 1098 | return retval; |
| 1099 | |
| 1100 | /* |
| 1101 | * Initialize hw specifications. |
| 1102 | */ |
| 1103 | retval = rt2800usb_probe_hw_mode(rt2x00dev); |
| 1104 | if (retval) |
| 1105 | return retval; |
| 1106 | |
| 1107 | /* |
Igor Perminov | 1afcfd54 | 2009-08-08 23:55:55 +0200 | [diff] [blame] | 1108 | * This device has multiple filters for control frames |
| 1109 | * and has a separate filter for PS Poll frames. |
| 1110 | */ |
| 1111 | __set_bit(DRIVER_SUPPORT_CONTROL_FILTERS, &rt2x00dev->flags); |
| 1112 | __set_bit(DRIVER_SUPPORT_CONTROL_FILTER_PSPOLL, &rt2x00dev->flags); |
| 1113 | |
| 1114 | /* |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 1115 | * This device requires firmware. |
| 1116 | */ |
| 1117 | __set_bit(DRIVER_REQUIRE_FIRMWARE, &rt2x00dev->flags); |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 1118 | __set_bit(DRIVER_REQUIRE_L2PAD, &rt2x00dev->flags); |
| 1119 | if (!modparam_nohwcrypt) |
| 1120 | __set_bit(CONFIG_SUPPORT_HW_CRYPTO, &rt2x00dev->flags); |
| 1121 | |
| 1122 | /* |
| 1123 | * Set the rssi offset. |
| 1124 | */ |
| 1125 | rt2x00dev->rssi_offset = DEFAULT_RSSI_OFFSET; |
| 1126 | |
| 1127 | return 0; |
| 1128 | } |
| 1129 | |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 1130 | static const struct rt2x00lib_ops rt2800usb_rt2x00_ops = { |
| 1131 | .probe_hw = rt2800usb_probe_hw, |
| 1132 | .get_firmware_name = rt2800usb_get_firmware_name, |
| 1133 | .check_firmware = rt2800usb_check_firmware, |
| 1134 | .load_firmware = rt2800usb_load_firmware, |
| 1135 | .initialize = rt2x00usb_initialize, |
| 1136 | .uninitialize = rt2x00usb_uninitialize, |
| 1137 | .clear_entry = rt2x00usb_clear_entry, |
| 1138 | .set_device_state = rt2800usb_set_device_state, |
Bartlomiej Zolnierkiewicz | f445061 | 2009-11-04 18:36:40 +0100 | [diff] [blame] | 1139 | .rfkill_poll = rt2800_rfkill_poll, |
| 1140 | .link_stats = rt2800_link_stats, |
| 1141 | .reset_tuner = rt2800_reset_tuner, |
| 1142 | .link_tuner = rt2800_link_tuner, |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 1143 | .write_tx_desc = rt2800usb_write_tx_desc, |
| 1144 | .write_tx_data = rt2x00usb_write_tx_data, |
| 1145 | .write_beacon = rt2800usb_write_beacon, |
| 1146 | .get_tx_data_len = rt2800usb_get_tx_data_len, |
| 1147 | .kick_tx_queue = rt2800usb_kick_tx_queue, |
| 1148 | .kill_tx_queue = rt2x00usb_kill_tx_queue, |
| 1149 | .fill_rxdone = rt2800usb_fill_rxdone, |
Bartlomiej Zolnierkiewicz | f445061 | 2009-11-04 18:36:40 +0100 | [diff] [blame] | 1150 | .config_shared_key = rt2800_config_shared_key, |
| 1151 | .config_pairwise_key = rt2800_config_pairwise_key, |
| 1152 | .config_filter = rt2800_config_filter, |
| 1153 | .config_intf = rt2800_config_intf, |
| 1154 | .config_erp = rt2800_config_erp, |
| 1155 | .config_ant = rt2800_config_ant, |
| 1156 | .config = rt2800_config, |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 1157 | }; |
| 1158 | |
| 1159 | static const struct data_queue_desc rt2800usb_queue_rx = { |
| 1160 | .entry_num = RX_ENTRIES, |
| 1161 | .data_size = AGGREGATION_SIZE, |
Bartlomiej Zolnierkiewicz | d42c8d8 | 2009-11-04 18:35:47 +0100 | [diff] [blame] | 1162 | .desc_size = RXINFO_DESC_SIZE + RXWI_DESC_SIZE, |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 1163 | .priv_size = sizeof(struct queue_entry_priv_usb), |
| 1164 | }; |
| 1165 | |
| 1166 | static const struct data_queue_desc rt2800usb_queue_tx = { |
| 1167 | .entry_num = TX_ENTRIES, |
| 1168 | .data_size = AGGREGATION_SIZE, |
| 1169 | .desc_size = TXINFO_DESC_SIZE + TXWI_DESC_SIZE, |
| 1170 | .priv_size = sizeof(struct queue_entry_priv_usb), |
| 1171 | }; |
| 1172 | |
| 1173 | static const struct data_queue_desc rt2800usb_queue_bcn = { |
| 1174 | .entry_num = 8 * BEACON_ENTRIES, |
| 1175 | .data_size = MGMT_FRAME_SIZE, |
| 1176 | .desc_size = TXINFO_DESC_SIZE + TXWI_DESC_SIZE, |
| 1177 | .priv_size = sizeof(struct queue_entry_priv_usb), |
| 1178 | }; |
| 1179 | |
| 1180 | static const struct rt2x00_ops rt2800usb_ops = { |
| 1181 | .name = KBUILD_MODNAME, |
| 1182 | .max_sta_intf = 1, |
| 1183 | .max_ap_intf = 8, |
| 1184 | .eeprom_size = EEPROM_SIZE, |
| 1185 | .rf_size = RF_SIZE, |
| 1186 | .tx_queues = NUM_TX_QUEUES, |
| 1187 | .rx = &rt2800usb_queue_rx, |
| 1188 | .tx = &rt2800usb_queue_tx, |
| 1189 | .bcn = &rt2800usb_queue_bcn, |
| 1190 | .lib = &rt2800usb_rt2x00_ops, |
Bartlomiej Zolnierkiewicz | 2ce3399 | 2009-11-04 18:37:05 +0100 | [diff] [blame] | 1191 | .hw = &rt2800_mac80211_ops, |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 1192 | #ifdef CONFIG_RT2X00_LIB_DEBUGFS |
Bartlomiej Zolnierkiewicz | f445061 | 2009-11-04 18:36:40 +0100 | [diff] [blame] | 1193 | .debugfs = &rt2800_rt2x00debug, |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 1194 | #endif /* CONFIG_RT2X00_LIB_DEBUGFS */ |
| 1195 | }; |
| 1196 | |
| 1197 | /* |
| 1198 | * rt2800usb module information. |
| 1199 | */ |
| 1200 | static struct usb_device_id rt2800usb_device_table[] = { |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 1201 | /* Abocom */ |
| 1202 | { USB_DEVICE(0x07b8, 0x2870), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1203 | { USB_DEVICE(0x07b8, 0x2770), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1204 | { USB_DEVICE(0x07b8, 0x3070), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1205 | { USB_DEVICE(0x07b8, 0x3071), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1206 | { USB_DEVICE(0x07b8, 0x3072), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1207 | { USB_DEVICE(0x1482, 0x3c09), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1208 | /* AirTies */ |
| 1209 | { USB_DEVICE(0x1eda, 0x2310), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1210 | /* Amigo */ |
| 1211 | { USB_DEVICE(0x0e0b, 0x9031), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1212 | { USB_DEVICE(0x0e0b, 0x9041), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1213 | /* Amit */ |
| 1214 | { USB_DEVICE(0x15c5, 0x0008), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1215 | /* ASUS */ |
| 1216 | { USB_DEVICE(0x0b05, 0x1731), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1217 | { USB_DEVICE(0x0b05, 0x1732), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1218 | { USB_DEVICE(0x0b05, 0x1742), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1219 | { USB_DEVICE(0x0b05, 0x1760), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1220 | { USB_DEVICE(0x0b05, 0x1761), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1221 | /* AzureWave */ |
| 1222 | { USB_DEVICE(0x13d3, 0x3247), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1223 | { USB_DEVICE(0x13d3, 0x3262), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1224 | { USB_DEVICE(0x13d3, 0x3273), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1225 | { USB_DEVICE(0x13d3, 0x3284), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1226 | /* Belkin */ |
| 1227 | { USB_DEVICE(0x050d, 0x8053), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1228 | { USB_DEVICE(0x050d, 0x805c), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1229 | { USB_DEVICE(0x050d, 0x815c), USB_DEVICE_DATA(&rt2800usb_ops) }, |
Ivo van Doorn | 2c617b0 | 2009-05-19 07:26:04 +0200 | [diff] [blame] | 1230 | { USB_DEVICE(0x050d, 0x825a), USB_DEVICE_DATA(&rt2800usb_ops) }, |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 1231 | /* Buffalo */ |
| 1232 | { USB_DEVICE(0x0411, 0x00e8), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1233 | { USB_DEVICE(0x0411, 0x012e), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1234 | /* Conceptronic */ |
| 1235 | { USB_DEVICE(0x14b2, 0x3c06), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1236 | { USB_DEVICE(0x14b2, 0x3c07), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1237 | { USB_DEVICE(0x14b2, 0x3c08), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1238 | { USB_DEVICE(0x14b2, 0x3c09), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1239 | { USB_DEVICE(0x14b2, 0x3c11), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1240 | { USB_DEVICE(0x14b2, 0x3c12), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1241 | { USB_DEVICE(0x14b2, 0x3c23), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1242 | { USB_DEVICE(0x14b2, 0x3c25), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1243 | { USB_DEVICE(0x14b2, 0x3c27), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1244 | { USB_DEVICE(0x14b2, 0x3c28), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1245 | /* Corega */ |
| 1246 | { USB_DEVICE(0x07aa, 0x002f), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1247 | { USB_DEVICE(0x07aa, 0x003c), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1248 | { USB_DEVICE(0x07aa, 0x003f), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1249 | { USB_DEVICE(0x18c5, 0x0008), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1250 | { USB_DEVICE(0x18c5, 0x0012), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1251 | /* D-Link */ |
| 1252 | { USB_DEVICE(0x07d1, 0x3c09), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1253 | { USB_DEVICE(0x07d1, 0x3c0a), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1254 | { USB_DEVICE(0x07d1, 0x3c0b), USB_DEVICE_DATA(&rt2800usb_ops) }, |
Ivo van Doorn | ce2ebc9 | 2009-05-22 21:33:21 +0200 | [diff] [blame] | 1255 | { USB_DEVICE(0x07d1, 0x3c0d), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1256 | { USB_DEVICE(0x07d1, 0x3c0e), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1257 | { USB_DEVICE(0x07d1, 0x3c0f), USB_DEVICE_DATA(&rt2800usb_ops) }, |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 1258 | { USB_DEVICE(0x07d1, 0x3c11), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1259 | { USB_DEVICE(0x07d1, 0x3c13), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1260 | /* Edimax */ |
| 1261 | { USB_DEVICE(0x7392, 0x7711), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1262 | { USB_DEVICE(0x7392, 0x7717), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1263 | { USB_DEVICE(0x7392, 0x7718), USB_DEVICE_DATA(&rt2800usb_ops) }, |
Ivo van Doorn | ce2ebc9 | 2009-05-22 21:33:21 +0200 | [diff] [blame] | 1264 | /* Encore */ |
| 1265 | { USB_DEVICE(0x203d, 0x1480), USB_DEVICE_DATA(&rt2800usb_ops) }, |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 1266 | /* EnGenius */ |
| 1267 | { USB_DEVICE(0X1740, 0x9701), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1268 | { USB_DEVICE(0x1740, 0x9702), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1269 | { USB_DEVICE(0x1740, 0x9703), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1270 | { USB_DEVICE(0x1740, 0x9705), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1271 | { USB_DEVICE(0x1740, 0x9706), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1272 | { USB_DEVICE(0x1740, 0x9801), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1273 | /* Gemtek */ |
| 1274 | { USB_DEVICE(0x15a9, 0x0010), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1275 | /* Gigabyte */ |
| 1276 | { USB_DEVICE(0x1044, 0x800b), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1277 | { USB_DEVICE(0x1044, 0x800c), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1278 | { USB_DEVICE(0x1044, 0x800d), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1279 | /* Hawking */ |
| 1280 | { USB_DEVICE(0x0e66, 0x0001), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1281 | { USB_DEVICE(0x0e66, 0x0003), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1282 | { USB_DEVICE(0x0e66, 0x0009), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1283 | { USB_DEVICE(0x0e66, 0x000b), USB_DEVICE_DATA(&rt2800usb_ops) }, |
Ivo van Doorn | ce2ebc9 | 2009-05-22 21:33:21 +0200 | [diff] [blame] | 1284 | /* I-O DATA */ |
| 1285 | { USB_DEVICE(0x04bb, 0x0945), USB_DEVICE_DATA(&rt2800usb_ops) }, |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 1286 | /* LevelOne */ |
| 1287 | { USB_DEVICE(0x1740, 0x0605), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1288 | { USB_DEVICE(0x1740, 0x0615), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1289 | /* Linksys */ |
| 1290 | { USB_DEVICE(0x1737, 0x0070), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1291 | { USB_DEVICE(0x1737, 0x0071), USB_DEVICE_DATA(&rt2800usb_ops) }, |
Ivo van Doorn | e430d60 | 2009-04-27 23:58:31 +0200 | [diff] [blame] | 1292 | { USB_DEVICE(0x1737, 0x0077), USB_DEVICE_DATA(&rt2800usb_ops) }, |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 1293 | /* Logitec */ |
| 1294 | { USB_DEVICE(0x0789, 0x0162), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1295 | { USB_DEVICE(0x0789, 0x0163), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1296 | { USB_DEVICE(0x0789, 0x0164), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1297 | /* Motorola */ |
| 1298 | { USB_DEVICE(0x100d, 0x9031), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1299 | { USB_DEVICE(0x100d, 0x9032), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1300 | /* Ovislink */ |
| 1301 | { USB_DEVICE(0x1b75, 0x3072), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1302 | /* Pegatron */ |
| 1303 | { USB_DEVICE(0x1d4d, 0x0002), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1304 | { USB_DEVICE(0x1d4d, 0x000c), USB_DEVICE_DATA(&rt2800usb_ops) }, |
Ivo van Doorn | ce2ebc9 | 2009-05-22 21:33:21 +0200 | [diff] [blame] | 1305 | { USB_DEVICE(0x1d4d, 0x000e), USB_DEVICE_DATA(&rt2800usb_ops) }, |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 1306 | /* Philips */ |
| 1307 | { USB_DEVICE(0x0471, 0x200f), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1308 | /* Planex */ |
| 1309 | { USB_DEVICE(0x2019, 0xed06), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1310 | { USB_DEVICE(0x2019, 0xab24), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1311 | { USB_DEVICE(0x2019, 0xab25), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1312 | /* Qcom */ |
| 1313 | { USB_DEVICE(0x18e8, 0x6259), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1314 | /* Quanta */ |
| 1315 | { USB_DEVICE(0x1a32, 0x0304), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1316 | /* Ralink */ |
Ivo van Doorn | ce2ebc9 | 2009-05-22 21:33:21 +0200 | [diff] [blame] | 1317 | { USB_DEVICE(0x0db0, 0x3820), USB_DEVICE_DATA(&rt2800usb_ops) }, |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 1318 | { USB_DEVICE(0x0db0, 0x6899), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1319 | { USB_DEVICE(0x148f, 0x2070), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1320 | { USB_DEVICE(0x148f, 0x2770), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1321 | { USB_DEVICE(0x148f, 0x2870), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1322 | { USB_DEVICE(0x148f, 0x3070), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1323 | { USB_DEVICE(0x148f, 0x3071), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1324 | { USB_DEVICE(0x148f, 0x3072), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1325 | { USB_DEVICE(0x148f, 0x3572), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1326 | /* Samsung */ |
| 1327 | { USB_DEVICE(0x04e8, 0x2018), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1328 | /* Siemens */ |
| 1329 | { USB_DEVICE(0x129b, 0x1828), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1330 | /* Sitecom */ |
| 1331 | { USB_DEVICE(0x0df6, 0x0017), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1332 | { USB_DEVICE(0x0df6, 0x002b), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1333 | { USB_DEVICE(0x0df6, 0x002c), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1334 | { USB_DEVICE(0x0df6, 0x002d), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1335 | { USB_DEVICE(0x0df6, 0x0039), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1336 | { USB_DEVICE(0x0df6, 0x003b), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1337 | { USB_DEVICE(0x0df6, 0x003c), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1338 | { USB_DEVICE(0x0df6, 0x003d), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1339 | { USB_DEVICE(0x0df6, 0x003e), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1340 | { USB_DEVICE(0x0df6, 0x003f), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1341 | { USB_DEVICE(0x0df6, 0x0040), USB_DEVICE_DATA(&rt2800usb_ops) }, |
Ivo van Doorn | ce2ebc9 | 2009-05-22 21:33:21 +0200 | [diff] [blame] | 1342 | { USB_DEVICE(0x0df6, 0x0042), USB_DEVICE_DATA(&rt2800usb_ops) }, |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 1343 | /* SMC */ |
| 1344 | { USB_DEVICE(0x083a, 0x6618), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1345 | { USB_DEVICE(0x083a, 0x7511), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1346 | { USB_DEVICE(0x083a, 0x7512), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1347 | { USB_DEVICE(0x083a, 0x7522), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1348 | { USB_DEVICE(0x083a, 0x8522), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1349 | { USB_DEVICE(0x083a, 0xa512), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1350 | { USB_DEVICE(0x083a, 0xa618), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1351 | { USB_DEVICE(0x083a, 0xb522), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1352 | { USB_DEVICE(0x083a, 0xc522), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1353 | /* Sparklan */ |
| 1354 | { USB_DEVICE(0x15a9, 0x0006), USB_DEVICE_DATA(&rt2800usb_ops) }, |
Ivo van Doorn | 3b91c36 | 2009-05-21 19:16:14 +0200 | [diff] [blame] | 1355 | /* Sweex */ |
| 1356 | { USB_DEVICE(0x177f, 0x0153), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1357 | { USB_DEVICE(0x177f, 0x0302), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1358 | { USB_DEVICE(0x177f, 0x0313), USB_DEVICE_DATA(&rt2800usb_ops) }, |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 1359 | /* U-Media*/ |
| 1360 | { USB_DEVICE(0x157e, 0x300e), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1361 | /* ZCOM */ |
| 1362 | { USB_DEVICE(0x0cde, 0x0022), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1363 | { USB_DEVICE(0x0cde, 0x0025), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1364 | /* Zinwell */ |
| 1365 | { USB_DEVICE(0x5a57, 0x0280), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1366 | { USB_DEVICE(0x5a57, 0x0282), USB_DEVICE_DATA(&rt2800usb_ops) }, |
Ivo van Doorn | ce2ebc9 | 2009-05-22 21:33:21 +0200 | [diff] [blame] | 1367 | { USB_DEVICE(0x5a57, 0x0283), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1368 | { USB_DEVICE(0x5a57, 0x5257), USB_DEVICE_DATA(&rt2800usb_ops) }, |
Ivo van Doorn | d53d9e6 | 2009-04-26 15:47:48 +0200 | [diff] [blame] | 1369 | /* Zyxel */ |
| 1370 | { USB_DEVICE(0x0586, 0x3416), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1371 | { USB_DEVICE(0x0586, 0x341a), USB_DEVICE_DATA(&rt2800usb_ops) }, |
| 1372 | { 0, } |
| 1373 | }; |
| 1374 | |
| 1375 | MODULE_AUTHOR(DRV_PROJECT); |
| 1376 | MODULE_VERSION(DRV_VERSION); |
| 1377 | MODULE_DESCRIPTION("Ralink RT2800 USB Wireless LAN driver."); |
| 1378 | MODULE_SUPPORTED_DEVICE("Ralink RT2870 USB chipset based cards"); |
| 1379 | MODULE_DEVICE_TABLE(usb, rt2800usb_device_table); |
| 1380 | MODULE_FIRMWARE(FIRMWARE_RT2870); |
| 1381 | MODULE_LICENSE("GPL"); |
| 1382 | |
| 1383 | static struct usb_driver rt2800usb_driver = { |
| 1384 | .name = KBUILD_MODNAME, |
| 1385 | .id_table = rt2800usb_device_table, |
| 1386 | .probe = rt2x00usb_probe, |
| 1387 | .disconnect = rt2x00usb_disconnect, |
| 1388 | .suspend = rt2x00usb_suspend, |
| 1389 | .resume = rt2x00usb_resume, |
| 1390 | }; |
| 1391 | |
| 1392 | static int __init rt2800usb_init(void) |
| 1393 | { |
| 1394 | return usb_register(&rt2800usb_driver); |
| 1395 | } |
| 1396 | |
| 1397 | static void __exit rt2800usb_exit(void) |
| 1398 | { |
| 1399 | usb_deregister(&rt2800usb_driver); |
| 1400 | } |
| 1401 | |
| 1402 | module_init(rt2800usb_init); |
| 1403 | module_exit(rt2800usb_exit); |