History log of /drivers/net/wireless/ath/ath9k/hw.c
Revision Date Author Comments
4e6ce4dc7ce71d0886908d55129d5d6482a27ff9 06-Nov-2014 Miaoqing Pan <miaoqing@qca.qualcomm.com> ath9k: Fix RTC_DERIVED_CLK usage

Based on the reference clock, which could be 25MHz or 40MHz,
AR_RTC_DERIVED_CLK is programmed differently for AR9340 and AR9550.
But, when a chip reset is done, processing the initvals
sets the register back to the default value.

Fix this by moving the code in ath9k_hw_init_pll() to
ar9003_hw_override_ini(). Also, do this override for AR9531.

Cc: stable@vger.kernel.org
Signed-off-by: Miaoqing Pan <miaoqing@qca.qualcomm.com>
Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
5fb9b1b949ce9b829e7e8f799cc85e91527213bd 29-Sep-2014 Felix Fietkau <nbd@openwrt.org> ath9k_hw: fix PLL clock initialization for newer SoC

On AR934x and newer SoC devices, the layout of the AR_RTC_PLL_CONTROL
register changed. This currently breaks at least 5/10 MHz operation.
AR933x uses the old layout.

It might also have been causing other stability issues because of the
different location of the PLL_BYPASS bit which needs to be set during
PLL clock initialization.

This patch also removes more instances of hardcoded register values in
favor of properly computed ones with the PLL_BYPASS bit added.

Reported-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
83322eb862e408029baf7872db1b82124f291d58 27-Sep-2014 Felix Fietkau <nbd@openwrt.org> ath9k_hw: disable hardware ad-hoc flag on ar934x rev 3

On AR934x rev 3, settin the ad-hoc flag completely messes up hardware
state - beacons get stuck, almost no packets make it out, hardware is
constantly reset.

When leaving out that flag and setting up the hw like in AP mode, TSF
timers won't be automatically synced, but at least the rest works.

AR934x rev 2 and older are not affected by this bug

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
09c74f7bceb41d9072f2e4b3d11da5ce2bd51390 27-Sep-2014 Felix Fietkau <nbd@openwrt.org> ath9k: use ah->get_mac_revision for all SoC devices if available

It is needed for AR934x as well

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
7a0a260a0f6ff0226c33cf28a5cc26711ab0ae5f 16-Sep-2014 Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> ath9k: enable ext channel pulse detection

Enable pulse detection on extension channel if 40MHz channel width has been set

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
7aefa8aacbd4694db9a7ea7cbff490a1e31c3613 16-Sep-2014 Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> ath9k: do not overwrite ACK timeout estimation

Do not overwrite ACK timeout estimation in ath9k_hw_init_global_settings() if
dynack processing has been enabled

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
c774d57fd47c71675bb8c41a4dc2aafd78baa39d 16-Sep-2014 Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> ath9k: add dynamic ACK timeout estimation

Add dynamic ACK timeout estimation algorithm based on ACK frame RX timestamp,
TX frame timestamp and frame duration.

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Tested-by: Philippe Duchein <wireless-dev@duchein.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
8e15e09465977d38ed4cc45af10148a4e6542f1c 16-Sep-2014 Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> ath9k: export methods related to ACK timeout estimation

Remove static keyword and export ath9k_hw_setslottime(),
ath9k_hw_set_ack_timeout() and ath9k_hw_set_cts_timeout() in hw.h.
These methods will be used in ACK timeout estimation algorithm (dynack)

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
4307b0fe22f4641530bc24066dc432e3f1125459 11-Sep-2014 Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> ath9k: fix radar parameters initialization

Move ath9k_hw_set_radar_params() in ath9k_hw_reset() in order to avoid
AR_PHY_RADAR registers are overwritten after hw reset

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
6438e0ddc870f282f7ad46c050c211063a574687 16-Jul-2014 Thomas Gleixner <tglx@linutronix.de> wireless: ath9k: Get rid of timespec conversions

We have interfaces. Remove the open coded cruft. Reduces text size
along with the code.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: QCA ath9k Development <ath9k-devel@qca.qualcomm.com>
Cc: John W. Linville <linville@tuxdriver.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
76ac9ed6ffb32eb38d2f208204159ae0cd3394b6 24-Jun-2014 Rajkumar Manoharan <rmanohar@qti.qualcomm.com> ath9k_hw: Fix pll2_divfrac for AR953x

Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
8d7e09dda8214e4154f45238b4c85ab1ecb5d89a 11-Jun-2014 Felix Fietkau <nbd@openwrt.org> ath9k: save tsf in channel context

Save TSF in channel context for multiple operating channels.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
9d83cd5cd2e43f7f24feec66f8d15457589f7033 11-May-2014 Oleksij Rempel <linux@rempel-privat.de> ath9k: reorder or remove some includes

to fix compile errors

Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
7a42e4e74b71576d06d59c0937225e37471dc2fd 05-May-2014 Felix Fietkau <nbd@openwrt.org> ath9k_hw: get QCA953x WMAC revision via platform_data

The SREV register in the WMAC register space does not contain the chip
revision, so it needs to be passed in from the kernel.

With an updated kernel, this fixes tx gain table selection.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
c90d4f7bc5b8595b86753d3c0b64259c3972b341 17-Mar-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Disable AR_INTR_SYNC_HOST1_FATAL for QCA953x

Along with AR9340 and AR955x, this is also needed for
the QCA953x SoC.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
c08148bb7540c4547691c8fbe6db80edaf26cf10 17-Mar-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Add QCA953x WMAC platform support

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
105ff411c96c52c67261efbe245f0947d39ebce7 09-Mar-2014 Felix Fietkau <nbd@openwrt.org> ath9k_hw: fix unreachable code in baseband hang detection code

The commit "ath9k: reduce baseband hang detection false positive rate"
added a delay in the loop checking the baseband state, however it was
unreachable due to previous 'continue' statements.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
d31a36a6d87f68c3b97193bfca11e99d0cc385f7 24-Feb-2014 Felix Fietkau <nbd@openwrt.org> ath9k: reduce baseband hang detection false positive rate

Check if the baseband state remains stable, and add a small delay
between register reads.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
9e495a2603334f9c8fcc6802300c22fc8a0eae02 06-Feb-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Remove ath9k rate control

There is no benefit in retaining the legacy rate control module
in the driver codebase.

It is known to be buggy and has less than optimal performance
in real-world environments compared with minstrel. The only
reason that it was kept when we made the switch to minstrel
as default was that it showed higher throughput numbers in a
clean/ideal environment.

This is no longer the case and minstrel can push ath9k to
the same throughput levels. In TCP, with 3-stream cards, more than
295 Mbps can be obtained in open air, with 2-stream cards,
210 Mbps is easily reached. To test performance issues,
instead of using a broken rate control module, it is better
to use the fixed-rate interface provided by mac80211 anyway.

The ath9k RC has not received any bug fixes in years and is
just bit-rotting away - this patch removes it.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
3683a07b29d2bddebb903f1400860c77d8e423f3 04-Feb-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Fix build error on ARM

Use mdelay instead of udelay to fix this error:

ERROR: "__bad_udelay" [drivers/net/wireless/ath/ath9k/ath9k_hw.ko] undefined!
make[1]: *** [__modpost] Error 1
make: *** [modules] Error 2

Reported-by: Josh Boyer <jwboyer@fedoraproject.org>
Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
a64e1a45060f41423c89768f4f7bef3283678539 23-Jan-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Fix RX interrupt mitigation

The threshold values for RX interrupt mitigation
are different for AR9003 and AR9002 families.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
1e2f9295f4c657500111514f92a3d3894d0e05b4 09-Jan-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Disable cross-band FCC

Fast Channel Change across bands was enabled for
AR9462 recently, but this is causing baseband issues.
Disable it until this feature is tested well. Also,
remove the feature bit for AR9565 since it is
a single-band card and doesn't support this feature.

Cc: stable@vger.kernel.org
Reported-by: Oleksij Rempel <linux@rempel-privat.de>
Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2c323058bcecb7d57610ebbcb85d4fa082d26c3b 31-Dec-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Add hardware support for QCA9531

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
e6b1e46eb25c240f7ac462efce6ae7aad90e5b7a 31-Dec-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Assign macVersion for QCA9531

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ff47f9320e8a20c60b78c4bb8340f2d76e18ff08 28-Dec-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Remove unused config option ack_6mb

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
04575f21d9c8dc3fbf8ad7d7ce3fc8261377def1 28-Dec-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Fix AR9100 chip power-on

AR9100 requires a larger delay after waking up
the RTC.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
f57cf939f050733871530b2441741186a5d8bcf3 28-Dec-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Cleanup __ath9k_hw_init()

* Move initialization of config variables to
ath9k_hw_init_config().

* Move initialization of defaults to ath9k_hw_init_defaults().

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
de82582b9a5e763835276012afd1b00746c8cf02 28-Dec-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Handle unsupported MAC versions early

There is no point in trying to bring up the chip when
the MAC version is not present in the supported list.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
e4ef2763039ec6ccd727b29d461e56414bf5425e 28-Dec-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Move private HW callbacks to hw-ops.h

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
1dd9619a21b7a334f84f35524aed1c39c5087b3b 28-Dec-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Remove unused functions

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
a7abaf7da975ecac58e22bae75605b2a1d8e7ff0 24-Dec-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Fix PHY restart workaround

The PHY restart workaround that handles baseband hangs
for packets with unsupported rates is required only
for a HW bug in AR9300 v2.2. All the subsequent chips in
the AR9003 family do not require this driver fix since
it has been addressed in the HW.

Since the value of the AR_PHY_RESTART register is written
with the default initvals, make sure that PHY restart is
always disabled once this particular BB hang signaure has
been encountered.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
990de2b2e48ac377fb40842a9b04fd940ba78e1b 24-Dec-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Add HW callbacks for MAC/BB hang checks

This is required for adding separate hang check
routines for AR9002 and AR9003.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
4598702d1b3e0b6aa6694f4c786313a999afbdc9 24-Dec-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Register supported HW hang checks

HW hang checks have to be done on a per-chip basis.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
cca213fd6bdfab7badfae3d8ca32b6af96202cb5 20-Dec-2013 Felix Fietkau <nbd@openwrt.org> ath9k_hw: fix TSF offset calculation

Since the unit is microseconds and not milliseconds, tv_sec needs to be
multiplied by 1000000, not 1000.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
a6a172b292a13c44464d9012809f24da41ddbf8a 20-Dec-2013 Felix Fietkau <nbd@openwrt.org> ath9k_hw: fix gentimer callback without overflow handler

If a gentimer has both the trigger and the overflow bits set, only
mask out the trigger bit if an overflow handler is present.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
6a4d05dc0c0178b0c30dbda6e9bb79b5dd9662f5 19-Dec-2013 Felix Fietkau <nbd@openwrt.org> ath9k: move ath9k_debug_sync_cause out of ath9k_hw

ath9k_hw should not depend on any ath9k data structures like ath_softc

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
d7df7a55cbac30acf8edade8f06458d35900ebfa 18-Dec-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Use a subroutine for the AR9330 reset WAR

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
4dc78c437a0a2ac152a2b2c5e91a814a6ef3599e 18-Dec-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Fix RTC reset delay

The delay that is required after issuing a RTC reset
varies for each chip. Handle this properly.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
afe36533c108f55c5245397a1cc82af312a32614 18-Dec-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Add a delay between RTC reset/clear for AR9003

The small delay that is present between a RTC reset/clear
operation is required for the chip to settle and this is
needed for all chips, not just the AR9002 family.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
4ed15762dce67192d4662860470a8be1f6d5fd53 14-Dec-2013 Felix Fietkau <nbd@openwrt.org> ath9k_hw: clean up station beacon timer API

Remove unused fields, pass timer info in usec instead of TU.
Preparation for fixing nexttbtt calculation

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
49685634c6cb943ba9b35ff182ee479ca5b73302 14-Dec-2013 Felix Fietkau <nbd@openwrt.org> ath9k_hw: remove additional_swba_backoff

It is unused

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ae0c40314a86c5c942d32d9cbbc9f96d70839935 14-Dec-2013 Felix Fietkau <nbd@openwrt.org> ath9k_hw: simplify spur channel handling

Remove ah->config.spurmode and ah->config.spurchans, always use EEPROM
data.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
787e05360bbe54b0cd95f2f424ca3c3d1d3639db 14-Dec-2013 Felix Fietkau <nbd@openwrt.org> ath9k_hw: remove ah->config.pcie_clock_req

It is unused

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
60c4bf29747ebcc2c467c1143a512cee92fc673f 14-Dec-2013 Felix Fietkau <nbd@openwrt.org> ath9k_hw: remove defunct ad-hoc mode ATIM window handling code

The hardware does not have support for ATIM processing, and the driver
does not set up ah->atim_window anywhere. Additionally, the code can
clobber the timer used by P2P powersave.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
c67ce33919d57627e98fadceea555ddc01ad77b4 14-Dec-2013 Felix Fietkau <nbd@openwrt.org> ath9k_hw: clean up generic timer code

- Use generic bitops instead of custom hackery
- Move interrupt enable/disable logic from ath9k to ath9k_hw
- Decouple ISR call from btcoex
- Make the overflow callback optional (to prevent IRQ storms)

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
935d00ccf7321d704a1bf8e982dd6934165c1327 12-Dec-2013 Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> ath9k: fix 5/10MHz channel width initialization on ar9003

Move ath9k_hw_set_rfmode() after ath9k_hw_process_ini() in order to avoid
AR_PHY_MODE register is overwritten with default values by
ar9003_hw_process_ini()

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
0c7c2bb4daebb23b08b86c24fe70189c3c049f78 06-Dec-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Fix regulatory compliance

Adjusting the CCA registers for maximum permissible
noise floor in ETSI/Japan domains has to be done for
all AR9003 family chips.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
af02efb32e34938aecce5362b0cdb70e4d18e846 18-Nov-2013 Felix Fietkau <nbd@openwrt.org> ath9k_hw: allow fast channel change when only CHANNEL_HT changes

The CHANNEL_HT flag is insignificant for fast channel change conditions,
since it does not affect any important part of the hardware reset /
channel setup.
Scanning usually runs with HT disabled, so this change will slightly
improve scan time on many chipsets.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
09d8e315d90a70eb1096d68f27be04d6c43724f3 18-Nov-2013 Felix Fietkau <nbd@openwrt.org> ath9k_hw: fix TSF save/restore around chip reset

A cold reset can be triggered because of DMA stop issues, and this leads
to TSF being cleared on all chipsets. To properly deal with this, always
save the TSF.
Additionally, account for the time it takes to do the actual chip reset,
which can be quite significant. On AR9344 it takes around 4.5 ms.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
c6fc7e64e1a699b77681dd383d9a5a1ff9eb48e9 29-Oct-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Remove pcieSerDesWrite

This HW config option is always set to true and is not needed.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
beae416b1f40ef3b6f7918035cefcf1d5f9aeb49 29-Nov-2013 Michal Nazarewicz <mina86@mina86.com> net: wireless: ath9k: avoid possible NULL pointer dereference

Code in ath9k_hw_set_clockrate function indicates that ah->curchan
(and thus chan local variable) may be NULL. If that is indeed the
case, IS_CHAN_HT40(chan) check has to be performed only in branch
where chan is not NULL. Moving the code under already existing
if condition fixes this issue.

Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
5bc225acfe6a6226333061107708033a8d181d39 11-Oct-2013 Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> ath9k: add noise floor parameter to ath9k_hw_getchan_noise

Add nf parameter to ath9k_hw_getchan_noise() in order to compute NF for EXT
chains with the same scale of noise floor calculated on CTL chains.
ath9k_hw_getchan_noise() will be used in ath_process_fft() for spectral scan on
HT40 channels

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
e4744ec78669926000e47e6ec78b987c0b2f10e9 11-Oct-2013 Felix Fietkau <nbd@openwrt.org> ath9k_hw: remove references to hw->conf

Accessing it to get the current operating channel is racy and in the way
of further channel handling related changes

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
6b21fd2027f8deb6fb7d3283b4c2eacabc8eeb95 11-Oct-2013 Felix Fietkau <nbd@openwrt.org> ath9k_hw: simplify channel flags

There was some duplication between channelFlags and chanmode, as well as
a lot of redundant checks based on the combinations of flags.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
81c507a8b09fe00a1b4a2e7e84ba7234b126c332 11-Oct-2013 Felix Fietkau <nbd@openwrt.org> ath9k_hw: remove IS_CHAN_OFDM()

The hardware is always configured with OFDM support enabled

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
1a5e63265f6dbd616596325d899332ddc506e83e 11-Oct-2013 Felix Fietkau <nbd@openwrt.org> ath9k_hw: remove IS_CHAN_B()

Hardware 802.11b-only mode isn't supported by the driver (the device is
configured for 802.11n/g instead). Simplify the code by removing checks
for it.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
8896934c168474079ba1e81cf3f0c4a975b30406 11-Oct-2013 Felix Fietkau <nbd@openwrt.org> ath9k_hw: remove direct accesses to channel mode flags

Use wrappers where available. Simplifies code and helps with further
improvements to the channel data structure

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
4b9b42bfe08fa369c4f51f00d5f349b32242cd8c 11-Sep-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Use bitops for calibration flags

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
1e516ca7c9ceeeec4ed87f549a14bc3b73427f83 11-Sep-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Handle abnormal NAV in AP mode

Beacon transmission would get stuck if the NAV is
an invalid value for some reason. Check and correct
the NAV value in the HW when this happens.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
5e88ba6228e66741811992a6c1d7cf37195ed4be 05-Sep-2013 Zefir Kurtisi <zefir.kurtisi@neratec.com> ath9k: replace snprintf() with scnprintf()

Whenever the return value of snprintf() is used to calculate
remaining buffer-space, we wanted to use sncprintf() instead.

Indentation is adapted where possible. Some lines exceed the
line width limit, either they did it already before, or
since they can not be broken reasonably well.

Signed-off-by: Zefir Kurtisi <zefir.kurtisi@neratec.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
d3b371cb03330fc2474d418b0a86a5fea7267370 03-Sep-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Fix regulatory compliance for AR9462/AR9565

Adjust the CCA values based on the regulatory domain
present in the EEPROM.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
27251e0087598befb39599eb3dd2a3c59bce2fb9 27-Aug-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Enable D3/L1 ASPM fix for AR9462

AR9462 requires this HW fix for ASPM to work properly.
Also, since WARegVal is used only for the AR8003 family,
use AR_SREV_9300_20_OR_LATER.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
65c1a4de59b0d417d68c04d5ee033058a9e7a83a 27-Aug-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Remove unused ANI commands

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
d1ae25a0174938f03e28dee8f3269a826fc1bec5 25-Aug-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Fix ASPM workaround usage

The PCIE Workaround register (AR_WA/0x4004) is used to handle
various hardware quirks. For AR9002 chips, AR_WA_D3_L1_DISABLE
is used to prevent the HW from automatically entering L1 state
when D3 is enforced.

AR_WA_D3_L1_DISABLE has to be enabled for a few AR9280 based
cards, mark them based on their PCI subdevice/subvendor IDs
and enforce it in ar9002_hw_configpcipowersave().

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
92367fe7f24159d6ba83276bc7a0f45c6f663837 14-Aug-2013 Simon Wunderlich <simon.wunderlich@s2003.tu-chemnitz.de> ath9k: always use SIFS times from OFDM for 5/10 MHz

5/10 MHz channels should always use SIFS times as defined in IEEE
802.11-2012 18.4.4 (OFDM PHY characteristics). This makes it compatible
to ath5k, which does the same.

Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
Signed-off-by: Mathias Kretschmer <mathias.kretschmer@fokus.fraunhofer.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
7bdea96a1bbae75e7922584e3ae37fb9ad6cb79a 04-Aug-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Remove "shared_chain_lnadiv"

This variable is redundant since we can use
common->bt_ant_diversity to determine if diversity
has to be enabled/disabled.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
f85c3371aee070a65d837afdd5377e9dc66fbd52 04-Aug-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Print LNA combining mode during init

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
70e89a71c83b1937f1662429b255cf21e51aecea 15-Jul-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Release the RF bus after setting board values

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
5f35c0fae9162b867d6cd035490fe4831151301d 15-Jul-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Use correct channel when switching bands

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
b840cffedee3a19b8c90becc4b999e6bf4f28cb0 15-Jul-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Fix FastChannelChange for AR9462/AR9565

Right now, even though these chips support cross-band
FCC, the code is non-functional since we bail out early if
the channelFlags differ. Fix this so that cross-band
FCC works for cards that support this feature.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
81dc75b584fd0f889b56b49b363287a600eaf0d3 15-Jul-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Add a HW flag for FCC

Fast Channel Change across 2G/5G bands is supported
only by AR9462 and AR9565. Add a HW capability field
to indicate this.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
74e13060f11dbf4028b810e34c359f64929415f3 03-Jul-2013 Johannes Berg <johannes.berg@intel.com> ath9k: make rfkill configurable

When the platform doesn't have rfkill support, i.e. nothing
is connected to the rfkill GPIO, there's little value in
polling the GPIO. Add a Kconfig option to allow disabling
the polling in ath9k.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2b5e54e22f596bcd9ec0018f228a2606e016a108 24-Jun-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Add support for AR9462 2.1

Various parts of the HW code are applicable for
both v2.0 and v2.1.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
143353104983f5af2c6087203b83312e58f3dc86 18-Jun-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Merge HWTIMER debug level with BTCOEX

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
696df78509d1f81b651dd98ecdc1aecab616db6b 10-Jun-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Fix noisefloor calibration

The commits,

"ath9k: Fix regression in channelwidth switch at the same channel"
"ath9k: Fix invalid noisefloor reading due to channel update"

attempted to fix noisefloor calibration when a channel switch
happens due to HT20/HT40 bandwidth change. This is causing invalid
readings resulting in messages like:

"ath: phy16: NF[0] (-45) > MAX (-95), correcting to MAX".

This results in an incorrect noise being used initially for reporting
the signal level of received packets, until NF calibration is done
and the history buffer is updated via the ANI timer, which happens
much later.

When a bandwidth change happens, it is appropriate to reset
the internal history data for the channel. Do this correctly in the
reset() routine by checking the "chanmode" variable.

Cc: stable@vger.kernel.org
Cc: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
e323300d9741d44e6543ece3659671742f93acba 03-Jun-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Simplify ANI initialization

The check "enable_ani" is not required since it is always
set to true and the logic for disabling/enabling ANI via
debugfs is done at a higher layer.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
846e438f5ffec6d5508478bba2b9245a1f358df3 03-Jun-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Enable WoW only for AR9462

The only card with which WoW has been tested and verified is
AR9462. Do not enable it for all cards since WoW is really quirky
and needs to be tested properly with each chip.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
86c157b3f83597e11d8f03a9dece98d1e77a8ce7 23-May-2013 Felix Fietkau <nbd@openwrt.org> ath9k_hw: improve performance for AR934x v1.3+

AR934x v1.3 no longer needs the DCU backoff reduction workaround for
preventing rx overruns, but in turn needs the number of usable Tx
buffers to be reduced slightly.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
a37a99102e4573145aa60a2f78a690cc8def027c 23-May-2013 Felix Fietkau <nbd@openwrt.org> ath9k_hw: fix host interface reset on AR934x

If a local bus timeout has been detected, the host interface needs to be
reset to clear the errors. AR934x uses a different synchronous interrupt
bit to indicate this, so the check needs to be fixed.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2664d6665f45ef582583d14929dba1170829042e 08-May-2013 Thomas Pedersen <thomas@cozybit.com> ath9k: use ap style beaconing for mesh

Chun-Yeow and Javier Lopez contributed these changes to
make mesh mode use the more similar AP beaconing mode and
queue parameters. Should improve PS performance, interface
concurrency (AP modes can coexist), and beacon interval
stability.

AR9271 (ath9k_htc) mesh interfaces also need to be in AP
operating mode.

Signed-off-by: Thomas Pedersen <thomas@cozybit.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
f77f8234409978fefa0422b12a497451173e39b3 22-Apr-2013 Mathias Kretschmer <mathias.kretschmer@fokus.fraunhofer.de> ath9k: apply coverage class on slottime too

According to 802.11-2007 17.3.8.6 (slot time), the slot time should
be increased by 3 us * coverage class. The code only increased the
ack timeout, which is fixed by this patch.

We have noticed in our long shot scenario that we see less collisions
with this patch.

Signed-off-by: Mathias Kretschmer <mathias.kretschmer@fokus.fraunhofer.de>
[add standard reference and commit message]
Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ecbbed32e7c2ad7d9a6305b02e11502b51f2605c 16-Apr-2013 Felix Fietkau <nbd@openwrt.org> ath: update hardware mac address with bssid mask

Preparation for updating common->macaddr along with virtual interface
MAC address changes.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
73e4937d489072a26a0077c72c7d50ef2d0bf02b 03-Apr-2013 Zefir Kurtisi <zefir.kurtisi@neratec.com> ath9k: add support for DFS master mode

These are the remaining knobs in ath9k to support DFS:
* mark AR9280 and AR9580 as DFS tested
* synchronize DFS regulatory domain to reg notifyer
* set required RX filter flags for radar detection
* process radar PHY errors at DFS detector
* notify DFS master on radar detection

DFS support requires CONFIG_ATH9K_DFS_CERTIFIED to be set.

Signed-off-by: Zefir Kurtisi <zefir.kurtisi@neratec.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
675a0b049abf6edf30f8dd84c5610b6edc2296c8 25-Mar-2013 Karl Beldan <karl.beldan@rivierawaves.com> mac80211: Use a cfg80211_chan_def in ieee80211_hw_conf_chan

Drivers that don't use chanctxes cannot perform VHT association because
they still use a "backward compatibility" pair of {ieee80211_channel,
nl80211_channel_type} in ieee80211_conf and ieee80211_local.

Signed-off-by: Karl Beldan <karl.beldan@rivierawaves.com>
[fix kernel-doc]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
15d2b58577ac6ef580160069911a237aeaf955db 03-Mar-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k_hw: Use helper functions to simplify HW reset

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
fcb9a3de1e72cb271343aa9484a20c066b6c4eee 03-Mar-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k_hw: Remove CHANNEL_CW_INT

This flag is used for indicating channel interference and
we currently do nothing with it, so remove it.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
3412f2f086ea7531378fabe756bd4a1109994ae6 25-Feb-2013 Felix Fietkau <nbd@openwrt.org> ath9k_hw: improve reset reliability after errors

On many different chips, important aspects of the MAC state are not
fully cleared by a warm reset. This can show up as tx/rx hangs, those
annoying "DMA failed to stop in 10 ms..." messages or other quirks.

On AR933x, the chip can occasionally get stuck in a way that only a
driver unload/reload or a reboot would bring it back to life.

With this patch, a full reset is issued when bringing the chip out of
FULL-SLEEP state (after idle), or if either Rx or Tx was not shut down
properly. This makes the DMA related error messages disappear completely
in my tests on AR933x, and the chip does not get stuck anymore.

Cc: stable@vger.kernel.org
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
14f8dc49532f765968ff37c3b99edbeb99004ace 07-Feb-2013 Joe Perches <joe@perches.com> drivers: net: Remove remaining alloc/OOM messages

alloc failures already get standardized OOM
messages and a dump_stack.

For the affected mallocs around these OOM messages:

Converted kmallocs with multiplies to kmalloc_array.
Converted a kmalloc/memcpy to kmemdup.
Removed now unused stack variables.
Removed unnecessary parentheses.
Neatened alignment.

Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: Arend van Spriel <arend@broadcom.com>
Acked-by: Marc Kleine-Budde <mkl@pengutronix.de>
Acked-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
f5ffe23aa0a8f6512952cf393daf86cbd6e4685d 20-Jan-2013 Felix Fietkau <nbd@openwrt.org> ath9k_hw: remove ath9k_hw_ani_setup and its variables

They are no longer needed for ANI functionality

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
0166b4beec575f9740b7a0843675173c2e00cdbc 20-Jan-2013 Felix Fietkau <nbd@openwrt.org> ath9k_hw: make the initval parameter to ath9k_hw_write_array const

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
6aaacd861517f89797f2f4a54624a599847262f3 13-Jan-2013 Felix Fietkau <nbd@openwrt.org> ath9k_hw: fix RF bank initialization

ar900*_init_mode_regs needs to be called before RF banks are allocated,
otherwise the storage size of RF banks isn't known. This patch fixes
a memory overrun that can show up as a crash on unloading the module.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
b686929c544be6d2d30b82dfb7a61a7766885177 02-Jan-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k_hw: Enable calibration types in init_cal_settings

Doing this in ath9k_hw_fill_cap_info() is odd and it's
cleaner to do this in the init function for calibration.
Also, setup the supported calibration type in init_cal_settings.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
c1b976d2fcb3b308906be7c6bda1390251dec32d 12-Dec-2012 Felix Fietkau <nbd@openwrt.org> ath9k_hw: use the devres API for allocations

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Acked-by: Luis R. Rodriguez <mcgrof@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
0f21ee8d9c8a041b974cfb75d81d07b61bd0869f 10-Dec-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k_hw: Add HW cap for PAPRD

Add a HW capability to indicate whether PAPRD is enabled
for the card, since PAPRD could be enabled in the EEPROM, but
disabled in the driver. This makes things clearer.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
da8fb123b041e487d28f54d3a77a15139cb9e3b9 17-Nov-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k_hw: Fix regression in device reset

Commit "ath9k: improve suspend/resume reliability" broke ath9k_htc
and bringing up the device would hang indefinitely. Fix this.

Cc: stable@vger.kernel.org
Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
b126b02796eaac8534b699571bd4209e05b64146 12-Nov-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Remove unused workaround

The workaround for ASPM/L0s is needed only for AR9485 1.0,
which was never sold and is not supported by ath9k.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
cdbe408da76d5cc294edb013850cc3a972d80968 25-Oct-2012 Rajkumar Manoharan <rmanohar@qca.qualcomm.com> ath9k_hw: validate MCI stuck after RTC wakeup

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ceb26a6013b962b82f644189ea29d802490fc8fc 03-Oct-2012 Felix Fietkau <nbd@openwrt.org> ath9k: improve suspend/resume reliability

Ensure that drv_start() always returns true, as a failing hw start usually
eventually leads to crashes when there's still a station entry present.
Call a power-on reset after a resume and after a hw reset failure to bring
the hardware back to life again.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
06236e53ce83d9f770a25a5305b8651544ff8b67 16-Sep-2012 Sujith Manoharan <c_manoha@qualcomm.com> ath9k_hw: Enable WLAN RX diversity for AR9565

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
362cd03fd828af38327fb448416c07a7c7a8e3cb 16-Sep-2012 Sujith Manoharan <c_manoha@qualcomm.com> ath9k_hw: Add a HW callback to set diversity

This patch adds a new callback to handle WLAN RX diversity for
AR9565.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
88033318e119bbf4647db4d50ad549fc86e0acf0 12-Sep-2012 Rajkumar Manoharan <rmanohar@qca.qualcomm.com> ath9k_hw: move 2g5g switch before nfcal start

During fast channel change, perform 2g5g_switch before starting
noisefloor calibration to avoid nfload timeout.

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
b7f597668657c9c9579dbdff9692aea3e8e9bf5a 11-Sep-2012 Sujith Manoharan <c_manoha@qualcomm.com> ath9k_hw: Handle gentimer termination properly

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
8565f8bf478e28a416e2816d906a84e323e5629c 10-Sep-2012 Sujith Manoharan <c_manoha@qualcomm.com> ath9k_hw: Program correct PLL value for AR9565

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
e41db61d55fa58de9854c1d4932ea255f448d4b8 10-Sep-2012 Sujith Manoharan <c_manoha@qualcomm.com> ath9k: Set correct max streams for AR9565

Also, set the correct chainmask.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
a4a2954ff49e72ce3fa1f78a156b2492a023c89d 10-Sep-2012 Sujith Manoharan <c_manoha@qualcomm.com> ath9k_hw: Add AR9565 HW support

Various parts of the code require AR9565 checks,
this patch adds them.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
77fac465b4b65056a2cec62c1acdc754b7ae86ed 11-Sep-2012 Sujith Manoharan <c_manoha@qualcomm.com> ath9k_hw: Add version/revision macros for AR9565

And recognize the device in the init path.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
74673db99ca3c09d34ea479f684522ceedb65eb9 08-Sep-2012 Felix Fietkau <nbd@openwrt.org> ath9k: make PA linearization optional, disabled by default and fix checks

Some checks for PA linearization support checked ATH9K_HW_CAP_PAPRD and some
used the EEPROM ops, leading to issues in tx power handling, since those
two can be out of sync.

Disable the feature by default, since it has been reported that it can
cause damage to the rx path under some circumstances. It can now be enabled
for testing via debugfs.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
b3ccc1a56280119fe1fbf9929a76b4034358bfef 27-Aug-2012 Felix Fietkau <nbd@openwrt.org> ath9k_hw: enable PA linearization

This feature had been disabled in ath9k because the code to support
it was incomplete, but now the code is in sync with the internal QCA
codebase, so it's time to enable it.

On many newer devices, the calibration is assumed to be done with PA
linearization enabled.

Tests with a particular AR933x device showed that the signal emitted
at full power was highly distorted and unreliable with PA linearization
disabled. With this patch, the signal becomes clear and stability
is improved.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
51dea9be7e01d7e825ed1882246693f09c21374c 27-Aug-2012 Felix Fietkau <nbd@openwrt.org> ath9k: fix PA linearization calibration related crash

Before PAPRD training can run, the card needs to have sent a packet for
thermal calibration. Sending a dummy packet with the PAPRD training flag
set causes a crash under some circumstance.
Fix the code by replacing the dummy tx with a delay that waits for a
real packet tx to have occurred.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
1630d25fd00f195f0923d4b895e0529fdbba83c3 27-Aug-2012 Felix Fietkau <nbd@openwrt.org> ath9k_hw: disable PA linearization for AR9462

Support for it is incomplete

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
280b9a9de19b0819dcf1ab38c88e37bb82dbea0c 27-Aug-2012 Felix Fietkau <nbd@openwrt.org> ath9k_hw: do not enable the MIB interrupt in the interrupt mask register

The interrupt is no longer handling it. While it shouldn't fire (wraparound
is highly unlikely), the consequences would be fatal (interrupt storm).
Disable the interrupt to prevent that from happening.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
d4e5979c0da95791aa717c18e162540c7a596360 02-Aug-2012 Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com> ath9k: Add PID/VID support for AR1111

AR1111 is same as AR9485. The h/w
difference between them is quite insignificant,
Felix suggests only very few baseband features
may not be available in AR1111. The h/w code for
AR9485 is already present, so AR1111 should
work fine with the addition of its PID/VID.

Cc: stable@vger.kernel.org [2.6.39+]
Cc: Felix Bitterli <felixb@qca.qualcomm.com>
Reported-by: Tim Bentley <Tim.Bentley@Gmail.com>
Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Tested-by: Tim Bentley <Tim.Bentley@Gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
60ca9f8744d29b8fdfd33d3dec8fc2cfc9ec381a 17-Jul-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k_hw: Cleanup ath9k_hw_set_tsfadjust

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
00f97b4fd578328a6a54d4e2c3cfa74c6c32683f 15-Jul-2012 Felix Fietkau <nbd@openwrt.org> ath9k_hw: enable ANI on AR934x

It has been tested and works properly

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
d687809bd839bd45d78de7f16707de9a98aab717 10-Jul-2012 Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com> ath9k_hw: advertise WoW support for capable chipsets

support WoW for all chipsets starting from AR9280, AR9285, AR9287,
AR9380, AR9382, AR9485, AR9462. Really all hardware may not support
WoW even though the flag is set and the WoW working depends on
your laptop, BIOS apart from the hardware.

Cc: Senthil Balasubramanian <senthilb@qca.qualcomm.com>
Cc: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Cc: vadivel@qca.qualcomm.com
Signed-off-by: Luis R. Rodriguez <mcgrof@qca.qualcomm.com>
Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2b943a3315f4c01e84b7913e9e97b148da9da9d3 03-Jul-2012 Gabor Juhos <juhosg@openwrt.org> ath9k: enable support for AR9550

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Acked-by: Luis R. Rodriguez <mcgrof@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
fc05a3178476695603c25b6be8c28e8457df0cc2 03-Jul-2012 Gabor Juhos <juhosg@openwrt.org> ath9k: fix PLL initialization for AR9550

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Acked-by: Luis R. Rodriguez <mcgrof@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
3b8a0577b746f700646c0d8814fd1aabc2fc9c91 03-Jul-2012 Gabor Juhos <juhosg@openwrt.org> ath9k: disable SYNC_HOST1_FATAL interrupts for AR9550

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Acked-by: Luis R. Rodriguez <mcgrof@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2f8d10fd860639ba10f39a3a6e3dfd8061759ff5 03-Jul-2012 Gabor Juhos <juhosg@openwrt.org> ath9k: enable TX/RX data byte swap for AR9550

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Acked-by: Luis R. Rodriguez <mcgrof@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
c95b584b8d7ffda2e08c24bb3164a601736a8b92 03-Jul-2012 Gabor Juhos <juhosg@openwrt.org> ath9k: clear pciexpress flag for AR9550

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Acked-by: Luis R. Rodriguez <mcgrof@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
485124cbb746eba343e0763b917cc303ae3d0916 03-Jul-2012 Gabor Juhos <juhosg@openwrt.org> ath9k: add BB name string for AR9550

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Acked-by: Luis R. Rodriguez <mcgrof@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
813831dc67ae06abc35d28fa6995553a01f25a94 03-Jul-2012 Gabor Juhos <juhosg@openwrt.org> ath9k: set MAC version for AR9550

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Acked-by: Luis R. Rodriguez <mcgrof@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
1fe860edb0787fa2df6d043e34a55dc739e235f0 01-Jul-2012 Rajkumar Manoharan <rmanohar@qca.qualcomm.com> ath9k_hw: start noisefloor calibration after MCI reset

noisefloor calibration has to be loaded and started after
chip reset completion and restoring chainmask. Right now it is
being started before MCI reset completion on full reset. Fix that.

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
7508b657967cf664b5aa0f6367d05016e7e3bc2a 26-Jun-2012 Panayiotis Karabassis <panayk@gmail.com> ath9k: enable serialize_regmode for non-PCIE AR9287

https://bugzilla.kernel.org/show_bug.cgi?id=42903

Based on the work of <fynivx@gmail.com>

Signed-off-by: Panayiotis Karabassis <panayk@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: John W. Linville <linville@tuxdriver.com>
f18e3c6b67f448ec47b3a5b242789bd3d5644879 18-Jun-2012 Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com> ath9k_hw: avoid possible infinite loop in ar9003_get_pll_sqsum_dvc

"ath9k: Fix softlockup in AR9485" with commit id
64bc1239c790e051ff677e023435d770d2ffa174 fixed the reported
issue, yet its better to avoid the possible infinite loop
in ar9003_get_pll_sqsum_dvc by having a timeout as suggested
by ath9k maintainers.
http://www.spinics.net/lists/linux-wireless/msg92126.html.
Based on my testing PLL's locking measurement is done in
~200us (2 iterations).

Cc: stable@vger.kernel.org
Cc: Rolf Offermanns <rolf.offermanns@gmx.net>
Cc: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Cc: Senthil Balasubramanian <senthilb@qca.qualcomm.com>
Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
506847ad34c08fe4f766ffe1b955713628acf6bd 12-Jun-2012 Rajkumar Manoharan <rmanohar@qca.qualcomm.com> ath9k_hw: cleanup MCI gpm offset state

Add utility functions to get and test GPM offset and
remove MCI_STATE*_GPM_OFFSET states.

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ed6ebd8bc852845e34e8160eed43b29236b1892f 10-Jun-2012 Rajkumar Manoharan <rmanohar@qca.qualcomm.com> ath9k_hw: program OBS register only when MCI is disabled

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
1bde95fa7ed84094d0606d9e79356a9dd8d0e01b 10-Jun-2012 Rajkumar Manoharan <rmanohar@qca.qualcomm.com> ath9k_hw: fix incorrect LNA register settings

After a full reset, mci_reset will put LNA update to the setting
for 2G mode. Those registers need to be forced to update when
the channel is in 5G.

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
3863495b86d8ee8e7e70a328de5b88d555d7305a 10-Jun-2012 Rajkumar Manoharan <rmanohar@qca.qualcomm.com> ath9k_hw: check GPM HW write pointer before chip reset

Both "MAC Warm Reset" and "MCI Reset Rx" will reset GPM HW write_ptr.
We should check software cached write_ptr against HW write_ptr before
reset. Otherwise the pending DMA data will be lost.

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
9dd9b0dc1de8031a31b3eaebc6a9c0ab60612026 10-Jun-2012 Rajkumar Manoharan <rmanohar@qca.qualcomm.com> ath9k_hw: Fix AR9462 power consumption on idle associated

The HW statemachine is sometimes found stuck in the state
WL_LNA_CTRL_DISABLE when BT is in sleep, which will cause
TX_HOLD always asserted and resmgr stuck in PENDING_TX state

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
153dccd467b818b1dd3a6801b14e94a7a48ef859 04-Jun-2012 Rajkumar Manoharan <rmanohar@qca.qualcomm.com> ath9k_hw: fix power state for MCI

Program MCI related power registers only if MCI interrupts
are enabled. This could help to reduce power consumptions when
WLAN alone is enabled in BT coex chips.

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
99922a45e96b22df387823ad5ecfe4dc26a96c9e 04-Jun-2012 Rajkumar Manoharan <rmanohar@qca.qualcomm.com> ath9k_hw: fix BT RF performance

When software rfkill is triggered, before put the chip in reset
state, give LNA and SPDT control to BT to make sure BT can have
good RF performance.

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
31604cf0a73ffd63929f3a646d5402d5901c6e4b 04-Jun-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k_hw: Cleanup power mode API

The 'setChip' variable is unused, remove it and
simplify the functions.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
5955b2b0ef208e03188ef1c2810c004bde493253 04-Jun-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k_hw: Fix MCI usage

MCI has to be handled only when BTCOEX is actually enabled.
Check for this condition before calling MCI related functions
from various reset/calibration call-sites.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
83c7a52dcce256fc20cd43dbf6866e3e05f2bf71 04-Jun-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k_hw: Fix AR_RTC_KEEP_AWAKE usage

The default value that is being programmed to AR_RTC_KEEP_AWAKE
is 0x2, there is no need to program it manually in various
functions.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
d09f5f4cfb9f4c6aa8c18ea522e824660d4096d7 04-Jun-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Handle ASPM properly

ASPM has to be disabled when BTCOEX is in use, do this properly
by calling the bus-specific ASPM init routine after the
BTCOEX scheme has been determined.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
bfc441a4bbe9b7a56d3611cc14c98cce3a573565 24-May-2012 Felix Fietkau <nbd@openwrt.org> ath9k_hw: apply internal regulator settings on AR933x

On AR933x, the internal regulator settings need to be applied before the
PLL init to avoid stability issues.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
8a90555fea9f2e1498a9efe4f25c32d2846f257f 04-May-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k_hw: Fix RTT calibration

This patch fixes multiple issues with the current RTT
implementation in ath9k.

* The data that is obtained from the RTT interface registers
are stored in 31:5 - mask out the extra bits when reading them.

* A history buffer is maintained which is not needed at all.
Remove this array and just store the baseband data for each
chain (or bank).

* A 'num_readings' variable was being used to handle the
last entry. But it was being used in an improper manner, with
the result that the RTT values were never being written
to the RTT Interface registers. Fix this by using a simple
flag.

* Stop baseband operations before programming the calibration values
to the HW.

* Do not restore RX gain settings as part of RTT.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
feb7bc9951246157cb9043b9886c7919b32d3cb9 19-Apr-2012 Felix Fietkau <nbd@openwrt.org> ath9k_hw: disable fast channel change when changing from/to half/quarter mode

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
7c5adc8d83c344dbad251091879baf1244007564 19-Apr-2012 Felix Fietkau <nbd@openwrt.org> ath9k_hw: fix and clean up PHY activation delay

The delay calculation is the same for all chips, however some parts of the
code missed the extra delay factor for half/quarter.
Clean up the code and move the delay calculation to a common place.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
e115b7ec336bdeb1cf950cfcdc159f4628775c53 19-Apr-2012 Felix Fietkau <nbd@openwrt.org> ath9k_hw: increase ACK timeout for half/quarter channels

For some reason the MAC timing is a bit off when waiting for ACKs, so add
some extra delay to the ACK timeout values. Significantly reduces the
number of retransmissions in my tests.
Also disable the 2.4 GHz ACK timeout workaround in half/quarter mode, it
is not required there.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
e88e486115a21c27389b666191b318988fbca07f 19-Apr-2012 Felix Fietkau <nbd@openwrt.org> ath9k_hw: use standard SIFS time as reference for half/quarter channels

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
64ea57d0c77bd85003b63c6090ddfae114ef6508 15-Apr-2012 Gabor Juhos <juhosg@openwrt.org> ath9k: add an extra boolean parameter to ath9k_hw_apply_txpower

In order to unifying regulatory limit handling
commit ca2c68cc7bc80fc4504fb420df04cce99c9ee6ec
(ath9k_hw: clean up tx power handling) introduced
a new helper function 'ath9k_hw_apply_txpower',
and the direct calls of 'ah->eep_ops->set_txpower'
has been replaced by a call of the helper function.

This caused a change in the behaviour of the
'ath9k_hw_set_txpowerlimit' function. The purpose
of that function is to calculate and store the
rate txpower table and the regulatory limit without
touching the hardware registers. Before the commit,
the 'test' parameter of the function was passed to
the 'ah->eep_ops->set_txpower'. Now the calling of
the 'set_txpower' function happens indirectly through
'ath9k_hw_apply_txpower', so the 'test' argument of
the 'set_txpower' is always 'false'.

This patch restores the original behaviour of
'ath9k_hw_set_txpowerlimit' by adding a new
argument to 'ath9k_hw_apply_txpower.'

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Acked-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
689e756fad5b89d25bb47d40a0e08e3aba79510f 12-Apr-2012 Felix Fietkau <nbd@openwrt.org> ath9k_hw: add support for 8 AP mode interfaces

Also tweak beacon response times for better stability with the shorter
timer intervals.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
462e58f2b6f2f3ca113b44794f2c35ee8e792b93 12-Apr-2012 Ben Greear <greearb@candelatech.com> ath9k: Gather and report IRQ sync_cause errors.

Report all defined sync_cause errors in debugfs
to aid with debugging.

Use a macro to print out the interrupts file contents
to decrease code duplication.

Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
997002785e3f932fd26a0f9c3cd91d4b4861ed29 10-Apr-2012 Zefir Kurtisi <zefir.kurtisi@neratec.com> ath9k: remove dead code

Clean up some orphaned code lines containing
* unused variables (not referenced / write-only)
* non-implemented function prototypes

Signed-off-by: Zefir Kurtisi <zefir.kurtisi@neratec.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
01e189182d62d6ee3603233fc88f9235e9830b92 15-Mar-2012 Rajkumar Manoharan <rmanohar@qca.qualcomm.com> ath9k: recover ar9380 chips from rare stuck state

In the experiment with Azimuth ADEPT-n testbed where the APs transmit
power was reduced to 25% and the signal strength was futher attenuated
by 20dB and induced a path loss of ~7dB, the station was reporting
beacon losses and the following issue were observed.

* rx clear is stuck at low for more than 300ms
* dcu chain and complete state is stuck at one of the hang signature

This patch triggers the hang detection logic that recovers the chip
from any of the above conditions. As the issue was originally reported
in ChromeOs with AR9382 chips, this detection logic is enabled only for
AR9380/2 chips.

Cc: Paul Stewart <pstew@google.com>
Reported-by: Gary Morain <gmorain@google.com>
Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
c8664d13a58f7cccc673c0840efcc698f7872172 14-Mar-2012 Felix Fietkau <nbd@openwrt.org> ath9k_hw: fold ar9002_hw_cck_chan14_spread into mode regs initialization

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
f3eef64521f82330b4b173584d776b8a04b3e795 14-Mar-2012 Felix Fietkau <nbd@openwrt.org> ath9k: optimize register access functions

By checking for NR_CPUS, the compiler can optimize out register access
serialization code on non-SMP kernels

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
99ac8cd6ff44e733acdff0d36475dce2d3fe6a6b 14-Mar-2012 Felix Fietkau <nbd@openwrt.org> ath9k_hw: remove ath9k_hw_getdefantenna

The default antenna (as programmed by the INI file) is always 0 anyway.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
8efa7a813233affeafd9fd7770709e9bda6855b6 14-Mar-2012 Felix Fietkau <nbd@openwrt.org> ath9k_hw: remove ath9k_hw_htc_resetinit

Automatically set the ah->htc_reset_init on init and after PHY disable.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
caed6579c2f9756d3f5a95e8186fa4c04d64cae2 14-Mar-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k_hw: Cleanup FastChannelChange

The logic to determine whether to use FCC is a bit convoluted.
Use a small helper function to decide whether FCC is to be
used.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
3789d59c24cb142e4590492c3b5137a7c3dec352 08-Mar-2012 Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com> ath9k_hw: Fix enabling of MCI and RTT

tested in AR9462 Rev:2, both hardware capability flag are set

Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
9c083af8683808e486c20ca1f36da520d82e5981 03-Mar-2012 Felix Fietkau <nbd@openwrt.org> ath9k_hw: use cold instead of warm reset on AR9280

Cold reset is more reliable for getting the hardware out of some specific
stuck states.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
dbccdd1d320e8454e25750ba6adec3b0d0688fe8 22-Feb-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k_hw: Use CONFIG_ATH9K_BTCOEX_SUPPORT

Make use of CONFIG_ATH9K_BTCOEX_SUPPORT in ath9k_hw
to provide a clean way of compilation without BTCOEX
support.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
f4701b5a0dc3e047d4a9e11cd70d8839893bad17 21-Feb-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k_hw: Cleanup MCI bits from hw.h

This patch moves all the MCI-specific declarations that have been
dumped unceremoniously in hw.h to ar9003_mci.h

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
528e5d3605a589632bb6660aa1ea90729f8ca776 21-Feb-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k_hw: Cleanup MCI bits from ath9k_hw_reset()

This patch moves all the MCI-specific code in the main reset
function to helper functions.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
d1ca8b8ecd18d99cf3ae0c2a9b81d3a22b4141c1 21-Feb-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k_hw: Handle MCI power state using a helper

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
d68475de9637a476ad8e5870060ccc69a80f2299 21-Feb-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Initialize BTCOEX scheme using a helper

Setting up the required scheme can be done as part of the
BTCOEX initialization path and it doesn't belong in
ath9k_hw_fill_cap_info() anyway.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
c91ec465cab4a831671e01d65113330239faee61 21-Feb-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com> ath9k: Remove AR9462 v1.0 support

v1.0 chips are not available in the market.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
23677ce3172fcb93522a1df077d21019e73ee1e3 09-Feb-2012 Joe Perches <joe@perches.com> drivers/net: Remove boolean comparisons to true/false

Booleans should not be compared to true or false
but be directly tested or tested with !.

Done via cocci script:

@@
bool t;
@@
- t == true
+ t
@@
bool t;
@@
- t != true
+ !t
@@
bool t;
@@
- t == false
+ !t
@@
bool t;
@@
- t != false
+ t

Signed-off-by: Joe Perches <joe@perches.com>
Reviewed-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
55a2bb4a6d5e8c7b324d003e130fd9aaf33be4e6 05-Feb-2012 Felix Fietkau <nbd@openwrt.org> ath9k_hw: fix a RTS/CTS timeout regression

commit adb5066 "ath9k_hw: do not apply the 2.4 ghz ack timeout
workaround to cts" reduced the hardware CTS timeout to the normal
values specified by the standard, but it turns out while it doesn't
need the same extra time that it needs for the ACK timeout, it
does need more than the value specified in the standard, but only
for 2.4 GHz.

This patch brings the CTS timeout value in sync with the initialization
values, while still allowing adjustment for bigger distances.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Cc: stable@vger.kernel.org
Reported-by: Seth Forshee <seth.forshee@canonical.com>
Reported-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
8a30930563521c9dba73c93b5631be1d0993f78f 17-Dec-2011 Felix Fietkau <nbd@openwrt.org> ath9k_hw: make bluetooth coexistence support optional at compile time

Many systems (e.g. embedded systems) do not have wifi modules connected to
bluetooth modules, so bluetooth coexistence is irrelevant there. With the
addition of MCI support, ath9k picked up quite a bit of extra code that
can be compiled out this way.

This patch redefines ATH9K_HW_CAP_MCI and adds an inline wrapper for
querying the bluetooth coexistence scheme, allowing the compiler to
eliminate code that uses it, with only very little use of #ifdef.

On MIPS this reduces the total size for the modules by about 20k.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
d2182b69dcb6a68b1ef6070b2efd094e13dea3f1 15-Dec-2011 Joe Perches <joe@perches.com> ath: Convert ath_dbg(bar, ATH_DBG_<FOO>, to ath_dbg(bar, FOO

Add ATH_DBG_ to macros to shorten the uses and
reduce the line count.

Coalesce ath_dbg formats.
Add missing spaces to coalesced formats.
Add missing newline terminations to ath_dbg formats.
Align ath_dbg arguments where appropriate.
Standardize ath_dbg formats without periods.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
1b2538b2ab8f37e55b91b3cce98d2df5c126125d 07-Dec-2011 Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com> ath9k_hw: remove ATH9K_HW_CAP_CST

its not used anywhere in the current code

Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
9a66af3317be2b2ceea38f403d2f682f255de82a 15-Dec-2011 Zefir Kurtisi <zefir.kurtisi@neratec.com> ath9k_hw: add DFS testing check

In order to enable DFS upstream we want to be sure
DFS has been tested for each chipset. Push for public
documentation of the requirements we want in place and
allow for enabling each chipset through a single upstream
commit.

Signed-off-by: Zefir Kurtisi <zefir.kurtisi@neratec.com>
Signed-off-by: Luis R. Rodriguez <mcgrof@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
4f17c48e3902c823e4af68d2de9546f5b707533d 07-Dec-2011 Nikolay Martynov <mar.kolya@gmail.com> ath9k: enable ANI for ar9100 chips

Enable ANI for ar9100 since it seems to be working fine (and as a
matter of fact ANI was always performed for ar9100 since code which
was supposed to disable it didn't achieve this goal).
This patch sets config.enable_ani to default (true) value for
ar9100.

Signed-off-by: Nikolay Martynov <mar.kolya@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
4279425cef58808c0cdc616b8fff17c8308617bd 03-Dec-2011 Nikolay Martynov <mar.kolya@gmail.com> ath9k: use config.enable_ani to check if ani should be performed

Currently in ath9k code there is an attempt which is meant to
disable ANI for ar9100 and ar9340. But it doesn't really achieve
this. All it does is disable ANI init and setup (i.e. calls to
ath9k_hw_ani_setup and ath9k_hw_ani_init). Since ath9k_hw_ani_setup is
not called ah->config.ani_poll_interval is never initialized (i.e. it
is always zero) and ath_ani_calibrate always executes ANI procedures
(over uninitialized ANI parameters).
Moreover, ath_ani_calibrate is being called each 1ms because
common->ani.timer is set to zero interval because
ah->config.ani_poll_interval==0 (and thus smallest value of all
intervals). Normally it should not be called this often.
This patch changes the code so config.enable_ani is used to check if
ANI should be performed.
config.enable_ani is initialized to true by default. This patch sets
it to false for ar9100 and ar9340.

Signed-off-by: Nikolay Martynov <mar.kolya@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ba5736a5e9ac20c378ae4179e8a0ed3cc4b44351 30-Nov-2011 Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com> ath9k_hw: add default chainmask for AR9462

the default tx/rx chainmask for AR9462 is 0x3.
this patch helps to assign 0x3 rather than 0x7 for
AR9462 with the help of fix_chainmask module if something
goes wrong in reading tx/rx chain mask from OTP/EEPROM
card(though its very unlikely)

Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
6fea593d9c0e3ad8014c4080e95cb93e42c8915c 30-Nov-2011 Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com> ath9k_hw: Fix TX IQ calibration for AR9003

only for AR9485 (or) later chipsets TxIQ calibration
runs as part of AGC calibration. without this patch
TX IQ cal completion i.e. ar9003_hw_tx_iq_cal_run won't be executed
for AR9003

Reviewed-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
19686ddf638cac8c779216bb1f5e53b2666a9035 30-Nov-2011 Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com> ath9k: MCI state machine based on MCI interrupt

Cc: Wilson Tsao <wtsao@qca.qualcomm.com>
Cc: Senthil Balasubramanian <senthilb@qca.qualcomm.com>
Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
63d3296741e9f556d1edbdc34c07ce7dbe54a471 30-Nov-2011 Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com> ath9k_hw: Add MCI related changes in chip reset

here we check for BT state and if BT calibration has started,
give 25ms for BT Calibration to finish. we also take care of 2G/5G
switch and LNA transfer incase WLAN is operating in 5G. in case the BT
state is awake when we do WLAN calibration re-calibrate and we reset
the message exchange between WLAN and BT. BT is given preference when
simultaneous CAL request happens. calibration for WLAN/BT is done
assuming that the other co-existing module is in awake state, if not
we continue to do calibration while if the other module's state changes
we need to do restart the calibration handshake

Cc: Wilson Tsao <wtsao@qca.qualcomm.com>
Cc: Senthil Balasubramanian <senthilb@qca.qualcomm.com>
Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
7a9233ff6de823d14a26662697813bee82617268 30-Nov-2011 Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com> ath9k_hw: MCI related changes in set_reset_reg

Cc: Wilson Tsao <wtsao@qca.qualcomm.com>
Cc: Senthil Balasubramanian <senthilb@qca.qualcomm.com>
Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
1010911ec389fe7a342b9962877fdb88d7f04247 30-Nov-2011 Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com> ath9k_hw: MCI related changes in chip management

send halt BT GPM if the chip is in network sleep and BT state
is awake

Cc: Wilson Tsao <wtsao@qca.qualcomm.com>
Cc: Senthil Balasubramanian <senthilb@qca.qualcomm.com>
Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
a73228124bed4022d4d4c5663d9679ba2fb99c6c 26-Nov-2011 Rafael J. Wysocki <rjw@sisk.pl> ath9k: Revert change that broke AR928X on Acer Ferrari One

Revert a hunk in drivers/net/wireless/ath/ath9k/hw.c introduced by
commit 2577c6e8f2320f1d2f09be122efef5b9118efee4 (ath9k_hw: Add
support for AR946/8x chipsets) that caused a nasty regression to
appear on my Acer Ferrari One (the box locks up entirely at random
times after the wireless has been started without any way to get
debug information out of it).

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
06718f151144aa5eea97cdf2813fe7eb70e73d17 26-Nov-2011 Rafael J. Wysocki <rjw@sisk.pl> ath9k: Revert change that broke AR928X on Acer Ferrari One

Revert a hunk in drivers/net/wireless/ath/ath9k/hw.c introduced by
commit 2577c6e8f232 ("ath9k_hw: Add support for AR946/8x chipsets") that
caused a nasty regression to appear on my Acer Ferrari One (the box
locks up entirely at random times after the wireless has been started
without any way to get debug information out of it).

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
7dc181c273861c4d96991f59a4fdcda3a3eaccae 24-Oct-2011 Rajkumar Manoharan <rmanohar@qca.qualcomm.com> ath9k: Add btcoex profile management support for AR9462

AR9462 chips have the capabilities to provoide bluetooth
profile information. For non-AR9462 btcoex chips, the BT
priority traffic was identified by periodically polling
the respective registers and updated dutycycle, stomptype,
etc. As AR9462 chip offers the BT profile informations,
let us make use of that to update aggregation limit,
dutycycle, stomptype and wieghtages.

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
48ef5c427ac2cfd12c150b38263d3ebb0d989647 17-Oct-2011 Dan Carpenter <dan.carpenter@oracle.com> ath9k_hw: min_t() casts u32 to int

The code here treats very large values of "limit" as less than
MAX_POWER_RATE because of the cast to int. We should do the compare
as u32 instead.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Pavel Roskin <proski@gnu.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
93348928f2c980718434b1bc42f9d7638d665db4 25-Oct-2011 Rajkumar Manoharan <rmanohar@qca.qualcomm.com> ath9k_hw: Fix noise floor calibration timeout on fast channel change

During the fast channel change noise floor values are being loaded
twice at init_cal and after channel_change. The commit "ath9k_hw:
Improve fast channel change for AR9003 chips" overlooked it that
caused failure to load nf while doing bgscan. This patch performs noise
floor calibration after the fast and full reset.

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
9d9779e723a5d23b94abbe5bb7d1197921f6f3dd 03-Jul-2011 Paul Gortmaker <paul.gortmaker@windriver.com> drivers/net: Add module.h to drivers who were implicitly using it

The device.h header was including module.h, making it present for
most of these drivers. But we want to clean that up. Call out the
include of module.h in the modular network drivers.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
423e38e8079f8f4fe0bf66d4f9a7d61beb232aca 13-Oct-2011 Rajkumar Manoharan <rmanohar@qca.qualcomm.com> ath9k: Rename AR9480 into AR9462

Renamed to be in sync with Marketing term and to avoid
confusion with other chip names.

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
a126ff511b12bd0e7b6ca9c16ab3f6f325ba6356 13-Oct-2011 Rajkumar Manoharan <rmanohar@qca.qualcomm.com> ath9k_hw: Do fast channel change based on reusable calibration results

Support the fast channel change across band switch only when there
are available of reusable cabliration results. And also observed that
doing agc control calibration on fastcc, sometimes causing calibration
timeout. Hence changing agc control to be run only on full chip reset.

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
324c74ad64c7528a9cf243455723d5ed57238e15 13-Oct-2011 Rajkumar Manoharan <rmanohar@qca.qualcomm.com> ath9k_hw: Add radio retention support for AR9480

Supported calibrations of radio retention table (RTT) are
- DC offset
- Filter
- Peak detect

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
19787b251eccf66282d686cf2ef9a2b3033439dd 13-Oct-2011 Rajkumar Manoharan <rmanohar@qca.qualcomm.com> ath9k_hw: Support fast channel change on 5GHz for AR9003 chips

The commit "ath9k_hw: Improve fast channel change for AR9003 chips"
fixes the fast channel change issue for AR9003 chips that was
originally observed in AR9382 chip. Hence enabling fastcc support
again for 11A channel for AR9003 chips.

Cc: Paul Stewart <pstew@google.com>
Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
8ad74c4d8c5e26121f698f56595768b76d1bed81 13-Oct-2011 Rajkumar Manoharan <rmanohar@qca.qualcomm.com> ath9k_hw: Cleanup Tx calibrations for AR9003 chips

Currently Tx IQ calibration is enabled by default for all AR9003
chips. But for AR9480, the calibration status should be read from
chip after processing ini. And also the carrier leak calibration
status is checked during init cal. As the init_cal is being called
for fast channel change too, the tx_cl status only be read after
full reset. Hence moving that into process ini function.

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
77a5a6648da6b90d6ba990bf03c59993cdd5a516 13-Oct-2011 Rajkumar Manoharan <rmanohar@qca.qualcomm.com> ath9k_hw: Add support to reuse Carrier leak calibration

This patch adds support to reuse Carrier leak calibration
during fast channel change for AR9480 chips.

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
5f0c04ea1e7394c2b28fa247c1722487f9a77523 13-Oct-2011 Rajkumar Manoharan <rmanohar@qca.qualcomm.com> ath9k_hw: Improve fast channel change for AR9003 chips

In order to reduce the overall scan time, fast channel change
should be implemented properly. This patch adds fast channel
change support across band switch or channel mode switch
instead of doing full chip reset. During the fastcc, tx iqcal
measurements are preserved and will be reloaded after successful
the channel change.

This patch also addressed fast channel issue where the STA can not
see APs in higher than operating channel on 5GHz band after
the association.

Cc: Paul Stewart <pstew@google.com>
Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
eec353c5dab7f0e2b217d2793a3e75ea942e1cca 13-Oct-2011 Rajkumar Manoharan <rmanohar@qca.qualcomm.com> ath9k_hw: Fix ASPM L1 issue for AR9480

Because of not clearing Bit 14 of AR_WA, the ASPM L1 is not
enabled when entering into sleep mode. AR9480 does not need
bit 14 to be set.

Cc: stable@kernel.org
Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
cd2ea0df6892893c9a47b55f37a4d73736221a39 08-Oct-2011 Felix Fietkau <nbd@openwrt.org> ath: remove ath_regulatory::current_rd_ext

It is unused since the previous dead code that was using it had been
removed earlier.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ca2c68cc7bc80fc4504fb420df04cce99c9ee6ec 08-Oct-2011 Felix Fietkau <nbd@openwrt.org> ath9k_hw: clean up tx power handling

The code for handling various restrictions concerning regulatory limits,
antenna gain, etc. is very convoluted and duplicated across various
EEPROM parsing implementations, making it hard to review.

This patch partially cleans up the mess by unifying regulatory limit
handling in one function and simplifying handling of antenna gain.
It also removes unused transmit power scaling arrays from the EEPROM code,
which belonged to an unimplemented API that isn't supposed to be in
the driver anyway.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
76ed94be65c8bd80b565865c186dd9f24bb2f23b 30-Sep-2011 Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com> ath9k_hw: set pci_express capability true for AR9480

the AR_SREV register does not seems to indicate whether AR9480 is
pci_express capable or not though the other information like macVersion
etc can be obtained properly. this fix is essential as ASPM won't be intialized
and its related driver functionality ath9k_hw_configpcipowersave won't be
called

Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
6321eb0977b011ac61dfca36e7c69b2c4325b104 30-Sep-2011 Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com> ath9k_hw: Fix number of GPIO pins for AR9287/9300

this patch fixes the assumption of maximum number of GPIO pins present
in AR9287/AR9300. this fix is essential as we might encounter some
functionality issues involved in accessing the status of GPIO pins which
are all incorrectly assumed to be not within the range of max_num_gpio
of AR9300/AR9287 chipsets

Cc: stable@kernel.org
Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
7db062ac4bafac040afb28faf355fc2acb426413 14-Sep-2011 Rajkumar Manoharan <rmanohar@qca.qualcomm.com> ath9k_hw: Do full chip reset on 11A channels for AR9003

AR9003 seems to have issues sometimes with fast channel change
in 5GHz and this case is handled specifically for AR9280 by doing
a full reset. Let's do a full reset for 5GHz channles of AR9380
& for all channels of AR9280 pci chips.

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2577c6e8f2320f1d2f09be122efef5b9118efee4 13-Sep-2011 Senthil Balasubramanian <senthilb@qca.qualcomm.com> ath9k_hw: Add support for AR946/8x chipsets.

This patch adds support for AR946/8x chipets.

Signed-off-by: Senthil Balasubramanian <senthilb@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
82b2d334314c387ebd857b88a3d889c9a2cfec4a 03-Sep-2011 Felix Fietkau <nbd@openwrt.org> ath9k: eliminate common->{rx,tx}_chainmask

we already have ah->{rx,tx}chainmask for the same purpose

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
f84f234c6417e3d60b1cfeaf9d16c3bd1c8fe2a5 31-Aug-2011 Bill Jordan <bjordan@rajant.com> ath9k: ath9k_hw_set_txpowerlimit sets previous txpower

In commit 9c204b46c7af93e334114bea1f5eeaa6fea9ba07
(ath9k_hw: do not limit initial tx power to 20 dbm),
setting of txpower was broken.

This patch fixes it by initializing reg_pwr from the new
power limit, not the previous value.

Signed-off-by: Bill Jordan <bjordan@rajant.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
81a91d575512de74b1455d0ea213bde6f7b1e026 31-Aug-2011 Rajkumar Manoharan <rmanohar@qca.qualcomm.com> ath9k_hw: Fix rx latency of 11a mode

Rx latecy to start signal(usec) of 11a is 41 not 37 and
also corrected the rx delay in quarter rate.

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
adb5066ae2cefede1807c29ac16e1faa381416da 28-Aug-2011 Felix Fietkau <nbd@openwrt.org> ath9k_hw: do not apply the 2.4 ghz ack timeout workaround to cts

It is only used to workaround interoperability issues related to longer
delays in receiving the block ack, so it is not necessary to apply it
to the CTS exchange.
Should improve throughput slightly, especially when there are lots
of retransmissions.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
a7be039d347743c289b7280d5de82abf7bbdf1d8 26-Aug-2011 Rajkumar Manoharan <rmanohar@qca.qualcomm.com> ath9k: Fix eifs/usec timeout for AR9287 v1.3+

For AR9287 v1.3+ chips, MAC runs at 117MHz. But the initvals
IFS parameters are loaded based on 44/88MHz clockrate. So
eifs/usec from ini should not be used for AR9287 v1.3+.
The mentioned values are tested on 2 chain HT40 mode.

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
e3f2acc76dbae64d1b08455bbbaa855141d0238d 27-Aug-2011 Rajkumar Manoharan <rmanohar@qca.qualcomm.com> ath9k_hw: Set default slottime as 9us

Initialize 9us slot time as that is what is used mostly
(for non-ERP cases) and also to be in sync with initvals.

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
397e5d5b93ba99ad3dc56f1e294f487e77d2daa8 25-Aug-2011 Florian Fainelli <florian@openwrt.org> ath9k: add missing AR9340 in ath_mac_bb_names

AR9340 is not listed in ath_mac_bb_names, which leads to such a message:
ieee80211 phy0: Atheros AR???? Rev:0 mem=0xb8100000, irq=2

Signed-off-by: Florian Fainelli <florian@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
5a63ef0faf90985c847a2f924a72a22830ed1c10 25-Aug-2011 Luis R. Rodriguez <mcgrof@qca.qualcomm.com> ath9k_hw: add AR9580 support

Here are the AR9580 1.0 initvals checksums using the
Atheros initvals-tools [1]. This is useful for when
we udate the initvals again with other values. It ensures
that we match the same initvals used internally. The
tool is documented on the wiki [2].

$ ./initvals -f ar9580-1p0
0x00000000e912711f ar9580_1p0_modes_fast_clock
0x000000004a488fc7 ar9580_1p0_radio_postamble
0x00000000f3888b02 ar9580_1p0_baseband_core
0x0000000003f783bb ar9580_1p0_mac_postamble
0x0000000094be244a ar9580_1p0_low_ob_db_tx_gain_table
0x0000000094be244a ar9580_1p0_high_power_tx_gain_table
0x0000000090be244a ar9580_1p0_lowest_ob_db_tx_gain_table
0x00000000ed9eaac6 ar9580_1p0_baseband_core_txfir_coeff_japan_2484
0x00000000c4d66d1b ar9580_1p0_mac_core
0x00000000e8e9043a ar9580_1p0_mixed_ob_db_tx_gain_table
0x000000003521a300 ar9580_1p0_wo_xlna_rx_gain_table
0x00000000301fc841 ar9580_1p0_soc_postamble
0x00000000a9a06b3a ar9580_1p0_high_ob_db_tx_gain_table
0x00000000a15ccf1b ar9580_1p0_soc_preamble
0x0000000029495000 ar9580_1p0_rx_gain_table
0x0000000037ac0ee8 ar9580_1p0_radio_core
0x00000000603a1b80 ar9580_1p0_baseband_postamble
0x000000003d8b4396 ar9580_1p0_pcie_phy_clkreq_enable_L1
0x00000000398b4396 ar9580_1p0_pcie_phy_clkreq_disable_L1
0x00000000397b4396 ar9580_1p0_pcie_phy_pll_on_clkreq

[1] git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/initvals-tool.git
[2] http://wireless.kernel.org/en/users/Drivers/ath9k_hw/initvals-tool

Cc: David Quan <dquan@qca.qualcomm.com>
Cc: Kathy Giori <kgiori@qca.qualcomm.com>
Cc: Senthil Balasubramanian <senthilb@qca.qualcomm.com>
Tested-by: Florian Fainelli <florian@openwrt.org>
Signed-off-by: Luis R. Rodriguez <mcgrof@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
948990251508d8d41f5dd2c9988d415fb8fb49c7 16-Aug-2011 Alex Hacker <hacker@epn.ru> ath9k_hw: fix EIFS value to microseconds

The EIFS value read from AR_D_GBL_IFS_EIFS register in core clocks and then
written back as microsecond value.

Signed-off-by: Alex Hacker <hacker@epn.ru>
Acked-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
69ce674bfa69c55cdf32710d811fa89738eafbef 05-Aug-2011 Stanislaw Gruszka <sgruszka@redhat.com> ath9k: do btcoex ASPM disabling at initialization time

Disable ASPM in pci ->probe on upstream (device) and downstream
(PCIe port) component. According to e1000e driver authors this is
required. I did not find that requirement in PCIe spec, but it seems
to be logical for me.

This need to be fixed for CONFIG_PCIEASPM, that will be done later ...

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
f23fba49b31070dc180d0d41d0125ab80f71c09f 28-Jul-2011 Felix Fietkau <nbd@openwrt.org> ath9k_hw: calculate a much better approximation of channel noise

Currently ath9k presents the internal calibrated noise floor as channel
noise measurement, however this results in highly chip specific values
that are only useful as relative measurements but do not resemble any
real channel noise values.

In order to give a much better approximation of the real channel noise,
add the difference between the measured noise floor and the nominal
chip specific noise floor to the default minimum channel noise value,
which is currently used to calculate the signal strength from the RSSI
value. This may not be 100% accurate, but it's much better than what's
there before.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
9c204b46c7af93e334114bea1f5eeaa6fea9ba07 27-Jul-2011 Felix Fietkau <nbd@openwrt.org> ath9k_hw: do not limit initial tx power to 20 dbm

When testing for tx power, bypass the default limits.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
d4930086bdd0c08a8b3a4d66a9c702297cb74a99 29-Jul-2011 Stanislaw Gruszka <sgruszka@redhat.com> ath9k: skip ->config_pci_powersave() if PCIe port has ASPM disabled

We receive many bug reports about system hang during suspend/resume
when ath9k driver is in use. Adrian Chadd remarked that this problem
happens on systems that have ASPM disabled.

To do not hit the bug, skip doing ->config_pci_powersave magic if PCIe
downstream port device, which ath9k device is connected to, has ASPM
disabled.

Bug was introduced by:

commit 53bc7aa08b48e5cd745f986731cc7dc24eef2a9f
Author: Vivek Natarajan <vnatarajan@atheros.com>
Date: Mon Apr 5 14:48:04 2010 +0530

ath9k: Add support for newer AR9285 chipsets.

Patch should address:
https://bugzilla.kernel.org/show_bug.cgi?id=37462
https://bugzilla.kernel.org/show_bug.cgi?id=37082
https://bugzilla.redhat.com/show_bug.cgi?id=697157

however I did not receive confirmation about that, except from Camilo
Mesias, whose system stops hang regularly with this patch (but still
hangs from time to time, but this is probably some other bug).

Tested-by: Camilo Mesias <camilo@mesias.co.uk>
Cc: stable@kernel.org # 2.6.35+
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
6054069a03f77ffa686e2dfd5f07cff8ee40b72d 19-Jul-2011 Felix Fietkau <nbd@openwrt.org> ath9k_hw: validate and fix broken eeprom chainmask settings

Some devices (e.g. Ubiquiti AirRouter) ship with broken EEPROM chainmask
data, which breaks the initial calibration after a hardware reset.
To fix this, mask the eeprom chainmask with the chainmask of the chip,
and use the chip chainmask if the result is zero.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
fe2b6afbce05abe90d31651d3b92c88e0abc5ecb 09-Jul-2011 Felix Fietkau <nbd@openwrt.org> ath9k_hw: remove ar9287 v1.3+ specific hardcoded register hacks

Now that the clock rate is initialized properly and SIFS, EIFS, USEC,
slot time and ACK timeout are properly calculated by the generic code,
the 'async FIFO' register hacks are no longer necessary.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
b6ba41bb27eb9810d54e2301355ce56fd0e94a1a 09-Jul-2011 Felix Fietkau <nbd@openwrt.org> ath9k_hw: initialize more timing related registers for half/quarter channels

Initialize the the clock-to-TSF field of AR_USEC and the SIFS and EIFS time
registers based on the clock rate instead of relying on initvals.
With those changes, some of the hardcoded AR9287 1.3+ specific overrides
can be dropped.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
087b6ff682ff62c49c9a36ddfd24fc781367b1d1 09-Jul-2011 Felix Fietkau <nbd@openwrt.org> ath9k_hw: fix MAC clock rate for AR9287 v1.3+

This chip uses the async FIFO feature and runs the MAC at 117 MHz

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
906c720527b23ba8c99683ea5f9ea1f9d7749e8c 09-Jul-2011 Felix Fietkau <nbd@openwrt.org> ath9k_hw: fix MAC clock for half/quarter rate

Enabling half/quarter rate makes the MAC run at half/quarter clock speed.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
a949b1725c38775fb869d24433f13d2d104de145 09-Jul-2011 Felix Fietkau <nbd@openwrt.org> ath9k_hw: always enable 5 GHz fast clock for AR9280

All devices support this, but some disable it using an EEPROM flag
for some reason. Improves 5 GHz performance on those devices.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
999a7a88f1b062af5617fa55df317446af86a3da 21-Jun-2011 Gabor Juhos <juhosg@openwrt.org> ath9k: enable support for AR9330

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
7d95847c9b3631d31f657d8cede153b518ed9e2e 21-Jun-2011 Gabor Juhos <juhosg@openwrt.org> ath9k: add external_reset callback to ath9k_platfom_data for AR9330

The patch adds a callback to ath9k_platform_data. If the
callback is provided by the platform code, then it can be
used to hard reset the WMAC device.

The callback is required for doing a hard reset of the AR9330
chips to get them working again after a hang.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
431da56a814959753f7ad6962f0bd5fa0430e508 21-Jun-2011 Gabor Juhos <juhosg@openwrt.org> ath9k: enable antenna diversity for AR9330

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
4033bdad63a871da4c406a4a16d01b6de0a7e56e 21-Jun-2011 Gabor Juhos <juhosg@openwrt.org> ath9k: enable TX/RX data byte swap for AR9330

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
0e707a9473bf981111d09ced796e79aad4b4fbca 21-Jun-2011 Gabor Juhos <juhosg@openwrt.org> ath9k: don't enable LDPC for AR9330

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
88e641df19a8f9f36e4ca18f8cdff000be8d5ef9 21-Jun-2011 Gabor Juhos <juhosg@openwrt.org> ath9k: use different BB watchdog timeout value for AR9330

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
a5415d625d35871dd8eaf3784a402f36c028c29d 21-Jun-2011 Gabor Juhos <juhosg@openwrt.org> ath9k: add AR9330 specific PLL initialization

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
3762561aa8afb0bd9fb60d3d847961f9945f8143 21-Jun-2011 Gabor Juhos <juhosg@openwrt.org> ath9k: add MAC revision detection for AR9330

The AR9330 1.0 and 1.1 are using the same revision,
thus it is not possible to distinguish the two chips.
The platform setup code can distinguish the chips based
on the SoC revision.

Add a callback function to ath9k_platform_data in order
to allow getting the revision number from the platform code.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2c8e59379a02c5c2a478e8ce6ebc481793076792 21-Jun-2011 Gabor Juhos <juhosg@openwrt.org> ath9k: define mac version for AR9330

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
f29f5c0882bdd58c42b8176ee0b578f92589fda2 20-May-2011 Rajkumar Manoharan <rmanoharan@atheros.com> ath9k: Remove ATH9K_BEACON_PERIOD mask

Earlier beacon_interval is used to hold interval value and
some flags (ATH9K_BEACON_ENA &ATH9K_BEACON_PERIOD). So to
extract interval ATH9K_BEACON_PERIOD is used. Those flags
were completely removed. So masking beacon_interval is
not required.

Signed-off-by: Rajkumar Manoharan <rmanoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
51ac8cbb2176dc159ee910d7074c6796079c3068 20-May-2011 Rajkumar Manoharan <rmanoharan@atheros.com> ath9k_hw: disable phy restart on baseband panic caused by RXSM

While receiving unsupported rate frame rx state machine
gets into a state 0xb and if phy_restart happens in that
state, BB would go hang. If RXSM is in 0xb state after
first bb panic, ensure to disable the phy_restart.

Signed-off-by: Rajkumar Manoharan <rmanoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
5b68138e5659cbfd5df2879d17f9ba0b66477fec 17-May-2011 Sujith Manoharan <Sujith.Manoharan@atheros.com> ath9k: Drag the driver to the year 2011

The Times They Are a-Changin'.

Signed-off-by: Sujith Manoharan <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
21d2c63a2866a47030803de3db9b4e8759806095 13-May-2011 Mohammed Shafi Shajakhan <mshajakhan@atheros.com> ath9k_hw: enable Antenna diversity for AR9485

read antenna diversity and combining information from the EEPROM.
Enable antenna diversity/combining feature only when both LNA
diversity and fast diversity are supported

Cc: Gabriel Tseng <Gabriel.Tseng@Atheros.com>
Cc: Senthilkumar Balasubramanian <Senthilkumar.Balasubramanian@Atheros.com>
Tested-by: Mohammed Shafi Shajakhan <mshajakhan@atheros.com>
Signed-off-by: Mohammed Shafi Shajakhan <mshajakhan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
a6ef530f2b0bc7e871e8c2f2b2a0905eed57fead 26-Apr-2011 Vivek Natarajan <vnatarajan@atheros.com> ath9k_hw: Add support for btcoexistence in AR9300.

Signed-off-by: Vivek Natarajan <vnatarajan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
b84628eb574f04db714d34276383edbe6d8bfd96 22-Apr-2011 Senthil Balasubramanian <senthilkumar@atheros.com> ath9k: Add power save wrappers and modularize hw_pll handler

We should protect hw_pll handler with power save wrappers and
also modularize hw_pll handler properly for better readability.

Also add a debug message to track chip resets on pll hang condition.

Signed-off-by: Senthil Balasubramanian <senthilkumar@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
d1c038d620c45fbbc65bcadf813a86bca686dd31 22-Apr-2011 Senthil Balasubramanian <senthilkumar@atheros.com> ath9k_hw: Fix incorrect baseband PLL phase shift for AR9485

we should program the AR9485 baseband PLL phase shift to 6 and
a redundant setting overwrites the correct value. Remove the
incorrect and unwnated register setting.

Signed-off-by: Senthil Balasubramanian <senthilkumar@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
788f6875fcf5d2bce221fbfd2318ac48df299031 21-Apr-2011 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k: Fix bug in configuring hw timer

Hw next tigger time is configured as current_tsf + (timer_period * 10) which
is wrong, it should be current_tsf + timer_period. The wrong hw timer configuration
would cause btcoex related issues.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
0ff2b5c05d4dd84222a8e163335c5b550e2ca195 20-Apr-2011 Sujith Manoharan <Sujith.Manoharan@atheros.com> ath9k: Fix warnings from -Wunused-but-set-variable

Signed-off-by: Sujith Manoharan <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
bca04689a2260ca4da227e7f7fa35f28f40e6a00 19-Apr-2011 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k_hw: Enable AR9340 support

AR9340 is a AR9003 family built-in 2x2 wmac of ar934x SOCs. It is single band
in ar9341 SOC and dual band in ar9344/ar9342 SOCs.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
79d1d2b8a34fd36e63cc7f5267cf79217a44edcc 19-Apr-2011 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k_hw: Disable INTR_HOST1_FATAL to avoid interrupt strom with ar9430

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ecb1d385ad61001ff85407e5370a40934a1cc50b 19-Apr-2011 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k_hw: Assign macversion based on devid for built-in wmac

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2be7bfe0b454bc7c60ede777907ec817baa6196e 19-Apr-2011 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k_hw: Enable byte Tx/Rx data swap for AR9340

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
070c4d509b1edcd0b8a40177a02e4302416c56d7 19-Apr-2011 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k_hw: Don't do ani initialization for AR9340

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
0b488ac6ece598fda69b5f3348015994129c48b9 20-Apr-2011 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k_hw: Configure pll control register accordingly for AR9340

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
b99a7be47dc37c60b6524d761ecfce432de84c01 19-Apr-2011 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k_hw: Define devid and mac version for AR9340

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
3dfd7f606645279c788f48cfdfdf9565ec72c4f0 11-Apr-2011 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k: Implement integer mode for AR9485

This fixes random disconnect.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
5882da02e9d9089b7e8c739f3e774aaeeff8b7ba 08-Apr-2011 Felix Fietkau <nbd@openwrt.org> ath9k_hw: fix stopping rx DMA during resets

During PHY errors, the MAC can sometimes fail to enter an idle state on older
hardware (before AR9380) after an rx stop has been requested.

This typically shows up in the kernel log with messages like these:

ath: Could not stop RX, we could be confusing the DMA engine when we start RX up
------------[ cut here ]------------
WARNING: at drivers/net/wireless/ath/ath9k/recv.c:504 ath_stoprecv+0xcc/0xf0 [ath9k]()
Call Trace:
[<8023f0e8>] dump_stack+0x8/0x34
[<80075050>] warn_slowpath_common+0x78/0xa4
[<80075094>] warn_slowpath_null+0x18/0x24
[<80d66d60>] ath_stoprecv+0xcc/0xf0 [ath9k]
[<80d642cc>] ath_set_channel+0xbc/0x270 [ath9k]
[<80d65254>] ath_radio_disable+0x4a4/0x7fc [ath9k]

When this happens, the state that the MAC enters is easy to identify and
does not result in bogus DMA traffic, however to ensure a working state
after a channel change, the hardware should still be reset.

This patch adds detection for this specific MAC state, after which the above
warnings completely disappear in my tests.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Cc: stable@kernel.org
Cc: Kyungwan Nam <Kyungwan.Nam@Atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2638126a7c7cce87d51ae5d3bfaca9350503c0b4 24-Mar-2011 Mohammed Shafi Shajakhan <mshajakhan@atheros.com> ath9k_hw: remove ath9k_get_channel_edges

This function is nowhere used.

Signed-off-by: Mohammed Shafi Shajakhan <mshajakhan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
8f06ca2c83689f4d352a34ef1c484f40c25b41ed 01-Apr-2011 Senthil Balasubramanian <senthilkumar@atheros.com> ath9k: Fix phy info print message with AR9485 chipset.

The phy information print during driver init time doesn't show
the numeric part of the chip name properly for AR9485. This patch
addresses this issue by adding the string to the respective array.

Signed-off-by: Senthil Balasubramanian <senthilkumar@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
83860c594f65945b1a2c99e84338e1145cd34890 23-Mar-2011 Felix Fietkau <nbd@openwrt.org> ath9k_hw: remove pCap->tx_triglevel_max

It has the same purpose (and value) as ah->config.max_txtrig_level

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
340d0ea774d4ff0038a068e14340b59c5a1fce2c 23-Mar-2011 Felix Fietkau <nbd@openwrt.org> ath9k_hw: remove ATH9K_HW_CAP_ENHANCEDPM

It is not used anywhere

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
6de12a1bcef0145436e815d30a3d48b9fadb199d 23-Mar-2011 Felix Fietkau <nbd@openwrt.org> ath9k_hw: remove pCap->keycache_size

Similar to the number of tx queue, the number of keycache entries depends
on the chip and shouldn't be messed with based on EEPROM data.
Remove this field and stick to using AR_KEYTABLE_SIZE

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
c429bdcf8fe033f04830a960e07c13a01f631499 23-Mar-2011 Felix Fietkau <nbd@openwrt.org> ath9k_hw: remove pCap->reg_cap

It is not used anywhere and seems pointless

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
0db156e9648e69c34e8e88328358a26611fd71e3 23-Mar-2011 Felix Fietkau <nbd@openwrt.org> ath9k_hw: remove ah->config.ht_enable

It is only used in one place, and the device id check that it's based on
can be moved there as well.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
f4c607dc53ece4ac15afed163292425efa060775 23-Mar-2011 Felix Fietkau <nbd@openwrt.org> ath9k_hw: remove pCap->total_queues

The EEPROM contains a field that can restrict the number of hardware queues,
however this is not only useless (all the known chips contain the same
number of hardware queues), but also potentially dangerous in case of a
misprogrammed EEPROM (could trigger driver crashes), so let's just ignore
it completely.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
a9b6b2569cf107fe541381e82faa0a3c47a9a7fd 23-Mar-2011 Felix Fietkau <nbd@openwrt.org> ath9k_hw: turn a few big macros into functions

RF_BANK_SETUP, REG_WRITE_RF_ARRAY and REG_WRITE_ARRAY are way too big,
so they shouldn't be inlined at every single callsite, especially since they
can easily be turned into real functions.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ca7a4deb4a1a87dbdc6e7cab0d1022a535204226 23-Mar-2011 Felix Fietkau <nbd@openwrt.org> ath9k_hw: replace REG_READ+REG_WRITE with REG_RMW

It's easier to read and it slightly decreases code size

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
dd347f2fb2ddb20a80e9a8285252bf208ab91398 22-Mar-2011 Felix Fietkau <nbd@openwrt.org> ath9k: fix beacon timer handling issues

AP mode beacon timers in ath9k are configured in milliseconds, which breaks
when increasing ATH_BCBUF to 8 instead of 4 (due to rounding errors).
Since the hardware timers are actually configured in microseconds, it's
better to let the driver use that unit directly.

To be able to do that, the beacon interval parameter abuse for passing
certain flags needs to be removed. This is easy to do, because those flags
are completely unnecessary anyway. ATH9K_BEACON_ENA is ignored,
ATH9K_BEACON_RESET_TSF can be replaced with calling ath9k_hw_reset_tsf
from the driver directly.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
598cdd5246ea158310942699e5008ac7f687ad62 19-Mar-2011 Felix Fietkau <nbd@openwrt.org> ath9k_hw: force rx chainmask to 7 on AR9100

Most AR9100 devices already have a chainmask of 7 (three antennas), however
on the ones that don't (rx and tx chainmask set to 5), problems with IQ
mismatch calibration have been observed.
This shows up as tx queue hangs (and subsequent hardware resets) if traffic
is sent during this type of calibration.
Forcing the rx chainmask to 7 fixes the calibration issues with no apparent
negative side effects on throughput and stability.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
f171760c558946c7a2e0ee310dfb968f9d4853c6 19-Mar-2011 Felix Fietkau <nbd@openwrt.org> ath9k_hw: enable a BlockAck related fixup specific to AR9100

Fixes interop issues with aggregation in combination with multi-BSSID

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
691680b8335fa8995b190676f53e3bcef6477b4a 19-Mar-2011 Felix Fietkau <nbd@openwrt.org> ath9k: add an interface for overriding the value of specific GPIO pins

Some devices control antenna settings or other things through GPIO pins
of the wireless interface. Add a debugfs interface for changing those
and keeping them set across card resets.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
75e03512455827eb2c09e057578ae23178a93cf8 10-Mar-2011 Vivek Natarajan <vnatarajan@atheros.com> ath9k_hw: Fix PLL initialization for AR9485.

Increase the delay to make sure the initialization of pll
passes.

Signed-off-by: Vivek Natarajan <vnatarajan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
320d6c1b56de5f461c6062625b9664095f90ee95 21-Feb-2011 Sujith Manoharan <Sujith.Manoharan@atheros.com> ath9k_hw: Fix power on reset

Commit "ath9k_hw: add an extra delay when reseting AR_RTC_RESET"
added an extra udelay to the reset routine. As the required
delay is already present, remove this.

Signed-off-by: Sujith Manoharan <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
22983c301f01b297a6f85de4757108c6b0eac792 27-Jan-2011 Vivek Natarajan <vnatarajan@atheros.com> ath9k_hw: DDR_PLL and BB_PLL need correct setting.

Updates from the analog team for AR9485 chipsets to set
DDR_PLL2 and DDR_PLL3. Also program the BB_PLL ki
and kd value.

Signed-off-by: Vivek Natarajan <vnatarajan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
b141581923ab4904052174e3b4eb17cc3ce8632c 27-Jan-2011 Vivek Natarajan <vnatarajan@atheros.com> ath9k_hw: Add a function to read sqsum_dvc.

Add a function to observe the delta VC of BB_PLL.
For a good chip, the sqsum_dvc is below 2000.

Signed-off-by: Vivek Natarajan <vnatarajan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
00e0003e0969517c5a447ac3173442dfbdb0613b 26-Jan-2011 Sujith Manoharan <Sujith.Manoharan@atheros.com> ath9k_hw: Fix opmode initialization

Commit "ath9k_hw: Relocate Opmode initialization"
moved the opmode initialization before the STA_ID1 register
was programmed with defaults. This changed the original
behaviour because the re-programming code doesn't take into
account the existing value in the register. Both ath9k and ath9k_htc
were not affected by this change because the opmode is
re-initialized after every reset, when RX is started.

Revert to the original behavior, except keep it outside the
REGWRITE block. This would help remove extraneous opmode calls
in the driver core.

Signed-off-by: Sujith Manoharan <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
0a8d7cb0c8182df7a28ad719780071178c386f0f 22-Dec-2010 Senthil Balasubramanian <senthilkumar@atheros.com> ath9k_hw: read and backup AR_WA register value even before chip reset on.

We need to read and backup AR_WA register value permanently and reading
this after the chip is awakened results in this register being zeroed out.

This seems to fix the ASPM with L1 enabled issue that we have observed.
The laptop becomes very slow and hangs mostly with ASPM L1 enabled without
this fix.

Cc: Stable Kernel <stable@kernel.org>
Signed-off-by: Senthil Balasubramanian <senthilkumar@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ac45c12dfb3f727a5a7a3332ed9c11b4a5ab287e 22-Dec-2010 Senthil Balasubramanian <senthilkumar@atheros.com> ath9k_hw: Fix incorrect macversion and macrev checks

There are few places where we are checking for macversion and revsions
before RTC is powered ON. However we are reading the macversion and
revisions only after RTC is powered ON and so both macversion and
revisions are actully zero and this leads to incorrect srev checks

Incorrect srev checks can cause registers to be configured wrongly and can
cause unexpected behavior. Fixing this seems to address the ASPM issue that
we have observed. The laptop becomes very slow and hangs mostly with ASPM L1
enabled without this fix.

fix this by reading the macversion and revisisons even before we start
using them. There is no reason why should we delay reading this info
until RTC is powered on as this is just a register information.

Cc: Stable Kernel <stable@kernel.org>
Signed-off-by: Senthil Balasubramanian <senthilkumar@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
6f4810101a629b31b5427872a09ea092cfc5c4bd 21-Jan-2011 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: disabled PAPRD for AR9003

AR9003's PAPRD was enabled prematurely, and is causing some
large discrepancies on throughput and network connectivity.
For example downlink (RX) throughput against an AR9280 AP
can vary widlely from 43-73 Mbit/s while disabling this
gets AR9382 (2x2) up to around 93 Mbit/s in a 2.4 GHz HT20 setup.

Cc: stable@kernel.org
Cc: Paul Shaw <paul.shaw@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
6d50192c17d4481c0e34c1ed2ae24fd7bc16e121 04-Jan-2011 Sujith Manoharan <Sujith.Manoharan@atheros.com> ath9k_hw: Fix RX handling for USB devices

Commit "ath9k_hw: Abort rx if hw is not coming out of full sleep in reset"
uncondionally added aborting RX DMA in a HW reset, though it is a bit
unclear as to why this is needed.

Anyway, RX DMA is handled in the target for USB devices, and this would
interfere with normal operations (scanning etc.), so fix this.

Signed-off-by: Sujith Manoharan <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
6cae913d6c06557fee81aa8a181eafcc9a76516a 04-Jan-2011 Sujith Manoharan <Sujith.Manoharan@atheros.com> ath9k_hw: Fix chip test

USB devices do not require the chip test routine.

Signed-off-by: Sujith Manoharan <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
97dcec5715a381362c88d1542e52c63147764d3c 20-Dec-2010 Sujith Manoharan <Sujith.Manoharan@atheros.com> ath9k_htc: Fix warning on device removal

The commit "ath9k_hw: warn if we cannot change the power to the chip"
introduced a new warning to indicate chip powerup failures, but this
is not required for devices that have been removed. Handle USB device
removal properly by checking for unplugged status.

For PCI devices, this warning will still be seen when the card is pulled
out, not sure how to check for card removal.

Signed-off-by: Sujith Manoharan <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
55821324dc6a10fab36871534a322bad159fad79 17-Dec-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: remove baseband rfsilent support

When rfkill is enabled, ath9k_hw unnecessarily configured the baseband to
turn off based on GPIO input, however that code was hardcoded to GPIO 0
instead of ah->rfkill_gpio.
Since ath9k uses software rfkill anyway, this code is completely unnecessary
and should be removed in case anything else ever uses GPIO 0.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
45ef6a0bcc9cd8f13004789ec6decb52e1d3045c 15-Dec-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k_hw: Configure appropriate Tx power when PAPRD fails

Target Tx power available in eeprom is for PAPRD. If PAPRD
fails, paprd scale factor needs to be detected from this
target tx power.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
caabf2bf228cd6b1c6197dbb25bddb4682d30c9d 13-Dec-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: fix the slot time setting for long distance links

Testing shows that adjusting the slot time based on the coverage class
produces very high latencies and very low throughput on long distance links.

Adjusting only the ACK timeout and leaving the slot time at the regular
values - while technically not optimal for CSMA - works a lot better on
long links (tested with 10 km distance)

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
4357c6bfc83d4e8b1f18588f640be27bf4b0d0f7 13-Dec-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: initialize ah->slottime

(u32) -1 is not particularly useful as a slottime default, so even though
the ath9k_hw default should never get used, it's better to pick something
sane here.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
5f65c309be7b9eae06136a5e7df43ea08b25d3f9 12-Dec-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: remove ah->beacon_interval

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
6da5a720bab3866ba23a37841f6a61d96e498a3f 12-Dec-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: clean up SREV version checks

There's no need to have separate callbacks for pre-AR9003 vs AR9003
SREV version checks, so just merge those into one function.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
df3c8b2b10b47429d2f3fe79d00daa38a3381aad 12-Dec-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: remove antenna configuration eeprom ops and variables

AR9280 based hardware with 3 antennas and slow antenna diversity has
not been seen in the wild and ath9k does not support that form of
antenna diversity, so remove the EEPROM ops for it.
These EEPROM ops are currently only used for setting the
AR_PHY_SWITCH_COM register, which is being done in the EEPROM specific
file already.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
040b74f741b20dbf07359716d5c540356a036ade 12-Dec-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: only use the PCIe disable register write sequence for AR5416

Newer chips do not need this, and maybe these register writes could have
negative side effects on newer hardware.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
f33fdcf1b3a02fb92971a577d194ec6c579374af 09-Dec-2010 Mohammed Shafi Shajakhan <mshajakhan@atheros.com> ath9k: clean up hardware code for beacon handling

The registers TBTT_TIMER ,DMA_BEACON_ALERT ,NEXT_SWBA are need to be
configured only for AP and IBSS mode.

SWBA register is used for generating software interrupts so that beacon
frames will be created by the software.DMA beacon alert register is
to indicate the hardware to DMA the contents of beacon buffer to PCU buffer
and TBTT to start transmitting the packet buffer to the base band.
Clearly these things are not needed for station/monitor mode so
remove configuring them.

Cc: doug dahlby <ddahlby@atheros.com>
Signed-off-by: Mohammed Shafi Shajakhan <mshajakhan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
69f4aab1157d2a386e7ea4de77cc253629d1b4f2 08-Dec-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: warn if we cannot change the power to the chip

Suspend requires the device to be in fullsleep otherwise upon
resume the device becomes unresponsive. We need to ensure
that when we want the device to go to sleep it yields to
the request, otherwise we'll have a useless devices upon
resume. Warn when changing the power fails as we need
to look into these issues.

Cc: Paul Stewart <pstew@google.com>
Cc: Amod Bodas <amod.bodas@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
d09b17f73fd8f475f33d0b8311d7b5a0bed67c67 06-Dec-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k: Configure pll control for AR9485

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
47c80de62e9d6d262a829502d689a8b56add8d3d 06-Dec-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k_hw: Find the maximum number of chains that hw supports

Have it in ah->caps. This will be used during various
calibrations.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
8060e169e02fe855f5533b5ef6af1f23ae2db0c4 06-Dec-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k: Enable extended synch for AR9485 to fix L0s recovery issue

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
784ad50324ec531fa4ab22586fe305657cc6e307 06-Dec-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k_hw: Disable LDPC for AR9485

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
3050c9146b2a4c98a916192fac2867c0023ec2b1 06-Dec-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k_hw: Enable hw initialization for AR9485

Also make it a supported mac

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
226afe68fdbd1aa3680158aca0a3631cbd019626 03-Dec-2010 Joe Perches <joe@perches.com> ath: Convert ath_print to ath_dbg

Remove ath/debug.h and the includes of these files.
Coalesce long formats.
Correct a few misspellings and missing "\n"s from these logging messages.
Remove unnecessary trailing space before a newline.
Remove ARRAY_SIZE casts, use printf type %zu

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
3800276a40751539a920ef8e0537ef2e19126799 03-Dec-2010 Joe Perches <joe@perches.com> ath: Convert ath_print(.., ATH_DBG_FATAL to ath_err

So these errors are always emitted at KERN_ERR level.
Remove ARRAY_SIZE casts, use printf type %zu

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
9306990a656d9cfd8bf3586938012729c1f2ea50 01-Dec-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k: Fix bug in reading input gpio state for ar9003

The register which gives input gpio state is 0x404c for ar9003,
currently 0x4048 is wrongly used. This will disable RF and make
it unusable on some of AR9003.

Cc:stable@kernel.org
Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ea066d5a91f2610116dcd27054f749e4f07799d8 23-Nov-2010 Mohammed Shafi Shajakhan <mshajakhan@atheros.com> ath9k: Add support for Adaptive Power Management

This feature is to mitigate the problem of certain 3
stream chips that exceed the PCIe power requirements.An EEPROM flag
controls which chips have APM enabled which is basically read from
miscellaneous configuration element of the EEPROM header.

This workaround will reduce power consumption by using 2 Tx chains for
Single and Double stream rates (5 GHz only).All self generated frames
(regardless of rate) are sent on 2 chains when this feature is
enabled(Chip Limitation).

Cc: Paul Shaw <paul.shaw@atheros.com>
Signed-off-by: Mohammed Shafi Shajakhan <mshajakhan@atheros.com>
Tested-by: Mohammed Shafi Shajakhan <mshajakhan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
8f5dcb1cfb71ce832f53a4723deba72e6695078b 26-Nov-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k: Reintroduce modparam to enable btcoex

It is not ideal to enable btcoex based on subsys id as it is
not unique, they are so random. It is also a pain keeping
all of them in a table to enable btcoex for a particular
hw. Going back to the old idea.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
02d2ebb2a0aa2cae0446289c8f927067aec06079 22-Nov-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: fix A-MPDU key search issues on AR9003

Under load, a large number of frames can produce decryption errors, even when
no key cache update is being done. Performing a key search for every single
frame in an A-MPDU improves reliability.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
07b2fa5a2368accf0fe6cb16e7eca6d1150554ed 21-Nov-2010 Joe Perches <joe@perches.com> ath9k: Use static const

Using static const generally increases object text and decreases data size.
It also generally decreases overall object size.

text data bss dec hex filename
11161 56 2136 13353 3429 drivers/net/wireless/ath/ath9k/ar9003_paprd.o.new
11167 56 2136 13359 342f drivers/net/wireless/ath/ath9k/ar9003_paprd.o.old
15428 56 3056 18540 486c drivers/net/wireless/ath/ath9k/eeprom_4k.o.old
15451 56 3056 18563 4883 drivers/net/wireless/ath/ath9k/eeprom_4k.o.new
14087 56 2560 16703 413f drivers/net/wireless/ath/ath9k/eeprom_9287.o.old
14036 56 2560 16652 410c drivers/net/wireless/ath/ath9k/eeprom_9287.o.new
10041 56 2384 12481 30c1 drivers/net/wireless/ath/ath9k/ani.o.new
10088 56 2384 12528 30f0 drivers/net/wireless/ath/ath9k/ani.o.old
9316 1580 2304 13200 3390 drivers/net/wireless/ath/ath9k/htc_drv_init.o.new
9316 1580 2304 13200 3390 drivers/net/wireless/ath/ath9k/htc_drv_init.o.old
16483 56 3432 19971 4e03 drivers/net/wireless/ath/ath9k/ar9003_phy.o.new
16517 56 3432 20005 4e25 drivers/net/wireless/ath/ath9k/ar9003_phy.o.old
18221 104 2960 21285 5325 drivers/net/wireless/ath/ath9k/rc.o.old
18203 104 2960 21267 5313 drivers/net/wireless/ath/ath9k/rc.o.new
19985 56 4288 24329 5f09 drivers/net/wireless/ath/ath9k/eeprom_def.o.new
20040 56 4288 24384 5f40 drivers/net/wireless/ath/ath9k/eeprom_def.o.old
23997 56 4984 29037 716d drivers/net/wireless/ath/ath9k/ar5008_phy.o.old
23846 56 4984 28886 70d6 drivers/net/wireless/ath/ath9k/ar5008_phy.o.new
24285 56 3184 27525 6b85 drivers/net/wireless/ath/ath9k/ar9003_eeprom.o.old
24101 56 3184 27341 6acd drivers/net/wireless/ath/ath9k/ar9003_eeprom.o.new
6834 56 1032 7922 1ef2 drivers/net/wireless/ath/ath9k/ar9002_phy.o.old
6780 56 1032 7868 1ebc drivers/net/wireless/ath/ath9k/ar9002_phy.o.new
36211 64 8624 44899 af63 drivers/net/wireless/ath/ath9k/hw.o.new
36401 64 8624 45089 b021 drivers/net/wireless/ath/ath9k/hw.o.old
9281 56 1496 10833 2a51 drivers/net/wireless/ath/ath9k/ar9003_calib.o.old
9150 56 1496 10702 29ce drivers/net/wireless/ath/ath9k/ar9003_calib.o.new

Use ARRAY_SIZE instead of a magic number.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
a05b5d45049d60a06a1b12976150572304a51928 17-Nov-2010 Felix Fietkau <nbd@openwrt.org> ath9k: add support for reading eeprom from platform data on PCI devices

Some embedded boards store platform data for connected PCIe AR92xx
chips in the system flash instead of a separate EEPROM chip.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
6ee63f55c7754462a45315ac93027a1df60667c9 10-Nov-2010 Senthil Balasubramanian <senthilkumar@atheros.com> ath9k_hw: Fix low throughput issue with AR93xx

TX underruns were noticed when RTS/CTS preceded aggregates.
This issue was noticed in ar93xx family of chipsets only.
The workaround involves padding the RTS or CTS length up
to the min packet length of 256 bytes required by the
hardware by adding delimiters to the fist descriptor of
the aggregate.

Signed-off-by: Senthil Balasubramanian <senthilkumar@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
de40f316c01b1ba9535e6dc99f6a67e7655b07da 20-Oct-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: extend ath9k_hw_set_txpowerlimit to test channel txpower

ath9k_hw_set_txpowerlimit gets an extra boolean parameter that - if set -
causes the rate txpower table and the regulatory limit to be calculated
and stored, without changing hardware registers.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
744bcb42a1ff1b9200e82dd074468877e31ff161 15-Oct-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: make ath9k_hw_gettsf32 static

It is now only used in hw.c

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
48a7c3df14d0cda850337a9b3f9e667a0b12a996 08-Nov-2010 Rajkumar Manoharan <rmanoharan@atheros.com> ath9k_hw: Fix memory leak on ath9k_hw_rf_alloc_ext_banks failure

The allocated externel radio banks have to be freed in
case of ath9k_hw_rf_alloc_ext_banks failure.

Cc: stable@kernel.org
Signed-off-by: Rajkumar Manoharan <rmanoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
5f841b4130a639e5f0fbcf4a9b26045d734e4ee6 27-Oct-2010 Rajkumar Manoharan <rmanoharan@atheros.com> ath9k: Avoid HW opmode overridden on monitor mode changes

The HW opmode is blindly set to monitor type on monitor mode
change notification. This overrides the opmode when one of the
interfaces is still running as non-monitor iftype. So the monitoring
information needs to be maintained seperately.

Signed-off-by: Rajkumar Manoharan <rmanoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
d4659912b557e9f68c0ad8be14e2cafd3210dd16 14-Oct-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: remove enum wireless_mode and its users

The wireless mode bitfield was only used to detect 2.4 and 5 GHz support,
which can be simplified by using ATH9K_HW_CAP_* capabilities.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
dfdac8ac033c9ad048a5c68563bd41bda6c5e60b 08-Oct-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: store the clock rate in common data on channel changes

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
093115b7fd641f03d89404252044c976928764cb 04-Oct-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: clean up ANI state handling

ANI state is kept per channel, so instead of keeping an array of ANI states
with an arbitrary size of 255, move the ANI state into the channel struct.

Move some config settings that are not per-channel out of
the per-channel struct to save some memory.

With those changes, ath9k_ani_restart_old and ath9k_ani_restart_new can
be merged into a single function.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
435c1610f46dc4d86a6633adb037b18109e6ffdc 05-Oct-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: clean up register write buffering

Throughout the code, DISABLE_REGWRITE_BUFFER is always called right after
REGWRITE_BUFFER_FLUSH. Since that's unlikely to change any time soon, that
makes keeping those ops separate rather pointless, as it only increases
code size and line number counts.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
d9891c7804f27c5b0ea9eb51f42bf473b24338a0 29-Sep-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: keep calibrated noise floor values per channel

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
a42acef0dd3548ffda03d245d41b95250354017e 22-Sep-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: simplify revision checks for AR9287

Since AR9287 v1.0 was never sold (and the initvals removed), its revision
checks can be simplified similar to AR9280

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
e17f83eafd37129f9e09425136e59bc4333bdb9c 22-Sep-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: simplify revision checks for AR9285

Since AR9285 v1.0 and v1.1 were never sold (and the initvals removed),
its revision checks can be simplified similar to AR9280

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
7a37081e2e25e58701b17c41579fd06bc353b392 22-Sep-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: simplify revision checks for AR9280

Since AR9280 v1.0 was never sold (and the initvals removed), v1.0 specific
revision checks can be removed and the 'v2.0 or later' check can be
simplified to a check for AR9280 or later.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ce2220d1da0bad9583af38a03ad508968d554c0f 17-Sep-2010 Bruno Randolf <br1@einfach.org> ath/ath5k/ath9k: Fix crypto capabilities merge issue

Fixing up a merge issue / concurrent development:

Remove unneeded ath_crypt_caps flags, as per "ath9k_hw: remove useless hw
capability flags" (364734fafbba0c3133e482db78149b9a823ae7a5), but set the
AESCCM flag for ath9k. common ath code still needs a flag for this because
there is ath5k hardware which can't do AES in hardware.

Signed-off-by: Bruno Randolf <br1@einfach.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
040e539e8e8d5585e1c3d7d15fa7215d3a691258 08-Sep-2010 Bruno Randolf <br1@einfach.org> ath9k: Use common ath key management functions

Use key management functions which have been moved to ath/key.c and remove
ath9k copies of these functions and other now unused definitions.

Signed-off-by: Bruno Randolf <br1@einfach.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
364734fafbba0c3133e482db78149b9a823ae7a5 14-Sep-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: remove useless hw capability flags

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
58d7e0f37cfc5b4f473d437024a03d874e5969a3 08-Sep-2010 Rajkumar Manoharan <rmanoharan@atheros.com> ath9k_hw: Support fastcc for AR7010

To reduce scan time, enable fastcc for AR7010

(fastcc == fast channel change -- JWL)

Signed-off-by: Rajkumar Manoharan <rmanoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
c2ba33424600e742f4d44ba2237024e6322a00fa 03-Sep-2010 Rajkumar Manoharan <rmanoharan@atheros.com> ath9k_hw: Restore ANI registers to default during partial reset for AR9271

For AR9271 chips, if partial reset is done while scanning, the cycpwrThr1
will be set to maximum. This causes the degrade in DL throughput.
So restore the ANI registers to default during the partial reset.

Signed-off-by: Rajkumar Manoharan <rmanoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
754dc53641e0038cd4fd3574b1f5b3c7239f73ce 02-Sep-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k_hw: Add capability flag for Antenna diversity and combining feature

This is enabled only for ar9285.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
20bd2a0952d01ba82a99b3f22d46e3832c255529 31-Jul-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: clean up per-channel calibration data

The noise floor history buffer is currently not kept per channel, which
can lead to problems when changing channels from a clean channel to a
noisy one. Also when switching from HT20 to HT40, the noise floor
history buffer is full of measurements, but none of them contain data
for the extension channel, which it needs quite a bit of time to recover
from.

This patch puts all the per-channel calibration data into a single data
structure, and gives the the driver control over whether that is used
per-channel or even not used for some channels.

For ath9k_htc, I decided to keep this per-channel in order to avoid
creating regressions.

For ath9k, the data is kept only for the operating channel, which saves
some space. ath9k_hw takes care of wiping old data when the operating
channel or its channel flags change.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
00c86590e36bd42574821b43b5124d75f30df9dd 30-Jul-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: clean up and fix initial noise floor calibration

On AR9003 the initial noise floor calibration is currently triggered
at the end of the reset without allowing the hardware to update the
baseband settings. This could potentially make scans in noisy
environments a bit more unreliable, so use the same calibration
sequence that is used on AR9002.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Acked-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
4c85ab11ca56da1aa59b58c80cc6a356515cc645 28-Jul-2010 John W. Linville <linville@tuxdriver.com> ath9k: enable serialize_regmode for non-PCIE AR9160

https://bugzilla.kernel.org/show_bug.cgi?id=16476

Signed-off-by: John W. Linville <linville@tuxdriver.com>
Acked-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Cc: stable@kernel.org
9cc2f3e881dcda5466c55ffe8dd0a9d1433469cb 11-Jul-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: prevent a fast channel change after a rx DMA stuck issue

If the receive path gets stuck, a full hardware reset is necessary to
recover from it. If this happens during a scan, the whole scan might fail,
as each channel change bypasses the full reset sequence.
Fix this by resetting the fast channel change flag if stopping the
receive path fails.

This will reduce the number of error messages that look like this:
ath: DMA failed to stop in 10 ms AR_CR=0x00000024 AR_DIAG_SW=0x40000020

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Cc: stable@kernel.org
Signed-off-by: John W. Linville <linville@tuxdriver.com>
f2552e28375cb34073a2f940ee9a8439c37d9ec2 02-Jul-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: sanitize noise floor values properly on all chips

This refactors the noise floor range checks to make them generic,
and adds proper ranges for each supported chip type.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
88c1f4f6dffe66e2fed8e7e3276e091ee850bed0 30-Jun-2010 Sujith <Sujith.Manoharan@atheros.com> ath9k_htc: Add LED support for AR7010

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
f860d526eb2939a1c37128900b5af2b6f3ff7f20 30-Jun-2010 Felix Fietkau <nbd@openwrt.org> ath9k: fix TSF after reset on AR913x

When issuing a reset, the TSF value is lost in the hardware because of
the 913x specific cold reset. As with some AR9280 cards, the TSF needs
to be preserved in software here.

Additionally, there's an issue that frequently prevents a successful
TSF write directly after the chip reset. In this case, repeating the
TSF write after the initval-writes usually works.

This patch detects failed TSF writes and recovers from them, taking
into account the delay caused by the initval writes.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Reported-by: Björn Smedman <bjorn.smedman@venatech.se>
Cc: stable@kernel.org
Signed-off-by: John W. Linville <linville@tuxdriver.com>
f35376a44f7655bcb9a9abea1fbffcde1b80be55 29-Jun-2010 John W. Linville <linville@tuxdriver.com> ath9k: make ath9k_hw_keysetmac static

Reported-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
99aeed9cde404365f9f72da25518068cbbc40b89 29-Jun-2010 John W. Linville <linville@tuxdriver.com> ath9k: remove unused function ath9k_hw_keyisvalid

Reported-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ee031112d9eef5508f765ebc90ab488e01db002e 22-Jun-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: add an extra delay when reseting AR_RTC_RESET

Without this we could start trying to work with the device without
it being fully functional yet and loose some packets upon resume.

Cc: Aeolus Yang <aeolus.yang@atheros.com>
Cc: Madhan Jaganathan <madhan.jaganathan@atheros.com>
signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>

Signed-off-by: John W. Linville <linville@tuxdriver.com>
6a0ec30ad4acae63a81526ca8c157f718904993b 22-Jun-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: add pcieSerDesWrite to disable SERDES ASPM tweaks

This can be useful during testing of new ASPM tweaks which often
have to be done through the PCI Serializer-Deserializer (SERDES).

Cc: Aeolus Yang <aeolus.yang@atheros.com>
Cc: Madhan Jaganathan <madhan.jaganathan@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
653fe371226fcbcc41b4662d35d2207648a6075d 22-Jun-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: move LowPower array writes to ar9003_hw_configpcipowersave()

The LowPower array writes disables the PLL when ASPM is enabled.
The host driver makes quite a few calls to ath9k_hw_configpcipowersave()
and these same calls also need to ensure the PLL is off when they issue
it.

Cc: Aeolus Yang <aeolus.yang@atheros.com>
Cc: Madhan Jaganathan <madhan.jaganathan@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
9a658d2b5c222b62919ab47b11c907c731ac180a 22-Jun-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: fix ASPM setting for AR9003

The AR_WA register should not be read when in sleep state so
add a variable we can stash its value into for when we need
to set it. Additionally the AR_WA_D3_TO_L1_DISABLE_REAL
(bit 16) needs to be removed.

Cc: Aeolus Yang <aeolus.yang@atheros.com>
Cc: Madhan Jaganathan <madhan.jaganathan@atheros.com>
signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>

Signed-off-by: John W. Linville <linville@tuxdriver.com>
7b9a4b001971c89f35d55180867753a612d17458 12-Jun-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: remove ATH9K_CAP_DS

This capability check is no longer used, so it can be removed along with
the now-obsolete ath9k_hw_getcapability function.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
16f2411fcb76253c690e3420fbcf3f0208eeaa51 12-Jun-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: remove ATH9K_CAP_MCAST_KEYSRCH

The driver always sets this to enabled, but this can be simplified with
a small change to ah->sta_id1_defaults instead.
This change also removes the now-obsolete ath9k_hw_setcapability function.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
f32a488463d1b2048a7797a5b618be65a1dfabad 12-Jun-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: remove ATH9K_CAP_TKIP_SPLIT

This is only used as a workaround for an issue in one specific hw revision.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
71fca6e983ebbf70b2d1089c66f0ec945ae16dc0 12-Jun-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: remove ATH9K_CAP_TKIP_MIC

TKIP MIC support is always enabled anyway.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
9cc3271faa3967754ca1d6ac982e91e347c55489 12-Jun-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: remove ATH9K_CAP_TXPOW

replace calls that read this capability with accesses to ath9k_hw's
regulatory data.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
716f7fc5b83ec04c53274a4810a723747e12f910 12-Jun-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: remove ATH9K_CAP_CIPHER

All of the ciphers that are tested for are always supported

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
4935250ac14d9aac7d98411bdead2e33a9fadeac 12-Jun-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: add support for parsing PA predistortion related EEPROM fields

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
96d159d03c5b849fa39dc7305e04ebf374085e4a 12-Jun-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: remove a useless function for setting the mac address

ath9k_hw_setmac() only copies the mac address it is called with into
common->macaddr, yet in all call sites, the supplied mac address pointer
is already common->macaddr.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
a6d2055b02dde1067075795274672720baadd3ca 12-Jun-2010 Felix Fietkau <nbd@openwrt.org> ath9k: fix extending the rx timestamp with the hardware TSF

AR5416 and all newer chipsets use a 32 bit rx timestamp, so there
is no need to keep the 15 bit timestamp extending logic around.

This patch removes ath9k_hw_extend_tsf (replaced by a call to
ath9k_hw_gettsf64), and reduces the frequency of TSF reads, which
can improve performance in some cases.

This change also has the side effect of making rx timestamps
more accurate.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
03c725183bfa1328995f28e0d0e9c49e1e6ae730 12-Jun-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: enable ANI for AR9003

AR9003 has been tested with the new ANI implementation
and so ANI can now be enabled for that family.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
e36b27aff1b10c81c53990b28da4ab6ab0ed0761 12-Jun-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: add new ANI implementation for AR9003

This adds support for ANI for AR9003. The implementation for
ANI for AR9003 is slightly different than the one used for
the older chipset families. It can technically be used for
the older families as well but this is not yet fully tested
so we only enable the new ANI for the AR5008, AR9001 and AR9002
families with a module parameter, force_new_ani.

The old ANI implementation is left intact.

Details of the new ANI implemention:

* ANI adjustment logic is now table driven so that each ANI level
setting is parameterized. This makes adjustments much more
deterministic than the old procedure based logic and allows
adjustments to be made incrementally to several parameters per
level.

* ANI register settings are now relative to INI values; so ANI
param zero level == INI value. Appropriate floor and ceiling
values are obeyed when adjustments are combined with INI values.

* ANI processing is done once per second rather that every 100ms.
The poll interval is now a set upon hardware initialization and
can be picked up by the core driver.

* OFDM error and CCK error processing are made in a round robin
fashion rather than allowing all OFDM adjustments to be made
before CCK adjustments.

* ANI adjusts MRC CCK off in the presence of high CCK errors

* When adjusting spur immunity (SI) and OFDM weak signal detection,
ANI now sets register values for the extension channel too

* When adjusting FIR step (ST), ANI now sets register for FIR step
low too

* FIR step adjustments now allow for an extra level of immunity for
extremely noisy environments

* The old Noise immunity setting (NI), which changes coarse low, size
desired, etc have been removed. Changing these settings could affect
up RIFS RX as well.

* CCK weak signal adjustment is no longer used

* ANI no longer enables phy error interrupts; in all cases phy hw
counting registers are used instead

* The phy error count (overflow) interrupts are also no longer used
for ANI adjustments. All ANI adjustments are made via the polling
routine and no adjustments are possible in the ISR context anymore

* A history settings buffer is now correctly used for each channel;
channel settings are initialized with the defaults but later
changes are restored when returning back to that channel

* When scanning, ANI is disabled settings are returned to (INI) defaults.

* OFDM phy error thresholds are now 400 & 1000 (errors/second units) for
low/high water marks, providing increased stability/hysteresis when
changing levels.

* Similarly CCK phy error thresholds are now 300 & 600 (errors/second)

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
7337725609d5b9ef053011d32727cbe7e8b33563 12-Jun-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: move clock definitions from hw.c to hw.h

These will be used by the ANI code next.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
cbba8cd101c1230284ee46629c841481f7c34b68 02-Jun-2010 Sujith <Sujith.Manoharan@atheros.com> ath9k_hw: Configure byte swap for non AR9271 chips

This patch fixes programming the byte swap registers
for chipsets other than AR9271. This is needed for
AR7010.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
e9141f71f4734584bc9704e1266090abe98e1859 01-Jun-2010 Sujith <Sujith.Manoharan@atheros.com> ath9k_hw: Fix async fifo for AR9287

Async fifo is now enabled only for versions 1.3 and above.
Enable it in the appropriate place, in the reset routine,
instead of process_ini().

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
1d0bb42d5eee20bd70f237d0a32cfe3b079849e2 25-May-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: add multicast key search support

If a MAC address for a key table entry is flagged with the
multicast bit (0x01), indicate to the hardware that multicast
lookup instead of unicast lookup should be used. The multicast
bit itself never makes it to the actual keytable entry register,
as it is shifted out.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
c5395b67437b47c4a4c0686d3db99be9327ef67e 19-May-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: Enable TX IQ calibration on AR9003

To enable it we now disable and re-enable the PHY chips
after TX IQ calibration.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
d5d1154ffdc87b618518629fce44d51834df0f2e 18-May-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k_hw: Enable auto sleep for ar9003

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
b4dec5e8f5c02f75d8c08dd377193f73b553bfe2 16-May-2010 Sujith <Sujith.Manoharan@atheros.com> ath9k_htc: Enable SGI in HT20 for AR9271

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
6473d24d5b6b76bb5fd16914709a619a00c44d28 14-May-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k: Enable Short GI in 20 Mhz for ar9287 and later chips

This patch enables short GI rx at all rates and tx at mcs15
for 20 Mhz channel width also.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
aea702b70ae0964c16e17944e4a5ce2c2b038ced 13-May-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: add support for the AR9003 baseband watchdog

The baseband watchdog will monitor blocks of the baseband
through timers and will issue an interrupt when things are
detected to be stalled. It is only available on the AR9003
family.

Cc: Sam Ng <sam.ng@atheros.com>
Cc: Paul Shaw <paul.shaw@atheros.com>
Cc: Don Breslin <don.breslin@atheros.com>
Cc: Cliff Holden <cliff.holden@atheros.com
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
5efa3a6bf4dd1674920d7419cbde9d731cdb61f1 08-May-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: enable PCIe low power mode for AR9003

Cc: Paul Shaw <paul.shaw@atheros.com>
Cc: Don Breslin <don.breslin@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
6b42e8d03bef975085c0397806d00fbd1df67eb8 26-Apr-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: fix fast clock handling for 5GHz channels

Combine multiple checks that were supposed to check for the same
conditions, but didn't. Always enable fast PLL clock on AR9280 2.0

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
e55537240f97635f9a7c42fac224ff80fa637624 26-Apr-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k_hw: Fix usec to hw clock conversion in 5Ghz for ar9003

Fast clock operation (44Mhz) is enabled for 5Ghz in ar9003, so
take care of the conversion from usec to hw clock.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
b360a884834a83ede845733cf344a29eb10dd2e3 26-Apr-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: disable TX IQ calibration for AR9003

Disable TX IQ calibration, it was prematurely enabled in
previous versions.

Cc: Paul Shaw <Paul.Shaw@Atheros.com>
Cc: Thomas Hammel <Thomas.Hammel@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
51f139d567574e6a9b5c8aaddb8ff3a240cf8e52 23-Apr-2010 Sujith <Sujith.Manoharan@atheros.com> ath9k_hw: Remove pointless ANI deinit

There is no reason to disable the PHY Error / MIB counters
when the module is being unloaded.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
c9c99e5e440013c420fd8ec41ee83e89909d5186 19-Apr-2010 Felix Fietkau <nbd@openwrt.org> ath9k: check for specific rx stuck conditions and recover from them

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
7d0d0df0eca695c83a08dc386824a9d1d7c526a4 16-Apr-2010 Sujith <Sujith.Manoharan@atheros.com> ath9k_hw: Use buffered register writes

This patch adds macros at certain places
which could be optimized for multiple register writes.

The performance of ath9k_htc improves considerably,
especially reducing the latency involved in a scan run.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
6819d57f07440a8f9540967d9212a70e9c98eceb 16-Apr-2010 Sujith <Sujith.Manoharan@atheros.com> ath9k_hw: Relocate Opmode initialization

Programming the opmode in the HW can be done
before the assoc_id and STA_ID registers are
setup. This helps ath9k_htc when multiple register
writes are used.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
1c0fc65e6de4e941ff483df445e721d6edb1f84b 16-Apr-2010 Benoit Papillault <benoit.papillault@free.fr> ath5k/ath9k: Fix 64 bits TSF reads

According to tests, both TSF lower and upper registers kept counting, so
the higher part could have been updated after the lower part has been
read, as shown in the following log where the upper part is read first
and the lower part next.

tsf = {00000003-fffffffd}
tsf = {00000003-00000001}
tsf = {00000004-0000000b}

This patch corrects this by checking that the upper part has not been
changed while the lower part was read. It has been tested in an IBSS
network where artifical IBSS merges have been done in order to trigger
hundreds of rollover for the TSF lower part.

It follows the logic mentionned by Derek, with only 2 register reads
needed at each additional steps instead of 3 (the minimum number of
register reads is still 3).

Signed-off-by: Benoit Papillault <benoit.papillault@free.fr>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
9b9cc61c46822ced22bc09d9aaa9f0f1859719cb 15-Apr-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k_hw: Abort rx if hw is not coming out of full sleep in reset

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ce01805a226328228a885b4a6e4b632b4e73f8ee 15-Apr-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: add LDPC support for AR9003

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
5088c2f1a2475546d9a79b515bde6d65b8681e51 15-Apr-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k: Initialize and configure tx status for EDMA

Also add a function to clean up tx status ring.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
b622a720b45def8dce816244a83b82992da4fe20 15-Apr-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: move AR9002 mac ops to its own file

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
744d402580f959072f6b805a98745837f185c8e0 15-Apr-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k_hw: Add function to configure tx status ring buffer

Also reset tx status ring suring chip reset.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
d8903a5361817bd96ceed212ad27a380e7ef4d8e 15-Apr-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k: Load SW filtered NF values and start NF cal during full reset for AR9003

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
6c94fdc97a27bd681afeaf05d9101b3f9a06f986 15-Apr-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: skip WEP aggregation enable code for AR9003

The AR9002 hardware code enables aggregation for WEP but
mac80211 doesn't enable aggregation with WEP, and the AR9003
code family does not need this so skip it for now for AR9003
but leave the code and annotate we should eventually consider
how to remove this in consideration for the HAL unification
goals.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
78ec26778803abd4ebb105bb19c729100c829837 15-Apr-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: skip asynch fifo enablement to AR9003

The asynch fifo code is specific to >= AR9287 so stuff it
into the AR9002 hardware family code and skip it for AR9003
cards.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
57b32227cd7f1f81f4143d8bc82a5ffe37ab4df9 15-Apr-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: Update ath9k_hw_set_dma for AR9300

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ec83903e67f9d1e8398568c77dc4fdd333531e96 15-Apr-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: add the AR9300 SREV hw name print

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
7f62a136910f70d9b412f48f764321ff20ce6f38 15-Apr-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k_hw: Configure Tx interrupt mitigation timer

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ebd5a14a450e31611696dfe96781a3b8915d835c 15-Apr-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: move the RF claim stuff to AR9002 hardware family

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
57b98384e5450996300d77ece61739b58325a84f 15-Apr-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: move AR9280 PCI EEPROM fix to eeprom_def.c

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
6c84ce08aaf5995afc7ff7b4c54069c2431fca87 15-Apr-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k_hw: Fill get_isr() for AR9003

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
49101676b2f1a66e0043509423e876414c73b5aa 15-Apr-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: restore mac address reading logic

Once upon a time the AR_EEPROM_MAC macro was added to let us
add a random attribute to the three 4-bytes of MAC addresses
entries we read from the EEPROM. This was good while a random
high-enough value was used which did not conflict with any
of the already existing enum eeprom_param values. With AR9003
support the enums overlap and it means we either increment
the random offset or just restore the reading logic to match
what the HAL has. I choose to do the later to synchronize
the logic on both code bases.

This should fix reading the MAC address from the EEPROM
on AR9003 hardware.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
668602404d7398d841681c5e23fd8a9a45e4bb30 15-Apr-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k_hw: Initialize interrupt mask for AR9003

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
55e82df4be45305bfb5e7ecb877a349ed4da8ed2 15-Apr-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k_hw: Abstract the routine which returns interrupt status

Also move interrupt related code to mac.c

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
991312d88cb8844e3e1a1e57a72823802da36fcd 15-Apr-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: move TX/RX gain INI stuff to its own hardware family code

The AR9003 TX/RX gain is currently initialized with the other
components, so for now AR9003 does not implment this callback,
after hardware bring up we can test moving the TX/RX gain there
as well and if it works well move them to its own callback as
well.

Since all INI stuff is now moved out hw.c no longer needs to
include and touch any original INI headers/structs.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
d8f492b7d9a4c1cfdac69ba18a81acbd86d1dc6e 15-Apr-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: move the cck channel 14 INI to the AR9002 hw code

This is specific to the AR9002 family only.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
b3950e6a52b1d0279787ef44ba1efac2f3414260 15-Apr-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: split the generic hardware code by hardware family

Move out the generic hardware family code out into their own
files, we have one for AR5008, AR9001, and AR9002 family (ar9002_hw.c)
and another file for the new AR9003 hardware family (ar9003_hw.c).

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
204729fd182bd56180323d9293c31038dde32995 15-Apr-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: add the config_pci_powersave AR9003 callback

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
795f5e2ca672727a96bacf97075976cfe1249fcf 15-Apr-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: split calib code by hardware families

Calibration code touches phy registers and since these
change the calibration code needs to be abstracted.

Noise floor calibration is the only thing remaining but
since the remaining calls only touch the AR_PHY_AGC_CONTROL
register we'll just define that register conditionally, that
will be done separately. The goal is to remove the dependency
of ar9002_phy.h on calib.c

This also adds stubs to be filled for AR9003 calibration code.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
0df13da4555320f6dc9b901fd5f22cf54065c708 15-Apr-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: move the cal AR9100 calibration settings

The calibration settings should go into the respective
hardware family AR9002 calibration settings callback,
ar9002_hw_init_cal_settings().

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
939ad86de538d23533d2f9dd43f80725789d43ba 15-Apr-2010 Senthil Balasubramanian <senthilkumar@atheros.com> ath9k_hw: the eep_map is used only for AR9280 PCI card ini fixup

We can reorganize the code in such a way that eep_map can be removed,
which makes the code more clearer.

Signed-off-by: Senthil Balasubramanian <senthilkumar@atheros.com>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
641d99217f507024720d21f0a76a8075824fcc46 15-Apr-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: Split out the function for reading the noise floor

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
162c3be3780dcb241ce0c9d49626c6cfb90f9f61 15-Apr-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k_hw: Define tx control struct for AR9003

Store appropriate desc length which will be used by the
ath9k module while duplicating tx desc.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
13ce3e997c8a63269e49f1b6c239035d79bb18e8 15-Apr-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: add initvals for the AR9003 hardware family

The AR9003 hardware family now initializes hardware by block
components and into stages: pre, core and init.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
af01c04e21816da01454e1d580891f394465b77e 15-Apr-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: split initvals.h by hardware family

The initvals.h file is over 7000 lines now, so instead of adding
AR9003 initvals to it instead lets split the current initvals.h by
hardware family: AR5008, AR9001, AR9002

The AR9003 family will have its own initval file later.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
84e2169b0fead5d87de0a29f17a06fba904bc46b 15-Apr-2010 Senthil Balasubramanian <senthilkumar@atheros.com> ath9k_hw: prevent reset control register zeroing on AR9003 reset

Also, no need for the udelay(2) on AR9003 hardware.

Signed-off-by: Senthil Balasubramanian <senthilkumar@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
1f3f06184006dff1ec439c56dcee9a99ed93e985 15-Apr-2010 Senthil Balasubramanian <senthilkumar@atheros.com> ath9k_hw: update the chip tests for AR9003

The AR9003 family requires a change on the loop and can also skip
testing the PHY timing registers. This chip test can now be used
by all Atheros hardware families, including legacy. We can
eventually move this out to the generic ath module.

Signed-off-by: Senthil Balasubramanian <senthilkumar@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ae3bb6d4628dae7ead588263177a0674221fea78 15-Apr-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k_hw: Fill rx_enable() for the AR9003 hardware family

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
cee1f625bfcabeed39138547be21d8995357f8e1 15-Apr-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k_hw: Add abstraction for rx enable

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ceb2644576bcb9fe7b79614512c1efe2bf3c307c 15-Apr-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k_hw: Fill few hw cap for edma

HP & LP queue depth and rx status length.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
1adf02ffad449ea955e21393e05b0e45ef2c16a4 15-Apr-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k_hw: Add hw cap flag for EDMA for the AR9003 family

AR9003 supports extended DMA (EDMA), this comes with some
bells and whistles on top of the legacy DMA that we are used
to. Mark AR9003 and later chips EDMA capable.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
31a0bd3c7564ec79cf86a3eb9f9aaa3c47099d9b 15-Apr-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: disable ANI for AR9003

ANI is still being debugged on AR9003 by our systems team
so it should not yet be enabled yet. When ANI will be
enabled all ANI functionality is expected to be enabled
so fill the ANI functionality to all for AR9003 for now
as well.

Cc: Enis Akay <Enis.Akay@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
61accab9b5cfc2a7f42c88f30656d9f1771400d3 15-Apr-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: add the AR9003 ar9003_hw_macversion_supported()

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
bab1f62e214f19d2edb1b5508ad5ba1b0a8a22ec 15-Apr-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: move init config and default after chip is up

This allows us to add SREV checks on these helpers.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
8525f2801df14b6c4ae6a96127e47d646be5304c 15-Apr-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: Add AR9003 PHY support

This add stubs for PHY support for the AR9003 hardware family.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
db3cc53a2faea2da5730304af06a77d343f314a5 15-Apr-2010 Senthil Balasubramanian <senthilkumar@atheros.com> ath9k_hw: Add the PCI IDs for AR9300 and fill up the pci_id_tables

Also, clean up and reorganize the AR9287 macro to have better
ordering. We won't add the PCI ID to the supported device list
until we have some functional code for it.

Signed-off-by: Senthil Balasubramanian <senthilkumar@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
647739645bea4a5628f9e4eaf8022dcc5875c535 15-Apr-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: add a private callback for PLL control computation

The PLL control computation used to program the AR_RTC_PLL_CONTROL
register varies between our harware so just add a private callback for it.
AR9003 will use its own callback.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
bbd79af5639bd51af1119e5df866568063a1b011 15-Apr-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: add some comments for ath9k_set_power_network_sleep()

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
e041228fed0c9fe8b5c3b8e0ca66b08178b26a87 15-Apr-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: skip PLL initialization on AR9003 on Power-On-Reset

This is not required for the AR9003 family.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
8fe6536850ae49609704a263cbc7542133536922 15-Apr-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: Move some RF ops to the private callbacks

The PHY split is easier done in a few steps. First move
the RF ops to the private ops and rename them accordingly.
We split PHY stuff up first for the AR5008 and AR9002
families. There are some callbacks that AR9002 share
with the AR5008 familiy so we set those first, if AR9002
has some different callbacks it will override them upon
hardware init.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
aed1baf1ab10f4b6bd40952a9deb791dbba48f3a 15-Apr-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: remove wrapper ath9k_hw_write_regs()

This is used only once by ath9k_hw_process_ini() to
write an array of phy registers through REG_WRITE_ARRAY(),
but we already call REG_WRITE_ARRAY() multiple times
on the same caller so just remove this pointless wrapper.
We'll eventually just move the ath9k_hw_process_ini()
caller as an callback to abstract away between different
hardware families.

Although this change is subtle I should note that this
does change the delay pattern on writing the next series
of registers. REG_WRITE_ARRAY() uses a counter for each
register write and does a udelay(1) every 64 writes. By
removing this call it means that the counter is processed
for all the iniBB_RfGain registers and is incremented
on ath9k_hw_process_ini(), before this the after the call
ath9k_hw_write_regs() was made the register counter was
kept at the same index number prior to the call.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
42d5bc3faabcc9d7ea1cfe9237d71ef7dce386e3 15-Apr-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: AR9003 does not have AR_RC_AHB skip its setting

AR9003 does not have a reset control for AHB.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
783dfca1fceb0140e629d671b67e4be7e8dc7f8d 15-Apr-2010 Felix Fietkau <nbd@openwrt.org> ath9k_hw: add support for GPIO differences on AR9003

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
d70357d56942fa587e39505547cb69e10a8d59a0 15-Apr-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: start building an abstraction layer for hardware routines

ath9k supports the AR5008, AR9001 and AR9002 family of Atheros
chipsets, all 802.11n. The new breed of 802.11n chips, the
AR9003 family will be supported as well soon. To help with its
support we're going to add a few callbacks for hardware routines
which differ considerably instead of adding branch checks for
the revision at runtime.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2eb46d9bda44b3f85727fee6865d9b25725e6bf9 07-Apr-2010 Pavel Roskin <proski@gnu.org> ath9k: simplify AR9220 fixup code for AR_AN_TOP2 register

Don't modify ah->iniModes, it's supposed to be constant. Instead, apply
the fixup when the data is written to the registers.

Change ath9k_hw_init_eeprom_fix() to only determine whether the fixup is
needed.

This allows similteneous support for AR9220 cards that need AR_AN_TOP2
fixup (such as Ubiquiti SR71-12) and those that don't need it (D-Link
DWA-552 rev A2).

Signed-off-by: Pavel Roskin <proski@gnu.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
bde748a40d4d5a9915def6772e208848c105e616 05-Apr-2010 Vivek Natarajan <vnatarajan@atheros.com> ath9k_htc: Add support for power save.

Signed-off-by: Vivek Natarajan <vnatarajan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
53bc7aa08b48e5cd745f986731cc7dc24eef2a9f 05-Apr-2010 Vivek Natarajan <vnatarajan@atheros.com> ath9k: Add support for newer AR9285 chipsets.

This patch adds support for a modified newer version of AR9285
chipsets.

Signed-off-by: Vivek Natarajan <vnatarajan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ffa49f8209ef77ebf2cce0bbc129ca40064b8fb6 01-Apr-2010 Sujith <Sujith.Manoharan@atheros.com> ath9k_hw: Don't check devid for ath9k_htc

For USB devices, this check is invalid.
Remove the check so that new product IDs can be added.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
152d530d9edbb08424dc1b6561252597a7932c49 01-Apr-2010 Pavel Roskin <proski@gnu.org> ath9k: remove ah->mask_reg, it's never used properly

ah->mask_reg was used to hold different data throughout the driver.
ath9k_hw_init_interrupt_masks() used it to save the value written to
AR_IMR. ath9k_hw_set_interrupts() used it to hold the interrupt mask as
defined in enum ath9k_int. Those masks differ in many bits.

Use ah->imask instead of ah->mask_reg in ath9k_hw_set_interrupts() and
ath9k_hw_updatetxtriglevel(). That's what the code was meant to do.
ah->imask is initialized in ath9k_start(), so we don't need to
initialize it from ah->mask_reg.

Once it's done, ah->mask_reg becomes write-only, so it's replaced with a
local variable in ath9k_hw_init_interrupt_masks().

Signed-off-by: Pavel Roskin <proski@gnu.org>
Reported-by: Julia Lawall <julia@diku.dk>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
5a0e3ad6af8660be21ca98a971cd00f331318c05 24-Mar-2010 Tejun Heo <tj@kernel.org> 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>
736b3a27b3c50c4a23717b802240435a69e8d0ff 17-Mar-2010 Sujith <Sujith.Manoharan@atheros.com> ath9k_hw: fix hardware deinit

Without this you will get a panic if the device initialization
fails. Also, free ath_hw instance properly. ath9k_hw_deinit()
shouldn't do it.

Cc: stable@kernel.org
Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
05020d236e91ddab1cb42483843a8995b3be1adf 17-Mar-2010 Sujith <Sujith.Manoharan@atheros.com> ath9k_hw: add HTC init hardware call for special resets for AR9271

AR9271 needs a full reset only upon the first reset, add
a call for the driver to enable these special resets. We
can optimize this out later without an export.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
25e2ab17fd77e752597050980cec4efae7f87854 17-Mar-2010 Sujith <Sujith.Manoharan@atheros.com> ath9k_hw: always set the core clock for AR9271

When initializing the PLL on AR9271 we always need
to set the core clock to 117MHz. While at it remove
the baud rate settings for the serial device on the
AR9271, the default settings work well unless you
want to customize it.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
14b3af381df6359b15416df350e4e11892a52ab3 17-Mar-2010 Sujith <Sujith.Manoharan@atheros.com> ath9k_hw: Fix full sleep setup for AR9271

After telling the AR9271 to go into full sleep we do not need
to clear the RTC reset signal.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
527d485fd8765e1df1dd9114f5c623253d6349c3 17-Mar-2010 Sujith <Sujith.Manoharan@atheros.com> ath9k_hw: skip chip tests for AR9271

The chip test is not required for AR9271 on the host driver
code as the firmware will do the test internally on its own.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
5b5fa3558db7451f4744ef92f2b1830d05b9307b 17-Mar-2010 Sujith <Sujith.Manoharan@atheros.com> ath9k_hw: add GPIO setup code for AR9271

Assign the proper number of GPIO pins for AR9271.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
70807e99dbb0c5847668b617caf0ad7f876a23d9 17-Mar-2010 Sujith <Sujith.Manoharan@atheros.com> ath9k_hw: update initialization values for AR9271

Update the register initialization values for AR9271.
This is based on our last review from our systems team.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
74bad5cb497080514c4a945f38589bdb574fdfb7 24-Feb-2010 Pavel Roskin <proski@gnu.org> ath9k: never read from the AR_IMR_S2 register

The AR_IMR_S2 register sometimes cannot be read correctly. Instead of a
valid value, 0xdeadbeef is returned. The driver has been observed
writing that value back to AR_IMR_S2 after changing a few bits.

Cache the register value in ah->imrs2_reg and always write chached value
to the register.

Signed-off-by: Pavel Roskin <proski@gnu.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
7bfbae10dc10a5c94a780d117a57e875d77e8e5a 24-Feb-2010 Felix Fietkau <nbd@openwrt.org> ath9k: disable RIFS search for AR91xx based chips

While ath9k does not support RIFS yet, the ability to receive RIFS
frames is currently enabled for most chipsets in the initvals.
This is causing baseband related issues on AR9160 and AR9130 based
chipsets, which can lock up under certain conditions.

This patch fixes these issues by overriding the initvals, effectively
disabling RIFS for all affected chipsets.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Cc: stable@kernel.org
Acked-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
42c4568a4ace0adc27a9d6f02936e2047ba6fc7e 11-Feb-2010 Felix Fietkau <nbd@openwrt.org> ath9k: add a workaround for ack timeout issues

Adding support for setting the coverage class in some cases broke
association and data transfer, as it overwrote the initial ACK timeout
value from the initvals with a smaller value.
I don't know why the new value works in 5 GHz (matches the initval
there), but not in 2.4 GHz (initvals use 64us here), so until the
problem is fully understood, the value should be increased again.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
5ffaf8a361b4c9025963959a744f21d8173c7669 02-Feb-2010 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: add support for 802.11n bonded out AR2427

Some single chip family devices are sold in the market with
802.11n bonded out, these have no hardware capability for
802.11n but ath9k can still support them. These are called
AR2427.

Cc: stable@kernel.org
Reported-by: Rolf Leggewie <bugzilla.kernel.org@rolf.leggewie.biz>
Tested-by: Bernhard Reiter <ockham@raz.or.at>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
aa8bc9ef18a2c5b2b97e1f36ee9604cf15743f96 23-Jan-2010 Felix Fietkau <nbd@openwrt.org> ath9k: fix eeprom INI values override for 2GHz-only cards

Among other changes, this commit:

commit 06d0f0663e11cab4ec5f2c143a118d71a12fbbe9
Author: Sujith <Sujith.Manoharan@atheros.com>
Date: Thu Feb 12 10:06:45 2009 +0530

ath9k: Enable Fractional N mode

changed the hw attach code to fix up initialization values only for
dual band devices, however the commit message did not give a reason as
to why this would be useful or necessary.

According to tests by Jorge Boncompte, this breaks at least some
2GHz-only cards, so the code should be changed back to the
unconditional INI fixup.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Reported-by: Jorge Boncompte <jorge@dti2.net>
Cc: stable@kernel.org
Tested-by: Pavel Roskin <proski@gnu.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
e239d8591843945630521ec85edca08289f1a751 15-Jan-2010 Felix Fietkau <nbd@openwrt.org> ath9k: implement coverage class support

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
0005baf4a31efe6de6f922f73ccbd3762a110062 15-Jan-2010 Felix Fietkau <nbd@openwrt.org> ath9k: cleanup slot time and ack/cts timeout handling

Previously ath9k left the initialization of slot timing and ACK/CTS
timeout to the mode specific initvals. This does not handle short vs
long slot in 2.4 GHz and uses a rather strange value for the 2.4 GHz
ACK timeout (64 usec).
This patch uses the proper ath9k_hw functions for setting slot time and
timeouts and also implements the switch between short and long slot
time in 2.4 GHz

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
285f2ddae03ca207877262f5a9dbd9cddd8b3913 08-Jan-2010 Sujith <Sujith.Manoharan@atheros.com> ath9k: Cleanup init/deinit routines

The device initialization and termination functions
were messy and convoluted. Introduce helper functions
to clarify init_softc() and simplify things in general.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
0ce024cbcd5837596bc82861f1d3074d53e956f6 14-Dec-2009 Sujith <Sujith.Manoharan@atheros.com> ath9k: Clarify Interrupt mitigation

ath9k currently supports only RX interrupt
mitigation.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
411132628f95dd3d51b84e0e2d8ff8f4f2d09cdb 26-Nov-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: remove unused ath9k_hw_devname() and ath9k_hw_probe()

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
a9a29ce674ac62e7bfcb6c1404ca86cda4782988 27-Nov-2009 Gabor Juhos <juhosg@openwrt.org> ath9k: enable 2GHz band only if the device supports it

Currently, the 2GHz band is enabled unconditionally, even if the device
does not support it.

Changes-licensed-under: ISC
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
f4709fdf683e1ed37b321c258b614ebe39752bf3 25-Nov-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: Fix maximum tx fifo settings for single stream devices

Atheros single stream AR9285 and AR9271 have half the PCU TX FIFO
buffer size of that of dual stream devices. Dual stream devices
have a max PCU TX FIFO size of 8 KB while single stream devices
have 4 KB. Single stream devices have an issue though and require
hardware only to use half of the amount of its capable PCU TX FIFO
size, 2 KB and this requires a change in software.

Technically a change would not have been required (except for frame
burst considerations of 128 bytes) if these devices would have been
able to use the full 4 KB of the PCU TX FIFO size but our systems
engineers recommend 2 KB to be used only. We enforce this through
software by reducing the max frame triggger level to 2 KB.

Fixing the max frame trigger level should then have a few benefits:

* The PER will now be adjusted as designed for underruns when the
max trigger level is reached. This should help alleviate the
bus as the rate control algorithm chooses a slower rate which
should ensure frames are transmitted properly under high system
bus load.

* The poll we use on our TX queues should now trigger and work
as designed for single stream devices. The hardware passes
data from each TX queue on the PCU TX FIFO queue respecting each
queue's priority. The new trigger level ensures this seeding of
the PCU TX FIFO queue occurs as designed which could mean avoiding
false resets and actually reseting hw correctly when a TX queue
is indeed stuck.

* Some undocumented / unsupported behaviour could have been triggered
when the max trigger level level was being set to 4 KB on single
stream devices. Its not clear what this issue was to me yet.

Cc: Kyungwan Nam <kyungwan.nam@atheros.com>
Cc: Bennyam Malavazi <bennyam.malavazi@atheros.com>
Cc: Stephen Chen <stephen.chen@atheros.com>
Cc: Shan Palanisamy <shan.palanisamy@atheros.com>
Cc: Paul Shaw <paul.shaw@atheros.com>
Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
545750d36fa78203e28acefb4bab61ebb7c4d197 23-Nov-2009 Felix Fietkau <nbd@openwrt.org> ath9k: properly use the mac80211 rate control api

This patch changes ath9k to pass proper MCS indexes and flags
between the RC and the rest of the driver code.
sc->cur_rate_table remains, as it's used by the RC code internally,
but the rest of the driver code no longer uses it, so a potential
new RC for ath9k would not have to update it.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
cb53a150caa3068ce366b75dd354718145f5e893 16-Nov-2009 Sujith <Sujith.Manoharan@atheros.com> ath9k: Fix bug in initializing chain masks

Check for AR5416 ver 1.0 before calibrating 3 chains
for multi-chain. This is a WAR for calibration
failure.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
201cd6cce4f67ccead6240eb04ffa2f311661174 16-Nov-2009 Sujith <Sujith.Manoharan@atheros.com> ath9k: Remove a few unused functions

ATH9K_ANT_VARIABLE is the default diversity control used.
Consequently ath9k_hw_decrease_chain_power() does nothing.
ath9k_hw_setantennaswitch() is unused too.

Also, gbeacon_rate is unused.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
30cbd42265546a3efa146d4eb3456165325c83a7 04-Nov-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: move ath_extend_tsf() to hw code to share as ath9k_hw_extend_tsf()

This will be shared between ath9k and ath9k_htc.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
a77658286105c8be3741305c5dcf4c319746817f 19-Oct-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: Fix and complete force bias for AR5416

Force bias is a fix for usage of AR5416 radios on the 2.4 GHz band
for orientation sensitivity. This was only partially implemented
with the ath9k_hw_decrease_chain_power() but first -- this was being
called for all chipsets which is not correct and second -- it was
missing the actual orientation code.

We now ensure to only enable force bias only for AR5416 and BUG_ON()
on other chipsets. Although ath9k_hw_decrease_chain_power() was enabled
for newer chipsets I suspect that it never ran unless the EEPROM had
ATH9K_ANT_FIXED_A or ATH9K_ANT_FIXED_B for antenna diversity.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
896ff260351f736f0d9d32f4fd36257f3e75bd97 19-Oct-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: remove unused modesIndex param from ath9k_hw_write_regs()

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ae478cf69e9e49a88e0fe8beaffbcba2f97b5209 19-Oct-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: make spur mitigation a callback

This only differs between single-chip solutions and non single-chip
solutions.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
e16393bbb17e828aa433be9909462f9a61e4cbdb 19-Oct-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: order phy.c code and integrate spur mitigation

This reorders phy.c routines in the order in the order in which they are used
and also moves the spur mitigation helpers for each type of chip into phy.c
as they are RF related.

This patch has no functional changes.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
e68a060b5d88a72c06ec87864d20bea3f2a40629 19-Oct-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: use a callback for frequency change

This avoids a branch on every channel change.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
0a3b7bac673ee9462f5defe808609746d27af50d 19-Oct-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: make both analog channel change routines return int

This allows us to later define a callback for both.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
dc51dd503953a8bed545d10eb89fb3340a98879b 19-Oct-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: rename ath9k_hw_rf_free() to ath9k_hw_rf_free_ext_banks()

This clarifies this is only required for external radios.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
574d6b122d37549bc2817a4939d238f3d8b41da4 19-Oct-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: simplify rf attach and rename to ath9k_hw_rf_alloc_ext_banks()

ath9k_hw_rfattach() was just calling a helper and this helper was
doing nothing for single-chip devices, and for non single-chip devices
it is just allocating memory for banks to program the RF registers
at a later time. Simplify this by having the hw initialization call
the rf bank allocation directly for external radios.

Also, propagate an -ENOMEM properly now upon failure.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
c75724d1747230abdd37d0594ac5277b867befd4 19-Oct-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: change the way we initialize the pll for ar9271

We adjust the core clock for ar9271 to 117 MHz; this also
requires us to adjust the baud divider based on the targetted
baud rate.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
8564328d85f69121744d8337124857a2e726239b 19-Oct-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: update register initialization/reset values for ar9271

This update the register initialization/reset values (aka initvals)
for ar9271 based on the last recommended values on 2009-06-04 by our
systems engineering team.

The changes account for:

* Supporting ar9271 1.0 and ar9271 1.1 together, the difference
is bb_spectral_scan_ena, for 1.0 we'll set this to 0x1.

* Ensuring we get the correct noise floor values -115 ~ -118
when we enable bb_enable_ant_div_lnadiv=0 and
mc_tx_def_ant_sel=1. Previous to this we would get noise
floor values in the range -50 ~ -80. To fix settings for
the registers:

- bb_ch1_xatten1_db
- bb_ch1_xatten2_db
- bb_ch1_xatten1_margin
- bb_ch1_xatten2_margin
- bb_ch1_gain_force
- bb_ch1_xatten2_hyst_margin
- bb_ch1_xatten1_hyst_margin
- bb_ch1_max_oc_gain

* 0x8120[2] mc_mic_new_location_enable is changed to 0x1. The MAC team
suggest to set this value.

* 0x9910[0] bb_spectral_scan_ena is changed to 0x0.
For ar9271 1.1 we don't need to enable this bit.

Cc: Stephen Chen <Stephen.Chen@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ec11bb88f977321f117865b4d21079bbacc474ee 27-Oct-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: correct AR_PHY_SPECTRAL_SCAN register offset

We had 0x9912 but AR_PHY_SPECTRAL_SCAN is 0x9910. By using the
0x9912 we were making the hardware unresponsive. This allows us
to move forward with hardware reset on ar9271 on the ath9k_htc
driver.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
11158472c4ea7a4817d85912c491afa36a244192 27-Oct-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: add AR9271 single chip name mapping

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
f934c4d9de85571ff792360aa72dd26e00e1afc7 27-Oct-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: distinguish single-chip solutions on initial probe print

Devices with external radios have revisions which we can count on.
On single chip solutions these EEPROM values for these radio revision
also exist but are not meaningful as the radios are embedded onto the
same chip. Each single-chip device evolves together as one device.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2da4f01a0938b688f92f9ee380013cfb8653510f 27-Oct-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: move mac name and rf name helpers to hw code

These are shared between ath9k and the future ath9k_htc driver.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
211f5859af951788a3fe4752142a5e9047afa5d8 07-Oct-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: initialize hw prior to debugfs

debugfs uses the hardware for several debugfs files as such the
hardware must be initialized and available prior to its usage. The
same applies to when we free the hw structs -- free debufs file
entries prior to free'ing the hardware.

Reported-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
7976b4263cb05dc638297d35f2a42375090ebaff 24-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: add AR9271 srev and device ID to allow hw to support ar9271

This allows for hw support to be enabled for ar9271.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
3ca340381a1da26906dc766a1e4f8a5d0a613189 24-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k_hw: print device ID if not supported

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
7322fd19295fa7f7d954a19a5f0b77687d441846 24-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: move hw code to its own module

hw code for Atheros 802.11n hardware is commmon between
different chipsets. This moves this code into a separate
module, the next expected user of this code will be
the ath9k_htc module.

The ath9k/ dir is now selected by ATH9K_HW, an option which
gets selected by either ath9k or ath9k_htc, but remains
invisible for user menuconfig configuration. If either
ath9k or ath9k_htc will be compiled into the kernel
ath9k_hw will also be compiled in.

Cc: Jouni Malinen <jouni.malinen@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ebb90cfc32f0d7ee55be7787ce7d88e521e9ed01 18-Sep-2009 Senthil Balasubramanian <senthilkumar@atheros.com> ath9k: Advertise midband for AR5416 devices

This has to be done if the EEPROM supports FCC Midband
capability.

Signed-off-by: Senthil Balasubramanian <senthilkumar@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
63a75b912b00fbafeb54849ca3bcd0295ad68609 18-Sep-2009 Senthil Balasubramanian <senthilkumar@atheros.com> ath9k: Reduce PLL Settle time and eliminate redundant PLL calls.

Reduce PLL Settle time and eliminate redundant PLL calls. Also reduce
the LoadNF timeout from 10 msec to 250usec as the 10 msec timeout was
hit with AR9285 in some cases.

Signed-off-by: Senthil Balasubramanian <senthilkumar@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
1d50a69b18818b276333590d1f2c9382d292d84d 18-Sep-2009 Senthil Balasubramanian <senthilkumar@atheros.com> ath9k: Handle ATH9K_BEACON_RESET_TSF properly

Clearing a local variable is unnecessary.
Get rid of it.

Signed-off-by: Senthil Balasubramanian <senthilkumar@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
4921be8058f1c8854e501305b96196856fe7f830 18-Sep-2009 Sujith <Sujith.Manoharan@atheros.com> ath9k: Fix RTC reset for AR5416

For AR5416 chipsets, clearing RTC_RESET_EN when setting
the chip to SLEEP mode results in high power consumption.
This patch fixes this issue by not clearing it for AR5416.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
193cd4585e6c5650875e98ccfef2fa93616fef30 18-Sep-2009 Sujith <Sujith.Manoharan@atheros.com> ath9k: Update INI release for AR9287

If the current channel is between 2412 and 2472 MHz and if the channel is
changing to 2484 MHz, then the registers 0xa1f4, 0xa1f8 and 0xa1fc need to be
programmed to the "japan_2484" values. Conversely, if the current channel
is 2484 MHz and if the channel is changing to one between 2412 and 2472 MHz, then
the three registers need to be programmed to the "normal" values.

This is needed for compliance with Japanese regulatory requirements.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
cfe8cba982cda73d4970dab712411bebdcc3b9cd 14-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: clarify what hw code is and remove ath9k.h from a few files

hw code will be shared between ath9k and ath9k_htc.
Just a few more files are left to clean up, mark them as well.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
9680e8a391078a2bfa099b2c59542a6916a023ed 14-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: remove driver ASSERT, just use BUG_ON()

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
25c56eec92b15fdec5be96fa1303dac3443200ae 14-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: remove ath9k_ht_macmode

This is used just to determine how to program the MAC,
either for 20 MHz operation of 40 MHz so just use conf_is_ht40()

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
6420014ca4a6b0e853c9a19a8649d93682a5bdac 14-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: remove ath9k 25 MHz HT40 spacing stuff

This was for supporting 25 MHz spacing for HT40, this is not used
as we use 20 MHz spacing instead for HT40 as per 802.11n. The hardware
is capable of it though so we leave the phymode definition and EEPROM
parsing for it. If some experimenter wants to work on this stuff stuff
you can add an extension enabling bool on ath_common and perhaps some
debugfs knob to enable it. Keep in mind you'll also need to update the
phymode with the AR_PHY_FC_DYN2040_EXT_CH which has been left on the
driver.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
43c2761364b77cd7fd20eb1f14cfee4cd1462abd 14-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com> atheros: move tx/rx chainmask to ath_common

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
c46917bb53a546f60c7d3103407fe953c418dd5b 13-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com> atheros: add common debug printing

ath9k uses this for now, ath9k_htc is expected to re-use this
as well. We lave ath5k as is, but it certainly can also be
converted later.

The ath9k module parameter and debugfs entry is kept.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
cd9bf689600e62d84449d65b3d25fb6d2757589e 13-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: separate core driver and hw timer code

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
b002a4a950e41326310795cf4a0c74d0e90fa70a 13-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com> atheros: add ieee80211_hw to ath_common

Make use of it on hw code in ath9k to avoid
using the ath9k ath_softc.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
13b81559200b8e54473e5b140323cbb5f2bb21c0 11-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com> atheros: define shared bssidmask setting

Also make ath5k and ath9k use it, and share register definitions.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
9e4bffd233f27fe83fc48efb01935aee7d0685bf 11-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com> atheros/ath9k: add common read/write ops and port ath9k to use it

In an effort to make hw code driver core agnostic read
and write operations are defined on the ath_common structure.
This patch adds that and makes ath9k use it. This allows
drivers like ath9k_htc to define its own read/write ops and
still rely on the same hw code. This also paves the way for
sharing code between ath9k/ath5k/ath9k_htc.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
867633f026456ff71d4c4890f502c7a61b2adac0 10-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: Define bus agnostic bluetooth coex prep helper

We disable ASPM when enabling bluetooth coexistance. Disabling
ASPM is a bus specific operation. In the future other buses may
support bluetooth coexistance, an example is USB. To this end
move the current routine which disables ASPM into pci.c, and declare
it the PCI bt_coex_prep() helper. Additionally, since ASPM is
a PCI-Express primitive ensure we don't ever try to muck with ASPM
registers on non PCI-express devices.

This also cleans up hw.c to not include bus specific headers or
utilities.

Cc: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Cc: Stephen Chen <stephen.chen@atheros.com>
Cc: Zhifeng Cai <zhifeng.cai@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
1510718d0fd6e20803aac95fe1d8a44846098a34 10-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com> atheros/ath9k: move macaddr, curaid, curbssid and bssidmask to common

These are common amongst ath9k and ath5k, so put them into the
common structure and make ath9k to use it. ar9170 can use macaddr,
and curbssid. We'll change ath5k and ar9170 separately.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
3453ad8839ca91e1c11211d4d87dc3657c5a2b44 10-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: use ath9k_hw_write_associd() on reset

Use the already provided helper instead of rewriting the code
required in place.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
7664072b7937d0bd5563800359e04ff4418572e0 10-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: Use ath9k_hw_setbssidmask() on reset

The same code was being implemented on reset for setting the bssidmask,
instead just use the already provided helper.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
f2b2143e60651228945f361c09de7ee752360cd1 10-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: make ath9k_hw_setbssidmask() and ath9k_hw_write_associd() use ath_hw

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
9ecdef4be864fede4e5964abc82c8d7451288539 10-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: rename driver core and hw power save helpers

ath9k_hw_setpower_nolock --> ath9k_hw_setpower()
ath9k_hw_setpower() --> ath9k_setpower()

Also change the param for ath9k_setpower() to pass the ath_softc.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
8c77a5694cd31eb2291948dd1bfe700a199be8e7 10-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: move ath9k_hw_setpower() to main.c

And we make it static.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
1adc93c832726c9de4a43445c008a7f17549390b 10-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: avoid usage of ath9k_hw_setpower() on hw.c

ath9k_hw_setpower() is a core driver helper with locking
protection. Locking protection should be left to the driver
core, not the hw code. Hardware code no longer contends for
locking when it needs to wake up the chip or put it to sleep.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
a91d75aec19d8d23c7c543dd4bc0e394e1d46867 10-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: move ath9k_ps_wakeup() and ath9k_ps_restore() to main.c

These are driver core helpers.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
21526d57ad98635fe12dc8efe46a3d992439a443 10-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: move ps helpers onto core driver when reseting tsf

When the TSF is reset power save state is disabled and
then restored. The helpers to disable power save and restore
it use a lock provided by the driver core. Move the callers
of the helpers outside of the hw code.

We reset the TSF when mac80211 tells us and on the beacon.c
helper ath9k_hw_beaconinit() when it is made explicitly required.
Add a helper on beacon.c which will deal with ps awake/restore
if we need to reset the TSF upon ath9k_hw_beaconinit().

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
a36cfbca21d0acbab0840337f0b59ea58f415e50 10-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: rename ath_btcoex_supported() to ath9k_hw_btcoex_supported()

Also just pass the ath_hw as the parameter.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
766ec4a9a813ae262b61842020f150f865c1b10a 09-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: rename ath_btcoex_info to ath_btcoex_hw

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
46289e1e5f2155ba1502b079e786e91755919823 09-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: rename btcoex_scheme to just scheme

btcoex_scheme is already part of a btcoex struct, its implied
this is btcoex related.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
8c1b39547e2562f9aa0cc00b1a7d4cc325a46a4c 09-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: replaces SC_OP_BTCOEX_ENABLED with a bool

Whether or not bluetooth coex has been enabled is a hardware
state and only the hardware helpers will be able to set this.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
af03abecd8e3646736904431f3335dad5e28cb8d 09-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: move hw specific btcoex info to ath_hw

Since we now access it via the ath_hw declare the ath_hw pointer
at the header of some routines and se it. ath9k.h no longer needs to
access btcoex.h and to adjust for this move ath_btcoex_set_weight()
into btcoex.h and instead give main.c a helper for setting initial
values upon drv_start()

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
4d6b228d84ba992ee13c90312c1ed539191c94b1 07-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: use ath_hw for DPRINTF() and debug init/exit

DPRINTF() is used in hw specific related code, as such
ensure we don't rely on the private driver core ath_softc
struct when calling it. Drivers can then implement their
own DPRINTF() as they see fit.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
b37fa870c7ccb500c7bf6aabc72cefa757da9791 23-Sep-2009 Vivek Natarajan <vivek.natraj@gmail.com> ath9k: Initialize txgain and rxgain for newer AR9287 chipsets.

Signed-off-by: Vivek Natarajan <vnatarajan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
a3ca95fbe488b9cc6edd4903c609b19ba0365efc 17-Sep-2009 Vivek Natarajan <vnatarajan@atheros.com> ath9k: Disable autosleep feature by default.

Autosleep needs to be disabled for AR9287 chipsets also.
Since autosleep is not used for any of the currently supported
chipsets, disable it by default and can be enabled if needed
for any of the future chipsets.

Signed-off-by: Vivek Natarajan <vnatarajan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
42abfbee23bf86e2c74d569b7ddd040d29782c5a 17-Sep-2009 Vivek Natarajan <vnatarajan@atheros.com> ath9k: Fix AHB reset for AR9280

The commit "ath9k: Do an AHB reset before doing RTC reset"
fixed RTC reset issue for AR9280 2.0 chipsets and above.
The fix is valid for all AR9280 chipsets.

Signed-off-by: Vivek Natarajan <vnatarajan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
0a475cc6a0ac8e38ac3587cff87026551800b7fe 17-Sep-2009 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k: Do a full reset for AR9280

AR9280 requires a full reset during channel change and HW reset.
Currently, a fast channel change is done. This patch fixes
this bug.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
9ebef7997d0c131a8d53c045bff68becddd58124 17-Sep-2009 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k: Don't read NF when chip has gone through full sleep mode

NF value may be incorrect when we read it just after the chip
has gone through a full sleep mode. Reading incorrect NF values
affects RX throughput.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
204d794086f26a7b191d9a9c3483af8b81362b16 17-Sep-2009 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k: Fix rx data corruption

Setting bit 20 and 25 of 0x8344 can cause occasional rx data
corruption, clear them to fix this issue.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
46fe782c97f5e54a02485ad97b2e6256386a8c8f 17-Sep-2009 Sujith <Sujith.Manoharan@atheros.com> ath9k: Restore TSF after RESET

For chips requiring RTC reset, TSF has to be restored
after power on reset.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
93b1b37f6a4de8bce17f55d9cfa10ef5c8c04e8a 17-Sep-2009 Vivek Natarajan <vnatarajan@atheros.com> ath9k: Revamp PCIE workarounds

* Disable L1 state ONLY when device is in D3 mode.
* Clear bit 22 of register 0x4004.
* Handle power on/off properly

Not setting the workarounds properly resulted in the
disappearance of the card in certain cases.

Signed-off-by: Vivek Natarajan <vnatarajan@atheros.com>
Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
8c8f9ba7051b017e44124666b41c1dc70333a77c 09-Sep-2009 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k: Initialize the priority gpio for BT coex 3-wire

Oops, a stupid mistake in the original patch which adds coex 3-wire
support. Bluetooth priority gpio needs to be gpio 7.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
f42cc2c2909f24faa1381ae139067edeba8c796d 09-Sep-2009 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k: Get rid of the modparam btcoex_enable

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
fe12946e66575677879941a14f75b70ca2d2962a 09-Sep-2009 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k: Enable btcoex based on the subsystem id of the device

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
7b6840ab5f836a18c4ea98173f73c8d046930efb 07-Sep-2009 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k: Disable ASPM when btcoex is active

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
7ea310be65bfcbc6e2395844fd3498762dc2aea6 02-Sep-2009 Sujith <Sujith.Manoharan@atheros.com> ath9k: Fix RX Filter handling for BAR

BAR frames have to be sent to mac80211 only if the
current channel is HT. Also, move the macro to
enum ath9k_rx_filter.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
1c29ce672fe817c208309eea0c1ff7bf76250f15 31-Aug-2009 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k: Do an AHB reset before doing RTC reset

Doing an RTC reset when DMA is active may corrupt memory,
make sure no DMA is active at this moment by doing an
AHB reset.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
1773912bd25196c2a3ca6c174574561363f43b2b 26-Aug-2009 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k: Add Bluetooth Coexistence 3-wire support

This patch adds 3-wire bluetooth coex support for AR9285.
This support can be enabled through btcoex_enable modparam.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ff155a45cea56ad7a90c3f5192db59a4c7812fde 26-Aug-2009 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k: Add infrastructure for generic hw timers

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
81fa16fbe06cb3a4d29cc5a6f925132554521c72 26-Aug-2009 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k: Remove hw capability bit meant for btcoex

We don't need a hw cap bit for btcoex anymore as btcoex scheme type
is enough to do this.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
22f25d0d5e146112d4ec464564ebb49a5b8a547b 26-Aug-2009 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k: Determine btcoex scheme type based on chip version

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
f14462c6661c6b9e91d436f7ab66b35ed52ea703 26-Aug-2009 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k: Move btcoex related data to a separate struct

Also define macros for wlanactive and btactive (5 & 6) gpios.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
42cc41edf24b75fc6c37c99aed6e85455687e080 26-Aug-2009 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k: Configure btcoex register during every reset

Make sure btcoex register configured with appropriate values
after it is initialized with the default values from initvals.h
during reset.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
17d50d1df48631ae868958032edada7aa920636b 26-Aug-2009 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k: Move btcoex stuff from hw.[ch] to new btcoex.[ch]

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
f985ad12b595094839fddaf757fcf5d853ed3d7f 26-Aug-2009 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k: Split ath9k_hw_btcoex_enable() into two logical pieces

This function currently does initialization + enable the
btcoex support. Split it into two logical functions which
does the above operations separately. Btcoex initialization
is done during attach time and enabling this feature is done
in start(). Also, add code to disable btcoex support in stop().

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
608b88cb34b0e70a538ee1fc334cc833ef691836 18-Aug-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath: move regulatory info into shared common structure

This moves the shared regulatory structure into the
common structure. We will use this ongoing for common
data.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
326bebbcb51d3ce9761f616b8b9a35827fd9c697 14-Aug-2009 Vivek Natarajan <vivek.natraj@gmail.com> ath9k: Updates for AR9287_12 version of chipset.

Enable AsyncFIFO and AGGWEP for AR9287_12 and later revisions only.

Signed-off-by: Vivek Natarajan <vnatarajan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
d340b1f0e5e374fc902a020cb6ef9ebd7fb9f368 14-Aug-2009 Vivek Natarajan <vivek.natraj@gmail.com> ath9k: Set AR_WA for AR9287 as it improves consistency in throughput.

Signed-off-by: Vivek Natarajan <vnatarajan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
db91f2e4d410bf3011b3649b9257e5b3c60b25ff 14-Aug-2009 Vivek Natarajan <vivek.natraj@gmail.com> ath9k: Add open loop power control support for AR9287.

Signed-off-by: Vivek Natarajan <vnatarajan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
1cf6873a191388ff7d06bbd70f68bbffe1d70019 13-Aug-2009 Sujith <Sujith.Manoharan@atheros.com> ath9k: Remove duplicate variables

diversity_control and antenna_switch_swap are already
present in ath9k_ops_config. Remove duplicate occurrences
in ath_hw.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
54e4cec69e70ba30aec68650fb95b3a7e1e6dc18 07-Aug-2009 Sujith <Sujith.Manoharan@atheros.com> ath9k: Cleanup function return types

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
d7e7d229c7d1395283e1e1fda8727af60ca6f4ad 04-Aug-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: add initial hardware support for ar9271

We will finalize this after some driver core changes, for now
we leave this unsupported.

Cc: Stephen Chen <stephen.chen@atheros.com>
Cc: Zhifeng Cai <zhifeng.cai@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
39068d1c2810077377fc2ffcfbe380bfbed696cb 03-Aug-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: remove spurious check for channel on keycache reset

ath9k_hw_keyreset() has a spurious check for ah->curchan..
remove it.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
95fafca26dc317b7ea0667c57576b0b5389f5bef 03-Aug-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: call ath9k_hw_detach() once upon hw init failure

If hw initialization fails (ath9k_hw_init()) on ath_init_softc()
we bail out and call ath9k_hw_detach(). The call ath9k_hw_detach()
is conditional though as ath9k_hw_init() could itself have called
ath9k_hw_detach(). Just describing this is itself a brain twister.
Avoid this nonsense by removing ath9k_hw_detach() from ath9k_hw_init().

Upon hw initialization failure we expect the callers to take care of
the cleanup.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
9db6b6a25fd829a0d29480785ac0770a1e76f9a4 03-Aug-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: set ah to null after freeing

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
e70c0cfdbf98384d9ce0b7a7332b6e60ec22ad54 03-Aug-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: rename ath9k_hw_ani_detach() to ath9k_hw_ani_disable()

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
081b35ab2e98a2f76d0378219e91cd1c90aed55f 03-Aug-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: rename ath9k_hw_rfdetach() to ath9k_hw_rf_free()

This makes it clear what this does.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
f637cfd6bbacbaeab329f9dfc56e9855cc15849d 03-Aug-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: describe hw initialization better

During initialization ath9k tends to use "attach" to when we
initialize hardware due to the fact we used to attach a "HAL".
The notion of a HAL is long gone, so lets just be clear on what
we are doing.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
aa4058aea24efe7aef736cbfb2d9b07de920ca27 03-Aug-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: break up hw initialization into a few more helpers

This makes reading the hardware initialization process
easier to understand. The new helpers added are:

ath9k_hw_init_cal_settings()
ath9k_hw_init_mode_regs()
ath9k_hw_init_mode_gain_regs()
ath9k_hw_init_11a_eeprom_fix()

This patch has no functional changes.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
b8b0f377c762558b3773e27f73c7bbcd0fa40171 03-Aug-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: rename ath9k_hw_set_defaults() to ath9k_hw_init_config()

This reflects better what we are actually doing there.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
50aca25b5824f29fa94417abadf82ee7f0c7f816 03-Aug-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: rename ath9k_hw_newstate() to ath9k_hw_init_defaults()

This reflects better what we are actually doing there.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
f9d4a668035b0bf65d1c8d5eba680201112f7c3d 03-Aug-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: move hw macrevision checker to helper

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
07c10c6177bdd199fead127c2a4c43acb415a5be 03-Aug-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: pass only one argument to hw attach

The softc is cached and set within the ath_hw struct.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ee2bb460e28b757f097efb9e5947a6e47e2477e1 03-Aug-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: call hw initializer directly

ath9k_hw_attach() was going first through some device id verifier,
and then calling some other helper which was doing the real hardware
initialization. Lets just do the devid checks within the real worker
by calling a helper ath9k_hw_devid_supported().

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
8df5d1b77395271dd9b75ed2b9aa9235f7589a0d 03-Aug-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: move devid cache setting to ath_init()

This lets us trim one argument off of hw initializer routines.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
4f3acf81f2a47244f7403353784f528c92e98a6c 03-Aug-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: move memory allocation of ath_hw to ath_init()

This lets us simplify attach code and arguments passed.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
7819ac84b689b61340f29af6233fa1d15b76a6ef 03-Aug-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: propagate hw initialization errors

We were never propagating hw initialization errors, lets
do that now and also use -EOPNOTSUPP when device revision is
not supported yet.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
fbf54660d1b48fba8527aae5c628ba72feee8f83 03-Aug-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: use a switch for revising supported hw mac revisions

This makes adding new hw revisions a one line change here.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ed459c18517881890193b3414a25dbfe83d2ae7f 03-Aug-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: remove usage of AR_SREV_*() wrapper to detect supported hw

We will clean this up next to just use a switch.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
0b3acfa71a50a1fa1fcee528aa15404ea4ea0877 29-Jul-2009 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k: Remove unused ath9k_hw_intrget()

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
cbdec9758736c30ecbb03651b0c2915c442a5895 24-Jul-2009 Gabor Juhos <juhosg@openwrt.org> ath9k: get rid of unnecessary setpower calls

We are using setpower routines regardless of the current power mode.
Don't bother the hardware, if it is not necessary.

Changes-licensed-under: ISC
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
96148326c4b54db5c384def1a5ab285c359d1395 24-Jul-2009 Gabor Juhos <juhosg@openwrt.org> ath9k: fix race with IEEE80211_CONF_PS checks

There is a small window where the mac80211 changes the IEEE80211_CONF_PS
flag, and then informs the driver about the change. We have a race
condition if we are checking the flag in the same time. Avoid it by
introducing a local variable, and using that instead of checking the
IEEE80211_CONF_PS flag directly.

This fix the problem reported by Luis:
http://article.gmane.org/gmane.linux.kernel.wireless.general/34363

Changes-licensed-under: ISC
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ac88b6ecdfa629fd1261dab1504d78a56fd4cabf 23-Jul-2009 Vivek Natarajan <vivek.natraj@gmail.com> ath9k: Add support for AR9287 based chipsets.

Signed-off-by: Vivek Natarajan <vnatarajan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
f9b604f6c24ad161e9c9e30a138d5899724225c8 21-Jun-2009 Gabor Juhos <juhosg@openwrt.org> ath9k: make use ath9k_hw_wait int ath9k_hw_reset_tsf

We have a dedicated function for this kind of checks, use that
instead of duplicating the code.

Changes-licensed-under: ISC
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
1b7e528b2e39bfed37228eedaaf0665196d8ddc9 21-Jun-2009 Gabor Juhos <juhosg@openwrt.org> ath9k: wake up the chip for TSF reset

If we are in NETWORK SLEEP state, AR_SLP32_TSF_WRITE_STATUS limit
always exceeds in 'ath9k_hw_reset_tsf', because reading of the
AR_SLP3 register always return with the magic 0xdeadbeef value.

Changes-licensed-under: ISC
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
709ade9eb8ef06e03526115408e2fc93a9feabbd 15-Jul-2009 Gabor Juhos <juhosg@openwrt.org> ath9k: serialize ath9k_ps_{wakeup,restore} calls

These functions are changing the power mode of the chip, but this may
have unpredictable effects, if another code are trying to set the power
mode via 'ath9k_hw_setpower' in the same time from another context.

Changes-licensed-under: ISC
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
0bc0798b7605664c3ab8d577b398dc7ae0b2e58c 15-Jul-2009 Gabor Juhos <juhosg@openwrt.org> ath9k: uninline ath9k_ps_{wakeup,restore} functions

Uninline these functions before we add functional changes to them.

Changes-licensed-under: ISC
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
04717ccd80e5acc500239222684fcf8d2c759a84 15-Jul-2009 Gabor Juhos <juhosg@openwrt.org> ath9k: serialize ath9k_hw_setpower calls

Because ath9k_setpower is called from various contexts, we have to
protect it against concurrent calls.

Changes-licensed-under: ISC
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
dfe80a3fd2199c31d0a2dc24044abaadb64c26c2 15-Jul-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: remove ATH9K_MODE_11B

This saves us 2733 bytes.

text data bss dec hex filename
252265 3628 1584 257477 3edc5 ath9k-has-b-rate.ko
249905 3628 1584 255117 3e48d ath9k.ko

Cc: Derek Smithies <derek@indranet.co.nz>
Cc: Chittajit Mitra <Chittajit.Mitra@Atheros.com>
Siged-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>

Signed-off-by: John W. Linville <linville@tuxdriver.com>
6badaaf7729e5d1c02934b1739303ce79014ab67 28-Jun-2009 Joe Perches <joe@perches.com> drivers/net/wireless/ath/ath9k: Remove unnecessary semicolons

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
3b319aae4244f9b4758212605f67cf63207a4fa1 13-Jun-2009 Johannes Berg <johannes@sipsolutions.net> ath9k: port to cfg80211 rfkill

This ports the ath9k rfkill code to the new API offered by
cfg80211 and thus removes a lot of useless stuff.

("With this series a kernel panic, which is a regression, during module
unload disappears." -- Vasanthakumar Thiagarajan <vasanth@atheros.com>

Other patches in the series:

ath9k: Add helper to get ath9k specific current channel
ath9k: Make sure we have current channel in ah_curchan before rf
disable/enable

-- JWL)

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Luis Rodriguez <mcgrof@gmail.com>
Tested-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
e31a16d6f64ef0e324c6f54d5112703c3f13a9c4 21-May-2009 Zhu Yi <yi.zhu@intel.com> wireless: move some utility functions from mac80211 to cfg80211

The patch moves some utility functions from mac80211 to cfg80211.
Because these functions are doing generic 802.11 operations so they
are not mac80211 specific. The moving allows some fullmac drivers
to be also benefit from these utility functions.

Signed-off-by: Zhu Yi <yi.zhu@intel.com>
Signed-off-by: Samuel Ortiz <samuel.ortiz@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
8fbff4b838c53945d6baeafe609c627000f85cd6 09-May-2009 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k: Cleanup ineffective return values

This patch makes the return type of some of the functions
void as those functions always return true

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
19eddca67628e5fb722e4ebbbba8c307a884d0e8 09-May-2009 Vasanthakumar Thiagarajan <vasanth@atheros.com> ath9k: Remove bogus break after return

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
f9dd6b52873ad9fda51a3881c80c96d06ee6a57d 06-May-2009 Gabor Juhos <juhosg@openwrt.org> ath9k: remove redundant AR9285 checks

The AR_SREV_9285_1[12]_OR_LATER macros already contains the
AR_SREV_9285 check.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
4f0fc7c39f2a224b939f22d4dca552b266319525 06-May-2009 Luis R. Rodriguez <lrodriguez@atheros.com> ath9k: make private driver rate tables const

On x86 this allows us to do the following small savings:
shave off 23 % off of the module's data, and
shave off 6 % off of the module's text.

We save 456 bytes, for those counting.

$ size ath9k.ko
text data bss dec hex filename
250794 3628 1600 256022 3e816 ath9k.ko
$ size ath9k-old.ko
text data bss dec hex filename
239114 15308 1600 256022 3e816 ath9k-old.ko

$ du -b ath9k.ko
4034244 ath9k.ko
$ du -b ath9k-old.ko
4033788 ath9k-old.ko

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
fb4a3d35a26aa8ef5049f10666e6a163b4c32855 29-Apr-2009 Gabor Juhos <juhosg@openwrt.org> ath9k: uninline ath9k_io{read,write}32 routines

The spin_lock handling uses lots of instructions on some archs.
With this patch the size of the ath9k module will be significantly
smaller.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Acked-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
882b709230246de3359b04b195ad3e80b93b73ef 14-Apr-2009 Vivek Natarajan <vivek.natraj@gmail.com> ath9k: Disable autosleep feature for AR9285 based chipsets.

Signed-off-by: Vivek Natarajan <vnatarajan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
a89bff9a78b2bf51e21a961b473b5be94b22f12e 12-Apr-2009 Steven Luo <steven@steven676.net> ath9k: reset after PCI FATAL/PERR interrupts

ath9k_hw_getisr() doesn't appear to set anything in the status mask for
PCI FATAL or PERR interrupts (AR_INTR_SYNC_HOST1_FATAL/PERR), which
the open-source HAL seems to do. This means that the card isn't reset
after these interrupts.

This patch seems to fix a problem where the wireless drops out with an
"ath9k: received PCI FATAL interrupt" in dmesg after some time; the
hardware is an AR5416 in an ASUS WL-500W running 2.6.28.7 (OpenWRT) and
compat-wireless 2009-03-31.

Signed-off-by: Steven Luo <steven@steven676.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
203c4805e91786f9a010bc7945a0fde70c9da28e 31-Mar-2009 Luis R. Rodriguez <lrodriguez@atheros.com> atheros: put atheros wireless drivers into ath/

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>