Re: [ath9k-devel] [RFC] ath9k: advertise p2p dev support when chanctx

2015-06-15 Thread Sujith Manoharan
Janusz Dziedzic wrote:
 Add p2p dev support when ath9k loaded with
 use_chanctx=1. This will fix problem, when first
 interface is an AP and next we would like to run
 p2p_find. Before p2p scan failed.
 
 Signed-off-by: Janusz Dziedzic janusz.dzied...@tieto.com
 ---
 @Felix, Sujith please review. I am not sure if didn't miss some
 case for NL80211_IFTYPE_P2P_DEVICE (special handling required?).

At least the callbacks for adding/removing interfaces need
to be handled ?

But, can you describe the sequence of commands used that
resulted in this issue ?

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] [RFC] ath9k: allow to receive probe request when offchannel

2015-06-15 Thread Sujith Manoharan
Janusz Dziedzic wrote:
  case ATH_OFFCHANNEL_ROC_START:
  +   /* Allow to receive probe requests */
  +   rfilt = ath_calcrxfilter(sc);
  +   rfilt |= ATH9K_RX_FILTER_PROBEREQ;
  +   ath9k_hw_setrxfilter(sc-sc_ah, rfilt);
  +

ath9k_set_offchannel_state() would be a better place to do this,
since setting up various bits in the HW for offchannel operation
is done there. Also, it would make sure that the HW state is
retained when a chip reset is done for some reason.

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] [RFC] ath9k: advertise p2p dev support when chanctx

2015-06-15 Thread Sujith Manoharan
Janusz Dziedzic wrote:
  At least the callbacks for adding/removing interfaces need
  to be handled ?
 
 Strange, but I didn't hit any problem yet with my simple patch.

Ok. But I am not very familiar with how p2p-device is supposed
to be used...

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] [RFC] ath9k: advertise p2p dev support when chanctx

2015-06-15 Thread Sujith Manoharan
Arend van Spriel wrote:
 The p2p-device is designed to be used for p2p discovery and p2p action 
 frame exchange. It make it easier for driver and/or firmware to 
 determine if user-space request is p2p related or not. However, in 
 discussions with Jouni I got the impression that ath (or qca) firmware 
 and/or drivers did not need this design. Not sure if that claim is 
 unaffected by the use_chanctx=1 parameter.

Thanks for the explanation.

I don't think advertising support for p2p-device is required for
ath9k. P2P discovery works properly with the normal station/ap interface
types and the 'use_chanctx' modparam simply enables multiple channel
contexts.

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] ar9330 autosleep

2015-04-06 Thread Sujith Manoharan
Bob Copeland wrote:
 Ok, got it, so if I have a need to wake up for beacons from multiple
 APs with different TSFs, then autosleep probably wouldn't work for me?
 (I already implemented what I need with the TIM_TIMER on these chips,
 just asking to confirm my understanding.)

I think so, I haven't checked. :-)
It might be possible using the secondary TSF/BSSID that is allowed
in some chips, which was added to support Mesh/P2P.

https://github.com/qca/qcamain_open_hal_public/blob/master/hal/ar9300/osprey_reg_map.h#L847

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] ar9330 autosleep

2015-04-03 Thread Sujith Manoharan
Bob Copeland wrote:
 So I'm still missing the part where we wake hardware up on this version.
 It seemed to work for me though.

Sorry, I was referring to the PS mechanism on chips which don't
support autosleep.

For autosleep, no special handling in the driver is required
except the initial duration programming done in
ath9k_hw_set_sta_beacon_timers(). The HW wakes up to receive
every beacon and automatically goes back to network sleep.

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] ar9330 autosleep

2015-04-02 Thread Sujith Manoharan
Adrian Chadd wrote:
 I'm still debugging some of the sleep stuff with the AR9380 on
 FreeBSD. The later chips do the right thing, but the AR9380 beacon
 programming for /some/ reason is not hearing beacons in network sleep
 mode and eventually the BMISS interrupts cause a rescan/reassociation.
 IT doesn't happen on the later chips (AR9485, AR9462, .etc.) sigh.

Relying on the HW TIM interrupt wasn't reliable, IIRC. Instead of
using ATH9K_INT_TIM to process a beacon which has the TIM bit set
for our station, ath9k uses ATH9K_INT_TIM_TIMER. AR_TIM_TIMER_EN
is always enabled in station mode, so power-saving has lots of
room for improvement, since we completely ignore DTIM and always
wake up to receive every beacon.

Beacon/TIM processing is done in mac80211, for drivers that set
IEEE80211_HW_PS_NULLFUNC_STACK.

I am not sure why parsing beacons in the HW for the TIM IE
is unreliable.

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] Power drain during suspend

2015-03-23 Thread Sujith Manoharan
Frank Zafka wrote:
 As per suggestions, I tried modprobe -r ehci_hcd. No difference I'm
 afraid. I have another laptop with almost identical hardward (acer
 1810tz) and I recently installed the very same wifi card. I tested
 suspend on that last night and it didn't experience any significant
 battery discharge. If that information helps?
 
 Forgot to add that this laptop (1810tz)  runs Windows 8.

Can you blacklist ath9k and check ?
https://wiki.archlinux.org/index.php/kernel_modules#Blacklisting

Reboot and make sure that ath9k is not loaded, suspend/resume and
check battery status. If the drain issue is still seen, then
ath9k is not the problem.

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] Power drain during suspend

2015-03-21 Thread Sujith Manoharan
Adrian Chadd wrote:
 Sujith - do you have access to the PCIe breakout stuff at QCA?
 Something that we can use to measure the current draw of the NIC?

Nope, no access.

I asked internally if using a card that has been reworked for WOW
support can be used on a different mainboard - didn't get any
clear answer.

I found a doc which mentions this to enable WOW for WB222/AR9462:

For the hardware module: 
1. Power must be provided to the module during the S3/S4 states to support WoW. 
2. BOM change: (note that a host pull-up resistor (≧5 KΩ) tied to no higher than
+3.3 Vaux is required on this pin)

WB222-031:
Load R4 with 0 Ω, +5% 0201
Load R50 with 10K Ω, +5% 0201 (Optional)

I have no idea if this is a HW issue or just a bug in ath9k.
This page mentions that unloading ehci_hcd makes a difference:
http://www.thinkwiki.org/wiki/Problem_with_high_power_drain_in_ACPI_sleep#USB

Maybe that can be tried (or xhci_hcd).

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] Power drain during suspend

2015-03-20 Thread Sujith Manoharan
Adrian Chadd wrote:
 Maybe leaving WOW enabled is leaving the PCIe PHYs online and active?
 And/or USB/bluetooth?
 
 It has to be drawing significant current for it to flatten the battery
 whilst suspended, so my guess is that quite a large chunk of the
 hardware between the NIC and the battery is not fully suspended.

WOW is enabled only when a user configures it. The WOW code is compiled
into ath9k, but it is not used in the suspend/resume path, normally.

AFAIK, the MCI subsystem is enabled by default for WB222 in the windows
driver, we don't do that in ath9k.

Frank, can you load the driver with BTCOEX enabled and see if things improve ?
(sudo modprobe ath9k btcoex_enable=1)

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] Power drain during suspend

2015-03-20 Thread Sujith Manoharan
Sujith Manoharan wrote:
 Frank Zafka wrote:
  02:00.0 Network controller [0280]: Qualcomm Atheros AR9462 Wireless
  Network Adapter [168c:0034] (rev 01)
  Subsystem: Lenovo Device [17aa:3214]

Was this card obtained from a different machine ?
From an earlier email, your machine is Acer ?

I think WOW-enabled cards require hardware changes from the
base reference design (in your case WB222/AR9462), to receive
power when suspended.

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH] ath9k: Fix compilation error

2015-03-20 Thread Sujith Manoharan
From: Sujith Manoharan c_man...@qca.qualcomm.com

AIC needs to be registered only when BTCOEX is enabled.
This fixes the error reported by kbuild:

 ERROR: ar9003_hw_attach_aic_ops 
 [drivers/net/wireless/ath/ath9k/ath9k_hw.ko] undefined!

Signed-off-by: Sujith Manoharan c_man...@qca.qualcomm.com
---
 drivers/net/wireless/ath/ath9k/hw.h | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/hw.h 
b/drivers/net/wireless/ath/ath9k/hw.h
index c22edd3..aaec945 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -1117,8 +1117,6 @@ void ar9003_hw_attach_calib_ops(struct ath_hw *ah);
 int ar9002_hw_attach_ops(struct ath_hw *ah);
 void ar9003_hw_attach_ops(struct ath_hw *ah);
 
-void ar9003_hw_attach_aic_ops(struct ath_hw *ah);
-
 void ar9002_hw_load_ani_reg(struct ath_hw *ah, struct ath9k_channel *chan);
 
 void ath9k_ani_reset(struct ath_hw *ah, bool is_scanning);
@@ -1129,6 +1127,7 @@ void ath9k_hw_set_cts_timeout(struct ath_hw *ah, u32 us);
 void ath9k_hw_setslottime(struct ath_hw *ah, u32 us);
 
 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
+void ar9003_hw_attach_aic_ops(struct ath_hw *ah);
 static inline bool ath9k_hw_btcoex_is_enabled(struct ath_hw *ah)
 {
return ah-btcoex_hw.enabled;
@@ -1146,6 +1145,9 @@ ath9k_hw_get_btcoex_scheme(struct ath_hw *ah)
return ah-btcoex_hw.scheme;
 }
 #else
+static inline void ar9003_hw_attach_aic_ops(struct ath_hw *ah)
+{
+}
 static inline bool ath9k_hw_btcoex_is_enabled(struct ath_hw *ah)
 {
return false;
-- 
2.3.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] Power drain during suspend

2015-03-18 Thread Sujith Manoharan
Frank Zafka wrote:
 So has anyone got any good ideas on how to proceed with this issue?

I have an AR9565 card which also appears to show similar behavior.
The rate of power drain is slower, but the battery does reach zero
capacity after suspend. WOW is enabled on this machine/chip too.
Unfortunately removing the card is cumbersome on this small netbook,
so I can't rule out other causes. But, I'll check if something
needs to be done in ath9k.

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] Power drain during suspend

2015-03-15 Thread Sujith Manoharan
Frank Zafka wrote:
 02:00.0 Network controller [0280]: Qualcomm Atheros AR9462 Wireless
 Network Adapter [168c:0034] (rev 01)
 Subsystem: Lenovo Device [17aa:3214]

This card supports WOWLAN and is a BT combo device. Maybe
ath9k is missing something in the suspend path.

Can you check if unloading both ath9k and ath3k before suspend
makes any difference ?

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] Power drain during suspend

2015-03-14 Thread Sujith Manoharan
Frank Zafka wrote:
 Hello. Looking for some advice regarding a massive powerdrain during
 suspend caused by the wifi card.
 
 I have a new Atheros AR9462 connected to my n-wireless network.
 Everything works fine. I put the computer into suspend (shut lid) and
 everything goes as expected. However the battery is completely
 emptying over night.

Which card/machine is this ? Can you post the output of
'sudo lspci -vv -nn -d 168c:*' and 'sudo dmidecode' ?

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] ath9k channel switch

2015-03-14 Thread Sujith Manoharan
Saurabh Pal wrote:
 Just wanted to know whether it is possible to switch the channel without
 resetting the chip. Also if possible can anybody tell me how much time it
 takes to switch the channel by resetting the chip?

Fast Channel Change is used to switch channels without a full chip reset.
The time taken to switch channels is not exported, but you can measure it
in the driver.

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH v2 09/11] ath9k: Handle MCI_STATE_AIC_START

2015-03-13 Thread Sujith Manoharan
From: Sujith Manoharan c_man...@qca.qualcomm.com

This patch adds a function to handle the
MCI message MCI_STATE_AIC_START.

Signed-off-by: Sujith Manoharan c_man...@qca.qualcomm.com
---
 drivers/net/wireless/ath/ath9k/ar9003_aic.c | 33 +
 drivers/net/wireless/ath/ath9k/ar9003_aic.h |  1 +
 drivers/net/wireless/ath/ath9k/ar9003_mci.c |  4 
 3 files changed, 38 insertions(+)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_aic.c 
b/drivers/net/wireless/ath/ath9k/ar9003_aic.c
index 4e8cf08..5b4f818 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_aic.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_aic.c
@@ -18,6 +18,7 @@
 #include hw-ops.h
 #include ar9003_mci.h
 #include ar9003_aic.h
+#include ar9003_phy.h
 #include reg_aic.h
 
 static const u8 com_att_db_table[ATH_AIC_MAX_COM_ATT_DB_TABLE] = {
@@ -512,6 +513,38 @@ exit:
 
 }
 
+u8 ar9003_aic_start_normal(struct ath_hw *ah)
+{
+   struct ath9k_hw_aic *aic = ah-btcoex_hw.aic;
+   int16_t i;
+
+   if (aic-aic_cal_state != AIC_CAL_STATE_DONE)
+   return 1;
+
+   ar9003_aic_gain_table(ah);
+
+   REG_WRITE(ah, AR_PHY_AIC_SRAM_ADDR_B1, ATH_AIC_SRAM_AUTO_INCREMENT);
+
+   for (i = 0; i  ATH_AIC_MAX_BT_CHANNEL; i++) {
+   REG_WRITE(ah, AR_PHY_AIC_SRAM_DATA_B1, aic-aic_sram[i]);
+   }
+
+   /* FIXME: Replace these with proper register names */
+   REG_WRITE(ah, 0xa6b0, 0x80);
+   REG_WRITE(ah, 0xa6b4, 0x5b2df0);
+   REG_WRITE(ah, 0xa6b8, 0x10762cc8);
+   REG_WRITE(ah, 0xa6bc, 0x1219a4b);
+   REG_WRITE(ah, 0xa6c0, 0x1e01);
+   REG_WRITE(ah, 0xb6b4, 0xf0);
+   REG_WRITE(ah, 0xb6c0, 0x1e01);
+   REG_WRITE(ah, 0xb6b0, 0x81);
+   REG_WRITE(ah, AR_PHY_65NM_CH1_RXTX4, 0x4000);
+
+   aic-aic_enabled = true;
+
+   return 0;
+}
+
 u8 ar9003_aic_cal_reset(struct ath_hw *ah)
 {
struct ath9k_hw_aic *aic = ah-btcoex_hw.aic;
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_aic.h 
b/drivers/net/wireless/ath/ath9k/ar9003_aic.h
index f7c9546..4dbff96 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_aic.h
+++ b/drivers/net/wireless/ath/ath9k/ar9003_aic.h
@@ -53,6 +53,7 @@ struct ath_aic_out_info {
struct ath_aic_sram_info sram;
 };
 
+u8 ar9003_aic_start_normal(struct ath_hw *ah);
 u8 ar9003_aic_cal_reset(struct ath_hw *ah);
 u8 ar9003_aic_calibration_single(struct ath_hw *ah);
 
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mci.c 
b/drivers/net/wireless/ath/ath9k/ar9003_mci.c
index d6ed628..b559d75 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_mci.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_mci.c
@@ -1363,6 +1363,10 @@ u32 ar9003_mci_state(struct ath_hw *ah, u32 state_type)
value = (!mci-unhalt_bt_gpm  mci-need_flush_btinfo) ? 1 : 0;
mci-need_flush_btinfo = false;
break;
+   case MCI_STATE_AIC_START:
+   if (ath9k_hw_is_aic_enabled(ah))
+   ar9003_aic_start_normal(ah);
+   break;
case MCI_STATE_AIC_CAL_RESET:
if (ath9k_hw_is_aic_enabled(ah))
value = ar9003_aic_cal_reset(ah);
-- 
2.3.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH v2 06/11] ath9k: Process the AIC calibration results

2015-03-13 Thread Sujith Manoharan
From: Sujith Manoharan c_man...@qca.qualcomm.com

This patch adds support for post-processing
the AIC calibration results.

Signed-off-by: Sujith Manoharan c_man...@qca.qualcomm.com
---
 drivers/net/wireless/ath/ath9k/ar9003_aic.c | 245 
 1 file changed, 245 insertions(+)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_aic.c 
b/drivers/net/wireless/ath/ath9k/ar9003_aic.c
index 00aaf4d..51ecc9b 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_aic.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_aic.c
@@ -20,6 +20,22 @@
 #include ar9003_aic.h
 #include reg_aic.h
 
+static const u8 com_att_db_table[ATH_AIC_MAX_COM_ATT_DB_TABLE] = {
+   0, 3, 9, 15, 21, 27
+};
+
+static const u16 aic_lin_table[ATH_AIC_MAX_AIC_LIN_TABLE] = {
+   8191, 7300, 6506, 5799, 5168, 4606, 4105, 3659,
+   3261, 2906, 2590, 2309, 2057, 1834, 1634, 1457,
+   1298, 1157, 1031, 919,  819,  730,  651,  580,
+   517,  461,  411,  366,  326,  291,  259,  231,
+   206,  183,  163,  146,  130,  116,  103,  92,
+   82,   73,   65,   58,   52,   46,   41,   37,
+   33,   29,   26,   23,   21,   18,   16,   15,
+   13,   12,   10,   9,8,7,7,6,
+   5,5,4,4,3
+};
+
 static bool ar9003_hw_is_aic_enabled(struct ath_hw *ah)
 {
struct ath9k_hw_mci *mci_hw = ah-btcoex_hw.mci;
@@ -30,6 +46,56 @@ static bool ar9003_hw_is_aic_enabled(struct ath_hw *ah)
return true;
 }
 
+static int16_t ar9003_aic_find_valid(struct ath_aic_sram_info *cal_sram,
+bool dir, u8 index)
+{
+   int16_t i;
+
+   if (dir) {
+   for (i = index + 1; i  ATH_AIC_MAX_BT_CHANNEL; i++) {
+   if (cal_sram[i].valid)
+   break;
+   }
+   } else {
+   for (i = index - 1; i = 0; i--) {
+   if (cal_sram[i].valid)
+   break;
+   }
+   }
+
+   if ((i = ATH_AIC_MAX_BT_CHANNEL) || (i  0))
+   i = -1;
+
+   return i;
+}
+
+/*
+ * type 0: aic_lin_table, 1: com_att_db_table
+ */
+static int16_t ar9003_aic_find_index(u8 type, int16_t value)
+{
+   int16_t i = -1;
+
+   if (type == 0) {
+   for (i = ATH_AIC_MAX_AIC_LIN_TABLE - 1; i = 0; i--) {
+   if (aic_lin_table[i] = value)
+   break;
+   }
+   } else if (type == 1) {
+   for (i = 0; i  ATH_AIC_MAX_COM_ATT_DB_TABLE; i++) {
+   if (com_att_db_table[i]  value) {
+   i--;
+   break;
+   }
+   }
+
+   if (i = ATH_AIC_MAX_COM_ATT_DB_TABLE)
+   i = -1;
+   }
+
+   return i;
+}
+
 static void ar9003_aic_gain_table(struct ath_hw *ah)
 {
u32 aic_atten_word[19], i;
@@ -186,12 +252,191 @@ static void ar9003_aic_cal_start(struct ath_hw *ah, u8 
min_valid_count)
aic-aic_cal_state = AIC_CAL_STATE_STARTED;
 }
 
+static bool ar9003_aic_cal_post_process(struct ath_hw *ah)
+{
+   struct ath9k_hw_aic *aic = ah-btcoex_hw.aic;
+   struct ath_aic_sram_info cal_sram[ATH_AIC_MAX_BT_CHANNEL];
+   struct ath_aic_out_info aic_sram[ATH_AIC_MAX_BT_CHANNEL];
+   u32 dir_path_gain_idx, quad_path_gain_idx, value;
+   u32 fixed_com_att_db;
+   int8_t dir_path_sign, quad_path_sign;
+   int16_t i;
+   bool ret = true;
+
+   memset(cal_sram, 0, sizeof(cal_sram));
+   memset(aic_sram, 0, sizeof(aic_sram));
+
+   for (i = 0; i  ATH_AIC_MAX_BT_CHANNEL; i++) {
+   value = aic-aic_sram[i];
+
+   cal_sram[i].valid =
+   MS(value, AR_PHY_AIC_SRAM_VALID);
+   cal_sram[i].rot_quad_att_db =
+   MS(value, AR_PHY_AIC_SRAM_ROT_QUAD_ATT_DB);
+   cal_sram[i].vga_quad_sign =
+   MS(value, AR_PHY_AIC_SRAM_VGA_QUAD_SIGN);
+   cal_sram[i].rot_dir_att_db =
+   MS(value, AR_PHY_AIC_SRAM_ROT_DIR_ATT_DB);
+   cal_sram[i].vga_dir_sign =
+   MS(value, AR_PHY_AIC_SRAM_VGA_DIR_SIGN);
+   cal_sram[i].com_att_6db =
+   MS(value, AR_PHY_AIC_SRAM_COM_ATT_6DB);
+
+   if (cal_sram[i].valid) {
+   dir_path_gain_idx = cal_sram[i].rot_dir_att_db +
+   com_att_db_table[cal_sram[i].com_att_6db];
+   quad_path_gain_idx = cal_sram[i].rot_quad_att_db +
+   com_att_db_table[cal_sram[i].com_att_6db];
+
+   dir_path_sign = (cal_sram[i].vga_dir_sign) ? 1 : -1;
+   quad_path_sign = (cal_sram[i].vga_quad_sign) ? 1 : -1;
+
+   aic_sram[i].dir_path_gain_lin = dir_path_sign *
+   aic_lin_table[dir_path_gain_idx

[ath9k-devel] [PATCH v2 10/11] ath9k: Handle MCI_STATE_AIC_CAL

2015-03-13 Thread Sujith Manoharan
From: Sujith Manoharan c_man...@qca.qualcomm.com

Add the main AIC calibration function to
handle MCI_STATE_AIC_CAL.

Signed-off-by: Sujith Manoharan c_man...@qca.qualcomm.com
---
 drivers/net/wireless/ath/ath9k/ar9003_aic.c | 28 ++--
 drivers/net/wireless/ath/ath9k/ar9003_aic.h |  1 +
 drivers/net/wireless/ath/ath9k/ar9003_mci.c |  4 
 3 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_aic.c 
b/drivers/net/wireless/ath/ath9k/ar9003_aic.c
index 5b4f818..1db119d 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_aic.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_aic.c
@@ -162,7 +162,7 @@ static void ar9003_aic_gain_table(struct ath_hw *ah)
}
 }
 
-static void ar9003_aic_cal_start(struct ath_hw *ah, u8 min_valid_count)
+static u8 ar9003_aic_cal_start(struct ath_hw *ah, u8 min_valid_count)
 {
struct ath9k_hw_aic *aic = ah-btcoex_hw.aic;
int i;
@@ -257,6 +257,8 @@ static void ar9003_aic_cal_start(struct ath_hw *ah, u8 
min_valid_count)
 
aic-aic_caled_chan = 0;
aic-aic_cal_state = AIC_CAL_STATE_STARTED;
+
+   return aic-aic_cal_state;
 }
 
 static bool ar9003_aic_cal_post_process(struct ath_hw *ah)
@@ -513,6 +515,28 @@ exit:
 
 }
 
+u8 ar9003_aic_calibration(struct ath_hw *ah)
+{
+   struct ath9k_hw_aic *aic = ah-btcoex_hw.aic;
+   u8 cal_ret = AIC_CAL_STATE_ERROR;
+
+   switch (aic-aic_cal_state) {
+   case AIC_CAL_STATE_IDLE:
+   cal_ret = ar9003_aic_cal_start(ah, 1);
+   break;
+   case AIC_CAL_STATE_STARTED:
+   cal_ret = ar9003_aic_cal_continue(ah, false);
+   break;
+   case AIC_CAL_STATE_DONE:
+   cal_ret = AIC_CAL_STATE_DONE;
+   break;
+   default:
+   break;
+   }
+
+   return cal_ret;
+}
+
 u8 ar9003_aic_start_normal(struct ath_hw *ah)
 {
struct ath9k_hw_aic *aic = ah-btcoex_hw.aic;
@@ -561,7 +585,7 @@ u8 ar9003_aic_calibration_single(struct ath_hw *ah)
 
num_chan = MS(mci_hw-config, ATH_MCI_CONFIG_AIC_CAL_NUM_CHAN);
 
-   ar9003_aic_cal_start(ah, num_chan);
+   (void) ar9003_aic_cal_start(ah, num_chan);
cal_ret = ar9003_aic_cal_continue(ah, true);
 
return cal_ret;
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_aic.h 
b/drivers/net/wireless/ath/ath9k/ar9003_aic.h
index 4dbff96..86f4064 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_aic.h
+++ b/drivers/net/wireless/ath/ath9k/ar9003_aic.h
@@ -53,6 +53,7 @@ struct ath_aic_out_info {
struct ath_aic_sram_info sram;
 };
 
+u8 ar9003_aic_calibration(struct ath_hw *ah);
 u8 ar9003_aic_start_normal(struct ath_hw *ah);
 u8 ar9003_aic_cal_reset(struct ath_hw *ah);
 u8 ar9003_aic_calibration_single(struct ath_hw *ah);
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mci.c 
b/drivers/net/wireless/ath/ath9k/ar9003_mci.c
index b559d75..cdd83d4 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_mci.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_mci.c
@@ -1363,6 +1363,10 @@ u32 ar9003_mci_state(struct ath_hw *ah, u32 state_type)
value = (!mci-unhalt_bt_gpm  mci-need_flush_btinfo) ? 1 : 0;
mci-need_flush_btinfo = false;
break;
+   case MCI_STATE_AIC_CAL:
+   if (ath9k_hw_is_aic_enabled(ah))
+   value = ar9003_aic_calibration(ah);
+   break;
case MCI_STATE_AIC_START:
if (ath9k_hw_is_aic_enabled(ah))
ar9003_aic_start_normal(ah);
-- 
2.3.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH v2 11/11] ath9k: Start AIC calibration during MCI reset

2015-03-13 Thread Sujith Manoharan
From: Sujith Manoharan c_man...@qca.qualcomm.com

When a MCI reset is done, make sure that AIC
is started.

Signed-off-by: Sujith Manoharan c_man...@qca.qualcomm.com
---
 drivers/net/wireless/ath/ath9k/ar9003_mci.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mci.c 
b/drivers/net/wireless/ath/ath9k/ar9003_mci.c
index cdd83d4..af5ee41 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_mci.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_mci.c
@@ -1017,6 +1017,9 @@ int ar9003_mci_reset(struct ath_hw *ah, bool en_int, bool 
is_2g,
if (en_int)
ar9003_mci_enable_interrupt(ah);
 
+   if (ath9k_hw_is_aic_enabled(ah))
+   ar9003_aic_start_normal(ah);
+
return 0;
 }
 
-- 
2.3.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH v2 07/11] ath9k: Disable AIC by default

2015-03-13 Thread Sujith Manoharan
From: Sujith Manoharan c_man...@qca.qualcomm.com

Since various MCI messages need to be
handled, along with driver-level support
in upper layers, disable AIC for now.

Signed-off-by: Sujith Manoharan c_man...@qca.qualcomm.com
---
 drivers/net/wireless/ath/ath9k/ar9003_aic.c | 6 ++
 drivers/net/wireless/ath/ath9k/ar9003_mci.c | 3 ++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_aic.c 
b/drivers/net/wireless/ath/ath9k/ar9003_aic.c
index 51ecc9b..7bdbc7a 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_aic.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_aic.c
@@ -40,6 +40,12 @@ static bool ar9003_hw_is_aic_enabled(struct ath_hw *ah)
 {
struct ath9k_hw_mci *mci_hw = ah-btcoex_hw.mci;
 
+   /*
+* Disable AIC for now, until we have all the
+* HW code and the driver-layer support ready.
+*/
+   return false;
+
if (mci_hw-config  ATH_MCI_CONFIG_DISABLE_AIC)
return false;
 
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mci.c 
b/drivers/net/wireless/ath/ath9k/ar9003_mci.c
index 20bb5b9..6fa98e5 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_mci.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_mci.c
@@ -1364,7 +1364,8 @@ u32 ar9003_mci_state(struct ath_hw *ah, u32 state_type)
mci-need_flush_btinfo = false;
break;
case MCI_STATE_AIC_CAL_SINGLE:
-   value = ar9003_aic_calibration_single(ah);
+   if (ath9k_hw_is_aic_enabled(ah))
+   value = ar9003_aic_calibration_single(ah);
break;
default:
break;
-- 
2.3.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH v2 05/11] ath9k: Finish AIC calibration

2015-03-13 Thread Sujith Manoharan
From: Sujith Manoharan c_man...@qca.qualcomm.com

Set the appropriate bits in the HW after
AIC calibration is done.

Signed-off-by: Sujith Manoharan c_man...@qca.qualcomm.com
---
 drivers/net/wireless/ath/ath9k/ar9003_aic.c | 78 -
 1 file changed, 77 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_aic.c 
b/drivers/net/wireless/ath/ath9k/ar9003_aic.c
index c2cfac3..00aaf4d 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_aic.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_aic.c
@@ -186,15 +186,91 @@ static void ar9003_aic_cal_start(struct ath_hw *ah, u8 
min_valid_count)
aic-aic_cal_state = AIC_CAL_STATE_STARTED;
 }
 
+static void ar9003_aic_cal_done(struct ath_hw *ah)
+{
+   /* Disable AIC reference signal in BT modem. */
+   REG_WRITE(ah, ATH_AIC_BT_JUPITER_CTRL,
+ (REG_READ(ah, ATH_AIC_BT_JUPITER_CTRL) 
+  ~ATH_AIC_BT_AIC_ENABLE));
+}
+
+static u8 ar9003_aic_cal_continue(struct ath_hw *ah, bool cal_once)
+{
+   struct ath_common *common = ath9k_hw_common(ah);
+   struct ath9k_hw_mci *mci_hw = ah-btcoex_hw.mci;
+   struct ath9k_hw_aic *aic = ah-btcoex_hw.aic;
+   int i, num_chan;
+
+   num_chan = MS(mci_hw-config, ATH_MCI_CONFIG_AIC_CAL_NUM_CHAN);
+
+   if (!num_chan) {
+   aic-aic_cal_state = AIC_CAL_STATE_ERROR;
+   return aic-aic_cal_state;
+   }
+
+   if (cal_once) {
+   for (i = 0; i  1; i++) {
+   if ((REG_READ(ah, AR_PHY_AIC_CTRL_0_B1) 
+AR_PHY_AIC_CAL_ENABLE) == 0)
+   break;
+
+   udelay(100);
+   }
+   }
+
+   /*
+* Use AR_PHY_AIC_CAL_ENABLE bit instead of AR_PHY_AIC_CAL_DONE.
+* Sometimes CAL_DONE bit is not asserted.
+*/
+   if ((REG_READ(ah, AR_PHY_AIC_CTRL_0_B1) 
+AR_PHY_AIC_CAL_ENABLE) != 0) {
+   ath_dbg(common, MCI, AIC cal is not done after 40ms);
+   goto exit;
+   }
+
+   REG_WRITE(ah, AR_PHY_AIC_SRAM_ADDR_B1,
+ (ATH_AIC_SRAM_CAL_OFFSET | ATH_AIC_SRAM_AUTO_INCREMENT));
+
+   for (i = 0; i  ATH_AIC_MAX_BT_CHANNEL; i++) {
+   u32 value;
+
+   value = REG_READ(ah, AR_PHY_AIC_SRAM_DATA_B1);
+
+   if (value  0x01) {
+   if (aic-aic_sram[i] == 0)
+   aic-aic_caled_chan++;
+
+   aic-aic_sram[i] = value;
+
+   if (!cal_once)
+   break;
+   }
+   }
+
+   if ((aic-aic_caled_chan = num_chan) || cal_once) {
+   ar9003_aic_cal_done(ah);
+   } else {
+   /* Start calibration */
+   REG_CLR_BIT(ah, AR_PHY_AIC_CTRL_0_B1, AR_PHY_AIC_CAL_ENABLE);
+   REG_SET_BIT(ah, AR_PHY_AIC_CTRL_0_B1,
+   AR_PHY_AIC_CAL_CH_VALID_RESET);
+   REG_SET_BIT(ah, AR_PHY_AIC_CTRL_0_B1, AR_PHY_AIC_CAL_ENABLE);
+   }
+exit:
+   return aic-aic_cal_state;
+
+}
+
 u8 ar9003_aic_calibration_single(struct ath_hw *ah)
 {
struct ath9k_hw_mci *mci_hw = ah-btcoex_hw.mci;
-   u8 cal_ret = 0;
+   u8 cal_ret;
int num_chan;
 
num_chan = MS(mci_hw-config, ATH_MCI_CONFIG_AIC_CAL_NUM_CHAN);
 
ar9003_aic_cal_start(ah, num_chan);
+   cal_ret = ar9003_aic_cal_continue(ah, true);
 
return cal_ret;
 }
-- 
2.3.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH v2 08/11] ath9k: Handle MCI_STATE_AIC_CAL_RESET

2015-03-13 Thread Sujith Manoharan
From: Sujith Manoharan c_man...@qca.qualcomm.com

Add a routine to handle the MCI_STATE_AIC_CAL_RESET
message.

Signed-off-by: Sujith Manoharan c_man...@qca.qualcomm.com
---
 drivers/net/wireless/ath/ath9k/ar9003_aic.c | 8 
 drivers/net/wireless/ath/ath9k/ar9003_aic.h | 1 +
 drivers/net/wireless/ath/ath9k/ar9003_mci.c | 4 
 3 files changed, 13 insertions(+)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_aic.c 
b/drivers/net/wireless/ath/ath9k/ar9003_aic.c
index 7bdbc7a..4e8cf08 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_aic.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_aic.c
@@ -512,6 +512,14 @@ exit:
 
 }
 
+u8 ar9003_aic_cal_reset(struct ath_hw *ah)
+{
+   struct ath9k_hw_aic *aic = ah-btcoex_hw.aic;
+
+   aic-aic_cal_state = AIC_CAL_STATE_IDLE;
+   return aic-aic_cal_state;
+}
+
 u8 ar9003_aic_calibration_single(struct ath_hw *ah)
 {
struct ath9k_hw_mci *mci_hw = ah-btcoex_hw.mci;
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_aic.h 
b/drivers/net/wireless/ath/ath9k/ar9003_aic.h
index e31c44e..f7c9546 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_aic.h
+++ b/drivers/net/wireless/ath/ath9k/ar9003_aic.h
@@ -53,6 +53,7 @@ struct ath_aic_out_info {
struct ath_aic_sram_info sram;
 };
 
+u8 ar9003_aic_cal_reset(struct ath_hw *ah);
 u8 ar9003_aic_calibration_single(struct ath_hw *ah);
 
 #endif /* AR9003_AIC_H */
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mci.c 
b/drivers/net/wireless/ath/ath9k/ar9003_mci.c
index 6fa98e5..d6ed628 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_mci.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_mci.c
@@ -1363,6 +1363,10 @@ u32 ar9003_mci_state(struct ath_hw *ah, u32 state_type)
value = (!mci-unhalt_bt_gpm  mci-need_flush_btinfo) ? 1 : 0;
mci-need_flush_btinfo = false;
break;
+   case MCI_STATE_AIC_CAL_RESET:
+   if (ath9k_hw_is_aic_enabled(ah))
+   value = ar9003_aic_cal_reset(ah);
+   break;
case MCI_STATE_AIC_CAL_SINGLE:
if (ath9k_hw_is_aic_enabled(ah))
value = ar9003_aic_calibration_single(ah);
-- 
2.3.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH v2 03/11] ath9k: Add register definitions for AIC

2015-03-13 Thread Sujith Manoharan
From: Sujith Manoharan c_man...@qca.qualcomm.com

Various registers to control and check AIC
status.

Signed-off-by: Sujith Manoharan c_man...@qca.qualcomm.com
---
 drivers/net/wireless/ath/ath9k/ar9003_aic.c |   1 +
 drivers/net/wireless/ath/ath9k/ar9003_phy.h |  25 -
 drivers/net/wireless/ath/ath9k/reg_aic.h| 168 
 3 files changed, 169 insertions(+), 25 deletions(-)
 create mode 100644 drivers/net/wireless/ath/ath9k/reg_aic.h

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_aic.c 
b/drivers/net/wireless/ath/ath9k/ar9003_aic.c
index 0cd159d..cc1e97b 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_aic.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_aic.c
@@ -18,6 +18,7 @@
 #include hw-ops.h
 #include ar9003_mci.h
 #include ar9003_aic.h
+#include reg_aic.h
 
 static bool ar9003_hw_is_aic_enabled(struct ath_hw *ah)
 {
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.h 
b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
index c311b2b..fc595b9 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.h
+++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
@@ -640,16 +640,6 @@
 #define AR_PHY_BB_THERM_ADC_4_LATEST_VOLT_VALUE0xff00
 #define AR_PHY_BB_THERM_ADC_4_LATEST_VOLT_VALUE_S  8
 
-/* AIC Registers */
-#define AR_PHY_AIC_CTRL_0_B0   (AR_SM_BASE + 0x4b0)
-#define AR_PHY_AIC_CTRL_1_B0   (AR_SM_BASE + 0x4b4)
-#define AR_PHY_AIC_CTRL_2_B0   (AR_SM_BASE + 0x4b8)
-#define AR_PHY_AIC_CTRL_3_B0   (AR_SM_BASE + 0x4bc)
-#define AR_PHY_AIC_STAT_0_B0   (AR_SM_BASE + 0x4c4))
-#define AR_PHY_AIC_STAT_1_B0   (AR_SM_BASE + 0x4c8))
-#define AR_PHY_AIC_CTRL_4_B0   (AR_SM_BASE + 0x4c0)
-#define AR_PHY_AIC_STAT_2_B0   (AR_SM_BASE + 0x4cc)
-
 #define AR_PHY_65NM_CH0_TXRF3   0x16048
 #define AR_PHY_65NM_CH0_TXRF3_CAPDIV2G 0x001e
 #define AR_PHY_65NM_CH0_TXRF3_CAPDIV2G_S   1
@@ -989,21 +979,6 @@
 #define AR_PHY_TX_IQCAL_STATUS_B1   (AR_SM1_BASE + 0x48c)
 #define AR_PHY_TX_IQCAL_CORR_COEFF_B1(_i)(AR_SM1_BASE + 0x450 + ((_i)  
2))
 
-/* SM 1 AIC Registers */
-
-#define AR_PHY_AIC_CTRL_0_B1   (AR_SM1_BASE + 0x4b0)
-#define AR_PHY_AIC_CTRL_1_B1   (AR_SM1_BASE + 0x4b4)
-#define AR_PHY_AIC_CTRL_2_B1   (AR_SM1_BASE + 0x4b8)
-#define AR_PHY_AIC_STAT_0_B1   (AR_SM1_BASE + (AR_SREV_9462_10(ah) ? \
-   0x4c0 : 0x4c4))
-#define AR_PHY_AIC_STAT_1_B1   (AR_SM1_BASE + (AR_SREV_9462_10(ah) ? \
-   0x4c4 : 0x4c8))
-#define AR_PHY_AIC_CTRL_4_B1   (AR_SM1_BASE + 0x4c0)
-#define AR_PHY_AIC_STAT_2_B1   (AR_SM1_BASE + 0x4cc)
-
-#define AR_PHY_AIC_SRAM_ADDR_B1(AR_SM1_BASE + 0x5f0)
-#define AR_PHY_AIC_SRAM_DATA_B1(AR_SM1_BASE + 0x5f4)
-
 #define AR_PHY_RTT_TABLE_SW_INTF_B(i)  (0x384 + ((i) ? \
AR_SM1_BASE : AR_SM_BASE))
 #define AR_PHY_RTT_TABLE_SW_INTF_1_B(i)(0x388 + ((i) ? \
diff --git a/drivers/net/wireless/ath/ath9k/reg_aic.h 
b/drivers/net/wireless/ath/ath9k/reg_aic.h
new file mode 100644
index 000..955147a
--- /dev/null
+++ b/drivers/net/wireless/ath/ath9k/reg_aic.h
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 2015 Qualcomm Atheros Inc.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef REG_AIC_H
+#define REG_AIC_H
+
+#define AR_SM_BASE  0xa200
+#define AR_SM1_BASE 0xb200
+#define AR_AGC_BASE 0x9e00
+
+#define AR_PHY_AIC_CTRL_0_B0(AR_SM_BASE + 0x4b0)
+#define AR_PHY_AIC_CTRL_1_B0(AR_SM_BASE + 0x4b4)
+#define AR_PHY_AIC_CTRL_2_B0(AR_SM_BASE + 0x4b8)
+#define AR_PHY_AIC_CTRL_3_B0(AR_SM_BASE + 0x4bc)
+#define AR_PHY_AIC_CTRL_4_B0(AR_SM_BASE + 0x4c0)
+
+#define AR_PHY_AIC_STAT_0_B0(AR_SM_BASE + 0x4c4)
+#define AR_PHY_AIC_STAT_1_B0(AR_SM_BASE + 0x4c8)
+#define AR_PHY_AIC_STAT_2_B0(AR_SM_BASE + 0x4cc)
+
+#define AR_PHY_AIC_CTRL_0_B1(AR_SM1_BASE + 0x4b0)
+#define AR_PHY_AIC_CTRL_1_B1(AR_SM1_BASE + 0x4b4)
+#define AR_PHY_AIC_CTRL_4_B1(AR_SM1_BASE + 0x4c0)
+
+#define AR_PHY_AIC_STAT_0_B1(AR_SM1_BASE + 0x4c4)
+#define

[ath9k-devel] [PATCH v2 04/11] ath9k: Handle MCI_STATE_AIC_CAL_SINGLE

2015-03-13 Thread Sujith Manoharan
From: Sujith Manoharan c_man...@qca.qualcomm.com

This patch adds routines to handle the MCI
message AIC_CAL_SINGLE, starting the required
HW calibration.

Signed-off-by: Sujith Manoharan c_man...@qca.qualcomm.com
---
 drivers/net/wireless/ath/ath9k/ar9003_aic.c | 169 
 drivers/net/wireless/ath/ath9k/ar9003_aic.h |   9 ++
 drivers/net/wireless/ath/ath9k/ar9003_mci.c |   4 +
 drivers/net/wireless/ath/ath9k/btcoex.h |   1 +
 4 files changed, 183 insertions(+)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_aic.c 
b/drivers/net/wireless/ath/ath9k/ar9003_aic.c
index cc1e97b..c2cfac3 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_aic.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_aic.c
@@ -30,6 +30,175 @@ static bool ar9003_hw_is_aic_enabled(struct ath_hw *ah)
return true;
 }
 
+static void ar9003_aic_gain_table(struct ath_hw *ah)
+{
+   u32 aic_atten_word[19], i;
+
+   /* Config LNA gain difference */
+   REG_WRITE(ah, AR_PHY_BT_COEX_4, 0x2c200a00);
+   REG_WRITE(ah, AR_PHY_BT_COEX_5, 0x5c4e4438);
+
+   /* Program gain table */
+   aic_atten_word[0] = (0x1  0xf)  14 | (0x1f  0x1f)  9 | (0x0  
0xf)  5 |
+   (0x1f  0x1f); /* -01 dB: 4'd1, 5'd31,  00 dB: 4'd0, 5'd31 */
+   aic_atten_word[1] = (0x3  0xf)  14 | (0x1f  0x1f)  9 | (0x2  
0xf)  5 |
+   (0x1f  0x1f); /* -03 dB: 4'd3, 5'd31, -02 dB: 4'd2, 5'd31 */
+   aic_atten_word[2] = (0x5  0xf)  14 | (0x1f  0x1f)  9 | (0x4  
0xf)  5 |
+   (0x1f  0x1f); /* -05 dB: 4'd5, 5'd31, -04 dB: 4'd4, 5'd31 */
+   aic_atten_word[3] = (0x1  0xf)  14 | (0x1e  0x1f)  9 | (0x0  
0xf)  5 |
+   (0x1e  0x1f); /* -07 dB: 4'd1, 5'd30, -06 dB: 4'd0, 5'd30 */
+   aic_atten_word[4] = (0x3  0xf)  14 | (0x1e  0x1f)  9 | (0x2  
0xf)  5 |
+   (0x1e  0x1f); /* -09 dB: 4'd3, 5'd30, -08 dB: 4'd2, 5'd30 */
+   aic_atten_word[5] = (0x5  0xf)  14 | (0x1e  0x1f)  9 | (0x4  
0xf)  5 |
+   (0x1e  0x1f); /* -11 dB: 4'd5, 5'd30, -10 dB: 4'd4, 5'd30 */
+   aic_atten_word[6] = (0x1  0xf)  14 | (0xf  0x1f)  9  | (0x0  
0xf)  5 |
+   (0xf  0x1f);  /* -13 dB: 4'd1, 5'd15, -12 dB: 4'd0, 5'd15 */
+   aic_atten_word[7] = (0x3  0xf)  14 | (0xf  0x1f)  9  | (0x2  
0xf)  5 |
+   (0xf  0x1f);  /* -15 dB: 4'd3, 5'd15, -14 dB: 4'd2, 5'd15 */
+   aic_atten_word[8] = (0x5  0xf)  14 | (0xf  0x1f)  9  | (0x4  
0xf)  5 |
+   (0xf  0x1f);  /* -17 dB: 4'd5, 5'd15, -16 dB: 4'd4, 5'd15 */
+   aic_atten_word[9] = (0x1  0xf)  14 | (0x7  0x1f)  9  | (0x0  
0xf)  5 |
+   (0x7  0x1f);  /* -19 dB: 4'd1, 5'd07, -18 dB: 4'd0, 5'd07 */
+   aic_atten_word[10] = (0x3  0xf)  14 | (0x7  0x1f)  9  | (0x2  
0xf)  5 |
+   (0x7  0x1f);  /* -21 dB: 4'd3, 5'd07, -20 dB: 4'd2, 5'd07 */
+   aic_atten_word[11] = (0x5  0xf)  14 | (0x7  0x1f)  9  | (0x4  
0xf)  5 |
+   (0x7  0x1f);  /* -23 dB: 4'd5, 5'd07, -22 dB: 4'd4, 5'd07 */
+   aic_atten_word[12] = (0x7  0xf)  14 | (0x7  0x1f)  9  | (0x6  
0xf)  5 |
+   (0x7  0x1f);  /* -25 dB: 4'd7, 5'd07, -24 dB: 4'd6, 5'd07 */
+   aic_atten_word[13] = (0x3  0xf)  14 | (0x3  0x1f)  9  | (0x2  
0xf)  5 |
+   (0x3  0x1f);  /* -27 dB: 4'd3, 5'd03, -26 dB: 4'd2, 5'd03 */
+   aic_atten_word[14] = (0x5  0xf)  14 | (0x3  0x1f)  9  | (0x4  
0xf)  5 |
+   (0x3  0x1f);  /* -29 dB: 4'd5, 5'd03, -28 dB: 4'd4, 5'd03 */
+   aic_atten_word[15] = (0x1  0xf)  14 | (0x1  0x1f)  9  | (0x0  
0xf)  5 |
+   (0x1  0x1f);  /* -31 dB: 4'd1, 5'd01, -30 dB: 4'd0, 5'd01 */
+   aic_atten_word[16] = (0x3  0xf)  14 | (0x1  0x1f)  9  | (0x2  
0xf)  5 |
+   (0x1  0x1f);  /* -33 dB: 4'd3, 5'd01, -32 dB: 4'd2, 5'd01 */
+   aic_atten_word[17] = (0x5  0xf)  14 | (0x1  0x1f)  9  | (0x4  
0xf)  5 |
+   (0x1  0x1f);  /* -35 dB: 4'd5, 5'd01, -34 dB: 4'd4, 5'd01 */
+   aic_atten_word[18] = (0x7  0xf)  14 | (0x1  0x1f)  9  | (0x6  
0xf)  5 |
+   (0x1  0x1f);  /* -37 dB: 4'd7, 5'd01, -36 dB: 4'd6, 5'd01 */
+
+   /* Write to Gain table with auto increment enabled. */
+   REG_WRITE(ah, (AR_PHY_AIC_SRAM_ADDR_B0 + 0x3000),
+ (ATH_AIC_SRAM_AUTO_INCREMENT |
+  ATH_AIC_SRAM_GAIN_TABLE_OFFSET));
+
+   for (i = 0; i  19; i++) {
+   REG_WRITE(ah, (AR_PHY_AIC_SRAM_DATA_B0 + 0x3000),
+ aic_atten_word[i]);
+   }
+}
+
+static void ar9003_aic_cal_start(struct ath_hw *ah, u8 min_valid_count)
+{
+   struct ath9k_hw_aic *aic = ah-btcoex_hw.aic;
+   int i;
+
+   /* Write to Gain table with auto increment enabled. */
+   REG_WRITE(ah, (AR_PHY_AIC_SRAM_ADDR_B0 + 0x3000),
+ (ATH_AIC_SRAM_AUTO_INCREMENT |
+  ATH_AIC_SRAM_CAL_OFFSET));
+
+   for (i = 0; i  ATH_AIC_MAX_BT_CHANNEL; i++) {
+   REG_WRITE(ah, (AR_PHY_AIC_SRAM_DATA_B0 + 0x3000), 0);
+   aic

[ath9k-devel] [PATCH v2 02/11] ath9k: Register private AIC ops

2015-03-13 Thread Sujith Manoharan
From: Sujith Manoharan c_man...@qca.qualcomm.com

AIC can be disabled or enabled on a per-card
basis using MCI configuration, so register a function
to check its status.

Signed-off-by: Sujith Manoharan c_man...@qca.qualcomm.com
---
 drivers/net/wireless/ath/ath9k/Makefile |  3 ++-
 drivers/net/wireless/ath/ath9k/ar9003_aic.c | 37 +
 drivers/net/wireless/ath/ath9k/ar9003_hw.c  |  1 +
 drivers/net/wireless/ath/ath9k/hw-ops.h |  8 +++
 drivers/net/wireless/ath/ath9k/hw.h |  6 +
 5 files changed, 54 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/wireless/ath/ath9k/ar9003_aic.c

diff --git a/drivers/net/wireless/ath/ath9k/Makefile 
b/drivers/net/wireless/ath/ath9k/Makefile
index 4739722..ecda613 100644
--- a/drivers/net/wireless/ath/ath9k/Makefile
+++ b/drivers/net/wireless/ath/ath9k/Makefile
@@ -46,7 +46,8 @@ ath9k_hw-y:=  \
 ath9k_hw-$(CONFIG_ATH9K_WOW) += ar9003_wow.o
 
 ath9k_hw-$(CONFIG_ATH9K_BTCOEX_SUPPORT) += btcoex.o \
-  ar9003_mci.o
+  ar9003_mci.o \
+  ar9003_aic.o
 
 ath9k_hw-$(CONFIG_ATH9K_PCOEM) += ar9003_rtt.o
 
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_aic.c 
b/drivers/net/wireless/ath/ath9k/ar9003_aic.c
new file mode 100644
index 000..0cd159d
--- /dev/null
+++ b/drivers/net/wireless/ath/ath9k/ar9003_aic.c
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2015 Qualcomm Atheros Inc.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include hw.h
+#include hw-ops.h
+#include ar9003_mci.h
+#include ar9003_aic.h
+
+static bool ar9003_hw_is_aic_enabled(struct ath_hw *ah)
+{
+   struct ath9k_hw_mci *mci_hw = ah-btcoex_hw.mci;
+
+   if (mci_hw-config  ATH_MCI_CONFIG_DISABLE_AIC)
+   return false;
+
+   return true;
+}
+
+void ar9003_hw_attach_aic_ops(struct ath_hw *ah)
+{
+   struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah);
+
+   priv_ops-is_aic_enabled = ar9003_hw_is_aic_enabled;
+}
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_hw.c 
b/drivers/net/wireless/ath/ath9k/ar9003_hw.c
index df176e6..79fd3b2 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_hw.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_hw.c
@@ -1180,4 +1180,5 @@ void ar9003_hw_attach_ops(struct ath_hw *ah)
ar9003_hw_attach_phy_ops(ah);
ar9003_hw_attach_calib_ops(ah);
ar9003_hw_attach_mac_ops(ah);
+   ar9003_hw_attach_aic_ops(ah);
 }
diff --git a/drivers/net/wireless/ath/ath9k/hw-ops.h 
b/drivers/net/wireless/ath/ath9k/hw-ops.h
index 88769b6..232339b 100644
--- a/drivers/net/wireless/ath/ath9k/hw-ops.h
+++ b/drivers/net/wireless/ath/ath9k/hw-ops.h
@@ -108,6 +108,14 @@ static inline void ath9k_hw_set_bt_ant_diversity(struct 
ath_hw *ah, bool enable)
ath9k_hw_ops(ah)-set_bt_ant_diversity(ah, enable);
 }
 
+static inline bool ath9k_hw_is_aic_enabled(struct ath_hw *ah)
+{
+   if (ath9k_hw_private_ops(ah)-is_aic_enabled)
+   return ath9k_hw_private_ops(ah)-is_aic_enabled(ah);
+
+   return false;
+}
+
 #endif
 
 /* Private hardware call ops */
diff --git a/drivers/net/wireless/ath/ath9k/hw.h 
b/drivers/net/wireless/ath/ath9k/hw.h
index 2067cb5..c22edd3 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -653,6 +653,10 @@ struct ath_hw_private_ops {
 
/* ANI */
void (*ani_cache_ini_regs)(struct ath_hw *ah);
+
+#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
+   bool (*is_aic_enabled)(struct ath_hw *ah);
+#endif /* CONFIG_ATH9K_BTCOEX_SUPPORT */
 };
 
 /**
@@ -1113,6 +1117,8 @@ void ar9003_hw_attach_calib_ops(struct ath_hw *ah);
 int ar9002_hw_attach_ops(struct ath_hw *ah);
 void ar9003_hw_attach_ops(struct ath_hw *ah);
 
+void ar9003_hw_attach_aic_ops(struct ath_hw *ah);
+
 void ar9002_hw_load_ani_reg(struct ath_hw *ah, struct ath9k_channel *chan);
 
 void ath9k_ani_reset(struct ath_hw *ah, bool is_scanning);
-- 
2.3.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH v2 01/11] ath9k: Add initial structures for AIC

2015-03-13 Thread Sujith Manoharan
From: Sujith Manoharan c_man...@qca.qualcomm.com

These are necessary for implementing AIC,
supported by chips like WB222.

Signed-off-by: Sujith Manoharan c_man...@qca.qualcomm.com
---
 drivers/net/wireless/ath/ath9k/ar9003_aic.h | 49 +
 drivers/net/wireless/ath/ath9k/btcoex.h | 11 +++
 2 files changed, 60 insertions(+)
 create mode 100644 drivers/net/wireless/ath/ath9k/ar9003_aic.h

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_aic.h 
b/drivers/net/wireless/ath/ath9k/ar9003_aic.h
new file mode 100644
index 000..b81d5d1
--- /dev/null
+++ b/drivers/net/wireless/ath/ath9k/ar9003_aic.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2015 Qualcomm Atheros Inc.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef AR9003_AIC_H
+#define AR9003_AIC_H
+
+#define ATH_AIC_MAX_COM_ATT_DB_TABLE6
+#define ATH_AIC_MAX_AIC_LIN_TABLE   69
+#define ATH_AIC_MIN_ROT_DIR_ATT_DB  0
+#define ATH_AIC_MIN_ROT_QUAD_ATT_DB 0
+#define ATH_AIC_MAX_ROT_DIR_ATT_DB  37
+#define ATH_AIC_MAX_ROT_QUAD_ATT_DB 37
+#define ATH_AIC_SRAM_AUTO_INCREMENT 0x8000
+#define ATH_AIC_SRAM_GAIN_TABLE_OFFSET  0x280
+#define ATH_AIC_SRAM_CAL_OFFSET 0x140
+#define ATH_AIC_SRAM_OFFSET 0x00
+#define ATH_AIC_MEAS_MAG_THRESH 20
+#define ATH_AIC_BT_JUPITER_CTRL 0x66820
+#define ATH_AIC_BT_AIC_ENABLE   0x02
+
+struct ath_aic_sram_info {
+   bool valid:1;
+   bool vga_quad_sign:1;
+   bool vga_dir_sign:1;
+   u8 rot_quad_att_db;
+   u8 rot_dir_att_db;
+   u8 com_att_6db;
+};
+
+struct ath_aic_out_info {
+   int16_t dir_path_gain_lin;
+   int16_t quad_path_gain_lin;
+   struct ath_aic_sram_info sram;
+};
+
+#endif /* AR9003_AIC_H */
diff --git a/drivers/net/wireless/ath/ath9k/btcoex.h 
b/drivers/net/wireless/ath/ath9k/btcoex.h
index 5fe62ff..b3ed738 100644
--- a/drivers/net/wireless/ath/ath9k/btcoex.h
+++ b/drivers/net/wireless/ath/ath9k/btcoex.h
@@ -44,6 +44,9 @@
 
 #define AR9300_NUM_BT_WEIGHTS   4
 #define AR9300_NUM_WLAN_WEIGHTS 4
+
+#define ATH_AIC_MAX_BT_CHANNEL  79
+
 /* Defines the BT AR_BT_COEX_WGHT used */
 enum ath_stomp_type {
ATH_BTCOEX_STOMP_ALL,
@@ -93,6 +96,14 @@ struct ath9k_hw_mci {
u32 last_recovery;
 };
 
+struct ath9k_hw_aic {
+   bool aic_enabled;
+   u8 aic_cal_state;
+   u8 aic_caled_chan;
+   u32 aic_sram[ATH_AIC_MAX_BT_CHANNEL];
+   u32 aic_cal_start_time;
+};
+
 struct ath_btcoex_hw {
enum ath_btcoex_scheme scheme;
struct ath9k_hw_mci mci;
-- 
2.3.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH v2 00/11] ath9k patches

2015-03-13 Thread Sujith Manoharan
From: Sujith Manoharan c_man...@qca.qualcomm.com

AIC support, for -next.

v2 : Address warning reported by Kalle:
 ar9003_aic.c: In function 'ar9003_aic_cal_post_process':
 ar9003_aic.c:431:1: warning: the frame size of 1312 bytes is larger than 
1024 bytes [-Wframe-larger-than=]

Sujith Manoharan (11):
  ath9k: Add initial structures for AIC
  ath9k: Register private AIC ops
  ath9k: Add register definitions for AIC
  ath9k: Handle MCI_STATE_AIC_CAL_SINGLE
  ath9k: Finish AIC calibration
  ath9k: Process the AIC calibration results
  ath9k: Disable AIC by default
  ath9k: Handle MCI_STATE_AIC_CAL_RESET
  ath9k: Handle MCI_STATE_AIC_START
  ath9k: Handle MCI_STATE_AIC_CAL
  ath9k: Start AIC calibration during MCI reset

 drivers/net/wireless/ath/ath9k/Makefile |   3 +-
 drivers/net/wireless/ath/ath9k/ar9003_aic.c | 599 
 drivers/net/wireless/ath/ath9k/ar9003_aic.h |  61 +++
 drivers/net/wireless/ath/ath9k/ar9003_hw.c  |   1 +
 drivers/net/wireless/ath/ath9k/ar9003_mci.c |  20 +
 drivers/net/wireless/ath/ath9k/ar9003_phy.h |  25 --
 drivers/net/wireless/ath/ath9k/btcoex.h |  12 +
 drivers/net/wireless/ath/ath9k/hw-ops.h |   8 +
 drivers/net/wireless/ath/ath9k/hw.h |   6 +
 drivers/net/wireless/ath/ath9k/reg_aic.h| 168 
 10 files changed, 877 insertions(+), 26 deletions(-)
 create mode 100644 drivers/net/wireless/ath/ath9k/ar9003_aic.c
 create mode 100644 drivers/net/wireless/ath/ath9k/ar9003_aic.h
 create mode 100644 drivers/net/wireless/ath/ath9k/reg_aic.h

-- 
2.3.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 2/4] ath9k: Handle MCI_STATE_AIC_START

2015-03-12 Thread Sujith Manoharan
From: Sujith Manoharan c_man...@qca.qualcomm.com

This patch adds a function to handle the
MCI message MCI_STATE_AIC_START.

Signed-off-by: Sujith Manoharan c_man...@qca.qualcomm.com
---
 drivers/net/wireless/ath/ath9k/ar9003_aic.c | 33 +
 drivers/net/wireless/ath/ath9k/ar9003_aic.h |  1 +
 drivers/net/wireless/ath/ath9k/ar9003_mci.c |  4 
 3 files changed, 38 insertions(+)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_aic.c 
b/drivers/net/wireless/ath/ath9k/ar9003_aic.c
index 4e8cf08..5b4f818 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_aic.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_aic.c
@@ -18,6 +18,7 @@
 #include hw-ops.h
 #include ar9003_mci.h
 #include ar9003_aic.h
+#include ar9003_phy.h
 #include reg_aic.h
 
 static const u8 com_att_db_table[ATH_AIC_MAX_COM_ATT_DB_TABLE] = {
@@ -512,6 +513,38 @@ exit:
 
 }
 
+u8 ar9003_aic_start_normal(struct ath_hw *ah)
+{
+   struct ath9k_hw_aic *aic = ah-btcoex_hw.aic;
+   int16_t i;
+
+   if (aic-aic_cal_state != AIC_CAL_STATE_DONE)
+   return 1;
+
+   ar9003_aic_gain_table(ah);
+
+   REG_WRITE(ah, AR_PHY_AIC_SRAM_ADDR_B1, ATH_AIC_SRAM_AUTO_INCREMENT);
+
+   for (i = 0; i  ATH_AIC_MAX_BT_CHANNEL; i++) {
+   REG_WRITE(ah, AR_PHY_AIC_SRAM_DATA_B1, aic-aic_sram[i]);
+   }
+
+   /* FIXME: Replace these with proper register names */
+   REG_WRITE(ah, 0xa6b0, 0x80);
+   REG_WRITE(ah, 0xa6b4, 0x5b2df0);
+   REG_WRITE(ah, 0xa6b8, 0x10762cc8);
+   REG_WRITE(ah, 0xa6bc, 0x1219a4b);
+   REG_WRITE(ah, 0xa6c0, 0x1e01);
+   REG_WRITE(ah, 0xb6b4, 0xf0);
+   REG_WRITE(ah, 0xb6c0, 0x1e01);
+   REG_WRITE(ah, 0xb6b0, 0x81);
+   REG_WRITE(ah, AR_PHY_65NM_CH1_RXTX4, 0x4000);
+
+   aic-aic_enabled = true;
+
+   return 0;
+}
+
 u8 ar9003_aic_cal_reset(struct ath_hw *ah)
 {
struct ath9k_hw_aic *aic = ah-btcoex_hw.aic;
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_aic.h 
b/drivers/net/wireless/ath/ath9k/ar9003_aic.h
index 5e48710..1ee5a8c 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_aic.h
+++ b/drivers/net/wireless/ath/ath9k/ar9003_aic.h
@@ -53,6 +53,7 @@ struct ath_aic_out_info {
struct ath_aic_sram_info sram;
 };
 
+u8 ar9003_aic_start_normal(struct ath_hw *ah);
 u8 ar9003_aic_cal_reset(struct ath_hw *ah);
 u8 ar9003_aic_calibration_single(struct ath_hw *ah);
 
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mci.c 
b/drivers/net/wireless/ath/ath9k/ar9003_mci.c
index d6ed628..b559d75 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_mci.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_mci.c
@@ -1363,6 +1363,10 @@ u32 ar9003_mci_state(struct ath_hw *ah, u32 state_type)
value = (!mci-unhalt_bt_gpm  mci-need_flush_btinfo) ? 1 : 0;
mci-need_flush_btinfo = false;
break;
+   case MCI_STATE_AIC_START:
+   if (ath9k_hw_is_aic_enabled(ah))
+   ar9003_aic_start_normal(ah);
+   break;
case MCI_STATE_AIC_CAL_RESET:
if (ath9k_hw_is_aic_enabled(ah))
value = ar9003_aic_cal_reset(ah);
-- 
2.3.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 0/4] ath9k patches

2015-03-12 Thread Sujith Manoharan
From: Sujith Manoharan c_man...@qca.qualcomm.com

More support for AIC, for -next.

Sujith Manoharan (4):
  ath9k: Handle MCI_STATE_AIC_CAL_RESET
  ath9k: Handle MCI_STATE_AIC_START
  ath9k: Handle MCI_STATE_AIC_CAL
  ath9k: Start AIC calibration during MCI reset

 drivers/net/wireless/ath/ath9k/ar9003_aic.c | 69 -
 drivers/net/wireless/ath/ath9k/ar9003_aic.h |  3 ++
 drivers/net/wireless/ath/ath9k/ar9003_mci.c | 15 +++
 3 files changed, 85 insertions(+), 2 deletions(-)

-- 
2.3.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 4/4] ath9k: Start AIC calibration during MCI reset

2015-03-12 Thread Sujith Manoharan
From: Sujith Manoharan c_man...@qca.qualcomm.com

When a MCI reset is done, make sure that AIC
is started.

Signed-off-by: Sujith Manoharan c_man...@qca.qualcomm.com
---
 drivers/net/wireless/ath/ath9k/ar9003_mci.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mci.c 
b/drivers/net/wireless/ath/ath9k/ar9003_mci.c
index cdd83d4..af5ee41 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_mci.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_mci.c
@@ -1017,6 +1017,9 @@ int ar9003_mci_reset(struct ath_hw *ah, bool en_int, bool 
is_2g,
if (en_int)
ar9003_mci_enable_interrupt(ah);
 
+   if (ath9k_hw_is_aic_enabled(ah))
+   ar9003_aic_start_normal(ah);
+
return 0;
 }
 
-- 
2.3.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 1/4] ath9k: Handle MCI_STATE_AIC_CAL_RESET

2015-03-12 Thread Sujith Manoharan
From: Sujith Manoharan c_man...@qca.qualcomm.com

Add a routine to handle the MCI_STATE_AIC_CAL_RESET
message.

Signed-off-by: Sujith Manoharan c_man...@qca.qualcomm.com
---
 drivers/net/wireless/ath/ath9k/ar9003_aic.c | 8 
 drivers/net/wireless/ath/ath9k/ar9003_aic.h | 1 +
 drivers/net/wireless/ath/ath9k/ar9003_mci.c | 4 
 3 files changed, 13 insertions(+)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_aic.c 
b/drivers/net/wireless/ath/ath9k/ar9003_aic.c
index 7bdbc7a..4e8cf08 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_aic.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_aic.c
@@ -512,6 +512,14 @@ exit:
 
 }
 
+u8 ar9003_aic_cal_reset(struct ath_hw *ah)
+{
+   struct ath9k_hw_aic *aic = ah-btcoex_hw.aic;
+
+   aic-aic_cal_state = AIC_CAL_STATE_IDLE;
+   return aic-aic_cal_state;
+}
+
 u8 ar9003_aic_calibration_single(struct ath_hw *ah)
 {
struct ath9k_hw_mci *mci_hw = ah-btcoex_hw.mci;
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_aic.h 
b/drivers/net/wireless/ath/ath9k/ar9003_aic.h
index 9651bcd..5e48710 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_aic.h
+++ b/drivers/net/wireless/ath/ath9k/ar9003_aic.h
@@ -53,6 +53,7 @@ struct ath_aic_out_info {
struct ath_aic_sram_info sram;
 };
 
+u8 ar9003_aic_cal_reset(struct ath_hw *ah);
 u8 ar9003_aic_calibration_single(struct ath_hw *ah);
 
 #endif /* AR9003_AIC_H */
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mci.c 
b/drivers/net/wireless/ath/ath9k/ar9003_mci.c
index 6fa98e5..d6ed628 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_mci.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_mci.c
@@ -1363,6 +1363,10 @@ u32 ar9003_mci_state(struct ath_hw *ah, u32 state_type)
value = (!mci-unhalt_bt_gpm  mci-need_flush_btinfo) ? 1 : 0;
mci-need_flush_btinfo = false;
break;
+   case MCI_STATE_AIC_CAL_RESET:
+   if (ath9k_hw_is_aic_enabled(ah))
+   value = ar9003_aic_cal_reset(ah);
+   break;
case MCI_STATE_AIC_CAL_SINGLE:
if (ath9k_hw_is_aic_enabled(ah))
value = ar9003_aic_calibration_single(ah);
-- 
2.3.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 3/4] ath9k: Handle MCI_STATE_AIC_CAL

2015-03-12 Thread Sujith Manoharan
From: Sujith Manoharan c_man...@qca.qualcomm.com

Add the main AIC calibration function to
handle MCI_STATE_AIC_CAL.

Signed-off-by: Sujith Manoharan c_man...@qca.qualcomm.com
---
 drivers/net/wireless/ath/ath9k/ar9003_aic.c | 28 ++--
 drivers/net/wireless/ath/ath9k/ar9003_aic.h |  1 +
 drivers/net/wireless/ath/ath9k/ar9003_mci.c |  4 
 3 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_aic.c 
b/drivers/net/wireless/ath/ath9k/ar9003_aic.c
index 5b4f818..1db119d 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_aic.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_aic.c
@@ -162,7 +162,7 @@ static void ar9003_aic_gain_table(struct ath_hw *ah)
}
 }
 
-static void ar9003_aic_cal_start(struct ath_hw *ah, u8 min_valid_count)
+static u8 ar9003_aic_cal_start(struct ath_hw *ah, u8 min_valid_count)
 {
struct ath9k_hw_aic *aic = ah-btcoex_hw.aic;
int i;
@@ -257,6 +257,8 @@ static void ar9003_aic_cal_start(struct ath_hw *ah, u8 
min_valid_count)
 
aic-aic_caled_chan = 0;
aic-aic_cal_state = AIC_CAL_STATE_STARTED;
+
+   return aic-aic_cal_state;
 }
 
 static bool ar9003_aic_cal_post_process(struct ath_hw *ah)
@@ -513,6 +515,28 @@ exit:
 
 }
 
+u8 ar9003_aic_calibration(struct ath_hw *ah)
+{
+   struct ath9k_hw_aic *aic = ah-btcoex_hw.aic;
+   u8 cal_ret = AIC_CAL_STATE_ERROR;
+
+   switch (aic-aic_cal_state) {
+   case AIC_CAL_STATE_IDLE:
+   cal_ret = ar9003_aic_cal_start(ah, 1);
+   break;
+   case AIC_CAL_STATE_STARTED:
+   cal_ret = ar9003_aic_cal_continue(ah, false);
+   break;
+   case AIC_CAL_STATE_DONE:
+   cal_ret = AIC_CAL_STATE_DONE;
+   break;
+   default:
+   break;
+   }
+
+   return cal_ret;
+}
+
 u8 ar9003_aic_start_normal(struct ath_hw *ah)
 {
struct ath9k_hw_aic *aic = ah-btcoex_hw.aic;
@@ -561,7 +585,7 @@ u8 ar9003_aic_calibration_single(struct ath_hw *ah)
 
num_chan = MS(mci_hw-config, ATH_MCI_CONFIG_AIC_CAL_NUM_CHAN);
 
-   ar9003_aic_cal_start(ah, num_chan);
+   (void) ar9003_aic_cal_start(ah, num_chan);
cal_ret = ar9003_aic_cal_continue(ah, true);
 
return cal_ret;
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_aic.h 
b/drivers/net/wireless/ath/ath9k/ar9003_aic.h
index 1ee5a8c..509d1f5 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_aic.h
+++ b/drivers/net/wireless/ath/ath9k/ar9003_aic.h
@@ -53,6 +53,7 @@ struct ath_aic_out_info {
struct ath_aic_sram_info sram;
 };
 
+u8 ar9003_aic_calibration(struct ath_hw *ah);
 u8 ar9003_aic_start_normal(struct ath_hw *ah);
 u8 ar9003_aic_cal_reset(struct ath_hw *ah);
 u8 ar9003_aic_calibration_single(struct ath_hw *ah);
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mci.c 
b/drivers/net/wireless/ath/ath9k/ar9003_mci.c
index b559d75..cdd83d4 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_mci.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_mci.c
@@ -1363,6 +1363,10 @@ u32 ar9003_mci_state(struct ath_hw *ah, u32 state_type)
value = (!mci-unhalt_bt_gpm  mci-need_flush_btinfo) ? 1 : 0;
mci-need_flush_btinfo = false;
break;
+   case MCI_STATE_AIC_CAL:
+   if (ath9k_hw_is_aic_enabled(ah))
+   value = ar9003_aic_calibration(ah);
+   break;
case MCI_STATE_AIC_START:
if (ath9k_hw_is_aic_enabled(ah))
ar9003_aic_start_normal(ah);
-- 
2.3.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 2/7] ath9k: Register private AIC ops

2015-03-10 Thread Sujith Manoharan
From: Sujith Manoharan c_man...@qca.qualcomm.com

AIC can be disabled or enabled on a per-card
basis using MCI configuration, so register a function
to check its status.

Signed-off-by: Sujith Manoharan c_man...@qca.qualcomm.com
---
 drivers/net/wireless/ath/ath9k/Makefile |  3 ++-
 drivers/net/wireless/ath/ath9k/ar9003_aic.c | 37 +
 drivers/net/wireless/ath/ath9k/ar9003_hw.c  |  1 +
 drivers/net/wireless/ath/ath9k/hw-ops.h |  8 +++
 drivers/net/wireless/ath/ath9k/hw.h |  6 +
 5 files changed, 54 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/wireless/ath/ath9k/ar9003_aic.c

diff --git a/drivers/net/wireless/ath/ath9k/Makefile 
b/drivers/net/wireless/ath/ath9k/Makefile
index 4739722..ecda613 100644
--- a/drivers/net/wireless/ath/ath9k/Makefile
+++ b/drivers/net/wireless/ath/ath9k/Makefile
@@ -46,7 +46,8 @@ ath9k_hw-y:=  \
 ath9k_hw-$(CONFIG_ATH9K_WOW) += ar9003_wow.o
 
 ath9k_hw-$(CONFIG_ATH9K_BTCOEX_SUPPORT) += btcoex.o \
-  ar9003_mci.o
+  ar9003_mci.o \
+  ar9003_aic.o
 
 ath9k_hw-$(CONFIG_ATH9K_PCOEM) += ar9003_rtt.o
 
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_aic.c 
b/drivers/net/wireless/ath/ath9k/ar9003_aic.c
new file mode 100644
index 000..0cd159d
--- /dev/null
+++ b/drivers/net/wireless/ath/ath9k/ar9003_aic.c
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2015 Qualcomm Atheros Inc.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include hw.h
+#include hw-ops.h
+#include ar9003_mci.h
+#include ar9003_aic.h
+
+static bool ar9003_hw_is_aic_enabled(struct ath_hw *ah)
+{
+   struct ath9k_hw_mci *mci_hw = ah-btcoex_hw.mci;
+
+   if (mci_hw-config  ATH_MCI_CONFIG_DISABLE_AIC)
+   return false;
+
+   return true;
+}
+
+void ar9003_hw_attach_aic_ops(struct ath_hw *ah)
+{
+   struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah);
+
+   priv_ops-is_aic_enabled = ar9003_hw_is_aic_enabled;
+}
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_hw.c 
b/drivers/net/wireless/ath/ath9k/ar9003_hw.c
index df176e6..79fd3b2 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_hw.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_hw.c
@@ -1180,4 +1180,5 @@ void ar9003_hw_attach_ops(struct ath_hw *ah)
ar9003_hw_attach_phy_ops(ah);
ar9003_hw_attach_calib_ops(ah);
ar9003_hw_attach_mac_ops(ah);
+   ar9003_hw_attach_aic_ops(ah);
 }
diff --git a/drivers/net/wireless/ath/ath9k/hw-ops.h 
b/drivers/net/wireless/ath/ath9k/hw-ops.h
index 88769b6..232339b 100644
--- a/drivers/net/wireless/ath/ath9k/hw-ops.h
+++ b/drivers/net/wireless/ath/ath9k/hw-ops.h
@@ -108,6 +108,14 @@ static inline void ath9k_hw_set_bt_ant_diversity(struct 
ath_hw *ah, bool enable)
ath9k_hw_ops(ah)-set_bt_ant_diversity(ah, enable);
 }
 
+static inline bool ath9k_hw_is_aic_enabled(struct ath_hw *ah)
+{
+   if (ath9k_hw_private_ops(ah)-is_aic_enabled)
+   return ath9k_hw_private_ops(ah)-is_aic_enabled(ah);
+
+   return false;
+}
+
 #endif
 
 /* Private hardware call ops */
diff --git a/drivers/net/wireless/ath/ath9k/hw.h 
b/drivers/net/wireless/ath/ath9k/hw.h
index 2067cb5..c22edd3 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -653,6 +653,10 @@ struct ath_hw_private_ops {
 
/* ANI */
void (*ani_cache_ini_regs)(struct ath_hw *ah);
+
+#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
+   bool (*is_aic_enabled)(struct ath_hw *ah);
+#endif /* CONFIG_ATH9K_BTCOEX_SUPPORT */
 };
 
 /**
@@ -1113,6 +1117,8 @@ void ar9003_hw_attach_calib_ops(struct ath_hw *ah);
 int ar9002_hw_attach_ops(struct ath_hw *ah);
 void ar9003_hw_attach_ops(struct ath_hw *ah);
 
+void ar9003_hw_attach_aic_ops(struct ath_hw *ah);
+
 void ar9002_hw_load_ani_reg(struct ath_hw *ah, struct ath9k_channel *chan);
 
 void ath9k_ani_reset(struct ath_hw *ah, bool is_scanning);
-- 
2.3.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 1/7] ath9k: Add initial structures for AIC

2015-03-10 Thread Sujith Manoharan
From: Sujith Manoharan c_man...@qca.qualcomm.com

These are necessary for implementing AIC,
supported by chips like WB222.

Signed-off-by: Sujith Manoharan c_man...@qca.qualcomm.com
---
 drivers/net/wireless/ath/ath9k/ar9003_aic.h | 49 +
 drivers/net/wireless/ath/ath9k/btcoex.h | 11 +++
 2 files changed, 60 insertions(+)
 create mode 100644 drivers/net/wireless/ath/ath9k/ar9003_aic.h

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_aic.h 
b/drivers/net/wireless/ath/ath9k/ar9003_aic.h
new file mode 100644
index 000..d1adb49
--- /dev/null
+++ b/drivers/net/wireless/ath/ath9k/ar9003_aic.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2015 Qualcomm Atheros Inc.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef AR9003_AIC_H
+#define AR9003_AIC_H
+
+#define ATH_AIC_MAX_COM_ATT_DB_TABLE6
+#define ATH_AIC_MAX_AIC_LIN_TABLE   69
+#define ATH_AIC_MIN_ROT_DIR_ATT_DB  0
+#define ATH_AIC_MIN_ROT_QUAD_ATT_DB 0
+#define ATH_AIC_MAX_ROT_DIR_ATT_DB  37
+#define ATH_AIC_MAX_ROT_QUAD_ATT_DB 37
+#define ATH_AIC_SRAM_AUTO_INCREMENT 0x8000
+#define ATH_AIC_SRAM_GAIN_TABLE_OFFSET  0x280
+#define ATH_AIC_SRAM_CAL_OFFSET 0x140
+#define ATH_AIC_SRAM_OFFSET 0x00
+#define ATH_AIC_MEAS_MAG_THRESH 20
+#define ATH_AIC_BT_JUPITER_CTRL 0x66820
+#define ATH_AIC_BT_AIC_ENABLE   0x02
+
+struct ath_aic_sram_info {
+   bool valid;
+   u8 rot_quad_att_db;
+   bool vga_quad_sign;
+   u8 rot_dir_att_db;
+   bool vga_dir_sign;
+   u8 com_att_6db;
+};
+
+struct ath_aic_out_info {
+   int16_t dir_path_gain_lin;
+   int16_t quad_path_gain_lin;
+   struct ath_aic_sram_info sram;
+};
+
+#endif /* AR9003_AIC_H */
diff --git a/drivers/net/wireless/ath/ath9k/btcoex.h 
b/drivers/net/wireless/ath/ath9k/btcoex.h
index 5fe62ff..b3ed738 100644
--- a/drivers/net/wireless/ath/ath9k/btcoex.h
+++ b/drivers/net/wireless/ath/ath9k/btcoex.h
@@ -44,6 +44,9 @@
 
 #define AR9300_NUM_BT_WEIGHTS   4
 #define AR9300_NUM_WLAN_WEIGHTS 4
+
+#define ATH_AIC_MAX_BT_CHANNEL  79
+
 /* Defines the BT AR_BT_COEX_WGHT used */
 enum ath_stomp_type {
ATH_BTCOEX_STOMP_ALL,
@@ -93,6 +96,14 @@ struct ath9k_hw_mci {
u32 last_recovery;
 };
 
+struct ath9k_hw_aic {
+   bool aic_enabled;
+   u8 aic_cal_state;
+   u8 aic_caled_chan;
+   u32 aic_sram[ATH_AIC_MAX_BT_CHANNEL];
+   u32 aic_cal_start_time;
+};
+
 struct ath_btcoex_hw {
enum ath_btcoex_scheme scheme;
struct ath9k_hw_mci mci;
-- 
2.3.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 3/7] ath9k: Add register definitions for AIC

2015-03-10 Thread Sujith Manoharan
From: Sujith Manoharan c_man...@qca.qualcomm.com

Various registers to control and check AIC
status.

Signed-off-by: Sujith Manoharan c_man...@qca.qualcomm.com
---
 drivers/net/wireless/ath/ath9k/ar9003_aic.c |   1 +
 drivers/net/wireless/ath/ath9k/ar9003_phy.h |  25 -
 drivers/net/wireless/ath/ath9k/reg_aic.h| 168 
 3 files changed, 169 insertions(+), 25 deletions(-)
 create mode 100644 drivers/net/wireless/ath/ath9k/reg_aic.h

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_aic.c 
b/drivers/net/wireless/ath/ath9k/ar9003_aic.c
index 0cd159d..cc1e97b 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_aic.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_aic.c
@@ -18,6 +18,7 @@
 #include hw-ops.h
 #include ar9003_mci.h
 #include ar9003_aic.h
+#include reg_aic.h
 
 static bool ar9003_hw_is_aic_enabled(struct ath_hw *ah)
 {
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.h 
b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
index c311b2b..fc595b9 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.h
+++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
@@ -640,16 +640,6 @@
 #define AR_PHY_BB_THERM_ADC_4_LATEST_VOLT_VALUE0xff00
 #define AR_PHY_BB_THERM_ADC_4_LATEST_VOLT_VALUE_S  8
 
-/* AIC Registers */
-#define AR_PHY_AIC_CTRL_0_B0   (AR_SM_BASE + 0x4b0)
-#define AR_PHY_AIC_CTRL_1_B0   (AR_SM_BASE + 0x4b4)
-#define AR_PHY_AIC_CTRL_2_B0   (AR_SM_BASE + 0x4b8)
-#define AR_PHY_AIC_CTRL_3_B0   (AR_SM_BASE + 0x4bc)
-#define AR_PHY_AIC_STAT_0_B0   (AR_SM_BASE + 0x4c4))
-#define AR_PHY_AIC_STAT_1_B0   (AR_SM_BASE + 0x4c8))
-#define AR_PHY_AIC_CTRL_4_B0   (AR_SM_BASE + 0x4c0)
-#define AR_PHY_AIC_STAT_2_B0   (AR_SM_BASE + 0x4cc)
-
 #define AR_PHY_65NM_CH0_TXRF3   0x16048
 #define AR_PHY_65NM_CH0_TXRF3_CAPDIV2G 0x001e
 #define AR_PHY_65NM_CH0_TXRF3_CAPDIV2G_S   1
@@ -989,21 +979,6 @@
 #define AR_PHY_TX_IQCAL_STATUS_B1   (AR_SM1_BASE + 0x48c)
 #define AR_PHY_TX_IQCAL_CORR_COEFF_B1(_i)(AR_SM1_BASE + 0x450 + ((_i)  
2))
 
-/* SM 1 AIC Registers */
-
-#define AR_PHY_AIC_CTRL_0_B1   (AR_SM1_BASE + 0x4b0)
-#define AR_PHY_AIC_CTRL_1_B1   (AR_SM1_BASE + 0x4b4)
-#define AR_PHY_AIC_CTRL_2_B1   (AR_SM1_BASE + 0x4b8)
-#define AR_PHY_AIC_STAT_0_B1   (AR_SM1_BASE + (AR_SREV_9462_10(ah) ? \
-   0x4c0 : 0x4c4))
-#define AR_PHY_AIC_STAT_1_B1   (AR_SM1_BASE + (AR_SREV_9462_10(ah) ? \
-   0x4c4 : 0x4c8))
-#define AR_PHY_AIC_CTRL_4_B1   (AR_SM1_BASE + 0x4c0)
-#define AR_PHY_AIC_STAT_2_B1   (AR_SM1_BASE + 0x4cc)
-
-#define AR_PHY_AIC_SRAM_ADDR_B1(AR_SM1_BASE + 0x5f0)
-#define AR_PHY_AIC_SRAM_DATA_B1(AR_SM1_BASE + 0x5f4)
-
 #define AR_PHY_RTT_TABLE_SW_INTF_B(i)  (0x384 + ((i) ? \
AR_SM1_BASE : AR_SM_BASE))
 #define AR_PHY_RTT_TABLE_SW_INTF_1_B(i)(0x388 + ((i) ? \
diff --git a/drivers/net/wireless/ath/ath9k/reg_aic.h 
b/drivers/net/wireless/ath/ath9k/reg_aic.h
new file mode 100644
index 000..955147a
--- /dev/null
+++ b/drivers/net/wireless/ath/ath9k/reg_aic.h
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 2015 Qualcomm Atheros Inc.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef REG_AIC_H
+#define REG_AIC_H
+
+#define AR_SM_BASE  0xa200
+#define AR_SM1_BASE 0xb200
+#define AR_AGC_BASE 0x9e00
+
+#define AR_PHY_AIC_CTRL_0_B0(AR_SM_BASE + 0x4b0)
+#define AR_PHY_AIC_CTRL_1_B0(AR_SM_BASE + 0x4b4)
+#define AR_PHY_AIC_CTRL_2_B0(AR_SM_BASE + 0x4b8)
+#define AR_PHY_AIC_CTRL_3_B0(AR_SM_BASE + 0x4bc)
+#define AR_PHY_AIC_CTRL_4_B0(AR_SM_BASE + 0x4c0)
+
+#define AR_PHY_AIC_STAT_0_B0(AR_SM_BASE + 0x4c4)
+#define AR_PHY_AIC_STAT_1_B0(AR_SM_BASE + 0x4c8)
+#define AR_PHY_AIC_STAT_2_B0(AR_SM_BASE + 0x4cc)
+
+#define AR_PHY_AIC_CTRL_0_B1(AR_SM1_BASE + 0x4b0)
+#define AR_PHY_AIC_CTRL_1_B1(AR_SM1_BASE + 0x4b4)
+#define AR_PHY_AIC_CTRL_4_B1(AR_SM1_BASE + 0x4c0)
+
+#define AR_PHY_AIC_STAT_0_B1(AR_SM1_BASE + 0x4c4)
+#define

Re: [ath9k-devel] [PATCH 0/7] ath9k patches

2015-03-10 Thread Sujith Manoharan
Hi Kalle,

Sorry, I forgot to mention that this is intended for -next.

Sujith

Sujith Manoharan wrote:
 From: Sujith Manoharan c_man...@qca.qualcomm.com
 
 This series adds initial support for AIC.
 
 Active Interference Cancellation is a method
 implemented in the HW to counter WLAN RX
 sensitivity degradation when BT is transmitting
 at the same time. This feature is supported by
 cards like WB222 based on AR9462.
 
 Sujith Manoharan (7):
   ath9k: Add initial structures for AIC
   ath9k: Register private AIC ops
   ath9k: Add register definitions for AIC
   ath9k: Handle MCI_STATE_AIC_CAL_SINGLE
   ath9k: Finish AIC calibration
   ath9k: Process the AIC calibration results
   ath9k: Disable AIC by default
 
  drivers/net/wireless/ath/ath9k/Makefile |   3 +-
  drivers/net/wireless/ath/ath9k/ar9003_aic.c | 534 
 
  drivers/net/wireless/ath/ath9k/ar9003_aic.h |  58 +++
  drivers/net/wireless/ath/ath9k/ar9003_hw.c  |   1 +
  drivers/net/wireless/ath/ath9k/ar9003_mci.c |   5 +
  drivers/net/wireless/ath/ath9k/ar9003_phy.h |  25 --
  drivers/net/wireless/ath/ath9k/btcoex.h |  12 +
  drivers/net/wireless/ath/ath9k/hw-ops.h |   8 +
  drivers/net/wireless/ath/ath9k/hw.h |   6 +
  drivers/net/wireless/ath/ath9k/reg_aic.h| 168 +
  10 files changed, 794 insertions(+), 26 deletions(-)
  create mode 100644 drivers/net/wireless/ath/ath9k/ar9003_aic.c
  create mode 100644 drivers/net/wireless/ath/ath9k/ar9003_aic.h
  create mode 100644 drivers/net/wireless/ath/ath9k/reg_aic.h
 
 -- 
 2.3.1
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-wireless in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 0/7] ath9k patches

2015-03-10 Thread Sujith Manoharan
From: Sujith Manoharan c_man...@qca.qualcomm.com

This series adds initial support for AIC.

Active Interference Cancellation is a method
implemented in the HW to counter WLAN RX
sensitivity degradation when BT is transmitting
at the same time. This feature is supported by
cards like WB222 based on AR9462.

Sujith Manoharan (7):
  ath9k: Add initial structures for AIC
  ath9k: Register private AIC ops
  ath9k: Add register definitions for AIC
  ath9k: Handle MCI_STATE_AIC_CAL_SINGLE
  ath9k: Finish AIC calibration
  ath9k: Process the AIC calibration results
  ath9k: Disable AIC by default

 drivers/net/wireless/ath/ath9k/Makefile |   3 +-
 drivers/net/wireless/ath/ath9k/ar9003_aic.c | 534 
 drivers/net/wireless/ath/ath9k/ar9003_aic.h |  58 +++
 drivers/net/wireless/ath/ath9k/ar9003_hw.c  |   1 +
 drivers/net/wireless/ath/ath9k/ar9003_mci.c |   5 +
 drivers/net/wireless/ath/ath9k/ar9003_phy.h |  25 --
 drivers/net/wireless/ath/ath9k/btcoex.h |  12 +
 drivers/net/wireless/ath/ath9k/hw-ops.h |   8 +
 drivers/net/wireless/ath/ath9k/hw.h |   6 +
 drivers/net/wireless/ath/ath9k/reg_aic.h| 168 +
 10 files changed, 794 insertions(+), 26 deletions(-)
 create mode 100644 drivers/net/wireless/ath/ath9k/ar9003_aic.c
 create mode 100644 drivers/net/wireless/ath/ath9k/ar9003_aic.h
 create mode 100644 drivers/net/wireless/ath/ath9k/reg_aic.h

-- 
2.3.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 4/7] ath9k: Handle MCI_STATE_AIC_CAL_SINGLE

2015-03-10 Thread Sujith Manoharan
From: Sujith Manoharan c_man...@qca.qualcomm.com

This patch adds routines to handle the MCI
message AIC_CAL_SINGLE, starting the required
HW calibration.

Signed-off-by: Sujith Manoharan c_man...@qca.qualcomm.com
---
 drivers/net/wireless/ath/ath9k/ar9003_aic.c | 169 
 drivers/net/wireless/ath/ath9k/ar9003_aic.h |   9 ++
 drivers/net/wireless/ath/ath9k/ar9003_mci.c |   4 +
 drivers/net/wireless/ath/ath9k/btcoex.h |   1 +
 4 files changed, 183 insertions(+)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_aic.c 
b/drivers/net/wireless/ath/ath9k/ar9003_aic.c
index cc1e97b..c2cfac3 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_aic.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_aic.c
@@ -30,6 +30,175 @@ static bool ar9003_hw_is_aic_enabled(struct ath_hw *ah)
return true;
 }
 
+static void ar9003_aic_gain_table(struct ath_hw *ah)
+{
+   u32 aic_atten_word[19], i;
+
+   /* Config LNA gain difference */
+   REG_WRITE(ah, AR_PHY_BT_COEX_4, 0x2c200a00);
+   REG_WRITE(ah, AR_PHY_BT_COEX_5, 0x5c4e4438);
+
+   /* Program gain table */
+   aic_atten_word[0] = (0x1  0xf)  14 | (0x1f  0x1f)  9 | (0x0  
0xf)  5 |
+   (0x1f  0x1f); /* -01 dB: 4'd1, 5'd31,  00 dB: 4'd0, 5'd31 */
+   aic_atten_word[1] = (0x3  0xf)  14 | (0x1f  0x1f)  9 | (0x2  
0xf)  5 |
+   (0x1f  0x1f); /* -03 dB: 4'd3, 5'd31, -02 dB: 4'd2, 5'd31 */
+   aic_atten_word[2] = (0x5  0xf)  14 | (0x1f  0x1f)  9 | (0x4  
0xf)  5 |
+   (0x1f  0x1f); /* -05 dB: 4'd5, 5'd31, -04 dB: 4'd4, 5'd31 */
+   aic_atten_word[3] = (0x1  0xf)  14 | (0x1e  0x1f)  9 | (0x0  
0xf)  5 |
+   (0x1e  0x1f); /* -07 dB: 4'd1, 5'd30, -06 dB: 4'd0, 5'd30 */
+   aic_atten_word[4] = (0x3  0xf)  14 | (0x1e  0x1f)  9 | (0x2  
0xf)  5 |
+   (0x1e  0x1f); /* -09 dB: 4'd3, 5'd30, -08 dB: 4'd2, 5'd30 */
+   aic_atten_word[5] = (0x5  0xf)  14 | (0x1e  0x1f)  9 | (0x4  
0xf)  5 |
+   (0x1e  0x1f); /* -11 dB: 4'd5, 5'd30, -10 dB: 4'd4, 5'd30 */
+   aic_atten_word[6] = (0x1  0xf)  14 | (0xf  0x1f)  9  | (0x0  
0xf)  5 |
+   (0xf  0x1f);  /* -13 dB: 4'd1, 5'd15, -12 dB: 4'd0, 5'd15 */
+   aic_atten_word[7] = (0x3  0xf)  14 | (0xf  0x1f)  9  | (0x2  
0xf)  5 |
+   (0xf  0x1f);  /* -15 dB: 4'd3, 5'd15, -14 dB: 4'd2, 5'd15 */
+   aic_atten_word[8] = (0x5  0xf)  14 | (0xf  0x1f)  9  | (0x4  
0xf)  5 |
+   (0xf  0x1f);  /* -17 dB: 4'd5, 5'd15, -16 dB: 4'd4, 5'd15 */
+   aic_atten_word[9] = (0x1  0xf)  14 | (0x7  0x1f)  9  | (0x0  
0xf)  5 |
+   (0x7  0x1f);  /* -19 dB: 4'd1, 5'd07, -18 dB: 4'd0, 5'd07 */
+   aic_atten_word[10] = (0x3  0xf)  14 | (0x7  0x1f)  9  | (0x2  
0xf)  5 |
+   (0x7  0x1f);  /* -21 dB: 4'd3, 5'd07, -20 dB: 4'd2, 5'd07 */
+   aic_atten_word[11] = (0x5  0xf)  14 | (0x7  0x1f)  9  | (0x4  
0xf)  5 |
+   (0x7  0x1f);  /* -23 dB: 4'd5, 5'd07, -22 dB: 4'd4, 5'd07 */
+   aic_atten_word[12] = (0x7  0xf)  14 | (0x7  0x1f)  9  | (0x6  
0xf)  5 |
+   (0x7  0x1f);  /* -25 dB: 4'd7, 5'd07, -24 dB: 4'd6, 5'd07 */
+   aic_atten_word[13] = (0x3  0xf)  14 | (0x3  0x1f)  9  | (0x2  
0xf)  5 |
+   (0x3  0x1f);  /* -27 dB: 4'd3, 5'd03, -26 dB: 4'd2, 5'd03 */
+   aic_atten_word[14] = (0x5  0xf)  14 | (0x3  0x1f)  9  | (0x4  
0xf)  5 |
+   (0x3  0x1f);  /* -29 dB: 4'd5, 5'd03, -28 dB: 4'd4, 5'd03 */
+   aic_atten_word[15] = (0x1  0xf)  14 | (0x1  0x1f)  9  | (0x0  
0xf)  5 |
+   (0x1  0x1f);  /* -31 dB: 4'd1, 5'd01, -30 dB: 4'd0, 5'd01 */
+   aic_atten_word[16] = (0x3  0xf)  14 | (0x1  0x1f)  9  | (0x2  
0xf)  5 |
+   (0x1  0x1f);  /* -33 dB: 4'd3, 5'd01, -32 dB: 4'd2, 5'd01 */
+   aic_atten_word[17] = (0x5  0xf)  14 | (0x1  0x1f)  9  | (0x4  
0xf)  5 |
+   (0x1  0x1f);  /* -35 dB: 4'd5, 5'd01, -34 dB: 4'd4, 5'd01 */
+   aic_atten_word[18] = (0x7  0xf)  14 | (0x1  0x1f)  9  | (0x6  
0xf)  5 |
+   (0x1  0x1f);  /* -37 dB: 4'd7, 5'd01, -36 dB: 4'd6, 5'd01 */
+
+   /* Write to Gain table with auto increment enabled. */
+   REG_WRITE(ah, (AR_PHY_AIC_SRAM_ADDR_B0 + 0x3000),
+ (ATH_AIC_SRAM_AUTO_INCREMENT |
+  ATH_AIC_SRAM_GAIN_TABLE_OFFSET));
+
+   for (i = 0; i  19; i++) {
+   REG_WRITE(ah, (AR_PHY_AIC_SRAM_DATA_B0 + 0x3000),
+ aic_atten_word[i]);
+   }
+}
+
+static void ar9003_aic_cal_start(struct ath_hw *ah, u8 min_valid_count)
+{
+   struct ath9k_hw_aic *aic = ah-btcoex_hw.aic;
+   int i;
+
+   /* Write to Gain table with auto increment enabled. */
+   REG_WRITE(ah, (AR_PHY_AIC_SRAM_ADDR_B0 + 0x3000),
+ (ATH_AIC_SRAM_AUTO_INCREMENT |
+  ATH_AIC_SRAM_CAL_OFFSET));
+
+   for (i = 0; i  ATH_AIC_MAX_BT_CHANNEL; i++) {
+   REG_WRITE(ah, (AR_PHY_AIC_SRAM_DATA_B0 + 0x3000), 0);
+   aic

[ath9k-devel] [PATCH 5/7] ath9k: Finish AIC calibration

2015-03-10 Thread Sujith Manoharan
From: Sujith Manoharan c_man...@qca.qualcomm.com

Set the appropriate bits in the HW after
AIC calibration is done.

Signed-off-by: Sujith Manoharan c_man...@qca.qualcomm.com
---
 drivers/net/wireless/ath/ath9k/ar9003_aic.c | 78 -
 1 file changed, 77 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_aic.c 
b/drivers/net/wireless/ath/ath9k/ar9003_aic.c
index c2cfac3..00aaf4d 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_aic.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_aic.c
@@ -186,15 +186,91 @@ static void ar9003_aic_cal_start(struct ath_hw *ah, u8 
min_valid_count)
aic-aic_cal_state = AIC_CAL_STATE_STARTED;
 }
 
+static void ar9003_aic_cal_done(struct ath_hw *ah)
+{
+   /* Disable AIC reference signal in BT modem. */
+   REG_WRITE(ah, ATH_AIC_BT_JUPITER_CTRL,
+ (REG_READ(ah, ATH_AIC_BT_JUPITER_CTRL) 
+  ~ATH_AIC_BT_AIC_ENABLE));
+}
+
+static u8 ar9003_aic_cal_continue(struct ath_hw *ah, bool cal_once)
+{
+   struct ath_common *common = ath9k_hw_common(ah);
+   struct ath9k_hw_mci *mci_hw = ah-btcoex_hw.mci;
+   struct ath9k_hw_aic *aic = ah-btcoex_hw.aic;
+   int i, num_chan;
+
+   num_chan = MS(mci_hw-config, ATH_MCI_CONFIG_AIC_CAL_NUM_CHAN);
+
+   if (!num_chan) {
+   aic-aic_cal_state = AIC_CAL_STATE_ERROR;
+   return aic-aic_cal_state;
+   }
+
+   if (cal_once) {
+   for (i = 0; i  1; i++) {
+   if ((REG_READ(ah, AR_PHY_AIC_CTRL_0_B1) 
+AR_PHY_AIC_CAL_ENABLE) == 0)
+   break;
+
+   udelay(100);
+   }
+   }
+
+   /*
+* Use AR_PHY_AIC_CAL_ENABLE bit instead of AR_PHY_AIC_CAL_DONE.
+* Sometimes CAL_DONE bit is not asserted.
+*/
+   if ((REG_READ(ah, AR_PHY_AIC_CTRL_0_B1) 
+AR_PHY_AIC_CAL_ENABLE) != 0) {
+   ath_dbg(common, MCI, AIC cal is not done after 40ms);
+   goto exit;
+   }
+
+   REG_WRITE(ah, AR_PHY_AIC_SRAM_ADDR_B1,
+ (ATH_AIC_SRAM_CAL_OFFSET | ATH_AIC_SRAM_AUTO_INCREMENT));
+
+   for (i = 0; i  ATH_AIC_MAX_BT_CHANNEL; i++) {
+   u32 value;
+
+   value = REG_READ(ah, AR_PHY_AIC_SRAM_DATA_B1);
+
+   if (value  0x01) {
+   if (aic-aic_sram[i] == 0)
+   aic-aic_caled_chan++;
+
+   aic-aic_sram[i] = value;
+
+   if (!cal_once)
+   break;
+   }
+   }
+
+   if ((aic-aic_caled_chan = num_chan) || cal_once) {
+   ar9003_aic_cal_done(ah);
+   } else {
+   /* Start calibration */
+   REG_CLR_BIT(ah, AR_PHY_AIC_CTRL_0_B1, AR_PHY_AIC_CAL_ENABLE);
+   REG_SET_BIT(ah, AR_PHY_AIC_CTRL_0_B1,
+   AR_PHY_AIC_CAL_CH_VALID_RESET);
+   REG_SET_BIT(ah, AR_PHY_AIC_CTRL_0_B1, AR_PHY_AIC_CAL_ENABLE);
+   }
+exit:
+   return aic-aic_cal_state;
+
+}
+
 u8 ar9003_aic_calibration_single(struct ath_hw *ah)
 {
struct ath9k_hw_mci *mci_hw = ah-btcoex_hw.mci;
-   u8 cal_ret = 0;
+   u8 cal_ret;
int num_chan;
 
num_chan = MS(mci_hw-config, ATH_MCI_CONFIG_AIC_CAL_NUM_CHAN);
 
ar9003_aic_cal_start(ah, num_chan);
+   cal_ret = ar9003_aic_cal_continue(ah, true);
 
return cal_ret;
 }
-- 
2.3.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 6/7] ath9k: Process the AIC calibration results

2015-03-10 Thread Sujith Manoharan
From: Sujith Manoharan c_man...@qca.qualcomm.com

This patch adds support for post-processing
the AIC calibration results.

Signed-off-by: Sujith Manoharan c_man...@qca.qualcomm.com
---
 drivers/net/wireless/ath/ath9k/ar9003_aic.c | 245 
 1 file changed, 245 insertions(+)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_aic.c 
b/drivers/net/wireless/ath/ath9k/ar9003_aic.c
index 00aaf4d..51ecc9b 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_aic.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_aic.c
@@ -20,6 +20,22 @@
 #include ar9003_aic.h
 #include reg_aic.h
 
+static const u8 com_att_db_table[ATH_AIC_MAX_COM_ATT_DB_TABLE] = {
+   0, 3, 9, 15, 21, 27
+};
+
+static const u16 aic_lin_table[ATH_AIC_MAX_AIC_LIN_TABLE] = {
+   8191, 7300, 6506, 5799, 5168, 4606, 4105, 3659,
+   3261, 2906, 2590, 2309, 2057, 1834, 1634, 1457,
+   1298, 1157, 1031, 919,  819,  730,  651,  580,
+   517,  461,  411,  366,  326,  291,  259,  231,
+   206,  183,  163,  146,  130,  116,  103,  92,
+   82,   73,   65,   58,   52,   46,   41,   37,
+   33,   29,   26,   23,   21,   18,   16,   15,
+   13,   12,   10,   9,8,7,7,6,
+   5,5,4,4,3
+};
+
 static bool ar9003_hw_is_aic_enabled(struct ath_hw *ah)
 {
struct ath9k_hw_mci *mci_hw = ah-btcoex_hw.mci;
@@ -30,6 +46,56 @@ static bool ar9003_hw_is_aic_enabled(struct ath_hw *ah)
return true;
 }
 
+static int16_t ar9003_aic_find_valid(struct ath_aic_sram_info *cal_sram,
+bool dir, u8 index)
+{
+   int16_t i;
+
+   if (dir) {
+   for (i = index + 1; i  ATH_AIC_MAX_BT_CHANNEL; i++) {
+   if (cal_sram[i].valid)
+   break;
+   }
+   } else {
+   for (i = index - 1; i = 0; i--) {
+   if (cal_sram[i].valid)
+   break;
+   }
+   }
+
+   if ((i = ATH_AIC_MAX_BT_CHANNEL) || (i  0))
+   i = -1;
+
+   return i;
+}
+
+/*
+ * type 0: aic_lin_table, 1: com_att_db_table
+ */
+static int16_t ar9003_aic_find_index(u8 type, int16_t value)
+{
+   int16_t i = -1;
+
+   if (type == 0) {
+   for (i = ATH_AIC_MAX_AIC_LIN_TABLE - 1; i = 0; i--) {
+   if (aic_lin_table[i] = value)
+   break;
+   }
+   } else if (type == 1) {
+   for (i = 0; i  ATH_AIC_MAX_COM_ATT_DB_TABLE; i++) {
+   if (com_att_db_table[i]  value) {
+   i--;
+   break;
+   }
+   }
+
+   if (i = ATH_AIC_MAX_COM_ATT_DB_TABLE)
+   i = -1;
+   }
+
+   return i;
+}
+
 static void ar9003_aic_gain_table(struct ath_hw *ah)
 {
u32 aic_atten_word[19], i;
@@ -186,12 +252,191 @@ static void ar9003_aic_cal_start(struct ath_hw *ah, u8 
min_valid_count)
aic-aic_cal_state = AIC_CAL_STATE_STARTED;
 }
 
+static bool ar9003_aic_cal_post_process(struct ath_hw *ah)
+{
+   struct ath9k_hw_aic *aic = ah-btcoex_hw.aic;
+   struct ath_aic_sram_info cal_sram[ATH_AIC_MAX_BT_CHANNEL];
+   struct ath_aic_out_info aic_sram[ATH_AIC_MAX_BT_CHANNEL];
+   u32 dir_path_gain_idx, quad_path_gain_idx, value;
+   u32 fixed_com_att_db;
+   int8_t dir_path_sign, quad_path_sign;
+   int16_t i;
+   bool ret = true;
+
+   memset(cal_sram, 0, sizeof(cal_sram));
+   memset(aic_sram, 0, sizeof(aic_sram));
+
+   for (i = 0; i  ATH_AIC_MAX_BT_CHANNEL; i++) {
+   value = aic-aic_sram[i];
+
+   cal_sram[i].valid =
+   MS(value, AR_PHY_AIC_SRAM_VALID);
+   cal_sram[i].rot_quad_att_db =
+   MS(value, AR_PHY_AIC_SRAM_ROT_QUAD_ATT_DB);
+   cal_sram[i].vga_quad_sign =
+   MS(value, AR_PHY_AIC_SRAM_VGA_QUAD_SIGN);
+   cal_sram[i].rot_dir_att_db =
+   MS(value, AR_PHY_AIC_SRAM_ROT_DIR_ATT_DB);
+   cal_sram[i].vga_dir_sign =
+   MS(value, AR_PHY_AIC_SRAM_VGA_DIR_SIGN);
+   cal_sram[i].com_att_6db =
+   MS(value, AR_PHY_AIC_SRAM_COM_ATT_6DB);
+
+   if (cal_sram[i].valid) {
+   dir_path_gain_idx = cal_sram[i].rot_dir_att_db +
+   com_att_db_table[cal_sram[i].com_att_6db];
+   quad_path_gain_idx = cal_sram[i].rot_quad_att_db +
+   com_att_db_table[cal_sram[i].com_att_6db];
+
+   dir_path_sign = (cal_sram[i].vga_dir_sign) ? 1 : -1;
+   quad_path_sign = (cal_sram[i].vga_quad_sign) ? 1 : -1;
+
+   aic_sram[i].dir_path_gain_lin = dir_path_sign *
+   aic_lin_table[dir_path_gain_idx

Re: [ath9k-devel] AR9462 problems connecting again..

2015-02-23 Thread Sujith Manoharan
Jouni Malinen wrote:
 Even I think that this goes a bit too far especially on 2.4 GHz band,
 but I would actually consider limiting EAPOL frames to using non-HT/VHT
 (e.g., 6 Mbps OFDM at least for EAPOL-Key frames) to avoid some
 interoperability issues. I would say that the current minstrel_ht
 behavior is somewhat excessive for EAPOL-Key frames in the other
 direction. Using MCS 14 with fallback to something like MCS 5 for the
 second Data frame after an association can certainly fail.
 
 Number of Linux drivers do already limit EAPOL frame TX rate, so this
 specific item is mainly applicable only to driver that use minstrel from
 mac80211 (e.g., ath9k). Though, that IEEE80211_TX_CTL_USE_MINRATE would
 likely affect most mac80211 drivers.

We had this in the ath9k RC, where EAPOL frames were sent out at min-rate
on the VO queue. I think instead of re-introducing it in the driver,
having it in minstrel is cleaner.

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] AR9462 problems connecting again..

2015-02-22 Thread Sujith Manoharan
Linus Torvalds wrote:
 14:07:23.542927: wlp1s0: Event DEAUTH (12) received
 14:07:23.542946: wlp1s0: Deauthentication notification
 14:07:23.542964: wlp1s0:  * reason 2
 14:07:23.542982: wlp1s0:  * address 20:9f:db:e7:80:80
 14:07:23.542997: Deauthentication frame IE(s) - hexdump(len=0): [NULL]
 14:07:23.543055: wlp1s0: CTRL-EVENT-DISCONNECTED bssid=20:9f:db:e7:80:80 
 reason=2

Sporadic association problems could be a problem with the chosen rates.
This would show the rates for the EAPOL frames:

iw dev wlp1s0 interface add mon0 type monitor
ifconfig mon0 up
tshark -i mon0 -Y eapol -T fields -e radiotap.datarate -e wlan -e eapol -e 
wlan.sa -e wlan.da
Run wpa_s.

Does setting a lower rate improve connectivity ?

'iw dev wlp1s0 set bitrates ht-mcs-2.4 1' would choose a lower
rate for the key-exchange frames.

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] AR9462 problems connecting again..

2015-02-22 Thread Sujith Manoharan
Sujith Manoharan wrote:
 'iw dev wlp1s0 set bitrates ht-mcs-2.4 1' would choose a lower
 rate for the key-exchange frames.

Or 'iw dev wlp1s0 set bitrates ht-mcs-2.4 0' to choose the lowest
HT rate.

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] AR9462 problems connecting again..

2015-02-22 Thread Sujith Manoharan
Linus Torvalds wrote:
 I've got the wpa supplicant log for this timeframe, but I'd rather not
 send it out in public. I see [REMOVED] for what looks like the key
 data, but there's a lot of other hex data. Is any of it sensitive?

Unless the '-K' option is used with wpa_s, the keys are not displayed
in the debug output when '-dd' is used, so it would be helpful to
have the wpa_s log.

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] AR9462 problems connecting again..

2015-02-21 Thread Sujith Manoharan
Linus Torvalds wrote:
 So I've had problems connecting to some networks before on my
 Chromebook Pixel, but now I'm testing a new Ubiquiti network at home,
 and can see this issue at home too.

Can you please post the output of 'iw dev wlp1s0 scan' ?

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] AR9103(AR9132) Antenna diversity

2015-01-22 Thread Sujith Manoharan
Adrian Chadd wrote:
 It's already doing MIMO diversity. If you have a chainmask that has 2
 or more antennas enabled it already is doing it.
 
 I think that variable is slow antenna diversity, not MIMO diversity.

It's for LNA diversity - 1x1 chips like AR9485, AR9565 etc.

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] Bluetooth not working on AR9462/0489:e076

2015-01-15 Thread Sujith Manoharan
Sekou DIAKITE wrote:
 How do I find the firmware filename/path ?

The ath3k firmware is usually in /lib/firmware/ar3k

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] Bluetooth not working on AR9462/0489:e076

2015-01-15 Thread Sujith Manoharan
Hi,

Can you post the output of 'sudo lspci -vv -nn -d 0x168c:* ?
I'll check if this card needs any platform-specific initialization.

Sujith

Sekou DIAKITE wrote:
 With the patch, cold-boot (nothing works, rfkill, hciconfig does not
 see the device):
  :~$ dmesg | grep -i btusb\|bluetooth\|ath3k\|firmware
 [0.165234] [Firmware Bug]: ACPI: BIOS _OSI(Linux) query ignored
 [5.132502] Bluetooth: Core ver 2.20
 [5.132522] Bluetooth: HCI device and connection manager initialized
 [5.132529] Bluetooth: HCI socket layer initialized
 [5.132532] Bluetooth: L2CAP socket layer initialized
 [5.132538] Bluetooth: SCO socket layer initialized
 [5.139655] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
 [5.139659] Bluetooth: BNEP filters: protocol multicast
 [5.139691] Bluetooth: BNEP socket layer initialized
 [5.139947] Bluetooth: RFCOMM TTY layer initialized
 [5.139953] Bluetooth: RFCOMM socket layer initialized
 [5.139958] Bluetooth: RFCOMM ver 1.11
 [5.321921] [Firmware Bug]: ACPI(PEGP) defines _DOD but not _DOS
 [6.336151] usbcore: registered new interface driver btusb
 [6.419089] usbcore: registered new interface driver ath3k
 [9.918557] Bluetooth: Error in firmware loading err = -110,len =
 448, size = 4096
 [9.918572] Bluetooth: Loading patch file failed
 [9.918584] ath3k: probe of 2-5:1.0 failed with error -110
 
 With the patch, when rebooting from **Windows** (Everything is working):
 :~$ dmesg | grep -i btusb\|bluetooth\|ath3k\|firmware
 [0.165411] [Firmware Bug]: ACPI: BIOS _OSI(Linux) query ignored
 [7.277840] [Firmware Bug]: ACPI(PEGP) defines _DOD but not _DOS
 [7.338358] Bluetooth: Core ver 2.20
 [7.338382] Bluetooth: HCI device and connection manager initialized
 [7.338391] Bluetooth: HCI socket layer initialized
 [7.338394] Bluetooth: L2CAP socket layer initialized
 [7.338402] Bluetooth: SCO socket layer initialized
 [7.349094] Bluetooth: RFCOMM TTY layer initialized
 [7.349108] Bluetooth: RFCOMM socket layer initialized
 [7.349145] Bluetooth: RFCOMM ver 1.11
 [7.350880] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
 [7.350884] Bluetooth: BNEP filters: protocol multicast
 [7.350892] Bluetooth: BNEP socket layer initialized
 [8.173590] usbcore: registered new interface driver btusb
 [8.187979] usbcore: registered new interface driver ath3k
 [   22.291160] Bluetooth: HIDP (Human Interface Emulation) ver 1.2
 [   22.291174] Bluetooth: HIDP socket layer initialized
 [   22.293873] input: Bluetooth Laser Travel Mouse as
 /devices/pci:00/:00:14.0/usb2/2-5/2-5:1.0/bluetooth/hci0/hci0:21/0005:046D:B008.0002/input/input16
 [   22.294028] hid-generic 0005:046D:B008.0002: input,hidraw1:
 BLUETOOTH HID v3.18 Mouse [Bluetooth Laser Travel Mouse] on
 10:08:b1:c7:88:62
 
 
 2015-01-13 23:07 GMT+01:00 Sujith Manoharan suj...@msujith.org:
  Sekou DIAKITE wrote:
  I've installed the latest backport driver and added the btcoex_enable=1.
  It doesn't change the behavior (bluetooth works only after a reboot
  from Windows).
 
  From the askubuntu page, 0489:e076 is the USB ID for your card.
  It doesn't appear to be present in the kernel and I don't think
  ath3k would be loaded.
 
  I have a patch to add this ID to ath3k, can you apply it in
  backports-20141221 and check ?
 
  http://msujith.org/dir/patches/wl/Jan-14-2015/0013-ath3k-Add-new-AR3012-device.patch
 
  Inside backports:
 
  patch -p1  0013-ath3k-Add-new-AR3012-device.patch
 
  And then, do a make menuconfig to select ath9k/ath3k
  and install.
 
  Sujith
  ___
  ath9k-devel mailing list
  ath9k-devel@lists.ath9k.org
  https://lists.ath9k.org/mailman/listinfo/ath9k-devel
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] Bluetooth not working on AR9462/0489:e076

2015-01-15 Thread Sujith Manoharan
Sekou DIAKITE wrote:
 [9.918557] Bluetooth: Error in firmware loading err = -110,len = 448, 
 size = 4096
 [9.918572] Bluetooth: Loading patch file failed
 [9.918584] ath3k: probe of 2-5:1.0 failed with error -110

The errno corresponds to -ETIMEDOUT, not sure why the ath3k fw fails to
load before Windows gets a chance to fiddle with the card.

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] Any chance for support for bluetooth on Atheros QCNFA wifi/bluetooth combos?

2015-01-13 Thread Sujith Manoharan
Jeremy  wrote:
 It looks like the firmware needed has changed, at least the file names
 This bug report https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1383184
 
 The lsusb shows: Bus 001 Device 003: ID 0cf3:3004 Atheros Communications, Inc,
 which is supported but the dmesg shows: Bluetooth: Configuration file not
 found ar3k/ ramps_0x0200_0.dfu and I imagine it would need the
 AthrBT_0x0200_0.dfu

This is a card that will probably be supported by ath10k. Bluetooth support
will happen when wifi/bt coex support is added, I guess.

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] Bluetooth not working on AR9462/0489:e076

2015-01-13 Thread Sujith Manoharan
Sekou DIAKITE wrote:
 I've installed the latest backport driver and added the btcoex_enable=1.
 It doesn't change the behavior (bluetooth works only after a reboot
 from Windows).

From the askubuntu page, 0489:e076 is the USB ID for your card.
It doesn't appear to be present in the kernel and I don't think
ath3k would be loaded.

I have a patch to add this ID to ath3k, can you apply it in
backports-20141221 and check ?

http://msujith.org/dir/patches/wl/Jan-14-2015/0013-ath3k-Add-new-AR3012-device.patch

Inside backports:

patch -p1  0013-ath3k-Add-new-AR3012-device.patch

And then, do a make menuconfig to select ath9k/ath3k
and install.

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] Bluetooth not working on AR9462/0489:e076

2015-01-10 Thread Sujith Manoharan
Sekou DIAKITE wrote:
 Hello,
 
 I have some troubles making my bluetooth device work on Ubutun 14.10
 (Kernel: 3.16.0-29-generic, linux-firmware* installed).

Can you install the latest backports driver ?

https://backports.wiki.kernel.org/index.php/Main_Page
https://www.kernel.org/pub/linux/kernel/projects/backports/2014/12/21/

And load the ath9k driver with the parameter btcoex_enable=1 ?
(http://wireless.kernel.org/en/users/Drivers/ath9k/btcoex)

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] [PATCH] ath: ath9k: use debugfs_create_devm_seqfile() helper for seq_file entries

2015-01-08 Thread Sujith Manoharan
Arend van Spriel wrote:
 So the content of the modified debugfs files looks sane?

Yep, as sane as the code populating the debug data. :-)

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] [PATCH] ath: ath9k: use debugfs_create_devm_seqfile() helper for seq_file entries

2015-01-07 Thread Sujith Manoharan
 Arend van Spriel ar...@broadcom.com writes:
 
  Use the helper to get rid of the file operations per debugfs file. The
  device driver data contains struct ieee80211_hw pointer and the
  struct ath9k_softc pointer is assigned to ieee80211_hw::priv so it can
  be accessed in the seq_file read operation.
 
  Cc: ath9k-devel@lists.ath9k.org
  Signed-off-by: Arend van Spriel ar...@broadcom.com

Thanks for the patch.

 Can someone with ath9k hardware test this, please? I'm hesitant to apply
 this without testing.

I tested it and there were no crashes.

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] AR9580 Driver in kernel 2.26.31

2015-01-05 Thread Sujith Manoharan
杨铁军 wrote:
 Does somebody know where I could download AR9580 driver for Kernel 2.26.31?

Linux backports: https://backports.wiki.kernel.org/index.php/Main_Page
2.6.31 is not supported by the latest releases.

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] How can I disable BT on AR9462 chip in Ubuntu kernel

2015-01-02 Thread Sujith Manoharan
Tony Kitzky wrote:
 How can I disable BT on AR9462 chip in Ubuntu kernel
 
 I am looking for a way to disable the bluetooth capabilities on the Atheros
 AR9462 chipset in Ubuntu. I am having problems getting BT to work properly. I
 have a cheap USB BT adapter that works but it conflicts with BT on the Atheros
 chip. I have an open question on AskUbuntu trying to get the Atheros chip
 working properly.

Have you tried loading the ath9k driver with btcoex_enable=1 ?
The BT/WLAN co-existence code in ath9k is not very robust, but it
should improve things.

 For now I would just like to disable BT on this chip. Ideally I can disable
 this in the kernel. (nobt=1, maybe? :-)

Blacklisting ath3k would be an option if the other USB BT adapter doesn't
use ath3k.

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] Disabling physical spectrum sensing

2015-01-02 Thread Sujith Manoharan
Yahia Shabara wrote:
 I am doing an experiment that involves implementing a proposed channel access
 scheme and I need to enable or disable physical spectrum sensing in a dynamic
 manner. In addition to disabling the back-off time intended for collision
 avoidance since my experiment and system model involves only one transceiver
 pair per priority level.

This disables carrier sensing:

Set AR_DIAG_FORCE_CH_IDLE_HIGH in AR_DIAG_SW.
Set AR_DIAG_IGNORE_VIRT_CS in AR_DIAG_SW.
Set force_agc_clear (bit 28 of reg 0xa360).

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] queue priority mapping

2014-11-26 Thread Sujith Manoharan
Hubert Feurstein wrote:
 Well, in fact it does. To understand my post you have to know the
 behaviour of ath_txq_setup. The point here is that on the first call
 of ath_txq_setup(..ATH9K_TX_QUEUE_DATA..), hw-queue 0 is returned. On
 the second call hw-queue 1 is returned, ... . And IEEE80211_AC_VO = 0,
 so hw-queue 0 is assigned, which is wrong in my opinion. But the right
 place to fix this would be ath_txq_setup itself.

The mapping has been changed recently and I think it might be a problem,
since this is what the datasheet says:

The mapping of physical DCUs to absolute channel access priorities is fixed and
cannot be altered by software.

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] [PATCH 2/2] ath9k: fix regression in bssidmask calculation

2014-11-12 Thread Sujith Manoharan
John W. Linville wrote:
 Any word from the ath9k posse?

Looks good to me...

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] Bluetooth unable to scan devices

2014-11-11 Thread Sujith Manoharan
Giuseppe Torelli wrote:
 Bus 001 Device 003: ID 04ca:300b Lite-On Technology Corp. 
 Device Descriptor:
   idVendor           0x04ca Lite-On Technology Corp.
   idProduct          0x300b 

Support for this card appears to be already present in the
ath3k bluetooth driver since v3.14 kernel. You need to update
the kernel.

 03:00.0 Network controller [0280]: Qualcomm Atheros QCA9565 / AR9565 Wireless 
 Network Adapter [168c:0036] (rev 01)
 Subsystem: Lite-On Communications Inc Device [11ad:0632]

This PCI ID is present in ath9k.

For newer wireless/bluetooth drivers, the backports package can be used:
https://backports.wiki.kernel.org/index.php/Main_Page

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] Bluetooth unable to scan devices

2014-11-08 Thread Sujith Manoharan
Giuseppe Torelli wrote:
 I have an ACER E1-570 whose bluetooth is not working:
 
 t@Aspire-E1-570 ~ $ hcitool dev
 Devices:
 hci0 48:D2:24:D6:C7:34
 gt@Aspire-E1-570 ~ 
 
 t@Aspire-E1-570 ~ $ uname -a
 Linux Aspire-E1-570 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15 03:51:08 UTC 
 2014 x86_64 x86_64 x86_64 GNU/Linux

Please post the output of 'sudo lsusb -v' and 'sudo lspci -vnn'

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] Support for 13d3:3408 in ath3k

2014-11-08 Thread Sujith Manoharan
Hi,

Thanks, I'll send a patch to add support for this card.

Sujith

Jeremy whocares wrote:
 T: Bus=03 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=5000 MxCh= 4
 B: Alloc= 0/800 us ( 0%), #Int= 0, #Iso= 0
 D: Ver= 3.00 Cls=09(hub ) Sub=00 Prot=03 MxPS= 9 #Cfgs= 1
 P: Vendor=1d6b ProdID=0003 Rev= 3.13
 S: Manufacturer=Linux 3.13.0-24-generic xhci_hcd
 S: Product=xHCI Host Controller
 S: SerialNumber=:00:14.0
 C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 0mA
 I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
 E: Ad=81(I) Atr=03(Int.) MxPS= 4 Ivl=256ms
 
 
 T: Bus=02 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=480 MxCh= 9
 B: Alloc= 0/800 us ( 0%), #Int= 0, #Iso= 0
 D: Ver= 2.00 Cls=09(hub ) Sub=00 Prot=01 MxPS=64 #Cfgs= 1
 P: Vendor=1d6b ProdID=0002 Rev= 3.13
 S: Manufacturer=Linux 3.13.0-24-generic xhci_hcd
 S: Product=xHCI Host Controller
 S: SerialNumber=:00:14.0
 C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 0mA
 I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
 E: Ad=81(I) Atr=03(Int.) MxPS= 4 Ivl=256ms
 
 
 T: Bus=02 Lev=01 Prnt=01 Port=04 Cnt=01 Dev#= 2 Spd=480 MxCh= 0
 D: Ver= 2.00 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs= 1
 P: Vendor=04f2 ProdID=b40a Rev=69.64
 S: Manufacturer=Chicony Electronics Co.,Ltd.
 S: Product=USB2.0 HD UVC WebCam
 S: SerialNumber=0x0001
 C:* #Ifs= 2 Cfg#= 1 Atr=80 MxPwr=500mA
 A: FirstIf#= 0 IfCount= 2 Cls=0e(video) Sub=03 Prot=00
 I:* If#= 0 Alt= 0 #EPs= 1 Cls=0e(video) Sub=01 Prot=00 Driver=uvcvideo
 E: Ad=83(I) Atr=03(Int.) MxPS= 16 Ivl=4ms
 I:* If#= 1 Alt= 0 #EPs= 0 Cls=0e(video) Sub=02 Prot=00 Driver=uvcvideo
 I: If#= 1 Alt= 1 #EPs= 1 Cls=0e(video) Sub=02 Prot=00 Driver=uvcvideo
 E: Ad=81(I) Atr=05(Isoc) MxPS= 128 Ivl=125us
 I: If#= 1 Alt= 2 #EPs= 1 Cls=0e(video) Sub=02 Prot=00 Driver=uvcvideo
 E: Ad=81(I) Atr=05(Isoc) MxPS= 512 Ivl=125us
 I: If#= 1 Alt= 3 #EPs= 1 Cls=0e(video) Sub=02 Prot=00 Driver=uvcvideo
 E: Ad=81(I) Atr=05(Isoc) MxPS=1024 Ivl=125us
 I: If#= 1 Alt= 4 #EPs= 1 Cls=0e(video) Sub=02 Prot=00 Driver=uvcvideo
 E: Ad=81(I) Atr=05(Isoc) MxPS=1536 Ivl=125us
 I: If#= 1 Alt= 5 #EPs= 1 Cls=0e(video) Sub=02 Prot=00 Driver=uvcvideo
 E: Ad=81(I) Atr=05(Isoc) MxPS=2048 Ivl=125us
 I: If#= 1 Alt= 6 #EPs= 1 Cls=0e(video) Sub=02 Prot=00 Driver=uvcvideo
 E: Ad=81(I) Atr=05(Isoc) MxPS=2688 Ivl=125us
 I: If#= 1 Alt= 7 #EPs= 1 Cls=0e(video) Sub=02 Prot=00 Driver=uvcvideo
 E: Ad=81(I) Atr=05(Isoc) MxPS=3072 Ivl=125us
 
 
 T: Bus=02 Lev=01 Prnt=01 Port=05 Cnt=02 Dev#= 3 Spd=12 MxCh= 0
 D: Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1
 P: Vendor=13d3 ProdID=3408 Rev= 0.01
 C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA
 A: FirstIf#= 0 IfCount= 2 Cls=e0(wlcon) Sub=01 Prot=01
 I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
 E: Ad=81(I) Atr=03(Int.) MxPS= 16 Ivl=1ms
 E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms
 E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms
 I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
 E: Ad=83(I) Atr=01(Isoc) MxPS= 0 Ivl=1ms
 E: Ad=03(O) Atr=01(Isoc) MxPS= 0 Ivl=1ms
 I: If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
 E: Ad=83(I) Atr=01(Isoc) MxPS= 9 Ivl=1ms
 E: Ad=03(O) Atr=01(Isoc) MxPS= 9 Ivl=1ms
 I: If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
 E: Ad=83(I) Atr=01(Isoc) MxPS= 17 Ivl=1ms
 E: Ad=03(O) Atr=01(Isoc) MxPS= 17 Ivl=1ms
 I: If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
 E: Ad=83(I) Atr=01(Isoc) MxPS= 25 Ivl=1ms
 E: Ad=03(O) Atr=01(Isoc) MxPS= 25 Ivl=1ms
 I: If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
 E: Ad=83(I) Atr=01(Isoc) MxPS= 33 Ivl=1ms
 E: Ad=03(O) Atr=01(Isoc) MxPS= 33 Ivl=1ms
 I: If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
 E: Ad=83(I) Atr=01(Isoc) MxPS= 49 Ivl=1ms
 E: Ad=03(O) Atr=01(Isoc) MxPS= 49 Ivl=1ms
 
 
 T: Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=480 MxCh= 2
 B: Alloc= 0/800 us ( 0%), #Int= 2, #Iso= 0
 D: Ver= 2.00 Cls=09(hub ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
 P: Vendor=1d6b ProdID=0002 Rev= 3.13
 S: Manufacturer=Linux 3.13.0-24-generic ehci_hcd
 S: Product=EHCI Host Controller
 S: SerialNumber=:00:1d.0
 C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 0mA
 I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
 E: Ad=81(I) Atr=03(Int.) MxPS= 4 Ivl=256ms
 
 
 T: Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=480 MxCh= 8
 D: Ver= 2.00 Cls=09(hub ) Sub=00 Prot=01 MxPS=64 #Cfgs= 1
 P: Vendor=8087 ProdID=8000 Rev= 0.04
 C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 0mA
 I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
 E: Ad=81(I) Atr=03(Int.) MxPS= 2 Ivl=256ms
 
 
 T: Bus=01 Lev=02 Prnt=02 Port=02 Cnt=01 Dev#= 3 Spd=1.5 MxCh= 0
 D: Ver= 1.10 Cls=00(ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
 P: Vendor= ProdID=0538 Rev= 1.00
 S: Product= USB OPTICAL MOUSE
 C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=100mA
 I:* If#= 0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=01 Prot=02 Driver=usbhid
 E: Ad=81(I) Atr=03(Int.) MxPS= 6 Ivl=10ms
 
 
 
 00:00.0 Host bridge [0600]: Intel Corporation Haswell-ULT DRAM

Re: [ath9k-devel] Support for 13d3:3408 in ath3k

2014-11-03 Thread Sujith Manoharan
Jeremy whocares wrote:
 A windows inf file shows 13d3:3408 as VID_13D3PID_3408 = Qualcomm Atheros 
 Bluetooth 4.0 + HS
 
 The wifi combo card is QCWB335

Can you please post the output of /sys/kernel/debug/usb/devices ?
Also 'sudo lspci -vnn'.

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] Support for killer n1525

2014-11-03 Thread Sujith Manoharan
Joris Guisson wrote:
 I recently purchased an MSI GT 72 gaming laptop with a killer n1525 wifi card
 in it. The wifi didn't work, so I took a look at the latest kernel release
 (3.18-rc3), and it seems there is no support in it for the card. I didn't find
 the PCI device id (0x003e) listed in any of the atheros drivers, the only
 killer related entries where in ath9k:
 
 It may just be a matter of adding a new device ID entry in the table above, if
 the NIC more or less works like previous killer NIC's.

This card/HW is not supported by ath9k. I think work is ongoing to add
support for this HW family to ath10k.

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] FRDC material for meeting in 10.23

2014-10-23 Thread Sujith Manoharan
Oleksij Rempel wrote:
 Should ask some one from QCA,
 i have no idea who is still working there. Sujith, may be you know?

Nope, this is not run by QCA. I think someone from madwifi is the admin.
Luis, who runs this list these days ?

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] rts/cts modification in ath9k

2014-10-23 Thread Sujith Manoharan
Tsaixiong wrote:
 I am trying to get RTS/CTS and ACK  frame in mac80211 or ath9k in order to 
 make 
 sure the receiver and transimitter and duration of next data frame .but i 
 cannot get them correctly,have you solved this problem,any reply will be much 
 apprecited !!

Control bit (ATH9K_RX_FILTER_CONTROL) needs to be set in the
RX filter to receive ACK/RTS/CTS frames in the driver.

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] Bluetooth Co-Existence Algorithm

2014-10-09 Thread Sujith Manoharan
Charounson Saintilus wrote:
 Could you provide a high level explanation of the bluetooth co-existence
 algorithm that's implemented in the ath9k driver. I am particularly interested
 in the file structure and the algorithm itself. Is this solely for co-located
 bluetooh and wi-fi or does the co-existence apply to non co-located devices. 
 
 Essentially, what is the general mechanism used by Wi-Fi to co-exist with
 Bluetooth and how is it implemented in this driver?

It depends on the chip. There are 2-wire, 3-wire and MCI based
co-existence schemes.

Which card are you using ?

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] 3.17 regression, ath9k: Summarize hw state per channel context

2014-10-04 Thread Sujith Manoharan
Ben Greear wrote:
 Took a while, but I found the regression that has been bugging me.
 
 This is on stock kernel, with hand-patched fixup from Felix that fixes
 crash related to minstrel (patch made it upstream later, so that isn't
 a current problem).
 
 The test case is easily reproducible on my systems.  I'm not sure
 all the details matter, but this happens to be my test case
 at the moment:
 
 32-bit Fedora OS, latest supplicant, etc.  ath9k NIC.

Does this happen with latest wireless-testing ?

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] Modifying the data rate of the ath9k driver

2014-09-18 Thread Sujith Manoharan
Charounson Saintilus wrote:
 Essentially, I would like to use the table to learn how the various rates are
 represented. Say I wanted to force the driver to use 6.5 Mb/s for all data
 frames it transmits. I'd like to initialize info-rates[i].Rate =  in xmit.c
 ,  but what are the possible options?

The Rate field in the packet descriptor is filled with a HW rate code.
The legacy rate codes are registered in ath9k_legacy_rates and MCS rates
are handled in ath_buf_set_rate() itself.

But, the set bitrates command in iw can be used to force a fixed rate,
so there is really no need to modify the driver...

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] Modifying the data rate of the ath9k driver

2014-09-10 Thread Sujith Manoharan
Charounson Saintilus wrote:
 Thank you for the response!! What I would actually like to do is to modify the
 driver code and recompile the kernel.  Any idea as to how I might go about
 modifying (hard-coding) the data rate within the driver code and then
 recompiling the kernel or just the ath9k module??

ath9k uses the minstrel rate control algorithm. So either minstrel can be
modified or ath_buf_set_rate() in ath9k/xmit.c.

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] Modifying the data rate of the ath9k driver

2014-09-09 Thread Sujith Manoharan
Charounson Saintilus wrote:
 Forgive me, I am new to driver development. I am working on a project
 which requires me to modify the data rate of the ath9k driver. It can be
 found at kernel-top-directory/drivers/net/wireless/ath/ath9k. For testing
 purposes, it's necessary to set the data rate really low (e.g. 6.5 Mb/s).
 
 I've searched the source code of the driver extensively, but have come up
 empty. I know where the RTS/CTS rate is set, but I'm having trouble finding
 where the general data rate is set.
 
 Any suggestions as to how and where I might modify the data rate? 

http://wireless.kernel.org/en/users/Documentation/iw#Modifying_transmit_bitrates

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] I cannot disable RTS/CTS on ath9k.

2014-09-04 Thread Sujith Manoharan
Ben Greear wrote:
 Thanks, that must be this thread:
 
 http://comments.gmane.org/gmane.linux.kernel.wireless.general/84459
 
 I think that explains much of my confusion.  I too would like a way to
 really disable RTS for testing.  On a mostly quiet channel, sending UDP
 frames one way, I still see lots of RTS/CTS, which must mean there are
 lots of retries (assuming Minstel-HT is cause of this).

The confusion arises from the command usage.

It should be iw phy phyname set rts rts threshold|no rts threshold,
or something similar, because rts off actually removes the threshold,
it doesn't disable RTS/CTS.

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] ath9k compliance with new EN 300 328 v.1.8

2014-07-20 Thread Sujith Manoharan
Adrien Decostre wrote:
 Would you know if there exists an open software tool to trigger the tests
 required for EN 300 328 v1.8.1.
 
 As far as I know, Atheros has developed the ART tool but this is not open
 source software. Is there any alternative for ath9k?

I am not sure. But, maybe the ART tool can be licensed from QCA.

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] [Cerowrt-devel] periodic hang of ath9k

2014-07-13 Thread Sujith Manoharan
Dave Taht wrote:
 cc-ing ath9k-devel for this update on http://www.bufferbloat.net/issues/442
 
 this bug, which some people (usually on macs with low signal strength)
 can get to occur fairly rapidly, but I can't, is driving me 9 kinds of
 crazy...

Does stock OpenWrt also have this bug, or is this specific to Cerowrt ?

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] [RFC 03/10] ath9k: add dynamic ack timeout estimation

2014-07-09 Thread Sujith Manoharan
Lorenzo Bianconi wrote:
 +/*
 + * Copyright 2014, Lorenzo Bianconi lorenzo.biancon...@gmail.com
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License version 2 as
 + * published by the Free Software Foundation.
 + */

I have not reviewed the patches, but the ath9k driver is licensed
under ISC. Introducing a file with GPLv2 license is bound to cause
complications and I think might require legal clearance from a
QCA employee maintaining ath9k.

Right now, I am not sure if there is an official maintainer for
ath9k, but is there any specific reason why you have chosen
GPLv2 ?

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] About duration field in RTS/CTS frame

2014-07-03 Thread Sujith Manoharan
Yi-Hung Wei wrote:
 I am doing some experiments about virtual carrier sense that I manipulate the
 duration field in RTS/CTS frames. I manually inject CTS frames, set the
 duration field to a specific number (i.e. 2000), and use a sniffer to monitor
 those frames. However, the duration filed is not the desired number as I
 filled in. The duration filed is always 0. 

Try manipulating the usage of AR_DurUpdateEna in the TX descriptor
in ar9002_set_txdesc() @ ar9002_mac.c

This field controls whether the HW MAC overwrites the duration field in
the frame when it is sent out.

 I also observed that to enable CTS for regular data frame (by
 setting ATH9K_TXDESC_CTSENA  in xmit.c). Hardware generate a CTS frame for the
 data frame, and the hardware sets the duration field of the corresponding CTS
 frame automatically. I am wondering if there is some way to force the hardware
 to send out CTS frames with manually configured duration field. 

You can try experimenting with the AR_RTSCTSRate field in the TX
descriptor. I think the MAC uses this field to fill the duration
for RTS/CTS frames.

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] meaning of rs_rssi_ctl[i] values ?

2014-06-09 Thread Sujith Manoharan
mahaveer gupta wrote:
 Actually, Is there another way to pull out individual RSSI values from
 individual antennas. which is what I am actually interested in. 
 
 One alternative I can think of is to set the rx-chain-mask to 1 and 2 to get
 the RSSI from antenna 0 and 1 respectively. Wondering if this should give
 reliable estimates

The RSSI values are obtained for each packet, for all active chains,
for both the control and extension channels. Why do you need another way
to get this information ?

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] ath9k compliance with new EN 300 328 v.1.8

2014-06-03 Thread Sujith Manoharan
Adrien Decostre wrote:
 I have read that a new ETSI regulation (EN 300 328 v.1.8.1) will become
 mandatory from 31-12-2014 onwards.
 
 I am wondering if the current ath9k driver is already compliant with this new
 regulation?
 
 Are the patches provided by Sujith Manoharan (“ath9k: Fix regulatory
 compliance” http://www.spinics.net/lists/linux-wireless/msg115798.html  and
 “ath9k: Fix ETSI compliance for AR9462 2.0”
 http://www.spinics.net/lists/linux-wireless/msg118665.html) sufficient for all
 AR93xx chipsets?

The patches should be sufficient for compliance for all chips, but ath9k
has not been tested in the lab to verify the new regulations, AFAIK.

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 2/3] ath9k: Disable AR_INTR_SYNC_HOST1_FATAL for QCA953x

2014-03-17 Thread Sujith Manoharan
From: Sujith Manoharan c_man...@qca.qualcomm.com

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

Signed-off-by: Sujith Manoharan c_man...@qca.qualcomm.com
---
 drivers/net/wireless/ath/ath9k/hw.c  | 2 +-
 drivers/net/wireless/ath/ath9k/mac.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/hw.c 
b/drivers/net/wireless/ath/ath9k/hw.c
index d91403f..c8a9dfa 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -882,7 +882,7 @@ static void ath9k_hw_init_interrupt_masks(struct ath_hw *ah,
AR_IMR_RXORN |
AR_IMR_BCNMISC;
 
-   if (AR_SREV_9340(ah) || AR_SREV_9550(ah))
+   if (AR_SREV_9340(ah) || AR_SREV_9550(ah) || AR_SREV_9531(ah))
sync_default = ~AR_INTR_SYNC_HOST1_FATAL;
 
if (AR_SREV_9300_20_OR_LATER(ah)) {
diff --git a/drivers/net/wireless/ath/ath9k/mac.c 
b/drivers/net/wireless/ath/ath9k/mac.c
index 5f72758..51ce36f 100644
--- a/drivers/net/wireless/ath/ath9k/mac.c
+++ b/drivers/net/wireless/ath/ath9k/mac.c
@@ -827,7 +827,7 @@ void ath9k_hw_enable_interrupts(struct ath_hw *ah)
return;
}
 
-   if (AR_SREV_9340(ah) || AR_SREV_9550(ah))
+   if (AR_SREV_9340(ah) || AR_SREV_9550(ah) || AR_SREV_9531(ah))
sync_default = ~AR_INTR_SYNC_HOST1_FATAL;
 
async_mask = AR_INTR_MAC_IRQ;
-- 
1.9.0

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 3/3] ath9k: Fix temperature compensation

2014-03-17 Thread Sujith Manoharan
From: Sujith Manoharan c_man...@qca.qualcomm.com

The registers for temperature compensation need to
be programmed only for active chains. Use the TX chainmask
to make sure that this is done properly for QCA953x.

Signed-off-by: Sujith Manoharan c_man...@qca.qualcomm.com
---
 drivers/net/wireless/ath/ath9k/ar9003_eeprom.c | 59 +++---
 1 file changed, 35 insertions(+), 24 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c 
b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
index d7625ec..235053b 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
@@ -4792,43 +4792,54 @@ static void ar9003_hw_power_control_override(struct 
ath_hw *ah,
 
 tempslope:
if (AR_SREV_9550(ah) || AR_SREV_9531(ah)) {
+   u8 txmask = (eep-baseEepHeader.txrxMask  0xf0)  4;
+
/*
 * AR955x has tempSlope register for each chain.
 * Check whether temp_compensation feature is enabled or not.
 */
if (eep-baseEepHeader.featureEnable  0x1) {
if (frequency  4000) {
-   REG_RMW_FIELD(ah, AR_PHY_TPC_19,
- AR_PHY_TPC_19_ALPHA_THERM,
- eep-base_ext2.tempSlopeLow);
-   REG_RMW_FIELD(ah, AR_PHY_TPC_19_B1,
- AR_PHY_TPC_19_ALPHA_THERM,
- temp_slope);
-   REG_RMW_FIELD(ah, AR_PHY_TPC_19_B2,
- AR_PHY_TPC_19_ALPHA_THERM,
- eep-base_ext2.tempSlopeHigh);
+   if (txmask  BIT(0))
+   REG_RMW_FIELD(ah, AR_PHY_TPC_19,
+ AR_PHY_TPC_19_ALPHA_THERM,
+ 
eep-base_ext2.tempSlopeLow);
+   if (txmask  BIT(1))
+   REG_RMW_FIELD(ah, AR_PHY_TPC_19_B1,
+ AR_PHY_TPC_19_ALPHA_THERM,
+ temp_slope);
+   if (txmask  BIT(2))
+   REG_RMW_FIELD(ah, AR_PHY_TPC_19_B2,
+ AR_PHY_TPC_19_ALPHA_THERM,
+ 
eep-base_ext2.tempSlopeHigh);
} else {
-   REG_RMW_FIELD(ah, AR_PHY_TPC_19,
- AR_PHY_TPC_19_ALPHA_THERM,
- temp_slope);
-   REG_RMW_FIELD(ah, AR_PHY_TPC_19_B1,
- AR_PHY_TPC_19_ALPHA_THERM,
- temp_slope1);
-   REG_RMW_FIELD(ah, AR_PHY_TPC_19_B2,
- AR_PHY_TPC_19_ALPHA_THERM,
- temp_slope2);
+   if (txmask  BIT(0))
+   REG_RMW_FIELD(ah, AR_PHY_TPC_19,
+ AR_PHY_TPC_19_ALPHA_THERM,
+ temp_slope);
+   if (txmask  BIT(1))
+   REG_RMW_FIELD(ah, AR_PHY_TPC_19_B1,
+ AR_PHY_TPC_19_ALPHA_THERM,
+ temp_slope1);
+   if (txmask  BIT(2))
+   REG_RMW_FIELD(ah, AR_PHY_TPC_19_B2,
+ AR_PHY_TPC_19_ALPHA_THERM,
+ temp_slope2);
}
} else {
/*
 * If temp compensation is not enabled,
 * set all registers to 0.
 */
-   REG_RMW_FIELD(ah, AR_PHY_TPC_19,
- AR_PHY_TPC_19_ALPHA_THERM, 0);
-   REG_RMW_FIELD(ah, AR_PHY_TPC_19_B1,
- AR_PHY_TPC_19_ALPHA_THERM, 0);
-   REG_RMW_FIELD(ah, AR_PHY_TPC_19_B2,
- AR_PHY_TPC_19_ALPHA_THERM, 0);
+   if (txmask  BIT(0))
+   REG_RMW_FIELD(ah, AR_PHY_TPC_19,
+ AR_PHY_TPC_19_ALPHA_THERM, 0);
+   if (txmask  BIT(1))
+   REG_RMW_FIELD

Re: [ath9k-devel] [PATCH 00/23] ath9k|ath9k_htc: move dups to common-beacon

2014-03-07 Thread Sujith Manoharan
Oleksij Rempel wrote:
 Last response was about initvals, my patch set affect only beacon code.
 Since i don't plan to rewrite ath9k_htc from scratch, i would assume it
 will be better to continue this periodic clean work.

I didn't review the patches, but someone else needs to make sure that
nothing is broken in ath9k.

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] Is it possible to force specific station inactive ??

2014-03-05 Thread Sujith Manoharan
Mathy wrote:
 You can abuse the NAV (virtual carrier sense) to prevent a station from
 transmitting packets. I'm not aware of a method to force a station into sleep
 mode.

A better way to stop transmission for sometime is to use the QUIET_TIME
feature that the chip supports. Check AR_QUIET1 in ath9k/reg.h

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] [PATCH 00/23] ath9k|ath9k_htc: move dups to common-beacon

2014-03-01 Thread Sujith Manoharan
Oleksij Rempel wrote:
 I was thinking about it too, but suddenly i don't have enough time and
 experience to do it. Beside, there is no need to write usb layer. It is
 clean and separate from other part of the driver. But the HTC/WMI
 interface is not completely separate.

Sure. It is just another option to consider.

 Now about bigger picture. Right now i work only on ath9kath9k_htc
 dups. But there are lots of dup code in ath9k itself. For example
 *_phy.c, *_initvals.h. Here are some examples:

We already have duplicate detection for initvals. It is part of
the initvals tool in qca-swiss-army-knife.

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] Hardware Timestamp Question

2014-02-18 Thread Sujith Manoharan
Adrian Chadd wrote:
 The AR9287 is the first chip with a second TSF counter, designed to be
 free-running and not be locked into the AP broadcast TSF. Ie, if you
 wanted to be an AP and a STA, you'd have one TSF for the AP and one
 TSF for the STA association. But I don't know how it all works in too
 much depth and I'm not sure how the relevant TSF gets stamped to which
 RX frame.

Are you sure ? I think AR9485 is the first chip with 2 TSF counters.

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] Slow connection when using eduroam (AR9285)

2014-02-18 Thread Sujith Manoharan
Marco André Dinis wrote:
 Could you point me to a link on how can I do that?
 
 I found this: 
 http://blog.securism.com/2009/01/how-to-cutting-edge-wireless-drivers-in-ubuntu/
 but not sure i can use it since it's using another repo.

backports is the easiest way to get the latest driver.

https://backports.wiki.kernel.org/index.php/Main_Page
Latest release: 
https://www.kernel.org/pub/linux/kernel/projects/backports/2014/02/10/

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] [PATCH] ath9k: Fix ETSI compliance for AR9462 2.0

2014-02-16 Thread Sujith Manoharan
Felix Fietkau wrote:
 Wouldn't it be better to do this for all AR93xx chipsets in
 ar9003_hw_apply_minccapwr_thresh instead of initvals?
 I'm pretty sure this patch will leave most other devices non-compliant.

The threshold values are adjusted for each chip and are not the same
for all chips in the AR9003 family, so this is done in the initvals.

ar9003_hw_apply_minccapwr_thresh() will be used only for chips which
contain the new 'MinCCApwr' field in struct ar9300_BaseExtension_1.
This is not present in almost all the AR9003-family chips. I believe it has
been introduced in AR955x.

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] [PATCH] ath9k: Fix ETSI compliance for AR9462 2.0

2014-02-16 Thread Sujith Manoharan
Felix Fietkau wrote:
 Almost all chips are using the same values in the initvals - the
 exceptions seem to be the ones that have had ETSI compliance fix
 attempts already. I'm pretty sure the new values (if adjusted for
 different bands) would be fully compatible.

For most of the chips, adjusting AR_PHY_CCA_MAX_GOOD_VAL_9300_2GHZ/5GHZ
from the previous values to -60 is sufficient and the initvals don't
need any changes to be compliant. For some chips, the change in the max. CCA
threshold require adjustments in the minCCApwr_thr field - it is easier to do 
this
via the initvals.

This has been done for AR9485, AR9462 and AR9565 so far.

AR9485: new value is -50 dB

AR9565: new value is -92 dB

AR9462:
chain 0 : 2G: -91dB, 5G: -88dB
chain 1 : 2G: -91dB, 5G: -90dB

The SoC chips do not have any corresponding changes in
minCCApwr_thr for the new CCA_MAX_GOOD_VAL. The only weird exception
is AR9331 which has new minCCApwr_thr values in the internal PCOEM driver,
but not in the SoC driver - not sure which one is correct.

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] Atheros QCWB335 / AR9565 / QCA9565 Bluetooth

2014-02-14 Thread Sujith Manoharan
Joshua Richenhagen wrote:
 Dear Sujith,
 
 finally I found the real reason, ath3k fails to work approximately 2/3
 of the time if btusb is connected to a pin which uses the xhci driver.
 I compiled a dkms kernel package, with the help of a very nice
 canonical employee, which switches the usb pin of the bt device to
 ehci on startup. Now ath3k and my bluetooth works like a charm 100% of
 the time. However, this is just a workaround for a very nasty bug. Can
 you forward this information to the bluetooth devs?

Sure, I will.

Thanks for tracking down this bug !

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH] ath9k: Fix ETSI compliance for AR9462 2.0

2014-02-13 Thread Sujith Manoharan
From: Sujith Manoharan c_man...@qca.qualcomm.com

The minimum CCA power threshold values have to be adjusted
for existing cards to be in compliance with new regulations.
Newer cards will make use of the values obtained from EEPROM,
support for this was added earlier. To make sure that cards
that are already in use and don't have proper values in EEPROM,
do not violate regulations, use the initvals instead.

Cc: sta...@vger.kernel.org
Reported-by: Jeang Daniel dyje...@qca.qualcomm.com
Signed-off-by: Sujith Manoharan c_man...@qca.qualcomm.com
---
 drivers/net/wireless/ath/ath9k/ar9462_2p0_initvals.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar9462_2p0_initvals.h 
b/drivers/net/wireless/ath/ath9k/ar9462_2p0_initvals.h
index 1cc1356..1b6b4d0 100644
--- a/drivers/net/wireless/ath/ath9k/ar9462_2p0_initvals.h
+++ b/drivers/net/wireless/ath/ath9k/ar9462_2p0_initvals.h
@@ -57,7 +57,7 @@ static const u32 ar9462_2p0_baseband_postamble[][5] = {
{0x9e14, 0x37b95d5e, 0x37b9605e, 0x3236605e, 0x32365a5e},
{0x9e18, 0x, 0x, 0x, 0x},
{0x9e1c, 0x0001cf9c, 0x0001cf9c, 0x00021f9c, 0x00021f9c},
-   {0x9e20, 0x03b5, 0x03b5, 0x03ce, 0x03ce},
+   {0x9e20, 0x03a5, 0x03a5, 0x03a5, 0x03a5},
{0x9e2c, 0x001c, 0x001c, 0x0021, 0x0021},
{0x9e3c, 0xcf946220, 0xcf946220, 0xcfd5c782, 0xcfd5c282},
{0x9e44, 0x62321e27, 0x62321e27, 0xfe291e27, 0xfe291e27},
@@ -96,7 +96,7 @@ static const u32 ar9462_2p0_baseband_postamble[][5] = {
{0xae04, 0x001c, 0x001c, 0x001c, 0x0010},
{0xae18, 0x, 0x, 0x, 0x},
{0xae1c, 0x019c, 0x019c, 0x019c, 0x019c},
-   {0xae20, 0x01b5, 0x01b5, 0x01ce, 0x01ce},
+   {0xae20, 0x01a6, 0x01a6, 0x01aa, 0x01aa},
{0xb284, 0x, 0x, 0x0550, 0x0550},
 };
 
-- 
1.8.5.4

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] [PATCH v2 00/13] eliminate some ath9k_htc code

2014-02-12 Thread Sujith Manoharan
Oleksij Rempel wrote:
 what is about this change set? Should i resend it.

As long as it doesn't introduce any regression or behavioral change
in ath9k, they look good. :)

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] [PATCH v2] ath9k: Remove ath9k rate control

2014-02-06 Thread Sujith Manoharan
Ben Greear wrote:
 Can you let us know the details on how your set up that TCP
 traffic?  For instance, number of streams, write size, socket
 buffer sizes, etc?  Upload, download, or are both similar
 throughput in your testing?

Stock OpenWrt (trunk) running on a 3x3 Scorpion board (AP136/AP135) as AP.
Windows 7 as client, using a 3x3 AR9300 card.

iperf with window size 512k, 4 parallel threads. With both
TX and RX, 290+ Mbps is seen. UDP traffic: 330 Mbps in both directions.
Environment: open air and the station is located about 1 meter from the AP.

 I find that those settings influence throughput a great deal,
 and I have not yet been able to reach 295Mbps of TCP throughput
 in our testing w/out hacking the tcp-ack logic to increase ack delays.

By adjusting TCP parameters using sysctl or hacking the code ?

Sujith
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 1/7] ath9k: Fix IQ cal post processing for SoC

2014-02-06 Thread Sujith Manoharan
From: Sujith Manoharan c_man...@qca.qualcomm.com

Calibration data is not reused for SoC chips, so
call ar9003_hw_tx_iq_cal_post_proc() with the correct
argument. The 'is_reusable' flag is currently used
only for PC-OEM chips, but it makes things clearer to
specify it explicity.

Signed-off-by: Sujith Manoharan c_man...@qca.qualcomm.com
---
 drivers/net/wireless/ath/ath9k/ar9003_calib.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_calib.c 
b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
index a352128..225b758 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
@@ -1461,7 +1461,7 @@ static bool ar9003_hw_init_cal_soc(struct ath_hw *ah,
struct ath_common *common = ath9k_hw_common(ah);
struct ath9k_hw_cal_data *caldata = ah-caldata;
bool txiqcal_done = false;
-   bool is_reusable = true, status = true;
+   bool status = true;
bool run_agc_cal = false, sep_iq_cal = false;
 
/* Use chip chainmask only for calibration */
@@ -1531,7 +1531,7 @@ skip_tx_iqcal:
}
 
if (txiqcal_done)
-   ar9003_hw_tx_iq_cal_post_proc(ah, is_reusable);
+   ar9003_hw_tx_iq_cal_post_proc(ah, false);
 
/* Revert chainmask to runtime parameters */
ar9003_hw_set_chain_masks(ah, ah-rxchainmask, ah-txchainmask);
-- 
1.8.5.3

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 0/7] ath9k patches

2014-02-06 Thread Sujith Manoharan
From: Sujith Manoharan c_man...@qca.qualcomm.com

This series updates the IQ calibration code, fixing various
issues. There are still some more issues to be addressed.

Sujith Manoharan (7):
  ath9k: Fix IQ cal post processing for SoC
  ath9k: Check explicitly for IQ calibration
  ath9k: Rename ar9003_hw_tx_iqcal_load_avg_2_passes
  ath9k: Fix magnitude/phase calculation
  ath9k: Modify IQ calibration for AR955x
  ath9k: Expand the IQ coefficient array
  ath9k: Calculate IQ-CAL median

 drivers/net/wireless/ath/ath9k/ar9003_calib.c | 232 +++---
 1 file changed, 173 insertions(+), 59 deletions(-)

-- 
1.8.5.3

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 2/7] ath9k: Check explicitly for IQ calibration

2014-02-06 Thread Sujith Manoharan
From: Sujith Manoharan c_man...@qca.qualcomm.com

In chips like AR955x, the initvals contain the information
whether IQ calibration is to be done in the HW when an
AGC calibration is triggered. Check if IQ-CAL is enabled
in the initvals before flagging 'txiqcal_done' as true.

Signed-off-by: Sujith Manoharan c_man...@qca.qualcomm.com
---
 drivers/net/wireless/ath/ath9k/ar9003_calib.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_calib.c 
b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
index 225b758..0ee4250 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
@@ -1485,7 +1485,12 @@ static bool ar9003_hw_init_cal_soc(struct ath_hw *ah,
 * AGC calibration. Specifically, AR9550 in SoC chips.
 */
if (ah-enabled_cals  TX_IQ_ON_AGC_CAL) {
-   txiqcal_done = true;
+   if (REG_READ_FIELD(ah, AR_PHY_TX_IQCAL_CONTROL_0,
+  AR_PHY_TX_IQCAL_CONTROL_0_ENABLE_TXIQ_CAL)) {
+   txiqcal_done = true;
+   } else {
+   txiqcal_done = false;
+   }
run_agc_cal = true;
} else {
sep_iq_cal = true;
-- 
1.8.5.3

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 3/7] ath9k: Rename ar9003_hw_tx_iqcal_load_avg_2_passes

2014-02-06 Thread Sujith Manoharan
From: Sujith Manoharan c_man...@qca.qualcomm.com

Use ar9003_hw_tx_iq_cal_outlier_detection instead.

Signed-off-by: Sujith Manoharan c_man...@qca.qualcomm.com
---
 drivers/net/wireless/ath/ath9k/ar9003_calib.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_calib.c 
b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
index 0ee4250..9210beb 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
@@ -886,9 +886,9 @@ static void ar9003_hw_detect_outlier(int *mp_coeff, int 
nmeasurement,
}
 }
 
-static void ar9003_hw_tx_iqcal_load_avg_2_passes(struct ath_hw *ah,
-struct coeff *coeff,
-bool is_reusable)
+static void ar9003_hw_tx_iq_cal_outlier_detection(struct ath_hw *ah,
+ struct coeff *coeff,
+ bool is_reusable)
 {
int i, im, nmeasurement;
u32 tx_corr_coeff[MAX_MEASUREMENT][AR9300_MAX_CHAINS];
@@ -1075,7 +1075,7 @@ static void ar9003_hw_tx_iq_cal_post_proc(struct ath_hw 
*ah, bool is_reusable)
coeff.phs_coeff[i][im] -= 128;
}
}
-   ar9003_hw_tx_iqcal_load_avg_2_passes(ah, coeff, is_reusable);
+   ar9003_hw_tx_iq_cal_outlier_detection(ah, coeff, is_reusable);
 
return;
 
-- 
1.8.5.3

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 4/7] ath9k: Fix magnitude/phase calculation

2014-02-06 Thread Sujith Manoharan
From: Sujith Manoharan c_man...@qca.qualcomm.com

Incorrect values are programmed in the registers
containing the IQ correction coefficients by the IQ-CAL
post-processing code. Fix this.

Signed-off-by: Sujith Manoharan c_man...@qca.qualcomm.com
---
 drivers/net/wireless/ath/ath9k/ar9003_calib.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_calib.c 
b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
index 9210beb..6d4cb00 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
@@ -891,6 +891,7 @@ static void ar9003_hw_tx_iq_cal_outlier_detection(struct 
ath_hw *ah,
  bool is_reusable)
 {
int i, im, nmeasurement;
+   int magnitude, phase;
u32 tx_corr_coeff[MAX_MEASUREMENT][AR9300_MAX_CHAINS];
struct ath9k_hw_cal_data *caldata = ah-caldata;
 
@@ -932,9 +933,11 @@ static void ar9003_hw_tx_iq_cal_outlier_detection(struct 
ath_hw *ah,
}
 
for (im = 0; im  nmeasurement; im++) {
+   magnitude = coeff-mag_coeff[i][im];
+   phase = coeff-phs_coeff[i][im];
 
-   coeff-iqc_coeff[0] = (coeff-mag_coeff[i][im]  0x7f) |
-   ((coeff-phs_coeff[i][im]  0x7f)  7);
+   coeff-iqc_coeff[0] =
+   (phase  0x7f) | ((magnitude  0x7f)  7);
 
if ((im % 2) == 0)
REG_RMW_FIELD(ah, tx_corr_coeff[im][i],
@@ -1065,8 +1068,9 @@ static void ar9003_hw_tx_iq_cal_post_proc(struct ath_hw 
*ah, bool is_reusable)
goto tx_iqcal_fail;
}
 
-   coeff.mag_coeff[i][im] = coeff.iqc_coeff[0]  0x7f;
coeff.phs_coeff[i][im] =
+   coeff.iqc_coeff[0]  0x7f;
+   coeff.mag_coeff[i][im] =
(coeff.iqc_coeff[0]  7)  0x7f;
 
if (coeff.mag_coeff[i][im]  63)
-- 
1.8.5.3

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 7/7] ath9k: Calculate IQ-CAL median

2014-02-06 Thread Sujith Manoharan
From: Sujith Manoharan c_man...@qca.qualcomm.com

This patch adds a routine to calculate the median IQ correction
values for AR955x, which is used for outlier detection.
The normal method which is used for all other chips is
bypassed for AR955x.

Signed-off-by: Sujith Manoharan c_man...@qca.qualcomm.com
---
 drivers/net/wireless/ath/ath9k/ar9003_calib.c | 91 +++
 1 file changed, 79 insertions(+), 12 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_calib.c 
b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
index 6f2a994..8bd4474 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
@@ -923,15 +923,22 @@ static void ar9003_hw_tx_iq_cal_outlier_detection(struct 
ath_hw *ah,
if (nmeasurement  MAX_MEASUREMENT)
nmeasurement = MAX_MEASUREMENT;
 
-   /* detect outlier only if nmeasurement  1 */
-   if (nmeasurement  1) {
-   /* Detect magnitude outlier */
-   ar9003_hw_detect_outlier(coeff-mag_coeff[i],
-   nmeasurement, MAX_MAG_DELTA);
-
-   /* Detect phase outlier */
-   ar9003_hw_detect_outlier(coeff-phs_coeff[i],
-   nmeasurement, MAX_PHS_DELTA);
+   /*
+* Skip normal outlier detection for AR9550.
+*/
+   if (!AR_SREV_9550(ah)) {
+   /* detect outlier only if nmeasurement  1 */
+   if (nmeasurement  1) {
+   /* Detect magnitude outlier */
+   ar9003_hw_detect_outlier(coeff-mag_coeff[i],
+nmeasurement,
+MAX_MAG_DELTA);
+
+   /* Detect phase outlier */
+   ar9003_hw_detect_outlier(coeff-phs_coeff[i],
+nmeasurement,
+MAX_PHS_DELTA);
+   }
}
 
for (im = 0; im  nmeasurement; im++) {
@@ -996,6 +1003,60 @@ static bool ar9003_hw_tx_iq_cal_run(struct ath_hw *ah)
return true;
 }
 
+static void __ar955x_tx_iq_cal_sort(struct ath_hw *ah,
+   struct coeff *coeff,
+   int i, int nmeasurement)
+{
+   struct ath_common *common = ath9k_hw_common(ah);
+   int im, ix, iy, temp;
+
+   for (im = 0; im  nmeasurement; im++) {
+   for (ix = 0; ix  MAXIQCAL - 1; ix++) {
+   for (iy = ix + 1; iy = MAXIQCAL - 1; iy++) {
+   if (coeff-mag_coeff[i][im][iy] 
+   coeff-mag_coeff[i][im][ix]) {
+   temp = coeff-mag_coeff[i][im][ix];
+   coeff-mag_coeff[i][im][ix] =
+   coeff-mag_coeff[i][im][iy];
+   coeff-mag_coeff[i][im][iy] = temp;
+   }
+   if (coeff-phs_coeff[i][im][iy] 
+   coeff-phs_coeff[i][im][ix]) {
+   temp = coeff-phs_coeff[i][im][ix];
+   coeff-phs_coeff[i][im][ix] =
+   coeff-phs_coeff[i][im][iy];
+   coeff-phs_coeff[i][im][iy] = temp;
+   }
+   }
+   }
+   coeff-mag_coeff[i][im][0] = coeff-mag_coeff[i][im][MAXIQCAL / 
2];
+   coeff-phs_coeff[i][im][0] = coeff-phs_coeff[i][im][MAXIQCAL / 
2];
+
+   ath_dbg(common, CALIBRATE,
+   IQCAL: Median [ch%d][gain%d]: mag = %d phase = %d\n,
+   i, im,
+   coeff-mag_coeff[i][im][0],
+   coeff-phs_coeff[i][im][0]);
+   }
+}
+
+static bool ar955x_tx_iq_cal_median(struct ath_hw *ah,
+   struct coeff *coeff,
+   int iqcal_idx,
+   int nmeasurement)
+{
+   int i;
+
+   if ((iqcal_idx + 1) != MAXIQCAL)
+   return false;
+
+   for (i = 0; i  AR9300_MAX_CHAINS; i++) {
+   __ar955x_tx_iq_cal_sort(ah, coeff, i, nmeasurement);
+   }
+
+   return true;
+}
+
 static void ar9003_hw_tx_iq_cal_post_proc(struct ath_hw *ah,
  int iqcal_idx,
  bool is_reusable)
@@ -1011,10 +1072,11 @@ static void ar9003_hw_tx_iq_cal_post_proc(struct ath_hw 
*ah

[ath9k-devel] [PATCH 6/7] ath9k: Expand the IQ coefficient array

2014-02-06 Thread Sujith Manoharan
From: Sujith Manoharan c_man...@qca.qualcomm.com

This will be used for storing data for mutiple
IQ calibration runs, for AR955x.

Signed-off-by: Sujith Manoharan c_man...@qca.qualcomm.com
---
 drivers/net/wireless/ath/ath9k/ar9003_calib.c | 41 ++-
 1 file changed, 21 insertions(+), 20 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_calib.c 
b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
index 4a02ceb..6f2a994 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
@@ -26,8 +26,8 @@
 #define MAXIQCAL3
 
 struct coeff {
-   int mag_coeff[AR9300_MAX_CHAINS][MAX_MEASUREMENT];
-   int phs_coeff[AR9300_MAX_CHAINS][MAX_MEASUREMENT];
+   int mag_coeff[AR9300_MAX_CHAINS][MAX_MEASUREMENT][MAXIQCAL];
+   int phs_coeff[AR9300_MAX_CHAINS][MAX_MEASUREMENT][MAXIQCAL];
int iqc_coeff[2];
 };
 
@@ -840,7 +840,8 @@ static bool ar9003_hw_calc_iq_corr(struct ath_hw *ah,
return true;
 }
 
-static void ar9003_hw_detect_outlier(int *mp_coeff, int nmeasurement,
+static void ar9003_hw_detect_outlier(int mp_coeff[][MAXIQCAL],
+int nmeasurement,
 int max_delta)
 {
int mp_max = -64, max_idx = 0;
@@ -849,20 +850,20 @@ static void ar9003_hw_detect_outlier(int *mp_coeff, int 
nmeasurement,
 
/* find min/max mismatch across all calibrated gains */
for (i = 0; i  nmeasurement; i++) {
-   if (mp_coeff[i]  mp_max) {
-   mp_max = mp_coeff[i];
+   if (mp_coeff[i][0]  mp_max) {
+   mp_max = mp_coeff[i][0];
max_idx = i;
-   } else if (mp_coeff[i]  mp_min) {
-   mp_min = mp_coeff[i];
+   } else if (mp_coeff[i][0]  mp_min) {
+   mp_min = mp_coeff[i][0];
min_idx = i;
}
}
 
/* find average (exclude max abs value) */
for (i = 0; i  nmeasurement; i++) {
-   if ((abs(mp_coeff[i])  abs(mp_max)) ||
-   (abs(mp_coeff[i])  abs(mp_min))) {
-   mp_avg += mp_coeff[i];
+   if ((abs(mp_coeff[i][0])  abs(mp_max)) ||
+   (abs(mp_coeff[i][0])  abs(mp_min))) {
+   mp_avg += mp_coeff[i][0];
mp_count++;
}
}
@@ -874,7 +875,7 @@ static void ar9003_hw_detect_outlier(int *mp_coeff, int 
nmeasurement,
if (mp_count)
mp_avg /= mp_count;
else
-   mp_avg = mp_coeff[nmeasurement - 1];
+   mp_avg = mp_coeff[nmeasurement - 1][0];
 
/* detect outlier */
if (abs(mp_max - mp_min)  max_delta) {
@@ -883,7 +884,7 @@ static void ar9003_hw_detect_outlier(int *mp_coeff, int 
nmeasurement,
else
outlier_idx = min_idx;
 
-   mp_coeff[outlier_idx] = mp_avg;
+   mp_coeff[outlier_idx][0] = mp_avg;
}
 }
 
@@ -934,8 +935,8 @@ static void ar9003_hw_tx_iq_cal_outlier_detection(struct 
ath_hw *ah,
}
 
for (im = 0; im  nmeasurement; im++) {
-   magnitude = coeff-mag_coeff[i][im];
-   phase = coeff-phs_coeff[i][im];
+   magnitude = coeff-mag_coeff[i][im][0];
+   phase = coeff-phs_coeff[i][im][0];
 
coeff-iqc_coeff[0] =
(phase  0x7f) | ((magnitude  0x7f)  7);
@@ -1071,15 +1072,15 @@ static void ar9003_hw_tx_iq_cal_post_proc(struct ath_hw 
*ah,
goto tx_iqcal_fail;
}
 
-   coeff.phs_coeff[i][im] =
+   coeff.phs_coeff[i][im][iqcal_idx] =
coeff.iqc_coeff[0]  0x7f;
-   coeff.mag_coeff[i][im] =
+   coeff.mag_coeff[i][im][iqcal_idx] =
(coeff.iqc_coeff[0]  7)  0x7f;
 
-   if (coeff.mag_coeff[i][im]  63)
-   coeff.mag_coeff[i][im] -= 128;
-   if (coeff.phs_coeff[i][im]  63)
-   coeff.phs_coeff[i][im] -= 128;
+   if (coeff.mag_coeff[i][im][iqcal_idx]  63)
+   coeff.mag_coeff[i][im][iqcal_idx] -= 128;
+   if (coeff.phs_coeff[i][im][iqcal_idx]  63)
+   coeff.phs_coeff[i][im][iqcal_idx] -= 128;
}
}
ar9003_hw_tx_iq_cal_outlier_detection(ah, coeff, is_reusable);
-- 
1.8.5.3

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH] ath9k: Fix TX power calculation

2014-02-03 Thread Sujith Manoharan
From: Sujith Manoharan c_man...@qca.qualcomm.com

The commit, ath9k_hw: Fix incorrect Tx control power in AR9003 template
fixed the incorrect values in the eeprom templates, but if
boards have already been calibrated with incorrect values,
they would still be using the wrong TX power. Fix this by assigning
a default value in such cases.

Cc: Rajkumar Manoharan rmano...@qti.qualcomm.com
Signed-off-by: Sujith Manoharan c_man...@qca.qualcomm.com
---
 drivers/net/wireless/ath/ath9k/ar9003_eeprom.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c 
b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
index 25243cb..b8daff7 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
@@ -5065,6 +5065,10 @@ static u16 ar9003_hw_get_max_edge_power(struct 
ar9300_eeprom *eep,
break;
}
}
+
+   if (is2GHz  !twiceMaxEdgePower)
+   twiceMaxEdgePower = 60;
+
return twiceMaxEdgePower;
 }
 
-- 
1.8.5.3

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


  1   2   3   4   5   6   7   8   >