Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (c) 2004-2008 Reyk Floeter <reyk@openbsd.org>
0003  * Copyright (c) 2006-2008 Nick Kossifidis <mickflemm@gmail.com>
0004  * Copyright (c) 2007-2008 Jiri Slaby <jirislaby@gmail.com>
0005  *
0006  * Permission to use, copy, modify, and distribute this software for any
0007  * purpose with or without fee is hereby granted, provided that the above
0008  * copyright notice and this permission notice appear in all copies.
0009  *
0010  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
0011  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
0012  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
0013  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
0014  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
0015  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
0016  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
0017  *
0018  */
0019 
0020 /**************\
0021 * Capabilities *
0022 \**************/
0023 
0024 #include "ath5k.h"
0025 #include "reg.h"
0026 #include "debug.h"
0027 #include "../regd.h"
0028 
0029 /*
0030  * Fill the capabilities struct
0031  * TODO: Merge this with EEPROM code when we are done with it
0032  */
0033 int ath5k_hw_set_capabilities(struct ath5k_hw *ah)
0034 {
0035     struct ath5k_capabilities *caps = &ah->ah_capabilities;
0036     u16 ee_header;
0037 
0038     /* Capabilities stored in the EEPROM */
0039     ee_header = caps->cap_eeprom.ee_header;
0040 
0041     if (ah->ah_version == AR5K_AR5210) {
0042         /*
0043          * Set radio capabilities
0044          * (The AR5110 only supports the middle 5GHz band)
0045          */
0046         caps->cap_range.range_5ghz_min = 5120;
0047         caps->cap_range.range_5ghz_max = 5430;
0048         caps->cap_range.range_2ghz_min = 0;
0049         caps->cap_range.range_2ghz_max = 0;
0050 
0051         /* Set supported modes */
0052         __set_bit(AR5K_MODE_11A, caps->cap_mode);
0053     } else {
0054         /*
0055          * XXX The transceiver supports frequencies from 4920 to 6100MHz
0056          * XXX and from 2312 to 2732MHz. There are problems with the
0057          * XXX current ieee80211 implementation because the IEEE
0058          * XXX channel mapping does not support negative channel
0059          * XXX numbers (2312MHz is channel -19). Of course, this
0060          * XXX doesn't matter because these channels are out of the
0061          * XXX legal range.
0062          */
0063 
0064         /*
0065          * Set radio capabilities
0066          */
0067 
0068         if (AR5K_EEPROM_HDR_11A(ee_header)) {
0069             if (ath_is_49ghz_allowed(caps->cap_eeprom.ee_regdomain))
0070                 caps->cap_range.range_5ghz_min = 4920;
0071             else
0072                 caps->cap_range.range_5ghz_min = 5005;
0073             caps->cap_range.range_5ghz_max = 6100;
0074 
0075             /* Set supported modes */
0076             __set_bit(AR5K_MODE_11A, caps->cap_mode);
0077         }
0078 
0079         /* Enable  802.11b if a 2GHz capable radio (2111/5112) is
0080          * connected */
0081         if (AR5K_EEPROM_HDR_11B(ee_header) ||
0082             (AR5K_EEPROM_HDR_11G(ee_header) &&
0083              ah->ah_version != AR5K_AR5211)) {
0084             /* 2312 */
0085             caps->cap_range.range_2ghz_min = 2412;
0086             caps->cap_range.range_2ghz_max = 2732;
0087 
0088             /* Override 2GHz modes on SoCs that need it
0089              * NOTE: cap_needs_2GHz_ovr gets set from
0090              * ath_ahb_probe */
0091             if (!caps->cap_needs_2GHz_ovr) {
0092                 if (AR5K_EEPROM_HDR_11B(ee_header))
0093                     __set_bit(AR5K_MODE_11B,
0094                             caps->cap_mode);
0095 
0096                 if (AR5K_EEPROM_HDR_11G(ee_header) &&
0097                 ah->ah_version != AR5K_AR5211)
0098                     __set_bit(AR5K_MODE_11G,
0099                             caps->cap_mode);
0100             }
0101         }
0102     }
0103 
0104     if ((ah->ah_radio_5ghz_revision & 0xf0) == AR5K_SREV_RAD_2112)
0105         __clear_bit(AR5K_MODE_11A, caps->cap_mode);
0106 
0107     /* Set number of supported TX queues */
0108     if (ah->ah_version == AR5K_AR5210)
0109         caps->cap_queues.q_tx_num = AR5K_NUM_TX_QUEUES_NOQCU;
0110     else
0111         caps->cap_queues.q_tx_num = AR5K_NUM_TX_QUEUES;
0112 
0113     /* Newer hardware has PHY error counters */
0114     if (ah->ah_mac_srev >= AR5K_SREV_AR5213A)
0115         caps->cap_has_phyerr_counters = true;
0116     else
0117         caps->cap_has_phyerr_counters = false;
0118 
0119     /* MACs since AR5212 have MRR support */
0120     if (ah->ah_version == AR5K_AR5212)
0121         caps->cap_has_mrr_support = true;
0122     else
0123         caps->cap_has_mrr_support = false;
0124 
0125     return 0;
0126 }
0127 
0128 /*
0129  * TODO: Following functions should be part of a new function
0130  * set_capability
0131  */
0132 
0133 int ath5k_hw_enable_pspoll(struct ath5k_hw *ah, u8 *bssid,
0134         u16 assoc_id)
0135 {
0136     if (ah->ah_version == AR5K_AR5210) {
0137         AR5K_REG_DISABLE_BITS(ah, AR5K_STA_ID1,
0138             AR5K_STA_ID1_NO_PSPOLL | AR5K_STA_ID1_DEFAULT_ANTENNA);
0139         return 0;
0140     }
0141 
0142     return -EIO;
0143 }
0144 
0145 int ath5k_hw_disable_pspoll(struct ath5k_hw *ah)
0146 {
0147     if (ah->ah_version == AR5K_AR5210) {
0148         AR5K_REG_ENABLE_BITS(ah, AR5K_STA_ID1,
0149             AR5K_STA_ID1_NO_PSPOLL | AR5K_STA_ID1_DEFAULT_ANTENNA);
0150         return 0;
0151     }
0152 
0153     return -EIO;
0154 }