aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorGábor Stefanik <netrolller.3d@gmail.com>2009-08-28 15:37:00 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-08-31 14:42:12 -0400
commitc206a39d58fa335275403088171482f66fdbedcf (patch)
treeda967cbf5b8813ba3ab8e998d7587e3bba38b6d5 /drivers
parentaf472a953ef23d6b9fe717486974d7caff3fa194 (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')
-rw-r--r--drivers/net/wireless/b43/phy_a.c48
-rw-r--r--drivers/net/wireless/b43/phy_g.c53
2 files changed, 36 insertions, 65 deletions
diff --git a/drivers/net/wireless/b43/phy_a.c b/drivers/net/wireless/b43/phy_a.c
index 809ec97031cb..d90217c3a706 100644
--- a/drivers/net/wireless/b43/phy_a.c
+++ b/drivers/net/wireless/b43/phy_a.c
@@ -518,58 +518,40 @@ static unsigned int b43_aphy_op_get_default_chan(struct b43_wldev *dev)
518static void b43_aphy_op_set_rx_antenna(struct b43_wldev *dev, int antenna) 518static void b43_aphy_op_set_rx_antenna(struct b43_wldev *dev, int antenna)
519{//TODO 519{//TODO
520 struct b43_phy *phy = &dev->phy; 520 struct b43_phy *phy = &dev->phy;
521 u64 hf;
522 u16 tmp; 521 u16 tmp;
523 int autodiv = 0; 522 int autodiv = 0;
524 523
525 if (antenna == B43_ANTENNA_AUTO0 || antenna == B43_ANTENNA_AUTO1) 524 if (antenna == B43_ANTENNA_AUTO0 || antenna == B43_ANTENNA_AUTO1)
526 autodiv = 1; 525 autodiv = 1;
527 526
528 hf = b43_hf_read(dev); 527 b43_hf_write(dev, b43_hf_read(dev) & ~B43_HF_ANTDIVHELP);
529 hf &= ~B43_HF_ANTDIVHELP;
530 b43_hf_write(dev, hf);
531 528
532 tmp = b43_phy_read(dev, B43_PHY_BBANDCFG); 529 b43_phy_maskset(dev, B43_PHY_BBANDCFG, ~B43_PHY_BBANDCFG_RXANT,
533 tmp &= ~B43_PHY_BBANDCFG_RXANT; 530 (autodiv ? B43_ANTENNA_AUTO1 : antenna) <<
534 tmp |= (autodiv ? B43_ANTENNA_AUTO1 : antenna) 531 B43_PHY_BBANDCFG_RXANT_SHIFT);
535 << B43_PHY_BBANDCFG_RXANT_SHIFT;
536 b43_phy_write(dev, B43_PHY_BBANDCFG, tmp);
537 532
538 if (autodiv) { 533 if (autodiv) {
539 tmp = b43_phy_read(dev, B43_PHY_ANTDWELL); 534 tmp = b43_phy_read(dev, B43_PHY_ANTDWELL);
540 if (antenna == B43_ANTENNA_AUTO0) 535 if (antenna == B43_ANTENNA_AUTO1)
541 tmp &= ~B43_PHY_ANTDWELL_AUTODIV1; 536 tmp &= ~B43_PHY_ANTDWELL_AUTODIV1;
542 else 537 else
543 tmp |= B43_PHY_ANTDWELL_AUTODIV1; 538 tmp |= B43_PHY_ANTDWELL_AUTODIV1;
544 b43_phy_write(dev, B43_PHY_ANTDWELL, tmp); 539 b43_phy_write(dev, B43_PHY_ANTDWELL, tmp);
545 } 540 }
546 if (phy->rev < 3) { 541 if (phy->rev < 3)
547 tmp = b43_phy_read(dev, B43_PHY_ANTDWELL); 542 b43_phy_maskset(dev, B43_PHY_ANTDWELL, 0xFF00, 0x24);
548 tmp = (tmp & 0xFF00) | 0x24; 543 else {
549 b43_phy_write(dev, B43_PHY_ANTDWELL, tmp); 544 b43_phy_set(dev, B43_PHY_OFDM61, 0x10);
550 } else { 545 if (phy->rev == 3) {
551 tmp = b43_phy_read(dev, B43_PHY_OFDM61); 546 b43_phy_write(dev, B43_PHY_CLIPPWRDOWNT, 0x1D);
552 tmp |= 0x10; 547 b43_phy_write(dev, B43_PHY_ADIVRELATED, 8);
553 b43_phy_write(dev, B43_PHY_OFDM61, tmp);
554 if (phy->analog == 3) {
555 b43_phy_write(dev, B43_PHY_CLIPPWRDOWNT,
556 0x1D);
557 b43_phy_write(dev, B43_PHY_ADIVRELATED,
558 8);
559 } else { 548 } else {
560 b43_phy_write(dev, B43_PHY_CLIPPWRDOWNT, 549 b43_phy_write(dev, B43_PHY_CLIPPWRDOWNT, 0x3A);
561 0x3A); 550 b43_phy_maskset(dev, B43_PHY_ADIVRELATED, 0xFF00, 8);
562 tmp =
563 b43_phy_read(dev,
564 B43_PHY_ADIVRELATED);
565 tmp = (tmp & 0xFF00) | 8;
566 b43_phy_write(dev, B43_PHY_ADIVRELATED,
567 tmp);
568 } 551 }
569 } 552 }
570 553
571 hf |= B43_HF_ANTDIVHELP; 554 b43_hf_write(dev, b43_hf_read(dev) | B43_HF_ANTDIVHELP);
572 b43_hf_write(dev, hf);
573} 555}
574 556
575static void b43_aphy_op_adjust_txpower(struct b43_wldev *dev) 557static void b43_aphy_op_adjust_txpower(struct b43_wldev *dev)
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)
2651static void b43_gphy_op_set_rx_antenna(struct b43_wldev *dev, int antenna) 2651static 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
2715static int b43_gphy_op_interf_mitigation(struct b43_wldev *dev, 2704static int b43_gphy_op_interf_mitigation(struct b43_wldev *dev,