aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorRafał Miłecki <zajec5@gmail.com>2010-10-14 13:33:34 -0400
committerJohn W. Linville <linville@tuxdriver.com>2010-10-15 15:57:36 -0400
commit204a665ba390bca861ad7b1a061f3ccded0e7eab (patch)
treeca5c39321bdeaa7473e427a9805664c7d94947c0 /drivers/net
parent9ebad4ab87f2ffa6eca825327721e647c7457264 (diff)
b43: N-PHY: replace N-specific radio_chanspec with common code
Signed-off-by: Rafał Miłecki <zajec5@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/b43/phy_common.h1
-rw-r--r--drivers/net/wireless/b43/phy_n.c55
-rw-r--r--drivers/net/wireless/b43/phy_n.h7
3 files changed, 26 insertions, 37 deletions
diff --git a/drivers/net/wireless/b43/phy_common.h b/drivers/net/wireless/b43/phy_common.h
index 6dcd0334ed02..0e6194228845 100644
--- a/drivers/net/wireless/b43/phy_common.h
+++ b/drivers/net/wireless/b43/phy_common.h
@@ -253,6 +253,7 @@ struct b43_phy {
253 253
254 /* Current channel */ 254 /* Current channel */
255 unsigned int channel; 255 unsigned int channel;
256 u16 channel_freq;
256 enum nl80211_channel_type channel_type; 257 enum nl80211_channel_type channel_type;
257 258
258 /* PHY TX errors counter. */ 259 /* PHY TX errors counter. */
diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index e532901246b6..3ade0191f319 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -81,21 +81,6 @@ static inline bool b43_channel_type_is_40mhz(
81 channel_type == NL80211_CHAN_HT40PLUS); 81 channel_type == NL80211_CHAN_HT40PLUS);
82} 82}
83 83
84static inline bool b43_empty_chanspec(struct b43_chanspec *chanspec)
85{
86 return !chanspec->channel && !chanspec->sideband &&
87 !chanspec->b_width && !chanspec->b_freq;
88}
89
90static inline bool b43_eq_chanspecs(struct b43_chanspec *chanspec1,
91 struct b43_chanspec *chanspec2)
92{
93 return (chanspec1->channel == chanspec2->channel &&
94 chanspec1->sideband == chanspec2->sideband &&
95 chanspec1->b_width == chanspec2->b_width &&
96 chanspec1->b_freq == chanspec2->b_freq);
97}
98
99void b43_nphy_set_rxantenna(struct b43_wldev *dev, int antenna) 84void b43_nphy_set_rxantenna(struct b43_wldev *dev, int antenna)
100{//TODO 85{//TODO
101} 86}
@@ -788,7 +773,7 @@ static void b43_nphy_spur_workaround(struct b43_wldev *dev)
788{ 773{
789 struct b43_phy_n *nphy = dev->phy.n; 774 struct b43_phy_n *nphy = dev->phy.n;
790 775
791 u8 channel = nphy->radio_chanspec.channel; 776 u8 channel = dev->phy.channel;
792 int tone[2] = { 57, 58 }; 777 int tone[2] = { 57, 58 };
793 u32 noise[2] = { 0x3FF, 0x3FF }; 778 u32 noise[2] = { 0x3FF, 0x3FF };
794 779
@@ -862,9 +847,9 @@ static void b43_nphy_adjust_lna_gain_table(struct b43_wldev *dev)
862 gain[0] = 6; 847 gain[0] = 6;
863 gain[1] = 6; 848 gain[1] = 6;
864 } else { 849 } else {
865 tmp = 40370 - 315 * nphy->radio_chanspec.channel; 850 tmp = 40370 - 315 * dev->phy.channel;
866 gain[0] = ((tmp >> 13) + ((tmp >> 12) & 1)); 851 gain[0] = ((tmp >> 13) + ((tmp >> 12) & 1));
867 tmp = 23242 - 224 * nphy->radio_chanspec.channel; 852 tmp = 23242 - 224 * dev->phy.channel;
868 gain[1] = ((tmp >> 13) + ((tmp >> 12) & 1)); 853 gain[1] = ((tmp >> 13) + ((tmp >> 12) & 1));
869 } 854 }
870 } else { 855 } else {
@@ -2090,12 +2075,12 @@ static void b43_nphy_restore_rssi_cal(struct b43_wldev *dev)
2090 u16 *rssical_phy_regs = NULL; 2075 u16 *rssical_phy_regs = NULL;
2091 2076
2092 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) { 2077 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) {
2093 if (b43_empty_chanspec(&nphy->rssical_chanspec_2G)) 2078 if (!nphy->rssical_chanspec_2G.center_freq)
2094 return; 2079 return;
2095 rssical_radio_regs = nphy->rssical_cache.rssical_radio_regs_2G; 2080 rssical_radio_regs = nphy->rssical_cache.rssical_radio_regs_2G;
2096 rssical_phy_regs = nphy->rssical_cache.rssical_phy_regs_2G; 2081 rssical_phy_regs = nphy->rssical_cache.rssical_phy_regs_2G;
2097 } else { 2082 } else {
2098 if (b43_empty_chanspec(&nphy->rssical_chanspec_5G)) 2083 if (!nphy->rssical_chanspec_5G.center_freq)
2099 return; 2084 return;
2100 rssical_radio_regs = nphy->rssical_cache.rssical_radio_regs_5G; 2085 rssical_radio_regs = nphy->rssical_cache.rssical_radio_regs_5G;
2101 rssical_phy_regs = nphy->rssical_cache.rssical_phy_regs_5G; 2086 rssical_phy_regs = nphy->rssical_cache.rssical_phy_regs_5G;
@@ -2551,7 +2536,8 @@ static void b43_nphy_save_cal(struct b43_wldev *dev)
2551 txcal_radio_regs[2] = b43_radio_read(dev, 0x8D); 2536 txcal_radio_regs[2] = b43_radio_read(dev, 0x8D);
2552 txcal_radio_regs[3] = b43_radio_read(dev, 0xBC); 2537 txcal_radio_regs[3] = b43_radio_read(dev, 0xBC);
2553 } 2538 }
2554 *iqcal_chanspec = nphy->radio_chanspec; 2539 iqcal_chanspec->center_freq = dev->phy.channel_freq;
2540 iqcal_chanspec->channel_type = dev->phy.channel_type;
2555 b43_ntab_write_bulk(dev, B43_NTAB16(15, 80), 8, table); 2541 b43_ntab_write_bulk(dev, B43_NTAB16(15, 80), 8, table);
2556 2542
2557 if (nphy->hang_avoid) 2543 if (nphy->hang_avoid)
@@ -2572,12 +2558,12 @@ static void b43_nphy_restore_cal(struct b43_wldev *dev)
2572 struct b43_phy_n_iq_comp *rxcal_coeffs = NULL; 2558 struct b43_phy_n_iq_comp *rxcal_coeffs = NULL;
2573 2559
2574 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) { 2560 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) {
2575 if (b43_empty_chanspec(&nphy->iqcal_chanspec_2G)) 2561 if (!nphy->iqcal_chanspec_2G.center_freq)
2576 return; 2562 return;
2577 table = nphy->cal_cache.txcal_coeffs_2G; 2563 table = nphy->cal_cache.txcal_coeffs_2G;
2578 loft = &nphy->cal_cache.txcal_coeffs_2G[5]; 2564 loft = &nphy->cal_cache.txcal_coeffs_2G[5];
2579 } else { 2565 } else {
2580 if (b43_empty_chanspec(&nphy->iqcal_chanspec_5G)) 2566 if (!nphy->iqcal_chanspec_5G.center_freq)
2581 return; 2567 return;
2582 table = nphy->cal_cache.txcal_coeffs_5G; 2568 table = nphy->cal_cache.txcal_coeffs_5G;
2583 loft = &nphy->cal_cache.txcal_coeffs_5G[5]; 2569 loft = &nphy->cal_cache.txcal_coeffs_5G[5];
@@ -2822,7 +2808,10 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev,
2822 b43_ntab_read_bulk(dev, B43_NTAB16(15, 96), length, 2808 b43_ntab_read_bulk(dev, B43_NTAB16(15, 96), length,
2823 nphy->txiqlocal_bestc); 2809 nphy->txiqlocal_bestc);
2824 nphy->txiqlocal_coeffsvalid = true; 2810 nphy->txiqlocal_coeffsvalid = true;
2825 nphy->txiqlocal_chanspec = nphy->radio_chanspec; 2811 nphy->txiqlocal_chanspec.center_freq =
2812 dev->phy.channel_freq;
2813 nphy->txiqlocal_chanspec.channel_type =
2814 dev->phy.channel_type;
2826 } else { 2815 } else {
2827 length = 11; 2816 length = 11;
2828 if (dev->phy.rev < 3) 2817 if (dev->phy.rev < 3)
@@ -2858,7 +2847,8 @@ static void b43_nphy_reapply_tx_cal_coeffs(struct b43_wldev *dev)
2858 bool equal = true; 2847 bool equal = true;
2859 2848
2860 if (!nphy->txiqlocal_coeffsvalid || 2849 if (!nphy->txiqlocal_coeffsvalid ||
2861 b43_eq_chanspecs(&nphy->txiqlocal_chanspec, &nphy->radio_chanspec)) 2850 nphy->txiqlocal_chanspec.center_freq != dev->phy.channel_freq ||
2851 nphy->txiqlocal_chanspec.channel_type != dev->phy.channel_type)
2862 return; 2852 return;
2863 2853
2864 b43_ntab_read_bulk(dev, B43_NTAB16(15, 80), 7, buffer); 2854 b43_ntab_read_bulk(dev, B43_NTAB16(15, 80), 7, buffer);
@@ -3264,11 +3254,9 @@ int b43_phy_initn(struct b43_wldev *dev)
3264 do_rssi_cal = false; 3254 do_rssi_cal = false;
3265 if (phy->rev >= 3) { 3255 if (phy->rev >= 3) {
3266 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) 3256 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ)
3267 do_rssi_cal = 3257 do_rssi_cal = !nphy->rssical_chanspec_2G.center_freq;
3268 b43_empty_chanspec(&nphy->rssical_chanspec_2G);
3269 else 3258 else
3270 do_rssi_cal = 3259 do_rssi_cal = !nphy->rssical_chanspec_5G.center_freq;
3271 b43_empty_chanspec(&nphy->rssical_chanspec_5G);
3272 3260
3273 if (do_rssi_cal) 3261 if (do_rssi_cal)
3274 b43_nphy_rssi_cal(dev); 3262 b43_nphy_rssi_cal(dev);
@@ -3280,9 +3268,9 @@ int b43_phy_initn(struct b43_wldev *dev)
3280 3268
3281 if (!((nphy->measure_hold & 0x6) != 0)) { 3269 if (!((nphy->measure_hold & 0x6) != 0)) {
3282 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) 3270 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ)
3283 do_cal = b43_empty_chanspec(&nphy->iqcal_chanspec_2G); 3271 do_cal = !nphy->iqcal_chanspec_2G.center_freq;
3284 else 3272 else
3285 do_cal = b43_empty_chanspec(&nphy->iqcal_chanspec_5G); 3273 do_cal = !nphy->iqcal_chanspec_5G.center_freq;
3286 3274
3287 if (nphy->mute) 3275 if (nphy->mute)
3288 do_cal = false; 3276 do_cal = false;
@@ -3411,7 +3399,10 @@ static int b43_nphy_set_channel(struct b43_wldev *dev,
3411 return -ESRCH; 3399 return -ESRCH;
3412 } 3400 }
3413 3401
3414 nphy->radio_chanspec.channel = channel->hw_value; 3402 /* Channel is set later in common code, but we need to set it on our
3403 own to let this function's subcalls work properly. */
3404 phy->channel = channel->hw_value;
3405 phy->channel_freq = channel->center_freq;
3415 3406
3416 if (b43_channel_type_is_40mhz(phy->channel_type) != 3407 if (b43_channel_type_is_40mhz(phy->channel_type) !=
3417 b43_channel_type_is_40mhz(channel_type)) 3408 b43_channel_type_is_40mhz(channel_type))
diff --git a/drivers/net/wireless/b43/phy_n.h b/drivers/net/wireless/b43/phy_n.h
index e7acae278be0..f915c83b46d7 100644
--- a/drivers/net/wireless/b43/phy_n.h
+++ b/drivers/net/wireless/b43/phy_n.h
@@ -927,10 +927,8 @@
927struct b43_wldev; 927struct b43_wldev;
928 928
929struct b43_chanspec { 929struct b43_chanspec {
930 u8 channel; 930 u16 center_freq;
931 u8 sideband; 931 enum nl80211_channel_type channel_type;
932 u8 b_width;
933 u8 b_freq;
934}; 932};
935 933
936struct b43_phy_n_iq_comp { 934struct b43_phy_n_iq_comp {
@@ -984,7 +982,6 @@ struct b43_phy_n {
984 u16 papd_epsilon_offset[2]; 982 u16 papd_epsilon_offset[2];
985 s32 preamble_override; 983 s32 preamble_override;
986 u32 bb_mult_save; 984 u32 bb_mult_save;
987 struct b43_chanspec radio_chanspec;
988 985
989 bool gain_boost; 986 bool gain_boost;
990 bool elna_gain_config; 987 bool elna_gain_config;