ath9k_hw: make support for PC-OEM cards optional
PATCH 1/10 ath9k_hw: make support for PC-OEM cards optional
The initvals use up quite a bit of space, and PC-OEM support is typically not needed on embedded systems
--- drivers/net/wireless/ath/ath9k/Kconfig | 5 ++++ drivers/net/wireless/ath/ath9k/Makefile | 3 ++- drivers/net/wireless/ath/ath9k/ar9003_rtt.h | 36 +++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath9k/hw.h | 17 ++++++++++---- drivers/net/wireless/ath/ath9k/init.c | 3 +++ drivers/net/wireless/ath/ath9k/pci.c | 6 +++++ drivers/net/wireless/ath/ath9k/reg.h | 33 +++++++++++++++----------- 7 files changed, 84 insertions(+), 19 deletions(-)
drivers/net/wireless/ath/ath9k/Kconfig +5 -0
@@ -148,6 +148,11 @@ config ATH9K_CHANNEL_CONTEXT for multi-channel concurrency. Enable this if P2P PowerSave support is required. +config ATH9K_PCOEM + bool "Atheros ath9k support for PC OEM cards" if EXPERT + depends on ATH9K + default y + config ATH9K_HTC tristate "Atheros HTC based wireless cards support" depends on USB && MAC80211
drivers/net/wireless/ath/ath9k/Makefile +2 -1
@@ -32,7 +32,6 @@ ath9k_hw-y:= \ ar5008_phy.o \ ar9002_calib.o \ ar9003_calib.o \ - ar9003_rtt.o \ calib.o \ eeprom.o \ eeprom_def.o \
@@ -50,6 +49,8 @@ ath9k_hw-$(CONFIG_ATH9K_WOW) += ar9003_wow.o ath9k_hw-$(CONFIG_ATH9K_BTCOEX_SUPPORT) += btcoex.o \ ar9003_mci.o +ath9k_hw-$(CONFIG_ATH9K_PCOEM) += ar9003_rtt.o + ath9k_hw-$(CONFIG_ATH9K_DYNACK) += dynack.o obj-$(CONFIG_ATH9K_HW) += ath9k_hw.o
drivers/net/wireless/ath/ath9k/ar9003_rtt.h +36 -0
@@ -17,6 +17,7 @@#ifndef AR9003_RTT_H #define AR9003_RTT_H +#ifdef CONFIG_ATH9K_PCOEM void ar9003_hw_rtt_enable (struct ath_hw *ah);void ar9003_hw_rtt_disable (struct ath_hw *ah);void ar9003_hw_rtt_set_mask (struct ath_hw *ah,u32 rtt_mask);
@@ -25,5 +26,40 @@ void ar9003_hw_rtt_load_hist(struct ath_hw *ah);void ar9003_hw_rtt_fill_hist (struct ath_hw *ah);void ar9003_hw_rtt_clear_hist (struct ath_hw *ah);bool ar9003_hw_rtt_restore (struct ath_hw *ah,struct ath9k_channel *chan); +#else +static inline void ar9003_hw_rtt_enable (struct ath_hw *ah) +{ +} + +static inline void ar9003_hw_rtt_disable (struct ath_hw *ah) +{ +} + +static inline void ar9003_hw_rtt_set_mask (struct ath_hw *ah,u32 rtt_mask) +{ +} + +static inline bool ar9003_hw_rtt_force_restore (struct ath_hw *ah) +{ +return false; +} + +static inline void ar9003_hw_rtt_load_hist (struct ath_hw *ah) +{ +} + +static inline void ar9003_hw_rtt_fill_hist (struct ath_hw *ah) +{ +} + +static inline void ar9003_hw_rtt_clear_hist (struct ath_hw *ah) +{ +} + +static inline bool ar9003_hw_rtt_restore (struct ath_hw *ah,struct ath9k_channel *chan) +{ +return false; +} +#endif #endif
drivers/net/wireless/ath/ath9k/hw.h +12 -5
@@ -244,13 +244,20 @@ enum ath9k_hw_caps {ATH9K_HW_CAP_2GHZ =BIT (11 ),ATH9K_HW_CAP_5GHZ =BIT (12 ),ATH9K_HW_CAP_APM =BIT (13 ), +#ifdef CONFIG_ATH9K_PCOEMATH9K_HW_CAP_RTT =BIT (14 ),ATH9K_HW_CAP_MCI =BIT (15 ), -ATH9K_HW_CAP_DFS =BIT (16 ), -ATH9K_HW_WOW_DEVICE_CAPABLE =BIT (17 ), -ATH9K_HW_CAP_PAPRD =BIT (18 ), -ATH9K_HW_CAP_FCC_BAND_SWITCH =BIT (19 ), - ATH9K_HW_CAP_BT_ANT_DIV = BIT(20), +ATH9K_HW_WOW_DEVICE_CAPABLE =BIT (16 ), +ATH9K_HW_CAP_BT_ANT_DIV =BIT (17 ), +#else +ATH9K_HW_CAP_RTT =0 , +ATH9K_HW_CAP_MCI =0 , +ATH9K_HW_WOW_DEVICE_CAPABLE =0 , +ATH9K_HW_CAP_BT_ANT_DIV =0 , +#endif +ATH9K_HW_CAP_DFS =BIT (18 ), +ATH9K_HW_CAP_PAPRD =BIT (19 ), + ATH9K_HW_CAP_FCC_BAND_SWITCH = BIT(20), };/*
drivers/net/wireless/ath/ath9k/init.c +3 -0
@@ -362,6 +362,9 @@ static void ath9k_init_pcoem_platform(struct ath_softc *sc)struct ath9k_hw_capabilities *pCap = &ah->caps;struct ath_common *common =ath9k_hw_common (ah); +if (!IS_ENABLED (CONFIG_ATH9K_PCOEM )) +return ; +if (common->bus_ops->ath_bus_type !=ATH_PCI )return ;
drivers/net/wireless/ath/ath9k/pci.c +6 -0
@@ -30,6 +30,7 @@ static const struct pci_device_id ath_pci_id_table[] = { { PCI_VDEVICE(ATHEROS, 0x0029) }, /* PCI */ { PCI_VDEVICE(ATHEROS, 0x002A) }, /* PCI-E */ +#ifdef CONFIG_ATH9K_PCOEM { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, 0x002A, PCI_VENDOR_ID_AZWAVE,
@@ -82,6 +83,7 @@ static const struct pci_device_id ath_pci_id_table[] = { PCI_VENDOR_ID_AZWAVE, 0x2C37), .driver_data = ATH9K_PCI_BT_ANT_DIV }, +#endif { PCI_VDEVICE(ATHEROS, 0x002B) }, /* PCI-E */ { PCI_VDEVICE(ATHEROS, 0x002C) }, /* PCI-E 802.11n bonded out */
@@ -102,6 +104,7 @@ static const struct pci_device_id ath_pci_id_table[] = { { PCI_VDEVICE(ATHEROS, 0x0030) }, /* PCI-E AR9300 */ +#ifdef CONFIG_ATH9K_PCOEM /* PCI-E CUS198 */ { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, 0x0032,
@@ -294,10 +297,12 @@ static const struct pci_device_id ath_pci_id_table[] = { PCI_VENDOR_ID_ASUSTEK, 0x850D), .driver_data = ATH9K_PCI_NO_PLL_PWRSAVE }, +#endif { PCI_VDEVICE(ATHEROS, 0x0032) }, /* PCI-E AR9485 */ { PCI_VDEVICE(ATHEROS, 0x0033) }, /* PCI-E AR9580 */ +#ifdef CONFIG_ATH9K_PCOEM /* PCI-E CUS217 */ { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, 0x0034,
@@ -657,6 +662,7 @@ static const struct pci_device_id ath_pci_id_table[] = { /* PCI-E AR9565 (WB335) */ { PCI_VDEVICE(ATHEROS, 0x0036), .driver_data = ATH9K_PCI_BT_ANT_DIV }, +#endif { 0 } };
drivers/net/wireless/ath/ath9k/reg.h +20 -13
@@ -892,10 +892,21 @@ (AR_SREV_9330 ((_ah)) && \ ((_ah)->hw_version.macRev == AR_SREV_REVISION_9330_12)) +#ifdef CONFIG_ATH9K_PCOEM +#define AR_SREV_9462 (_ah) \ + (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9462))#define AR_SREV_9485 (_ah) \ (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9485)) +#define AR_SREV_9565 (_ah) \ + (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9565)) +#else +#define AR_SREV_9462 (_ah) 0 +#define AR_SREV_9485 (_ah) 0 +#define AR_SREV_9565 (_ah) 0 +#endif +#define AR_SREV_9485_11_OR_LATER (_ah) \ - (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9485) && \ + (AR_SREV_9485(_ah) && \ ((_ah)->hw_version.macRev >= AR_SREV_REVISION_9485_11))#define AR_SREV_9485_OR_LATER (_ah) \ (((_ah)->hw_version.macVersion >= AR_SREV_VERSION_9485))
@@ -915,34 +926,30 @@ (AR_SREV_9285_12_OR_LATER (_ah) && \ ((REG_READ(_ah, AR_AN_SYNTH9) & 0x7) == 0x1)) -#define AR_SREV_9462 (_ah) \ - (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9462))#define AR_SREV_9462_20 (_ah) \ - (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9462) && \ + (AR_SREV_9462(_ah) && \ ((_ah)->hw_version.macRev == AR_SREV_REVISION_9462_20))#define AR_SREV_9462_21 (_ah) \ - (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9462) && \ + (AR_SREV_9462(_ah) && \ ((_ah)->hw_version.macRev == AR_SREV_REVISION_9462_21))#define AR_SREV_9462_20_OR_LATER (_ah) \ - (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9462) && \ + (AR_SREV_9462(_ah) && \ ((_ah)->hw_version.macRev >= AR_SREV_REVISION_9462_20))#define AR_SREV_9462_21_OR_LATER (_ah) \ - (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9462) && \ + (AR_SREV_9462(_ah) && \ ((_ah)->hw_version.macRev >= AR_SREV_REVISION_9462_21)) -#define AR_SREV_9565 (_ah) \ - (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9565))#define AR_SREV_9565_10 (_ah) \ - (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9565) && \ + (AR_SREV_9565(_ah) && \ ((_ah)->hw_version.macRev == AR_SREV_REVISION_9565_10))#define AR_SREV_9565_101 (_ah) \ - (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9565) && \ + (AR_SREV_9565(_ah) && \ ((_ah)->hw_version.macRev == AR_SREV_REVISION_9565_101))#define AR_SREV_9565_11 (_ah) \ - (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9565) && \ + (AR_SREV_9565(_ah) && \ ((_ah)->hw_version.macRev == AR_SREV_REVISION_9565_11))#define AR_SREV_9565_11_OR_LATER (_ah) \ - (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9565) && \ + (AR_SREV_9565(_ah) && \ ((_ah)->hw_version.macRev >= AR_SREV_REVISION_9565_11))#define AR_SREV_9550 (_ah) \
Signature · 1 line
2.0.4
PATCH 2/10 ath9k_hw: remove support for UB124 tx gain table
UB124 is a USB based reference design not supported by ath9k or ath9k_htc.
--- drivers/net/wireless/ath/ath9k/ar9003_hw.c | 3 --- 1 file changed, 3 deletions(-)
drivers/net/wireless/ath/ath9k/ar9003_hw.c +0 -3
@@ -670,9 +670,6 @@ static void ar9003_tx_gain_table_mode5(struct ath_hw *ah)if (AR_SREV_9485_11_OR_LATER (ah))INIT_INI_ARRAY (&ah->iniModesTxGain, ar9485Modes_green_ob_db_tx_gain_1_1); -else if (AR_SREV_9340 (ah)) -INIT_INI_ARRAY (&ah->iniModesTxGain, - ar9340Modes_ub124_tx_gain_table_1p0);else if (AR_SREV_9580 (ah))INIT_INI_ARRAY (&ah->iniModesTxGain, ar9580_1p0_type5_tx_gain_table);
Signature · 1 line
2.0.4
Re: [PATCH 02/10] ath9k_hw: remove support for UB124 tx gain table
drivers/net/wireless/ath/ath9k/ar9003_hw.c static void ar9003_tx_gain_table_mode5(struct ath_hw *ah) · line 675
Quoted 3 lines · Felix Fietkau
drivers/net/wireless/ath/ath9k/ar9003_hw.c +0
-3-else if (AR_SREV_9340 (ah)) -INIT_INI_ARRAY (&ah->iniModesTxGain, - ar9340Modes_ub124_tx_gain_table_1p0);
Shouldn't the array in ar9340_initvals.h also be removed ?
Sujith
Re: [PATCH 02/10] ath9k_hw: remove support for UB124 tx gain table
Quoted 6 lines · Sujith Manoharan
drivers/net/wireless/ath/ath9k/ar9003_hw.c static void ar9003_tx_gain_table_mode5(struct ath_hw *ah) · line 675
Quoted 3 lines · Felix Fietkau
drivers/net/wireless/ath/ath9k/ar9003_hw.c +0
-3-else if (AR_SREV_9340 (ah)) -INIT_INI_ARRAY (&ah->iniModesTxGain, - ar9340Modes_ub124_tx_gain_table_1p0);Shouldn't the array in
ar9340_initvals.halso be removed ?
We can do that later (when we change the qca-swiss-army-knife code). As long as it isn't referenced, the compiler will not emit the data into object files.
- Felix
PATCH 3/10 ath9k: fix processing RXORN interrupts
In reply to Felix FietkauThe "goto chip_reset" is a bit misleading, because it does not actually issue a chip reset. Instead it is bypassing processing of other interrupts and assumes that the tasklet will issue a chip reset.
In the case of RXORN this does not happen, so bypassing processing of other interrupts will simply allow them to fire again. Even if RXORN was triggering a reset, it is not critical enough to need the bypass here.
--- drivers/net/wireless/ath/ath9k/main.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath9k/main.c +3 -4
@@ -539,11 +539,10 @@ irqreturn_t ath_isr(int irq, void *dev) sched = true;/* -* If a FATAL or RXORN interrupt is received, we have to reset the -* chip immediately. +* If a FATAL interrupt is received, we have to reset the chip +* immediately. */ -if ((status &ATH9K_INT_FATAL ) || ((status &ATH9K_INT_RXORN ) && - !(ah->caps.hw_caps &ATH9K_HW_CAP_EDMA ))) +if (status &ATH9K_INT_FATAL ) goto chip_reset; if ((ah->config.hw_hang_checks & HW_BB_WATCHDOG) &&
Signature · 1 line
2.0.4
Re: [PATCH 03/10] ath9k: fix processing RXORN interrupts
Quoted 3 lines · Felix Fietkau
The "goto
chip_reset" is a bit misleading, because it does not actually issue a chip reset. Instead it is bypassing processing of other interrupts and assumes that the tasklet will issue a chip reset.
Well, we kill interrupts and the tasklet sets ATH_OP_HW_RESET, so no more interrupts will be processed in ath_isr(), so this is a fair assumption.
Quoted 4 lines
In the case of RXORN this does not happen, so bypassing processing of other interrupts will simply allow them to fire again. Even if RXORN was triggering a reset, it is not critical enough to need the bypass here.
Wouldn't this be fixed by just processing RXORN in the tasklet, along with FATAL ? Or are you saying that RXORN doesn't need a chip reset in both edma/legacy, since the edma check has been dropped ?
Sujith
Re: [PATCH 03/10] ath9k: fix processing RXORN interrupts
Quoted 8 lines · Sujith Manoharan
Quoted 3 lines · Felix Fietkau
The "goto
chip_reset" is a bit misleading, because it does not actually issue a chip reset. Instead it is bypassing processing of other interrupts and assumes that the tasklet will issue a chip reset.Well, we kill interrupts and the tasklet sets
ATH_OP_HW_RESET, so no more interrupts will be processed inath_isr(), so this is a fair assumption.
Except it only does that for FATAL, not RXORN.
Quoted 8 lines
Quoted 4 lines
In the case of RXORN this does not happen, so bypassing processing of other interrupts will simply allow them to fire again. Even if RXORN was triggering a reset, it is not critical enough to need the bypass here.
Wouldn't this be fixed by just processing RXORN in the tasklet, along with FATAL ? Or are you saying that RXORN doesn't need a chip reset in both edma/legacy, since the edma check has been dropped ?
I'm not sure if we should actually do the chip reset for RXORN, but even if we should, we don't need this 'goto chip_reset' in ath_isr.
- Felix
PATCH 4/10 ath9k: clean up debugfs print of reset causes
In reply to Felix FietkauReduce code duplication
--- drivers/net/wireless/ath/ath9k/debug.c | 48 +++++++++++++++------------------- 1 file changed, 21 insertions(+), 27 deletions(-)
drivers/net/wireless/ath/ath9k/debug.c +21 -27
@@ -852,36 +852,30 @@ static ssize_t read_file_reset(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { struct ath_softc *sc = file->private_data; +static const char *const reset_cause[__RESET_TYPE_MAX] = { + [RESET_TYPE_BB_HANG ] ="Baseband Hang" , + [RESET_TYPE_BB_WATCHDOG ] ="Baseband Watchdog" , + [RESET_TYPE_FATAL_INT ] ="Fatal HW Error" , + [RESET_TYPE_TX_ERROR ] ="TX HW error" , + [RESET_TYPE_TX_GTT ] ="Transmit timeout" , + [RESET_TYPE_TX_HANG ] ="TX Path Hang" , + [RESET_TYPE_PLL_HANG ] ="PLL RX Hang" , + [RESET_TYPE_MAC_HANG ] ="MAC Hang" , + [RESET_TYPE_BEACON_STUCK ] ="Stuck Beacon" , + [RESET_TYPE_MCI ] ="MCI Reset" , + };char buf[512 ];unsigned int len =0 ; +int i; - len +=scnprintf (buf + len,sizeof (buf) - len, -"%17s: %2d\n" ,"Baseband Hang" , - sc->debug.stats.reset[RESET_TYPE_BB_HANG ]); - len +=scnprintf (buf + len,sizeof (buf) - len, -"%17s: %2d\n" ,"Baseband Watchdog" , - sc->debug.stats.reset[RESET_TYPE_BB_WATCHDOG ]); - len +=scnprintf (buf + len,sizeof (buf) - len, -"%17s: %2d\n" ,"Fatal HW Error" , - sc->debug.stats.reset[RESET_TYPE_FATAL_INT ]); - len +=scnprintf (buf + len,sizeof (buf) - len, -"%17s: %2d\n" ,"TX HW error" , - sc->debug.stats.reset[RESET_TYPE_TX_ERROR ]); - len +=scnprintf (buf + len,sizeof (buf) - len, -"%17s: %2d\n" ,"TX Path Hang" , - sc->debug.stats.reset[RESET_TYPE_TX_HANG ]); - len +=scnprintf (buf + len,sizeof (buf) - len, -"%17s: %2d\n" ,"PLL RX Hang" , - sc->debug.stats.reset[RESET_TYPE_PLL_HANG ]); - len +=scnprintf (buf + len,sizeof (buf) - len, -"%17s: %2d\n" ,"MAC Hang" , - sc->debug.stats.reset[RESET_TYPE_MAC_HANG ]); - len +=scnprintf (buf + len,sizeof (buf) - len, -"%17s: %2d\n" ,"Stuck Beacon" , - sc->debug.stats.reset[RESET_TYPE_BEACON_STUCK ]); - len +=scnprintf (buf + len,sizeof (buf) - len, -"%17s: %2d\n" ,"MCI Reset" , - sc->debug.stats.reset[RESET_TYPE_MCI ]); +for (i =0 ; i <ARRAY_SIZE (reset_cause); i++) { +if (!reset_cause[i]) +continue ; + + len +=scnprintf (buf + len,sizeof (buf) - len, +"%17s: %2d\n" , reset_cause[i], + sc->debug.stats.reset[i]); + }if (len >sizeof (buf)) len =sizeof (buf);
Signature · 1 line
2.0.4
PATCH 5/10 ath9k: restart hardware after noise floor calibration failure
In reply to Felix FietkauWhen NF calibration fails, the radio often becomes deaf. The usual hardware hang checks do not detect this, so it's better to issue a reset when that happens.
--- drivers/net/wireless/ath/ath9k/ar9002_calib.c | 11 ++++++----- drivers/net/wireless/ath/ath9k/ar9003_calib.c | 11 ++++++----- drivers/net/wireless/ath/ath9k/calib.c | 6 ++++-- drivers/net/wireless/ath/ath9k/calib.h | 2 +- drivers/net/wireless/ath/ath9k/debug.c | 1 + drivers/net/wireless/ath/ath9k/debug.h | 1 + drivers/net/wireless/ath/ath9k/hw-ops.h | 7 +++---- drivers/net/wireless/ath/ath9k/hw.h | 6 ++---- drivers/net/wireless/ath/ath9k/link.c | 11 ++++++++--- 9 files changed, 32 insertions(+), 24 deletions(-)
drivers/net/wireless/ath/ath9k/ar9002_calib.c +6 -5
@@ -657,14 +657,13 @@ static void ar9002_hw_olc_temp_compensation(struct ath_hw *ah)ar9280_hw_olc_temp_compensation (ah); } -static bool ar9002_hw_calibrate (struct ath_hw *ah, -struct ath9k_channel *chan, -u8 rxchainmask, -bool longcal) +static int ar9002_hw_calibrate (struct ath_hw *ah,struct ath9k_channel *chan, +u8 rxchainmask,bool longcal) {bool iscaldone = true;struct ath9k_cal_list *currCal = ah->cal_list_curr;bool nfcal, nfcal_pending = false; +int ret; nfcal = !!(REG_READ (ah,AR_PHY_AGC_CONTROL ) &AR_PHY_AGC_CONTROL_NF );if (ah->caldata)
@@ -698,7 +697,9 @@ static bool ar9002_hw_calibrate(struct ath_hw *ah,* NF is slow time-variant, so it is OK to use a * historical value. */ -ath9k_hw_loadnf (ah, ah->curchan); + ret =ath9k_hw_loadnf (ah, ah->curchan); +if (ret <0 ) +return ret; }if (longcal) {
drivers/net/wireless/ath/ath9k/ar9003_calib.c +6 -5
@@ -121,13 +121,12 @@ static bool ar9003_hw_per_calibration(struct ath_hw *ah,return iscaldone; } -static bool ar9003_hw_calibrate (struct ath_hw *ah, -struct ath9k_channel *chan, -u8 rxchainmask, -bool longcal) +static int ar9003_hw_calibrate (struct ath_hw *ah,struct ath9k_channel *chan, +u8 rxchainmask,bool longcal) {bool iscaldone = true;struct ath9k_cal_list *currCal = ah->cal_list_curr; +int ret;/* * For given calibration:
@@ -163,7 +162,9 @@ static bool ar9003_hw_calibrate(struct ath_hw *ah,* NF is slow time-variant, so it is OK to use a historical * value. */ -ath9k_hw_loadnf (ah, ah->curchan); + ret =ath9k_hw_loadnf (ah, ah->curchan); +if (ret <0 ) +return ret;/* start NF calibration, without updating BB NF register */ ath9k_hw_start_nfcal (ah, false);
drivers/net/wireless/ath/ath9k/calib.c +4 -2
@@ -234,7 +234,7 @@ void ath9k_hw_start_nfcal(struct ath_hw *ah, bool update)REG_SET_BIT (ah,AR_PHY_AGC_CONTROL ,AR_PHY_AGC_CONTROL_NF ); } -void ath9k_hw_loadnf (struct ath_hw *ah,struct ath9k_channel *chan) +int ath9k_hw_loadnf (struct ath_hw *ah,struct ath9k_channel *chan) {struct ath9k_nfcal_hist *h =NULL ;unsigned i, j;
@@ -301,7 +301,7 @@ void ath9k_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan)ath_dbg (common,ANY ,"Timeout while waiting for nf to load: AR_PHY_AGC_CONTROL=0x%x\n" ,REG_READ (ah,AR_PHY_AGC_CONTROL )); -return ; +return -ETIMEDOUT ; }/*
@@ -322,6 +322,8 @@ void ath9k_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan) } }REGWRITE_BUFFER_FLUSH (ah); + +return 0 ; }
drivers/net/wireless/ath/ath9k/calib.h +1 -1
@@ -109,7 +109,7 @@ struct ath9k_pacal_info{bool ath9k_hw_reset_calvalid (struct ath_hw *ah);void ath9k_hw_start_nfcal (struct ath_hw *ah,bool update); -void ath9k_hw_loadnf (struct ath_hw *ah,struct ath9k_channel *chan); +int ath9k_hw_loadnf (struct ath_hw *ah,struct ath9k_channel *chan);bool ath9k_hw_getnf (struct ath_hw *ah,struct ath9k_channel *chan);void ath9k_init_nfcal_hist_buffer (struct ath_hw *ah,struct ath9k_channel *chan);
drivers/net/wireless/ath/ath9k/debug.c +1 -0
@@ -863,6 +863,7 @@ static ssize_t read_file_reset(struct file *file, char __user *user_buf, [RESET_TYPE_MAC_HANG] = "MAC Hang", [RESET_TYPE_BEACON_STUCK] = "Stuck Beacon", [RESET_TYPE_MCI] = "MCI Reset", + [RESET_TYPE_CALIBRATION] = "Calibration error", };char buf[512 ];unsigned int len =0 ;
drivers/net/wireless/ath/ath9k/debug.h +1 -0
@@ -49,6 +49,7 @@ enum ath_reset_type {RESET_TYPE_MAC_HANG ,RESET_TYPE_BEACON_STUCK ,RESET_TYPE_MCI , +RESET_TYPE_CALIBRATION , __RESET_TYPE_MAX };
drivers/net/wireless/ath/ath9k/hw-ops.h +3 -4
@@ -41,10 +41,9 @@ static inline void ath9k_hw_set_desc_link(struct ath_hw *ah, void *ds,ath9k_hw_ops (ah)->set_desc_link (ds, link); } -static inline bool ath9k_hw_calibrate (struct ath_hw *ah, -struct ath9k_channel *chan, -u8 rxchainmask, -bool longcal) +static inline int ath9k_hw_calibrate (struct ath_hw *ah, +struct ath9k_channel *chan, +u8 rxchainmask,bool longcal) {return ath9k_hw_ops (ah)->calibrate (ah, chan, rxchainmask, longcal); }
drivers/net/wireless/ath/ath9k/hw.h +2 -4
@@ -688,10 +688,8 @@ struct ath_hw_ops { bool power_off);void (*rx_enable)(struct ath_hw *ah);void (*set_desc_link)(void *ds,u32 link); -bool (*calibrate)(struct ath_hw *ah, -struct ath9k_channel *chan, -u8 rxchainmask, -bool longcal); +int (*calibrate)(struct ath_hw *ah,struct ath9k_channel *chan, +u8 rxchainmask,bool longcal);bool (*get_isr)(struct ath_hw *ah,enum ath9k_int *masked,u32 *sync_cause_p); void (*set_txdesc)(struct ath_hw *ah, void *ds,
drivers/net/wireless/ath/ath9k/link.c +8 -3
@@ -371,9 +371,14 @@ void ath_ani_calibrate(unsigned long data)/* Perform calibration if necessary */ if (longcal || shortcal) { - common->ani.caldone = -ath9k_hw_calibrate (ah, ah->curchan, - ah->rxchainmask, longcal); +int ret =ath9k_hw_calibrate (ah, ah->curchan, ah->rxchainmask, + longcal); +if (ret <0 ) { +ath9k_queue_reset (sc,RESET_TYPE_CALIBRATION ); +return ; + } + + common->ani.caldone = ret; } ath_dbg(common, ANI,
Signature · 1 line
2.0.4
Re: [PATCH 05/10] ath9k: restart hardware after noise floor calibration failure
Quoted 9 lines · Felix Fietkau
drivers/net/wireless/ath/ath9k/link.c +0
-1@@ -371,9 +371,14 @@ void ath_ani_calibrate(unsigned long data)/* Perform calibration if necessary */ if (longcal || shortcal) { - common->ani.caldone =
drivers/net/wireless/ath/ath9k/link.c void ath_ani_calibrate(unsigned long data) · line 381
Quoted 10 lines
drivers/net/wireless/ath/ath9k/link.c +8
-2-ath9k_hw_calibrate (ah, ah->curchan, - ah->rxchainmask, longcal); +int ret =ath9k_hw_calibrate (ah, ah->curchan, ah->rxchainmask, + longcal); +if (ret <0 ) { +ath9k_queue_reset (sc,RESET_TYPE_CALIBRATION ); +return ; + } + + common->ani.caldone = ret;
Shouldn't ani.caldone be set to false if calibration fails (and true otherwise) ? It is used earlier in the ANI routine and since this returns after queuing a reset, caldone will have incorrect information, no ?
Sujith
PATCH 6/10 ath9k_hw: do not run NF and periodic calibration at the same time
In reply to Felix FietkauIt can cause inconsistent calibration results or in some cases turn the radio deaf.
--- drivers/net/wireless/ath/ath9k/ar9002_calib.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-)
drivers/net/wireless/ath/ath9k/ar9002_calib.c +8 -11
@@ -660,7 +660,6 @@ static void ar9002_hw_olc_temp_compensation(struct ath_hw *ah)static int ar9002_hw_calibrate (struct ath_hw *ah,struct ath9k_channel *chan,u8 rxchainmask,bool longcal) { -bool iscaldone = true;struct ath9k_cal_list *currCal = ah->cal_list_curr;bool nfcal, nfcal_pending = false;int ret;
@@ -672,15 +671,13 @@ static int ar9002_hw_calibrate(struct ath_hw *ah, struct ath9k_channel *chan,if (currCal && !nfcal && (currCal->calState ==CAL_RUNNING || currCal->calState ==CAL_WAITING )) { - iscaldone =ar9002_hw_per_calibration (ah, chan, - rxchainmask, currCal); -if (iscaldone) { - ah->cal_list_curr = currCal = currCal->calNext; - -if (currCal->calState ==CAL_WAITING ) { - iscaldone = false; -ath9k_hw_reset_calibration (ah, currCal); - } +if (!ar9002_hw_per_calibration (ah, chan, rxchainmask, currCal)) +return 0 ; + + ah->cal_list_curr = currCal = currCal->calNext; +if (currCal->calState ==CAL_WAITING ) { +ath9k_hw_reset_calibration (ah, currCal); +return 0 ; } }
@@ -710,7 +707,7 @@ static int ar9002_hw_calibrate(struct ath_hw *ah, struct ath9k_channel *chan, } } -return iscaldone; +return 1 ; }/* Carrier leakage Calibration fix */
Signature · 1 line
2.0.4
Re: [PATCH 06/10] ath9k_hw: do not run NF and periodic calibration at the same time
drivers/net/wireless/ath/ath9k/ar9002_calib.c static int ar9002_hw_calibrate(struct ath_hw *ah, struct ath9k_channel *chan, · line 680
Quoted 7 lines · Felix Fietkau
drivers/net/wireless/ath/ath9k/ar9002_calib.c +7
-0+if (!ar9002_hw_per_calibration (ah, chan, rxchainmask, currCal)) +return 0 ; + + ah->cal_list_curr = currCal = currCal->calNext; +if (currCal->calState ==CAL_WAITING ) { +ath9k_hw_reset_calibration (ah, currCal); +return 0 ;
Won't this break things if longcal is set, since other types like PA/OLC etc. need to be run in that case.
Sujith
PATCH 7/10 ath9k_hw: start initial NF calibration after PA calibration on <AR9003
In reply to Felix FietkauThis makes the initial NF calibration less likely to fail.
--- drivers/net/wireless/ath/ath9k/ar9002_calib.c | 1 + drivers/net/wireless/ath/ath9k/hw.c | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath9k/ar9002_calib.c +1 -0
@@ -854,6 +854,7 @@ static bool ar9002_hw_init_cal(struct ath_hw *ah, struct ath9k_channel *chan)/* Do PA Calibration */ ar9002_hw_pa_cal (ah, true); +ath9k_hw_start_nfcal (ah, true);if (ah->caldata)set_bit (NFCAL_PENDING , &ah->caldata->cal_flags);
drivers/net/wireless/ath/ath9k/hw.c +4 -2
@@ -1953,8 +1953,10 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,if (ath9k_hw_mci_is_enabled (ah))ar9003_mci_check_bt (ah); -ath9k_hw_loadnf (ah, chan); -ath9k_hw_start_nfcal (ah, true); +if (AR_SREV_9300_20_OR_LATER (ah)) { +ath9k_hw_loadnf (ah, chan); +ath9k_hw_start_nfcal (ah, true); + }if (AR_SREV_9300_20_OR_LATER (ah))ar9003_hw_bb_watchdog_config (ah);
Signature · 1 line
2.0.4
Re: [PATCH 07/10] ath9k_hw: start initial NF calibration after PA calibration on <AR9003
Quoted 10 lines · Felix Fietkau
drivers/net/wireless/ath/ath9k/ar9002_calib.c +1
-0ar9002_hw_pa_cal (ah, true); +ath9k_hw_start_nfcal (ah, true);if (ah->caldata)set_bit (NFCAL_PENDING , &ah->caldata->cal_flags);drivers/net/wireless/ath/ath9k/hw.c +0
-0
drivers/net/wireless/ath/ath9k/hw.c int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, · line 1959
Quoted 9 lines
drivers/net/wireless/ath/ath9k/hw.c +4
-2@@ -1953,8 +1953,10 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,if (ath9k_hw_mci_is_enabled (ah))ar9003_mci_check_bt (ah); -ath9k_hw_loadnf (ah, chan); -ath9k_hw_start_nfcal (ah, true); +if (AR_SREV_9300_20_OR_LATER (ah)) { +ath9k_hw_loadnf (ah, chan); +ath9k_hw_start_nfcal (ah, true); + }
This doesn't seem to load the NF registers for AR9002 ? If a chip reset is done for some reason when the driver is operational, don't we have to load the history values ?
Sujith
PATCH 8/10 ath9k: add support for endian swap of eeprom from platform data
In reply to Felix FietkauOn some devices (especially little-endian ones), the flash EEPROM data has a different endian, which needs to be detected.
Add a flag to the platform data to allow overriding that behavior
--- drivers/net/wireless/ath/ath9k/eeprom_def.c | 31 ++++++++++------------------- drivers/net/wireless/ath/ath9k/hw.h | 1 + drivers/net/wireless/ath/ath9k/init.c | 2 ++ include/linux/ath9k_platform.h | 1 + 4 files changed, 14 insertions(+), 21 deletions(-)
drivers/net/wireless/ath/ath9k/eeprom_def.c +10 -21
@@ -262,7 +262,7 @@ static int ath9k_hw_def_check_eeprom(struct ath_hw *ah) {struct ar5416_eeprom_def *eep = &ah->eeprom.def;struct ath_common *common =ath9k_hw_common (ah); -u16 *eepdata, temp, magic, magic2; +u16 *eepdata, temp, magic;u32 sum =0 , el;bool need_swap = false;int i, addr, size;
@@ -272,27 +272,16 @@ static int ath9k_hw_def_check_eeprom(struct ath_hw *ah)return false; } -if (!ath9k_hw_use_flash (ah)) { -ath_dbg (common,EEPROM ,"Read Magic = 0x%04X\n" , magic); - -if (magic !=AR5416_EEPROM_MAGIC ) { - magic2 =swab16 (magic); - -if (magic2 ==AR5416_EEPROM_MAGIC ) { - size =sizeof (struct ar5416_eeprom_def ); - need_swap = true; - eepdata = (u16 *) (&ah->eeprom); +if (swab16 (magic) ==AR5416_EEPROM_MAGIC && + !(ah->ah_flags &AH_NO_EEP_SWAP )) { + size =sizeof (struct ar5416_eeprom_def ); + need_swap = true; + eepdata = (u16 *) (&ah->eeprom); -for (addr =0 ; addr < size /sizeof (u16); addr++) { - temp =swab16 (*eepdata); - *eepdata = temp; - eepdata++; - } - }else { -ath_err (common, -"Invalid EEPROM Magic. Endianness mismatch.\n" ); -return -EINVAL ; - } +for (addr =0 ; addr < size /sizeof (u16); addr++) { + temp =swab16 (*eepdata); + *eepdata = temp; + eepdata++; } }
drivers/net/wireless/ath/ath9k/hw.h +1 -0
@@ -731,6 +731,7 @@ enum ath_cal_list {#define AH_USE_EEPROM 0x1#define AH_UNPLUGGED 0x2/* The card has been physically removed. */ #define AH_FASTCC 0x4 +#define AH_NO_EEP_SWAP 0x8/* Do not swap EEPROM data */ struct ath_hw {struct ath_ops reg_ops;
drivers/net/wireless/ath/ath9k/init.c +2 -0
@@ -531,6 +531,8 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc, ah->is_clk_25mhz = pdata->is_clk_25mhz; ah->get_mac_revision = pdata->get_mac_revision; ah->external_reset = pdata->external_reset; +if (!pdata->endian_check) + ah->ah_flags |=AH_NO_EEP_SWAP ; } common->ops = &ah->reg_ops;
include/linux/ath9k_platform.h +1 -0
@@ -31,6 +31,7 @@ struct ath9k_platform_data {u32 gpio_mask;u32 gpio_val; +bool endian_check;bool is_clk_25mhz;bool tx_gain_buffalo;
Signature · 1 line
2.0.4
PATCH 9/10 ath9k: allow disabling bands via platform data
In reply to Felix FietkauSome devices have multiple bands enables in the EEPROM data, even though they are only calibrated for one. Allow platform data to disable unsupported bands.
--- drivers/net/wireless/ath/ath9k/hw.c | 24 ++++++++++++++++-------- drivers/net/wireless/ath/ath9k/hw.h | 2 ++ drivers/net/wireless/ath/ath9k/init.c | 2 ++ include/linux/ath9k_platform.h | 2 ++ 4 files changed, 22 insertions(+), 8 deletions(-)
drivers/net/wireless/ath/ath9k/hw.c +16 -8
@@ -2344,17 +2344,25 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah) } eeval = ah->eep_ops->get_eeprom (ah,EEP_OP_MODE ); -if ((eeval & (AR5416_OPFLAGS_11G |AR5416_OPFLAGS_11A )) ==0 ) { -ath_err (common, -"no band has been marked as supported in EEPROM\n" ); -return -EINVAL ; + +if (eeval &AR5416_OPFLAGS_11A ) { +if (ah->disable_5ghz) +ath_warn (common,"disabling 5GHz band\n" ); +else + pCap->hw_caps |=ATH9K_HW_CAP_5GHZ ; } -if (eeval &AR5416_OPFLAGS_11A ) - pCap->hw_caps |=ATH9K_HW_CAP_5GHZ ; +if (eeval &AR5416_OPFLAGS_11G ) { +if (ah->disable_2ghz) +ath_warn (common,"disabling 2GHz band\n" ); +else + pCap->hw_caps |=ATH9K_HW_CAP_2GHZ ; + } -if (eeval &AR5416_OPFLAGS_11G ) - pCap->hw_caps |=ATH9K_HW_CAP_2GHZ ; +if ((pCap->hw_caps & (ATH9K_HW_CAP_2GHZ |ATH9K_HW_CAP_5GHZ )) ==0 ) { +ath_err (common,"both bands are disabled\n" ); +return -EINVAL ; + } if (AR_SREV_9485(ah) || AR_SREV_9285(ah) ||
drivers/net/wireless/ath/ath9k/hw.h +2 -0
@@ -930,6 +930,8 @@ struct ath_hw {bool is_clk_25mhz;int (*get_mac_revision)(void );int (*external_reset)(void ); +bool disable_2ghz; +bool disable_5ghz;const struct firmware *eeprom_blob;
drivers/net/wireless/ath/ath9k/init.c +2 -0
@@ -531,6 +531,8 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc, ah->is_clk_25mhz = pdata->is_clk_25mhz; ah->get_mac_revision = pdata->get_mac_revision; ah->external_reset = pdata->external_reset; + ah->disable_2ghz = pdata->disable_2ghz; + ah->disable_5ghz = pdata->disable_5ghz;if (!pdata->endian_check) ah->ah_flags |=AH_NO_EEP_SWAP ; }
include/linux/ath9k_platform.h +2 -0
@@ -34,6 +34,8 @@ struct ath9k_platform_data {bool endian_check;bool is_clk_25mhz;bool tx_gain_buffalo; +bool disable_2ghz; +bool disable_5ghz;int (*get_mac_revision)(void );int (*external_reset)(void );
Signature · 1 line
2.0.4
PATCH 10/10 ath9k: use a random MAC address if the EEPROM address is invalid
In reply to Felix FietkauBased on OpenWrt patch by Gabor Juhos
--- drivers/net/wireless/ath/ath9k/hw.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath9k/hw.c +11 -2
@@ -19,6 +19,7 @@#include <linux/module.h> #include <linux/time.h> #include <linux/bitops.h> +#include <linux/etherdevice.h> #include <asm/unaligned.h> #include "hw.h"
@@ -446,8 +447,16 @@ static int ath9k_hw_init_macaddr(struct ath_hw *ah) common->macaddr[2 * i] = eeval >>8 ; common->macaddr[2 * i +1 ] = eeval &0xff ; } -if (sum ==0 || sum ==0xffff *3 ) -return -EADDRNOTAVAIL ; +if (!is_valid_ether_addr (common->macaddr)) { +ath_err (common, +"eeprom contains invalid mac address: %pM\n" , + common->macaddr); + +random_ether_addr (common->macaddr); +ath_err (common, +"random mac address will be used: %pM\n" , + common->macaddr); + }return 0 ; }
Signature · 1 line
2.0.4
Quoted 18 lines · Felix Fietkau
drivers/net/wireless/ath/ath9k/hw.h +3
-5@@ -244,13 +244,20 @@ enum ath9k_hw_caps {ATH9K_HW_CAP_2GHZ =BIT (11 ),ATH9K_HW_CAP_5GHZ =BIT (12 ),ATH9K_HW_CAP_APM =BIT (13 ), +#ifdef CONFIG_ATH9K_PCOEMATH9K_HW_CAP_RTT =BIT (14 ),ATH9K_HW_CAP_MCI =BIT (15 ), -ATH9K_HW_CAP_DFS =BIT (16 ), -ATH9K_HW_WOW_DEVICE_CAPABLE =BIT (17 ), -ATH9K_HW_CAP_PAPRD =BIT (18 ), -ATH9K_HW_CAP_FCC_BAND_SWITCH =BIT (19 ), - ATH9K_HW_CAP_BT_ANT_DIV = BIT(20), +ATH9K_HW_WOW_DEVICE_CAPABLE =BIT (16 ), + ATH9K_HW_CAP_BT_ANT_DIV = BIT(17),
drivers/net/wireless/ath/ath9k/hw.h enum ath9k_hw_caps { · line 261
Quoted 10 lines
drivers/net/wireless/ath/ath9k/hw.h +9
-0+#else +ATH9K_HW_CAP_RTT =0 , +ATH9K_HW_CAP_MCI =0 , +ATH9K_HW_WOW_DEVICE_CAPABLE =0 , +ATH9K_HW_CAP_BT_ANT_DIV =0 , +#endif +ATH9K_HW_CAP_DFS =BIT (18 ), +ATH9K_HW_CAP_PAPRD =BIT (19 ), + ATH9K_HW_CAP_FCC_BAND_SWITCH = BIT(20), };
Why is this needed ?
Quoted 23 lines · Sujith Manoharan
Quoted 22 lines · Felix Fietkau
drivers/net/wireless/ath/ath9k/hw.h +7
-5@@ -244,13 +244,20 @@ enum ath9k_hw_caps {ATH9K_HW_CAP_2GHZ =BIT (11 ),ATH9K_HW_CAP_5GHZ =BIT (12 ),ATH9K_HW_CAP_APM =BIT (13 ), +#ifdef CONFIG_ATH9K_PCOEMATH9K_HW_CAP_RTT =BIT (14 ),ATH9K_HW_CAP_MCI =BIT (15 ), -ATH9K_HW_CAP_DFS =BIT (16 ), -ATH9K_HW_WOW_DEVICE_CAPABLE =BIT (17 ), -ATH9K_HW_CAP_PAPRD =BIT (18 ), -ATH9K_HW_CAP_FCC_BAND_SWITCH =BIT (19 ), - ATH9K_HW_CAP_BT_ANT_DIV = BIT(20), +ATH9K_HW_WOW_DEVICE_CAPABLE =BIT (16 ), +ATH9K_HW_CAP_BT_ANT_DIV =BIT (17 ), +#else +ATH9K_HW_CAP_RTT =0 , +ATH9K_HW_CAP_MCI =0 , + ATH9K_HW_WOW_DEVICE_CAPABLE = 0,
Quoted 8 lines
drivers/net/wireless/ath/ath9k/hw.h enum ath9k_hw_caps { · line 261
Quoted 6 lines
drivers/net/wireless/ath/ath9k/hw.h +5
-0+ATH9K_HW_CAP_BT_ANT_DIV =0 , +#endif +ATH9K_HW_CAP_DFS =BIT (18 ), +ATH9K_HW_CAP_PAPRD =BIT (19 ), + ATH9K_HW_CAP_FCC_BAND_SWITCH = BIT(20), };Why is this needed ?
To allow the compiler to optimize out code checking for these features. That way we don't have to #ifdef all those places where this gets used.
- Felix