2008-08-30 03:45:39 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2004-2008 Reyk Floeter <reyk@openbsd.org>
|
2009-03-16 04:17:04 +08:00
|
|
|
* Copyright (c) 2006-2009 Nick Kossifidis <mickflemm@gmail.com>
|
|
|
|
* Copyright (c) 2008-2009 Felix Fietkau <nbd@openwrt.org>
|
2008-08-30 03:45:39 +08:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*************************************\
|
|
|
|
* EEPROM access functions and helpers *
|
|
|
|
\*************************************/
|
|
|
|
|
2012-03-19 08:30:52 +08:00
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
|
|
|
|
2008-08-30 03:45:39 +08:00
|
|
|
#include "ath5k.h"
|
|
|
|
#include "reg.h"
|
|
|
|
#include "debug.h"
|
|
|
|
|
2010-11-24 02:36:45 +08:00
|
|
|
|
|
|
|
/******************\
|
|
|
|
* Helper functions *
|
|
|
|
\******************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Translate binary channel representation in EEPROM to frequency
|
|
|
|
*/
|
|
|
|
static u16 ath5k_eeprom_bin2freq(struct ath5k_eeprom_info *ee, u16 bin,
|
|
|
|
unsigned int mode)
|
|
|
|
{
|
|
|
|
u16 val;
|
|
|
|
|
|
|
|
if (bin == AR5K_EEPROM_CHANNEL_DIS)
|
|
|
|
return bin;
|
|
|
|
|
|
|
|
if (mode == AR5K_EEPROM_MODE_11A) {
|
|
|
|
if (ee->ee_version > AR5K_EEPROM_VERSION_3_2)
|
|
|
|
val = (5 * bin) + 4800;
|
|
|
|
else
|
|
|
|
val = bin > 62 ? (10 * 62) + (5 * (bin - 62)) + 5100 :
|
|
|
|
(bin * 10) + 5100;
|
|
|
|
} else {
|
|
|
|
if (ee->ee_version > AR5K_EEPROM_VERSION_3_2)
|
|
|
|
val = bin + 2300;
|
|
|
|
else
|
|
|
|
val = bin + 2400;
|
|
|
|
}
|
|
|
|
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********\
|
|
|
|
* Parsers *
|
|
|
|
\*********/
|
|
|
|
|
2008-11-20 22:16:22 +08:00
|
|
|
/*
|
|
|
|
* Initialize eeprom & capabilities structs
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
ath5k_eeprom_init_header(struct ath5k_hw *ah)
|
|
|
|
{
|
|
|
|
struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
|
|
|
|
u16 val;
|
2010-01-04 23:40:39 +08:00
|
|
|
u32 cksum, offset, eep_max = AR5K_EEPROM_INFO_MAX;
|
2008-11-20 22:16:22 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Read values from EEPROM and store them in the capability structure
|
|
|
|
*/
|
|
|
|
AR5K_EEPROM_READ_HDR(AR5K_EEPROM_MAGIC, ee_magic);
|
|
|
|
AR5K_EEPROM_READ_HDR(AR5K_EEPROM_PROTECT, ee_protect);
|
|
|
|
AR5K_EEPROM_READ_HDR(AR5K_EEPROM_REG_DOMAIN, ee_regdomain);
|
|
|
|
AR5K_EEPROM_READ_HDR(AR5K_EEPROM_VERSION, ee_version);
|
|
|
|
AR5K_EEPROM_READ_HDR(AR5K_EEPROM_HDR, ee_header);
|
|
|
|
|
|
|
|
/* Return if we have an old EEPROM */
|
|
|
|
if (ah->ah_ee_version < AR5K_EEPROM_VERSION_3_0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Validate the checksum of the EEPROM date. There are some
|
|
|
|
* devices with invalid EEPROMs.
|
|
|
|
*/
|
2010-01-04 23:40:39 +08:00
|
|
|
AR5K_EEPROM_READ(AR5K_EEPROM_SIZE_UPPER, val);
|
|
|
|
if (val) {
|
|
|
|
eep_max = (val & AR5K_EEPROM_SIZE_UPPER_MASK) <<
|
|
|
|
AR5K_EEPROM_SIZE_ENDLOC_SHIFT;
|
|
|
|
AR5K_EEPROM_READ(AR5K_EEPROM_SIZE_LOWER, val);
|
|
|
|
eep_max = (eep_max | val) - AR5K_EEPROM_INFO_BASE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fail safe check to prevent stupid loops due
|
|
|
|
* to busted EEPROMs. XXX: This value is likely too
|
|
|
|
* big still, waiting on a better value.
|
|
|
|
*/
|
|
|
|
if (eep_max > (3 * AR5K_EEPROM_INFO_MAX)) {
|
2011-07-15 08:21:55 +08:00
|
|
|
ATH5K_ERR(ah, "Invalid max custom EEPROM size: "
|
2010-01-04 23:40:39 +08:00
|
|
|
"%d (0x%04x) max expected: %d (0x%04x)\n",
|
|
|
|
eep_max, eep_max,
|
|
|
|
3 * AR5K_EEPROM_INFO_MAX,
|
|
|
|
3 * AR5K_EEPROM_INFO_MAX);
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (cksum = 0, offset = 0; offset < eep_max; offset++) {
|
2008-11-20 22:16:22 +08:00
|
|
|
AR5K_EEPROM_READ(AR5K_EEPROM_INFO(offset), val);
|
|
|
|
cksum ^= val;
|
|
|
|
}
|
|
|
|
if (cksum != AR5K_EEPROM_INFO_CKSUM) {
|
2011-07-15 08:21:55 +08:00
|
|
|
ATH5K_ERR(ah, "Invalid EEPROM "
|
2010-01-04 23:40:39 +08:00
|
|
|
"checksum: 0x%04x eep_max: 0x%04x (%s)\n",
|
|
|
|
cksum, eep_max,
|
|
|
|
eep_max == AR5K_EEPROM_INFO_MAX ?
|
|
|
|
"default size" : "custom size");
|
2008-11-20 22:16:22 +08:00
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
AR5K_EEPROM_READ_HDR(AR5K_EEPROM_ANT_GAIN(ah->ah_ee_version),
|
|
|
|
ee_ant_gain);
|
|
|
|
|
|
|
|
if (ah->ah_ee_version >= AR5K_EEPROM_VERSION_4_0) {
|
|
|
|
AR5K_EEPROM_READ_HDR(AR5K_EEPROM_MISC0, ee_misc0);
|
|
|
|
AR5K_EEPROM_READ_HDR(AR5K_EEPROM_MISC1, ee_misc1);
|
2008-12-21 10:47:39 +08:00
|
|
|
|
|
|
|
/* XXX: Don't know which versions include these two */
|
|
|
|
AR5K_EEPROM_READ_HDR(AR5K_EEPROM_MISC2, ee_misc2);
|
|
|
|
|
|
|
|
if (ee->ee_version >= AR5K_EEPROM_VERSION_4_3)
|
|
|
|
AR5K_EEPROM_READ_HDR(AR5K_EEPROM_MISC3, ee_misc3);
|
|
|
|
|
|
|
|
if (ee->ee_version >= AR5K_EEPROM_VERSION_5_0) {
|
|
|
|
AR5K_EEPROM_READ_HDR(AR5K_EEPROM_MISC4, ee_misc4);
|
|
|
|
AR5K_EEPROM_READ_HDR(AR5K_EEPROM_MISC5, ee_misc5);
|
|
|
|
AR5K_EEPROM_READ_HDR(AR5K_EEPROM_MISC6, ee_misc6);
|
|
|
|
}
|
2008-11-20 22:16:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ah->ah_ee_version < AR5K_EEPROM_VERSION_3_3) {
|
|
|
|
AR5K_EEPROM_READ(AR5K_EEPROM_OBDB0_2GHZ, val);
|
|
|
|
ee->ee_ob[AR5K_EEPROM_MODE_11B][0] = val & 0x7;
|
|
|
|
ee->ee_db[AR5K_EEPROM_MODE_11B][0] = (val >> 3) & 0x7;
|
|
|
|
|
|
|
|
AR5K_EEPROM_READ(AR5K_EEPROM_OBDB1_2GHZ, val);
|
|
|
|
ee->ee_ob[AR5K_EEPROM_MODE_11G][0] = val & 0x7;
|
|
|
|
ee->ee_db[AR5K_EEPROM_MODE_11G][0] = (val >> 3) & 0x7;
|
|
|
|
}
|
|
|
|
|
2009-05-01 03:55:46 +08:00
|
|
|
AR5K_EEPROM_READ(AR5K_EEPROM_IS_HB63, val);
|
|
|
|
|
|
|
|
if ((ah->ah_mac_version == (AR5K_SREV_AR2425 >> 4)) && val)
|
|
|
|
ee->ee_is_hb63 = true;
|
|
|
|
else
|
|
|
|
ee->ee_is_hb63 = false;
|
|
|
|
|
|
|
|
AR5K_EEPROM_READ(AR5K_EEPROM_RFKILL, val);
|
|
|
|
ee->ee_rfkill_pin = (u8) AR5K_REG_MS(val, AR5K_EEPROM_RFKILL_GPIO_SEL);
|
|
|
|
ee->ee_rfkill_pol = val & AR5K_EEPROM_RFKILL_POLARITY ? true : false;
|
|
|
|
|
2009-08-10 08:26:55 +08:00
|
|
|
/* Check if PCIE_OFFSET points to PCIE_SERDES_SECTION
|
|
|
|
* and enable serdes programming if needed.
|
|
|
|
*
|
|
|
|
* XXX: Serdes values seem to be fixed so
|
|
|
|
* no need to read them here, we write them
|
2010-12-02 17:26:56 +08:00
|
|
|
* during ath5k_hw_init */
|
2009-08-10 08:26:55 +08:00
|
|
|
AR5K_EEPROM_READ(AR5K_EEPROM_PCIE_OFFSET, val);
|
|
|
|
ee->ee_serdes = (val == AR5K_EEPROM_PCIE_SERDES_SECTION) ?
|
|
|
|
true : false;
|
|
|
|
|
2008-11-20 22:16:22 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-30 03:45:39 +08:00
|
|
|
/*
|
|
|
|
* Read antenna infos from eeprom
|
|
|
|
*/
|
|
|
|
static int ath5k_eeprom_read_ants(struct ath5k_hw *ah, u32 *offset,
|
|
|
|
unsigned int mode)
|
|
|
|
{
|
|
|
|
struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
|
|
|
|
u32 o = *offset;
|
|
|
|
u16 val;
|
2011-01-11 16:00:31 +08:00
|
|
|
int i = 0;
|
2008-08-30 03:45:39 +08:00
|
|
|
|
|
|
|
AR5K_EEPROM_READ(o++, val);
|
|
|
|
ee->ee_switch_settling[mode] = (val >> 8) & 0x7f;
|
2008-11-20 22:16:22 +08:00
|
|
|
ee->ee_atn_tx_rx[mode] = (val >> 2) & 0x3f;
|
2008-08-30 03:45:39 +08:00
|
|
|
ee->ee_ant_control[mode][i] = (val << 4) & 0x3f;
|
|
|
|
|
|
|
|
AR5K_EEPROM_READ(o++, val);
|
|
|
|
ee->ee_ant_control[mode][i++] |= (val >> 12) & 0xf;
|
|
|
|
ee->ee_ant_control[mode][i++] = (val >> 6) & 0x3f;
|
|
|
|
ee->ee_ant_control[mode][i++] = val & 0x3f;
|
|
|
|
|
|
|
|
AR5K_EEPROM_READ(o++, val);
|
|
|
|
ee->ee_ant_control[mode][i++] = (val >> 10) & 0x3f;
|
|
|
|
ee->ee_ant_control[mode][i++] = (val >> 4) & 0x3f;
|
|
|
|
ee->ee_ant_control[mode][i] = (val << 2) & 0x3f;
|
|
|
|
|
|
|
|
AR5K_EEPROM_READ(o++, val);
|
|
|
|
ee->ee_ant_control[mode][i++] |= (val >> 14) & 0x3;
|
|
|
|
ee->ee_ant_control[mode][i++] = (val >> 8) & 0x3f;
|
|
|
|
ee->ee_ant_control[mode][i++] = (val >> 2) & 0x3f;
|
|
|
|
ee->ee_ant_control[mode][i] = (val << 4) & 0x3f;
|
|
|
|
|
|
|
|
AR5K_EEPROM_READ(o++, val);
|
|
|
|
ee->ee_ant_control[mode][i++] |= (val >> 12) & 0xf;
|
|
|
|
ee->ee_ant_control[mode][i++] = (val >> 6) & 0x3f;
|
|
|
|
ee->ee_ant_control[mode][i++] = val & 0x3f;
|
|
|
|
|
2009-05-01 03:55:49 +08:00
|
|
|
/* Get antenna switch tables */
|
|
|
|
ah->ah_ant_ctl[mode][AR5K_ANT_CTL] =
|
2009-02-09 12:12:58 +08:00
|
|
|
(ee->ee_ant_control[mode][0] << 4);
|
2009-05-01 03:55:49 +08:00
|
|
|
ah->ah_ant_ctl[mode][AR5K_ANT_SWTABLE_A] =
|
2011-07-08 06:13:24 +08:00
|
|
|
ee->ee_ant_control[mode][1] |
|
|
|
|
(ee->ee_ant_control[mode][2] << 6) |
|
2008-08-30 03:45:39 +08:00
|
|
|
(ee->ee_ant_control[mode][3] << 12) |
|
|
|
|
(ee->ee_ant_control[mode][4] << 18) |
|
|
|
|
(ee->ee_ant_control[mode][5] << 24);
|
2009-05-01 03:55:49 +08:00
|
|
|
ah->ah_ant_ctl[mode][AR5K_ANT_SWTABLE_B] =
|
2011-07-08 06:13:24 +08:00
|
|
|
ee->ee_ant_control[mode][6] |
|
|
|
|
(ee->ee_ant_control[mode][7] << 6) |
|
2008-08-30 03:45:39 +08:00
|
|
|
(ee->ee_ant_control[mode][8] << 12) |
|
|
|
|
(ee->ee_ant_control[mode][9] << 18) |
|
|
|
|
(ee->ee_ant_control[mode][10] << 24);
|
|
|
|
|
|
|
|
/* return new offset */
|
|
|
|
*offset = o;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2008-12-21 10:47:39 +08:00
|
|
|
* Read supported modes and some mode-specific calibration data
|
|
|
|
* from eeprom
|
2008-08-30 03:45:39 +08:00
|
|
|
*/
|
|
|
|
static int ath5k_eeprom_read_modes(struct ath5k_hw *ah, u32 *offset,
|
|
|
|
unsigned int mode)
|
|
|
|
{
|
|
|
|
struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
|
|
|
|
u32 o = *offset;
|
|
|
|
u16 val;
|
|
|
|
|
2008-11-20 22:16:22 +08:00
|
|
|
ee->ee_n_piers[mode] = 0;
|
|
|
|
AR5K_EEPROM_READ(o++, val);
|
|
|
|
ee->ee_adc_desired_size[mode] = (s8)((val >> 8) & 0xff);
|
2011-07-08 06:14:13 +08:00
|
|
|
switch (mode) {
|
2008-11-20 22:16:22 +08:00
|
|
|
case AR5K_EEPROM_MODE_11A:
|
2009-03-16 04:17:04 +08:00
|
|
|
ee->ee_ob[mode][3] = (val >> 5) & 0x7;
|
|
|
|
ee->ee_db[mode][3] = (val >> 2) & 0x7;
|
|
|
|
ee->ee_ob[mode][2] = (val << 1) & 0x7;
|
2008-11-20 22:16:22 +08:00
|
|
|
|
|
|
|
AR5K_EEPROM_READ(o++, val);
|
2009-03-16 04:17:04 +08:00
|
|
|
ee->ee_ob[mode][2] |= (val >> 15) & 0x1;
|
|
|
|
ee->ee_db[mode][2] = (val >> 12) & 0x7;
|
|
|
|
ee->ee_ob[mode][1] = (val >> 9) & 0x7;
|
|
|
|
ee->ee_db[mode][1] = (val >> 6) & 0x7;
|
|
|
|
ee->ee_ob[mode][0] = (val >> 3) & 0x7;
|
|
|
|
ee->ee_db[mode][0] = val & 0x7;
|
2008-11-20 22:16:22 +08:00
|
|
|
break;
|
|
|
|
case AR5K_EEPROM_MODE_11G:
|
|
|
|
case AR5K_EEPROM_MODE_11B:
|
2009-03-16 04:17:04 +08:00
|
|
|
ee->ee_ob[mode][1] = (val >> 4) & 0x7;
|
|
|
|
ee->ee_db[mode][1] = val & 0x7;
|
2008-11-20 22:16:22 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-08-30 03:45:39 +08:00
|
|
|
AR5K_EEPROM_READ(o++, val);
|
|
|
|
ee->ee_tx_end2xlna_enable[mode] = (val >> 8) & 0xff;
|
|
|
|
ee->ee_thr_62[mode] = val & 0xff;
|
|
|
|
|
|
|
|
if (ah->ah_ee_version <= AR5K_EEPROM_VERSION_3_2)
|
|
|
|
ee->ee_thr_62[mode] = mode == AR5K_EEPROM_MODE_11A ? 15 : 28;
|
|
|
|
|
|
|
|
AR5K_EEPROM_READ(o++, val);
|
|
|
|
ee->ee_tx_end2xpa_disable[mode] = (val >> 8) & 0xff;
|
|
|
|
ee->ee_tx_frm2xpa_enable[mode] = val & 0xff;
|
|
|
|
|
|
|
|
AR5K_EEPROM_READ(o++, val);
|
|
|
|
ee->ee_pga_desired_size[mode] = (val >> 8) & 0xff;
|
|
|
|
|
|
|
|
if ((val & 0xff) & 0x80)
|
|
|
|
ee->ee_noise_floor_thr[mode] = -((((val & 0xff) ^ 0xff)) + 1);
|
|
|
|
else
|
|
|
|
ee->ee_noise_floor_thr[mode] = val & 0xff;
|
|
|
|
|
|
|
|
if (ah->ah_ee_version <= AR5K_EEPROM_VERSION_3_2)
|
|
|
|
ee->ee_noise_floor_thr[mode] =
|
|
|
|
mode == AR5K_EEPROM_MODE_11A ? -54 : -1;
|
|
|
|
|
|
|
|
AR5K_EEPROM_READ(o++, val);
|
|
|
|
ee->ee_xlna_gain[mode] = (val >> 5) & 0xff;
|
|
|
|
ee->ee_x_gain[mode] = (val >> 1) & 0xf;
|
|
|
|
ee->ee_xpd[mode] = val & 0x1;
|
|
|
|
|
2010-03-09 15:56:21 +08:00
|
|
|
if (ah->ah_ee_version >= AR5K_EEPROM_VERSION_4_0 &&
|
|
|
|
mode != AR5K_EEPROM_MODE_11B)
|
2008-08-30 03:45:39 +08:00
|
|
|
ee->ee_fixed_bias[mode] = (val >> 13) & 0x1;
|
|
|
|
|
|
|
|
if (ah->ah_ee_version >= AR5K_EEPROM_VERSION_3_3) {
|
|
|
|
AR5K_EEPROM_READ(o++, val);
|
|
|
|
ee->ee_false_detect[mode] = (val >> 6) & 0x7f;
|
|
|
|
|
|
|
|
if (mode == AR5K_EEPROM_MODE_11A)
|
|
|
|
ee->ee_xr_power[mode] = val & 0x3f;
|
|
|
|
else {
|
2010-03-09 15:56:21 +08:00
|
|
|
/* b_DB_11[bg] and b_OB_11[bg] */
|
2008-08-30 03:45:39 +08:00
|
|
|
ee->ee_ob[mode][0] = val & 0x7;
|
|
|
|
ee->ee_db[mode][0] = (val >> 3) & 0x7;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ah->ah_ee_version < AR5K_EEPROM_VERSION_3_4) {
|
|
|
|
ee->ee_i_gain[mode] = AR5K_EEPROM_I_GAIN;
|
|
|
|
ee->ee_cck_ofdm_power_delta = AR5K_EEPROM_CCK_OFDM_DELTA;
|
|
|
|
} else {
|
|
|
|
ee->ee_i_gain[mode] = (val >> 13) & 0x7;
|
|
|
|
|
|
|
|
AR5K_EEPROM_READ(o++, val);
|
|
|
|
ee->ee_i_gain[mode] |= (val << 3) & 0x38;
|
|
|
|
|
2008-11-20 22:16:22 +08:00
|
|
|
if (mode == AR5K_EEPROM_MODE_11G) {
|
2008-08-30 03:45:39 +08:00
|
|
|
ee->ee_cck_ofdm_power_delta = (val >> 3) & 0xff;
|
2008-11-20 22:16:22 +08:00
|
|
|
if (ah->ah_ee_version >= AR5K_EEPROM_VERSION_4_6)
|
|
|
|
ee->ee_scaled_cck_delta = (val >> 11) & 0x1f;
|
|
|
|
}
|
2008-08-30 03:45:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ah->ah_ee_version >= AR5K_EEPROM_VERSION_4_0 &&
|
|
|
|
mode == AR5K_EEPROM_MODE_11A) {
|
|
|
|
ee->ee_i_cal[mode] = (val >> 8) & 0x3f;
|
|
|
|
ee->ee_q_cal[mode] = (val >> 3) & 0x1f;
|
|
|
|
}
|
|
|
|
|
2008-11-20 22:16:22 +08:00
|
|
|
if (ah->ah_ee_version < AR5K_EEPROM_VERSION_4_0)
|
|
|
|
goto done;
|
|
|
|
|
2008-12-21 10:47:39 +08:00
|
|
|
/* Note: >= v5 have bg freq piers on another location
|
|
|
|
* so these freq piers are ignored for >= v5 (should be 0xff
|
|
|
|
* anyway) */
|
2011-07-08 06:14:13 +08:00
|
|
|
switch (mode) {
|
2008-11-20 22:16:22 +08:00
|
|
|
case AR5K_EEPROM_MODE_11A:
|
|
|
|
if (ah->ah_ee_version < AR5K_EEPROM_VERSION_4_1)
|
|
|
|
break;
|
|
|
|
|
|
|
|
AR5K_EEPROM_READ(o++, val);
|
|
|
|
ee->ee_margin_tx_rx[mode] = val & 0x3f;
|
|
|
|
break;
|
|
|
|
case AR5K_EEPROM_MODE_11B:
|
|
|
|
AR5K_EEPROM_READ(o++, val);
|
|
|
|
|
|
|
|
ee->ee_pwr_cal_b[0].freq =
|
|
|
|
ath5k_eeprom_bin2freq(ee, val & 0xff, mode);
|
|
|
|
if (ee->ee_pwr_cal_b[0].freq != AR5K_EEPROM_CHANNEL_DIS)
|
|
|
|
ee->ee_n_piers[mode]++;
|
|
|
|
|
|
|
|
ee->ee_pwr_cal_b[1].freq =
|
|
|
|
ath5k_eeprom_bin2freq(ee, (val >> 8) & 0xff, mode);
|
|
|
|
if (ee->ee_pwr_cal_b[1].freq != AR5K_EEPROM_CHANNEL_DIS)
|
|
|
|
ee->ee_n_piers[mode]++;
|
|
|
|
|
|
|
|
AR5K_EEPROM_READ(o++, val);
|
|
|
|
ee->ee_pwr_cal_b[2].freq =
|
|
|
|
ath5k_eeprom_bin2freq(ee, val & 0xff, mode);
|
|
|
|
if (ee->ee_pwr_cal_b[2].freq != AR5K_EEPROM_CHANNEL_DIS)
|
|
|
|
ee->ee_n_piers[mode]++;
|
|
|
|
|
|
|
|
if (ah->ah_ee_version >= AR5K_EEPROM_VERSION_4_1)
|
|
|
|
ee->ee_margin_tx_rx[mode] = (val >> 8) & 0x3f;
|
|
|
|
break;
|
|
|
|
case AR5K_EEPROM_MODE_11G:
|
|
|
|
AR5K_EEPROM_READ(o++, val);
|
|
|
|
|
|
|
|
ee->ee_pwr_cal_g[0].freq =
|
|
|
|
ath5k_eeprom_bin2freq(ee, val & 0xff, mode);
|
|
|
|
if (ee->ee_pwr_cal_g[0].freq != AR5K_EEPROM_CHANNEL_DIS)
|
|
|
|
ee->ee_n_piers[mode]++;
|
|
|
|
|
|
|
|
ee->ee_pwr_cal_g[1].freq =
|
|
|
|
ath5k_eeprom_bin2freq(ee, (val >> 8) & 0xff, mode);
|
|
|
|
if (ee->ee_pwr_cal_g[1].freq != AR5K_EEPROM_CHANNEL_DIS)
|
|
|
|
ee->ee_n_piers[mode]++;
|
|
|
|
|
|
|
|
AR5K_EEPROM_READ(o++, val);
|
|
|
|
ee->ee_turbo_max_power[mode] = val & 0x7f;
|
|
|
|
ee->ee_xr_power[mode] = (val >> 7) & 0x3f;
|
|
|
|
|
|
|
|
AR5K_EEPROM_READ(o++, val);
|
|
|
|
ee->ee_pwr_cal_g[2].freq =
|
|
|
|
ath5k_eeprom_bin2freq(ee, val & 0xff, mode);
|
|
|
|
if (ee->ee_pwr_cal_g[2].freq != AR5K_EEPROM_CHANNEL_DIS)
|
|
|
|
ee->ee_n_piers[mode]++;
|
2008-08-30 03:45:39 +08:00
|
|
|
|
2008-11-20 22:16:22 +08:00
|
|
|
if (ah->ah_ee_version >= AR5K_EEPROM_VERSION_4_1)
|
|
|
|
ee->ee_margin_tx_rx[mode] = (val >> 8) & 0x3f;
|
|
|
|
|
|
|
|
AR5K_EEPROM_READ(o++, val);
|
2010-03-09 15:56:10 +08:00
|
|
|
ee->ee_i_cal[mode] = (val >> 5) & 0x3f;
|
|
|
|
ee->ee_q_cal[mode] = val & 0x1f;
|
2008-11-20 22:16:22 +08:00
|
|
|
|
|
|
|
if (ah->ah_ee_version >= AR5K_EEPROM_VERSION_4_2) {
|
|
|
|
AR5K_EEPROM_READ(o++, val);
|
|
|
|
ee->ee_cck_ofdm_gain_delta = val & 0xff;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-08-27 10:30:00 +08:00
|
|
|
/*
|
|
|
|
* Read turbo mode information on newer EEPROM versions
|
|
|
|
*/
|
2008-11-20 22:16:22 +08:00
|
|
|
if (ee->ee_version < AR5K_EEPROM_VERSION_5_0)
|
2009-08-27 10:30:00 +08:00
|
|
|
goto done;
|
2008-08-30 03:45:39 +08:00
|
|
|
|
2011-07-08 06:14:13 +08:00
|
|
|
switch (mode) {
|
2008-11-20 22:16:22 +08:00
|
|
|
case AR5K_EEPROM_MODE_11A:
|
|
|
|
ee->ee_switch_settling_turbo[mode] = (val >> 6) & 0x7f;
|
2008-08-30 03:45:39 +08:00
|
|
|
|
2008-11-20 22:16:22 +08:00
|
|
|
ee->ee_atn_tx_rx_turbo[mode] = (val >> 13) & 0x7;
|
|
|
|
AR5K_EEPROM_READ(o++, val);
|
|
|
|
ee->ee_atn_tx_rx_turbo[mode] |= (val & 0x7) << 3;
|
|
|
|
ee->ee_margin_tx_rx_turbo[mode] = (val >> 3) & 0x3f;
|
|
|
|
|
|
|
|
ee->ee_adc_desired_size_turbo[mode] = (val >> 9) & 0x7f;
|
|
|
|
AR5K_EEPROM_READ(o++, val);
|
|
|
|
ee->ee_adc_desired_size_turbo[mode] |= (val & 0x1) << 7;
|
|
|
|
ee->ee_pga_desired_size_turbo[mode] = (val >> 1) & 0xff;
|
|
|
|
|
2011-07-08 06:14:13 +08:00
|
|
|
if (AR5K_EEPROM_EEMAP(ee->ee_misc0) >= 2)
|
2008-11-20 22:16:22 +08:00
|
|
|
ee->ee_pd_gain_overlap = (val >> 9) & 0xf;
|
|
|
|
break;
|
|
|
|
case AR5K_EEPROM_MODE_11G:
|
|
|
|
ee->ee_switch_settling_turbo[mode] = (val >> 8) & 0x7f;
|
|
|
|
|
|
|
|
ee->ee_atn_tx_rx_turbo[mode] = (val >> 15) & 0x7;
|
|
|
|
AR5K_EEPROM_READ(o++, val);
|
|
|
|
ee->ee_atn_tx_rx_turbo[mode] |= (val & 0x1f) << 1;
|
|
|
|
ee->ee_margin_tx_rx_turbo[mode] = (val >> 5) & 0x3f;
|
|
|
|
|
|
|
|
ee->ee_adc_desired_size_turbo[mode] = (val >> 11) & 0x7f;
|
|
|
|
AR5K_EEPROM_READ(o++, val);
|
|
|
|
ee->ee_adc_desired_size_turbo[mode] |= (val & 0x7) << 5;
|
|
|
|
ee->ee_pga_desired_size_turbo[mode] = (val >> 3) & 0xff;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-08-27 10:30:00 +08:00
|
|
|
done:
|
2008-11-20 22:16:22 +08:00
|
|
|
/* return new offset */
|
|
|
|
*offset = o;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-12-21 10:47:39 +08:00
|
|
|
/* Read mode-specific data (except power calibration data) */
|
2008-11-20 22:16:22 +08:00
|
|
|
static int
|
|
|
|
ath5k_eeprom_init_modes(struct ath5k_hw *ah)
|
|
|
|
{
|
|
|
|
struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
|
|
|
|
u32 mode_offset[3];
|
|
|
|
unsigned int mode;
|
|
|
|
u32 offset;
|
|
|
|
int ret;
|
2008-08-30 03:45:39 +08:00
|
|
|
|
|
|
|
/*
|
2008-11-20 22:16:22 +08:00
|
|
|
* Get values for all modes
|
2008-08-30 03:45:39 +08:00
|
|
|
*/
|
2008-11-20 22:16:22 +08:00
|
|
|
mode_offset[AR5K_EEPROM_MODE_11A] = AR5K_EEPROM_MODES_11A(ah->ah_ee_version);
|
|
|
|
mode_offset[AR5K_EEPROM_MODE_11B] = AR5K_EEPROM_MODES_11B(ah->ah_ee_version);
|
|
|
|
mode_offset[AR5K_EEPROM_MODE_11G] = AR5K_EEPROM_MODES_11G(ah->ah_ee_version);
|
|
|
|
|
|
|
|
ee->ee_turbo_max_power[AR5K_EEPROM_MODE_11A] =
|
|
|
|
AR5K_EEPROM_HDR_T_5GHZ_DBM(ee->ee_header);
|
|
|
|
|
|
|
|
for (mode = AR5K_EEPROM_MODE_11A; mode <= AR5K_EEPROM_MODE_11G; mode++) {
|
|
|
|
offset = mode_offset[mode];
|
|
|
|
|
|
|
|
ret = ath5k_eeprom_read_ants(ah, &offset, mode);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
ret = ath5k_eeprom_read_modes(ah, &offset, mode);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2008-08-30 03:45:39 +08:00
|
|
|
}
|
2008-11-20 22:16:22 +08:00
|
|
|
|
|
|
|
/* override for older eeprom versions for better performance */
|
|
|
|
if (ah->ah_ee_version <= AR5K_EEPROM_VERSION_3_2) {
|
|
|
|
ee->ee_thr_62[AR5K_EEPROM_MODE_11A] = 15;
|
|
|
|
ee->ee_thr_62[AR5K_EEPROM_MODE_11B] = 28;
|
|
|
|
ee->ee_thr_62[AR5K_EEPROM_MODE_11G] = 28;
|
2008-08-30 03:45:39 +08:00
|
|
|
}
|
|
|
|
|
2008-11-20 22:16:22 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2008-08-30 03:45:39 +08:00
|
|
|
|
2008-12-21 10:47:39 +08:00
|
|
|
/* Read the frequency piers for each mode (mostly used on newer eeproms with 0xff
|
|
|
|
* frequency mask) */
|
2008-11-20 22:16:22 +08:00
|
|
|
static inline int
|
|
|
|
ath5k_eeprom_read_freq_list(struct ath5k_hw *ah, int *offset, int max,
|
2008-12-21 10:47:39 +08:00
|
|
|
struct ath5k_chan_pcal_info *pc, unsigned int mode)
|
2008-11-20 22:16:22 +08:00
|
|
|
{
|
2008-12-21 10:47:39 +08:00
|
|
|
struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
|
2008-11-20 22:16:22 +08:00
|
|
|
int o = *offset;
|
|
|
|
int i = 0;
|
2008-12-21 10:47:39 +08:00
|
|
|
u8 freq1, freq2;
|
2008-11-20 22:16:22 +08:00
|
|
|
u16 val;
|
|
|
|
|
2009-03-16 04:17:04 +08:00
|
|
|
ee->ee_n_piers[mode] = 0;
|
2011-07-08 06:14:13 +08:00
|
|
|
while (i < max) {
|
2008-11-20 22:16:22 +08:00
|
|
|
AR5K_EEPROM_READ(o++, val);
|
|
|
|
|
2009-03-16 04:17:04 +08:00
|
|
|
freq1 = val & 0xff;
|
|
|
|
if (!freq1)
|
|
|
|
break;
|
2008-11-20 22:16:22 +08:00
|
|
|
|
2009-03-16 04:17:04 +08:00
|
|
|
pc[i++].freq = ath5k_eeprom_bin2freq(ee,
|
|
|
|
freq1, mode);
|
|
|
|
ee->ee_n_piers[mode]++;
|
2008-11-20 22:16:22 +08:00
|
|
|
|
2009-03-16 04:17:04 +08:00
|
|
|
freq2 = (val >> 8) & 0xff;
|
|
|
|
if (!freq2)
|
2008-11-20 22:16:22 +08:00
|
|
|
break;
|
2009-03-16 04:17:04 +08:00
|
|
|
|
|
|
|
pc[i++].freq = ath5k_eeprom_bin2freq(ee,
|
|
|
|
freq2, mode);
|
|
|
|
ee->ee_n_piers[mode]++;
|
2008-08-30 03:45:39 +08:00
|
|
|
}
|
2008-12-21 10:47:39 +08:00
|
|
|
|
|
|
|
/* return new offset */
|
2008-11-20 22:16:22 +08:00
|
|
|
*offset = o;
|
2008-08-30 03:45:39 +08:00
|
|
|
|
2008-11-20 22:16:22 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-12-21 10:47:39 +08:00
|
|
|
/* Read frequency piers for 802.11a */
|
2008-11-20 22:16:22 +08:00
|
|
|
static int
|
|
|
|
ath5k_eeprom_init_11a_pcal_freq(struct ath5k_hw *ah, int offset)
|
|
|
|
{
|
|
|
|
struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
|
|
|
|
struct ath5k_chan_pcal_info *pcal = ee->ee_pwr_cal_a;
|
2011-01-11 16:00:31 +08:00
|
|
|
int i;
|
2008-11-20 22:16:22 +08:00
|
|
|
u16 val;
|
|
|
|
u8 mask;
|
|
|
|
|
|
|
|
if (ee->ee_version >= AR5K_EEPROM_VERSION_3_3) {
|
|
|
|
ath5k_eeprom_read_freq_list(ah, &offset,
|
|
|
|
AR5K_EEPROM_N_5GHZ_CHAN, pcal,
|
2008-12-21 10:47:39 +08:00
|
|
|
AR5K_EEPROM_MODE_11A);
|
2008-11-20 22:16:22 +08:00
|
|
|
} else {
|
|
|
|
mask = AR5K_EEPROM_FREQ_M(ah->ah_ee_version);
|
2008-08-30 03:45:39 +08:00
|
|
|
|
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
2008-11-20 22:16:22 +08:00
|
|
|
pcal[0].freq = (val >> 9) & mask;
|
|
|
|
pcal[1].freq = (val >> 2) & mask;
|
|
|
|
pcal[2].freq = (val << 5) & mask;
|
|
|
|
|
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
|
|
|
pcal[2].freq |= (val >> 11) & 0x1f;
|
|
|
|
pcal[3].freq = (val >> 4) & mask;
|
|
|
|
pcal[4].freq = (val << 3) & mask;
|
|
|
|
|
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
|
|
|
pcal[4].freq |= (val >> 13) & 0x7;
|
|
|
|
pcal[5].freq = (val >> 6) & mask;
|
|
|
|
pcal[6].freq = (val << 1) & mask;
|
|
|
|
|
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
|
|
|
pcal[6].freq |= (val >> 15) & 0x1;
|
|
|
|
pcal[7].freq = (val >> 8) & mask;
|
|
|
|
pcal[8].freq = (val >> 1) & mask;
|
|
|
|
pcal[9].freq = (val << 6) & mask;
|
|
|
|
|
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
|
|
|
pcal[9].freq |= (val >> 10) & 0x3f;
|
2008-12-21 10:47:39 +08:00
|
|
|
|
|
|
|
/* Fixed number of piers */
|
2008-11-20 22:16:22 +08:00
|
|
|
ee->ee_n_piers[AR5K_EEPROM_MODE_11A] = 10;
|
2008-08-30 03:45:39 +08:00
|
|
|
|
2008-12-21 10:47:39 +08:00
|
|
|
for (i = 0; i < AR5K_EEPROM_N_5GHZ_CHAN; i++) {
|
|
|
|
pcal[i].freq = ath5k_eeprom_bin2freq(ee,
|
2008-11-20 22:16:22 +08:00
|
|
|
pcal[i].freq, AR5K_EEPROM_MODE_11A);
|
2008-12-21 10:47:39 +08:00
|
|
|
}
|
2008-11-20 22:16:22 +08:00
|
|
|
}
|
2008-08-30 03:45:39 +08:00
|
|
|
|
2008-11-20 22:16:22 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2008-08-30 03:45:39 +08:00
|
|
|
|
2008-12-21 10:47:39 +08:00
|
|
|
/* Read frequency piers for 802.11bg on eeprom versions >= 5 and eemap >= 2 */
|
2008-11-20 22:16:22 +08:00
|
|
|
static inline int
|
|
|
|
ath5k_eeprom_init_11bg_2413(struct ath5k_hw *ah, unsigned int mode, int offset)
|
|
|
|
{
|
|
|
|
struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
|
|
|
|
struct ath5k_chan_pcal_info *pcal;
|
|
|
|
|
2011-07-08 06:14:13 +08:00
|
|
|
switch (mode) {
|
2008-11-20 22:16:22 +08:00
|
|
|
case AR5K_EEPROM_MODE_11B:
|
|
|
|
pcal = ee->ee_pwr_cal_b;
|
|
|
|
break;
|
|
|
|
case AR5K_EEPROM_MODE_11G:
|
|
|
|
pcal = ee->ee_pwr_cal_g;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2008-08-30 03:45:39 +08:00
|
|
|
|
2008-11-20 22:16:22 +08:00
|
|
|
ath5k_eeprom_read_freq_list(ah, &offset,
|
|
|
|
AR5K_EEPROM_N_2GHZ_CHAN_2413, pcal,
|
2008-12-21 10:47:39 +08:00
|
|
|
mode);
|
2008-08-30 03:45:39 +08:00
|
|
|
|
2008-11-20 22:16:22 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2008-08-30 03:45:39 +08:00
|
|
|
|
2010-11-24 02:36:45 +08:00
|
|
|
|
2009-03-16 04:17:04 +08:00
|
|
|
/*
|
|
|
|
* Read power calibration for RF5111 chips
|
|
|
|
*
|
2008-12-21 10:47:39 +08:00
|
|
|
* For RF5111 we have an XPD -eXternal Power Detector- curve
|
2009-03-16 04:17:04 +08:00
|
|
|
* for each calibrated channel. Each curve has 0,5dB Power steps
|
|
|
|
* on x axis and PCDAC steps (offsets) on y axis and looks like an
|
|
|
|
* exponential function. To recreate the curve we read 11 points
|
|
|
|
* here and interpolate later.
|
2008-12-21 10:47:39 +08:00
|
|
|
*/
|
2009-03-16 04:17:04 +08:00
|
|
|
|
|
|
|
/* Used to match PCDAC steps with power values on RF5111 chips
|
|
|
|
* (eeprom versions < 4). For RF5111 we have 11 pre-defined PCDAC
|
|
|
|
* steps that match with the power values we read from eeprom. On
|
2011-07-09 12:17:51 +08:00
|
|
|
* older eeprom versions (< 3.2) these steps are equally spaced at
|
2010-08-16 01:03:12 +08:00
|
|
|
* 10% of the pcdac curve -until the curve reaches its maximum-
|
2009-03-16 04:17:04 +08:00
|
|
|
* (11 steps from 0 to 100%) but on newer eeprom versions (>= 3.2)
|
|
|
|
* these 11 steps are spaced in a different way. This function returns
|
|
|
|
* the pcdac steps based on eeprom version and curve min/max so that we
|
|
|
|
* can have pcdac/pwr points.
|
|
|
|
*/
|
|
|
|
static inline void
|
|
|
|
ath5k_get_pcdac_intercepts(struct ath5k_hw *ah, u8 min, u8 max, u8 *vp)
|
|
|
|
{
|
2011-07-08 06:14:07 +08:00
|
|
|
static const u16 intercepts3[] = {
|
|
|
|
0, 5, 10, 20, 30, 50, 70, 85, 90, 95, 100
|
|
|
|
};
|
|
|
|
static const u16 intercepts3_2[] = {
|
|
|
|
0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100
|
|
|
|
};
|
2009-03-16 04:17:04 +08:00
|
|
|
const u16 *ip;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (ah->ah_ee_version >= AR5K_EEPROM_VERSION_3_2)
|
|
|
|
ip = intercepts3_2;
|
|
|
|
else
|
|
|
|
ip = intercepts3;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(intercepts3); i++)
|
|
|
|
vp[i] = (ip[i] * max + (100 - ip[i]) * min) / 100;
|
|
|
|
}
|
|
|
|
|
2011-04-09 03:33:12 +08:00
|
|
|
static int
|
|
|
|
ath5k_eeprom_free_pcal_info(struct ath5k_hw *ah, int mode)
|
|
|
|
{
|
|
|
|
struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
|
|
|
|
struct ath5k_chan_pcal_info *chinfo;
|
|
|
|
u8 pier, pdg;
|
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
case AR5K_EEPROM_MODE_11A:
|
|
|
|
if (!AR5K_EEPROM_HDR_11A(ee->ee_header))
|
|
|
|
return 0;
|
|
|
|
chinfo = ee->ee_pwr_cal_a;
|
|
|
|
break;
|
|
|
|
case AR5K_EEPROM_MODE_11B:
|
|
|
|
if (!AR5K_EEPROM_HDR_11B(ee->ee_header))
|
|
|
|
return 0;
|
|
|
|
chinfo = ee->ee_pwr_cal_b;
|
|
|
|
break;
|
|
|
|
case AR5K_EEPROM_MODE_11G:
|
|
|
|
if (!AR5K_EEPROM_HDR_11G(ee->ee_header))
|
|
|
|
return 0;
|
|
|
|
chinfo = ee->ee_pwr_cal_g;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (pier = 0; pier < ee->ee_n_piers[mode]; pier++) {
|
|
|
|
if (!chinfo[pier].pd_curves)
|
|
|
|
continue;
|
|
|
|
|
2011-06-29 11:04:51 +08:00
|
|
|
for (pdg = 0; pdg < AR5K_EEPROM_N_PD_CURVES; pdg++) {
|
2011-04-09 03:33:12 +08:00
|
|
|
struct ath5k_pdgain_info *pd =
|
|
|
|
&chinfo[pier].pd_curves[pdg];
|
|
|
|
|
2011-06-29 11:04:51 +08:00
|
|
|
kfree(pd->pd_step);
|
|
|
|
kfree(pd->pd_pwr);
|
2011-04-09 03:33:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
kfree(chinfo[pier].pd_curves);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-03-16 04:17:04 +08:00
|
|
|
/* Convert RF5111 specific data to generic raw data
|
|
|
|
* used by interpolation code */
|
|
|
|
static int
|
|
|
|
ath5k_eeprom_convert_pcal_info_5111(struct ath5k_hw *ah, int mode,
|
|
|
|
struct ath5k_chan_pcal_info *chinfo)
|
|
|
|
{
|
|
|
|
struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
|
|
|
|
struct ath5k_chan_pcal_info_rf5111 *pcinfo;
|
|
|
|
struct ath5k_pdgain_info *pd;
|
|
|
|
u8 pier, point, idx;
|
|
|
|
u8 *pdgain_idx = ee->ee_pdc_to_idx[mode];
|
|
|
|
|
|
|
|
/* Fill raw data for each calibration pier */
|
|
|
|
for (pier = 0; pier < ee->ee_n_piers[mode]; pier++) {
|
|
|
|
|
|
|
|
pcinfo = &chinfo[pier].rf5111_info;
|
|
|
|
|
|
|
|
/* Allocate pd_curves for this cal pier */
|
|
|
|
chinfo[pier].pd_curves =
|
|
|
|
kcalloc(AR5K_EEPROM_N_PD_CURVES,
|
|
|
|
sizeof(struct ath5k_pdgain_info),
|
|
|
|
GFP_KERNEL);
|
|
|
|
|
|
|
|
if (!chinfo[pier].pd_curves)
|
2011-04-09 03:33:12 +08:00
|
|
|
goto err_out;
|
2009-03-16 04:17:04 +08:00
|
|
|
|
|
|
|
/* Only one curve for RF5111
|
|
|
|
* find out which one and place
|
2010-05-18 19:44:54 +08:00
|
|
|
* in pd_curves.
|
2009-03-16 04:17:04 +08:00
|
|
|
* Note: ee_x_gain is reversed here */
|
|
|
|
for (idx = 0; idx < AR5K_EEPROM_N_PD_CURVES; idx++) {
|
|
|
|
|
|
|
|
if (!((ee->ee_x_gain[mode] >> idx) & 0x1)) {
|
|
|
|
pdgain_idx[0] = idx;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ee->ee_pd_gains[mode] = 1;
|
|
|
|
|
|
|
|
pd = &chinfo[pier].pd_curves[idx];
|
|
|
|
|
|
|
|
pd->pd_points = AR5K_EEPROM_N_PWR_POINTS_5111;
|
|
|
|
|
|
|
|
/* Allocate pd points for this curve */
|
|
|
|
pd->pd_step = kcalloc(AR5K_EEPROM_N_PWR_POINTS_5111,
|
|
|
|
sizeof(u8), GFP_KERNEL);
|
|
|
|
if (!pd->pd_step)
|
2011-04-09 03:33:12 +08:00
|
|
|
goto err_out;
|
2009-03-16 04:17:04 +08:00
|
|
|
|
|
|
|
pd->pd_pwr = kcalloc(AR5K_EEPROM_N_PWR_POINTS_5111,
|
|
|
|
sizeof(s16), GFP_KERNEL);
|
|
|
|
if (!pd->pd_pwr)
|
2011-04-09 03:33:12 +08:00
|
|
|
goto err_out;
|
2009-03-16 04:17:04 +08:00
|
|
|
|
|
|
|
/* Fill raw dataset
|
|
|
|
* (convert power to 0.25dB units
|
2011-07-09 12:17:51 +08:00
|
|
|
* for RF5112 compatibility) */
|
2009-03-16 04:17:04 +08:00
|
|
|
for (point = 0; point < pd->pd_points; point++) {
|
|
|
|
|
|
|
|
/* Absolute values */
|
|
|
|
pd->pd_pwr[point] = 2 * pcinfo->pwr[point];
|
|
|
|
|
|
|
|
/* Already sorted */
|
|
|
|
pd->pd_step[point] = pcinfo->pcdac[point];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set min/max pwr */
|
|
|
|
chinfo[pier].min_pwr = pd->pd_pwr[0];
|
|
|
|
chinfo[pier].max_pwr = pd->pd_pwr[10];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2011-04-09 03:33:12 +08:00
|
|
|
|
|
|
|
err_out:
|
|
|
|
ath5k_eeprom_free_pcal_info(ah, mode);
|
|
|
|
return -ENOMEM;
|
2009-03-16 04:17:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Parse EEPROM data */
|
2008-11-20 22:16:22 +08:00
|
|
|
static int
|
|
|
|
ath5k_eeprom_read_pcal_info_5111(struct ath5k_hw *ah, int mode)
|
|
|
|
{
|
|
|
|
struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
|
|
|
|
struct ath5k_chan_pcal_info *pcal;
|
|
|
|
int offset, ret;
|
2008-12-22 18:35:55 +08:00
|
|
|
int i;
|
2008-11-20 22:16:22 +08:00
|
|
|
u16 val;
|
|
|
|
|
|
|
|
offset = AR5K_EEPROM_GROUPS_START(ee->ee_version);
|
2011-07-08 06:14:13 +08:00
|
|
|
switch (mode) {
|
2008-11-20 22:16:22 +08:00
|
|
|
case AR5K_EEPROM_MODE_11A:
|
|
|
|
if (!AR5K_EEPROM_HDR_11A(ee->ee_header))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
ret = ath5k_eeprom_init_11a_pcal_freq(ah,
|
|
|
|
offset + AR5K_EEPROM_GROUP1_OFFSET);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
offset += AR5K_EEPROM_GROUP2_OFFSET;
|
|
|
|
pcal = ee->ee_pwr_cal_a;
|
|
|
|
break;
|
|
|
|
case AR5K_EEPROM_MODE_11B:
|
|
|
|
if (!AR5K_EEPROM_HDR_11B(ee->ee_header) &&
|
|
|
|
!AR5K_EEPROM_HDR_11G(ee->ee_header))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
pcal = ee->ee_pwr_cal_b;
|
|
|
|
offset += AR5K_EEPROM_GROUP3_OFFSET;
|
|
|
|
|
|
|
|
/* fixed piers */
|
|
|
|
pcal[0].freq = 2412;
|
|
|
|
pcal[1].freq = 2447;
|
|
|
|
pcal[2].freq = 2484;
|
|
|
|
ee->ee_n_piers[mode] = 3;
|
|
|
|
break;
|
|
|
|
case AR5K_EEPROM_MODE_11G:
|
|
|
|
if (!AR5K_EEPROM_HDR_11G(ee->ee_header))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
pcal = ee->ee_pwr_cal_g;
|
|
|
|
offset += AR5K_EEPROM_GROUP4_OFFSET;
|
|
|
|
|
|
|
|
/* fixed piers */
|
|
|
|
pcal[0].freq = 2312;
|
|
|
|
pcal[1].freq = 2412;
|
|
|
|
pcal[2].freq = 2484;
|
|
|
|
ee->ee_n_piers[mode] = 3;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
2008-08-30 03:45:39 +08:00
|
|
|
}
|
|
|
|
|
2008-11-20 22:16:22 +08:00
|
|
|
for (i = 0; i < ee->ee_n_piers[mode]; i++) {
|
|
|
|
struct ath5k_chan_pcal_info_rf5111 *cdata =
|
|
|
|
&pcal[i].rf5111_info;
|
2008-08-30 03:45:39 +08:00
|
|
|
|
2008-11-20 22:16:22 +08:00
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
|
|
|
cdata->pcdac_max = ((val >> 10) & AR5K_EEPROM_PCDAC_M);
|
|
|
|
cdata->pcdac_min = ((val >> 4) & AR5K_EEPROM_PCDAC_M);
|
|
|
|
cdata->pwr[0] = ((val << 2) & AR5K_EEPROM_POWER_M);
|
2008-08-30 03:45:39 +08:00
|
|
|
|
2008-11-20 22:16:22 +08:00
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
|
|
|
cdata->pwr[0] |= ((val >> 14) & 0x3);
|
|
|
|
cdata->pwr[1] = ((val >> 8) & AR5K_EEPROM_POWER_M);
|
|
|
|
cdata->pwr[2] = ((val >> 2) & AR5K_EEPROM_POWER_M);
|
|
|
|
cdata->pwr[3] = ((val << 4) & AR5K_EEPROM_POWER_M);
|
2008-08-30 03:45:39 +08:00
|
|
|
|
2008-11-20 22:16:22 +08:00
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
|
|
|
cdata->pwr[3] |= ((val >> 12) & 0xf);
|
|
|
|
cdata->pwr[4] = ((val >> 6) & AR5K_EEPROM_POWER_M);
|
|
|
|
cdata->pwr[5] = (val & AR5K_EEPROM_POWER_M);
|
2008-08-30 03:45:39 +08:00
|
|
|
|
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
2008-11-20 22:16:22 +08:00
|
|
|
cdata->pwr[6] = ((val >> 10) & AR5K_EEPROM_POWER_M);
|
|
|
|
cdata->pwr[7] = ((val >> 4) & AR5K_EEPROM_POWER_M);
|
|
|
|
cdata->pwr[8] = ((val << 2) & AR5K_EEPROM_POWER_M);
|
2008-08-30 03:45:39 +08:00
|
|
|
|
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
2008-11-20 22:16:22 +08:00
|
|
|
cdata->pwr[8] |= ((val >> 14) & 0x3);
|
|
|
|
cdata->pwr[9] = ((val >> 8) & AR5K_EEPROM_POWER_M);
|
|
|
|
cdata->pwr[10] = ((val >> 2) & AR5K_EEPROM_POWER_M);
|
|
|
|
|
|
|
|
ath5k_get_pcdac_intercepts(ah, cdata->pcdac_min,
|
|
|
|
cdata->pcdac_max, cdata->pcdac);
|
2008-08-30 03:45:39 +08:00
|
|
|
}
|
|
|
|
|
2009-03-16 04:17:04 +08:00
|
|
|
return ath5k_eeprom_convert_pcal_info_5111(ah, mode, pcal);
|
2008-11-20 22:16:22 +08:00
|
|
|
}
|
2008-08-30 03:45:39 +08:00
|
|
|
|
2009-03-16 04:17:04 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Read power calibration for RF5112 chips
|
|
|
|
*
|
2008-12-21 10:47:39 +08:00
|
|
|
* For RF5112 we have 4 XPD -eXternal Power Detector- curves
|
2011-07-09 12:17:51 +08:00
|
|
|
* for each calibrated channel on 0, -6, -12 and -18dBm but we only
|
2009-03-16 04:17:04 +08:00
|
|
|
* use the higher (3) and the lower (0) curves. Each curve has 0.5dB
|
|
|
|
* power steps on x axis and PCDAC steps on y axis and looks like a
|
|
|
|
* linear function. To recreate the curve and pass the power values
|
|
|
|
* on hw, we read 4 points for xpd 0 (lower gain -> max power)
|
|
|
|
* and 3 points for xpd 3 (higher gain -> lower power) here and
|
|
|
|
* interpolate later.
|
2008-12-21 10:47:39 +08:00
|
|
|
*
|
|
|
|
* Note: Many vendors just use xpd 0 so xpd 3 is zeroed.
|
|
|
|
*/
|
2009-03-16 04:17:04 +08:00
|
|
|
|
|
|
|
/* Convert RF5112 specific data to generic raw data
|
|
|
|
* used by interpolation code */
|
|
|
|
static int
|
|
|
|
ath5k_eeprom_convert_pcal_info_5112(struct ath5k_hw *ah, int mode,
|
|
|
|
struct ath5k_chan_pcal_info *chinfo)
|
|
|
|
{
|
|
|
|
struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
|
|
|
|
struct ath5k_chan_pcal_info_rf5112 *pcinfo;
|
|
|
|
u8 *pdgain_idx = ee->ee_pdc_to_idx[mode];
|
|
|
|
unsigned int pier, pdg, point;
|
|
|
|
|
|
|
|
/* Fill raw data for each calibration pier */
|
|
|
|
for (pier = 0; pier < ee->ee_n_piers[mode]; pier++) {
|
|
|
|
|
|
|
|
pcinfo = &chinfo[pier].rf5112_info;
|
|
|
|
|
|
|
|
/* Allocate pd_curves for this cal pier */
|
|
|
|
chinfo[pier].pd_curves =
|
|
|
|
kcalloc(AR5K_EEPROM_N_PD_CURVES,
|
|
|
|
sizeof(struct ath5k_pdgain_info),
|
|
|
|
GFP_KERNEL);
|
|
|
|
|
|
|
|
if (!chinfo[pier].pd_curves)
|
2011-04-09 03:33:12 +08:00
|
|
|
goto err_out;
|
2009-03-16 04:17:04 +08:00
|
|
|
|
|
|
|
/* Fill pd_curves */
|
|
|
|
for (pdg = 0; pdg < ee->ee_pd_gains[mode]; pdg++) {
|
|
|
|
|
|
|
|
u8 idx = pdgain_idx[pdg];
|
|
|
|
struct ath5k_pdgain_info *pd =
|
|
|
|
&chinfo[pier].pd_curves[idx];
|
|
|
|
|
|
|
|
/* Lowest gain curve (max power) */
|
|
|
|
if (pdg == 0) {
|
|
|
|
/* One more point for better accuracy */
|
|
|
|
pd->pd_points = AR5K_EEPROM_N_XPD0_POINTS;
|
|
|
|
|
|
|
|
/* Allocate pd points for this curve */
|
|
|
|
pd->pd_step = kcalloc(pd->pd_points,
|
|
|
|
sizeof(u8), GFP_KERNEL);
|
|
|
|
|
|
|
|
if (!pd->pd_step)
|
2011-04-09 03:33:12 +08:00
|
|
|
goto err_out;
|
2009-03-16 04:17:04 +08:00
|
|
|
|
|
|
|
pd->pd_pwr = kcalloc(pd->pd_points,
|
|
|
|
sizeof(s16), GFP_KERNEL);
|
|
|
|
|
|
|
|
if (!pd->pd_pwr)
|
2011-04-09 03:33:12 +08:00
|
|
|
goto err_out;
|
2009-03-16 04:17:04 +08:00
|
|
|
|
|
|
|
/* Fill raw dataset
|
|
|
|
* (all power levels are in 0.25dB units) */
|
|
|
|
pd->pd_step[0] = pcinfo->pcdac_x0[0];
|
|
|
|
pd->pd_pwr[0] = pcinfo->pwr_x0[0];
|
|
|
|
|
|
|
|
for (point = 1; point < pd->pd_points;
|
|
|
|
point++) {
|
|
|
|
/* Absolute values */
|
|
|
|
pd->pd_pwr[point] =
|
|
|
|
pcinfo->pwr_x0[point];
|
|
|
|
|
|
|
|
/* Deltas */
|
|
|
|
pd->pd_step[point] =
|
|
|
|
pd->pd_step[point - 1] +
|
|
|
|
pcinfo->pcdac_x0[point];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set min power for this frequency */
|
|
|
|
chinfo[pier].min_pwr = pd->pd_pwr[0];
|
|
|
|
|
|
|
|
/* Highest gain curve (min power) */
|
|
|
|
} else if (pdg == 1) {
|
|
|
|
|
|
|
|
pd->pd_points = AR5K_EEPROM_N_XPD3_POINTS;
|
|
|
|
|
|
|
|
/* Allocate pd points for this curve */
|
|
|
|
pd->pd_step = kcalloc(pd->pd_points,
|
|
|
|
sizeof(u8), GFP_KERNEL);
|
|
|
|
|
|
|
|
if (!pd->pd_step)
|
2011-04-09 03:33:12 +08:00
|
|
|
goto err_out;
|
2009-03-16 04:17:04 +08:00
|
|
|
|
|
|
|
pd->pd_pwr = kcalloc(pd->pd_points,
|
|
|
|
sizeof(s16), GFP_KERNEL);
|
|
|
|
|
|
|
|
if (!pd->pd_pwr)
|
2011-04-09 03:33:12 +08:00
|
|
|
goto err_out;
|
2009-03-16 04:17:04 +08:00
|
|
|
|
|
|
|
/* Fill raw dataset
|
|
|
|
* (all power levels are in 0.25dB units) */
|
|
|
|
for (point = 0; point < pd->pd_points;
|
|
|
|
point++) {
|
|
|
|
/* Absolute values */
|
|
|
|
pd->pd_pwr[point] =
|
|
|
|
pcinfo->pwr_x3[point];
|
|
|
|
|
|
|
|
/* Fixed points */
|
|
|
|
pd->pd_step[point] =
|
|
|
|
pcinfo->pcdac_x3[point];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Since we have a higher gain curve
|
|
|
|
* override min power */
|
|
|
|
chinfo[pier].min_pwr = pd->pd_pwr[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2011-04-09 03:33:12 +08:00
|
|
|
|
|
|
|
err_out:
|
|
|
|
ath5k_eeprom_free_pcal_info(ah, mode);
|
|
|
|
return -ENOMEM;
|
2009-03-16 04:17:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Parse EEPROM data */
|
2008-11-20 22:16:22 +08:00
|
|
|
static int
|
|
|
|
ath5k_eeprom_read_pcal_info_5112(struct ath5k_hw *ah, int mode)
|
|
|
|
{
|
|
|
|
struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
|
|
|
|
struct ath5k_chan_pcal_info_rf5112 *chan_pcal_info;
|
|
|
|
struct ath5k_chan_pcal_info *gen_chan_info;
|
2009-03-16 04:17:04 +08:00
|
|
|
u8 *pdgain_idx = ee->ee_pdc_to_idx[mode];
|
2008-11-20 22:16:22 +08:00
|
|
|
u32 offset;
|
2009-03-16 04:17:04 +08:00
|
|
|
u8 i, c;
|
2008-11-20 22:16:22 +08:00
|
|
|
u16 val;
|
2009-03-16 04:17:04 +08:00
|
|
|
u8 pd_gains = 0;
|
|
|
|
|
|
|
|
/* Count how many curves we have and
|
|
|
|
* identify them (which one of the 4
|
|
|
|
* available curves we have on each count).
|
|
|
|
* Curves are stored from lower (x0) to
|
|
|
|
* higher (x3) gain */
|
|
|
|
for (i = 0; i < AR5K_EEPROM_N_PD_CURVES; i++) {
|
|
|
|
/* ee_x_gain[mode] is x gain mask */
|
|
|
|
if ((ee->ee_x_gain[mode] >> i) & 0x1)
|
|
|
|
pdgain_idx[pd_gains++] = i;
|
|
|
|
}
|
|
|
|
ee->ee_pd_gains[mode] = pd_gains;
|
|
|
|
|
|
|
|
if (pd_gains == 0 || pd_gains > 2)
|
|
|
|
return -EINVAL;
|
2008-08-30 03:45:39 +08:00
|
|
|
|
2008-11-20 22:16:22 +08:00
|
|
|
switch (mode) {
|
|
|
|
case AR5K_EEPROM_MODE_11A:
|
|
|
|
/*
|
|
|
|
* Read 5GHz EEPROM channels
|
|
|
|
*/
|
|
|
|
offset = AR5K_EEPROM_GROUPS_START(ee->ee_version);
|
|
|
|
ath5k_eeprom_init_11a_pcal_freq(ah, offset);
|
|
|
|
|
|
|
|
offset += AR5K_EEPROM_GROUP2_OFFSET;
|
|
|
|
gen_chan_info = ee->ee_pwr_cal_a;
|
|
|
|
break;
|
|
|
|
case AR5K_EEPROM_MODE_11B:
|
|
|
|
offset = AR5K_EEPROM_GROUPS_START(ee->ee_version);
|
|
|
|
if (AR5K_EEPROM_HDR_11A(ee->ee_header))
|
|
|
|
offset += AR5K_EEPROM_GROUP3_OFFSET;
|
|
|
|
|
|
|
|
/* NB: frequency piers parsed during mode init */
|
|
|
|
gen_chan_info = ee->ee_pwr_cal_b;
|
|
|
|
break;
|
|
|
|
case AR5K_EEPROM_MODE_11G:
|
|
|
|
offset = AR5K_EEPROM_GROUPS_START(ee->ee_version);
|
|
|
|
if (AR5K_EEPROM_HDR_11A(ee->ee_header))
|
|
|
|
offset += AR5K_EEPROM_GROUP4_OFFSET;
|
|
|
|
else if (AR5K_EEPROM_HDR_11B(ee->ee_header))
|
|
|
|
offset += AR5K_EEPROM_GROUP2_OFFSET;
|
|
|
|
|
|
|
|
/* NB: frequency piers parsed during mode init */
|
|
|
|
gen_chan_info = ee->ee_pwr_cal_g;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2008-08-30 03:45:39 +08:00
|
|
|
|
2008-11-20 22:16:22 +08:00
|
|
|
for (i = 0; i < ee->ee_n_piers[mode]; i++) {
|
|
|
|
chan_pcal_info = &gen_chan_info[i].rf5112_info;
|
2008-08-30 03:45:39 +08:00
|
|
|
|
2009-03-16 04:17:04 +08:00
|
|
|
/* Power values in quarter dB
|
2008-11-20 22:16:22 +08:00
|
|
|
* for the lower xpd gain curve
|
|
|
|
* (0 dBm -> higher output power) */
|
|
|
|
for (c = 0; c < AR5K_EEPROM_N_XPD0_POINTS; c++) {
|
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
2009-03-16 04:17:04 +08:00
|
|
|
chan_pcal_info->pwr_x0[c] = (s8) (val & 0xff);
|
|
|
|
chan_pcal_info->pwr_x0[++c] = (s8) ((val >> 8) & 0xff);
|
2008-11-20 22:16:22 +08:00
|
|
|
}
|
2008-08-30 03:45:39 +08:00
|
|
|
|
2008-11-20 22:16:22 +08:00
|
|
|
/* PCDAC steps
|
|
|
|
* corresponding to the above power
|
|
|
|
* measurements */
|
2008-08-30 03:45:39 +08:00
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
2008-11-20 22:16:22 +08:00
|
|
|
chan_pcal_info->pcdac_x0[1] = (val & 0x1f);
|
|
|
|
chan_pcal_info->pcdac_x0[2] = ((val >> 5) & 0x1f);
|
|
|
|
chan_pcal_info->pcdac_x0[3] = ((val >> 10) & 0x1f);
|
2008-08-30 03:45:39 +08:00
|
|
|
|
2009-03-16 04:17:04 +08:00
|
|
|
/* Power values in quarter dB
|
2008-11-20 22:16:22 +08:00
|
|
|
* for the higher xpd gain curve
|
|
|
|
* (18 dBm -> lower output power) */
|
2008-08-30 03:45:39 +08:00
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
2009-03-16 04:17:04 +08:00
|
|
|
chan_pcal_info->pwr_x3[0] = (s8) (val & 0xff);
|
|
|
|
chan_pcal_info->pwr_x3[1] = (s8) ((val >> 8) & 0xff);
|
2008-08-30 03:45:39 +08:00
|
|
|
|
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
2008-11-20 22:16:22 +08:00
|
|
|
chan_pcal_info->pwr_x3[2] = (val & 0xff);
|
|
|
|
|
|
|
|
/* PCDAC steps
|
|
|
|
* corresponding to the above power
|
2008-12-21 10:47:39 +08:00
|
|
|
* measurements (fixed) */
|
2008-11-20 22:16:22 +08:00
|
|
|
chan_pcal_info->pcdac_x3[0] = 20;
|
|
|
|
chan_pcal_info->pcdac_x3[1] = 35;
|
|
|
|
chan_pcal_info->pcdac_x3[2] = 63;
|
|
|
|
|
|
|
|
if (ee->ee_version >= AR5K_EEPROM_VERSION_4_3) {
|
2009-03-16 04:17:04 +08:00
|
|
|
chan_pcal_info->pcdac_x0[0] = ((val >> 8) & 0x3f);
|
2008-11-20 22:16:22 +08:00
|
|
|
|
|
|
|
/* Last xpd0 power level is also channel maximum */
|
|
|
|
gen_chan_info[i].max_pwr = chan_pcal_info->pwr_x0[3];
|
|
|
|
} else {
|
|
|
|
chan_pcal_info->pcdac_x0[0] = 1;
|
2009-03-16 04:17:04 +08:00
|
|
|
gen_chan_info[i].max_pwr = (s8) ((val >> 8) & 0xff);
|
2008-11-20 22:16:22 +08:00
|
|
|
}
|
2008-08-30 03:45:39 +08:00
|
|
|
|
2008-11-20 22:16:22 +08:00
|
|
|
}
|
|
|
|
|
2009-03-16 04:17:04 +08:00
|
|
|
return ath5k_eeprom_convert_pcal_info_5112(ah, mode, gen_chan_info);
|
2008-11-20 22:16:22 +08:00
|
|
|
}
|
|
|
|
|
2009-03-16 04:17:04 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Read power calibration for RF2413 chips
|
|
|
|
*
|
|
|
|
* For RF2413 we have a Power to PDDAC table (Power Detector)
|
|
|
|
* instead of a PCDAC and 4 pd gain curves for each calibrated channel.
|
|
|
|
* Each curve has power on x axis in 0.5 db steps and PDDADC steps on y
|
|
|
|
* axis and looks like an exponential function like the RF5111 curve.
|
|
|
|
*
|
|
|
|
* To recreate the curves we read here the points and interpolate
|
|
|
|
* later. Note that in most cases only 2 (higher and lower) curves are
|
2011-03-31 09:57:33 +08:00
|
|
|
* used (like RF5112) but vendors have the opportunity to include all
|
2009-03-16 04:17:04 +08:00
|
|
|
* 4 curves on eeprom. The final curve (higher power) has an extra
|
|
|
|
* point for better accuracy like RF5112.
|
|
|
|
*/
|
|
|
|
|
2008-12-21 10:47:39 +08:00
|
|
|
/* For RF2413 power calibration data doesn't start on a fixed location and
|
2010-08-16 01:03:12 +08:00
|
|
|
* if a mode is not supported, its section is missing -not zeroed-.
|
2008-12-21 10:47:39 +08:00
|
|
|
* So we need to calculate the starting offset for each section by using
|
|
|
|
* these two functions */
|
|
|
|
|
|
|
|
/* Return the size of each section based on the mode and the number of pd
|
|
|
|
* gains available (maximum 4). */
|
2008-11-20 22:16:22 +08:00
|
|
|
static inline unsigned int
|
|
|
|
ath5k_pdgains_size_2413(struct ath5k_eeprom_info *ee, unsigned int mode)
|
|
|
|
{
|
|
|
|
static const unsigned int pdgains_size[] = { 4, 6, 9, 12 };
|
|
|
|
unsigned int sz;
|
|
|
|
|
|
|
|
sz = pdgains_size[ee->ee_pd_gains[mode] - 1];
|
|
|
|
sz *= ee->ee_n_piers[mode];
|
|
|
|
|
|
|
|
return sz;
|
|
|
|
}
|
|
|
|
|
2008-12-21 10:47:39 +08:00
|
|
|
/* Return the starting offset for a section based on the modes supported
|
|
|
|
* and each section's size. */
|
2008-11-20 22:16:22 +08:00
|
|
|
static unsigned int
|
|
|
|
ath5k_cal_data_offset_2413(struct ath5k_eeprom_info *ee, int mode)
|
|
|
|
{
|
|
|
|
u32 offset = AR5K_EEPROM_CAL_DATA_START(ee->ee_misc4);
|
|
|
|
|
2011-07-08 06:14:13 +08:00
|
|
|
switch (mode) {
|
2008-11-20 22:16:22 +08:00
|
|
|
case AR5K_EEPROM_MODE_11G:
|
|
|
|
if (AR5K_EEPROM_HDR_11B(ee->ee_header))
|
2009-03-16 04:17:04 +08:00
|
|
|
offset += ath5k_pdgains_size_2413(ee,
|
|
|
|
AR5K_EEPROM_MODE_11B) +
|
|
|
|
AR5K_EEPROM_N_2GHZ_CHAN_2413 / 2;
|
2008-11-20 22:16:22 +08:00
|
|
|
/* fall through */
|
|
|
|
case AR5K_EEPROM_MODE_11B:
|
|
|
|
if (AR5K_EEPROM_HDR_11A(ee->ee_header))
|
2009-03-16 04:17:04 +08:00
|
|
|
offset += ath5k_pdgains_size_2413(ee,
|
|
|
|
AR5K_EEPROM_MODE_11A) +
|
|
|
|
AR5K_EEPROM_N_5GHZ_CHAN / 2;
|
2008-11-20 22:16:22 +08:00
|
|
|
/* fall through */
|
|
|
|
case AR5K_EEPROM_MODE_11A:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
2009-03-16 04:17:04 +08:00
|
|
|
/* Convert RF2413 specific data to generic raw data
|
|
|
|
* used by interpolation code */
|
|
|
|
static int
|
|
|
|
ath5k_eeprom_convert_pcal_info_2413(struct ath5k_hw *ah, int mode,
|
|
|
|
struct ath5k_chan_pcal_info *chinfo)
|
|
|
|
{
|
|
|
|
struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
|
|
|
|
struct ath5k_chan_pcal_info_rf2413 *pcinfo;
|
|
|
|
u8 *pdgain_idx = ee->ee_pdc_to_idx[mode];
|
|
|
|
unsigned int pier, pdg, point;
|
|
|
|
|
|
|
|
/* Fill raw data for each calibration pier */
|
|
|
|
for (pier = 0; pier < ee->ee_n_piers[mode]; pier++) {
|
|
|
|
|
|
|
|
pcinfo = &chinfo[pier].rf2413_info;
|
|
|
|
|
|
|
|
/* Allocate pd_curves for this cal pier */
|
|
|
|
chinfo[pier].pd_curves =
|
|
|
|
kcalloc(AR5K_EEPROM_N_PD_CURVES,
|
|
|
|
sizeof(struct ath5k_pdgain_info),
|
|
|
|
GFP_KERNEL);
|
|
|
|
|
|
|
|
if (!chinfo[pier].pd_curves)
|
2011-04-09 03:33:12 +08:00
|
|
|
goto err_out;
|
2009-03-16 04:17:04 +08:00
|
|
|
|
|
|
|
/* Fill pd_curves */
|
|
|
|
for (pdg = 0; pdg < ee->ee_pd_gains[mode]; pdg++) {
|
|
|
|
|
|
|
|
u8 idx = pdgain_idx[pdg];
|
|
|
|
struct ath5k_pdgain_info *pd =
|
|
|
|
&chinfo[pier].pd_curves[idx];
|
|
|
|
|
|
|
|
/* One more point for the highest power
|
|
|
|
* curve (lowest gain) */
|
|
|
|
if (pdg == ee->ee_pd_gains[mode] - 1)
|
|
|
|
pd->pd_points = AR5K_EEPROM_N_PD_POINTS;
|
|
|
|
else
|
|
|
|
pd->pd_points = AR5K_EEPROM_N_PD_POINTS - 1;
|
|
|
|
|
|
|
|
/* Allocate pd points for this curve */
|
|
|
|
pd->pd_step = kcalloc(pd->pd_points,
|
|
|
|
sizeof(u8), GFP_KERNEL);
|
|
|
|
|
|
|
|
if (!pd->pd_step)
|
2011-04-09 03:33:12 +08:00
|
|
|
goto err_out;
|
2009-03-16 04:17:04 +08:00
|
|
|
|
|
|
|
pd->pd_pwr = kcalloc(pd->pd_points,
|
|
|
|
sizeof(s16), GFP_KERNEL);
|
|
|
|
|
|
|
|
if (!pd->pd_pwr)
|
2011-04-09 03:33:12 +08:00
|
|
|
goto err_out;
|
2009-03-16 04:17:04 +08:00
|
|
|
|
|
|
|
/* Fill raw dataset
|
|
|
|
* convert all pwr levels to
|
2011-07-09 12:17:51 +08:00
|
|
|
* quarter dB for RF5112 compatibility */
|
2009-03-16 04:17:04 +08:00
|
|
|
pd->pd_step[0] = pcinfo->pddac_i[pdg];
|
|
|
|
pd->pd_pwr[0] = 4 * pcinfo->pwr_i[pdg];
|
|
|
|
|
|
|
|
for (point = 1; point < pd->pd_points; point++) {
|
|
|
|
|
|
|
|
pd->pd_pwr[point] = pd->pd_pwr[point - 1] +
|
|
|
|
2 * pcinfo->pwr[pdg][point - 1];
|
|
|
|
|
|
|
|
pd->pd_step[point] = pd->pd_step[point - 1] +
|
|
|
|
pcinfo->pddac[pdg][point - 1];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Highest gain curve -> min power */
|
|
|
|
if (pdg == 0)
|
|
|
|
chinfo[pier].min_pwr = pd->pd_pwr[0];
|
|
|
|
|
|
|
|
/* Lowest gain curve -> max power */
|
|
|
|
if (pdg == ee->ee_pd_gains[mode] - 1)
|
|
|
|
chinfo[pier].max_pwr =
|
|
|
|
pd->pd_pwr[pd->pd_points - 1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2011-04-09 03:33:12 +08:00
|
|
|
|
|
|
|
err_out:
|
|
|
|
ath5k_eeprom_free_pcal_info(ah, mode);
|
|
|
|
return -ENOMEM;
|
2009-03-16 04:17:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Parse EEPROM data */
|
2008-11-20 22:16:22 +08:00
|
|
|
static int
|
|
|
|
ath5k_eeprom_read_pcal_info_2413(struct ath5k_hw *ah, int mode)
|
|
|
|
{
|
|
|
|
struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
|
2009-03-16 04:17:04 +08:00
|
|
|
struct ath5k_chan_pcal_info_rf2413 *pcinfo;
|
|
|
|
struct ath5k_chan_pcal_info *chinfo;
|
|
|
|
u8 *pdgain_idx = ee->ee_pdc_to_idx[mode];
|
2008-11-20 22:16:22 +08:00
|
|
|
u32 offset;
|
2011-01-11 16:00:31 +08:00
|
|
|
int idx, i;
|
2008-11-20 22:16:22 +08:00
|
|
|
u16 val;
|
|
|
|
u8 pd_gains = 0;
|
|
|
|
|
2009-03-16 04:17:04 +08:00
|
|
|
/* Count how many curves we have and
|
|
|
|
* identify them (which one of the 4
|
|
|
|
* available curves we have on each count).
|
|
|
|
* Curves are stored from higher to
|
|
|
|
* lower gain so we go backwards */
|
|
|
|
for (idx = AR5K_EEPROM_N_PD_CURVES - 1; idx >= 0; idx--) {
|
|
|
|
/* ee_x_gain[mode] is x gain mask */
|
|
|
|
if ((ee->ee_x_gain[mode] >> idx) & 0x1)
|
|
|
|
pdgain_idx[pd_gains++] = idx;
|
|
|
|
|
|
|
|
}
|
2008-11-20 22:16:22 +08:00
|
|
|
ee->ee_pd_gains[mode] = pd_gains;
|
|
|
|
|
2009-03-16 04:17:04 +08:00
|
|
|
if (pd_gains == 0)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2008-11-20 22:16:22 +08:00
|
|
|
offset = ath5k_cal_data_offset_2413(ee, mode);
|
|
|
|
switch (mode) {
|
|
|
|
case AR5K_EEPROM_MODE_11A:
|
|
|
|
if (!AR5K_EEPROM_HDR_11A(ee->ee_header))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
ath5k_eeprom_init_11a_pcal_freq(ah, offset);
|
|
|
|
offset += AR5K_EEPROM_N_5GHZ_CHAN / 2;
|
2009-03-16 04:17:04 +08:00
|
|
|
chinfo = ee->ee_pwr_cal_a;
|
2008-11-20 22:16:22 +08:00
|
|
|
break;
|
|
|
|
case AR5K_EEPROM_MODE_11B:
|
|
|
|
if (!AR5K_EEPROM_HDR_11B(ee->ee_header))
|
|
|
|
return 0;
|
2008-08-30 03:45:39 +08:00
|
|
|
|
2008-11-20 22:16:22 +08:00
|
|
|
ath5k_eeprom_init_11bg_2413(ah, mode, offset);
|
|
|
|
offset += AR5K_EEPROM_N_2GHZ_CHAN_2413 / 2;
|
2009-03-16 04:17:04 +08:00
|
|
|
chinfo = ee->ee_pwr_cal_b;
|
2008-11-20 22:16:22 +08:00
|
|
|
break;
|
|
|
|
case AR5K_EEPROM_MODE_11G:
|
|
|
|
if (!AR5K_EEPROM_HDR_11G(ee->ee_header))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
ath5k_eeprom_init_11bg_2413(ah, mode, offset);
|
|
|
|
offset += AR5K_EEPROM_N_2GHZ_CHAN_2413 / 2;
|
2009-03-16 04:17:04 +08:00
|
|
|
chinfo = ee->ee_pwr_cal_g;
|
2008-11-20 22:16:22 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < ee->ee_n_piers[mode]; i++) {
|
2009-03-16 04:17:04 +08:00
|
|
|
pcinfo = &chinfo[i].rf2413_info;
|
2008-11-20 22:16:22 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Read pwr_i, pddac_i and the first
|
|
|
|
* 2 pd points (pwr, pddac)
|
|
|
|
*/
|
2008-08-30 03:45:39 +08:00
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
2009-03-16 04:17:04 +08:00
|
|
|
pcinfo->pwr_i[0] = val & 0x1f;
|
|
|
|
pcinfo->pddac_i[0] = (val >> 5) & 0x7f;
|
|
|
|
pcinfo->pwr[0][0] = (val >> 12) & 0xf;
|
2008-08-30 03:45:39 +08:00
|
|
|
|
2008-11-20 22:16:22 +08:00
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
2009-03-16 04:17:04 +08:00
|
|
|
pcinfo->pddac[0][0] = val & 0x3f;
|
|
|
|
pcinfo->pwr[0][1] = (val >> 6) & 0xf;
|
|
|
|
pcinfo->pddac[0][1] = (val >> 10) & 0x3f;
|
2008-11-20 22:16:22 +08:00
|
|
|
|
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
2009-03-16 04:17:04 +08:00
|
|
|
pcinfo->pwr[0][2] = val & 0xf;
|
|
|
|
pcinfo->pddac[0][2] = (val >> 4) & 0x3f;
|
2008-11-20 22:16:22 +08:00
|
|
|
|
2009-03-16 04:17:04 +08:00
|
|
|
pcinfo->pwr[0][3] = 0;
|
|
|
|
pcinfo->pddac[0][3] = 0;
|
2008-11-20 22:16:22 +08:00
|
|
|
|
|
|
|
if (pd_gains > 1) {
|
|
|
|
/*
|
|
|
|
* Pd gain 0 is not the last pd gain
|
|
|
|
* so it only has 2 pd points.
|
2011-03-31 09:57:33 +08:00
|
|
|
* Continue with pd gain 1.
|
2008-11-20 22:16:22 +08:00
|
|
|
*/
|
2009-03-16 04:17:04 +08:00
|
|
|
pcinfo->pwr_i[1] = (val >> 10) & 0x1f;
|
2008-11-20 22:16:22 +08:00
|
|
|
|
2009-03-16 04:17:04 +08:00
|
|
|
pcinfo->pddac_i[1] = (val >> 15) & 0x1;
|
2008-08-30 03:45:39 +08:00
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
2009-03-16 04:17:04 +08:00
|
|
|
pcinfo->pddac_i[1] |= (val & 0x3F) << 1;
|
2008-11-20 22:16:22 +08:00
|
|
|
|
2009-03-16 04:17:04 +08:00
|
|
|
pcinfo->pwr[1][0] = (val >> 6) & 0xf;
|
|
|
|
pcinfo->pddac[1][0] = (val >> 10) & 0x3f;
|
2008-11-20 22:16:22 +08:00
|
|
|
|
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
2009-03-16 04:17:04 +08:00
|
|
|
pcinfo->pwr[1][1] = val & 0xf;
|
|
|
|
pcinfo->pddac[1][1] = (val >> 4) & 0x3f;
|
|
|
|
pcinfo->pwr[1][2] = (val >> 10) & 0xf;
|
|
|
|
|
|
|
|
pcinfo->pddac[1][2] = (val >> 14) & 0x3;
|
2008-11-20 22:16:22 +08:00
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
2009-03-16 04:17:04 +08:00
|
|
|
pcinfo->pddac[1][2] |= (val & 0xF) << 2;
|
2008-11-20 22:16:22 +08:00
|
|
|
|
2009-03-16 04:17:04 +08:00
|
|
|
pcinfo->pwr[1][3] = 0;
|
|
|
|
pcinfo->pddac[1][3] = 0;
|
2008-11-20 22:16:22 +08:00
|
|
|
} else if (pd_gains == 1) {
|
|
|
|
/*
|
|
|
|
* Pd gain 0 is the last one so
|
|
|
|
* read the extra point.
|
|
|
|
*/
|
2009-03-16 04:17:04 +08:00
|
|
|
pcinfo->pwr[0][3] = (val >> 10) & 0xf;
|
2008-11-20 22:16:22 +08:00
|
|
|
|
2009-03-16 04:17:04 +08:00
|
|
|
pcinfo->pddac[0][3] = (val >> 14) & 0x3;
|
2008-11-20 22:16:22 +08:00
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
2009-03-16 04:17:04 +08:00
|
|
|
pcinfo->pddac[0][3] |= (val & 0xF) << 2;
|
2008-11-20 22:16:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Proceed with the other pd_gains
|
|
|
|
* as above.
|
|
|
|
*/
|
|
|
|
if (pd_gains > 2) {
|
2009-03-16 04:17:04 +08:00
|
|
|
pcinfo->pwr_i[2] = (val >> 4) & 0x1f;
|
|
|
|
pcinfo->pddac_i[2] = (val >> 9) & 0x7f;
|
2008-11-20 22:16:22 +08:00
|
|
|
|
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
2009-03-16 04:17:04 +08:00
|
|
|
pcinfo->pwr[2][0] = (val >> 0) & 0xf;
|
|
|
|
pcinfo->pddac[2][0] = (val >> 4) & 0x3f;
|
|
|
|
pcinfo->pwr[2][1] = (val >> 10) & 0xf;
|
|
|
|
|
|
|
|
pcinfo->pddac[2][1] = (val >> 14) & 0x3;
|
2008-11-20 22:16:22 +08:00
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
2009-03-16 04:17:04 +08:00
|
|
|
pcinfo->pddac[2][1] |= (val & 0xF) << 2;
|
2008-11-20 22:16:22 +08:00
|
|
|
|
2009-03-16 04:17:04 +08:00
|
|
|
pcinfo->pwr[2][2] = (val >> 4) & 0xf;
|
|
|
|
pcinfo->pddac[2][2] = (val >> 8) & 0x3f;
|
2008-11-20 22:16:22 +08:00
|
|
|
|
2009-03-16 04:17:04 +08:00
|
|
|
pcinfo->pwr[2][3] = 0;
|
|
|
|
pcinfo->pddac[2][3] = 0;
|
2008-11-20 22:16:22 +08:00
|
|
|
} else if (pd_gains == 2) {
|
2009-03-16 04:17:04 +08:00
|
|
|
pcinfo->pwr[1][3] = (val >> 4) & 0xf;
|
|
|
|
pcinfo->pddac[1][3] = (val >> 8) & 0x3f;
|
2008-11-20 22:16:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pd_gains > 3) {
|
2009-03-16 04:17:04 +08:00
|
|
|
pcinfo->pwr_i[3] = (val >> 14) & 0x3;
|
2008-11-20 22:16:22 +08:00
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
2009-03-16 04:17:04 +08:00
|
|
|
pcinfo->pwr_i[3] |= ((val >> 0) & 0x7) << 2;
|
2008-11-20 22:16:22 +08:00
|
|
|
|
2009-03-16 04:17:04 +08:00
|
|
|
pcinfo->pddac_i[3] = (val >> 3) & 0x7f;
|
|
|
|
pcinfo->pwr[3][0] = (val >> 10) & 0xf;
|
|
|
|
pcinfo->pddac[3][0] = (val >> 14) & 0x3;
|
2008-11-20 22:16:22 +08:00
|
|
|
|
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
2009-03-16 04:17:04 +08:00
|
|
|
pcinfo->pddac[3][0] |= (val & 0xF) << 2;
|
|
|
|
pcinfo->pwr[3][1] = (val >> 4) & 0xf;
|
|
|
|
pcinfo->pddac[3][1] = (val >> 8) & 0x3f;
|
|
|
|
|
|
|
|
pcinfo->pwr[3][2] = (val >> 14) & 0x3;
|
2008-11-20 22:16:22 +08:00
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
2009-03-16 04:17:04 +08:00
|
|
|
pcinfo->pwr[3][2] |= ((val >> 0) & 0x3) << 2;
|
2008-11-20 22:16:22 +08:00
|
|
|
|
2009-03-16 04:17:04 +08:00
|
|
|
pcinfo->pddac[3][2] = (val >> 2) & 0x3f;
|
|
|
|
pcinfo->pwr[3][3] = (val >> 8) & 0xf;
|
2008-11-20 22:16:22 +08:00
|
|
|
|
2009-03-16 04:17:04 +08:00
|
|
|
pcinfo->pddac[3][3] = (val >> 12) & 0xF;
|
2008-11-20 22:16:22 +08:00
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
2009-03-16 04:17:04 +08:00
|
|
|
pcinfo->pddac[3][3] |= ((val >> 0) & 0x3) << 4;
|
2008-11-20 22:16:22 +08:00
|
|
|
} else if (pd_gains == 3) {
|
2009-03-16 04:17:04 +08:00
|
|
|
pcinfo->pwr[2][3] = (val >> 14) & 0x3;
|
2008-11-20 22:16:22 +08:00
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
2009-03-16 04:17:04 +08:00
|
|
|
pcinfo->pwr[2][3] |= ((val >> 0) & 0x3) << 2;
|
2008-11-20 22:16:22 +08:00
|
|
|
|
2009-03-16 04:17:04 +08:00
|
|
|
pcinfo->pddac[2][3] = (val >> 2) & 0x3f;
|
2008-08-30 03:45:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-16 04:17:04 +08:00
|
|
|
return ath5k_eeprom_convert_pcal_info_2413(ah, mode, chinfo);
|
2008-11-20 22:16:22 +08:00
|
|
|
}
|
|
|
|
|
2009-03-16 04:17:04 +08:00
|
|
|
|
2008-11-20 22:16:22 +08:00
|
|
|
/*
|
|
|
|
* Read per rate target power (this is the maximum tx power
|
|
|
|
* supported by the card). This info is used when setting
|
|
|
|
* tx power, no matter the channel.
|
|
|
|
*
|
|
|
|
* This also works for v5 EEPROMs.
|
|
|
|
*/
|
2009-03-16 04:17:04 +08:00
|
|
|
static int
|
|
|
|
ath5k_eeprom_read_target_rate_pwr_info(struct ath5k_hw *ah, unsigned int mode)
|
2008-11-20 22:16:22 +08:00
|
|
|
{
|
|
|
|
struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
|
|
|
|
struct ath5k_rate_pcal_info *rate_pcal_info;
|
2009-03-16 04:17:04 +08:00
|
|
|
u8 *rate_target_pwr_num;
|
2008-11-20 22:16:22 +08:00
|
|
|
u32 offset;
|
|
|
|
u16 val;
|
2011-01-11 16:00:31 +08:00
|
|
|
int i;
|
2008-11-20 22:16:22 +08:00
|
|
|
|
|
|
|
offset = AR5K_EEPROM_TARGET_PWRSTART(ee->ee_misc1);
|
|
|
|
rate_target_pwr_num = &ee->ee_rate_target_pwr_num[mode];
|
|
|
|
switch (mode) {
|
|
|
|
case AR5K_EEPROM_MODE_11A:
|
|
|
|
offset += AR5K_EEPROM_TARGET_PWR_OFF_11A(ee->ee_version);
|
|
|
|
rate_pcal_info = ee->ee_rate_tpwr_a;
|
2012-08-16 04:48:35 +08:00
|
|
|
ee->ee_rate_target_pwr_num[mode] = AR5K_EEPROM_N_5GHZ_RATE_CHAN;
|
2008-11-20 22:16:22 +08:00
|
|
|
break;
|
|
|
|
case AR5K_EEPROM_MODE_11B:
|
|
|
|
offset += AR5K_EEPROM_TARGET_PWR_OFF_11B(ee->ee_version);
|
|
|
|
rate_pcal_info = ee->ee_rate_tpwr_b;
|
|
|
|
ee->ee_rate_target_pwr_num[mode] = 2; /* 3rd is g mode's 1st */
|
|
|
|
break;
|
|
|
|
case AR5K_EEPROM_MODE_11G:
|
|
|
|
offset += AR5K_EEPROM_TARGET_PWR_OFF_11G(ee->ee_version);
|
|
|
|
rate_pcal_info = ee->ee_rate_tpwr_g;
|
|
|
|
ee->ee_rate_target_pwr_num[mode] = AR5K_EEPROM_N_2GHZ_CHAN;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Different freq mask for older eeproms (<= v3.2) */
|
|
|
|
if (ee->ee_version <= AR5K_EEPROM_VERSION_3_2) {
|
|
|
|
for (i = 0; i < (*rate_target_pwr_num); i++) {
|
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
|
|
|
rate_pcal_info[i].freq =
|
|
|
|
ath5k_eeprom_bin2freq(ee, (val >> 9) & 0x7f, mode);
|
|
|
|
|
|
|
|
rate_pcal_info[i].target_power_6to24 = ((val >> 3) & 0x3f);
|
|
|
|
rate_pcal_info[i].target_power_36 = (val << 3) & 0x3f;
|
|
|
|
|
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
|
|
|
|
|
|
|
if (rate_pcal_info[i].freq == AR5K_EEPROM_CHANNEL_DIS ||
|
|
|
|
val == 0) {
|
|
|
|
(*rate_target_pwr_num) = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
rate_pcal_info[i].target_power_36 |= ((val >> 13) & 0x7);
|
|
|
|
rate_pcal_info[i].target_power_48 = ((val >> 7) & 0x3f);
|
|
|
|
rate_pcal_info[i].target_power_54 = ((val >> 1) & 0x3f);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (i = 0; i < (*rate_target_pwr_num); i++) {
|
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
|
|
|
rate_pcal_info[i].freq =
|
|
|
|
ath5k_eeprom_bin2freq(ee, (val >> 8) & 0xff, mode);
|
|
|
|
|
|
|
|
rate_pcal_info[i].target_power_6to24 = ((val >> 2) & 0x3f);
|
|
|
|
rate_pcal_info[i].target_power_36 = (val << 4) & 0x3f;
|
|
|
|
|
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
|
|
|
|
|
|
|
if (rate_pcal_info[i].freq == AR5K_EEPROM_CHANNEL_DIS ||
|
|
|
|
val == 0) {
|
|
|
|
(*rate_target_pwr_num) = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
rate_pcal_info[i].target_power_36 |= (val >> 12) & 0xf;
|
|
|
|
rate_pcal_info[i].target_power_48 = ((val >> 6) & 0x3f);
|
|
|
|
rate_pcal_info[i].target_power_54 = (val & 0x3f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-11-24 02:36:45 +08:00
|
|
|
|
2008-12-21 10:47:39 +08:00
|
|
|
/*
|
|
|
|
* Read per channel calibration info from EEPROM
|
|
|
|
*
|
|
|
|
* This info is used to calibrate the baseband power table. Imagine
|
|
|
|
* that for each channel there is a power curve that's hw specific
|
|
|
|
* (depends on amplifier etc) and we try to "correct" this curve using
|
2009-10-29 03:11:03 +08:00
|
|
|
* offsets we pass on to phy chip (baseband -> before amplifier) so that
|
2008-12-21 10:47:39 +08:00
|
|
|
* it can use accurate power values when setting tx power (takes amplifier's
|
|
|
|
* performance on each channel into account).
|
|
|
|
*
|
|
|
|
* EEPROM provides us with the offsets for some pre-calibrated channels
|
|
|
|
* and we have to interpolate to create the full table for these channels and
|
|
|
|
* also the table for any channel.
|
|
|
|
*/
|
2008-11-20 22:16:22 +08:00
|
|
|
static int
|
|
|
|
ath5k_eeprom_read_pcal_info(struct ath5k_hw *ah)
|
|
|
|
{
|
|
|
|
struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
|
|
|
|
int (*read_pcal)(struct ath5k_hw *hw, int mode);
|
|
|
|
int mode;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if ((ah->ah_ee_version >= AR5K_EEPROM_VERSION_4_0) &&
|
|
|
|
(AR5K_EEPROM_EEMAP(ee->ee_misc0) == 1))
|
|
|
|
read_pcal = ath5k_eeprom_read_pcal_info_5112;
|
|
|
|
else if ((ah->ah_ee_version >= AR5K_EEPROM_VERSION_5_0) &&
|
|
|
|
(AR5K_EEPROM_EEMAP(ee->ee_misc0) == 2))
|
|
|
|
read_pcal = ath5k_eeprom_read_pcal_info_2413;
|
|
|
|
else
|
|
|
|
read_pcal = ath5k_eeprom_read_pcal_info_5111;
|
|
|
|
|
2009-03-16 04:17:04 +08:00
|
|
|
|
|
|
|
for (mode = AR5K_EEPROM_MODE_11A; mode <= AR5K_EEPROM_MODE_11G;
|
|
|
|
mode++) {
|
2008-11-20 22:16:22 +08:00
|
|
|
err = read_pcal(ah, mode);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
err = ath5k_eeprom_read_target_rate_pwr_info(ah, mode);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-12-21 10:47:39 +08:00
|
|
|
/* Read conformance test limits used for regulatory control */
|
2008-11-20 22:16:22 +08:00
|
|
|
static int
|
|
|
|
ath5k_eeprom_read_ctl_info(struct ath5k_hw *ah)
|
|
|
|
{
|
|
|
|
struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
|
|
|
|
struct ath5k_edge_power *rep;
|
|
|
|
unsigned int fmask, pmask;
|
|
|
|
unsigned int ctl_mode;
|
2011-01-11 16:00:31 +08:00
|
|
|
int i, j;
|
2008-11-20 22:16:22 +08:00
|
|
|
u32 offset;
|
|
|
|
u16 val;
|
|
|
|
|
|
|
|
pmask = AR5K_EEPROM_POWER_M;
|
|
|
|
fmask = AR5K_EEPROM_FREQ_M(ee->ee_version);
|
|
|
|
offset = AR5K_EEPROM_CTL(ee->ee_version);
|
|
|
|
ee->ee_ctls = AR5K_EEPROM_N_CTLS(ee->ee_version);
|
|
|
|
for (i = 0; i < ee->ee_ctls; i += 2) {
|
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
|
|
|
ee->ee_ctl[i] = (val >> 8) & 0xff;
|
|
|
|
ee->ee_ctl[i + 1] = val & 0xff;
|
|
|
|
}
|
|
|
|
|
|
|
|
offset = AR5K_EEPROM_GROUP8_OFFSET;
|
|
|
|
if (ee->ee_version >= AR5K_EEPROM_VERSION_4_0)
|
|
|
|
offset += AR5K_EEPROM_TARGET_PWRSTART(ee->ee_misc1) -
|
|
|
|
AR5K_EEPROM_GROUP5_OFFSET;
|
|
|
|
else
|
|
|
|
offset += AR5K_EEPROM_GROUPS_START(ee->ee_version);
|
|
|
|
|
|
|
|
rep = ee->ee_ctl_pwr;
|
2011-07-08 06:14:13 +08:00
|
|
|
for (i = 0; i < ee->ee_ctls; i++) {
|
|
|
|
switch (ee->ee_ctl[i] & AR5K_CTL_MODE_M) {
|
2008-11-20 22:16:22 +08:00
|
|
|
case AR5K_CTL_11A:
|
|
|
|
case AR5K_CTL_TURBO:
|
|
|
|
ctl_mode = AR5K_EEPROM_MODE_11A;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ctl_mode = AR5K_EEPROM_MODE_11G;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (ee->ee_ctl[i] == 0) {
|
|
|
|
if (ee->ee_version >= AR5K_EEPROM_VERSION_3_3)
|
|
|
|
offset += 8;
|
|
|
|
else
|
|
|
|
offset += 7;
|
|
|
|
rep += AR5K_EEPROM_N_EDGES;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (ee->ee_version >= AR5K_EEPROM_VERSION_3_3) {
|
|
|
|
for (j = 0; j < AR5K_EEPROM_N_EDGES; j += 2) {
|
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
|
|
|
rep[j].freq = (val >> 8) & fmask;
|
|
|
|
rep[j + 1].freq = val & fmask;
|
|
|
|
}
|
|
|
|
for (j = 0; j < AR5K_EEPROM_N_EDGES; j += 2) {
|
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
|
|
|
rep[j].edge = (val >> 8) & pmask;
|
|
|
|
rep[j].flag = (val >> 14) & 1;
|
|
|
|
rep[j + 1].edge = val & pmask;
|
|
|
|
rep[j + 1].flag = (val >> 6) & 1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
|
|
|
rep[0].freq = (val >> 9) & fmask;
|
|
|
|
rep[1].freq = (val >> 2) & fmask;
|
|
|
|
rep[2].freq = (val << 5) & fmask;
|
|
|
|
|
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
|
|
|
rep[2].freq |= (val >> 11) & 0x1f;
|
|
|
|
rep[3].freq = (val >> 4) & fmask;
|
|
|
|
rep[4].freq = (val << 3) & fmask;
|
|
|
|
|
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
|
|
|
rep[4].freq |= (val >> 13) & 0x7;
|
|
|
|
rep[5].freq = (val >> 6) & fmask;
|
|
|
|
rep[6].freq = (val << 1) & fmask;
|
|
|
|
|
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
|
|
|
rep[6].freq |= (val >> 15) & 0x1;
|
|
|
|
rep[7].freq = (val >> 8) & fmask;
|
|
|
|
|
|
|
|
rep[0].edge = (val >> 2) & pmask;
|
|
|
|
rep[1].edge = (val << 4) & pmask;
|
|
|
|
|
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
|
|
|
rep[1].edge |= (val >> 12) & 0xf;
|
|
|
|
rep[2].edge = (val >> 6) & pmask;
|
|
|
|
rep[3].edge = val & pmask;
|
|
|
|
|
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
|
|
|
rep[4].edge = (val >> 10) & pmask;
|
|
|
|
rep[5].edge = (val >> 4) & pmask;
|
|
|
|
rep[6].edge = (val << 2) & pmask;
|
|
|
|
|
|
|
|
AR5K_EEPROM_READ(offset++, val);
|
|
|
|
rep[6].edge |= (val >> 14) & 0x3;
|
|
|
|
rep[7].edge = (val >> 8) & pmask;
|
|
|
|
}
|
|
|
|
for (j = 0; j < AR5K_EEPROM_N_EDGES; j++) {
|
|
|
|
rep[j].freq = ath5k_eeprom_bin2freq(ee,
|
|
|
|
rep[j].freq, ctl_mode);
|
|
|
|
}
|
|
|
|
rep += AR5K_EEPROM_N_EDGES;
|
|
|
|
}
|
2008-08-30 03:45:39 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-05-01 03:55:45 +08:00
|
|
|
static int
|
|
|
|
ath5k_eeprom_read_spur_chans(struct ath5k_hw *ah)
|
|
|
|
{
|
|
|
|
struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
|
|
|
|
u32 offset;
|
|
|
|
u16 val;
|
|
|
|
int ret = 0, i;
|
|
|
|
|
|
|
|
offset = AR5K_EEPROM_CTL(ee->ee_version) +
|
|
|
|
AR5K_EEPROM_N_CTLS(ee->ee_version);
|
|
|
|
|
|
|
|
if (ee->ee_version < AR5K_EEPROM_VERSION_5_3) {
|
|
|
|
/* No spur info for 5GHz */
|
|
|
|
ee->ee_spur_chans[0][0] = AR5K_EEPROM_NO_SPUR;
|
|
|
|
/* 2 channels for 2GHz (2464/2420) */
|
|
|
|
ee->ee_spur_chans[0][1] = AR5K_EEPROM_5413_SPUR_CHAN_1;
|
|
|
|
ee->ee_spur_chans[1][1] = AR5K_EEPROM_5413_SPUR_CHAN_2;
|
|
|
|
ee->ee_spur_chans[2][1] = AR5K_EEPROM_NO_SPUR;
|
|
|
|
} else if (ee->ee_version >= AR5K_EEPROM_VERSION_5_3) {
|
|
|
|
for (i = 0; i < AR5K_EEPROM_N_SPUR_CHANS; i++) {
|
|
|
|
AR5K_EEPROM_READ(offset, val);
|
|
|
|
ee->ee_spur_chans[i][0] = val;
|
|
|
|
AR5K_EEPROM_READ(offset + AR5K_EEPROM_N_SPUR_CHANS,
|
|
|
|
val);
|
|
|
|
ee->ee_spur_chans[i][1] = val;
|
|
|
|
offset++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2008-11-20 22:16:22 +08:00
|
|
|
|
2010-11-24 02:36:45 +08:00
|
|
|
|
|
|
|
/***********************\
|
|
|
|
* Init/Detach functions *
|
|
|
|
\***********************/
|
|
|
|
|
2008-11-20 22:16:22 +08:00
|
|
|
/*
|
2009-05-01 03:55:45 +08:00
|
|
|
* Initialize eeprom data structure
|
2008-11-20 22:16:22 +08:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
ath5k_eeprom_init(struct ath5k_hw *ah)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
|
|
|
err = ath5k_eeprom_init_header(ah);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
err = ath5k_eeprom_init_modes(ah);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
err = ath5k_eeprom_read_pcal_info(ah);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
err = ath5k_eeprom_read_ctl_info(ah);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
|
2009-05-01 03:55:45 +08:00
|
|
|
err = ath5k_eeprom_read_spur_chans(ah);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
|
2008-11-20 22:16:22 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2009-02-09 12:12:58 +08:00
|
|
|
|
2010-11-24 02:36:45 +08:00
|
|
|
void
|
|
|
|
ath5k_eeprom_detach(struct ath5k_hw *ah)
|
2008-08-30 03:45:39 +08:00
|
|
|
{
|
2010-11-24 02:36:45 +08:00
|
|
|
u8 mode;
|
2009-03-07 17:26:42 +08:00
|
|
|
|
2010-11-24 02:36:45 +08:00
|
|
|
for (mode = AR5K_EEPROM_MODE_11A; mode <= AR5K_EEPROM_MODE_11G; mode++)
|
|
|
|
ath5k_eeprom_free_pcal_info(ah, mode);
|
2008-08-30 03:45:39 +08:00
|
|
|
}
|
2010-12-21 16:30:43 +08:00
|
|
|
|
|
|
|
int
|
2013-02-25 22:36:48 +08:00
|
|
|
ath5k_eeprom_mode_from_channel(struct ath5k_hw *ah,
|
|
|
|
struct ieee80211_channel *channel)
|
2010-12-21 16:30:43 +08:00
|
|
|
{
|
2011-07-23 21:29:09 +08:00
|
|
|
switch (channel->hw_value) {
|
|
|
|
case AR5K_MODE_11A:
|
2010-12-21 16:30:43 +08:00
|
|
|
return AR5K_EEPROM_MODE_11A;
|
2011-07-23 21:29:09 +08:00
|
|
|
case AR5K_MODE_11G:
|
2010-12-21 16:30:43 +08:00
|
|
|
return AR5K_EEPROM_MODE_11G;
|
2011-07-23 21:29:09 +08:00
|
|
|
case AR5K_MODE_11B:
|
2010-12-21 16:30:43 +08:00
|
|
|
return AR5K_EEPROM_MODE_11B;
|
|
|
|
default:
|
2013-02-25 22:36:48 +08:00
|
|
|
ATH5K_WARN(ah, "channel is not A/B/G!");
|
|
|
|
return AR5K_EEPROM_MODE_11A;
|
2010-12-21 16:30:43 +08:00
|
|
|
}
|
|
|
|
}
|