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>
This commit is contained in:
parent
9ebad4ab87
commit
204a665ba3
|
@ -253,6 +253,7 @@ struct b43_phy {
|
||||||
|
|
||||||
/* Current channel */
|
/* Current channel */
|
||||||
unsigned int channel;
|
unsigned int channel;
|
||||||
|
u16 channel_freq;
|
||||||
enum nl80211_channel_type channel_type;
|
enum nl80211_channel_type channel_type;
|
||||||
|
|
||||||
/* PHY TX errors counter. */
|
/* PHY TX errors counter. */
|
||||||
|
|
|
@ -81,21 +81,6 @@ static inline bool b43_channel_type_is_40mhz(
|
||||||
channel_type == NL80211_CHAN_HT40PLUS);
|
channel_type == NL80211_CHAN_HT40PLUS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool b43_empty_chanspec(struct b43_chanspec *chanspec)
|
|
||||||
{
|
|
||||||
return !chanspec->channel && !chanspec->sideband &&
|
|
||||||
!chanspec->b_width && !chanspec->b_freq;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool b43_eq_chanspecs(struct b43_chanspec *chanspec1,
|
|
||||||
struct b43_chanspec *chanspec2)
|
|
||||||
{
|
|
||||||
return (chanspec1->channel == chanspec2->channel &&
|
|
||||||
chanspec1->sideband == chanspec2->sideband &&
|
|
||||||
chanspec1->b_width == chanspec2->b_width &&
|
|
||||||
chanspec1->b_freq == chanspec2->b_freq);
|
|
||||||
}
|
|
||||||
|
|
||||||
void b43_nphy_set_rxantenna(struct b43_wldev *dev, int antenna)
|
void b43_nphy_set_rxantenna(struct b43_wldev *dev, int antenna)
|
||||||
{//TODO
|
{//TODO
|
||||||
}
|
}
|
||||||
|
@ -788,7 +773,7 @@ static void b43_nphy_spur_workaround(struct b43_wldev *dev)
|
||||||
{
|
{
|
||||||
struct b43_phy_n *nphy = dev->phy.n;
|
struct b43_phy_n *nphy = dev->phy.n;
|
||||||
|
|
||||||
u8 channel = nphy->radio_chanspec.channel;
|
u8 channel = dev->phy.channel;
|
||||||
int tone[2] = { 57, 58 };
|
int tone[2] = { 57, 58 };
|
||||||
u32 noise[2] = { 0x3FF, 0x3FF };
|
u32 noise[2] = { 0x3FF, 0x3FF };
|
||||||
|
|
||||||
|
@ -862,9 +847,9 @@ static void b43_nphy_adjust_lna_gain_table(struct b43_wldev *dev)
|
||||||
gain[0] = 6;
|
gain[0] = 6;
|
||||||
gain[1] = 6;
|
gain[1] = 6;
|
||||||
} else {
|
} else {
|
||||||
tmp = 40370 - 315 * nphy->radio_chanspec.channel;
|
tmp = 40370 - 315 * dev->phy.channel;
|
||||||
gain[0] = ((tmp >> 13) + ((tmp >> 12) & 1));
|
gain[0] = ((tmp >> 13) + ((tmp >> 12) & 1));
|
||||||
tmp = 23242 - 224 * nphy->radio_chanspec.channel;
|
tmp = 23242 - 224 * dev->phy.channel;
|
||||||
gain[1] = ((tmp >> 13) + ((tmp >> 12) & 1));
|
gain[1] = ((tmp >> 13) + ((tmp >> 12) & 1));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -2090,12 +2075,12 @@ static void b43_nphy_restore_rssi_cal(struct b43_wldev *dev)
|
||||||
u16 *rssical_phy_regs = NULL;
|
u16 *rssical_phy_regs = NULL;
|
||||||
|
|
||||||
if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) {
|
if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) {
|
||||||
if (b43_empty_chanspec(&nphy->rssical_chanspec_2G))
|
if (!nphy->rssical_chanspec_2G.center_freq)
|
||||||
return;
|
return;
|
||||||
rssical_radio_regs = nphy->rssical_cache.rssical_radio_regs_2G;
|
rssical_radio_regs = nphy->rssical_cache.rssical_radio_regs_2G;
|
||||||
rssical_phy_regs = nphy->rssical_cache.rssical_phy_regs_2G;
|
rssical_phy_regs = nphy->rssical_cache.rssical_phy_regs_2G;
|
||||||
} else {
|
} else {
|
||||||
if (b43_empty_chanspec(&nphy->rssical_chanspec_5G))
|
if (!nphy->rssical_chanspec_5G.center_freq)
|
||||||
return;
|
return;
|
||||||
rssical_radio_regs = nphy->rssical_cache.rssical_radio_regs_5G;
|
rssical_radio_regs = nphy->rssical_cache.rssical_radio_regs_5G;
|
||||||
rssical_phy_regs = nphy->rssical_cache.rssical_phy_regs_5G;
|
rssical_phy_regs = nphy->rssical_cache.rssical_phy_regs_5G;
|
||||||
|
@ -2551,7 +2536,8 @@ static void b43_nphy_save_cal(struct b43_wldev *dev)
|
||||||
txcal_radio_regs[2] = b43_radio_read(dev, 0x8D);
|
txcal_radio_regs[2] = b43_radio_read(dev, 0x8D);
|
||||||
txcal_radio_regs[3] = b43_radio_read(dev, 0xBC);
|
txcal_radio_regs[3] = b43_radio_read(dev, 0xBC);
|
||||||
}
|
}
|
||||||
*iqcal_chanspec = nphy->radio_chanspec;
|
iqcal_chanspec->center_freq = dev->phy.channel_freq;
|
||||||
|
iqcal_chanspec->channel_type = dev->phy.channel_type;
|
||||||
b43_ntab_write_bulk(dev, B43_NTAB16(15, 80), 8, table);
|
b43_ntab_write_bulk(dev, B43_NTAB16(15, 80), 8, table);
|
||||||
|
|
||||||
if (nphy->hang_avoid)
|
if (nphy->hang_avoid)
|
||||||
|
@ -2572,12 +2558,12 @@ static void b43_nphy_restore_cal(struct b43_wldev *dev)
|
||||||
struct b43_phy_n_iq_comp *rxcal_coeffs = NULL;
|
struct b43_phy_n_iq_comp *rxcal_coeffs = NULL;
|
||||||
|
|
||||||
if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) {
|
if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) {
|
||||||
if (b43_empty_chanspec(&nphy->iqcal_chanspec_2G))
|
if (!nphy->iqcal_chanspec_2G.center_freq)
|
||||||
return;
|
return;
|
||||||
table = nphy->cal_cache.txcal_coeffs_2G;
|
table = nphy->cal_cache.txcal_coeffs_2G;
|
||||||
loft = &nphy->cal_cache.txcal_coeffs_2G[5];
|
loft = &nphy->cal_cache.txcal_coeffs_2G[5];
|
||||||
} else {
|
} else {
|
||||||
if (b43_empty_chanspec(&nphy->iqcal_chanspec_5G))
|
if (!nphy->iqcal_chanspec_5G.center_freq)
|
||||||
return;
|
return;
|
||||||
table = nphy->cal_cache.txcal_coeffs_5G;
|
table = nphy->cal_cache.txcal_coeffs_5G;
|
||||||
loft = &nphy->cal_cache.txcal_coeffs_5G[5];
|
loft = &nphy->cal_cache.txcal_coeffs_5G[5];
|
||||||
|
@ -2822,7 +2808,10 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev,
|
||||||
b43_ntab_read_bulk(dev, B43_NTAB16(15, 96), length,
|
b43_ntab_read_bulk(dev, B43_NTAB16(15, 96), length,
|
||||||
nphy->txiqlocal_bestc);
|
nphy->txiqlocal_bestc);
|
||||||
nphy->txiqlocal_coeffsvalid = true;
|
nphy->txiqlocal_coeffsvalid = true;
|
||||||
nphy->txiqlocal_chanspec = nphy->radio_chanspec;
|
nphy->txiqlocal_chanspec.center_freq =
|
||||||
|
dev->phy.channel_freq;
|
||||||
|
nphy->txiqlocal_chanspec.channel_type =
|
||||||
|
dev->phy.channel_type;
|
||||||
} else {
|
} else {
|
||||||
length = 11;
|
length = 11;
|
||||||
if (dev->phy.rev < 3)
|
if (dev->phy.rev < 3)
|
||||||
|
@ -2858,7 +2847,8 @@ static void b43_nphy_reapply_tx_cal_coeffs(struct b43_wldev *dev)
|
||||||
bool equal = true;
|
bool equal = true;
|
||||||
|
|
||||||
if (!nphy->txiqlocal_coeffsvalid ||
|
if (!nphy->txiqlocal_coeffsvalid ||
|
||||||
b43_eq_chanspecs(&nphy->txiqlocal_chanspec, &nphy->radio_chanspec))
|
nphy->txiqlocal_chanspec.center_freq != dev->phy.channel_freq ||
|
||||||
|
nphy->txiqlocal_chanspec.channel_type != dev->phy.channel_type)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
b43_ntab_read_bulk(dev, B43_NTAB16(15, 80), 7, buffer);
|
b43_ntab_read_bulk(dev, B43_NTAB16(15, 80), 7, buffer);
|
||||||
|
@ -3264,11 +3254,9 @@ int b43_phy_initn(struct b43_wldev *dev)
|
||||||
do_rssi_cal = false;
|
do_rssi_cal = false;
|
||||||
if (phy->rev >= 3) {
|
if (phy->rev >= 3) {
|
||||||
if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ)
|
if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ)
|
||||||
do_rssi_cal =
|
do_rssi_cal = !nphy->rssical_chanspec_2G.center_freq;
|
||||||
b43_empty_chanspec(&nphy->rssical_chanspec_2G);
|
|
||||||
else
|
else
|
||||||
do_rssi_cal =
|
do_rssi_cal = !nphy->rssical_chanspec_5G.center_freq;
|
||||||
b43_empty_chanspec(&nphy->rssical_chanspec_5G);
|
|
||||||
|
|
||||||
if (do_rssi_cal)
|
if (do_rssi_cal)
|
||||||
b43_nphy_rssi_cal(dev);
|
b43_nphy_rssi_cal(dev);
|
||||||
|
@ -3280,9 +3268,9 @@ int b43_phy_initn(struct b43_wldev *dev)
|
||||||
|
|
||||||
if (!((nphy->measure_hold & 0x6) != 0)) {
|
if (!((nphy->measure_hold & 0x6) != 0)) {
|
||||||
if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ)
|
if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ)
|
||||||
do_cal = b43_empty_chanspec(&nphy->iqcal_chanspec_2G);
|
do_cal = !nphy->iqcal_chanspec_2G.center_freq;
|
||||||
else
|
else
|
||||||
do_cal = b43_empty_chanspec(&nphy->iqcal_chanspec_5G);
|
do_cal = !nphy->iqcal_chanspec_5G.center_freq;
|
||||||
|
|
||||||
if (nphy->mute)
|
if (nphy->mute)
|
||||||
do_cal = false;
|
do_cal = false;
|
||||||
|
@ -3411,7 +3399,10 @@ static int b43_nphy_set_channel(struct b43_wldev *dev,
|
||||||
return -ESRCH;
|
return -ESRCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
nphy->radio_chanspec.channel = channel->hw_value;
|
/* Channel is set later in common code, but we need to set it on our
|
||||||
|
own to let this function's subcalls work properly. */
|
||||||
|
phy->channel = channel->hw_value;
|
||||||
|
phy->channel_freq = channel->center_freq;
|
||||||
|
|
||||||
if (b43_channel_type_is_40mhz(phy->channel_type) !=
|
if (b43_channel_type_is_40mhz(phy->channel_type) !=
|
||||||
b43_channel_type_is_40mhz(channel_type))
|
b43_channel_type_is_40mhz(channel_type))
|
||||||
|
|
|
@ -927,10 +927,8 @@
|
||||||
struct b43_wldev;
|
struct b43_wldev;
|
||||||
|
|
||||||
struct b43_chanspec {
|
struct b43_chanspec {
|
||||||
u8 channel;
|
u16 center_freq;
|
||||||
u8 sideband;
|
enum nl80211_channel_type channel_type;
|
||||||
u8 b_width;
|
|
||||||
u8 b_freq;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct b43_phy_n_iq_comp {
|
struct b43_phy_n_iq_comp {
|
||||||
|
@ -984,7 +982,6 @@ struct b43_phy_n {
|
||||||
u16 papd_epsilon_offset[2];
|
u16 papd_epsilon_offset[2];
|
||||||
s32 preamble_override;
|
s32 preamble_override;
|
||||||
u32 bb_mult_save;
|
u32 bb_mult_save;
|
||||||
struct b43_chanspec radio_chanspec;
|
|
||||||
|
|
||||||
bool gain_boost;
|
bool gain_boost;
|
||||||
bool elna_gain_config;
|
bool elna_gain_config;
|
||||||
|
|
Loading…
Reference in New Issue