Nick Kossifidis | c6e387a | 2008-08-29 22:45:39 +0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2004-2008 Reyk Floeter <reyk@openbsd.org> |
| 3 | * Copyright (c) 2006-2008 Nick Kossifidis <mickflemm@gmail.com> |
| 4 | * Copyright (c) 2007-2008 Jiri Slaby <jirislaby@gmail.com> |
| 5 | * |
| 6 | * Permission to use, copy, modify, and distribute this software for any |
| 7 | * purpose with or without fee is hereby granted, provided that the above |
| 8 | * copyright notice and this permission notice appear in all copies. |
| 9 | * |
| 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 17 | * |
| 18 | */ |
| 19 | |
| 20 | /**************\ |
| 21 | * Capabilities * |
| 22 | \**************/ |
| 23 | |
| 24 | #include "ath5k.h" |
| 25 | #include "reg.h" |
| 26 | #include "debug.h" |
Pavel Roskin | 931be26 | 2011-07-26 22:26:59 -0400 | [diff] [blame] | 27 | #include "../regd.h" |
Nick Kossifidis | c6e387a | 2008-08-29 22:45:39 +0300 | [diff] [blame] | 28 | |
| 29 | /* |
| 30 | * Fill the capabilities struct |
| 31 | * TODO: Merge this with EEPROM code when we are done with it |
| 32 | */ |
| 33 | int ath5k_hw_set_capabilities(struct ath5k_hw *ah) |
| 34 | { |
Bruno Randolf | 20a9049 | 2011-01-25 13:15:28 +0900 | [diff] [blame] | 35 | struct ath5k_capabilities *caps = &ah->ah_capabilities; |
Nick Kossifidis | c6e387a | 2008-08-29 22:45:39 +0300 | [diff] [blame] | 36 | u16 ee_header; |
| 37 | |
Nick Kossifidis | c6e387a | 2008-08-29 22:45:39 +0300 | [diff] [blame] | 38 | /* Capabilities stored in the EEPROM */ |
Bruno Randolf | 20a9049 | 2011-01-25 13:15:28 +0900 | [diff] [blame] | 39 | ee_header = caps->cap_eeprom.ee_header; |
Nick Kossifidis | c6e387a | 2008-08-29 22:45:39 +0300 | [diff] [blame] | 40 | |
| 41 | if (ah->ah_version == AR5K_AR5210) { |
| 42 | /* |
| 43 | * Set radio capabilities |
| 44 | * (The AR5110 only supports the middle 5GHz band) |
| 45 | */ |
Bruno Randolf | 20a9049 | 2011-01-25 13:15:28 +0900 | [diff] [blame] | 46 | caps->cap_range.range_5ghz_min = 5120; |
| 47 | caps->cap_range.range_5ghz_max = 5430; |
| 48 | caps->cap_range.range_2ghz_min = 0; |
| 49 | caps->cap_range.range_2ghz_max = 0; |
Nick Kossifidis | c6e387a | 2008-08-29 22:45:39 +0300 | [diff] [blame] | 50 | |
| 51 | /* Set supported modes */ |
Bruno Randolf | 20a9049 | 2011-01-25 13:15:28 +0900 | [diff] [blame] | 52 | __set_bit(AR5K_MODE_11A, caps->cap_mode); |
Nick Kossifidis | c6e387a | 2008-08-29 22:45:39 +0300 | [diff] [blame] | 53 | } else { |
| 54 | /* |
Pavel Roskin | 6a2a0e7 | 2011-07-09 00:17:51 -0400 | [diff] [blame] | 55 | * XXX The transceiver supports frequencies from 4920 to 6100MHz |
| 56 | * XXX and from 2312 to 2732MHz. There are problems with the |
Nick Kossifidis | c6e387a | 2008-08-29 22:45:39 +0300 | [diff] [blame] | 57 | * XXX current ieee80211 implementation because the IEEE |
| 58 | * XXX channel mapping does not support negative channel |
| 59 | * XXX numbers (2312MHz is channel -19). Of course, this |
Bruno Randolf | ead3dcf | 2011-01-25 13:15:38 +0900 | [diff] [blame] | 60 | * XXX doesn't matter because these channels are out of the |
| 61 | * XXX legal range. |
Nick Kossifidis | c6e387a | 2008-08-29 22:45:39 +0300 | [diff] [blame] | 62 | */ |
| 63 | |
| 64 | /* |
| 65 | * Set radio capabilities |
| 66 | */ |
| 67 | |
| 68 | if (AR5K_EEPROM_HDR_11A(ee_header)) { |
Bruno Randolf | ead3dcf | 2011-01-25 13:15:38 +0900 | [diff] [blame] | 69 | if (ath_is_49ghz_allowed(caps->cap_eeprom.ee_regdomain)) |
| 70 | caps->cap_range.range_5ghz_min = 4920; |
| 71 | else |
| 72 | caps->cap_range.range_5ghz_min = 5005; |
Bruno Randolf | 20a9049 | 2011-01-25 13:15:28 +0900 | [diff] [blame] | 73 | caps->cap_range.range_5ghz_max = 6100; |
Nick Kossifidis | c6e387a | 2008-08-29 22:45:39 +0300 | [diff] [blame] | 74 | |
| 75 | /* Set supported modes */ |
Bruno Randolf | 20a9049 | 2011-01-25 13:15:28 +0900 | [diff] [blame] | 76 | __set_bit(AR5K_MODE_11A, caps->cap_mode); |
Nick Kossifidis | c6e387a | 2008-08-29 22:45:39 +0300 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | /* Enable 802.11b if a 2GHz capable radio (2111/5112) is |
| 80 | * connected */ |
| 81 | if (AR5K_EEPROM_HDR_11B(ee_header) || |
Helmut Schaa | 8109488 | 2009-01-12 13:04:06 +0100 | [diff] [blame] | 82 | (AR5K_EEPROM_HDR_11G(ee_header) && |
| 83 | ah->ah_version != AR5K_AR5211)) { |
Nick Kossifidis | c6e387a | 2008-08-29 22:45:39 +0300 | [diff] [blame] | 84 | /* 2312 */ |
Bruno Randolf | 20a9049 | 2011-01-25 13:15:28 +0900 | [diff] [blame] | 85 | caps->cap_range.range_2ghz_min = 2412; |
| 86 | caps->cap_range.range_2ghz_max = 2732; |
Nick Kossifidis | c6e387a | 2008-08-29 22:45:39 +0300 | [diff] [blame] | 87 | |
Nick Kossifidis | 86f62d9 | 2011-11-25 20:40:28 +0200 | [diff] [blame] | 88 | /* Override 2GHz modes on SoCs that need it |
| 89 | * NOTE: cap_needs_2GHz_ovr gets set from |
| 90 | * ath_ahb_probe */ |
| 91 | if (!caps->cap_needs_2GHz_ovr) { |
| 92 | if (AR5K_EEPROM_HDR_11B(ee_header)) |
| 93 | __set_bit(AR5K_MODE_11B, |
| 94 | caps->cap_mode); |
Nick Kossifidis | c6e387a | 2008-08-29 22:45:39 +0300 | [diff] [blame] | 95 | |
Nick Kossifidis | 86f62d9 | 2011-11-25 20:40:28 +0200 | [diff] [blame] | 96 | if (AR5K_EEPROM_HDR_11G(ee_header) && |
| 97 | ah->ah_version != AR5K_AR5211) |
| 98 | __set_bit(AR5K_MODE_11G, |
| 99 | caps->cap_mode); |
| 100 | } |
Nick Kossifidis | c6e387a | 2008-08-29 22:45:39 +0300 | [diff] [blame] | 101 | } |
| 102 | } |
| 103 | |
Felix Fietkau | 7f94f05 | 2011-04-13 21:56:42 +0200 | [diff] [blame] | 104 | if ((ah->ah_radio_5ghz_revision & 0xf0) == AR5K_SREV_RAD_2112) |
| 105 | __clear_bit(AR5K_MODE_11A, caps->cap_mode); |
| 106 | |
Nick Kossifidis | c6e387a | 2008-08-29 22:45:39 +0300 | [diff] [blame] | 107 | /* Set number of supported TX queues */ |
| 108 | if (ah->ah_version == AR5K_AR5210) |
Bruno Randolf | 20a9049 | 2011-01-25 13:15:28 +0900 | [diff] [blame] | 109 | caps->cap_queues.q_tx_num = AR5K_NUM_TX_QUEUES_NOQCU; |
Nick Kossifidis | c6e387a | 2008-08-29 22:45:39 +0300 | [diff] [blame] | 110 | else |
Bruno Randolf | 20a9049 | 2011-01-25 13:15:28 +0900 | [diff] [blame] | 111 | caps->cap_queues.q_tx_num = AR5K_NUM_TX_QUEUES; |
Nick Kossifidis | c6e387a | 2008-08-29 22:45:39 +0300 | [diff] [blame] | 112 | |
Nick Kossifidis | 86f62d9 | 2011-11-25 20:40:28 +0200 | [diff] [blame] | 113 | /* Newer hardware has PHY error counters */ |
Bruno Randolf | a8c944f | 2010-03-25 14:49:47 +0900 | [diff] [blame] | 114 | if (ah->ah_mac_srev >= AR5K_SREV_AR5213A) |
Bruno Randolf | 20a9049 | 2011-01-25 13:15:28 +0900 | [diff] [blame] | 115 | caps->cap_has_phyerr_counters = true; |
Bruno Randolf | a8c944f | 2010-03-25 14:49:47 +0900 | [diff] [blame] | 116 | else |
Bruno Randolf | 20a9049 | 2011-01-25 13:15:28 +0900 | [diff] [blame] | 117 | caps->cap_has_phyerr_counters = false; |
Bruno Randolf | a8c944f | 2010-03-25 14:49:47 +0900 | [diff] [blame] | 118 | |
Nick Kossifidis | 86f62d9 | 2011-11-25 20:40:28 +0200 | [diff] [blame] | 119 | /* MACs since AR5212 have MRR support */ |
| 120 | if (ah->ah_version == AR5K_AR5212) |
| 121 | caps->cap_has_mrr_support = true; |
| 122 | else |
| 123 | caps->cap_has_mrr_support = false; |
| 124 | |
Nick Kossifidis | c6e387a | 2008-08-29 22:45:39 +0300 | [diff] [blame] | 125 | return 0; |
| 126 | } |
| 127 | |
Nick Kossifidis | c6e387a | 2008-08-29 22:45:39 +0300 | [diff] [blame] | 128 | /* |
| 129 | * TODO: Following functions should be part of a new function |
| 130 | * set_capability |
| 131 | */ |
| 132 | |
| 133 | int ath5k_hw_enable_pspoll(struct ath5k_hw *ah, u8 *bssid, |
| 134 | u16 assoc_id) |
| 135 | { |
Nick Kossifidis | c6e387a | 2008-08-29 22:45:39 +0300 | [diff] [blame] | 136 | if (ah->ah_version == AR5K_AR5210) { |
| 137 | AR5K_REG_DISABLE_BITS(ah, AR5K_STA_ID1, |
| 138 | AR5K_STA_ID1_NO_PSPOLL | AR5K_STA_ID1_DEFAULT_ANTENNA); |
| 139 | return 0; |
| 140 | } |
| 141 | |
| 142 | return -EIO; |
| 143 | } |
| 144 | |
| 145 | int ath5k_hw_disable_pspoll(struct ath5k_hw *ah) |
| 146 | { |
Nick Kossifidis | c6e387a | 2008-08-29 22:45:39 +0300 | [diff] [blame] | 147 | if (ah->ah_version == AR5K_AR5210) { |
| 148 | AR5K_REG_ENABLE_BITS(ah, AR5K_STA_ID1, |
| 149 | AR5K_STA_ID1_NO_PSPOLL | AR5K_STA_ID1_DEFAULT_ANTENNA); |
| 150 | return 0; |
| 151 | } |
| 152 | |
| 153 | return -EIO; |
| 154 | } |