2022-05-13 14:25:19

by Wenli Looi

[permalink] [raw]
Subject: [PATCH v2 8/9] ath9k: rename ar9300_eeprom to ar9300_eeprom_v1

This clearly distinguishes it from ar9300_eeprom_v2 which will be
introduced next. It will break external patches involving ar9300_eeprom,
which is desired because those patches will probably be no longer
correct. The number of chains in the eeprom is also decoupled from
AR9300_MAX_CHAINS, which is the number of chains supported by the
driver.

Signed-off-by: Wenli Looi <[email protected]>
---
.../net/wireless/ath/ath9k/ar9003_eeprom.c | 74 +++++++++----------
.../net/wireless/ath/ath9k/ar9003_eeprom.h | 44 +++++------
drivers/net/wireless/ath/ath9k/hw.h | 2 +-
3 files changed, 60 insertions(+), 60 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
index 03eeee767..11c7b57a1 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
@@ -43,7 +43,7 @@
static int ar9003_hw_power_interpolate(int32_t x,
int32_t *px, int32_t *py, u_int16_t np);

-static const struct ar9300_eeprom ar9300_default = {
+static const struct ar9300_eeprom_v1 ar9300_default = {
.eepromVersion = 2,
.templateVersion = 2,
.macAddr = {0, 2, 3, 4, 5, 6},
@@ -622,7 +622,7 @@ static const struct ar9300_eeprom ar9300_default = {
}
};

-static const struct ar9300_eeprom ar9300_x113 = {
+static const struct ar9300_eeprom_v1 ar9300_x113 = {
.eepromVersion = 2,
.templateVersion = 6,
.macAddr = {0x00, 0x03, 0x7f, 0x0, 0x0, 0x0},
@@ -1201,7 +1201,7 @@ static const struct ar9300_eeprom ar9300_x113 = {
};


-static const struct ar9300_eeprom ar9300_h112 = {
+static const struct ar9300_eeprom_v1 ar9300_h112 = {
.eepromVersion = 2,
.templateVersion = 3,
.macAddr = {0x00, 0x03, 0x7f, 0x0, 0x0, 0x0},
@@ -1780,7 +1780,7 @@ static const struct ar9300_eeprom ar9300_h112 = {
};


-static const struct ar9300_eeprom ar9300_x112 = {
+static const struct ar9300_eeprom_v1 ar9300_x112 = {
.eepromVersion = 2,
.templateVersion = 5,
.macAddr = {0x00, 0x03, 0x7f, 0x0, 0x0, 0x0},
@@ -2358,7 +2358,7 @@ static const struct ar9300_eeprom ar9300_x112 = {
}
};

-static const struct ar9300_eeprom ar9300_h116 = {
+static const struct ar9300_eeprom_v1 ar9300_h116 = {
.eepromVersion = 2,
.templateVersion = 4,
.macAddr = {0x00, 0x03, 0x7f, 0x0, 0x0, 0x0},
@@ -2937,7 +2937,7 @@ static const struct ar9300_eeprom ar9300_h116 = {
};


-static const struct ar9300_eeprom *ar9300_eep_templates[] = {
+static const struct ar9300_eeprom_v1 *ar9300_eep_templates[] = {
&ar9300_default,
&ar9300_x112,
&ar9300_h116,
@@ -2945,7 +2945,7 @@ static const struct ar9300_eeprom *ar9300_eep_templates[] = {
&ar9300_x113,
};

-static const struct ar9300_eeprom *ar9003_eeprom_struct_find_by_id(int id)
+static const struct ar9300_eeprom_v1 *ar9003_eeprom_struct_find_by_id(int id)
{
int it;

@@ -2973,7 +2973,7 @@ static int interpolate(int x, int xa, int xb, int ya, int yb)
/* XXX: review hardware docs */
static int ath9k_hw_ar9300_get_eeprom_ver(struct ath_hw *ah)
{
- return ah->eeprom.ar9300_eep.eepromVersion;
+ return ah->eeprom.ar9300_eep_v1.eepromVersion;
}

/* XXX: could be read from the eepromVersion, not sure yet */
@@ -2984,18 +2984,18 @@ static int ath9k_hw_ar9300_get_eeprom_rev(struct ath_hw *ah)

static struct ar9300_base_eep_hdr *ar9003_base_header(struct ath_hw *ah)
{
- return &ah->eeprom.ar9300_eep.baseEepHeader;
+ return &ah->eeprom.ar9300_eep_v1.baseEepHeader;
}

static struct ar9300_BaseExtension_1 *ar9003_base_ext1(struct ath_hw *ah)
{
- return &ah->eeprom.ar9300_eep.base_ext1;
+ return &ah->eeprom.ar9300_eep_v1.base_ext1;
}

-static struct ar9300_modal_eep_header *ar9003_modal_header(struct ath_hw *ah,
+static struct ar9300_modal_eep_header_v1 *ar9003_modal_header(struct ath_hw *ah,
bool is2ghz)
{
- struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
+ struct ar9300_eeprom_v1 *eep = &ah->eeprom.ar9300_eep_v1;

if (is2ghz)
return &eep->modalHeader2G;
@@ -3010,35 +3010,35 @@ static int8_t ar9003_ant_gain(struct ath_hw *ah, bool is2ghz)

static u8 ar9003_cal_freq_pier(struct ath_hw *ah, int idx, bool is2ghz)
{
- struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
+ struct ar9300_eeprom_v1 *eep = &ah->eeprom.ar9300_eep_v1;
return is2ghz ? eep->calFreqPier2G[idx] : eep->calFreqPier5G[idx];
}

static struct ar9300_cal_data_per_freq_op_loop *
ar9003_cal_pier_data(struct ath_hw *ah, int chain, int idx, bool is2ghz)
{
- struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
+ struct ar9300_eeprom_v1 *eep = &ah->eeprom.ar9300_eep_v1;
return is2ghz ? &eep->calPierData2G[chain][idx] :
&eep->calPierData5G[chain][idx];
}

static u8 ar9003_cal_target_freqbin(struct ath_hw *ah, int idx, bool is2ghz)
{
- struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
+ struct ar9300_eeprom_v1 *eep = &ah->eeprom.ar9300_eep_v1;
return is2ghz ? eep->calTarget_freqbin_2G[idx] :
eep->calTarget_freqbin_5G[idx];
}

static u8 ar9003_cal_target_freqbin_cck(struct ath_hw *ah, int idx)
{
- struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
+ struct ar9300_eeprom_v1 *eep = &ah->eeprom.ar9300_eep_v1;
return eep->calTarget_freqbin_Cck[idx];
}

static u8 ar9003_cal_target_freqbin_ht20(struct ath_hw *ah, int idx,
bool is2ghz)
{
- struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
+ struct ar9300_eeprom_v1 *eep = &ah->eeprom.ar9300_eep_v1;
return is2ghz ? eep->calTarget_freqbin_2GHT20[idx] :
eep->calTarget_freqbin_5GHT20[idx];
}
@@ -3046,7 +3046,7 @@ static u8 ar9003_cal_target_freqbin_ht20(struct ath_hw *ah, int idx,
static u8 ar9003_cal_target_freqbin_ht40(struct ath_hw *ah, int idx,
bool is2ghz)
{
- struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
+ struct ar9300_eeprom_v1 *eep = &ah->eeprom.ar9300_eep_v1;
return is2ghz ? eep->calTarget_freqbin_2GHT40[idx] :
eep->calTarget_freqbin_5GHT40[idx];
}
@@ -3054,21 +3054,21 @@ static u8 ar9003_cal_target_freqbin_ht40(struct ath_hw *ah, int idx,
static u8 ar9003_cal_target_power(struct ath_hw *ah, int idx, int rateIndex,
bool is2ghz)
{
- struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
+ struct ar9300_eeprom_v1 *eep = &ah->eeprom.ar9300_eep_v1;
return is2ghz ? eep->calTargetPower2G[idx].tPow2x[rateIndex] :
eep->calTargetPower5G[idx].tPow2x[rateIndex];
}

static u8 ar9003_cal_target_power_cck(struct ath_hw *ah, int idx, int rateIndex)
{
- struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
+ struct ar9300_eeprom_v1 *eep = &ah->eeprom.ar9300_eep_v1;
return eep->calTargetPowerCck[idx].tPow2x[rateIndex];
}

static u8 ar9003_cal_target_power_ht20(struct ath_hw *ah, int idx,
int rateIndex, bool is2ghz)
{
- struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
+ struct ar9300_eeprom_v1 *eep = &ah->eeprom.ar9300_eep_v1;
return is2ghz ? eep->calTargetPower2GHT20[idx].tPow2x[rateIndex] :
eep->calTargetPower5GHT20[idx].tPow2x[rateIndex];
}
@@ -3076,28 +3076,28 @@ static u8 ar9003_cal_target_power_ht20(struct ath_hw *ah, int idx,
static u8 ar9003_cal_target_power_ht40(struct ath_hw *ah, int idx,
int rateIndex, bool is2ghz)
{
- struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
+ struct ar9300_eeprom_v1 *eep = &ah->eeprom.ar9300_eep_v1;
return is2ghz ? eep->calTargetPower2GHT40[idx].tPow2x[rateIndex] :
eep->calTargetPower5GHT40[idx].tPow2x[rateIndex];
}

static u8 ar9003_ctl_freqbin(struct ath_hw *ah, int idx, int edge, bool is2ghz)
{
- struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
+ struct ar9300_eeprom_v1 *eep = &ah->eeprom.ar9300_eep_v1;
return is2ghz ? eep->ctl_freqbin_2G[idx][edge] :
eep->ctl_freqbin_5G[idx][edge];
}

static u8 ar9003_ctl_index(struct ath_hw *ah, int idx, bool is2ghz)
{
- struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
+ struct ar9300_eeprom_v1 *eep = &ah->eeprom.ar9300_eep_v1;
return is2ghz ? eep->ctlIndex_2G[idx] : eep->ctlIndex_5G[idx];
}

static u8 ar9003_ctl_power_data(struct ath_hw *ah, int idx, int edge,
bool is2ghz)
{
- struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
+ struct ar9300_eeprom_v1 *eep = &ah->eeprom.ar9300_eep_v1;
return is2ghz ? eep->ctlPowerData_2G[idx].ctlEdges[edge] :
eep->ctlPowerData_5G[idx].ctlEdges[edge];
}
@@ -3137,12 +3137,12 @@ static int8_t ar9003_temp_slope(struct ath_hw *ah, bool is2ghz)

static int8_t ar9003_temp_slope_high(struct ath_hw *ah)
{
- return ah->eeprom.ar9300_eep.base_ext2.tempSlopeHigh;
+ return ah->eeprom.ar9300_eep_v1.base_ext2.tempSlopeHigh;
}

static int8_t ar9003_temp_slope_low(struct ath_hw *ah)
{
- return ah->eeprom.ar9300_eep.base_ext2.tempSlopeLow;
+ return ah->eeprom.ar9300_eep_v1.base_ext2.tempSlopeLow;
}

static u8 ar9003_tx_end_to_xpa_off(struct ath_hw *ah, bool is2ghz)
@@ -3157,22 +3157,22 @@ static u8 ar9003_tx_frame_to_xpa_on(struct ath_hw *ah, bool is2ghz)

static u8 ar9003_xatten1_db_high(struct ath_hw *ah, int chain)
{
- return ah->eeprom.ar9300_eep.base_ext2.xatten1DBHigh[chain];
+ return ah->eeprom.ar9300_eep_v1.base_ext2.xatten1DBHigh[chain];
}

static u8 ar9003_xatten1_db_low(struct ath_hw *ah, int chain)
{
- return ah->eeprom.ar9300_eep.base_ext2.xatten1DBLow[chain];
+ return ah->eeprom.ar9300_eep_v1.base_ext2.xatten1DBLow[chain];
}

static u8 ar9003_xatten1_db_margin_high(struct ath_hw *ah, int chain)
{
- return ah->eeprom.ar9300_eep.base_ext2.xatten1MarginHigh[chain];
+ return ah->eeprom.ar9300_eep_v1.base_ext2.xatten1MarginHigh[chain];
}

static u8 ar9003_xatten1_db_margin_low(struct ath_hw *ah, int chain)
{
- return ah->eeprom.ar9300_eep.base_ext2.xatten1MarginLow[chain];
+ return ah->eeprom.ar9300_eep_v1.base_ext2.xatten1MarginLow[chain];
}

static u8 ar9003_xatten1_db(struct ath_hw *ah, int chain, bool is2ghz)
@@ -3197,7 +3197,7 @@ static u8 ar9003_xpa_bias_lvl(struct ath_hw *ah, bool is2ghz)

static u8 *ar9003_mac_addr(struct ath_hw *ah)
{
- return ah->eeprom.ar9300_eep.macAddr;
+ return ah->eeprom.ar9300_eep_v1.macAddr;
}

static u16 ar9003_switch_com_spdt_get(struct ath_hw *ah, bool is2ghz)
@@ -3421,7 +3421,7 @@ static int ar9300_compress_decision(struct ath_hw *ah,
u8 *word, int length, int mdata_size)
{
struct ath_common *common = ath9k_hw_common(ah);
- const struct ar9300_eeprom *eep = NULL;
+ const struct ar9300_eeprom_v1 *eep = NULL;

switch (code) {
case _CompressNone:
@@ -3512,7 +3512,7 @@ static int ar9300_eeprom_restore_internal(struct ath_hw *ah,
int it;
u16 checksum, mchecksum;
struct ath_common *common = ath9k_hw_common(ah);
- struct ar9300_eeprom *eep;
+ struct ar9300_eeprom_v1 *eep;
eeprom_read_op read;

if (ath9k_hw_use_flash(ah)) {
@@ -3522,7 +3522,7 @@ static int ar9300_eeprom_restore_internal(struct ath_hw *ah,
return -EIO;

/* check if eeprom contains valid data */
- eep = (struct ar9300_eeprom *) mptr;
+ eep = (struct ar9300_eeprom_v1 *) mptr;
txrx = eep->baseEepHeader.txrxMask;
if (txrx != 0 && txrx != 0xff)
return 0;
@@ -3625,10 +3625,10 @@ static int ar9300_eeprom_restore_internal(struct ath_hw *ah,
*/
static bool ath9k_hw_ar9300_fill_eeprom(struct ath_hw *ah)
{
- u8 *mptr = (u8 *) &ah->eeprom.ar9300_eep;
+ u8 *mptr = (u8 *) &ah->eeprom.ar9300_eep_v1;

if (ar9300_eeprom_restore_internal(ah, mptr,
- sizeof(struct ar9300_eeprom)) < 0)
+ sizeof(struct ar9300_eeprom_v1)) < 0)
return false;

return true;
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
index f8ae20318..b020092e8 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
@@ -41,7 +41,7 @@
#define AR9300_EEPMISC_WOW 0x02
#define AR9300_CUSTOMER_DATA_SIZE 20

-#define AR9300_MAX_CHAINS 3
+#define AR9300_EEPROM_V1_MAX_CHAINS 3
#define AR9300_ANT_16S 25
#define AR9300_FUTURE_MODAL_SZ 6

@@ -215,23 +215,23 @@ struct ar9300_base_eep_hdr {
__le32 swreg;
} __packed;

-struct ar9300_modal_eep_header {
+struct ar9300_modal_eep_header_v1 {
/* 4 idle, t1, t2, b (4 bits per setting) */
__le32 antCtrlCommon;
/* 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12 */
__le32 antCtrlCommon2;
/* 6 idle, t, r, rx1, rx12, b (2 bits each) */
- __le16 antCtrlChain[AR9300_MAX_CHAINS];
+ __le16 antCtrlChain[AR9300_EEPROM_V1_MAX_CHAINS];
/* 3 xatten1_db for AR9280 (0xa20c/b20c 5:0) */
- u8 xatten1DB[AR9300_MAX_CHAINS];
+ u8 xatten1DB[AR9300_EEPROM_V1_MAX_CHAINS];
/* 3 xatten1_margin for merlin (0xa20c/b20c 16:12 */
- u8 xatten1Margin[AR9300_MAX_CHAINS];
+ u8 xatten1Margin[AR9300_EEPROM_V1_MAX_CHAINS];
int8_t tempSlope;
int8_t voltSlope;
/* spur channels in usual fbin coding format */
u8 spurChans[AR_EEPROM_MODAL_SPURS];
/* 3 Check if the register is per chain */
- int8_t noiseFloorThreshCh[AR9300_MAX_CHAINS];
+ int8_t noiseFloorThreshCh[AR9300_EEPROM_V1_MAX_CHAINS];
u8 reserved[11];
int8_t quick_drop;
u8 xpaBiasLvl;
@@ -270,7 +270,7 @@ struct cal_tgt_pow_legacy {
u8 tPow2x[4];
} __packed;

-struct cal_tgt_pow_ht {
+struct cal_tgt_pow_ht_v1 {
u8 tPow2x[14];
} __packed;

@@ -300,16 +300,16 @@ struct ar9300_BaseExtension_1 {
int8_t quick_drop_high;
} __packed;

-struct ar9300_BaseExtension_2 {
+struct ar9300_BaseExtension_2_v1 {
int8_t tempSlopeLow;
int8_t tempSlopeHigh;
- u8 xatten1DBLow[AR9300_MAX_CHAINS];
- u8 xatten1MarginLow[AR9300_MAX_CHAINS];
- u8 xatten1DBHigh[AR9300_MAX_CHAINS];
- u8 xatten1MarginHigh[AR9300_MAX_CHAINS];
+ u8 xatten1DBLow[AR9300_EEPROM_V1_MAX_CHAINS];
+ u8 xatten1MarginLow[AR9300_EEPROM_V1_MAX_CHAINS];
+ u8 xatten1DBHigh[AR9300_EEPROM_V1_MAX_CHAINS];
+ u8 xatten1MarginHigh[AR9300_EEPROM_V1_MAX_CHAINS];
} __packed;

-struct ar9300_eeprom {
+struct ar9300_eeprom_v1 {
u8 eepromVersion;
u8 templateVersion;
u8 macAddr[6];
@@ -317,11 +317,11 @@ struct ar9300_eeprom {

struct ar9300_base_eep_hdr baseEepHeader;

- struct ar9300_modal_eep_header modalHeader2G;
+ struct ar9300_modal_eep_header_v1 modalHeader2G;
struct ar9300_BaseExtension_1 base_ext1;
u8 calFreqPier2G[AR9300_NUM_2G_CAL_PIERS];
struct ar9300_cal_data_per_freq_op_loop
- calPierData2G[AR9300_MAX_CHAINS][AR9300_NUM_2G_CAL_PIERS];
+ calPierData2G[AR9300_EEPROM_V1_MAX_CHAINS][AR9300_NUM_2G_CAL_PIERS];
u8 calTarget_freqbin_Cck[AR9300_NUM_2G_CCK_TARGET_POWERS];
u8 calTarget_freqbin_2G[AR9300_NUM_2G_20_TARGET_POWERS];
u8 calTarget_freqbin_2GHT20[AR9300_NUM_2G_20_TARGET_POWERS];
@@ -330,26 +330,26 @@ struct ar9300_eeprom {
calTargetPowerCck[AR9300_NUM_2G_CCK_TARGET_POWERS];
struct cal_tgt_pow_legacy
calTargetPower2G[AR9300_NUM_2G_20_TARGET_POWERS];
- struct cal_tgt_pow_ht
+ struct cal_tgt_pow_ht_v1
calTargetPower2GHT20[AR9300_NUM_2G_20_TARGET_POWERS];
- struct cal_tgt_pow_ht
+ struct cal_tgt_pow_ht_v1
calTargetPower2GHT40[AR9300_NUM_2G_40_TARGET_POWERS];
u8 ctlIndex_2G[AR9300_NUM_CTLS_2G];
u8 ctl_freqbin_2G[AR9300_NUM_CTLS_2G][AR9300_NUM_BAND_EDGES_2G];
struct cal_ctl_data_2g ctlPowerData_2G[AR9300_NUM_CTLS_2G];
- struct ar9300_modal_eep_header modalHeader5G;
- struct ar9300_BaseExtension_2 base_ext2;
+ struct ar9300_modal_eep_header_v1 modalHeader5G;
+ struct ar9300_BaseExtension_2_v1 base_ext2;
u8 calFreqPier5G[AR9300_NUM_5G_CAL_PIERS];
struct ar9300_cal_data_per_freq_op_loop
- calPierData5G[AR9300_MAX_CHAINS][AR9300_NUM_5G_CAL_PIERS];
+ calPierData5G[AR9300_EEPROM_V1_MAX_CHAINS][AR9300_NUM_5G_CAL_PIERS];
u8 calTarget_freqbin_5G[AR9300_NUM_5G_20_TARGET_POWERS];
u8 calTarget_freqbin_5GHT20[AR9300_NUM_5G_20_TARGET_POWERS];
u8 calTarget_freqbin_5GHT40[AR9300_NUM_5G_40_TARGET_POWERS];
struct cal_tgt_pow_legacy
calTargetPower5G[AR9300_NUM_5G_20_TARGET_POWERS];
- struct cal_tgt_pow_ht
+ struct cal_tgt_pow_ht_v1
calTargetPower5GHT20[AR9300_NUM_5G_20_TARGET_POWERS];
- struct cal_tgt_pow_ht
+ struct cal_tgt_pow_ht_v1
calTargetPower5GHT40[AR9300_NUM_5G_40_TARGET_POWERS];
u8 ctlIndex_5G[AR9300_NUM_CTLS_5G];
u8 ctl_freqbin_5G[AR9300_NUM_CTLS_5G][AR9300_NUM_BAND_EDGES_5G];
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index 759a5991a..22349c2b7 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -789,7 +789,7 @@ struct ath_hw {
struct ar5416_eeprom_def def;
struct ar5416_eeprom_4k map4k;
struct ar9287_eeprom map9287;
- struct ar9300_eeprom ar9300_eep;
+ struct ar9300_eeprom_v1 ar9300_eep_v1;
} eeprom;
const struct eeprom_ops *eep_ops;

--
2.25.1