2
* Copyright (c) 2010 Atheros Communications Inc.
2
* Copyright (c) 2010-2011 Atheros Communications Inc.
4
4
* Permission to use, copy, modify, and/or distribute this software for any
5
5
* purpose with or without fee is hereby granted, provided that the above
75
75
freq = centers.synth_center;
77
77
if (freq < 4800) { /* 2 GHz, fractional mode */
79
channelSel = CHANSEL_2G_9485(freq);
78
if (AR_SREV_9485(ah)) {
82
* freq_ref = 40 / (refdiva >> amoderefsel); where refdiva=1 and amoderefsel=0
83
* ndiv = ((chan_mhz * 4) / 3) / freq_ref;
84
* chansel = int(ndiv), chanfrac = (ndiv - chansel) * 0x20000
86
channelSel = (freq * 4) / 120;
87
chan_frac = (((freq * 4) % 120) * 0x20000) / 120;
88
channelSel = (channelSel << 17) | chan_frac;
89
} else if (AR_SREV_9340(ah)) {
90
if (ah->is_clk_25mhz) {
93
channelSel = (freq * 2) / 75;
94
chan_frac = (((freq * 2) % 75) * 0x20000) / 75;
95
channelSel = (channelSel << 17) | chan_frac;
97
channelSel = CHANSEL_2G(freq) >> 1;
81
99
channelSel = CHANSEL_2G(freq);
82
100
/* Set to 2G mode */
85
channelSel = CHANSEL_5G(freq);
86
/* Doubler is ON, so, divide channelSel by 2. */
103
if (AR_SREV_9340(ah) && ah->is_clk_25mhz) {
106
channelSel = (freq * 2) / 75;
107
chan_frac = ((freq % 75) * 0x20000) / 75;
108
channelSel = (channelSel << 17) | chan_frac;
110
channelSel = CHANSEL_5G(freq);
111
/* Doubler is ON, so, divide channelSel by 2. */
88
114
/* Set to 5G mode */
142
168
* is out-of-band and can be ignored.
145
if (AR_SREV_9485(ah)) {
171
if (AR_SREV_9485(ah) || AR_SREV_9340(ah)) {
146
172
spur_fbin_ptr = ar9003_get_spur_chan_ptr(ah,
147
173
IS_CHAN_2GHZ(chan));
148
174
if (spur_fbin_ptr[0] == 0) /* No spur */
168
194
for (i = 0; i < max_spur_cnts; i++) {
170
if (AR_SREV_9485(ah))
196
if (AR_SREV_9485(ah) || AR_SREV_9340(ah))
171
197
cur_bb_spur = FBIN2FREQ(spur_fbin_ptr[i],
172
198
IS_CHAN_2GHZ(chan)) - synth_freq;
402
428
ar9003_hw_spur_ofdm_clear(ah);
404
for (i = 0; spurChansPtr[i] && i < 5; i++) {
430
for (i = 0; i < AR_EEPROM_MODAL_SPURS && spurChansPtr[i]; i++) {
405
431
freq_offset = FBIN2FREQ(spurChansPtr[i], mode) - synth_freq;
406
432
if (abs(freq_offset) < range) {
407
433
ar9003_hw_spur_ofdm_work(ah, chan, freq_offset);
590
616
struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
591
617
unsigned int regWrites = 0, i;
592
618
struct ieee80211_channel *channel = chan->chan;
593
u32 modesIndex, freqIndex;
595
621
switch (chan->chanmode) {
597
623
case CHANNEL_A_HT20:
601
626
case CHANNEL_A_HT40PLUS:
602
627
case CHANNEL_A_HT40MINUS:
607
631
case CHANNEL_G_HT20:
612
635
case CHANNEL_G_HT40PLUS:
613
636
case CHANNEL_G_HT40MINUS:
637
659
REG_WRITE_ARRAY(&ah->iniModesAdditional,
638
660
modesIndex, regWrites);
662
if (AR_SREV_9340(ah) && !ah->is_clk_25mhz)
663
REG_WRITE_ARRAY(&ah->iniModesAdditional_40M, 1, regWrites);
640
665
ar9003_hw_override_ini(ah);
641
666
ar9003_hw_set_channel_regs(ah, chan);
642
667
ar9003_hw_set_chain_masks(ah, ah->rxchainmask, ah->txchainmask);
1159
1184
conf->radar_inband = 8;
1187
static void ar9003_hw_antdiv_comb_conf_get(struct ath_hw *ah,
1188
struct ath_hw_antcomb_conf *antconf)
1192
regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL);
1193
antconf->main_lna_conf = (regval & AR_PHY_9485_ANT_DIV_MAIN_LNACONF) >>
1194
AR_PHY_9485_ANT_DIV_MAIN_LNACONF_S;
1195
antconf->alt_lna_conf = (regval & AR_PHY_9485_ANT_DIV_ALT_LNACONF) >>
1196
AR_PHY_9485_ANT_DIV_ALT_LNACONF_S;
1197
antconf->fast_div_bias = (regval & AR_PHY_9485_ANT_FAST_DIV_BIAS) >>
1198
AR_PHY_9485_ANT_FAST_DIV_BIAS_S;
1199
antconf->lna1_lna2_delta = -9;
1200
antconf->div_group = 2;
1203
static void ar9003_hw_antdiv_comb_conf_set(struct ath_hw *ah,
1204
struct ath_hw_antcomb_conf *antconf)
1208
regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL);
1209
regval &= ~(AR_PHY_9485_ANT_DIV_MAIN_LNACONF |
1210
AR_PHY_9485_ANT_DIV_ALT_LNACONF |
1211
AR_PHY_9485_ANT_FAST_DIV_BIAS |
1212
AR_PHY_9485_ANT_DIV_MAIN_GAINTB |
1213
AR_PHY_9485_ANT_DIV_ALT_GAINTB);
1214
regval |= ((antconf->main_lna_conf <<
1215
AR_PHY_9485_ANT_DIV_MAIN_LNACONF_S)
1216
& AR_PHY_9485_ANT_DIV_MAIN_LNACONF);
1217
regval |= ((antconf->alt_lna_conf << AR_PHY_9485_ANT_DIV_ALT_LNACONF_S)
1218
& AR_PHY_9485_ANT_DIV_ALT_LNACONF);
1219
regval |= ((antconf->fast_div_bias << AR_PHY_9485_ANT_FAST_DIV_BIAS_S)
1220
& AR_PHY_9485_ANT_FAST_DIV_BIAS);
1221
regval |= ((antconf->main_gaintb << AR_PHY_9485_ANT_DIV_MAIN_GAINTB_S)
1222
& AR_PHY_9485_ANT_DIV_MAIN_GAINTB);
1223
regval |= ((antconf->alt_gaintb << AR_PHY_9485_ANT_DIV_ALT_GAINTB_S)
1224
& AR_PHY_9485_ANT_DIV_ALT_GAINTB);
1226
REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
1162
1229
void ar9003_hw_attach_phy_ops(struct ath_hw *ah)
1164
1231
struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah);
1232
struct ath_hw_ops *ops = ath9k_hw_ops(ah);
1165
1233
static const u32 ar9300_cca_regs[6] = {
1188
1256
priv_ops->ani_cache_ini_regs = ar9003_hw_ani_cache_ini_regs;
1189
1257
priv_ops->set_radar_params = ar9003_hw_set_radar_params;
1259
ops->antdiv_comb_conf_get = ar9003_hw_antdiv_comb_conf_get;
1260
ops->antdiv_comb_conf_set = ar9003_hw_antdiv_comb_conf_set;
1191
1262
ar9003_hw_set_nf_limits(ah);
1192
1263
ar9003_hw_set_radar_conf(ah);
1193
1264
memcpy(ah->nf_regs, ar9300_cca_regs, sizeof(ah->nf_regs));
1310
1381
"==== BB update: done ====\n\n");
1312
1383
EXPORT_SYMBOL(ar9003_hw_bb_watchdog_dbg_info);
1385
void ar9003_hw_disable_phy_restart(struct ath_hw *ah)
1389
/* While receiving unsupported rate frame rx state machine
1390
* gets into a state 0xb and if phy_restart happens in that
1391
* state, BB would go hang. If RXSM is in 0xb state after
1392
* first bb panic, ensure to disable the phy_restart.
1394
if (!((MS(ah->bb_watchdog_last_status,
1395
AR_PHY_WATCHDOG_RX_OFDM_SM) == 0xb) ||
1396
ah->bb_hang_rx_ofdm))
1399
ah->bb_hang_rx_ofdm = true;
1400
val = REG_READ(ah, AR_PHY_RESTART);
1401
val &= ~AR_PHY_RESTART_ENA;
1403
REG_WRITE(ah, AR_PHY_RESTART, val);
1405
EXPORT_SYMBOL(ar9003_hw_disable_phy_restart);