1 /*
2 * Copyright (c) 2009-2011 Atheros Communications Inc.
3 *
4 * Modified for iPXE by Scott K Logan <logans@cottsay.net> July 2011
5 * Original from Linux kernel 3.0.1
6 *
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
20 /*
21 * Module for common driver code between ath9k and ath9k_htc
22 */
23
24 #include "common.h"
25
26 /*
27 * Update internal channel flags.
28 */
ath9k_cmn_update_ichannel(struct ath9k_channel * ichan,struct net80211_channel * chan)29 void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan,
30 struct net80211_channel *chan)
31 {
32 ichan->channel = chan->center_freq;
33 ichan->chan = chan;
34
35 if (chan->band == NET80211_BAND_2GHZ) {
36 ichan->chanmode = CHANNEL_G;
37 ichan->channelFlags = CHANNEL_2GHZ | CHANNEL_OFDM;
38 } else {
39 ichan->chanmode = CHANNEL_A;
40 ichan->channelFlags = CHANNEL_5GHZ | CHANNEL_OFDM;
41 }
42 }
43
44 /*
45 * Get the internal channel reference.
46 */
ath9k_cmn_get_curchannel(struct net80211_device * dev,struct ath_hw * ah)47 struct ath9k_channel *ath9k_cmn_get_curchannel(struct net80211_device *dev,
48 struct ath_hw *ah)
49 {
50 struct net80211_channel *curchan = dev->channels + dev->channel;
51 struct ath9k_channel *channel;
52 u8 chan_idx;
53
54 chan_idx = curchan->hw_value;
55 channel = &ah->channels[chan_idx];
56 ath9k_cmn_update_ichannel(channel, curchan);
57
58 return channel;
59 }
60
ath9k_cmn_update_txpow(struct ath_hw * ah,u16 cur_txpow,u16 new_txpow,u16 * txpower)61 void ath9k_cmn_update_txpow(struct ath_hw *ah, u16 cur_txpow,
62 u16 new_txpow, u16 *txpower)
63 {
64 if (cur_txpow != new_txpow) {
65 ath9k_hw_set_txpowerlimit(ah, new_txpow, 0);
66 /* read back in case value is clamped */
67 *txpower = ath9k_hw_regulatory(ah)->power_limit;
68 }
69 }
70