diff options
author | Gábor Stefanik <netrolller.3d@gmail.com> | 2009-08-28 15:37:00 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-08-31 14:42:12 -0400 |
commit | c206a39d58fa335275403088171482f66fdbedcf (patch) | |
tree | da967cbf5b8813ba3ab8e998d7587e3bba38b6d5 /drivers/net/wireless/b43/phy_g.c | |
parent | af472a953ef23d6b9fe717486974d7caff3fa194 (diff) |
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: Gábor Stefanik <netrolller.3d@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/b43/phy_g.c')
-rw-r--r-- | drivers/net/wireless/b43/phy_g.c | 53 |
1 files changed, 21 insertions, 32 deletions
diff --git a/drivers/net/wireless/b43/phy_g.c b/drivers/net/wireless/b43/phy_g.c index bdff9afe3f81..5afa4df0b02f 100644 --- a/drivers/net/wireless/b43/phy_g.c +++ b/drivers/net/wireless/b43/phy_g.c | |||
@@ -2651,65 +2651,54 @@ static unsigned int b43_gphy_op_get_default_chan(struct b43_wldev *dev) | |||
2651 | static void b43_gphy_op_set_rx_antenna(struct b43_wldev *dev, int antenna) | 2651 | static void b43_gphy_op_set_rx_antenna(struct b43_wldev *dev, int antenna) |
2652 | { | 2652 | { |
2653 | struct b43_phy *phy = &dev->phy; | 2653 | struct b43_phy *phy = &dev->phy; |
2654 | u64 hf; | ||
2655 | u16 tmp; | 2654 | u16 tmp; |
2656 | int autodiv = 0; | 2655 | int autodiv = 0; |
2657 | 2656 | ||
2658 | if (antenna == B43_ANTENNA_AUTO0 || antenna == B43_ANTENNA_AUTO1) | 2657 | if (antenna == B43_ANTENNA_AUTO0 || antenna == B43_ANTENNA_AUTO1) |
2659 | autodiv = 1; | 2658 | autodiv = 1; |
2660 | 2659 | ||
2661 | hf = b43_hf_read(dev); | 2660 | b43_hf_write(dev, b43_hf_read(dev) & ~B43_HF_ANTDIVHELP); |
2662 | hf &= ~B43_HF_ANTDIVHELP; | ||
2663 | b43_hf_write(dev, hf); | ||
2664 | 2661 | ||
2665 | tmp = b43_phy_read(dev, B43_PHY_BBANDCFG); | 2662 | b43_phy_maskset(dev, B43_PHY_BBANDCFG, ~B43_PHY_BBANDCFG_RXANT, |
2666 | tmp &= ~B43_PHY_BBANDCFG_RXANT; | 2663 | (autodiv ? B43_ANTENNA_AUTO1 : antenna) << |
2667 | tmp |= (autodiv ? B43_ANTENNA_AUTO1 : antenna) | 2664 | B43_PHY_BBANDCFG_RXANT_SHIFT); |
2668 | << B43_PHY_BBANDCFG_RXANT_SHIFT; | ||
2669 | b43_phy_write(dev, B43_PHY_BBANDCFG, tmp); | ||
2670 | 2665 | ||
2671 | if (autodiv) { | 2666 | if (autodiv) { |
2672 | tmp = b43_phy_read(dev, B43_PHY_ANTDWELL); | 2667 | tmp = b43_phy_read(dev, B43_PHY_ANTDWELL); |
2673 | if (antenna == B43_ANTENNA_AUTO0) | 2668 | if (antenna == B43_ANTENNA_AUTO1) |
2674 | tmp &= ~B43_PHY_ANTDWELL_AUTODIV1; | 2669 | tmp &= ~B43_PHY_ANTDWELL_AUTODIV1; |
2675 | else | 2670 | else |
2676 | tmp |= B43_PHY_ANTDWELL_AUTODIV1; | 2671 | tmp |= B43_PHY_ANTDWELL_AUTODIV1; |
2677 | b43_phy_write(dev, B43_PHY_ANTDWELL, tmp); | 2672 | b43_phy_write(dev, B43_PHY_ANTDWELL, tmp); |
2678 | } | 2673 | } |
2674 | |||
2679 | tmp = b43_phy_read(dev, B43_PHY_ANTWRSETT); | 2675 | tmp = b43_phy_read(dev, B43_PHY_ANTWRSETT); |
2680 | if (autodiv) | 2676 | if (autodiv) |
2681 | tmp |= B43_PHY_ANTWRSETT_ARXDIV; | 2677 | tmp |= B43_PHY_ANTWRSETT_ARXDIV; |
2682 | else | 2678 | else |
2683 | tmp &= ~B43_PHY_ANTWRSETT_ARXDIV; | 2679 | tmp &= ~B43_PHY_ANTWRSETT_ARXDIV; |
2684 | b43_phy_write(dev, B43_PHY_ANTWRSETT, tmp); | 2680 | b43_phy_write(dev, B43_PHY_ANTWRSETT, tmp); |
2685 | if (phy->rev >= 2) { | ||
2686 | tmp = b43_phy_read(dev, B43_PHY_OFDM61); | ||
2687 | tmp |= B43_PHY_OFDM61_10; | ||
2688 | b43_phy_write(dev, B43_PHY_OFDM61, tmp); | ||
2689 | 2681 | ||
2690 | tmp = | 2682 | if (autodiv) |
2691 | b43_phy_read(dev, B43_PHY_DIVSRCHGAINBACK); | 2683 | b43_phy_set(dev, B43_PHY_ANTWRSETT, B43_PHY_ANTWRSETT_ARXDIV); |
2692 | tmp = (tmp & 0xFF00) | 0x15; | 2684 | else { |
2693 | b43_phy_write(dev, B43_PHY_DIVSRCHGAINBACK, | 2685 | b43_phy_mask(dev, B43_PHY_ANTWRSETT, |
2694 | tmp); | 2686 | B43_PHY_ANTWRSETT_ARXDIV); |
2687 | } | ||
2695 | 2688 | ||
2696 | if (phy->rev == 2) { | 2689 | if (phy->rev >= 2) { |
2697 | b43_phy_write(dev, B43_PHY_ADIVRELATED, | 2690 | b43_phy_set(dev, B43_PHY_OFDM61, B43_PHY_OFDM61_10); |
2698 | 8); | 2691 | b43_phy_maskset(dev, B43_PHY_DIVSRCHGAINBACK, 0xFF00, 0x15); |
2699 | } else { | 2692 | |
2700 | tmp = | 2693 | if (phy->rev == 2) |
2701 | b43_phy_read(dev, | 2694 | b43_phy_write(dev, B43_PHY_ADIVRELATED, 8); |
2702 | B43_PHY_ADIVRELATED); | 2695 | else |
2703 | tmp = (tmp & 0xFF00) | 8; | 2696 | b43_phy_maskset(dev, B43_PHY_ADIVRELATED, 0xFF00, 8); |
2704 | b43_phy_write(dev, B43_PHY_ADIVRELATED, | ||
2705 | tmp); | ||
2706 | } | ||
2707 | } | 2697 | } |
2708 | if (phy->rev >= 6) | 2698 | if (phy->rev >= 6) |
2709 | b43_phy_write(dev, B43_PHY_OFDM9B, 0xDC); | 2699 | b43_phy_write(dev, B43_PHY_OFDM9B, 0xDC); |
2710 | 2700 | ||
2711 | hf |= B43_HF_ANTDIVHELP; | 2701 | b43_hf_write(dev, b43_hf_read(dev) | B43_HF_ANTDIVHELP); |
2712 | b43_hf_write(dev, hf); | ||
2713 | } | 2702 | } |
2714 | 2703 | ||
2715 | static int b43_gphy_op_interf_mitigation(struct b43_wldev *dev, | 2704 | static int b43_gphy_op_interf_mitigation(struct b43_wldev *dev, |