diff options
author | Luis R. Rodriguez <lrodriguez@atheros.com> | 2009-01-22 18:16:48 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-01-29 16:01:20 -0500 |
commit | 5f8e077c0adc0dc7cfad64cdc05276e1961a1394 (patch) | |
tree | dc918d9eacab12998d8e67f259de32dbbb409e81 /drivers/net/wireless/ath9k/hw.c | |
parent | 24ed1da1337b92e3b0a89f2c2b7cd33b9a8fcb62 (diff) |
ath9k: simplify regulatory code
Now that cfg80211 has its own regulatory infrastructure we can
condense ath9k's regulatory code considerably. We only keep data
we need to provide our own regulatory_hint(), reg_notifier() and
information necessary for calibration.
Atheros hardware supports 12 world regulatory domains, since these
are custom we apply them through the the new wiphy_apply_custom_regulatory().
Although we have 12 we can consolidate these into 5 structures based on
frequency and apply a different set of flags that differentiate them on
a case by case basis through the reg_notifier().
If CRDA is not found our own custom world regulatory domain is applied,
this is identical to cfg80211's except we enable passive scan on most
frequencies.
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath9k/hw.c')
-rw-r--r-- | drivers/net/wireless/ath9k/hw.c | 63 |
1 files changed, 9 insertions, 54 deletions
diff --git a/drivers/net/wireless/ath9k/hw.c b/drivers/net/wireless/ath9k/hw.c index 65e0d80f3b4d..f2922bab7761 100644 --- a/drivers/net/wireless/ath9k/hw.c +++ b/drivers/net/wireless/ath9k/hw.c | |||
@@ -187,46 +187,6 @@ u16 ath9k_hw_computetxtime(struct ath_hal *ah, | |||
187 | return txTime; | 187 | return txTime; |
188 | } | 188 | } |
189 | 189 | ||
190 | u32 ath9k_hw_mhz2ieee(struct ath_hal *ah, u32 freq, u32 flags) | ||
191 | { | ||
192 | if (flags & CHANNEL_2GHZ) { | ||
193 | if (freq == 2484) | ||
194 | return 14; | ||
195 | if (freq < 2484) | ||
196 | return (freq - 2407) / 5; | ||
197 | else | ||
198 | return 15 + ((freq - 2512) / 20); | ||
199 | } else if (flags & CHANNEL_5GHZ) { | ||
200 | if (ath9k_regd_is_public_safety_sku(ah) && | ||
201 | IS_CHAN_IN_PUBLIC_SAFETY_BAND(freq)) { | ||
202 | return ((freq * 10) + | ||
203 | (((freq % 5) == 2) ? 5 : 0) - 49400) / 5; | ||
204 | } else if ((flags & CHANNEL_A) && (freq <= 5000)) { | ||
205 | return (freq - 4000) / 5; | ||
206 | } else { | ||
207 | return (freq - 5000) / 5; | ||
208 | } | ||
209 | } else { | ||
210 | if (freq == 2484) | ||
211 | return 14; | ||
212 | if (freq < 2484) | ||
213 | return (freq - 2407) / 5; | ||
214 | if (freq < 5000) { | ||
215 | if (ath9k_regd_is_public_safety_sku(ah) | ||
216 | && IS_CHAN_IN_PUBLIC_SAFETY_BAND(freq)) { | ||
217 | return ((freq * 10) + | ||
218 | (((freq % 5) == | ||
219 | 2) ? 5 : 0) - 49400) / 5; | ||
220 | } else if (freq > 4900) { | ||
221 | return (freq - 4000) / 5; | ||
222 | } else { | ||
223 | return 15 + ((freq - 2512) / 20); | ||
224 | } | ||
225 | } | ||
226 | return (freq - 5000) / 5; | ||
227 | } | ||
228 | } | ||
229 | |||
230 | void ath9k_hw_get_channel_centers(struct ath_hal *ah, | 190 | void ath9k_hw_get_channel_centers(struct ath_hal *ah, |
231 | struct ath9k_channel *chan, | 191 | struct ath9k_channel *chan, |
232 | struct chan_centers *centers) | 192 | struct chan_centers *centers) |
@@ -1270,6 +1230,7 @@ static int ath9k_hw_process_ini(struct ath_hal *ah, | |||
1270 | { | 1230 | { |
1271 | int i, regWrites = 0; | 1231 | int i, regWrites = 0; |
1272 | struct ath_hal_5416 *ahp = AH5416(ah); | 1232 | struct ath_hal_5416 *ahp = AH5416(ah); |
1233 | struct ieee80211_channel *channel = chan->chan; | ||
1273 | u32 modesIndex, freqIndex; | 1234 | u32 modesIndex, freqIndex; |
1274 | int status; | 1235 | int status; |
1275 | 1236 | ||
@@ -1374,9 +1335,8 @@ static int ath9k_hw_process_ini(struct ath_hal *ah, | |||
1374 | 1335 | ||
1375 | status = ath9k_hw_set_txpower(ah, chan, | 1336 | status = ath9k_hw_set_txpower(ah, chan, |
1376 | ath9k_regd_get_ctl(ah, chan), | 1337 | ath9k_regd_get_ctl(ah, chan), |
1377 | ath9k_regd_get_antenna_allowed(ah, | 1338 | channel->max_antenna_gain * 2, |
1378 | chan), | 1339 | channel->max_power * 2, |
1379 | chan->maxRegTxPower * 2, | ||
1380 | min((u32) MAX_RATE_POWER, | 1340 | min((u32) MAX_RATE_POWER, |
1381 | (u32) ah->ah_powerLimit)); | 1341 | (u32) ah->ah_powerLimit)); |
1382 | if (status != 0) { | 1342 | if (status != 0) { |
@@ -1669,6 +1629,7 @@ static bool ath9k_hw_channel_change(struct ath_hal *ah, | |||
1669 | struct ath9k_channel *chan, | 1629 | struct ath9k_channel *chan, |
1670 | enum ath9k_ht_macmode macmode) | 1630 | enum ath9k_ht_macmode macmode) |
1671 | { | 1631 | { |
1632 | struct ieee80211_channel *channel = chan->chan; | ||
1672 | u32 synthDelay, qnum; | 1633 | u32 synthDelay, qnum; |
1673 | 1634 | ||
1674 | for (qnum = 0; qnum < AR_NUM_QCU; qnum++) { | 1635 | for (qnum = 0; qnum < AR_NUM_QCU; qnum++) { |
@@ -1705,8 +1666,8 @@ static bool ath9k_hw_channel_change(struct ath_hal *ah, | |||
1705 | 1666 | ||
1706 | if (ath9k_hw_set_txpower(ah, chan, | 1667 | if (ath9k_hw_set_txpower(ah, chan, |
1707 | ath9k_regd_get_ctl(ah, chan), | 1668 | ath9k_regd_get_ctl(ah, chan), |
1708 | ath9k_regd_get_antenna_allowed(ah, chan), | 1669 | channel->max_antenna_gain * 2, |
1709 | chan->maxRegTxPower * 2, | 1670 | channel->max_power * 2, |
1710 | min((u32) MAX_RATE_POWER, | 1671 | min((u32) MAX_RATE_POWER, |
1711 | (u32) ah->ah_powerLimit)) != 0) { | 1672 | (u32) ah->ah_powerLimit)) != 0) { |
1712 | DPRINTF(ah->ah_sc, ATH_DBG_EEPROM, | 1673 | DPRINTF(ah->ah_sc, ATH_DBG_EEPROM, |
@@ -2209,13 +2170,6 @@ int ath9k_hw_reset(struct ath_hal *ah, struct ath9k_channel *chan, | |||
2209 | ahp->ah_rxchainmask &= 0x3; | 2170 | ahp->ah_rxchainmask &= 0x3; |
2210 | } | 2171 | } |
2211 | 2172 | ||
2212 | if (ath9k_regd_check_channel(ah, chan) == NULL) { | ||
2213 | DPRINTF(ah->ah_sc, ATH_DBG_CHANNEL, | ||
2214 | "invalid channel %u/0x%x; no mapping\n", | ||
2215 | chan->channel, chan->channelFlags); | ||
2216 | return -EINVAL; | ||
2217 | } | ||
2218 | |||
2219 | if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE)) | 2173 | if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE)) |
2220 | return -EIO; | 2174 | return -EIO; |
2221 | 2175 | ||
@@ -3718,13 +3672,14 @@ bool ath9k_hw_disable(struct ath_hal *ah) | |||
3718 | bool ath9k_hw_set_txpowerlimit(struct ath_hal *ah, u32 limit) | 3672 | bool ath9k_hw_set_txpowerlimit(struct ath_hal *ah, u32 limit) |
3719 | { | 3673 | { |
3720 | struct ath9k_channel *chan = ah->ah_curchan; | 3674 | struct ath9k_channel *chan = ah->ah_curchan; |
3675 | struct ieee80211_channel *channel = chan->chan; | ||
3721 | 3676 | ||
3722 | ah->ah_powerLimit = min(limit, (u32) MAX_RATE_POWER); | 3677 | ah->ah_powerLimit = min(limit, (u32) MAX_RATE_POWER); |
3723 | 3678 | ||
3724 | if (ath9k_hw_set_txpower(ah, chan, | 3679 | if (ath9k_hw_set_txpower(ah, chan, |
3725 | ath9k_regd_get_ctl(ah, chan), | 3680 | ath9k_regd_get_ctl(ah, chan), |
3726 | ath9k_regd_get_antenna_allowed(ah, chan), | 3681 | channel->max_antenna_gain * 2, |
3727 | chan->maxRegTxPower * 2, | 3682 | channel->max_power * 2, |
3728 | min((u32) MAX_RATE_POWER, | 3683 | min((u32) MAX_RATE_POWER, |
3729 | (u32) ah->ah_powerLimit)) != 0) | 3684 | (u32) ah->ah_powerLimit)) != 0) |
3730 | return false; | 3685 | return false; |