2008-08-30 02:45:39 +07:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2004-2008 Reyk Floeter <reyk@openbsd.org>
|
|
|
|
* Copyright (c) 2006-2008 Nick Kossifidis <mickflemm@gmail.com>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*************************************\
|
|
|
|
* Attach/Detach Functions and helpers *
|
|
|
|
\*************************************/
|
|
|
|
|
2012-03-19 07:30:52 +07:00
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
|
2008-08-30 02:45:39 +07:00
|
|
|
#include <linux/pci.h>
|
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 15:04:11 +07:00
|
|
|
#include <linux/slab.h>
|
2008-08-30 02:45:39 +07:00
|
|
|
#include "ath5k.h"
|
|
|
|
#include "reg.h"
|
|
|
|
#include "debug.h"
|
|
|
|
|
|
|
|
/**
|
2011-11-26 01:40:25 +07:00
|
|
|
* ath5k_hw_post() - Power On Self Test helper function
|
2008-08-30 02:45:39 +07:00
|
|
|
* @ah: The &struct ath5k_hw
|
|
|
|
*/
|
|
|
|
static int ath5k_hw_post(struct ath5k_hw *ah)
|
|
|
|
{
|
|
|
|
|
2009-03-07 16:26:41 +07:00
|
|
|
static const u32 static_pattern[4] = {
|
2008-08-30 02:45:39 +07:00
|
|
|
0x55555555, 0xaaaaaaaa,
|
|
|
|
0x66666666, 0x99999999
|
|
|
|
};
|
2009-03-07 16:26:41 +07:00
|
|
|
static const u16 regs[2] = { AR5K_STA_ID0, AR5K_PHY(8) };
|
|
|
|
int i, c;
|
|
|
|
u16 cur_reg;
|
|
|
|
u32 var_pattern;
|
2008-08-30 02:45:39 +07:00
|
|
|
u32 init_val;
|
|
|
|
u32 cur_val;
|
|
|
|
|
|
|
|
for (c = 0; c < 2; c++) {
|
|
|
|
|
|
|
|
cur_reg = regs[c];
|
|
|
|
|
|
|
|
/* Save previous value */
|
|
|
|
init_val = ath5k_hw_reg_read(ah, cur_reg);
|
|
|
|
|
|
|
|
for (i = 0; i < 256; i++) {
|
|
|
|
var_pattern = i << 16 | i;
|
|
|
|
ath5k_hw_reg_write(ah, var_pattern, cur_reg);
|
|
|
|
cur_val = ath5k_hw_reg_read(ah, cur_reg);
|
|
|
|
|
|
|
|
if (cur_val != var_pattern) {
|
2011-07-15 07:21:55 +07:00
|
|
|
ATH5K_ERR(ah, "POST Failed !!!\n");
|
2008-08-30 02:45:39 +07:00
|
|
|
return -EAGAIN;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Found on ndiswrapper dumps */
|
|
|
|
var_pattern = 0x0039080f;
|
|
|
|
ath5k_hw_reg_write(ah, var_pattern, cur_reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
var_pattern = static_pattern[i];
|
|
|
|
ath5k_hw_reg_write(ah, var_pattern, cur_reg);
|
|
|
|
cur_val = ath5k_hw_reg_read(ah, cur_reg);
|
|
|
|
|
|
|
|
if (cur_val != var_pattern) {
|
2011-07-15 07:21:55 +07:00
|
|
|
ATH5K_ERR(ah, "POST Failed !!!\n");
|
2008-08-30 02:45:39 +07:00
|
|
|
return -EAGAIN;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Found on ndiswrapper dumps */
|
|
|
|
var_pattern = 0x003b080f;
|
|
|
|
ath5k_hw_reg_write(ah, var_pattern, cur_reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Restore previous value */
|
|
|
|
ath5k_hw_reg_write(ah, init_val, cur_reg);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-11-26 01:40:25 +07:00
|
|
|
* ath5k_hw_init() - Check if hw is supported and init the needed structs
|
2011-07-27 09:27:05 +07:00
|
|
|
* @ah: The &struct ath5k_hw associated with the device
|
2008-08-30 02:45:39 +07:00
|
|
|
*
|
|
|
|
* Check if the device is supported, perform a POST and initialize the needed
|
|
|
|
* structs. Returns -ENOMEM if we don't have memory for the needed structs,
|
|
|
|
* -ENODEV if the device is not supported or prints an error msg if something
|
|
|
|
* else went wrong.
|
|
|
|
*/
|
2011-07-15 07:21:55 +07:00
|
|
|
int ath5k_hw_init(struct ath5k_hw *ah)
|
2008-08-30 02:45:39 +07:00
|
|
|
{
|
2011-07-08 05:13:48 +07:00
|
|
|
static const u8 zero_mac[ETH_ALEN] = { };
|
2009-09-11 07:52:45 +07:00
|
|
|
struct ath_common *common = ath5k_hw_common(ah);
|
2011-07-15 07:21:55 +07:00
|
|
|
struct pci_dev *pdev = ah->pdev;
|
2009-08-25 10:00:33 +07:00
|
|
|
struct ath5k_eeprom_info *ee;
|
2008-08-30 02:45:39 +07:00
|
|
|
int ret;
|
|
|
|
u32 srev;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* HW information
|
|
|
|
*/
|
2010-11-24 01:58:34 +07:00
|
|
|
ah->ah_bwmode = AR5K_BWMODE_DEFAULT;
|
2008-08-30 02:45:39 +07:00
|
|
|
ah->ah_txpower.txp_tpc = AR5K_TUNE_TPC_TXPOWER;
|
|
|
|
ah->ah_imr = 0;
|
2011-01-28 14:52:11 +07:00
|
|
|
ah->ah_retry_short = AR5K_INIT_RETRY_SHORT;
|
|
|
|
ah->ah_retry_long = AR5K_INIT_RETRY_LONG;
|
2010-03-09 14:55:28 +07:00
|
|
|
ah->ah_ant_mode = AR5K_ANTMODE_DEFAULT;
|
2010-03-25 12:49:31 +07:00
|
|
|
ah->ah_noise_floor = -95; /* until first NF calibration is run */
|
2011-07-15 07:21:55 +07:00
|
|
|
ah->ani_state.ani_mode = ATH5K_ANI_MODE_AUTO;
|
|
|
|
ah->ah_current_channel = &ah->channels[0];
|
2008-08-30 02:45:39 +07:00
|
|
|
|
|
|
|
/*
|
2009-08-27 09:30:09 +07:00
|
|
|
* Find the mac version
|
2008-08-30 02:45:39 +07:00
|
|
|
*/
|
2010-12-02 16:27:06 +07:00
|
|
|
ath5k_hw_read_srev(ah);
|
|
|
|
srev = ah->ah_mac_srev;
|
2009-08-27 09:30:09 +07:00
|
|
|
if (srev < AR5K_SREV_AR5311)
|
|
|
|
ah->ah_version = AR5K_AR5210;
|
|
|
|
else if (srev < AR5K_SREV_AR5212)
|
|
|
|
ah->ah_version = AR5K_AR5211;
|
|
|
|
else
|
|
|
|
ah->ah_version = AR5K_AR5212;
|
2008-08-30 02:45:39 +07:00
|
|
|
|
2011-07-23 20:28:56 +07:00
|
|
|
/* Get the MAC version */
|
2010-12-02 16:27:06 +07:00
|
|
|
ah->ah_mac_version = AR5K_REG_MS(srev, AR5K_SREV_VER);
|
|
|
|
|
2010-08-16 00:03:12 +07:00
|
|
|
/* Fill the ath5k_hw struct with the needed functions */
|
2008-08-30 02:45:39 +07:00
|
|
|
ret = ath5k_hw_init_desc_functions(ah);
|
|
|
|
if (ret)
|
2010-10-28 00:38:34 +07:00
|
|
|
goto err;
|
2008-08-30 02:45:39 +07:00
|
|
|
|
2010-08-16 00:03:12 +07:00
|
|
|
/* Bring device out of sleep and reset its units */
|
2011-07-23 20:29:09 +07:00
|
|
|
ret = ath5k_hw_nic_wakeup(ah, NULL);
|
2008-08-30 02:45:39 +07:00
|
|
|
if (ret)
|
2010-10-28 00:38:34 +07:00
|
|
|
goto err;
|
2008-08-30 02:45:39 +07:00
|
|
|
|
2010-12-02 16:27:06 +07:00
|
|
|
/* Get PHY and RADIO revisions */
|
2008-08-30 02:45:39 +07:00
|
|
|
ah->ah_phy_revision = ath5k_hw_reg_read(ah, AR5K_PHY_CHIP_ID) &
|
|
|
|
0xffffffff;
|
|
|
|
ah->ah_radio_5ghz_revision = ath5k_hw_radio_revision(ah,
|
2011-07-23 20:29:09 +07:00
|
|
|
IEEE80211_BAND_5GHZ);
|
2008-08-30 02:45:39 +07:00
|
|
|
|
2010-08-16 00:03:12 +07:00
|
|
|
/* Try to identify radio chip based on its srev */
|
2008-09-29 05:18:16 +07:00
|
|
|
switch (ah->ah_radio_5ghz_revision & 0xf0) {
|
|
|
|
case AR5K_SREV_RAD_5111:
|
2008-08-30 02:45:39 +07:00
|
|
|
ah->ah_radio = AR5K_RF5111;
|
2008-09-29 05:18:16 +07:00
|
|
|
ah->ah_single_chip = false;
|
|
|
|
ah->ah_radio_2ghz_revision = ath5k_hw_radio_revision(ah,
|
2011-07-23 20:29:09 +07:00
|
|
|
IEEE80211_BAND_2GHZ);
|
2008-09-29 05:18:16 +07:00
|
|
|
break;
|
|
|
|
case AR5K_SREV_RAD_5112:
|
|
|
|
case AR5K_SREV_RAD_2112:
|
2008-08-30 02:45:39 +07:00
|
|
|
ah->ah_radio = AR5K_RF5112;
|
2008-09-29 05:18:16 +07:00
|
|
|
ah->ah_single_chip = false;
|
|
|
|
ah->ah_radio_2ghz_revision = ath5k_hw_radio_revision(ah,
|
2011-07-23 20:29:09 +07:00
|
|
|
IEEE80211_BAND_2GHZ);
|
2008-09-29 05:18:16 +07:00
|
|
|
break;
|
|
|
|
case AR5K_SREV_RAD_2413:
|
2008-08-30 02:45:39 +07:00
|
|
|
ah->ah_radio = AR5K_RF2413;
|
2008-09-29 05:18:16 +07:00
|
|
|
ah->ah_single_chip = true;
|
|
|
|
break;
|
|
|
|
case AR5K_SREV_RAD_5413:
|
2008-08-30 02:45:39 +07:00
|
|
|
ah->ah_radio = AR5K_RF5413;
|
2008-09-29 05:18:16 +07:00
|
|
|
ah->ah_single_chip = true;
|
|
|
|
break;
|
|
|
|
case AR5K_SREV_RAD_2316:
|
|
|
|
ah->ah_radio = AR5K_RF2316;
|
|
|
|
ah->ah_single_chip = true;
|
|
|
|
break;
|
|
|
|
case AR5K_SREV_RAD_2317:
|
|
|
|
ah->ah_radio = AR5K_RF2317;
|
|
|
|
ah->ah_single_chip = true;
|
|
|
|
break;
|
|
|
|
case AR5K_SREV_RAD_5424:
|
|
|
|
if (ah->ah_mac_version == AR5K_SREV_AR2425 ||
|
2011-07-08 05:14:13 +07:00
|
|
|
ah->ah_mac_version == AR5K_SREV_AR2417) {
|
2008-09-29 05:18:16 +07:00
|
|
|
ah->ah_radio = AR5K_RF2425;
|
|
|
|
ah->ah_single_chip = true;
|
|
|
|
} else {
|
2008-08-30 02:45:39 +07:00
|
|
|
ah->ah_radio = AR5K_RF5413;
|
2008-09-29 05:18:16 +07:00
|
|
|
ah->ah_single_chip = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* Identify radio based on mac/phy srev */
|
|
|
|
if (ah->ah_version == AR5K_AR5210) {
|
|
|
|
ah->ah_radio = AR5K_RF5110;
|
|
|
|
ah->ah_single_chip = false;
|
|
|
|
} else if (ah->ah_version == AR5K_AR5211) {
|
|
|
|
ah->ah_radio = AR5K_RF5111;
|
|
|
|
ah->ah_single_chip = false;
|
|
|
|
ah->ah_radio_2ghz_revision = ath5k_hw_radio_revision(ah,
|
2011-07-23 20:29:09 +07:00
|
|
|
IEEE80211_BAND_2GHZ);
|
2008-09-29 05:18:16 +07:00
|
|
|
} else if (ah->ah_mac_version == (AR5K_SREV_AR2425 >> 4) ||
|
2011-07-08 05:14:13 +07:00
|
|
|
ah->ah_mac_version == (AR5K_SREV_AR2417 >> 4) ||
|
|
|
|
ah->ah_phy_revision == AR5K_SREV_PHY_2425) {
|
2008-09-29 05:18:16 +07:00
|
|
|
ah->ah_radio = AR5K_RF2425;
|
|
|
|
ah->ah_single_chip = true;
|
|
|
|
ah->ah_radio_5ghz_revision = AR5K_SREV_RAD_2425;
|
|
|
|
} else if (srev == AR5K_SREV_AR5213A &&
|
2011-07-08 05:14:13 +07:00
|
|
|
ah->ah_phy_revision == AR5K_SREV_PHY_5212B) {
|
2008-09-29 05:18:16 +07:00
|
|
|
ah->ah_radio = AR5K_RF5112;
|
|
|
|
ah->ah_single_chip = false;
|
2009-02-09 11:12:58 +07:00
|
|
|
ah->ah_radio_5ghz_revision = AR5K_SREV_RAD_5112B;
|
2011-02-18 19:06:42 +07:00
|
|
|
} else if (ah->ah_mac_version == (AR5K_SREV_AR2415 >> 4) ||
|
2011-07-08 05:14:13 +07:00
|
|
|
ah->ah_mac_version == (AR5K_SREV_AR2315_R6 >> 4)) {
|
2008-09-29 05:18:16 +07:00
|
|
|
ah->ah_radio = AR5K_RF2316;
|
|
|
|
ah->ah_single_chip = true;
|
|
|
|
ah->ah_radio_5ghz_revision = AR5K_SREV_RAD_2316;
|
|
|
|
} else if (ah->ah_mac_version == (AR5K_SREV_AR5414 >> 4) ||
|
2011-07-08 05:14:13 +07:00
|
|
|
ah->ah_phy_revision == AR5K_SREV_PHY_5413) {
|
2008-09-29 05:18:16 +07:00
|
|
|
ah->ah_radio = AR5K_RF5413;
|
|
|
|
ah->ah_single_chip = true;
|
|
|
|
ah->ah_radio_5ghz_revision = AR5K_SREV_RAD_5413;
|
|
|
|
} else if (ah->ah_mac_version == (AR5K_SREV_AR2414 >> 4) ||
|
2011-07-08 05:14:13 +07:00
|
|
|
ah->ah_phy_revision == AR5K_SREV_PHY_2413) {
|
2008-09-29 05:18:16 +07:00
|
|
|
ah->ah_radio = AR5K_RF2413;
|
|
|
|
ah->ah_single_chip = true;
|
|
|
|
ah->ah_radio_5ghz_revision = AR5K_SREV_RAD_2413;
|
|
|
|
} else {
|
2011-07-15 07:21:55 +07:00
|
|
|
ATH5K_ERR(ah, "Couldn't identify radio revision.\n");
|
2008-09-29 05:18:16 +07:00
|
|
|
ret = -ENODEV;
|
2010-10-28 00:38:34 +07:00
|
|
|
goto err;
|
2008-08-30 02:45:39 +07:00
|
|
|
}
|
|
|
|
}
|
2008-09-29 05:18:16 +07:00
|
|
|
|
|
|
|
|
2011-07-09 11:17:51 +07:00
|
|
|
/* Return on unsupported chips (unsupported eeprom etc) */
|
2011-07-08 05:14:13 +07:00
|
|
|
if ((srev >= AR5K_SREV_AR5416) && (srev < AR5K_SREV_AR2425)) {
|
2011-07-15 07:21:55 +07:00
|
|
|
ATH5K_ERR(ah, "Device not yet supported.\n");
|
2008-09-29 05:18:16 +07:00
|
|
|
ret = -ENODEV;
|
2010-10-28 00:38:34 +07:00
|
|
|
goto err;
|
2008-09-29 05:18:16 +07:00
|
|
|
}
|
2008-08-30 02:45:39 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* POST
|
|
|
|
*/
|
|
|
|
ret = ath5k_hw_post(ah);
|
|
|
|
if (ret)
|
2010-10-28 00:38:34 +07:00
|
|
|
goto err;
|
2008-08-30 02:45:39 +07:00
|
|
|
|
2008-09-29 05:18:16 +07:00
|
|
|
/* Enable pci core retry fix on Hainan (5213A) and later chips */
|
|
|
|
if (srev >= AR5K_SREV_AR5213A)
|
2009-08-10 07:30:32 +07:00
|
|
|
AR5K_REG_ENABLE_BITS(ah, AR5K_PCICFG, AR5K_PCICFG_RETRY_FIX);
|
2008-08-30 02:45:39 +07:00
|
|
|
|
|
|
|
/*
|
2008-09-29 05:18:16 +07:00
|
|
|
* Get card capabilities, calibration values etc
|
|
|
|
* TODO: EEPROM work
|
2008-08-30 02:45:39 +07:00
|
|
|
*/
|
|
|
|
ret = ath5k_eeprom_init(ah);
|
|
|
|
if (ret) {
|
2011-07-15 07:21:55 +07:00
|
|
|
ATH5K_ERR(ah, "unable to init EEPROM\n");
|
2010-10-28 00:38:34 +07:00
|
|
|
goto err;
|
2008-08-30 02:45:39 +07:00
|
|
|
}
|
|
|
|
|
2009-09-11 00:57:00 +07:00
|
|
|
ee = &ah->ah_capabilities.cap_eeprom;
|
|
|
|
|
2009-08-10 07:26:55 +07:00
|
|
|
/*
|
|
|
|
* Write PCI-E power save settings
|
|
|
|
*/
|
2010-12-21 08:01:54 +07:00
|
|
|
if ((ah->ah_version == AR5K_AR5212) && pdev && (pci_is_pcie(pdev))) {
|
2009-08-10 07:26:55 +07:00
|
|
|
ath5k_hw_reg_write(ah, 0x9248fc00, AR5K_PCIE_SERDES);
|
|
|
|
ath5k_hw_reg_write(ah, 0x24924924, AR5K_PCIE_SERDES);
|
|
|
|
|
|
|
|
/* Shut off RX when elecidle is asserted */
|
|
|
|
ath5k_hw_reg_write(ah, 0x28000039, AR5K_PCIE_SERDES);
|
|
|
|
ath5k_hw_reg_write(ah, 0x53160824, AR5K_PCIE_SERDES);
|
|
|
|
|
2011-07-09 11:17:51 +07:00
|
|
|
/* If serdes programming is enabled, increase PCI-E
|
2009-08-10 07:26:55 +07:00
|
|
|
* tx power for systems with long trace from host
|
|
|
|
* to minicard connector. */
|
|
|
|
if (ee->ee_serdes)
|
|
|
|
ath5k_hw_reg_write(ah, 0xe5980579, AR5K_PCIE_SERDES);
|
|
|
|
else
|
|
|
|
ath5k_hw_reg_write(ah, 0xf6800579, AR5K_PCIE_SERDES);
|
|
|
|
|
|
|
|
/* Shut off PLL and CLKREQ active in L1 */
|
|
|
|
ath5k_hw_reg_write(ah, 0x001defff, AR5K_PCIE_SERDES);
|
|
|
|
|
|
|
|
/* Preserve other settings */
|
|
|
|
ath5k_hw_reg_write(ah, 0x1aaabe40, AR5K_PCIE_SERDES);
|
|
|
|
ath5k_hw_reg_write(ah, 0xbe105554, AR5K_PCIE_SERDES);
|
|
|
|
ath5k_hw_reg_write(ah, 0x000e3007, AR5K_PCIE_SERDES);
|
|
|
|
|
|
|
|
/* Reset SERDES to load new settings */
|
|
|
|
ath5k_hw_reg_write(ah, 0x00000000, AR5K_PCIE_SERDES_RESET);
|
2011-11-26 01:40:24 +07:00
|
|
|
usleep_range(1000, 1500);
|
2009-08-10 07:26:55 +07:00
|
|
|
}
|
|
|
|
|
2008-08-30 02:45:39 +07:00
|
|
|
/* Get misc capabilities */
|
|
|
|
ret = ath5k_hw_set_capabilities(ah);
|
|
|
|
if (ret) {
|
2011-07-15 07:21:55 +07:00
|
|
|
ATH5K_ERR(ah, "unable to get device capabilities\n");
|
2010-10-28 00:38:34 +07:00
|
|
|
goto err;
|
2008-08-30 02:45:39 +07:00
|
|
|
}
|
|
|
|
|
2009-08-25 10:00:33 +07:00
|
|
|
/* Crypto settings */
|
2011-07-15 07:21:55 +07:00
|
|
|
common->keymax = (ah->ah_version == AR5K_AR5210 ?
|
2010-09-08 14:04:43 +07:00
|
|
|
AR5K_KEYTABLE_SIZE_5210 : AR5K_KEYTABLE_SIZE_5211);
|
|
|
|
|
2010-09-08 14:04:59 +07:00
|
|
|
if (srev >= AR5K_SREV_AR5212_V4 &&
|
2011-04-14 02:56:45 +07:00
|
|
|
(ee->ee_version < AR5K_EEPROM_VERSION_5_0 ||
|
2010-09-08 14:04:59 +07:00
|
|
|
!AR5K_EEPROM_AES_DIS(ee->ee_misc5)))
|
2010-09-17 09:36:25 +07:00
|
|
|
common->crypt_caps |= ATH_CRYPT_CAP_CIPHER_AESCCM;
|
2009-08-25 10:00:33 +07:00
|
|
|
|
2008-11-27 04:17:25 +07:00
|
|
|
if (srev >= AR5K_SREV_AR2414) {
|
2010-09-08 14:04:59 +07:00
|
|
|
common->crypt_caps |= ATH_CRYPT_CAP_MIC_COMBINED;
|
2008-11-27 04:17:25 +07:00
|
|
|
AR5K_REG_ENABLE_BITS(ah, AR5K_MISC_MODE,
|
|
|
|
AR5K_MISC_MODE_COMBINED_MIC);
|
|
|
|
}
|
|
|
|
|
2008-11-18 11:40:38 +07:00
|
|
|
/* MAC address is cleared until add_interface */
|
2011-07-08 05:13:48 +07:00
|
|
|
ath5k_hw_set_lladdr(ah, zero_mac);
|
2008-11-18 11:40:38 +07:00
|
|
|
|
2008-08-30 02:45:39 +07:00
|
|
|
/* Set BSSID to bcast address: ff:ff:ff:ff:ff:ff for now */
|
2009-09-11 00:51:33 +07:00
|
|
|
memcpy(common->curbssid, ath_bcast_mac, ETH_ALEN);
|
2010-08-16 00:03:10 +07:00
|
|
|
ath5k_hw_set_bssid(ah);
|
2011-07-15 07:21:55 +07:00
|
|
|
ath5k_hw_set_opmode(ah, ah->opmode);
|
2008-08-30 02:45:39 +07:00
|
|
|
|
2009-02-09 11:03:41 +07:00
|
|
|
ath5k_hw_rfgain_opt_init(ah);
|
2008-08-30 02:45:39 +07:00
|
|
|
|
2009-10-15 01:16:30 +07:00
|
|
|
ath5k_hw_init_nfcal_hist(ah);
|
|
|
|
|
2009-06-11 09:22:21 +07:00
|
|
|
/* turn on HW LEDs */
|
|
|
|
ath5k_hw_set_ledstate(ah, AR5K_LED_INIT);
|
|
|
|
|
2009-09-11 08:04:47 +07:00
|
|
|
return 0;
|
2010-10-28 00:38:34 +07:00
|
|
|
err:
|
2009-09-11 08:04:47 +07:00
|
|
|
return ret;
|
2008-08-30 02:45:39 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-11-26 01:40:25 +07:00
|
|
|
* ath5k_hw_deinit() - Free the &struct ath5k_hw
|
2008-08-30 02:45:39 +07:00
|
|
|
* @ah: The &struct ath5k_hw
|
|
|
|
*/
|
2010-12-02 16:26:56 +07:00
|
|
|
void ath5k_hw_deinit(struct ath5k_hw *ah)
|
2008-08-30 02:45:39 +07:00
|
|
|
{
|
2011-07-15 07:21:55 +07:00
|
|
|
__set_bit(ATH_STAT_INVALID, ah->status);
|
2008-08-30 02:45:39 +07:00
|
|
|
|
|
|
|
if (ah->ah_rf_banks != NULL)
|
|
|
|
kfree(ah->ah_rf_banks);
|
|
|
|
|
2009-03-16 03:20:35 +07:00
|
|
|
ath5k_eeprom_detach(ah);
|
|
|
|
|
2008-08-30 02:45:39 +07:00
|
|
|
/* assume interrupts are down */
|
|
|
|
}
|