2022-04-18 12:21:14

by Wenli Looi

[permalink] [raw]
Subject: [PATCH 0/9] ath9k: add support for QCN550x

This patchset adds support for QCN550x. It is an attempt to write a
cleaner version of the following patch:

https://github.com/openwrt/openwrt/pull/9389

I'm definitely open to ideas on how to better implement this change.

Notes:

- While QCN5502 is a 4-stream device, ath9k only supports 3 streams, and
that is unchanged.
- The QCN550x EEPROM format is different from other AR9003 devices due
to the 4th stream. An abstraction layer has been added over the EEPROM
to support both formats.
- The QCN550x initvals here are a hacked version of the QCA956x
initvals, and have only been partially tested.
- This change has been tested on the following devices, which appear to
work as an access point:
- QCN5502: Netgear EX6400v2
- QCA9558: Netgear EX7300v1

Relevant links:

- QCN550x SoC support, which appears to be identical to QCA956x:
https://github.com/torvalds/linux/commit/a0b8cd5c223042efe764864b8dd9396ee127c763
- QSDK patch for QCN550x:
https://source.codeaurora.org/quic/qsdk/oss/system/openwrt/tree/target/linux/ar71xx/patches-3.3/9991-MIPS-ath79-add-SoC-detection-code-for-QCN550X.patch?h=aa/banana

Wenli Looi (9):
ath9k: add QCN550x device IDs
ath9k: basic support for QCN550x
ath9k: add QCN550x initvals
ath9k: implement QCN550x rx
ath9k: implement QCN550x tx
ath9k: group some ar9300 eeprom functions at the top
ath9k: add abstractions over ar9300 eeprom
ath9k: rename ar9300_eeprom to ar9300_eeprom_v1
ath9k: add ar9300_eeprom_v2

drivers/net/wireless/ath/ath9k/ahb.c | 4 +
drivers/net/wireless/ath/ath9k/ani.c | 2 +-
.../net/wireless/ath/ath9k/ar550x_initvals.h | 1296 +++++++++++++++++
drivers/net/wireless/ath/ath9k/ar9003_calib.c | 4 +-
.../net/wireless/ath/ath9k/ar9003_eeprom.c | 949 ++++++++----
.../net/wireless/ath/ath9k/ar9003_eeprom.h | 144 +-
drivers/net/wireless/ath/ath9k/ar9003_hw.c | 59 +
drivers/net/wireless/ath/ath9k/ar9003_mac.c | 79 +-
drivers/net/wireless/ath/ath9k/ar9003_mac.h | 10 +
drivers/net/wireless/ath/ath9k/ar9003_paprd.c | 4 +-
drivers/net/wireless/ath/ath9k/ar9003_phy.c | 35 +-
drivers/net/wireless/ath/ath9k/ar9003_phy.h | 83 +-
drivers/net/wireless/ath/ath9k/hw.c | 38 +-
drivers/net/wireless/ath/ath9k/hw.h | 4 +-
drivers/net/wireless/ath/ath9k/mac.c | 2 +-
drivers/net/wireless/ath/ath9k/mac.h | 12 +
drivers/net/wireless/ath/ath9k/recv.c | 2 +-
drivers/net/wireless/ath/ath9k/reg.h | 11 +-
drivers/net/wireless/ath/ath9k/reg_aic.h | 6 +-
19 files changed, 2330 insertions(+), 414 deletions(-)
create mode 100644 drivers/net/wireless/ath/ath9k/ar550x_initvals.h

--
2.25.1


2022-04-18 12:27:54

by Wenli Looi

[permalink] [raw]
Subject: [PATCH 1/9] ath9k: add QCN550x device IDs

Signed-off-by: Wenli Looi <[email protected]>
---
drivers/net/wireless/ath/ath9k/ahb.c | 4 ++++
drivers/net/wireless/ath/ath9k/hw.c | 6 ++++++
drivers/net/wireless/ath/ath9k/hw.h | 1 +
drivers/net/wireless/ath/ath9k/reg.h | 5 ++++-
4 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath9k/ahb.c b/drivers/net/wireless/ath/ath9k/ahb.c
index 9cd12b20b..1835b4469 100644
--- a/drivers/net/wireless/ath/ath9k/ahb.c
+++ b/drivers/net/wireless/ath/ath9k/ahb.c
@@ -47,6 +47,10 @@ static const struct platform_device_id ath9k_platform_id_table[] = {
.name = "qca956x_wmac",
.driver_data = AR9300_DEVID_QCA956X,
},
+ {
+ .name = "qcn550x_wmac",
+ .driver_data = AR9300_DEVID_QCN550X,
+ },
{},
};

diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 172081ffe..047512ce1 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -282,6 +282,9 @@ static bool ath9k_hw_read_revisions(struct ath_hw *ah)
case AR9300_DEVID_QCA956X:
ah->hw_version.macVersion = AR_SREV_VERSION_9561;
return true;
+ case AR9300_DEVID_QCN550X:
+ ah->hw_version.macVersion = AR_SREV_VERSION_5502;
+ return true;
}

srev = REG_READ(ah, AR_SREV);
@@ -592,6 +595,7 @@ static int __ath9k_hw_init(struct ath_hw *ah)
case AR_SREV_VERSION_9565:
case AR_SREV_VERSION_9531:
case AR_SREV_VERSION_9561:
+ case AR_SREV_VERSION_5502:
break;
default:
ath_err(common,
@@ -688,6 +692,7 @@ int ath9k_hw_init(struct ath_hw *ah)
case AR9300_DEVID_AR9565:
case AR9300_DEVID_AR953X:
case AR9300_DEVID_QCA956X:
+ case AR9300_DEVID_QCN550X:
break;
default:
if (common->bus_ops->ath_bus_type == ATH_USB)
@@ -3315,6 +3320,7 @@ static struct {
{ AR_SREV_VERSION_9565, "9565" },
{ AR_SREV_VERSION_9531, "9531" },
{ AR_SREV_VERSION_9561, "9561" },
+ { AR_SREV_VERSION_5502, "5502" },
};

/* For devices with external radios */
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index 096a206f4..759a5991a 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -56,6 +56,7 @@
#define AR9300_DEVID_AR9565 0x0036
#define AR9300_DEVID_AR953X 0x003d
#define AR9300_DEVID_QCA956X 0x003f
+#define AR9300_DEVID_QCN550X 0x0040

#define AR5416_AR9100_DEVID 0x000b

diff --git a/drivers/net/wireless/ath/ath9k/reg.h b/drivers/net/wireless/ath/ath9k/reg.h
index 8983ea6fc..5a07cf7d8 100644
--- a/drivers/net/wireless/ath/ath9k/reg.h
+++ b/drivers/net/wireless/ath/ath9k/reg.h
@@ -825,6 +825,7 @@
#define AR_SREV_REVISION_9531_11 1
#define AR_SREV_REVISION_9531_20 2
#define AR_SREV_VERSION_9561 0x600
+#define AR_SREV_VERSION_5502 0x700

#define AR_SREV_5416(_ah) \
(((_ah)->hw_version.macVersion == AR_SREV_VERSION_5416_PCI) || \
@@ -992,10 +993,12 @@

#define AR_SREV_9561(_ah) \
(((_ah)->hw_version.macVersion == AR_SREV_VERSION_9561))
+#define AR_SREV_5502(_ah) \
+ (((_ah)->hw_version.macVersion == AR_SREV_VERSION_5502))

#define AR_SREV_SOC(_ah) \
(AR_SREV_9340(_ah) || AR_SREV_9531(_ah) || AR_SREV_9550(_ah) || \
- AR_SREV_9561(_ah))
+ AR_SREV_9561(_ah) || AR_SREV_5502(_ah))

/* NOTE: When adding chips newer than Peacock, add chip check here */
#define AR_SREV_9580_10_OR_LATER(_ah) \
--
2.25.1

2022-04-18 12:29:19

by Wenli Looi

[permalink] [raw]
Subject: [PATCH 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

2022-04-18 12:33:44

by Wenli Looi

[permalink] [raw]
Subject: [PATCH 6/9] ath9k: group some ar9300 eeprom functions at the top

These functions will be part of an abstraction layer that works with
both old and new AR9300 eeprom formats.

Signed-off-by: Wenli Looi <[email protected]>
---
.../net/wireless/ath/ath9k/ar9003_eeprom.c | 90 +++++++++----------
1 file changed, 45 insertions(+), 45 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
index 49be3a315..6257d74c6 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
@@ -2970,6 +2970,51 @@ static int interpolate(int x, int xa, int xb, int ya, int yb)
return ya + factor + plus;
}

+/* XXX: review hardware docs */
+static int ath9k_hw_ar9300_get_eeprom_ver(struct ath_hw *ah)
+{
+ return ah->eeprom.ar9300_eep.eepromVersion;
+}
+
+/* XXX: could be read from the eepromVersion, not sure yet */
+static int ath9k_hw_ar9300_get_eeprom_rev(struct ath_hw *ah)
+{
+ return 0;
+}
+
+static struct ar9300_modal_eep_header *ar9003_modal_header(struct ath_hw *ah,
+ bool is2ghz)
+{
+ struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
+
+ if (is2ghz)
+ return &eep->modalHeader2G;
+ else
+ return &eep->modalHeader5G;
+}
+
+static u16 ar9003_hw_ant_ctrl_chain_get(struct ath_hw *ah, int chain,
+ bool is2ghz)
+{
+ __le16 val = ar9003_modal_header(ah, is2ghz)->antCtrlChain[chain];
+ return le16_to_cpu(val);
+}
+
+u32 ar9003_hw_ant_ctrl_common_get(struct ath_hw *ah, bool is2ghz)
+{
+ return le32_to_cpu(ar9003_modal_header(ah, is2ghz)->antCtrlCommon);
+}
+
+u32 ar9003_hw_ant_ctrl_common_2_get(struct ath_hw *ah, bool is2ghz)
+{
+ return le32_to_cpu(ar9003_modal_header(ah, is2ghz)->antCtrlCommon2);
+}
+
+static u16 ar9003_switch_com_spdt_get(struct ath_hw *ah, bool is2ghz)
+{
+ return le16_to_cpu(ar9003_modal_header(ah, is2ghz)->switchcomspdt);
+}
+
static u32 ath9k_hw_ar9300_get_eeprom(struct ath_hw *ah,
enum eeprom_param param)
{
@@ -3578,29 +3623,6 @@ static u32 ath9k_hw_ar9003_dump_eeprom(struct ath_hw *ah, bool dump_base_hdr,
}
#endif

-/* XXX: review hardware docs */
-static int ath9k_hw_ar9300_get_eeprom_ver(struct ath_hw *ah)
-{
- return ah->eeprom.ar9300_eep.eepromVersion;
-}
-
-/* XXX: could be read from the eepromVersion, not sure yet */
-static int ath9k_hw_ar9300_get_eeprom_rev(struct ath_hw *ah)
-{
- return 0;
-}
-
-static struct ar9300_modal_eep_header *ar9003_modal_header(struct ath_hw *ah,
- bool is2ghz)
-{
- struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
-
- if (is2ghz)
- return &eep->modalHeader2G;
- else
- return &eep->modalHeader5G;
-}
-
static void ar9003_hw_xpa_bias_level_apply(struct ath_hw *ah, bool is2ghz)
{
int bias = ar9003_modal_header(ah, is2ghz)->xpaBiasLvl;
@@ -3622,28 +3644,6 @@ static void ar9003_hw_xpa_bias_level_apply(struct ath_hw *ah, bool is2ghz)
}
}

-static u16 ar9003_switch_com_spdt_get(struct ath_hw *ah, bool is2ghz)
-{
- return le16_to_cpu(ar9003_modal_header(ah, is2ghz)->switchcomspdt);
-}
-
-u32 ar9003_hw_ant_ctrl_common_get(struct ath_hw *ah, bool is2ghz)
-{
- return le32_to_cpu(ar9003_modal_header(ah, is2ghz)->antCtrlCommon);
-}
-
-u32 ar9003_hw_ant_ctrl_common_2_get(struct ath_hw *ah, bool is2ghz)
-{
- return le32_to_cpu(ar9003_modal_header(ah, is2ghz)->antCtrlCommon2);
-}
-
-static u16 ar9003_hw_ant_ctrl_chain_get(struct ath_hw *ah, int chain,
- bool is2ghz)
-{
- __le16 val = ar9003_modal_header(ah, is2ghz)->antCtrlChain[chain];
- return le16_to_cpu(val);
-}
-
static void ar9003_hw_ant_ctrl_apply(struct ath_hw *ah, bool is2ghz)
{
struct ath_common *common = ath9k_hw_common(ah);
--
2.25.1

2022-04-18 12:37:34

by Wenli Looi

[permalink] [raw]
Subject: [PATCH 7/9] ath9k: add abstractions over ar9300 eeprom

This will allow the code to handle both old and new AR9300 eeprom
formats.

Signed-off-by: Wenli Looi <[email protected]>
---
.../net/wireless/ath/ath9k/ar9003_eeprom.c | 633 +++++++++++-------
1 file changed, 409 insertions(+), 224 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
index 6257d74c6..03eeee767 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
@@ -2982,6 +2982,16 @@ static int ath9k_hw_ar9300_get_eeprom_rev(struct ath_hw *ah)
return 0;
}

+static struct ar9300_base_eep_hdr *ar9003_base_header(struct ath_hw *ah)
+{
+ return &ah->eeprom.ar9300_eep.baseEepHeader;
+}
+
+static struct ar9300_BaseExtension_1 *ar9003_base_ext1(struct ath_hw *ah)
+{
+ return &ah->eeprom.ar9300_eep.base_ext1;
+}
+
static struct ar9300_modal_eep_header *ar9003_modal_header(struct ath_hw *ah,
bool is2ghz)
{
@@ -2993,6 +3003,105 @@ static struct ar9300_modal_eep_header *ar9003_modal_header(struct ath_hw *ah,
return &eep->modalHeader5G;
}

+static int8_t ar9003_ant_gain(struct ath_hw *ah, bool is2ghz)
+{
+ return ar9003_modal_header(ah, is2ghz)->antennaGain;
+}
+
+static u8 ar9003_cal_freq_pier(struct ath_hw *ah, int idx, bool is2ghz)
+{
+ struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
+ 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;
+ 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;
+ 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;
+ 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;
+ return is2ghz ? eep->calTarget_freqbin_2GHT20[idx] :
+ eep->calTarget_freqbin_5GHT20[idx];
+}
+
+static u8 ar9003_cal_target_freqbin_ht40(struct ath_hw *ah, int idx,
+ bool is2ghz)
+{
+ struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
+ return is2ghz ? eep->calTarget_freqbin_2GHT40[idx] :
+ eep->calTarget_freqbin_5GHT40[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;
+ 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;
+ 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;
+ return is2ghz ? eep->calTargetPower2GHT20[idx].tPow2x[rateIndex] :
+ eep->calTargetPower5GHT20[idx].tPow2x[rateIndex];
+}
+
+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;
+ 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;
+ 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;
+ 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;
+ return is2ghz ? eep->ctlPowerData_2G[idx].ctlEdges[edge] :
+ eep->ctlPowerData_5G[idx].ctlEdges[edge];
+}
+
static u16 ar9003_hw_ant_ctrl_chain_get(struct ath_hw *ah, int chain,
bool is2ghz)
{
@@ -3010,6 +3119,87 @@ u32 ar9003_hw_ant_ctrl_common_2_get(struct ath_hw *ah, bool is2ghz)
return le32_to_cpu(ar9003_modal_header(ah, is2ghz)->antCtrlCommon2);
}

+static int8_t ar9003_noise_floor_thres(struct ath_hw *ah, int chain,
+ bool is2ghz)
+{
+ return ar9003_modal_header(ah, is2ghz)->noiseFloorThreshCh[chain];
+}
+
+static int8_t ar9003_quick_drop(struct ath_hw *ah, bool is2ghz)
+{
+ return ar9003_modal_header(ah, is2ghz)->quick_drop;
+}
+
+static int8_t ar9003_temp_slope(struct ath_hw *ah, bool is2ghz)
+{
+ return ar9003_modal_header(ah, is2ghz)->tempSlope;
+}
+
+static int8_t ar9003_temp_slope_high(struct ath_hw *ah)
+{
+ return ah->eeprom.ar9300_eep.base_ext2.tempSlopeHigh;
+}
+
+static int8_t ar9003_temp_slope_low(struct ath_hw *ah)
+{
+ return ah->eeprom.ar9300_eep.base_ext2.tempSlopeLow;
+}
+
+static u8 ar9003_tx_end_to_xpa_off(struct ath_hw *ah, bool is2ghz)
+{
+ return ar9003_modal_header(ah, is2ghz)->txEndToXpaOff;
+}
+
+static u8 ar9003_tx_frame_to_xpa_on(struct ath_hw *ah, bool is2ghz)
+{
+ return ar9003_modal_header(ah, is2ghz)->txFrameToXpaOn;
+}
+
+static u8 ar9003_xatten1_db_high(struct ath_hw *ah, int chain)
+{
+ return ah->eeprom.ar9300_eep.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];
+}
+
+static u8 ar9003_xatten1_db_margin_high(struct ath_hw *ah, int chain)
+{
+ return ah->eeprom.ar9300_eep.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];
+}
+
+static u8 ar9003_xatten1_db(struct ath_hw *ah, int chain, bool is2ghz)
+{
+ return ar9003_modal_header(ah, is2ghz)->xatten1DB[chain];
+}
+
+static u8 ar9003_xatten1_margin(struct ath_hw *ah, int chain, bool is2ghz)
+{
+ return ar9003_modal_header(ah, is2ghz)->xatten1Margin[chain];
+}
+
+static u8 ar9003_xlna_bias_strength(struct ath_hw *ah, bool is2ghz)
+{
+ return ar9003_modal_header(ah, is2ghz)->xlna_bias_strength;
+}
+
+static u8 ar9003_xpa_bias_lvl(struct ath_hw *ah, bool is2ghz)
+{
+ return ar9003_modal_header(ah, is2ghz)->xpaBiasLvl;
+}
+
+static u8 *ar9003_mac_addr(struct ath_hw *ah)
+{
+ return ah->eeprom.ar9300_eep.macAddr;
+}
+
static u16 ar9003_switch_com_spdt_get(struct ath_hw *ah, bool is2ghz)
{
return le16_to_cpu(ar9003_modal_header(ah, is2ghz)->switchcomspdt);
@@ -3018,16 +3208,17 @@ static u16 ar9003_switch_com_spdt_get(struct ath_hw *ah, bool is2ghz)
static u32 ath9k_hw_ar9300_get_eeprom(struct ath_hw *ah,
enum eeprom_param param)
{
- struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
- struct ar9300_base_eep_hdr *pBase = &eep->baseEepHeader;
+ struct ar9300_base_eep_hdr *pBase = ar9003_base_header(ah);
+ struct ar9300_BaseExtension_1 *base_ext1 = ar9003_base_ext1(ah);
+ u8 *mac_addr = ar9003_mac_addr(ah);

switch (param) {
case EEP_MAC_LSW:
- return get_unaligned_be16(eep->macAddr);
+ return get_unaligned_be16(mac_addr);
case EEP_MAC_MID:
- return get_unaligned_be16(eep->macAddr + 2);
+ return get_unaligned_be16(mac_addr + 2);
case EEP_MAC_MSW:
- return get_unaligned_be16(eep->macAddr + 4);
+ return get_unaligned_be16(mac_addr + 4);
case EEP_REG_0:
return le16_to_cpu(pBase->regDmn[0]);
case EEP_OP_CAP:
@@ -3048,11 +3239,11 @@ static u32 ath9k_hw_ar9300_get_eeprom(struct ath_hw *ah,
if (AR_SREV_9565(ah))
return AR9300_EEP_ANTDIV_CONTROL_DEFAULT_VALUE;
else
- return eep->base_ext1.ant_div_control;
+ return base_ext1->ant_div_control;
case EEP_ANTENNA_GAIN_5G:
- return eep->modalHeader5G.antennaGain;
+ return ar9003_ant_gain(ah, /*is2ghz=*/false);
case EEP_ANTENNA_GAIN_2G:
- return eep->modalHeader2G.antennaGain;
+ return ar9003_ant_gain(ah, /*is2ghz=*/true);
default:
return 0;
}
@@ -3444,40 +3635,79 @@ static bool ath9k_hw_ar9300_fill_eeprom(struct ath_hw *ah)
}

#if defined(CONFIG_ATH9K_DEBUGFS) || defined(CONFIG_ATH9K_HTC_DEBUGFS)
-static u32 ar9003_dump_modal_eeprom(char *buf, u32 len, u32 size,
- struct ar9300_modal_eep_header *modal_hdr)
+
+static int8_t ar9003_adc_desired_size(struct ath_hw *ah, bool is2ghz)
{
- PR_EEP("Chain0 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[0]));
- PR_EEP("Chain1 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[1]));
- PR_EEP("Chain2 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[2]));
- PR_EEP("Ant. Common Control", le32_to_cpu(modal_hdr->antCtrlCommon));
- PR_EEP("Ant. Common Control2", le32_to_cpu(modal_hdr->antCtrlCommon2));
- PR_EEP("Ant. Gain", modal_hdr->antennaGain);
- PR_EEP("Switch Settle", modal_hdr->switchSettling);
- PR_EEP("Chain0 xatten1DB", modal_hdr->xatten1DB[0]);
- PR_EEP("Chain1 xatten1DB", modal_hdr->xatten1DB[1]);
- PR_EEP("Chain2 xatten1DB", modal_hdr->xatten1DB[2]);
- PR_EEP("Chain0 xatten1Margin", modal_hdr->xatten1Margin[0]);
- PR_EEP("Chain1 xatten1Margin", modal_hdr->xatten1Margin[1]);
- PR_EEP("Chain2 xatten1Margin", modal_hdr->xatten1Margin[2]);
- PR_EEP("Temp Slope", modal_hdr->tempSlope);
- PR_EEP("Volt Slope", modal_hdr->voltSlope);
- PR_EEP("spur Channels0", modal_hdr->spurChans[0]);
- PR_EEP("spur Channels1", modal_hdr->spurChans[1]);
- PR_EEP("spur Channels2", modal_hdr->spurChans[2]);
- PR_EEP("spur Channels3", modal_hdr->spurChans[3]);
- PR_EEP("spur Channels4", modal_hdr->spurChans[4]);
- PR_EEP("Chain0 NF Threshold", modal_hdr->noiseFloorThreshCh[0]);
- PR_EEP("Chain1 NF Threshold", modal_hdr->noiseFloorThreshCh[1]);
- PR_EEP("Chain2 NF Threshold", modal_hdr->noiseFloorThreshCh[2]);
- PR_EEP("Quick Drop", modal_hdr->quick_drop);
- PR_EEP("txEndToXpaOff", modal_hdr->txEndToXpaOff);
- PR_EEP("xPA Bias Level", modal_hdr->xpaBiasLvl);
- PR_EEP("txFrameToDataStart", modal_hdr->txFrameToDataStart);
- PR_EEP("txFrameToPaOn", modal_hdr->txFrameToPaOn);
- PR_EEP("txFrameToXpaOn", modal_hdr->txFrameToXpaOn);
- PR_EEP("txClip", modal_hdr->txClip);
- PR_EEP("ADC Desired size", modal_hdr->adcDesiredSize);
+ return ar9003_modal_header(ah, is2ghz)->adcDesiredSize;
+}
+
+static u8 ar9003_switch_settling(struct ath_hw *ah, bool is2ghz)
+{
+ return ar9003_modal_header(ah, is2ghz)->switchSettling;
+}
+
+static u8 ar9003_tx_clip(struct ath_hw *ah, bool is2ghz)
+{
+ return ar9003_modal_header(ah, is2ghz)->txClip;
+}
+
+static u8 ar9003_tx_frame_to_data_start(struct ath_hw *ah, bool is2ghz)
+{
+ return ar9003_modal_header(ah, is2ghz)->txFrameToDataStart;
+}
+
+static u8 ar9003_tx_frame_to_pa_on(struct ath_hw *ah, bool is2ghz)
+{
+ return ar9003_modal_header(ah, is2ghz)->txFrameToPaOn;
+}
+
+static int8_t ar9003_volt_slope(struct ath_hw *ah, bool is2ghz)
+{
+ return ar9003_modal_header(ah, is2ghz)->voltSlope;
+}
+
+static u32 ar9003_dump_modal_eeprom(struct ath_hw *ah, char *buf, u32 len,
+ u32 size, bool is_2g)
+{
+ PR_EEP("Chain0 Ant. Control",
+ ar9003_hw_ant_ctrl_chain_get(ah, 0, is_2g));
+ PR_EEP("Chain1 Ant. Control",
+ ar9003_hw_ant_ctrl_chain_get(ah, 1, is_2g));
+ PR_EEP("Chain2 Ant. Control",
+ ar9003_hw_ant_ctrl_chain_get(ah, 2, is_2g));
+ PR_EEP("Ant. Common Control", ar9003_hw_ant_ctrl_common_get(ah, is_2g));
+ PR_EEP("Ant. Common Control2",
+ ar9003_hw_ant_ctrl_common_2_get(ah, is_2g));
+ PR_EEP("Ant. Gain", ar9003_ant_gain(ah, is_2g));
+ PR_EEP("Switch Settle", ar9003_switch_settling(ah, is_2g));
+ PR_EEP("Chain0 xatten1DB", ar9003_xatten1_db(ah, 0, is_2g));
+ PR_EEP("Chain1 xatten1DB", ar9003_xatten1_db(ah, 1, is_2g));
+ PR_EEP("Chain2 xatten1DB", ar9003_xatten1_db(ah, 2, is_2g));
+ PR_EEP("Chain0 xatten1Margin", ar9003_xatten1_margin(ah, 0, is_2g));
+ PR_EEP("Chain1 xatten1Margin", ar9003_xatten1_margin(ah, 1, is_2g));
+ PR_EEP("Chain2 xatten1Margin", ar9003_xatten1_margin(ah, 2, is_2g));
+ PR_EEP("Temp Slope", ar9003_temp_slope(ah, is_2g));
+ PR_EEP("Volt Slope", ar9003_volt_slope(ah, is_2g));
+ PR_EEP("spur Channels0", ar9003_get_spur_chan_ptr(ah, is_2g)[0]);
+ PR_EEP("spur Channels1", ar9003_get_spur_chan_ptr(ah, is_2g)[1]);
+ PR_EEP("spur Channels2", ar9003_get_spur_chan_ptr(ah, is_2g)[2]);
+ PR_EEP("spur Channels3", ar9003_get_spur_chan_ptr(ah, is_2g)[3]);
+ PR_EEP("spur Channels4", ar9003_get_spur_chan_ptr(ah, is_2g)[4]);
+ PR_EEP("Chain0 NF Threshold",
+ ar9003_noise_floor_thres(ah, 0, is_2g));
+ PR_EEP("Chain1 NF Threshold",
+ ar9003_noise_floor_thres(ah, 1, is_2g));
+ PR_EEP("Chain2 NF Threshold",
+ ar9003_noise_floor_thres(ah, 2, is_2g));
+ PR_EEP("Quick Drop", ar9003_quick_drop(ah, is_2g));
+ PR_EEP("txEndToXpaOff", ar9003_tx_end_to_xpa_off(ah, is_2g));
+ PR_EEP("xPA Bias Level", ar9003_xpa_bias_lvl(ah, is_2g));
+ PR_EEP("txFrameToDataStart",
+ ar9003_tx_frame_to_data_start(ah, is_2g));
+ PR_EEP("txFrameToPaOn", ar9003_tx_frame_to_pa_on(ah, is_2g));
+ PR_EEP("txFrameToXpaOn", ar9003_tx_frame_to_xpa_on(ah, is_2g));
+ PR_EEP("txClip", ar9003_tx_clip(ah, is_2g));
+ PR_EEP("ADC Desired size", ar9003_adc_desired_size(ah, is_2g));

return len;
}
@@ -3485,15 +3715,12 @@ static u32 ar9003_dump_modal_eeprom(char *buf, u32 len, u32 size,
static u32 ar9003_dump_cal_data(struct ath_hw *ah, char *buf, u32 len, u32 size,
bool is_2g)
{
- struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
- struct ar9300_base_eep_hdr *pBase;
+ struct ar9300_base_eep_hdr *pBase = ar9003_base_header(ah);
struct ar9300_cal_data_per_freq_op_loop *cal_pier;
int cal_pier_nr;
int freq;
int i, j;

- pBase = &eep->baseEepHeader;
-
if (is_2g)
cal_pier_nr = AR9300_NUM_2G_CAL_PIERS;
else
@@ -3509,12 +3736,11 @@ static u32 ar9003_dump_cal_data(struct ath_hw *ah, char *buf, u32 len, u32 size,
"Freq\t ref\tvolt\ttemp\tnf_cal\tnf_pow\trx_temp\n");

for (j = 0; j < cal_pier_nr; j++) {
+ cal_pier = ar9003_cal_pier_data(ah, i, j, is_2g);
if (is_2g) {
- cal_pier = &eep->calPierData2G[i][j];
- freq = 2300 + eep->calFreqPier2G[j];
+ freq = 2300 + ar9003_cal_freq_pier(ah, j, is_2g);
} else {
- cal_pier = &eep->calPierData5G[i][j];
- freq = 4800 + eep->calFreqPier5G[j] * 5;
+ freq = 4800 + ar9003_cal_freq_pier(ah, j, is_2g) * 5;
}

len += scnprintf(buf + len, size - len,
@@ -3539,22 +3765,19 @@ static u32 ar9003_dump_cal_data(struct ath_hw *ah, char *buf, u32 len, u32 size,
static u32 ath9k_hw_ar9003_dump_eeprom(struct ath_hw *ah, bool dump_base_hdr,
u8 *buf, u32 len, u32 size)
{
- struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
- struct ar9300_base_eep_hdr *pBase;
+ struct ar9300_base_eep_hdr *pBase = ar9003_base_header(ah);

if (!dump_base_hdr) {
len += scnprintf(buf + len, size - len,
"%20s :\n", "2GHz modal Header");
- len = ar9003_dump_modal_eeprom(buf, len, size,
- &eep->modalHeader2G);
+ len = ar9003_dump_modal_eeprom(ah, buf, len, size, true);

len += scnprintf(buf + len, size - len, "Calibration data\n");
len = ar9003_dump_cal_data(ah, buf, len, size, true);

len += scnprintf(buf + len, size - len,
"%20s :\n", "5GHz modal Header");
- len = ar9003_dump_modal_eeprom(buf, len, size,
- &eep->modalHeader5G);
+ len = ar9003_dump_modal_eeprom(ah, buf, len, size, false);

len += scnprintf(buf + len, size - len, "Calibration data\n");
len = ar9003_dump_cal_data(ah, buf, len, size, false);
@@ -3562,9 +3785,7 @@ static u32 ath9k_hw_ar9003_dump_eeprom(struct ath_hw *ah, bool dump_base_hdr,
goto out;
}

- pBase = &eep->baseEepHeader;
-
- PR_EEP("EEPROM Version", ah->eeprom.ar9300_eep.eepromVersion);
+ PR_EEP("EEPROM Version", ath9k_hw_ar9300_get_eeprom_ver(ah));
PR_EEP("RegDomain1", le16_to_cpu(pBase->regDmn[0]));
PR_EEP("RegDomain2", le16_to_cpu(pBase->regDmn[1]));
PR_EEP("TX Mask", (pBase->txrxMask >> 4));
@@ -3608,7 +3829,7 @@ static u32 ath9k_hw_ar9003_dump_eeprom(struct ath_hw *ah, bool dump_base_hdr,
PR_EEP("SW Reg", le32_to_cpu(pBase->swreg));

len += scnprintf(buf + len, size - len, "%20s : %pM\n", "MacAddress",
- ah->eeprom.ar9300_eep.macAddr);
+ ar9003_mac_addr(ah));
out:
if (len > size)
len = size;
@@ -3625,7 +3846,7 @@ static u32 ath9k_hw_ar9003_dump_eeprom(struct ath_hw *ah, bool dump_base_hdr,

static void ar9003_hw_xpa_bias_level_apply(struct ath_hw *ah, bool is2ghz)
{
- int bias = ar9003_modal_header(ah, is2ghz)->xpaBiasLvl;
+ int bias = ar9003_xpa_bias_lvl(ah, is2ghz);

if (AR_SREV_9485(ah) || AR_SREV_9330(ah) || AR_SREV_9340(ah) ||
AR_SREV_9531(ah) || AR_SREV_9561(ah))
@@ -3798,8 +4019,7 @@ static void ar9003_hw_ant_ctrl_apply(struct ath_hw *ah, bool is2ghz)

static void ar9003_hw_drive_strength_apply(struct ath_hw *ah)
{
- struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
- struct ar9300_base_eep_hdr *pBase = &eep->baseEepHeader;
+ struct ar9300_base_eep_hdr *pBase = ar9003_base_header(ah);
int drive_strength;
unsigned long reg;

@@ -3843,23 +4063,23 @@ static u16 ar9003_hw_atten_chain_get(struct ath_hw *ah, int chain,
{
int f[3], t[3];
u16 value;
- struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
+ bool is2ghz = IS_CHAN_2GHZ(chan);

if (chain >= 0 && chain < 3) {
- if (IS_CHAN_2GHZ(chan))
- return eep->modalHeader2G.xatten1DB[chain];
- else if (eep->base_ext2.xatten1DBLow[chain] != 0) {
- t[0] = eep->base_ext2.xatten1DBLow[chain];
+ if (is2ghz)
+ return ar9003_xatten1_db(ah, chain, is2ghz);
+ else if (ar9003_xatten1_db_low(ah, chain) != 0) {
+ t[0] = ar9003_xatten1_db_low(ah, chain);
f[0] = 5180;
- t[1] = eep->modalHeader5G.xatten1DB[chain];
+ t[1] = ar9003_xatten1_db(ah, chain, is2ghz);
f[1] = 5500;
- t[2] = eep->base_ext2.xatten1DBHigh[chain];
+ t[2] = ar9003_xatten1_db_high(ah, chain);
f[2] = 5785;
value = ar9003_hw_power_interpolate((s32) chan->channel,
f, t, 3);
return value;
} else
- return eep->modalHeader5G.xatten1DB[chain];
+ return ar9003_xatten1_db(ah, chain, is2ghz);
}

return 0;
@@ -3871,23 +4091,23 @@ static u16 ar9003_hw_atten_chain_get_margin(struct ath_hw *ah, int chain,
{
int f[3], t[3];
u16 value;
- struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
+ bool is2ghz = IS_CHAN_2GHZ(chan);

if (chain >= 0 && chain < 3) {
- if (IS_CHAN_2GHZ(chan))
- return eep->modalHeader2G.xatten1Margin[chain];
- else if (eep->base_ext2.xatten1MarginLow[chain] != 0) {
- t[0] = eep->base_ext2.xatten1MarginLow[chain];
+ if (is2ghz)
+ return ar9003_xatten1_margin(ah, chain, is2ghz);
+ else if (ar9003_xatten1_db_margin_low(ah, chain) != 0) {
+ t[0] = ar9003_xatten1_db_margin_low(ah, chain);
f[0] = 5180;
- t[1] = eep->modalHeader5G.xatten1Margin[chain];
+ t[1] = ar9003_xatten1_margin(ah, chain, is2ghz);
f[1] = 5500;
- t[2] = eep->base_ext2.xatten1MarginHigh[chain];
+ t[2] = ar9003_xatten1_db_margin_high(ah, chain);
f[2] = 5785;
value = ar9003_hw_power_interpolate((s32) chan->channel,
f, t, 3);
return value;
} else
- return eep->modalHeader5G.xatten1Margin[chain];
+ return ar9003_xatten1_margin(ah, chain, is2ghz);
}

return 0;
@@ -3955,8 +4175,7 @@ static bool is_pmu_set(struct ath_hw *ah, u32 pmu_reg, int pmu_set)

void ar9003_hw_internal_regulator_apply(struct ath_hw *ah)
{
- struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
- struct ar9300_base_eep_hdr *pBase = &eep->baseEepHeader;
+ struct ar9300_base_eep_hdr *pBase = ar9003_base_header(ah);
u32 reg_val;

if (pBase->featureEnable & BIT(4)) {
@@ -4050,13 +4269,13 @@ void ar9003_hw_internal_regulator_apply(struct ath_hw *ah)

static void ar9003_hw_apply_tuning_caps(struct ath_hw *ah)
{
- struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
- u8 tuning_caps_param = eep->baseEepHeader.params_for_tuning_caps[0];
+ struct ar9300_base_eep_hdr *pBase = ar9003_base_header(ah);
+ u8 tuning_caps_param = pBase->params_for_tuning_caps[0];

if (AR_SREV_9340(ah) || AR_SREV_9531(ah))
return;

- if (eep->baseEepHeader.featureEnable & 0x40) {
+ if (pBase->featureEnable & 0x40) {
tuning_caps_param &= 0x7f;
REG_RMW_FIELD(ah, AR_CH0_XTAL, AR_CH0_XTAL_CAPINDAC,
tuning_caps_param);
@@ -4067,21 +4286,22 @@ static void ar9003_hw_apply_tuning_caps(struct ath_hw *ah)

static void ar9003_hw_quick_drop_apply(struct ath_hw *ah, u16 freq)
{
- struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
- struct ar9300_base_eep_hdr *pBase = &eep->baseEepHeader;
+ struct ar9300_base_eep_hdr *pBase = ar9003_base_header(ah);
+ struct ar9300_BaseExtension_1 *base_ext1 = ar9003_base_ext1(ah);
int quick_drop;
s32 t[3], f[3] = {5180, 5500, 5785};
+ bool is2ghz = freq < 4000;

if (!(pBase->miscConfiguration & BIT(4)))
return;

if (AR_SREV_9300(ah) || AR_SREV_9580(ah) || AR_SREV_9340(ah)) {
- if (freq < 4000) {
- quick_drop = eep->modalHeader2G.quick_drop;
+ if (is2ghz) {
+ quick_drop = ar9003_quick_drop(ah, is2ghz);
} else {
- t[0] = eep->base_ext1.quick_drop_low;
- t[1] = eep->modalHeader5G.quick_drop;
- t[2] = eep->base_ext1.quick_drop_high;
+ t[0] = base_ext1->quick_drop_low;
+ t[1] = ar9003_quick_drop(ah, is2ghz);
+ t[2] = base_ext1->quick_drop_high;
quick_drop = ar9003_hw_power_interpolate(freq, f, t, 3);
}
REG_RMW_FIELD(ah, AR_PHY_AGC, AR_PHY_AGC_QUICK_DROP, quick_drop);
@@ -4092,7 +4312,7 @@ static void ar9003_hw_txend_to_xpa_off_apply(struct ath_hw *ah, bool is2ghz)
{
u32 value;

- value = ar9003_modal_header(ah, is2ghz)->txEndToXpaOff;
+ value = ar9003_tx_end_to_xpa_off(ah, is2ghz);

REG_RMW_FIELD(ah, AR_PHY_XPA_TIMING_CTL,
AR_PHY_XPA_TIMING_CTL_TX_END_XPAB_OFF, value);
@@ -4102,10 +4322,10 @@ static void ar9003_hw_txend_to_xpa_off_apply(struct ath_hw *ah, bool is2ghz)

static void ar9003_hw_xpa_timing_control_apply(struct ath_hw *ah, bool is2ghz)
{
- struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
+ struct ar9300_base_eep_hdr *pBase = ar9003_base_header(ah);
u8 xpa_ctl;

- if (!(eep->baseEepHeader.featureEnable & 0x80))
+ if (!(pBase->featureEnable & 0x80))
return;

if (!AR_SREV_9300(ah) &&
@@ -4116,7 +4336,7 @@ static void ar9003_hw_xpa_timing_control_apply(struct ath_hw *ah, bool is2ghz)
!AR_SREV_5502(ah))
return;

- xpa_ctl = ar9003_modal_header(ah, is2ghz)->txFrameToXpaOn;
+ xpa_ctl = ar9003_tx_frame_to_xpa_on(ah, is2ghz);
if (is2ghz)
REG_RMW_FIELD(ah, AR_PHY_XPA_TIMING_CTL,
AR_PHY_XPA_TIMING_CTL_FRAME_XPAB_ON, xpa_ctl);
@@ -4127,16 +4347,16 @@ static void ar9003_hw_xpa_timing_control_apply(struct ath_hw *ah, bool is2ghz)

static void ar9003_hw_xlna_bias_strength_apply(struct ath_hw *ah, bool is2ghz)
{
- struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
+ struct ar9300_base_eep_hdr *pBase = ar9003_base_header(ah);
u8 bias;

- if (!(eep->baseEepHeader.miscConfiguration & 0x40))
+ if (!(pBase->miscConfiguration & 0x40))
return;

if (!AR_SREV_9300(ah))
return;

- bias = ar9003_modal_header(ah, is2ghz)->xlna_bias_strength;
+ bias = ar9003_xlna_bias_strength(ah, is2ghz);
REG_RMW_FIELD(ah, AR_PHY_65NM_CH0_RXTX4, AR_PHY_65NM_RXTX4_XLNA_BIAS,
bias & 0x3);
bias >>= 2;
@@ -4149,8 +4369,7 @@ static void ar9003_hw_xlna_bias_strength_apply(struct ath_hw *ah, bool is2ghz)

static int ar9003_hw_get_thermometer(struct ath_hw *ah)
{
- struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
- struct ar9300_base_eep_hdr *pBase = &eep->baseEepHeader;
+ struct ar9300_base_eep_hdr *pBase = ar9003_base_header(ah);
int thermometer = (pBase->miscConfiguration >> 1) & 0x3;

return --thermometer;
@@ -4208,7 +4427,7 @@ static void ar9003_hw_thermo_cal_apply(struct ath_hw *ah)
static void ar9003_hw_apply_minccapwr_thresh(struct ath_hw *ah,
bool is2ghz)
{
- struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
+ struct ar9300_BaseExtension_1 *base_ext1 = ar9003_base_ext1(ah);
const u_int32_t cca_ctrl[AR9300_MAX_CHAINS] = {
AR_PHY_CCA_CTRL_0,
AR_PHY_CCA_CTRL_1,
@@ -4218,10 +4437,10 @@ static void ar9003_hw_apply_minccapwr_thresh(struct ath_hw *ah,
u32 val;

if (is2ghz) {
- if (!(eep->base_ext1.misc_enable & BIT(2)))
+ if (!(base_ext1->misc_enable & BIT(2)))
return;
} else {
- if (!(eep->base_ext1.misc_enable & BIT(3)))
+ if (!(base_ext1->misc_enable & BIT(3)))
return;
}

@@ -4229,7 +4448,7 @@ static void ar9003_hw_apply_minccapwr_thresh(struct ath_hw *ah,
if (!(ah->caps.tx_chainmask & BIT(chain)))
continue;

- val = ar9003_modal_header(ah, is2ghz)->noiseFloorThreshCh[chain];
+ val = ar9003_noise_floor_thres(ah, chain, is2ghz);
REG_RMW_FIELD(ah, cca_ctrl[chain],
AR_PHY_EXT_CCA0_THRESH62_1, val);
}
@@ -4330,18 +4549,11 @@ static u8 ar9003_hw_eeprom_get_tgt_pwr(struct ath_hw *ah,
u16 numPiers, i;
s32 targetPowerArray[AR9300_NUM_5G_20_TARGET_POWERS];
s32 freqArray[AR9300_NUM_5G_20_TARGET_POWERS];
- struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
- struct cal_tgt_pow_legacy *pEepromTargetPwr;
- u8 *pFreqBin;

if (is2GHz) {
numPiers = AR9300_NUM_2G_20_TARGET_POWERS;
- pEepromTargetPwr = eep->calTargetPower2G;
- pFreqBin = eep->calTarget_freqbin_2G;
} else {
numPiers = AR9300_NUM_5G_20_TARGET_POWERS;
- pEepromTargetPwr = eep->calTargetPower5G;
- pFreqBin = eep->calTarget_freqbin_5G;
}

/*
@@ -4349,8 +4561,10 @@ static u8 ar9003_hw_eeprom_get_tgt_pwr(struct ath_hw *ah,
* targetpower piers stored on eeprom
*/
for (i = 0; i < numPiers; i++) {
- freqArray[i] = ath9k_hw_fbin2freq(pFreqBin[i], is2GHz);
- targetPowerArray[i] = pEepromTargetPwr[i].tPow2x[rateIndex];
+ freqArray[i] = ath9k_hw_fbin2freq(
+ ar9003_cal_target_freqbin(ah, i, is2GHz), is2GHz);
+ targetPowerArray[i] =
+ ar9003_cal_target_power(ah, i, rateIndex, is2GHz);
}

/* interpolate to get target power for given frequency */
@@ -4366,18 +4580,11 @@ static u8 ar9003_hw_eeprom_get_ht20_tgt_pwr(struct ath_hw *ah,
u16 numPiers, i;
s32 targetPowerArray[AR9300_NUM_5G_20_TARGET_POWERS];
s32 freqArray[AR9300_NUM_5G_20_TARGET_POWERS];
- struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
- struct cal_tgt_pow_ht *pEepromTargetPwr;
- u8 *pFreqBin;

if (is2GHz) {
numPiers = AR9300_NUM_2G_20_TARGET_POWERS;
- pEepromTargetPwr = eep->calTargetPower2GHT20;
- pFreqBin = eep->calTarget_freqbin_2GHT20;
} else {
numPiers = AR9300_NUM_5G_20_TARGET_POWERS;
- pEepromTargetPwr = eep->calTargetPower5GHT20;
- pFreqBin = eep->calTarget_freqbin_5GHT20;
}

/*
@@ -4385,8 +4592,11 @@ static u8 ar9003_hw_eeprom_get_ht20_tgt_pwr(struct ath_hw *ah,
* from targetpower piers stored on eeprom
*/
for (i = 0; i < numPiers; i++) {
- freqArray[i] = ath9k_hw_fbin2freq(pFreqBin[i], is2GHz);
- targetPowerArray[i] = pEepromTargetPwr[i].tPow2x[rateIndex];
+ freqArray[i] = ath9k_hw_fbin2freq(
+ ar9003_cal_target_freqbin_ht20(ah, i, is2GHz),
+ is2GHz);
+ targetPowerArray[i] = ar9003_cal_target_power_ht20(
+ ah, i, rateIndex, is2GHz);
}

/* interpolate to get target power for given frequency */
@@ -4402,18 +4612,11 @@ static u8 ar9003_hw_eeprom_get_ht40_tgt_pwr(struct ath_hw *ah,
u16 numPiers, i;
s32 targetPowerArray[AR9300_NUM_5G_40_TARGET_POWERS];
s32 freqArray[AR9300_NUM_5G_40_TARGET_POWERS];
- struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
- struct cal_tgt_pow_ht *pEepromTargetPwr;
- u8 *pFreqBin;

if (is2GHz) {
numPiers = AR9300_NUM_2G_40_TARGET_POWERS;
- pEepromTargetPwr = eep->calTargetPower2GHT40;
- pFreqBin = eep->calTarget_freqbin_2GHT40;
} else {
numPiers = AR9300_NUM_5G_40_TARGET_POWERS;
- pEepromTargetPwr = eep->calTargetPower5GHT40;
- pFreqBin = eep->calTarget_freqbin_5GHT40;
}

/*
@@ -4421,8 +4624,11 @@ static u8 ar9003_hw_eeprom_get_ht40_tgt_pwr(struct ath_hw *ah,
* targetpower piers stored on eeprom
*/
for (i = 0; i < numPiers; i++) {
- freqArray[i] = ath9k_hw_fbin2freq(pFreqBin[i], is2GHz);
- targetPowerArray[i] = pEepromTargetPwr[i].tPow2x[rateIndex];
+ freqArray[i] = ath9k_hw_fbin2freq(
+ ar9003_cal_target_freqbin_ht40(ah, i, is2GHz),
+ is2GHz);
+ targetPowerArray[i] = ar9003_cal_target_power_ht40(
+ ah, i, rateIndex, is2GHz);
}

/* interpolate to get target power for given frequency */
@@ -4437,17 +4643,16 @@ static u8 ar9003_hw_eeprom_get_cck_tgt_pwr(struct ath_hw *ah,
u16 numPiers = AR9300_NUM_2G_CCK_TARGET_POWERS, i;
s32 targetPowerArray[AR9300_NUM_2G_CCK_TARGET_POWERS];
s32 freqArray[AR9300_NUM_2G_CCK_TARGET_POWERS];
- struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
- struct cal_tgt_pow_legacy *pEepromTargetPwr = eep->calTargetPowerCck;
- u8 *pFreqBin = eep->calTarget_freqbin_Cck;

/*
* create array of channels and targetpower from
* targetpower piers stored on eeprom
*/
for (i = 0; i < numPiers; i++) {
- freqArray[i] = ath9k_hw_fbin2freq(pFreqBin[i], 1);
- targetPowerArray[i] = pEepromTargetPwr[i].tPow2x[rateIndex];
+ freqArray[i] = ath9k_hw_fbin2freq(
+ ar9003_cal_target_freqbin_cck(ah, i), 1);
+ targetPowerArray[i] =
+ ar9003_cal_target_power_cck(ah, i, rateIndex);
}

/* interpolate to get target power for given frequency */
@@ -4759,9 +4964,8 @@ static int ar9003_hw_cal_pier_get(struct ath_hw *ah,
int *ptemperature, int *pvoltage,
int *pnf_cal, int *pnf_power)
{
- u8 *pCalPier;
+ u8 calPier;
struct ar9300_cal_data_per_freq_op_loop *pCalPierStruct;
- struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
struct ath_common *common = ath9k_hw_common(ah);

if (ichain >= AR9300_MAX_CHAINS) {
@@ -4778,9 +4982,8 @@ static int ar9003_hw_cal_pier_get(struct ath_hw *ah,
AR9300_NUM_2G_CAL_PIERS);
return -1;
}
-
- pCalPier = &(eep->calFreqPier2G[ipier]);
- pCalPierStruct = &(eep->calPierData2G[ichain][ipier]);
+ calPier = ar9003_cal_freq_pier(ah, ipier, is2ghz);
+ pCalPierStruct = ar9003_cal_pier_data(ah, ichain, ipier, is2ghz);
} else {
if (ipier >= AR9300_NUM_5G_CAL_PIERS) {
ath_dbg(common, EEPROM,
@@ -4788,11 +4991,11 @@ static int ar9003_hw_cal_pier_get(struct ath_hw *ah,
AR9300_NUM_5G_CAL_PIERS);
return -1;
}
- pCalPier = &(eep->calFreqPier5G[ipier]);
- pCalPierStruct = &(eep->calPierData5G[ichain][ipier]);
+ calPier = ar9003_cal_freq_pier(ah, ipier, is2ghz);
+ pCalPierStruct = ar9003_cal_pier_data(ah, ichain, ipier, is2ghz);
}

- *pfrequency = ath9k_hw_fbin2freq(*pCalPier, is2ghz);
+ *pfrequency = ath9k_hw_fbin2freq(calPier, is2ghz);
*pcorrection = pCalPierStruct->refPower;
*ptemperature = pCalPierStruct->tempMeas;
*pvoltage = pCalPierStruct->voltMeas;
@@ -4810,7 +5013,12 @@ static void ar9003_hw_power_control_override(struct ath_hw *ah,
int *voltage, int *temperature)
{
int temp_slope = 0, temp_slope1 = 0, temp_slope2 = 0;
- struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
+ struct ar9300_base_eep_hdr *pBase = ar9003_base_header(ah);
+ struct ar9300_BaseExtension_1 *base_ext1 = ar9003_base_ext1(ah);
+ bool is2ghz = frequency < 4000;
+ int8_t eep_temp_slope = ar9003_temp_slope(ah, is2ghz);
+ int8_t eep_temp_slope_low = ar9003_temp_slope_low(ah);
+ int8_t eep_temp_slope_high = ar9003_temp_slope_high(ah);
int f[8], t[8], t1[3], t2[3], i;

REG_RMW(ah, AR_PHY_TPC_11_B0,
@@ -4842,23 +5050,23 @@ static void ar9003_hw_power_control_override(struct ath_hw *ah,
* enable temperature compensation
* Need to use register names
*/
- if (frequency < 4000) {
- temp_slope = eep->modalHeader2G.tempSlope;
+ if (is2ghz) {
+ temp_slope = eep_temp_slope;
} else {
if (AR_SREV_9550(ah)) {
- t[0] = eep->base_ext1.tempslopextension[2];
- t1[0] = eep->base_ext1.tempslopextension[3];
- t2[0] = eep->base_ext1.tempslopextension[4];
+ t[0] = base_ext1->tempslopextension[2];
+ t1[0] = base_ext1->tempslopextension[3];
+ t2[0] = base_ext1->tempslopextension[4];
f[0] = 5180;

- t[1] = eep->modalHeader5G.tempSlope;
- t1[1] = eep->base_ext1.tempslopextension[0];
- t2[1] = eep->base_ext1.tempslopextension[1];
+ t[1] = eep_temp_slope;
+ t1[1] = base_ext1->tempslopextension[0];
+ t2[1] = base_ext1->tempslopextension[1];
f[1] = 5500;

- t[2] = eep->base_ext1.tempslopextension[5];
- t1[2] = eep->base_ext1.tempslopextension[6];
- t2[2] = eep->base_ext1.tempslopextension[7];
+ t[2] = base_ext1->tempslopextension[5];
+ t1[2] = base_ext1->tempslopextension[6];
+ t2[2] = base_ext1->tempslopextension[7];
f[2] = 5785;

temp_slope = ar9003_hw_power_interpolate(frequency,
@@ -4871,42 +5079,44 @@ static void ar9003_hw_power_control_override(struct ath_hw *ah,
goto tempslope;
}

- if ((eep->baseEepHeader.miscConfiguration & 0x20) != 0) {
+ if ((pBase->miscConfiguration & 0x20) != 0) {
for (i = 0; i < 8; i++) {
- t[i] = eep->base_ext1.tempslopextension[i];
- f[i] = FBIN2FREQ(eep->calFreqPier5G[i], 0);
+ t[i] = base_ext1->tempslopextension[i];
+ f[i] = FBIN2FREQ(
+ ar9003_cal_freq_pier(ah, i, is2ghz),
+ 0);
}
temp_slope = ar9003_hw_power_interpolate((s32) frequency,
f, t, 8);
- } else if (eep->base_ext2.tempSlopeLow != 0) {
- t[0] = eep->base_ext2.tempSlopeLow;
+ } else if (eep_temp_slope_low != 0) {
+ t[0] = eep_temp_slope_low;
f[0] = 5180;
- t[1] = eep->modalHeader5G.tempSlope;
+ t[1] = eep_temp_slope;
f[1] = 5500;
- t[2] = eep->base_ext2.tempSlopeHigh;
+ t[2] = eep_temp_slope_high;
f[2] = 5785;
temp_slope = ar9003_hw_power_interpolate((s32) frequency,
f, t, 3);
} else {
- temp_slope = eep->modalHeader5G.tempSlope;
+ temp_slope = eep_temp_slope;
}
}

tempslope:
if (AR_SREV_9550(ah) || AR_SREV_9531(ah) || AR_SREV_9561(ah) ||
AR_SREV_5502(ah)) {
- u8 txmask = (eep->baseEepHeader.txrxMask & 0xf0) >> 4;
+ u8 txmask = (pBase->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) {
+ if (pBase->featureEnable & 0x1) {
+ if (is2ghz) {
if (txmask & BIT(0))
REG_RMW_FIELD(ah, AR_PHY_TPC_19,
AR_PHY_TPC_19_ALPHA_THERM,
- eep->base_ext2.tempSlopeLow);
+ eep_temp_slope_low);
if (txmask & BIT(1))
REG_RMW_FIELD(ah, AR_PHY_TPC_19_B1,
AR_PHY_TPC_19_ALPHA_THERM,
@@ -4914,7 +5124,7 @@ static void ar9003_hw_power_control_override(struct ath_hw *ah,
if (txmask & BIT(2))
REG_RMW_FIELD(ah, AR_PHY_TPC_19_B2,
AR_PHY_TPC_19_ALPHA_THERM,
- eep->base_ext2.tempSlopeHigh);
+ eep_temp_slope_high);
} else {
if (txmask & BIT(0))
REG_RMW_FIELD(ah, AR_PHY_TPC_19,
@@ -5139,42 +5349,25 @@ static int ar9003_hw_calibration_apply(struct ath_hw *ah, int frequency)
return 0;
}

-static u16 ar9003_hw_get_direct_edge_power(struct ar9300_eeprom *eep,
+static u16 ar9003_hw_get_direct_edge_power(struct ath_hw *ah,
int idx,
int edge,
bool is2GHz)
{
- struct cal_ctl_data_2g *ctl_2g = eep->ctlPowerData_2G;
- struct cal_ctl_data_5g *ctl_5g = eep->ctlPowerData_5G;
-
- if (is2GHz)
- return CTL_EDGE_TPOWER(ctl_2g[idx].ctlEdges[edge]);
- else
- return CTL_EDGE_TPOWER(ctl_5g[idx].ctlEdges[edge]);
+ return CTL_EDGE_TPOWER(ar9003_ctl_power_data(ah, idx, edge, is2GHz));
}

-static u16 ar9003_hw_get_indirect_edge_power(struct ar9300_eeprom *eep,
+static u16 ar9003_hw_get_indirect_edge_power(struct ath_hw *ah,
int idx,
unsigned int edge,
u16 freq,
bool is2GHz)
{
- struct cal_ctl_data_2g *ctl_2g = eep->ctlPowerData_2G;
- struct cal_ctl_data_5g *ctl_5g = eep->ctlPowerData_5G;
-
- u8 *ctl_freqbin = is2GHz ?
- &eep->ctl_freqbin_2G[idx][0] :
- &eep->ctl_freqbin_5G[idx][0];
-
- if (is2GHz) {
- if (ath9k_hw_fbin2freq(ctl_freqbin[edge - 1], 1) < freq &&
- CTL_EDGE_FLAGS(ctl_2g[idx].ctlEdges[edge - 1]))
- return CTL_EDGE_TPOWER(ctl_2g[idx].ctlEdges[edge - 1]);
- } else {
- if (ath9k_hw_fbin2freq(ctl_freqbin[edge - 1], 0) < freq &&
- CTL_EDGE_FLAGS(ctl_5g[idx].ctlEdges[edge - 1]))
- return CTL_EDGE_TPOWER(ctl_5g[idx].ctlEdges[edge - 1]);
- }
+ if (ath9k_hw_fbin2freq(ar9003_ctl_freqbin(ah, idx, edge - 1, is2GHz),
+ is2GHz) < freq &&
+ CTL_EDGE_FLAGS(ar9003_ctl_power_data(ah, idx, edge - 1, is2GHz)))
+ return CTL_EDGE_TPOWER(
+ ar9003_ctl_power_data(ah, idx, edge - 1, is2GHz));

return MAX_RATE_POWER;
}
@@ -5182,37 +5375,36 @@ static u16 ar9003_hw_get_indirect_edge_power(struct ar9300_eeprom *eep,
/*
* Find the maximum conformance test limit for the given channel and CTL info
*/
-static u16 ar9003_hw_get_max_edge_power(struct ar9300_eeprom *eep,
+static u16 ar9003_hw_get_max_edge_power(struct ath_hw *ah,
u16 freq, int idx, bool is2GHz)
{
u16 twiceMaxEdgePower = MAX_RATE_POWER;
- u8 *ctl_freqbin = is2GHz ?
- &eep->ctl_freqbin_2G[idx][0] :
- &eep->ctl_freqbin_5G[idx][0];
u16 num_edges = is2GHz ?
AR9300_NUM_BAND_EDGES_2G : AR9300_NUM_BAND_EDGES_5G;
unsigned int edge;

/* Get the edge power */
for (edge = 0;
- (edge < num_edges) && (ctl_freqbin[edge] != AR5416_BCHAN_UNUSED);
+ (edge < num_edges) &&
+ (ar9003_ctl_freqbin(ah, idx, edge, is2GHz) != AR5416_BCHAN_UNUSED);
edge++) {
/*
* If there's an exact channel match or an inband flag set
* on the lower channel use the given rdEdgePower
*/
- if (freq == ath9k_hw_fbin2freq(ctl_freqbin[edge], is2GHz)) {
- twiceMaxEdgePower =
- ar9003_hw_get_direct_edge_power(eep, idx,
- edge, is2GHz);
+ if (freq == ath9k_hw_fbin2freq(ar9003_ctl_freqbin(ah, idx, edge,
+ is2GHz),
+ is2GHz)) {
+ twiceMaxEdgePower = ar9003_hw_get_direct_edge_power(
+ ah, idx, edge, is2GHz);
break;
} else if ((edge > 0) &&
- (freq < ath9k_hw_fbin2freq(ctl_freqbin[edge],
- is2GHz))) {
- twiceMaxEdgePower =
- ar9003_hw_get_indirect_edge_power(eep, idx,
- edge, freq,
- is2GHz);
+ (freq <
+ ath9k_hw_fbin2freq(ar9003_ctl_freqbin(ah, idx, edge,
+ is2GHz),
+ is2GHz))) {
+ twiceMaxEdgePower = ar9003_hw_get_indirect_edge_power(
+ ah, idx, edge, freq, is2GHz);
/*
* Leave loop - no more affecting edges possible in
* this monotonic increasing list
@@ -5234,7 +5426,6 @@ static void ar9003_hw_set_power_per_rate_table(struct ath_hw *ah,
u16 powerLimit)
{
struct ath_common *common = ath9k_hw_common(ah);
- struct ar9300_eeprom *pEepData = &ah->eeprom.ar9300_eep;
u16 twiceMaxEdgePower;
int i;
u16 scaledPower = 0, minCtlPower;
@@ -5249,7 +5440,6 @@ static void ar9003_hw_set_power_per_rate_table(struct ath_hw *ah,
const u16 *pCtlMode;
u16 ctlMode, freq;
struct chan_centers centers;
- u8 *ctlIndex;
u8 ctlNum;
u16 twiceMinEdgePower;
bool is2ghz = IS_CHAN_2GHZ(chan);
@@ -5304,18 +5494,17 @@ static void ar9003_hw_set_power_per_rate_table(struct ath_hw *ah,

/* walk through each CTL index stored in EEPROM */
if (is2ghz) {
- ctlIndex = pEepData->ctlIndex_2G;
ctlNum = AR9300_NUM_CTLS_2G;
} else {
- ctlIndex = pEepData->ctlIndex_5G;
ctlNum = AR9300_NUM_CTLS_5G;
}

twiceMaxEdgePower = MAX_RATE_POWER;
- for (i = 0; (i < ctlNum) && ctlIndex[i]; i++) {
+ for (i = 0; (i < ctlNum) && ar9003_ctl_index(ah, i, is2ghz);
+ i++) {
ath_dbg(common, REGULATORY,
"LOOP-Ctlidx %d: cfgCtl 0x%2.2x pCtlMode 0x%2.2x ctlIndex 0x%2.2x chan %d\n",
- i, cfgCtl, pCtlMode[ctlMode], ctlIndex[i],
+ i, cfgCtl, pCtlMode[ctlMode], ar9003_ctl_index(ah, i, is2ghz),
chan->channel);

/*
@@ -5325,13 +5514,13 @@ static void ar9003_hw_set_power_per_rate_table(struct ath_hw *ah,
*/
if ((((cfgCtl & ~CTL_MODE_M) |
(pCtlMode[ctlMode] & CTL_MODE_M)) ==
- ctlIndex[i]) ||
+ ar9003_ctl_index(ah, i, is2ghz)) ||
(((cfgCtl & ~CTL_MODE_M) |
(pCtlMode[ctlMode] & CTL_MODE_M)) ==
- ((ctlIndex[i] & CTL_MODE_M) |
+ ((ar9003_ctl_index(ah, i, is2ghz) & CTL_MODE_M) |
SD_NO_CTL))) {
twiceMinEdgePower =
- ar9003_hw_get_max_edge_power(pEepData,
+ ar9003_hw_get_max_edge_power(ah,
freq, i,
is2ghz);

@@ -5569,16 +5758,12 @@ static u16 ath9k_hw_ar9300_get_spur_channel(struct ath_hw *ah,

s32 ar9003_hw_get_tx_gain_idx(struct ath_hw *ah)
{
- struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
-
- return (eep->baseEepHeader.txrxgain >> 4) & 0xf; /* bits 7:4 */
+ return (ar9003_base_header(ah)->txrxgain >> 4) & 0xf; /* bits 7:4 */
}

s32 ar9003_hw_get_rx_gain_idx(struct ath_hw *ah)
{
- struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
-
- return (eep->baseEepHeader.txrxgain) & 0xf; /* bits 3:0 */
+ return (ar9003_base_header(ah)->txrxgain) & 0xf; /* bits 3:0 */
}

u8 *ar9003_get_spur_chan_ptr(struct ath_hw *ah, bool is2ghz)
@@ -5619,7 +5804,7 @@ unsigned int ar9003_get_paprd_scale_factor(struct ath_hw *ah,

static u8 ar9003_get_eepmisc(struct ath_hw *ah)
{
- return ah->eeprom.ar9300_eep.baseEepHeader.opCapFlags.eepMisc;
+ return ar9003_base_header(ah)->opCapFlags.eepMisc;
}

const struct eeprom_ops eep_ar9300_ops = {
--
2.25.1

2022-04-18 12:43:24

by Wenli Looi

[permalink] [raw]
Subject: [PATCH 2/9] ath9k: basic support for QCN550x

QCN550x is very similar to QCA956x. Note that AR_CH0_XTAL is
intentionally unchanged. Certain arrays are no longer static because
they are no longer constant.
---
drivers/net/wireless/ath/ath9k/ani.c | 2 +-
drivers/net/wireless/ath/ath9k/ar9003_calib.c | 4 +-
.../net/wireless/ath/ath9k/ar9003_eeprom.c | 17 ++--
drivers/net/wireless/ath/ath9k/ar9003_paprd.c | 4 +-
drivers/net/wireless/ath/ath9k/ar9003_phy.c | 35 ++++----
drivers/net/wireless/ath/ath9k/ar9003_phy.h | 83 ++++++++++++-------
drivers/net/wireless/ath/ath9k/hw.c | 28 ++++---
drivers/net/wireless/ath/ath9k/mac.c | 2 +-
drivers/net/wireless/ath/ath9k/recv.c | 2 +-
drivers/net/wireless/ath/ath9k/reg.h | 4 +-
drivers/net/wireless/ath/ath9k/reg_aic.h | 6 +-
11 files changed, 112 insertions(+), 75 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ani.c b/drivers/net/wireless/ath/ath9k/ani.c
index 41d192709..281103865 100644
--- a/drivers/net/wireless/ath/ath9k/ani.c
+++ b/drivers/net/wireless/ath/ath9k/ani.c
@@ -261,7 +261,7 @@ static void ath9k_hw_set_cck_nil(struct ath_hw *ah, u_int8_t immunityLevel,

/* Skip MRC CCK for pre AR9003 families */
if (!AR_SREV_9300_20_OR_LATER(ah) || AR_SREV_9485(ah) ||
- AR_SREV_9565(ah) || AR_SREV_9561(ah))
+ AR_SREV_9565(ah) || AR_SREV_9561(ah) || AR_SREV_5502(ah))
return;

if (aniState->mrcCCK != entry_cck->mrc_cck_on)
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_calib.c b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
index 6ca089f15..e2cf4b733 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
@@ -201,7 +201,7 @@ static void ar9003_hw_iqcalibrate(struct ath_hw *ah, u8 numChains)
u32 qCoffDenom, iCoffDenom;
int32_t qCoff, iCoff;
int iqCorrNeg, i;
- static const u_int32_t offset_array[3] = {
+ const u_int32_t offset_array[3] = {
AR_PHY_RX_IQCAL_CORR_B0,
AR_PHY_RX_IQCAL_CORR_B1,
AR_PHY_RX_IQCAL_CORR_B2,
@@ -1202,7 +1202,7 @@ static void ar9003_hw_manual_peak_cal(struct ath_hw *ah, u8 chain, bool is_2g)

if (AR_SREV_9550(ah) || AR_SREV_9531(ah))
peak_detect_threshold = 8;
- else if (AR_SREV_9561(ah))
+ else if (AR_SREV_9561(ah) || AR_SREV_5502(ah))
peak_detect_threshold = 11;

/*
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
index 16bfcd0a1..49be3a315 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
@@ -3608,6 +3608,8 @@ static void ar9003_hw_xpa_bias_level_apply(struct ath_hw *ah, bool is2ghz)
if (AR_SREV_9485(ah) || AR_SREV_9330(ah) || AR_SREV_9340(ah) ||
AR_SREV_9531(ah) || AR_SREV_9561(ah))
REG_RMW_FIELD(ah, AR_CH0_TOP2, AR_CH0_TOP2_XPABIASLVL, bias);
+ else if (AR_SREV_5502(ah))
+ REG_RMW_FIELD(ah, AR_CH0_TOP3, AR_CH0_TOP3_XPABIASLVL, bias);
else if (AR_SREV_9462(ah) || AR_SREV_9550(ah) || AR_SREV_9565(ah))
REG_RMW_FIELD(ah, AR_CH0_TOP, AR_CH0_TOP_XPABIASLVL, bias);
else {
@@ -3648,7 +3650,7 @@ static void ar9003_hw_ant_ctrl_apply(struct ath_hw *ah, bool is2ghz)
struct ath9k_hw_capabilities *pCap = &ah->caps;
int chain;
u32 regval, value, gpio;
- static const u32 switch_chain_reg[AR9300_MAX_CHAINS] = {
+ const u32 switch_chain_reg[AR9300_MAX_CHAINS] = {
AR_PHY_SWITCH_CHAIN_0,
AR_PHY_SWITCH_CHAIN_1,
AR_PHY_SWITCH_CHAIN_2,
@@ -3669,7 +3671,8 @@ static void ar9003_hw_ant_ctrl_apply(struct ath_hw *ah, bool is2ghz)
if (AR_SREV_9462(ah) || AR_SREV_9565(ah)) {
REG_RMW_FIELD(ah, AR_PHY_SWITCH_COM,
AR_SWITCH_TABLE_COM_AR9462_ALL, value);
- } else if (AR_SREV_9550(ah) || AR_SREV_9531(ah) || AR_SREV_9561(ah)) {
+ } else if (AR_SREV_9550(ah) || AR_SREV_9531(ah) || AR_SREV_9561(ah) ||
+ AR_SREV_5502(ah)) {
REG_RMW_FIELD(ah, AR_PHY_SWITCH_COM,
AR_SWITCH_TABLE_COM_AR9550_ALL, value);
} else
@@ -4000,11 +4003,11 @@ void ar9003_hw_internal_regulator_apply(struct ath_hw *ah)
if (!is_pmu_set(ah, AR_PHY_PMU2, reg_pmu_set))
return;
} else if (AR_SREV_9462(ah) || AR_SREV_9565(ah) ||
- AR_SREV_9561(ah)) {
+ AR_SREV_9561(ah) || AR_SREV_5502(ah)) {
reg_val = le32_to_cpu(pBase->swreg);
REG_WRITE(ah, AR_PHY_PMU1, reg_val);

- if (AR_SREV_9561(ah))
+ if (AR_SREV_9561(ah) || AR_SREV_5502(ah))
REG_WRITE(ah, AR_PHY_PMU2, 0x10200000);
} else {
/* Internal regulator is ON. Write swreg register. */
@@ -4109,7 +4112,8 @@ static void ar9003_hw_xpa_timing_control_apply(struct ath_hw *ah, bool is2ghz)
!AR_SREV_9340(ah) &&
!AR_SREV_9580(ah) &&
!AR_SREV_9531(ah) &&
- !AR_SREV_9561(ah))
+ !AR_SREV_9561(ah) &&
+ !AR_SREV_5502(ah))
return;

xpa_ctl = ar9003_modal_header(ah, is2ghz)->txFrameToXpaOn;
@@ -4889,7 +4893,8 @@ static void ar9003_hw_power_control_override(struct ath_hw *ah,
}

tempslope:
- if (AR_SREV_9550(ah) || AR_SREV_9531(ah) || AR_SREV_9561(ah)) {
+ if (AR_SREV_9550(ah) || AR_SREV_9531(ah) || AR_SREV_9561(ah) ||
+ AR_SREV_5502(ah)) {
u8 txmask = (eep->baseEepHeader.txrxMask & 0xf0) >> 4;

/*
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
index b2d53b6c0..ff45abd14 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
@@ -138,12 +138,12 @@ static int ar9003_get_training_power_5g(struct ath_hw *ah)
static int ar9003_paprd_setup_single_table(struct ath_hw *ah)
{
struct ath_common *common = ath9k_hw_common(ah);
- static const u32 ctrl0[3] = {
+ const u32 ctrl0[3] = {
AR_PHY_PAPRD_CTRL0_B0,
AR_PHY_PAPRD_CTRL0_B1,
AR_PHY_PAPRD_CTRL0_B2
};
- static const u32 ctrl1[3] = {
+ const u32 ctrl1[3] = {
AR_PHY_PAPRD_CTRL1_B0,
AR_PHY_PAPRD_CTRL1_B1,
AR_PHY_PAPRD_CTRL1_B2
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.c b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
index dc0e5ea25..7cbe30bc4 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
@@ -157,9 +157,9 @@ static int ar9003_hw_set_channel(struct ath_hw *ah, struct ath9k_channel *chan)
freq = centers.synth_center;

if (freq < 4800) { /* 2 GHz, fractional mode */
- if (AR_SREV_9330(ah) || AR_SREV_9485(ah) ||
- AR_SREV_9531(ah) || AR_SREV_9550(ah) ||
- AR_SREV_9561(ah) || AR_SREV_9565(ah)) {
+ if (AR_SREV_9330(ah) || AR_SREV_9485(ah) || AR_SREV_9531(ah) ||
+ AR_SREV_9550(ah) || AR_SREV_9561(ah) || AR_SREV_5502(ah) ||
+ AR_SREV_9565(ah)) {
if (ah->is_clk_25mhz)
div = 75;
else
@@ -182,8 +182,8 @@ static int ar9003_hw_set_channel(struct ath_hw *ah, struct ath9k_channel *chan)
/* Set to 2G mode */
bMode = 1;
} else {
- if ((AR_SREV_9340(ah) || AR_SREV_9550(ah) ||
- AR_SREV_9531(ah) || AR_SREV_9561(ah)) &&
+ if ((AR_SREV_9340(ah) || AR_SREV_9550(ah) || AR_SREV_9531(ah) ||
+ AR_SREV_9561(ah) || AR_SREV_5502(ah)) &&
ah->is_clk_25mhz) {
channelSel = freq / 75;
chan_frac = ((freq % 75) * 0x20000) / 75;
@@ -250,7 +250,7 @@ static void ar9003_hw_spur_mitigate_mrc_cck(struct ath_hw *ah,
*/

if (AR_SREV_9485(ah) || AR_SREV_9340(ah) || AR_SREV_9330(ah) ||
- AR_SREV_9550(ah) || AR_SREV_9561(ah)) {
+ AR_SREV_9550(ah) || AR_SREV_9561(ah) || AR_SREV_5502(ah)) {
if (spur_fbin_ptr[0] == 0) /* No spur */
return;
max_spur_cnts = 5;
@@ -277,7 +277,7 @@ static void ar9003_hw_spur_mitigate_mrc_cck(struct ath_hw *ah,

negative = 0;
if (AR_SREV_9485(ah) || AR_SREV_9340(ah) || AR_SREV_9330(ah) ||
- AR_SREV_9550(ah) || AR_SREV_9561(ah))
+ AR_SREV_9550(ah) || AR_SREV_9561(ah) || AR_SREV_5502(ah))
cur_bb_spur = ath9k_hw_fbin2freq(spur_fbin_ptr[i],
IS_CHAN_2GHZ(chan));
else
@@ -619,7 +619,7 @@ static void ar9003_hw_set_channel_regs(struct ath_hw *ah,
/* Enable 11n HT, 20 MHz */
phymode = AR_PHY_GC_HT_EN | AR_PHY_GC_SHORT_GI_40 | enableDacFifo;

- if (!AR_SREV_9561(ah))
+ if (!(AR_SREV_9561(ah) || AR_SREV_5502(ah)))
phymode |= AR_PHY_GC_SINGLE_HT_LTF1;

/* Configure baseband for dynamic 20/40 operation */
@@ -724,7 +724,7 @@ static void ar9003_hw_override_ini(struct ath_hw *ah)
ah->enabled_cals &= ~TX_CL_CAL;

if (AR_SREV_9340(ah) || AR_SREV_9531(ah) || AR_SREV_9550(ah) ||
- AR_SREV_9561(ah)) {
+ AR_SREV_9561(ah) || AR_SREV_5502(ah)) {
if (ah->is_clk_25mhz) {
REG_WRITE(ah, AR_RTC_DERIVED_CLK, 0x17c << 1);
REG_WRITE(ah, AR_SLP32_MODE, 0x0010f3d7);
@@ -905,23 +905,25 @@ static int ar9003_hw_process_ini(struct ath_hw *ah,
}
}

- if (AR_SREV_9550(ah) || AR_SREV_9561(ah))
+ if (AR_SREV_9550(ah) || AR_SREV_9561(ah) || AR_SREV_5502(ah))
REG_WRITE_ARRAY(&ah->ini_modes_rx_gain_bounds, modesIndex,
regWrites);

- if (AR_SREV_9561(ah) && (ar9003_hw_get_rx_gain_idx(ah) == 0))
+ if ((AR_SREV_9561(ah) || AR_SREV_5502(ah)) &&
+ (ar9003_hw_get_rx_gain_idx(ah) == 0))
REG_WRITE_ARRAY(&ah->ini_modes_rxgain_xlna,
modesIndex, regWrites);
/*
* TXGAIN initvals.
*/
- if (AR_SREV_9550(ah) || AR_SREV_9531(ah) || AR_SREV_9561(ah)) {
+ if (AR_SREV_9550(ah) || AR_SREV_9531(ah) || AR_SREV_9561(ah) ||
+ AR_SREV_5502(ah)) {
int modes_txgain_index = 1;

if (AR_SREV_9550(ah))
modes_txgain_index = ar9550_hw_get_modes_txgain_index(ah, chan);

- if (AR_SREV_9561(ah))
+ if (AR_SREV_9561(ah) || AR_SREV_5502(ah))
modes_txgain_index =
ar9561_hw_get_modes_txgain_index(ah, chan);

@@ -1922,7 +1924,7 @@ void ar9003_hw_attach_phy_ops(struct ath_hw *ah)
{
struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah);
struct ath_hw_ops *ops = ath9k_hw_ops(ah);
- static const u32 ar9300_cca_regs[6] = {
+ const u32 ar9300_cca_regs[6] = {
AR_PHY_CCA_0,
AR_PHY_CCA_1,
AR_PHY_CCA_2,
@@ -1935,7 +1937,7 @@ void ar9003_hw_attach_phy_ops(struct ath_hw *ah)
priv_ops->spur_mitigate_freq = ar9003_hw_spur_mitigate;

if (AR_SREV_9340(ah) || AR_SREV_9550(ah) || AR_SREV_9531(ah) ||
- AR_SREV_9561(ah))
+ AR_SREV_9561(ah) || AR_SREV_5502(ah))
priv_ops->compute_pll_control = ar9003_hw_compute_pll_control_soc;
else
priv_ops->compute_pll_control = ar9003_hw_compute_pll_control;
@@ -2021,7 +2023,8 @@ bool ar9003_hw_bb_watchdog_check(struct ath_hw *ah)
case 0x04000b09:
return true;
case 0x04000409:
- if (AR_SREV_9340(ah) || AR_SREV_9531(ah) || AR_SREV_9561(ah))
+ if (AR_SREV_9340(ah) || AR_SREV_9531(ah) || AR_SREV_9561(ah) ||
+ AR_SREV_5502(ah))
return false;
else
return true;
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.h b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
index a171dbb29..4e258d70e 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.h
+++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
@@ -20,7 +20,7 @@
/*
* Channel Register Map
*/
-#define AR_CHAN_BASE 0x9800
+#define AR_CHAN_BASE (AR_SREV_5502(ah) ? 0x29800 : 0x9800)

#define AR_PHY_TIMING1 (AR_CHAN_BASE + 0x0)
#define AR_PHY_TIMING2 (AR_CHAN_BASE + 0x4)
@@ -214,7 +214,7 @@
/*
* MRC Register Map
*/
-#define AR_MRC_BASE 0x9c00
+#define AR_MRC_BASE (AR_SREV_5502(ah) ? 0x29c00 : 0x9c00)

#define AR_PHY_TIMING_3A (AR_MRC_BASE + 0x0)
#define AR_PHY_LDPC_CNTL1 (AR_MRC_BASE + 0x4)
@@ -255,12 +255,12 @@
/*
* BBB Register Map
*/
-#define AR_BBB_BASE 0x9d00
+#define AR_BBB_BASE (AR_SREV_5502(ah) ? 0x29d00 : 0x9d00)

/*
* AGC Register Map
*/
-#define AR_AGC_BASE 0x9e00
+#define AR_AGC_BASE (AR_SREV_5502(ah) ? 0x29e00 : 0x9e00)

#define AR_PHY_SETTLING (AR_AGC_BASE + 0x0)
#define AR_PHY_FORCEMAX_GAINS_0 (AR_AGC_BASE + 0x4)
@@ -448,14 +448,16 @@
/*
* SM Register Map
*/
-#define AR_SM_BASE 0xa200
+#define AR_SM_BASE (AR_SREV_5502(ah) ? 0x2a200 : 0xa200)

#define AR_PHY_D2_CHIP_ID (AR_SM_BASE + 0x0)
#define AR_PHY_GEN_CTRL (AR_SM_BASE + 0x4)
#define AR_PHY_MODE (AR_SM_BASE + 0x8)
#define AR_PHY_ACTIVE (AR_SM_BASE + 0xc)
-#define AR_PHY_SPUR_MASK_A (AR_SM_BASE + (AR_SREV_9561(ah) ? 0x18 : 0x20))
-#define AR_PHY_SPUR_MASK_B (AR_SM_BASE + (AR_SREV_9561(ah) ? 0x1c : 0x24))
+#define AR_PHY_SPUR_MASK_A \
+ (AR_SM_BASE + ((AR_SREV_9561(ah) || AR_SREV_5502(ah)) ? 0x18 : 0x20))
+#define AR_PHY_SPUR_MASK_B \
+ (AR_SM_BASE + ((AR_SREV_9561(ah) || AR_SREV_5502(ah)) ? 0x1c : 0x24))
#define AR_PHY_SPECTRAL_SCAN (AR_SM_BASE + 0x28)
#define AR_PHY_RADAR_BW_FILTER (AR_SM_BASE + 0x2c)
#define AR_PHY_SEARCH_START_DELAY (AR_SM_BASE + 0x30)
@@ -498,7 +500,8 @@
#define AR_PHY_SPUR_MASK_A_CF_PUNC_MASK_A 0x3FF
#define AR_PHY_SPUR_MASK_A_CF_PUNC_MASK_A_S 0

-#define AR_PHY_TEST (AR_SM_BASE + (AR_SREV_9561(ah) ? 0x15c : 0x160))
+#define AR_PHY_TEST \
+ (AR_SM_BASE + ((AR_SREV_9561(ah) || AR_SREV_5502(ah)) ? 0x15c : 0x160))

#define AR_PHY_TEST_BBB_OBS_SEL 0x780000
#define AR_PHY_TEST_BBB_OBS_SEL_S 19
@@ -509,7 +512,8 @@
#define AR_PHY_TEST_CHAIN_SEL 0xC0000000
#define AR_PHY_TEST_CHAIN_SEL_S 30

-#define AR_PHY_TEST_CTL_STATUS (AR_SM_BASE + (AR_SREV_9561(ah) ? 0x160 : 0x164))
+#define AR_PHY_TEST_CTL_STATUS \
+ (AR_SM_BASE + ((AR_SREV_9561(ah) || AR_SREV_5502(ah)) ? 0x160 : 0x164))
#define AR_PHY_TEST_CTL_TSTDAC_EN 0x1
#define AR_PHY_TEST_CTL_TSTDAC_EN_S 0
#define AR_PHY_TEST_CTL_TX_OBS_SEL 0x1C
@@ -523,23 +527,32 @@
#define AR_PHY_TEST_CTL_DEBUGPORT_SEL 0xe0000000
#define AR_PHY_TEST_CTL_DEBUGPORT_SEL_S 29

+#define AR_PHY_TSTDAC \
+ (AR_SM_BASE + ((AR_SREV_9561(ah) || AR_SREV_5502(ah)) ? 0x164 : 0x168))

-#define AR_PHY_TSTDAC (AR_SM_BASE + (AR_SREV_9561(ah) ? 0x164 : 0x168))
+#define AR_PHY_CHAN_STATUS \
+ (AR_SM_BASE + ((AR_SREV_9561(ah) || AR_SREV_5502(ah)) ? 0x168 : 0x16c))

-#define AR_PHY_CHAN_STATUS (AR_SM_BASE + (AR_SREV_9561(ah) ? 0x168 : 0x16c))
-
-#define AR_PHY_CHAN_INFO_MEMORY (AR_SM_BASE + (AR_SREV_9561(ah) ? 0x16c : 0x170))
+#define AR_PHY_CHAN_INFO_MEMORY \
+ (AR_SM_BASE + ((AR_SREV_9561(ah) || AR_SREV_5502(ah)) ? 0x16c : 0x170))
#define AR_PHY_CHAN_INFO_MEMORY_CHANINFOMEM_S2_READ 0x00000008
#define AR_PHY_CHAN_INFO_MEMORY_CHANINFOMEM_S2_READ_S 3

-#define AR_PHY_CHNINFO_NOISEPWR (AR_SM_BASE + (AR_SREV_9561(ah) ? 0x170 : 0x174))
-#define AR_PHY_CHNINFO_GAINDIFF (AR_SM_BASE + (AR_SREV_9561(ah) ? 0x174 : 0x178))
-#define AR_PHY_CHNINFO_FINETIM (AR_SM_BASE + (AR_SREV_9561(ah) ? 0x178 : 0x17c))
-#define AR_PHY_CHAN_INFO_GAIN_0 (AR_SM_BASE + (AR_SREV_9561(ah) ? 0x17c : 0x180))
-#define AR_PHY_SCRAMBLER_SEED (AR_SM_BASE + (AR_SREV_9561(ah) ? 0x184 : 0x190))
-#define AR_PHY_CCK_TX_CTRL (AR_SM_BASE + (AR_SREV_9561(ah) ? 0x188 : 0x194))
-
-#define AR_PHY_HEAVYCLIP_CTL (AR_SM_BASE + (AR_SREV_9561(ah) ? 0x198 : 0x1a4))
+#define AR_PHY_CHNINFO_NOISEPWR \
+ (AR_SM_BASE + ((AR_SREV_9561(ah) || AR_SREV_5502(ah)) ? 0x170 : 0x174))
+#define AR_PHY_CHNINFO_GAINDIFF \
+ (AR_SM_BASE + ((AR_SREV_9561(ah) || AR_SREV_5502(ah)) ? 0x174 : 0x178))
+#define AR_PHY_CHNINFO_FINETIM \
+ (AR_SM_BASE + ((AR_SREV_9561(ah) || AR_SREV_5502(ah)) ? 0x178 : 0x17c))
+#define AR_PHY_CHAN_INFO_GAIN_0 \
+ (AR_SM_BASE + ((AR_SREV_9561(ah) || AR_SREV_5502(ah)) ? 0x17c : 0x180))
+#define AR_PHY_SCRAMBLER_SEED \
+ (AR_SM_BASE + ((AR_SREV_9561(ah) || AR_SREV_5502(ah)) ? 0x184 : 0x190))
+#define AR_PHY_CCK_TX_CTRL \
+ (AR_SM_BASE + ((AR_SREV_9561(ah) || AR_SREV_5502(ah)) ? 0x188 : 0x194))
+
+#define AR_PHY_HEAVYCLIP_CTL \
+ (AR_SM_BASE + ((AR_SREV_9561(ah) || AR_SREV_5502(ah)) ? 0x198 : 0x1a4))
#define AR_PHY_HEAVYCLIP_20 (AR_SM_BASE + 0x1a8)
#define AR_PHY_HEAVYCLIP_40 (AR_SM_BASE + 0x1ac)
#define AR_PHY_HEAVYCLIP_1 (AR_SM_BASE + 0x19c)
@@ -722,6 +735,10 @@
#define AR_CH0_TOP2_XPABIASLVL (AR_SREV_9561(ah) ? 0x1e00 : 0xf000)
#define AR_CH0_TOP2_XPABIASLVL_S 12

+#define AR_CH0_TOP3 0x16288
+#define AR_CH0_TOP3_XPABIASLVL 0xf0000
+#define AR_CH0_TOP3_XPABIASLVL_S 16
+
#define AR_CH0_XTAL (AR_SREV_9300(ah) ? 0x16294 : \
((AR_SREV_9462(ah) || AR_SREV_9565(ah)) ? 0x16298 : \
(AR_SREV_9561(ah) ? 0x162c0 : 0x16290)))
@@ -730,13 +747,17 @@
#define AR_CH0_XTAL_CAPOUTDAC 0x00fe0000
#define AR_CH0_XTAL_CAPOUTDAC_S 17

-#define AR_PHY_PMU1 ((AR_SREV_9462(ah) || AR_SREV_9565(ah)) ? 0x16340 : \
- (AR_SREV_9561(ah) ? 0x16cc0 : 0x16c40))
+#define AR_PHY_PMU1 \
+ ((AR_SREV_9462(ah) || AR_SREV_9565(ah)) ? \
+ 0x16340 : \
+ ((AR_SREV_9561(ah) || AR_SREV_5502(ah)) ? 0x16cc0 : 0x16c40))
#define AR_PHY_PMU1_PWD 0x1
#define AR_PHY_PMU1_PWD_S 0

-#define AR_PHY_PMU2 ((AR_SREV_9462(ah) || AR_SREV_9565(ah)) ? 0x16344 : \
- (AR_SREV_9561(ah) ? 0x16cc4 : 0x16c44))
+#define AR_PHY_PMU2 \
+ ((AR_SREV_9462(ah) || AR_SREV_9565(ah)) ? \
+ 0x16344 : \
+ ((AR_SREV_9561(ah) || AR_SREV_5502(ah)) ? 0x16cc4 : 0x16c44))
#define AR_PHY_PMU2_PGM 0x00200000
#define AR_PHY_PMU2_PGM_S 21

@@ -925,7 +946,7 @@
/*
* Channel 1 Register Map
*/
-#define AR_CHAN1_BASE 0xa800
+#define AR_CHAN1_BASE (AR_SREV_5502(ah) ? 0x2a800 : 0xa800)

#define AR_PHY_EXT_CCA_1 (AR_CHAN1_BASE + 0x30)
#define AR_PHY_TX_PHASE_RAMP_1 (AR_CHAN1_BASE + 0xd0)
@@ -944,7 +965,7 @@
/*
* AGC 1 Register Map
*/
-#define AR_AGC1_BASE 0xae00
+#define AR_AGC1_BASE (AR_SREV_5502(ah) ? 0x2ae00 : 0xae00)

#define AR_PHY_FORCEMAX_GAINS_1 (AR_AGC1_BASE + 0x4)
#define AR_PHY_EXT_ATTEN_CTL_1 (AR_AGC1_BASE + 0x18)
@@ -963,7 +984,7 @@
/*
* SM 1 Register Map
*/
-#define AR_SM1_BASE 0xb200
+#define AR_SM1_BASE (AR_SREV_5502(ah) ? 0x2b200 : 0xb200)

#define AR_PHY_SWITCH_CHAIN_1 (AR_SM1_BASE + 0x84)
#define AR_PHY_FCAL_2_1 (AR_SM1_BASE + 0xd0)
@@ -989,7 +1010,7 @@
/*
* Channel 2 Register Map
*/
-#define AR_CHAN2_BASE 0xb800
+#define AR_CHAN2_BASE (AR_SREV_5502(ah) ? 0x2b800 : 0xb800)

#define AR_PHY_EXT_CCA_2 (AR_CHAN2_BASE + 0x30)
#define AR_PHY_TX_PHASE_RAMP_2 (AR_CHAN2_BASE + 0xd0)
@@ -1007,7 +1028,7 @@
/*
* AGC 2 Register Map
*/
-#define AR_AGC2_BASE 0xbe00
+#define AR_AGC2_BASE (AR_SREV_5502(ah) ? 0x2be00 : 0xbe00)

#define AR_PHY_FORCEMAX_GAINS_2 (AR_AGC2_BASE + 0x4)
#define AR_PHY_EXT_ATTEN_CTL_2 (AR_AGC2_BASE + 0x18)
@@ -1024,7 +1045,7 @@
/*
* SM 2 Register Map
*/
-#define AR_SM2_BASE 0xc200
+#define AR_SM2_BASE (AR_SREV_5502(ah) ? 0x2c200 : 0xc200)

#define AR_PHY_SWITCH_CHAIN_2 (AR_SM2_BASE + 0x84)
#define AR_PHY_FCAL_2_2 (AR_SM2_BASE + 0xd0)
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 047512ce1..c32b201a3 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -834,7 +834,7 @@ static void ath9k_hw_init_pll(struct ath_hw *ah,
REG_RMW_FIELD(ah, AR_CH0_BB_DPLL3,
AR_CH0_BB_DPLL3_PHASE_SHIFT, 0x1);
} else if (AR_SREV_9340(ah) || AR_SREV_9550(ah) || AR_SREV_9531(ah) ||
- AR_SREV_9561(ah)) {
+ AR_SREV_9561(ah) || AR_SREV_5502(ah)) {
u32 regval, pll2_divint, pll2_divfrac, refdiv;

REG_WRITE(ah, AR_RTC_PLL_CONTROL,
@@ -845,7 +845,8 @@ static void ath9k_hw_init_pll(struct ath_hw *ah,
udelay(100);

if (ah->is_clk_25mhz) {
- if (AR_SREV_9531(ah) || AR_SREV_9561(ah)) {
+ if (AR_SREV_9531(ah) || AR_SREV_9561(ah) ||
+ AR_SREV_5502(ah)) {
pll2_divint = 0x1c;
pll2_divfrac = 0xa3d2;
refdiv = 1;
@@ -861,15 +862,16 @@ static void ath9k_hw_init_pll(struct ath_hw *ah,
refdiv = 5;
} else {
pll2_divint = 0x11;
- pll2_divfrac = (AR_SREV_9531(ah) ||
- AR_SREV_9561(ah)) ?
+ pll2_divfrac =
+ (AR_SREV_9531(ah) || AR_SREV_9561(ah) ||
+ AR_SREV_5502(ah)) ?
0x26665 : 0x26666;
refdiv = 1;
}
}

regval = REG_READ(ah, AR_PHY_PLL_MODE);
- if (AR_SREV_9531(ah) || AR_SREV_9561(ah))
+ if (AR_SREV_9531(ah) || AR_SREV_9561(ah) || AR_SREV_5502(ah))
regval |= (0x1 << 22);
else
regval |= (0x1 << 16);
@@ -887,7 +889,8 @@ static void ath9k_hw_init_pll(struct ath_hw *ah,
(0x1 << 13) |
(0x4 << 26) |
(0x18 << 19);
- else if (AR_SREV_9531(ah) || AR_SREV_9561(ah)) {
+ else if (AR_SREV_9531(ah) || AR_SREV_9561(ah) ||
+ AR_SREV_5502(ah)) {
regval = (regval & 0x01c00fff) |
(0x1 << 31) |
(0x2 << 29) |
@@ -904,7 +907,7 @@ static void ath9k_hw_init_pll(struct ath_hw *ah,
(0x60 << 19);
REG_WRITE(ah, AR_PHY_PLL_MODE, regval);

- if (AR_SREV_9531(ah) || AR_SREV_9561(ah))
+ if (AR_SREV_9531(ah) || AR_SREV_9561(ah) || AR_SREV_5502(ah))
REG_WRITE(ah, AR_PHY_PLL_MODE,
REG_READ(ah, AR_PHY_PLL_MODE) & 0xffbfffff);
else
@@ -945,7 +948,7 @@ static void ath9k_hw_init_interrupt_masks(struct ath_hw *ah,
u32 msi_cfg = 0;

if (AR_SREV_9340(ah) || AR_SREV_9550(ah) || AR_SREV_9531(ah) ||
- AR_SREV_9561(ah))
+ AR_SREV_9561(ah) || AR_SREV_5502(ah))
sync_default &= ~AR_INTR_SYNC_HOST1_FATAL;

if (AR_SREV_9300_20_OR_LATER(ah)) {
@@ -1777,7 +1780,7 @@ static void ath9k_hw_init_desc(struct ath_hw *ah)
#ifdef __BIG_ENDIAN
else if (AR_SREV_9330(ah) || AR_SREV_9340(ah) ||
AR_SREV_9550(ah) || AR_SREV_9531(ah) ||
- AR_SREV_9561(ah))
+ AR_SREV_9561(ah) || AR_SREV_5502(ah))
REG_RMW(ah, AR_CFG, AR_CFG_SWRB | AR_CFG_SWTB, 0);
else
REG_WRITE(ah, AR_CFG, AR_CFG_SWTD | AR_CFG_SWRD);
@@ -2474,6 +2477,9 @@ static void ath9k_gpio_cap_init(struct ath_hw *ah)
} else if (AR_SREV_9561(ah)) {
pCap->num_gpio_pins = AR9561_NUM_GPIO;
pCap->gpio_mask = AR9561_GPIO_MASK;
+ } else if (AR_SREV_5502(ah)) {
+ pCap->num_gpio_pins = AR5502_NUM_GPIO;
+ pCap->gpio_mask = AR5502_GPIO_MASK;
} else if (AR_SREV_9565(ah)) {
pCap->num_gpio_pins = AR9565_NUM_GPIO;
pCap->gpio_mask = AR9565_GPIO_MASK;
@@ -2610,7 +2616,7 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah)
if (AR_SREV_9300_20_OR_LATER(ah)) {
pCap->hw_caps |= ATH9K_HW_CAP_EDMA | ATH9K_HW_CAP_FASTCLOCK;
if (!AR_SREV_9330(ah) && !AR_SREV_9485(ah) &&
- !AR_SREV_9561(ah) && !AR_SREV_9565(ah))
+ !AR_SREV_9561(ah) && !AR_SREV_5502(ah) && !AR_SREV_9565(ah))
pCap->hw_caps |= ATH9K_HW_CAP_LDPC;

pCap->rx_hp_qdepth = ATH9K_HW_RX_HP_QDEPTH;
@@ -2627,7 +2633,7 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah)
if (AR_SREV_9300_20_OR_LATER(ah))
pCap->hw_caps |= ATH9K_HW_CAP_RAC_SUPPORTED;

- if (AR_SREV_9561(ah))
+ if (AR_SREV_9561(ah) || AR_SREV_5502(ah))
ah->ent_mode = 0x3BDA000;
else if (AR_SREV_9300_20_OR_LATER(ah))
ah->ent_mode = REG_READ(ah, AR_ENT_OTP);
diff --git a/drivers/net/wireless/ath/ath9k/mac.c b/drivers/net/wireless/ath/ath9k/mac.c
index 58d02c19b..08f91f558 100644
--- a/drivers/net/wireless/ath/ath9k/mac.c
+++ b/drivers/net/wireless/ath/ath9k/mac.c
@@ -813,7 +813,7 @@ static void __ath9k_hw_enable_interrupts(struct ath_hw *ah)
u32 async_mask;

if (AR_SREV_9340(ah) || AR_SREV_9550(ah) || AR_SREV_9531(ah) ||
- AR_SREV_9561(ah))
+ AR_SREV_9561(ah) || AR_SREV_5502(ah))
sync_default &= ~AR_INTR_SYNC_HOST1_FATAL;

async_mask = AR_INTR_MAC_IRQ;
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index 0c0624a3b..3299aef65 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -422,7 +422,7 @@ u32 ath_calcrxfilter(struct ath_softc *sc)
}

if (AR_SREV_9550(sc->sc_ah) || AR_SREV_9531(sc->sc_ah) ||
- AR_SREV_9561(sc->sc_ah))
+ AR_SREV_9561(sc->sc_ah) || AR_SREV_5502(sc->sc_ah))
rfilt |= ATH9K_RX_FILTER_4ADDRESS;

if (AR_SREV_9462(sc->sc_ah) || AR_SREV_9565(sc->sc_ah))
diff --git a/drivers/net/wireless/ath/ath9k/reg.h b/drivers/net/wireless/ath/ath9k/reg.h
index 5a07cf7d8..d465167ac 100644
--- a/drivers/net/wireless/ath/ath9k/reg.h
+++ b/drivers/net/wireless/ath/ath9k/reg.h
@@ -1138,6 +1138,7 @@ enum {
#define AR9531_NUM_GPIO 18
#define AR9550_NUM_GPIO 24
#define AR9561_NUM_GPIO 23
+#define AR5502_NUM_GPIO 20
#define AR9565_NUM_GPIO 14
#define AR9580_NUM_GPIO 16
#define AR7010_NUM_GPIO 16
@@ -1155,6 +1156,7 @@ enum {
#define AR9531_GPIO_MASK 0x0000000F
#define AR9550_GPIO_MASK 0x0000000F
#define AR9561_GPIO_MASK 0x0000000F
+#define AR5502_GPIO_MASK 0x0000000F
#define AR9565_GPIO_MASK 0x00003FFF
#define AR9580_GPIO_MASK 0x0000F4FF
#define AR7010_GPIO_MASK 0x0000FFFF
@@ -2114,7 +2116,7 @@ enum {
* pcu_txsm.
*/

-#define AR9300_SM_BASE 0xa200
+#define AR9300_SM_BASE (AR_SREV_5502(ah) ? 0x2a200 : 0xa200)
#define AR9002_PHY_AGC_CONTROL 0x9860
#define AR9003_PHY_AGC_CONTROL AR9300_SM_BASE + 0xc4
#define AR_PHY_AGC_CONTROL (AR_SREV_9300_20_OR_LATER(ah) ? AR9003_PHY_AGC_CONTROL : AR9002_PHY_AGC_CONTROL)
diff --git a/drivers/net/wireless/ath/ath9k/reg_aic.h b/drivers/net/wireless/ath/ath9k/reg_aic.h
index 955147ab4..abd0370e0 100644
--- a/drivers/net/wireless/ath/ath9k/reg_aic.h
+++ b/drivers/net/wireless/ath/ath9k/reg_aic.h
@@ -17,9 +17,9 @@
#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_SM_BASE (AR_SREV_5502(ah) ? 0x2a200 : 0xa200)
+#define AR_SM1_BASE (AR_SREV_5502(ah) ? 0x2b200 : 0xb200)
+#define AR_AGC_BASE (AR_SREV_5502(ah) ? 0x29e00 : 0x9e00)

#define AR_PHY_AIC_CTRL_0_B0 (AR_SM_BASE + 0x4b0)
#define AR_PHY_AIC_CTRL_1_B0 (AR_SM_BASE + 0x4b4)
--
2.25.1

2022-04-20 17:21:08

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH 2/9] ath9k: basic support for QCN550x

Wenli Looi <[email protected]> writes:

> QCN550x is very similar to QCA956x. Note that AR_CH0_XTAL is
> intentionally unchanged. Certain arrays are no longer static because
> they are no longer constant.

s-o-b missing in patches 2-5.

--
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

2022-05-10 20:11:45

by Wenli Looi

[permalink] [raw]
Subject: Re: [PATCH 0/9] ath9k: add support for QCN550x

Thanks Kalle for the comments.

Please let me know if I should resend the patch with the minor changes
or if there are additional comments.

It would probably be ideal if this patch could be reviewed by someone
who is familiar with this device and could provide official initvals
like described here:

https://wireless.wiki.kernel.org/en/users/drivers/ath9k/initvals-tool#synch_initvals_from_the_atheros_hal

I would be happy to test other initvals on my device. The hacked
QCA956x initvals do appear to work stably for me though so this could
be done later.

2022-05-11 06:46:57

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH 0/9] ath9k: add support for QCN550x

Wenli Looi <[email protected]> writes:

> Thanks Kalle for the comments.
>
> Please let me know if I should resend the patch with the minor changes
> or if there are additional comments.

The patchset is set to 'Changes Requested' in patchwork:

https://patchwork.kernel.org/project/linux-wireless/list/?series=632942&state=*&order=date

This means you need to submit v2.

--
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

2022-05-11 11:28:18

by Toke Høiland-Jørgensen

[permalink] [raw]
Subject: Re: [PATCH 0/9] ath9k: add support for QCN550x

Kalle Valo <[email protected]> writes:

> Wenli Looi <[email protected]> writes:
>
>> Thanks Kalle for the comments.
>>
>> Please let me know if I should resend the patch with the minor changes
>> or if there are additional comments.
>
> The patchset is set to 'Changes Requested' in patchwork:
>
> https://patchwork.kernel.org/project/linux-wireless/list/?series=632942&state=*&order=date
>
> This means you need to submit v2.

Yes, please resubmit with Kalle's comments addressed :)

-Toke