Commit 8896934c authored by Felix Fietkau's avatar Felix Fietkau Committed by John W. Linville

ath9k_hw: remove direct accesses to channel mode flags

Use wrappers where available. Simplifies code and helps with further
improvements to the channel data structure
Signed-off-by: default avatarFelix Fietkau <nbd@openwrt.org>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 1a04d59d
...@@ -338,10 +338,9 @@ void ath9k_ani_reset(struct ath_hw *ah, bool is_scanning) ...@@ -338,10 +338,9 @@ void ath9k_ani_reset(struct ath_hw *ah, bool is_scanning)
aniState->cckNoiseImmunityLevel != aniState->cckNoiseImmunityLevel !=
ATH9K_ANI_CCK_DEF_LEVEL) { ATH9K_ANI_CCK_DEF_LEVEL) {
ath_dbg(common, ANI, ath_dbg(common, ANI,
"Restore defaults: opmode %u chan %d Mhz/0x%x is_scanning=%d ofdm:%d cck:%d\n", "Restore defaults: opmode %u chan %d Mhz is_scanning=%d ofdm:%d cck:%d\n",
ah->opmode, ah->opmode,
chan->channel, chan->channel,
chan->channelFlags,
is_scanning, is_scanning,
aniState->ofdmNoiseImmunityLevel, aniState->ofdmNoiseImmunityLevel,
aniState->cckNoiseImmunityLevel); aniState->cckNoiseImmunityLevel);
...@@ -354,10 +353,9 @@ void ath9k_ani_reset(struct ath_hw *ah, bool is_scanning) ...@@ -354,10 +353,9 @@ void ath9k_ani_reset(struct ath_hw *ah, bool is_scanning)
* restore historical levels for this channel * restore historical levels for this channel
*/ */
ath_dbg(common, ANI, ath_dbg(common, ANI,
"Restore history: opmode %u chan %d Mhz/0x%x is_scanning=%d ofdm:%d cck:%d\n", "Restore history: opmode %u chan %d Mhz is_scanning=%d ofdm:%d cck:%d\n",
ah->opmode, ah->opmode,
chan->channel, chan->channel,
chan->channelFlags,
is_scanning, is_scanning,
aniState->ofdmNoiseImmunityLevel, aniState->ofdmNoiseImmunityLevel,
aniState->cckNoiseImmunityLevel); aniState->cckNoiseImmunityLevel);
......
...@@ -666,8 +666,7 @@ static void ar5008_hw_set_channel_regs(struct ath_hw *ah, ...@@ -666,8 +666,7 @@ static void ar5008_hw_set_channel_regs(struct ath_hw *ah,
if (IS_CHAN_HT40(chan)) { if (IS_CHAN_HT40(chan)) {
phymode |= AR_PHY_FC_DYN2040_EN; phymode |= AR_PHY_FC_DYN2040_EN;
if ((chan->chanmode == CHANNEL_A_HT40PLUS) || if (IS_CHAN_HT40PLUS(chan))
(chan->chanmode == CHANNEL_G_HT40PLUS))
phymode |= AR_PHY_FC_DYN2040_PRI_CH; phymode |= AR_PHY_FC_DYN2040_PRI_CH;
} }
...@@ -691,31 +690,12 @@ static int ar5008_hw_process_ini(struct ath_hw *ah, ...@@ -691,31 +690,12 @@ static int ar5008_hw_process_ini(struct ath_hw *ah,
int i, regWrites = 0; int i, regWrites = 0;
u32 modesIndex, freqIndex; u32 modesIndex, freqIndex;
switch (chan->chanmode) { if (IS_CHAN_5GHZ(chan)) {
case CHANNEL_A:
case CHANNEL_A_HT20:
modesIndex = 1;
freqIndex = 1; freqIndex = 1;
break; modesIndex = IS_CHAN_HT40(chan) ? 2 : 1;
case CHANNEL_A_HT40PLUS: } else {
case CHANNEL_A_HT40MINUS:
modesIndex = 2;
freqIndex = 1;
break;
case CHANNEL_G:
case CHANNEL_G_HT20:
case CHANNEL_B:
modesIndex = 4;
freqIndex = 2;
break;
case CHANNEL_G_HT40PLUS:
case CHANNEL_G_HT40MINUS:
modesIndex = 3;
freqIndex = 2; freqIndex = 2;
break; modesIndex = IS_CHAN_HT40(chan) ? 3 : 4;
default:
return -EINVAL;
} }
/* /*
...@@ -1218,12 +1198,11 @@ static void ar5008_hw_ani_cache_ini_regs(struct ath_hw *ah) ...@@ -1218,12 +1198,11 @@ static void ar5008_hw_ani_cache_ini_regs(struct ath_hw *ah)
iniDef = &aniState->iniDef; iniDef = &aniState->iniDef;
ath_dbg(common, ANI, "ver %d.%d opmode %u chan %d Mhz/0x%x\n", ath_dbg(common, ANI, "ver %d.%d opmode %u chan %d Mhz\n",
ah->hw_version.macVersion, ah->hw_version.macVersion,
ah->hw_version.macRev, ah->hw_version.macRev,
ah->opmode, ah->opmode,
chan->channel, chan->channel);
chan->channelFlags);
val = REG_READ(ah, AR_PHY_SFCORR); val = REG_READ(ah, AR_PHY_SFCORR);
iniDef->m1Thresh = MS(val, AR_PHY_SFCORR_M1_THRESH); iniDef->m1Thresh = MS(val, AR_PHY_SFCORR_M1_THRESH);
......
...@@ -419,28 +419,10 @@ void ar9002_hw_load_ani_reg(struct ath_hw *ah, struct ath9k_channel *chan) ...@@ -419,28 +419,10 @@ void ar9002_hw_load_ani_reg(struct ath_hw *ah, struct ath9k_channel *chan)
u32 modesIndex; u32 modesIndex;
int i; int i;
switch (chan->chanmode) { if (IS_CHAN_5GHZ(chan))
case CHANNEL_A: modesIndex = IS_CHAN_HT40(chan) ? 2 : 1;
case CHANNEL_A_HT20: else
modesIndex = 1; modesIndex = IS_CHAN_HT40(chan) ? 3 : 4;
break;
case CHANNEL_A_HT40PLUS:
case CHANNEL_A_HT40MINUS:
modesIndex = 2;
break;
case CHANNEL_G:
case CHANNEL_G_HT20:
case CHANNEL_B:
modesIndex = 4;
break;
case CHANNEL_G_HT40PLUS:
case CHANNEL_G_HT40MINUS:
modesIndex = 3;
break;
default:
return;
}
ENABLE_REGWRITE_BUFFER(ah); ENABLE_REGWRITE_BUFFER(ah);
......
...@@ -551,8 +551,7 @@ static void ar9003_hw_set_channel_regs(struct ath_hw *ah, ...@@ -551,8 +551,7 @@ static void ar9003_hw_set_channel_regs(struct ath_hw *ah,
if (IS_CHAN_HT40(chan)) { if (IS_CHAN_HT40(chan)) {
phymode |= AR_PHY_GC_DYN2040_EN; phymode |= AR_PHY_GC_DYN2040_EN;
/* Configure control (primary) channel at +-10MHz */ /* Configure control (primary) channel at +-10MHz */
if ((chan->chanmode == CHANNEL_A_HT40PLUS) || if (IS_CHAN_HT40PLUS(chan))
(chan->chanmode == CHANNEL_G_HT40PLUS))
phymode |= AR_PHY_GC_DYN2040_PRI_CH; phymode |= AR_PHY_GC_DYN2040_PRI_CH;
} }
...@@ -682,41 +681,22 @@ static int ar9550_hw_get_modes_txgain_index(struct ath_hw *ah, ...@@ -682,41 +681,22 @@ static int ar9550_hw_get_modes_txgain_index(struct ath_hw *ah,
{ {
int ret; int ret;
switch (chan->chanmode) { if (IS_CHAN_2GHZ(chan)) {
case CHANNEL_A: if (IS_CHAN_HT40(chan))
case CHANNEL_A_HT20: return 7;
if (chan->channel <= 5350)
ret = 1;
else if ((chan->channel > 5350) && (chan->channel <= 5600))
ret = 3;
else else
ret = 5; return 8;
break; }
case CHANNEL_A_HT40PLUS:
case CHANNEL_A_HT40MINUS:
if (chan->channel <= 5350)
ret = 2;
else if ((chan->channel > 5350) && (chan->channel <= 5600))
ret = 4;
else
ret = 6;
break;
case CHANNEL_G:
case CHANNEL_G_HT20:
case CHANNEL_B:
ret = 8;
break;
case CHANNEL_G_HT40PLUS: if (chan->channel <= 5350)
case CHANNEL_G_HT40MINUS: ret = 1;
ret = 7; else if ((chan->channel > 5350) && (chan->channel <= 5600))
break; ret = 3;
else
ret = 5;
default: if (IS_CHAN_HT40(chan))
ret = -EINVAL; ret++;
}
return ret; return ret;
} }
...@@ -727,28 +707,10 @@ static int ar9003_hw_process_ini(struct ath_hw *ah, ...@@ -727,28 +707,10 @@ static int ar9003_hw_process_ini(struct ath_hw *ah,
unsigned int regWrites = 0, i; unsigned int regWrites = 0, i;
u32 modesIndex; u32 modesIndex;
switch (chan->chanmode) { if (IS_CHAN_5GHZ(chan))
case CHANNEL_A: modesIndex = IS_CHAN_HT40(chan) ? 2 : 1;
case CHANNEL_A_HT20: else
modesIndex = 1; modesIndex = IS_CHAN_HT40(chan) ? 3 : 4;
break;
case CHANNEL_A_HT40PLUS:
case CHANNEL_A_HT40MINUS:
modesIndex = 2;
break;
case CHANNEL_G:
case CHANNEL_G_HT20:
case CHANNEL_B:
modesIndex = 4;
break;
case CHANNEL_G_HT40PLUS:
case CHANNEL_G_HT40MINUS:
modesIndex = 3;
break;
default:
return -EINVAL;
}
/* /*
* SOC, MAC, BB, RADIO initvals. * SOC, MAC, BB, RADIO initvals.
...@@ -1273,12 +1235,11 @@ static void ar9003_hw_ani_cache_ini_regs(struct ath_hw *ah) ...@@ -1273,12 +1235,11 @@ static void ar9003_hw_ani_cache_ini_regs(struct ath_hw *ah)
aniState = &ah->ani; aniState = &ah->ani;
iniDef = &aniState->iniDef; iniDef = &aniState->iniDef;
ath_dbg(common, ANI, "ver %d.%d opmode %u chan %d Mhz/0x%x\n", ath_dbg(common, ANI, "ver %d.%d opmode %u chan %d Mhz\n",
ah->hw_version.macVersion, ah->hw_version.macVersion,
ah->hw_version.macRev, ah->hw_version.macRev,
ah->opmode, ah->opmode,
chan->channel, chan->channel);
chan->channelFlags);
val = REG_READ(ah, AR_PHY_SFCORR); val = REG_READ(ah, AR_PHY_SFCORR);
iniDef->m1Thresh = MS(val, AR_PHY_SFCORR_M1_THRESH); iniDef->m1Thresh = MS(val, AR_PHY_SFCORR_M1_THRESH);
...@@ -1536,28 +1497,10 @@ static int ar9003_hw_fast_chan_change(struct ath_hw *ah, ...@@ -1536,28 +1497,10 @@ static int ar9003_hw_fast_chan_change(struct ath_hw *ah,
unsigned int regWrites = 0; unsigned int regWrites = 0;
u32 modesIndex; u32 modesIndex;
switch (chan->chanmode) { if (IS_CHAN_5GHZ(chan))
case CHANNEL_A: modesIndex = IS_CHAN_HT40(chan) ? 2 : 1;
case CHANNEL_A_HT20: else
modesIndex = 1; modesIndex = IS_CHAN_HT40(chan) ? 3 : 4;
break;
case CHANNEL_A_HT40PLUS:
case CHANNEL_A_HT40MINUS:
modesIndex = 2;
break;
case CHANNEL_G:
case CHANNEL_G_HT20:
case CHANNEL_B:
modesIndex = 4;
break;
case CHANNEL_G_HT40PLUS:
case CHANNEL_G_HT40MINUS:
modesIndex = 3;
break;
default:
return -EINVAL;
}
if (modesIndex == ah->modes_index) { if (modesIndex == ah->modes_index) {
*ini_reloaded = false; *ini_reloaded = false;
......
...@@ -24,30 +24,10 @@ ...@@ -24,30 +24,10 @@
static enum htc_phymode ath9k_htc_get_curmode(struct ath9k_htc_priv *priv, static enum htc_phymode ath9k_htc_get_curmode(struct ath9k_htc_priv *priv,
struct ath9k_channel *ichan) struct ath9k_channel *ichan)
{ {
enum htc_phymode mode; if (IS_CHAN_5GHZ(ichan))
return HTC_MODE_11NA;
mode = -EINVAL;
switch (ichan->chanmode) {
case CHANNEL_G:
case CHANNEL_G_HT20:
case CHANNEL_G_HT40PLUS:
case CHANNEL_G_HT40MINUS:
mode = HTC_MODE_11NG;
break;
case CHANNEL_A:
case CHANNEL_A_HT20:
case CHANNEL_A_HT40PLUS:
case CHANNEL_A_HT40MINUS:
mode = HTC_MODE_11NA;
break;
default:
break;
}
WARN_ON(mode < 0);
return mode; return HTC_MODE_11NG;
} }
bool ath9k_htc_setpower(struct ath9k_htc_priv *priv, bool ath9k_htc_setpower(struct ath9k_htc_priv *priv,
......
...@@ -294,8 +294,7 @@ void ath9k_hw_get_channel_centers(struct ath_hw *ah, ...@@ -294,8 +294,7 @@ void ath9k_hw_get_channel_centers(struct ath_hw *ah,
return; return;
} }
if ((chan->chanmode == CHANNEL_A_HT40PLUS) || if (IS_CHAN_HT40PLUS(chan)) {
(chan->chanmode == CHANNEL_G_HT40PLUS)) {
centers->synth_center = centers->synth_center =
chan->channel + HT40_CHANNEL_CENTER_SHIFT; chan->channel + HT40_CHANNEL_CENTER_SHIFT;
extoff = 1; extoff = 1;
...@@ -1510,9 +1509,7 @@ static bool ath9k_hw_channel_change(struct ath_hw *ah, ...@@ -1510,9 +1509,7 @@ static bool ath9k_hw_channel_change(struct ath_hw *ah,
int r; int r;
if (pCap->hw_caps & ATH9K_HW_CAP_FCC_BAND_SWITCH) { if (pCap->hw_caps & ATH9K_HW_CAP_FCC_BAND_SWITCH) {
u32 cur = ah->curchan->channelFlags & (CHANNEL_2GHZ | CHANNEL_5GHZ); band_switch = IS_CHAN_5GHZ(ah->curchan) != IS_CHAN_5GHZ(chan);
u32 new = chan->channelFlags & (CHANNEL_2GHZ | CHANNEL_5GHZ);
band_switch = (cur != new);
mode_diff = (chan->chanmode != ah->curchan->chanmode); mode_diff = (chan->chanmode != ah->curchan->chanmode);
} }
......
...@@ -463,6 +463,8 @@ struct ath9k_channel { ...@@ -463,6 +463,8 @@ struct ath9k_channel {
((_c)->chanmode == CHANNEL_G_HT40PLUS) || \ ((_c)->chanmode == CHANNEL_G_HT40PLUS) || \
((_c)->chanmode == CHANNEL_G_HT40MINUS)) ((_c)->chanmode == CHANNEL_G_HT40MINUS))
#define IS_CHAN_HT(_c) (IS_CHAN_HT20((_c)) || IS_CHAN_HT40((_c))) #define IS_CHAN_HT(_c) (IS_CHAN_HT20((_c)) || IS_CHAN_HT40((_c)))
#define IS_CHAN_HT40PLUS(_c) ((_c)->chanmode & CHANNEL_HT40PLUS)
#define IS_CHAN_HT40MINUS(_c) ((_c)->chanmode & CHANNEL_HT40MINUS)
enum ath9k_power_mode { enum ath9k_power_mode {
ATH9K_PM_AWAKE = 0, ATH9K_PM_AWAKE = 0,
......
...@@ -661,9 +661,9 @@ void ath9k_mci_update_wlan_channels(struct ath_softc *sc, bool allow_all) ...@@ -661,9 +661,9 @@ void ath9k_mci_update_wlan_channels(struct ath_softc *sc, bool allow_all)
chan_start = wlan_chan - 10; chan_start = wlan_chan - 10;
chan_end = wlan_chan + 10; chan_end = wlan_chan + 10;
if (chan->chanmode == CHANNEL_G_HT40PLUS) if (IS_CHAN_HT40PLUS(chan))
chan_end += 20; chan_end += 20;
else if (chan->chanmode == CHANNEL_G_HT40MINUS) else if (IS_CHAN_HT40MINUS(chan))
chan_start -= 20; chan_start -= 20;
/* adjust side band */ /* adjust side band */
...@@ -707,11 +707,11 @@ void ath9k_mci_set_txpower(struct ath_softc *sc, bool setchannel, ...@@ -707,11 +707,11 @@ void ath9k_mci_set_txpower(struct ath_softc *sc, bool setchannel,
if (setchannel) { if (setchannel) {
struct ath9k_hw_cal_data *caldata = &sc->caldata; struct ath9k_hw_cal_data *caldata = &sc->caldata;
if ((caldata->chanmode == CHANNEL_G_HT40PLUS) && if (IS_CHAN_HT40PLUS(ah->curchan) &&
(ah->curchan->channel > caldata->channel) && (ah->curchan->channel > caldata->channel) &&
(ah->curchan->channel <= caldata->channel + 20)) (ah->curchan->channel <= caldata->channel + 20))
return; return;
if ((caldata->chanmode == CHANNEL_G_HT40MINUS) && if (IS_CHAN_HT40MINUS(ah->curchan) &&
(ah->curchan->channel < caldata->channel) && (ah->curchan->channel < caldata->channel) &&
(ah->curchan->channel >= caldata->channel - 20)) (ah->curchan->channel >= caldata->channel - 20))
return; return;
......
...@@ -2023,8 +2023,7 @@ u8 ath_txchainmask_reduction(struct ath_softc *sc, u8 chainmask, u32 rate) ...@@ -2023,8 +2023,7 @@ u8 ath_txchainmask_reduction(struct ath_softc *sc, u8 chainmask, u32 rate)
struct ath_hw *ah = sc->sc_ah; struct ath_hw *ah = sc->sc_ah;
struct ath9k_channel *curchan = ah->curchan; struct ath9k_channel *curchan = ah->curchan;
if ((ah->caps.hw_caps & ATH9K_HW_CAP_APM) && if ((ah->caps.hw_caps & ATH9K_HW_CAP_APM) && IS_CHAN_5GHZ(curchan) &&
(curchan->channelFlags & CHANNEL_5GHZ) &&
(chainmask == 0x7) && (rate < 0x90)) (chainmask == 0x7) && (rate < 0x90))
return 0x3; return 0x3;
else if (AR_SREV_9462(ah) && ath9k_hw_btcoex_is_enabled(ah) && else if (AR_SREV_9462(ah) && ath9k_hw_btcoex_is_enabled(ah) &&
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment