b43: Implement antenna diversity support for LP-PHY
authorGábor Stefanik <netrolller.3d@gmail.com>
Thu, 27 Aug 2009 20:49:49 +0000 (22:49 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Fri, 28 Aug 2009 18:40:55 +0000 (14:40 -0400)
The A/G-PHY changes are fallout fixes from the enum change,
which in turn allows the LP-PHY code to be much simpler.
The antenna_to_phyctl change is a fix for a potential
existing bug that this patch may otherwise trigger.

Signed-off-by: Gábor Stefanik <netrolller.3d@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/b43/main.c
drivers/net/wireless/b43/phy_a.c
drivers/net/wireless/b43/phy_common.h
drivers/net/wireless/b43/phy_g.c
drivers/net/wireless/b43/phy_lp.c

index f5bdf1cae1d12edf7724acf913115133bce1053c..0f168443ad4946c166f54d78060495a56708acd3 100644 (file)
@@ -1456,7 +1456,8 @@ static u16 b43_antenna_to_phyctl(int antenna)
                return B43_TXH_PHY_ANT2;
        case B43_ANTENNA3:
                return B43_TXH_PHY_ANT3;
-       case B43_ANTENNA_AUTO:
+       case B43_ANTENNA_AUTO0:
+       case B43_ANTENNA_AUTO1:
                return B43_TXH_PHY_ANT01AUTO;
        }
        B43_WARN_ON(1);
index 816e028a2620c9b43d06f8b615e11a7c518ddb8a..809ec97031cb5b93655327de7638c9d1e0521301 100644 (file)
@@ -531,7 +531,7 @@ static void b43_aphy_op_set_rx_antenna(struct b43_wldev *dev, int antenna)
 
        tmp = b43_phy_read(dev, B43_PHY_BBANDCFG);
        tmp &= ~B43_PHY_BBANDCFG_RXANT;
-       tmp |= (autodiv ? B43_ANTENNA_AUTO0 : antenna)
+       tmp |= (autodiv ? B43_ANTENNA_AUTO1 : antenna)
            << B43_PHY_BBANDCFG_RXANT_SHIFT;
        b43_phy_write(dev, B43_PHY_BBANDCFG, tmp);
 
index b47a0f55c0b6d57cb5c31c2275fc3d24eb14e07e..28e384633c34c05c4e6a19727a75caea17af5a5c 100644 (file)
@@ -49,11 +49,11 @@ enum b43_interference_mitigation {
 
 /* Antenna identifiers */
 enum {
-       B43_ANTENNA0,           /* Antenna 0 */
-       B43_ANTENNA1,           /* Antenna 0 */
-       B43_ANTENNA_AUTO1,      /* Automatic, starting with antenna 1 */
-       B43_ANTENNA_AUTO0,      /* Automatic, starting with antenna 0 */
-       B43_ANTENNA2,
+       B43_ANTENNA0 = 0,       /* Antenna 0 */
+       B43_ANTENNA1 = 1,       /* Antenna 1 */
+       B43_ANTENNA_AUTO0 = 2,  /* Automatic, starting with antenna 0 */
+       B43_ANTENNA_AUTO1 = 3,  /* Automatic, starting with antenna 1 */
+       B43_ANTENNA2 = 4,
        B43_ANTENNA3 = 8,
 
        B43_ANTENNA_AUTO = B43_ANTENNA_AUTO0,
index e47131216a67fe92ea907b911df96f307e9acc09..bdff9afe3f81a196bc3376be53fb73bf63c7c531 100644 (file)
@@ -2664,7 +2664,7 @@ static void b43_gphy_op_set_rx_antenna(struct b43_wldev *dev, int antenna)
 
        tmp = b43_phy_read(dev, B43_PHY_BBANDCFG);
        tmp &= ~B43_PHY_BBANDCFG_RXANT;
-       tmp |= (autodiv ? B43_ANTENNA_AUTO0 : antenna)
+       tmp |= (autodiv ? B43_ANTENNA_AUTO1 : antenna)
                        << B43_PHY_BBANDCFG_RXANT_SHIFT;
        b43_phy_write(dev, B43_PHY_BBANDCFG, tmp);
 
index 7d2a7027235a4aaf66b692596e078f4edf026237..1ab00b034cbd659b80c0161c14f0ae761c17319f 100644 (file)
@@ -2205,7 +2205,14 @@ static int b43_lpphy_op_init(struct b43_wldev *dev)
 
 static void b43_lpphy_op_set_rx_antenna(struct b43_wldev *dev, int antenna)
 {
-       //TODO
+       if (dev->phy.rev >= 2)
+               return; // rev2+ doesn't support antenna diversity
+
+       if (B43_WARN_ON(antenna > B43_ANTENNA_AUTO1))
+               return;
+
+       b43_phy_maskset(dev, B43_LPPHY_CRSGAIN_CTL, 0xFFFD, antenna & 0x2);
+       b43_phy_maskset(dev, B43_LPPHY_CRSGAIN_CTL, 0xFFFE, antenna & 0x1);
 }
 
 static void b43_lpphy_op_adjust_txpower(struct b43_wldev *dev)