diff options
author | Rafał Miłecki <zajec5@gmail.com> | 2010-01-29 18:12:20 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-02-01 15:40:05 -0500 |
commit | ef5127a4d256b9c0f47caae6cdc8ccfceedb09f9 (patch) | |
tree | 20d3e07ac9604048808f632a2340d1808f8fd9e3 /drivers/net/wireless | |
parent | 28fd7daabfb35b7a0df2f7eaf460221e16dd2608 (diff) |
b43: N-PHY: add workarounds for gain control
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r-- | drivers/net/wireless/b43/phy_n.c | 130 |
1 files changed, 129 insertions, 1 deletions
diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c index 60e730a6f1dd..d738d769b025 100644 --- a/drivers/net/wireless/b43/phy_n.c +++ b/drivers/net/wireless/b43/phy_n.c | |||
@@ -712,6 +712,134 @@ static void b43_nphy_stop_playback(struct b43_wldev *dev) | |||
712 | b43_nphy_stay_in_carrier_search(dev, 0); | 712 | b43_nphy_stay_in_carrier_search(dev, 0); |
713 | } | 713 | } |
714 | 714 | ||
715 | /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/WorkaroundsGainCtrl */ | ||
716 | static void b43_nphy_gain_crtl_workarounds(struct b43_wldev *dev) | ||
717 | { | ||
718 | struct b43_phy_n *nphy = dev->phy.n; | ||
719 | u8 i, j; | ||
720 | u8 code; | ||
721 | |||
722 | /* TODO: for PHY >= 3 | ||
723 | s8 *lna1_gain, *lna2_gain; | ||
724 | u8 *gain_db, *gain_bits; | ||
725 | u16 *rfseq_init; | ||
726 | u8 lpf_gain[6] = { 0x00, 0x06, 0x0C, 0x12, 0x12, 0x12 }; | ||
727 | u8 lpf_bits[6] = { 0, 1, 2, 3, 3, 3 }; | ||
728 | */ | ||
729 | |||
730 | u8 rfseq_events[3] = { 6, 8, 7 }; | ||
731 | u8 rfseq_delays[3] = { 10, 30, 1 }; | ||
732 | |||
733 | if (dev->phy.rev >= 3) { | ||
734 | /* TODO */ | ||
735 | } else { | ||
736 | /* Set Clip 2 detect */ | ||
737 | b43_phy_set(dev, B43_NPHY_C1_CGAINI, | ||
738 | B43_NPHY_C1_CGAINI_CL2DETECT); | ||
739 | b43_phy_set(dev, B43_NPHY_C2_CGAINI, | ||
740 | B43_NPHY_C2_CGAINI_CL2DETECT); | ||
741 | |||
742 | /* Set narrowband clip threshold */ | ||
743 | b43_phy_set(dev, B43_NPHY_C1_NBCLIPTHRES, 0x84); | ||
744 | b43_phy_set(dev, B43_NPHY_C2_NBCLIPTHRES, 0x84); | ||
745 | |||
746 | if (!dev->phy.is_40mhz) { | ||
747 | /* Set dwell lengths */ | ||
748 | b43_phy_set(dev, B43_NPHY_CLIP1_NBDWELL_LEN, 0x002B); | ||
749 | b43_phy_set(dev, B43_NPHY_CLIP2_NBDWELL_LEN, 0x002B); | ||
750 | b43_phy_set(dev, B43_NPHY_W1CLIP1_DWELL_LEN, 0x0009); | ||
751 | b43_phy_set(dev, B43_NPHY_W1CLIP2_DWELL_LEN, 0x0009); | ||
752 | } | ||
753 | |||
754 | /* Set wideband clip 2 threshold */ | ||
755 | b43_phy_maskset(dev, B43_NPHY_C1_CLIPWBTHRES, | ||
756 | ~B43_NPHY_C1_CLIPWBTHRES_CLIP2, | ||
757 | 21); | ||
758 | b43_phy_maskset(dev, B43_NPHY_C2_CLIPWBTHRES, | ||
759 | ~B43_NPHY_C2_CLIPWBTHRES_CLIP2, | ||
760 | 21); | ||
761 | |||
762 | if (!dev->phy.is_40mhz) { | ||
763 | b43_phy_maskset(dev, B43_NPHY_C1_CGAINI, | ||
764 | ~B43_NPHY_C1_CGAINI_GAINBKOFF, 0x1); | ||
765 | b43_phy_maskset(dev, B43_NPHY_C2_CGAINI, | ||
766 | ~B43_NPHY_C2_CGAINI_GAINBKOFF, 0x1); | ||
767 | b43_phy_maskset(dev, B43_NPHY_C1_CCK_CGAINI, | ||
768 | ~B43_NPHY_C1_CCK_CGAINI_GAINBKOFF, 0x1); | ||
769 | b43_phy_maskset(dev, B43_NPHY_C2_CCK_CGAINI, | ||
770 | ~B43_NPHY_C2_CCK_CGAINI_GAINBKOFF, 0x1); | ||
771 | } | ||
772 | |||
773 | b43_phy_set(dev, B43_NPHY_CCK_SHIFTB_REF, 0x809C); | ||
774 | |||
775 | if (nphy->gain_boost) { | ||
776 | if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ && | ||
777 | dev->phy.is_40mhz) | ||
778 | code = 4; | ||
779 | else | ||
780 | code = 5; | ||
781 | } else { | ||
782 | code = dev->phy.is_40mhz ? 6 : 7; | ||
783 | } | ||
784 | |||
785 | /* Set HPVGA2 index */ | ||
786 | b43_phy_maskset(dev, B43_NPHY_C1_INITGAIN, | ||
787 | ~B43_NPHY_C1_INITGAIN_HPVGA2, | ||
788 | code << B43_NPHY_C1_INITGAIN_HPVGA2_SHIFT); | ||
789 | b43_phy_maskset(dev, B43_NPHY_C2_INITGAIN, | ||
790 | ~B43_NPHY_C2_INITGAIN_HPVGA2, | ||
791 | code << B43_NPHY_C2_INITGAIN_HPVGA2_SHIFT); | ||
792 | |||
793 | b43_phy_write(dev, B43_NPHY_TABLE_ADDR, 0x1D06); | ||
794 | b43_phy_write(dev, B43_NPHY_TABLE_DATALO, | ||
795 | (code << 8 | 0x7C)); | ||
796 | b43_phy_write(dev, B43_NPHY_TABLE_DATALO, | ||
797 | (code << 8 | 0x7C)); | ||
798 | |||
799 | /* TODO: b43_nphy_adjust_lna_gain_table(dev); */ | ||
800 | |||
801 | if (nphy->elna_gain_config) { | ||
802 | b43_phy_write(dev, B43_NPHY_TABLE_ADDR, 0x0808); | ||
803 | b43_phy_write(dev, B43_NPHY_TABLE_DATALO, 0x0); | ||
804 | b43_phy_write(dev, B43_NPHY_TABLE_DATALO, 0x1); | ||
805 | b43_phy_write(dev, B43_NPHY_TABLE_DATALO, 0x1); | ||
806 | b43_phy_write(dev, B43_NPHY_TABLE_DATALO, 0x1); | ||
807 | |||
808 | b43_phy_write(dev, B43_NPHY_TABLE_ADDR, 0x0C08); | ||
809 | b43_phy_write(dev, B43_NPHY_TABLE_DATALO, 0x0); | ||
810 | b43_phy_write(dev, B43_NPHY_TABLE_DATALO, 0x1); | ||
811 | b43_phy_write(dev, B43_NPHY_TABLE_DATALO, 0x1); | ||
812 | b43_phy_write(dev, B43_NPHY_TABLE_DATALO, 0x1); | ||
813 | |||
814 | b43_phy_write(dev, B43_NPHY_TABLE_ADDR, 0x1D06); | ||
815 | b43_phy_write(dev, B43_NPHY_TABLE_DATALO, | ||
816 | (code << 8 | 0x74)); | ||
817 | b43_phy_write(dev, B43_NPHY_TABLE_DATALO, | ||
818 | (code << 8 | 0x74)); | ||
819 | } | ||
820 | |||
821 | if (dev->phy.rev == 2) { | ||
822 | for (i = 0; i < 4; i++) { | ||
823 | b43_phy_write(dev, B43_NPHY_TABLE_ADDR, | ||
824 | (0x0400 * i) + 0x0020); | ||
825 | for (j = 0; j < 21; j++) | ||
826 | b43_phy_write(dev, | ||
827 | B43_NPHY_TABLE_DATALO, 3 * j); | ||
828 | } | ||
829 | |||
830 | /* TODO: b43_nphy_set_rf_sequence(dev, 5, | ||
831 | rfseq_events, rfseq_delays, 3);*/ | ||
832 | b43_phy_maskset(dev, B43_NPHY_OVER_DGAIN1, | ||
833 | (u16)~B43_NPHY_OVER_DGAIN_CCKDGECV, | ||
834 | 0x5A << B43_NPHY_OVER_DGAIN_CCKDGECV_SHIFT); | ||
835 | |||
836 | if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) | ||
837 | b43_phy_maskset(dev, B43_PHY_N(0xC5D), | ||
838 | 0xFF80, 4); | ||
839 | } | ||
840 | } | ||
841 | } | ||
842 | |||
715 | /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/Workarounds */ | 843 | /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/Workarounds */ |
716 | static void b43_nphy_workarounds(struct b43_wldev *dev) | 844 | static void b43_nphy_workarounds(struct b43_wldev *dev) |
717 | { | 845 | { |
@@ -786,7 +914,7 @@ static void b43_nphy_workarounds(struct b43_wldev *dev) | |||
786 | /*TODO:b43_nphy_set_rf_sequence(dev, 0, events1, delays1, 7);*/ | 914 | /*TODO:b43_nphy_set_rf_sequence(dev, 0, events1, delays1, 7);*/ |
787 | /*TODO:b43_nphy_set_rf_sequence(dev, 1, events2, delays2, 7);*/ | 915 | /*TODO:b43_nphy_set_rf_sequence(dev, 1, events2, delays2, 7);*/ |
788 | 916 | ||
789 | /*TODO:b43_nphy_gain_crtl_workarounds(dev);*/ | 917 | b43_nphy_gain_crtl_workarounds(dev); |
790 | 918 | ||
791 | if (dev->phy.rev < 2) { | 919 | if (dev->phy.rev < 2) { |
792 | if (b43_phy_read(dev, B43_NPHY_RXCTL) & 0x2) | 920 | if (b43_phy_read(dev, B43_NPHY_RXCTL) & 0x2) |