Signed-off-by: Felix Fietkau <nbd@nbd.name>master
parent
98e4b504b4
commit
207338c78e
@ -0,0 +1,57 @@ |
|||||||
|
From: Felix Fietkau <nbd@nbd.name>
|
||||||
|
Date: Mon, 11 Jul 2016 11:31:39 +0200
|
||||||
|
Subject: [PATCH] ath9k_hw: fix duplicate (and partially wrong) definition
|
||||||
|
of AR_CH0_THERM
|
||||||
|
|
||||||
|
AR_PHY_65NM_CH0_THERM and AR_CH0_THERM were supposed to refer to the
|
||||||
|
same register, however they had different SREV checks.
|
||||||
|
|
||||||
|
Remove the duplicate and use the checks. Since there were other SREV
|
||||||
|
checks present in the only place that uses this, this will probaby not
|
||||||
|
affect runtime behavior.
|
||||||
|
|
||||||
|
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||||
|
---
|
||||||
|
|
||||||
|
--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.h
|
||||||
|
+++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
|
||||||
|
@@ -689,13 +689,6 @@
|
||||||
|
#define AR_CH0_TOP_XPABIASLVL (AR_SREV_9550(ah) ? 0x3c0 : 0x300)
|
||||||
|
#define AR_CH0_TOP_XPABIASLVL_S (AR_SREV_9550(ah) ? 6 : 8)
|
||||||
|
|
||||||
|
-#define AR_CH0_THERM (AR_SREV_9300(ah) ? 0x16290 : \
|
||||||
|
- ((AR_SREV_9485(ah) ? 0x1628c : 0x16294)))
|
||||||
|
-#define AR_CH0_THERM_XPABIASLVL_MSB 0x3
|
||||||
|
-#define AR_CH0_THERM_XPABIASLVL_MSB_S 0
|
||||||
|
-#define AR_CH0_THERM_XPASHORT2GND 0x4
|
||||||
|
-#define AR_CH0_THERM_XPASHORT2GND_S 2
|
||||||
|
-
|
||||||
|
#define AR_SWITCH_TABLE_COM_ALL (0xffff)
|
||||||
|
#define AR_SWITCH_TABLE_COM_ALL_S (0)
|
||||||
|
#define AR_SWITCH_TABLE_COM_AR9462_ALL (0xffffff)
|
||||||
|
@@ -712,15 +705,17 @@
|
||||||
|
#define AR_SWITCH_TABLE_ALL (0xfff)
|
||||||
|
#define AR_SWITCH_TABLE_ALL_S (0)
|
||||||
|
|
||||||
|
-#define AR_PHY_65NM_CH0_THERM (AR_SREV_9300(ah) ? 0x16290 :\
|
||||||
|
- ((AR_SREV_9462(ah) || AR_SREV_9565(ah)) ? 0x16294 : 0x1628c))
|
||||||
|
+#define AR_CH0_THERM (AR_SREV_9300(ah) ? 0x16290 :\
|
||||||
|
+ ((AR_SREV_9462(ah) || AR_SREV_9565(ah)) ? 0x16294 : 0x1628c))
|
||||||
|
+#define AR_CH0_THERM_XPABIASLVL_MSB 0x3
|
||||||
|
+#define AR_CH0_THERM_XPABIASLVL_MSB_S 0
|
||||||
|
+#define AR_CH0_THERM_XPASHORT2GND 0x4
|
||||||
|
+#define AR_CH0_THERM_XPASHORT2GND_S 2
|
||||||
|
|
||||||
|
-#define AR_PHY_65NM_CH0_THERM_LOCAL 0x80000000
|
||||||
|
-#define AR_PHY_65NM_CH0_THERM_LOCAL_S 31
|
||||||
|
-#define AR_PHY_65NM_CH0_THERM_START 0x20000000
|
||||||
|
-#define AR_PHY_65NM_CH0_THERM_START_S 29
|
||||||
|
-#define AR_PHY_65NM_CH0_THERM_SAR_ADC_OUT 0x0000ff00
|
||||||
|
-#define AR_PHY_65NM_CH0_THERM_SAR_ADC_OUT_S 8
|
||||||
|
+#define AR_CH0_THERM_LOCAL 0x80000000
|
||||||
|
+#define AR_CH0_THERM_START 0x20000000
|
||||||
|
+#define AR_CH0_THERM_SAR_ADC_OUT 0x0000ff00
|
||||||
|
+#define AR_CH0_THERM_SAR_ADC_OUT_S 8
|
||||||
|
|
||||||
|
#define AR_CH0_TOP2 (AR_SREV_9300(ah) ? 0x1628c : \
|
||||||
|
(AR_SREV_9462(ah) ? 0x16290 : 0x16284))
|
@ -0,0 +1,88 @@ |
|||||||
|
From: Felix Fietkau <nbd@nbd.name>
|
||||||
|
Date: Mon, 11 Jul 2016 11:34:47 +0200
|
||||||
|
Subject: [PATCH] ath9k_hw: simplify ar9003_hw_per_calibration
|
||||||
|
|
||||||
|
Reduce indentation, use a variable to save a few pointer dereferences
|
||||||
|
|
||||||
|
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||||
|
---
|
||||||
|
|
||||||
|
--- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
|
||||||
|
+++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
|
||||||
|
@@ -75,50 +75,49 @@ static bool ar9003_hw_per_calibration(st
|
||||||
|
struct ath9k_cal_list *currCal)
|
||||||
|
{
|
||||||
|
struct ath9k_hw_cal_data *caldata = ah->caldata;
|
||||||
|
- /* Cal is assumed not done until explicitly set below */
|
||||||
|
- bool iscaldone = false;
|
||||||
|
+ const struct ath9k_percal_data *cur_caldata = currCal->calData;
|
||||||
|
|
||||||
|
/* Calibration in progress. */
|
||||||
|
if (currCal->calState == CAL_RUNNING) {
|
||||||
|
/* Check to see if it has finished. */
|
||||||
|
- if (!(REG_READ(ah, AR_PHY_TIMING4) & AR_PHY_TIMING4_DO_CAL)) {
|
||||||
|
- /*
|
||||||
|
- * Accumulate cal measures for active chains
|
||||||
|
- */
|
||||||
|
- currCal->calData->calCollect(ah);
|
||||||
|
- ah->cal_samples++;
|
||||||
|
+ if (REG_READ(ah, AR_PHY_TIMING4) & AR_PHY_TIMING4_DO_CAL)
|
||||||
|
+ return false;
|
||||||
|
|
||||||
|
- if (ah->cal_samples >=
|
||||||
|
- currCal->calData->calNumSamples) {
|
||||||
|
- unsigned int i, numChains = 0;
|
||||||
|
- for (i = 0; i < AR9300_MAX_CHAINS; i++) {
|
||||||
|
- if (rxchainmask & (1 << i))
|
||||||
|
- numChains++;
|
||||||
|
- }
|
||||||
|
+ /*
|
||||||
|
+ * Accumulate cal measures for active chains
|
||||||
|
+ */
|
||||||
|
+ cur_caldata->calCollect(ah);
|
||||||
|
+ ah->cal_samples++;
|
||||||
|
|
||||||
|
- /*
|
||||||
|
- * Process accumulated data
|
||||||
|
- */
|
||||||
|
- currCal->calData->calPostProc(ah, numChains);
|
||||||
|
+ if (ah->cal_samples >= cur_caldata->calNumSamples) {
|
||||||
|
+ unsigned int i, numChains = 0;
|
||||||
|
+ for (i = 0; i < AR9300_MAX_CHAINS; i++) {
|
||||||
|
+ if (rxchainmask & (1 << i))
|
||||||
|
+ numChains++;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
- /* Calibration has finished. */
|
||||||
|
- caldata->CalValid |= currCal->calData->calType;
|
||||||
|
- currCal->calState = CAL_DONE;
|
||||||
|
- iscaldone = true;
|
||||||
|
- } else {
|
||||||
|
+ /*
|
||||||
|
+ * Process accumulated data
|
||||||
|
+ */
|
||||||
|
+ cur_caldata->calPostProc(ah, numChains);
|
||||||
|
+
|
||||||
|
+ /* Calibration has finished. */
|
||||||
|
+ caldata->CalValid |= cur_caldata->calType;
|
||||||
|
+ currCal->calState = CAL_DONE;
|
||||||
|
+ return true;
|
||||||
|
+ } else {
|
||||||
|
/*
|
||||||
|
* Set-up collection of another sub-sample until we
|
||||||
|
* get desired number
|
||||||
|
*/
|
||||||
|
ar9003_hw_setup_calibration(ah, currCal);
|
||||||
|
- }
|
||||||
|
}
|
||||||
|
- } else if (!(caldata->CalValid & currCal->calData->calType)) {
|
||||||
|
+ } else if (!(caldata->CalValid & cur_caldata->calType)) {
|
||||||
|
/* If current cal is marked invalid in channel, kick it off */
|
||||||
|
ath9k_hw_reset_calibration(ah, currCal);
|
||||||
|
}
|
||||||
|
|
||||||
|
- return iscaldone;
|
||||||
|
+ return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ar9003_hw_calibrate(struct ath_hw *ah, struct ath9k_channel *chan,
|
@ -0,0 +1,94 @@ |
|||||||
|
From: Felix Fietkau <nbd@nbd.name>
|
||||||
|
Date: Mon, 11 Jul 2016 11:35:20 +0200
|
||||||
|
Subject: [PATCH] ath9k_hw: get rid of some duplicate code in calibration
|
||||||
|
init
|
||||||
|
|
||||||
|
Remove a misleading debug message as well
|
||||||
|
|
||||||
|
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||||
|
---
|
||||||
|
|
||||||
|
--- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
|
||||||
|
+++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
|
||||||
|
@@ -1373,6 +1373,26 @@ static void ar9003_hw_cl_cal_post_proc(s
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+static void ar9003_hw_init_cal_common(struct ath_hw *ah)
|
||||||
|
+{
|
||||||
|
+ struct ath9k_hw_cal_data *caldata = ah->caldata;
|
||||||
|
+
|
||||||
|
+ /* Initialize list pointers */
|
||||||
|
+ ah->cal_list = ah->cal_list_last = ah->cal_list_curr = NULL;
|
||||||
|
+
|
||||||
|
+ INIT_CAL(&ah->iq_caldata);
|
||||||
|
+ INSERT_CAL(ah, &ah->iq_caldata);
|
||||||
|
+
|
||||||
|
+ /* Initialize current pointer to first element in list */
|
||||||
|
+ ah->cal_list_curr = ah->cal_list;
|
||||||
|
+
|
||||||
|
+ if (ah->cal_list_curr)
|
||||||
|
+ ath9k_hw_reset_calibration(ah, ah->cal_list_curr);
|
||||||
|
+
|
||||||
|
+ if (caldata)
|
||||||
|
+ caldata->CalValid = 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static bool ar9003_hw_init_cal_pcoem(struct ath_hw *ah,
|
||||||
|
struct ath9k_channel *chan)
|
||||||
|
{
|
||||||
|
@@ -1532,21 +1552,7 @@ skip_tx_iqcal:
|
||||||
|
/* Revert chainmask to runtime parameters */
|
||||||
|
ar9003_hw_set_chain_masks(ah, ah->rxchainmask, ah->txchainmask);
|
||||||
|
|
||||||
|
- /* Initialize list pointers */
|
||||||
|
- ah->cal_list = ah->cal_list_last = ah->cal_list_curr = NULL;
|
||||||
|
-
|
||||||
|
- INIT_CAL(&ah->iq_caldata);
|
||||||
|
- INSERT_CAL(ah, &ah->iq_caldata);
|
||||||
|
- ath_dbg(common, CALIBRATE, "enabling IQ Calibration\n");
|
||||||
|
-
|
||||||
|
- /* Initialize current pointer to first element in list */
|
||||||
|
- ah->cal_list_curr = ah->cal_list;
|
||||||
|
-
|
||||||
|
- if (ah->cal_list_curr)
|
||||||
|
- ath9k_hw_reset_calibration(ah, ah->cal_list_curr);
|
||||||
|
-
|
||||||
|
- if (caldata)
|
||||||
|
- caldata->CalValid = 0;
|
||||||
|
+ ar9003_hw_init_cal_common(ah);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@@ -1577,8 +1583,6 @@ static bool do_ar9003_agc_cal(struct ath
|
||||||
|
static bool ar9003_hw_init_cal_soc(struct ath_hw *ah,
|
||||||
|
struct ath9k_channel *chan)
|
||||||
|
{
|
||||||
|
- struct ath_common *common = ath9k_hw_common(ah);
|
||||||
|
- struct ath9k_hw_cal_data *caldata = ah->caldata;
|
||||||
|
bool txiqcal_done = false;
|
||||||
|
bool status = true;
|
||||||
|
bool run_agc_cal = false, sep_iq_cal = false;
|
||||||
|
@@ -1676,21 +1680,7 @@ skip_tx_iqcal:
|
||||||
|
/* Revert chainmask to runtime parameters */
|
||||||
|
ar9003_hw_set_chain_masks(ah, ah->rxchainmask, ah->txchainmask);
|
||||||
|
|
||||||
|
- /* Initialize list pointers */
|
||||||
|
- ah->cal_list = ah->cal_list_last = ah->cal_list_curr = NULL;
|
||||||
|
-
|
||||||
|
- INIT_CAL(&ah->iq_caldata);
|
||||||
|
- INSERT_CAL(ah, &ah->iq_caldata);
|
||||||
|
- ath_dbg(common, CALIBRATE, "enabling IQ Calibration\n");
|
||||||
|
-
|
||||||
|
- /* Initialize current pointer to first element in list */
|
||||||
|
- ah->cal_list_curr = ah->cal_list;
|
||||||
|
-
|
||||||
|
- if (ah->cal_list_curr)
|
||||||
|
- ath9k_hw_reset_calibration(ah, ah->cal_list_curr);
|
||||||
|
-
|
||||||
|
- if (caldata)
|
||||||
|
- caldata->CalValid = 0;
|
||||||
|
+ ar9003_hw_init_cal_common(ah);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
@ -0,0 +1,97 @@ |
|||||||
|
From: Felix Fietkau <nbd@nbd.name>
|
||||||
|
Date: Mon, 11 Jul 2016 11:35:55 +0200
|
||||||
|
Subject: [PATCH] ath9k_hw: implement temperature compensation support for
|
||||||
|
AR9003+
|
||||||
|
|
||||||
|
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||||
|
---
|
||||||
|
|
||||||
|
--- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
|
||||||
|
+++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
|
||||||
|
@@ -33,6 +33,7 @@ struct coeff {
|
||||||
|
|
||||||
|
enum ar9003_cal_types {
|
||||||
|
IQ_MISMATCH_CAL = BIT(0),
|
||||||
|
+ TEMP_COMP_CAL = BIT(1),
|
||||||
|
};
|
||||||
|
|
||||||
|
static void ar9003_hw_setup_calibration(struct ath_hw *ah,
|
||||||
|
@@ -58,6 +59,12 @@ static void ar9003_hw_setup_calibration(
|
||||||
|
/* Kick-off cal */
|
||||||
|
REG_SET_BIT(ah, AR_PHY_TIMING4, AR_PHY_TIMING4_DO_CAL);
|
||||||
|
break;
|
||||||
|
+ case TEMP_COMP_CAL:
|
||||||
|
+ ath_dbg(common, CALIBRATE,
|
||||||
|
+ "starting Temperature Compensation Calibration\n");
|
||||||
|
+ REG_SET_BIT(ah, AR_CH0_THERM, AR_CH0_THERM_LOCAL);
|
||||||
|
+ REG_SET_BIT(ah, AR_CH0_THERM, AR_CH0_THERM_START);
|
||||||
|
+ break;
|
||||||
|
default:
|
||||||
|
ath_err(common, "Invalid calibration type\n");
|
||||||
|
break;
|
||||||
|
@@ -86,7 +93,8 @@ static bool ar9003_hw_per_calibration(st
|
||||||
|
/*
|
||||||
|
* Accumulate cal measures for active chains
|
||||||
|
*/
|
||||||
|
- cur_caldata->calCollect(ah);
|
||||||
|
+ if (cur_caldata->calCollect)
|
||||||
|
+ cur_caldata->calCollect(ah);
|
||||||
|
ah->cal_samples++;
|
||||||
|
|
||||||
|
if (ah->cal_samples >= cur_caldata->calNumSamples) {
|
||||||
|
@@ -99,7 +107,8 @@ static bool ar9003_hw_per_calibration(st
|
||||||
|
/*
|
||||||
|
* Process accumulated data
|
||||||
|
*/
|
||||||
|
- cur_caldata->calPostProc(ah, numChains);
|
||||||
|
+ if (cur_caldata->calPostProc)
|
||||||
|
+ cur_caldata->calPostProc(ah, numChains);
|
||||||
|
|
||||||
|
/* Calibration has finished. */
|
||||||
|
caldata->CalValid |= cur_caldata->calType;
|
||||||
|
@@ -314,9 +323,16 @@ static const struct ath9k_percal_data iq
|
||||||
|
ar9003_hw_iqcalibrate
|
||||||
|
};
|
||||||
|
|
||||||
|
+static const struct ath9k_percal_data temp_cal_single_sample = {
|
||||||
|
+ TEMP_COMP_CAL,
|
||||||
|
+ MIN_CAL_SAMPLES,
|
||||||
|
+ PER_MAX_LOG_COUNT,
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
static void ar9003_hw_init_cal_settings(struct ath_hw *ah)
|
||||||
|
{
|
||||||
|
ah->iq_caldata.calData = &iq_cal_single_sample;
|
||||||
|
+ ah->temp_caldata.calData = &temp_cal_single_sample;
|
||||||
|
|
||||||
|
if (AR_SREV_9300_20_OR_LATER(ah)) {
|
||||||
|
ah->enabled_cals |= TX_IQ_CAL;
|
||||||
|
@@ -324,7 +340,7 @@ static void ar9003_hw_init_cal_settings(
|
||||||
|
ah->enabled_cals |= TX_IQ_ON_AGC_CAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
- ah->supp_cals = IQ_MISMATCH_CAL;
|
||||||
|
+ ah->supp_cals = IQ_MISMATCH_CAL | TEMP_COMP_CAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define OFF_UPPER_LT 24
|
||||||
|
@@ -1383,6 +1399,9 @@ static void ar9003_hw_init_cal_common(st
|
||||||
|
INIT_CAL(&ah->iq_caldata);
|
||||||
|
INSERT_CAL(ah, &ah->iq_caldata);
|
||||||
|
|
||||||
|
+ INIT_CAL(&ah->temp_caldata);
|
||||||
|
+ INSERT_CAL(ah, &ah->temp_caldata);
|
||||||
|
+
|
||||||
|
/* Initialize current pointer to first element in list */
|
||||||
|
ah->cal_list_curr = ah->cal_list;
|
||||||
|
|
||||||
|
--- a/drivers/net/wireless/ath/ath9k/hw.h
|
||||||
|
+++ b/drivers/net/wireless/ath/ath9k/hw.h
|
||||||
|
@@ -830,6 +830,7 @@ struct ath_hw {
|
||||||
|
/* Calibration */
|
||||||
|
u32 supp_cals;
|
||||||
|
struct ath9k_cal_list iq_caldata;
|
||||||
|
+ struct ath9k_cal_list temp_caldata;
|
||||||
|
struct ath9k_cal_list adcgain_caldata;
|
||||||
|
struct ath9k_cal_list adcdc_caldata;
|
||||||
|
struct ath9k_cal_list *cal_list;
|
Loading…
Reference in new issue