Commit c206a39d authored by Gábor Stefanik's avatar Gábor Stefanik Committed by John W. Linville

b43: Refactor and update antenna diversity for A/G-PHY

-Make use of the b43_phy_set/mask/maskset helpers.
-Fix a few errors in the code.
-Make the code more readable.
Signed-off-by: default avatarGábor Stefanik <netrolller.3d@gmail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent af472a95
...@@ -518,58 +518,40 @@ static unsigned int b43_aphy_op_get_default_chan(struct b43_wldev *dev) ...@@ -518,58 +518,40 @@ static unsigned int b43_aphy_op_get_default_chan(struct b43_wldev *dev)
static void b43_aphy_op_set_rx_antenna(struct b43_wldev *dev, int antenna) static void b43_aphy_op_set_rx_antenna(struct b43_wldev *dev, int antenna)
{//TODO {//TODO
struct b43_phy *phy = &dev->phy; struct b43_phy *phy = &dev->phy;
u64 hf;
u16 tmp; u16 tmp;
int autodiv = 0; int autodiv = 0;
if (antenna == B43_ANTENNA_AUTO0 || antenna == B43_ANTENNA_AUTO1) if (antenna == B43_ANTENNA_AUTO0 || antenna == B43_ANTENNA_AUTO1)
autodiv = 1; autodiv = 1;
hf = b43_hf_read(dev); b43_hf_write(dev, b43_hf_read(dev) & ~B43_HF_ANTDIVHELP);
hf &= ~B43_HF_ANTDIVHELP;
b43_hf_write(dev, hf);
tmp = b43_phy_read(dev, B43_PHY_BBANDCFG); b43_phy_maskset(dev, B43_PHY_BBANDCFG, ~B43_PHY_BBANDCFG_RXANT,
tmp &= ~B43_PHY_BBANDCFG_RXANT; (autodiv ? B43_ANTENNA_AUTO1 : antenna) <<
tmp |= (autodiv ? B43_ANTENNA_AUTO1 : antenna) B43_PHY_BBANDCFG_RXANT_SHIFT);
<< B43_PHY_BBANDCFG_RXANT_SHIFT;
b43_phy_write(dev, B43_PHY_BBANDCFG, tmp);
if (autodiv) { if (autodiv) {
tmp = b43_phy_read(dev, B43_PHY_ANTDWELL); tmp = b43_phy_read(dev, B43_PHY_ANTDWELL);
if (antenna == B43_ANTENNA_AUTO0) if (antenna == B43_ANTENNA_AUTO1)
tmp &= ~B43_PHY_ANTDWELL_AUTODIV1; tmp &= ~B43_PHY_ANTDWELL_AUTODIV1;
else else
tmp |= B43_PHY_ANTDWELL_AUTODIV1; tmp |= B43_PHY_ANTDWELL_AUTODIV1;
b43_phy_write(dev, B43_PHY_ANTDWELL, tmp); b43_phy_write(dev, B43_PHY_ANTDWELL, tmp);
} }
if (phy->rev < 3) { if (phy->rev < 3)
tmp = b43_phy_read(dev, B43_PHY_ANTDWELL); b43_phy_maskset(dev, B43_PHY_ANTDWELL, 0xFF00, 0x24);
tmp = (tmp & 0xFF00) | 0x24; else {
b43_phy_write(dev, B43_PHY_ANTDWELL, tmp); b43_phy_set(dev, B43_PHY_OFDM61, 0x10);
} else { if (phy->rev == 3) {
tmp = b43_phy_read(dev, B43_PHY_OFDM61); b43_phy_write(dev, B43_PHY_CLIPPWRDOWNT, 0x1D);
tmp |= 0x10; b43_phy_write(dev, B43_PHY_ADIVRELATED, 8);
b43_phy_write(dev, B43_PHY_OFDM61, tmp);
if (phy->analog == 3) {
b43_phy_write(dev, B43_PHY_CLIPPWRDOWNT,
0x1D);
b43_phy_write(dev, B43_PHY_ADIVRELATED,
8);
} else { } else {
b43_phy_write(dev, B43_PHY_CLIPPWRDOWNT, b43_phy_write(dev, B43_PHY_CLIPPWRDOWNT, 0x3A);
0x3A); b43_phy_maskset(dev, B43_PHY_ADIVRELATED, 0xFF00, 8);
tmp =
b43_phy_read(dev,
B43_PHY_ADIVRELATED);
tmp = (tmp & 0xFF00) | 8;
b43_phy_write(dev, B43_PHY_ADIVRELATED,
tmp);
} }
} }
hf |= B43_HF_ANTDIVHELP; b43_hf_write(dev, b43_hf_read(dev) | B43_HF_ANTDIVHELP);
b43_hf_write(dev, hf);
} }
static void b43_aphy_op_adjust_txpower(struct b43_wldev *dev) static void b43_aphy_op_adjust_txpower(struct b43_wldev *dev)
......
...@@ -2651,65 +2651,54 @@ static unsigned int b43_gphy_op_get_default_chan(struct b43_wldev *dev) ...@@ -2651,65 +2651,54 @@ static unsigned int b43_gphy_op_get_default_chan(struct b43_wldev *dev)
static void b43_gphy_op_set_rx_antenna(struct b43_wldev *dev, int antenna) static void b43_gphy_op_set_rx_antenna(struct b43_wldev *dev, int antenna)
{ {
struct b43_phy *phy = &dev->phy; struct b43_phy *phy = &dev->phy;
u64 hf;
u16 tmp; u16 tmp;
int autodiv = 0; int autodiv = 0;
if (antenna == B43_ANTENNA_AUTO0 || antenna == B43_ANTENNA_AUTO1) if (antenna == B43_ANTENNA_AUTO0 || antenna == B43_ANTENNA_AUTO1)
autodiv = 1; autodiv = 1;
hf = b43_hf_read(dev); b43_hf_write(dev, b43_hf_read(dev) & ~B43_HF_ANTDIVHELP);
hf &= ~B43_HF_ANTDIVHELP;
b43_hf_write(dev, hf);
tmp = b43_phy_read(dev, B43_PHY_BBANDCFG); b43_phy_maskset(dev, B43_PHY_BBANDCFG, ~B43_PHY_BBANDCFG_RXANT,
tmp &= ~B43_PHY_BBANDCFG_RXANT; (autodiv ? B43_ANTENNA_AUTO1 : antenna) <<
tmp |= (autodiv ? B43_ANTENNA_AUTO1 : antenna) B43_PHY_BBANDCFG_RXANT_SHIFT);
<< B43_PHY_BBANDCFG_RXANT_SHIFT;
b43_phy_write(dev, B43_PHY_BBANDCFG, tmp);
if (autodiv) { if (autodiv) {
tmp = b43_phy_read(dev, B43_PHY_ANTDWELL); tmp = b43_phy_read(dev, B43_PHY_ANTDWELL);
if (antenna == B43_ANTENNA_AUTO0) if (antenna == B43_ANTENNA_AUTO1)
tmp &= ~B43_PHY_ANTDWELL_AUTODIV1; tmp &= ~B43_PHY_ANTDWELL_AUTODIV1;
else else
tmp |= B43_PHY_ANTDWELL_AUTODIV1; tmp |= B43_PHY_ANTDWELL_AUTODIV1;
b43_phy_write(dev, B43_PHY_ANTDWELL, tmp); b43_phy_write(dev, B43_PHY_ANTDWELL, tmp);
} }
tmp = b43_phy_read(dev, B43_PHY_ANTWRSETT); tmp = b43_phy_read(dev, B43_PHY_ANTWRSETT);
if (autodiv) if (autodiv)
tmp |= B43_PHY_ANTWRSETT_ARXDIV; tmp |= B43_PHY_ANTWRSETT_ARXDIV;
else else
tmp &= ~B43_PHY_ANTWRSETT_ARXDIV; tmp &= ~B43_PHY_ANTWRSETT_ARXDIV;
b43_phy_write(dev, B43_PHY_ANTWRSETT, tmp); b43_phy_write(dev, B43_PHY_ANTWRSETT, tmp);
if (phy->rev >= 2) {
tmp = b43_phy_read(dev, B43_PHY_OFDM61);
tmp |= B43_PHY_OFDM61_10;
b43_phy_write(dev, B43_PHY_OFDM61, tmp);
tmp =
b43_phy_read(dev, B43_PHY_DIVSRCHGAINBACK);
tmp = (tmp & 0xFF00) | 0x15;
b43_phy_write(dev, B43_PHY_DIVSRCHGAINBACK,
tmp);
if (phy->rev == 2) { if (autodiv)
b43_phy_write(dev, B43_PHY_ADIVRELATED, b43_phy_set(dev, B43_PHY_ANTWRSETT, B43_PHY_ANTWRSETT_ARXDIV);
8); else {
} else { b43_phy_mask(dev, B43_PHY_ANTWRSETT,
tmp = B43_PHY_ANTWRSETT_ARXDIV);
b43_phy_read(dev,
B43_PHY_ADIVRELATED);
tmp = (tmp & 0xFF00) | 8;
b43_phy_write(dev, B43_PHY_ADIVRELATED,
tmp);
} }
if (phy->rev >= 2) {
b43_phy_set(dev, B43_PHY_OFDM61, B43_PHY_OFDM61_10);
b43_phy_maskset(dev, B43_PHY_DIVSRCHGAINBACK, 0xFF00, 0x15);
if (phy->rev == 2)
b43_phy_write(dev, B43_PHY_ADIVRELATED, 8);
else
b43_phy_maskset(dev, B43_PHY_ADIVRELATED, 0xFF00, 8);
} }
if (phy->rev >= 6) if (phy->rev >= 6)
b43_phy_write(dev, B43_PHY_OFDM9B, 0xDC); b43_phy_write(dev, B43_PHY_OFDM9B, 0xDC);
hf |= B43_HF_ANTDIVHELP; b43_hf_write(dev, b43_hf_read(dev) | B43_HF_ANTDIVHELP);
b43_hf_write(dev, hf);
} }
static int b43_gphy_op_interf_mitigation(struct b43_wldev *dev, static int b43_gphy_op_interf_mitigation(struct b43_wldev *dev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment