diff options
author | Rafał Miłecki <zajec5@gmail.com> | 2011-12-20 16:45:47 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2012-01-04 14:30:41 -0500 |
commit | 9dd4d9b99218b2bebbcfb4627b34145250deeb6e (patch) | |
tree | 744b62edf1751fd2acf49a565b4cc9de408dd9dc /drivers/net/wireless/b43/phy_n.c | |
parent | 3b77d5ec0c86b8a9594217ff9024b00e4d1c5795 (diff) |
b43: N-PHY: move common TX/RX functions
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/b43/phy_n.c')
-rw-r--r-- | drivers/net/wireless/b43/phy_n.c | 218 |
1 files changed, 111 insertions, 107 deletions
diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c index e89b04bcd1f4..52503c699b2e 100644 --- a/drivers/net/wireless/b43/phy_n.c +++ b/drivers/net/wireless/b43/phy_n.c | |||
@@ -1929,6 +1929,117 @@ static void b43_nphy_workarounds(struct b43_wldev *dev) | |||
1929 | } | 1929 | } |
1930 | 1930 | ||
1931 | /************************************************** | 1931 | /************************************************** |
1932 | * Tx/Rx common | ||
1933 | **************************************************/ | ||
1934 | |||
1935 | /* | ||
1936 | * Transmits a known value for LO calibration | ||
1937 | * http://bcm-v4.sipsolutions.net/802.11/PHY/N/TXTone | ||
1938 | */ | ||
1939 | static int b43_nphy_tx_tone(struct b43_wldev *dev, u32 freq, u16 max_val, | ||
1940 | bool iqmode, bool dac_test) | ||
1941 | { | ||
1942 | u16 samp = b43_nphy_gen_load_samples(dev, freq, max_val, dac_test); | ||
1943 | if (samp == 0) | ||
1944 | return -1; | ||
1945 | b43_nphy_run_samples(dev, samp, 0xFFFF, 0, iqmode, dac_test); | ||
1946 | return 0; | ||
1947 | } | ||
1948 | |||
1949 | /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/Chains */ | ||
1950 | static void b43_nphy_update_txrx_chain(struct b43_wldev *dev) | ||
1951 | { | ||
1952 | struct b43_phy_n *nphy = dev->phy.n; | ||
1953 | |||
1954 | bool override = false; | ||
1955 | u16 chain = 0x33; | ||
1956 | |||
1957 | if (nphy->txrx_chain == 0) { | ||
1958 | chain = 0x11; | ||
1959 | override = true; | ||
1960 | } else if (nphy->txrx_chain == 1) { | ||
1961 | chain = 0x22; | ||
1962 | override = true; | ||
1963 | } | ||
1964 | |||
1965 | b43_phy_maskset(dev, B43_NPHY_RFSEQCA, | ||
1966 | ~(B43_NPHY_RFSEQCA_TXEN | B43_NPHY_RFSEQCA_RXEN), | ||
1967 | chain); | ||
1968 | |||
1969 | if (override) | ||
1970 | b43_phy_set(dev, B43_NPHY_RFSEQMODE, | ||
1971 | B43_NPHY_RFSEQMODE_CAOVER); | ||
1972 | else | ||
1973 | b43_phy_mask(dev, B43_NPHY_RFSEQMODE, | ||
1974 | ~B43_NPHY_RFSEQMODE_CAOVER); | ||
1975 | } | ||
1976 | |||
1977 | /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/stop-playback */ | ||
1978 | static void b43_nphy_stop_playback(struct b43_wldev *dev) | ||
1979 | { | ||
1980 | struct b43_phy_n *nphy = dev->phy.n; | ||
1981 | u16 tmp; | ||
1982 | |||
1983 | if (nphy->hang_avoid) | ||
1984 | b43_nphy_stay_in_carrier_search(dev, 1); | ||
1985 | |||
1986 | tmp = b43_phy_read(dev, B43_NPHY_SAMP_STAT); | ||
1987 | if (tmp & 0x1) | ||
1988 | b43_phy_set(dev, B43_NPHY_SAMP_CMD, B43_NPHY_SAMP_CMD_STOP); | ||
1989 | else if (tmp & 0x2) | ||
1990 | b43_phy_mask(dev, B43_NPHY_IQLOCAL_CMDGCTL, 0x7FFF); | ||
1991 | |||
1992 | b43_phy_mask(dev, B43_NPHY_SAMP_CMD, ~0x0004); | ||
1993 | |||
1994 | if (nphy->bb_mult_save & 0x80000000) { | ||
1995 | tmp = nphy->bb_mult_save & 0xFFFF; | ||
1996 | b43_ntab_write(dev, B43_NTAB16(15, 87), tmp); | ||
1997 | nphy->bb_mult_save = 0; | ||
1998 | } | ||
1999 | |||
2000 | if (nphy->hang_avoid) | ||
2001 | b43_nphy_stay_in_carrier_search(dev, 0); | ||
2002 | } | ||
2003 | |||
2004 | /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/IqCalGainParams */ | ||
2005 | static void b43_nphy_iq_cal_gain_params(struct b43_wldev *dev, u16 core, | ||
2006 | struct nphy_txgains target, | ||
2007 | struct nphy_iqcal_params *params) | ||
2008 | { | ||
2009 | int i, j, indx; | ||
2010 | u16 gain; | ||
2011 | |||
2012 | if (dev->phy.rev >= 3) { | ||
2013 | params->txgm = target.txgm[core]; | ||
2014 | params->pga = target.pga[core]; | ||
2015 | params->pad = target.pad[core]; | ||
2016 | params->ipa = target.ipa[core]; | ||
2017 | params->cal_gain = (params->txgm << 12) | (params->pga << 8) | | ||
2018 | (params->pad << 4) | (params->ipa); | ||
2019 | for (j = 0; j < 5; j++) | ||
2020 | params->ncorr[j] = 0x79; | ||
2021 | } else { | ||
2022 | gain = (target.pad[core]) | (target.pga[core] << 4) | | ||
2023 | (target.txgm[core] << 8); | ||
2024 | |||
2025 | indx = (b43_current_band(dev->wl) == IEEE80211_BAND_5GHZ) ? | ||
2026 | 1 : 0; | ||
2027 | for (i = 0; i < 9; i++) | ||
2028 | if (tbl_iqcal_gainparams[indx][i][0] == gain) | ||
2029 | break; | ||
2030 | i = min(i, 8); | ||
2031 | |||
2032 | params->txgm = tbl_iqcal_gainparams[indx][i][1]; | ||
2033 | params->pga = tbl_iqcal_gainparams[indx][i][2]; | ||
2034 | params->pad = tbl_iqcal_gainparams[indx][i][3]; | ||
2035 | params->cal_gain = (params->txgm << 7) | (params->pga << 4) | | ||
2036 | (params->pad << 2); | ||
2037 | for (j = 0; j < 4; j++) | ||
2038 | params->ncorr[j] = tbl_iqcal_gainparams[indx][i][4 + j]; | ||
2039 | } | ||
2040 | } | ||
2041 | |||
2042 | /************************************************** | ||
1932 | * Tx and Rx | 2043 | * Tx and Rx |
1933 | **************************************************/ | 2044 | **************************************************/ |
1934 | 2045 | ||
@@ -2290,34 +2401,6 @@ static void b43_nphy_tx_lp_fbw(struct b43_wldev *dev) | |||
2290 | } | 2401 | } |
2291 | } | 2402 | } |
2292 | 2403 | ||
2293 | /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/Chains */ | ||
2294 | static void b43_nphy_update_txrx_chain(struct b43_wldev *dev) | ||
2295 | { | ||
2296 | struct b43_phy_n *nphy = dev->phy.n; | ||
2297 | |||
2298 | bool override = false; | ||
2299 | u16 chain = 0x33; | ||
2300 | |||
2301 | if (nphy->txrx_chain == 0) { | ||
2302 | chain = 0x11; | ||
2303 | override = true; | ||
2304 | } else if (nphy->txrx_chain == 1) { | ||
2305 | chain = 0x22; | ||
2306 | override = true; | ||
2307 | } | ||
2308 | |||
2309 | b43_phy_maskset(dev, B43_NPHY_RFSEQCA, | ||
2310 | ~(B43_NPHY_RFSEQCA_TXEN | B43_NPHY_RFSEQCA_RXEN), | ||
2311 | chain); | ||
2312 | |||
2313 | if (override) | ||
2314 | b43_phy_set(dev, B43_NPHY_RFSEQMODE, | ||
2315 | B43_NPHY_RFSEQMODE_CAOVER); | ||
2316 | else | ||
2317 | b43_phy_mask(dev, B43_NPHY_RFSEQMODE, | ||
2318 | ~B43_NPHY_RFSEQMODE_CAOVER); | ||
2319 | } | ||
2320 | |||
2321 | /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RxIqEst */ | 2404 | /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RxIqEst */ |
2322 | static void b43_nphy_rx_iq_est(struct b43_wldev *dev, struct nphy_iq_est *est, | 2405 | static void b43_nphy_rx_iq_est(struct b43_wldev *dev, struct nphy_iq_est *est, |
2323 | u16 samps, u8 time, bool wait) | 2406 | u16 samps, u8 time, bool wait) |
@@ -2569,33 +2652,6 @@ static void b43_nphy_tx_iq_workaround(struct b43_wldev *dev) | |||
2569 | b43_shm_write16(dev, B43_SHM_SHARED, B43_SHM_SH_NPHY_TXIQW3, array[3]); | 2652 | b43_shm_write16(dev, B43_SHM_SHARED, B43_SHM_SH_NPHY_TXIQW3, array[3]); |
2570 | } | 2653 | } |
2571 | 2654 | ||
2572 | /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/stop-playback */ | ||
2573 | static void b43_nphy_stop_playback(struct b43_wldev *dev) | ||
2574 | { | ||
2575 | struct b43_phy_n *nphy = dev->phy.n; | ||
2576 | u16 tmp; | ||
2577 | |||
2578 | if (nphy->hang_avoid) | ||
2579 | b43_nphy_stay_in_carrier_search(dev, 1); | ||
2580 | |||
2581 | tmp = b43_phy_read(dev, B43_NPHY_SAMP_STAT); | ||
2582 | if (tmp & 0x1) | ||
2583 | b43_phy_set(dev, B43_NPHY_SAMP_CMD, B43_NPHY_SAMP_CMD_STOP); | ||
2584 | else if (tmp & 0x2) | ||
2585 | b43_phy_mask(dev, B43_NPHY_IQLOCAL_CMDGCTL, 0x7FFF); | ||
2586 | |||
2587 | b43_phy_mask(dev, B43_NPHY_SAMP_CMD, ~0x0004); | ||
2588 | |||
2589 | if (nphy->bb_mult_save & 0x80000000) { | ||
2590 | tmp = nphy->bb_mult_save & 0xFFFF; | ||
2591 | b43_ntab_write(dev, B43_NTAB16(15, 87), tmp); | ||
2592 | nphy->bb_mult_save = 0; | ||
2593 | } | ||
2594 | |||
2595 | if (nphy->hang_avoid) | ||
2596 | b43_nphy_stay_in_carrier_search(dev, 0); | ||
2597 | } | ||
2598 | |||
2599 | /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/SpurWar */ | 2655 | /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/SpurWar */ |
2600 | static void b43_nphy_spur_workaround(struct b43_wldev *dev) | 2656 | static void b43_nphy_spur_workaround(struct b43_wldev *dev) |
2601 | { | 2657 | { |
@@ -2655,20 +2711,6 @@ static void b43_nphy_spur_workaround(struct b43_wldev *dev) | |||
2655 | b43_nphy_stay_in_carrier_search(dev, 0); | 2711 | b43_nphy_stay_in_carrier_search(dev, 0); |
2656 | } | 2712 | } |
2657 | 2713 | ||
2658 | /* | ||
2659 | * Transmits a known value for LO calibration | ||
2660 | * http://bcm-v4.sipsolutions.net/802.11/PHY/N/TXTone | ||
2661 | */ | ||
2662 | static int b43_nphy_tx_tone(struct b43_wldev *dev, u32 freq, u16 max_val, | ||
2663 | bool iqmode, bool dac_test) | ||
2664 | { | ||
2665 | u16 samp = b43_nphy_gen_load_samples(dev, freq, max_val, dac_test); | ||
2666 | if (samp == 0) | ||
2667 | return -1; | ||
2668 | b43_nphy_run_samples(dev, samp, 0xFFFF, 0, iqmode, dac_test); | ||
2669 | return 0; | ||
2670 | } | ||
2671 | |||
2672 | /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxPwrCtrlCoefSetup */ | 2714 | /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxPwrCtrlCoefSetup */ |
2673 | static void b43_nphy_tx_pwr_ctrl_coef_setup(struct b43_wldev *dev) | 2715 | static void b43_nphy_tx_pwr_ctrl_coef_setup(struct b43_wldev *dev) |
2674 | { | 2716 | { |
@@ -2872,44 +2914,6 @@ static void b43_nphy_tx_cal_radio_setup(struct b43_wldev *dev) | |||
2872 | } | 2914 | } |
2873 | } | 2915 | } |
2874 | 2916 | ||
2875 | /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/IqCalGainParams */ | ||
2876 | static void b43_nphy_iq_cal_gain_params(struct b43_wldev *dev, u16 core, | ||
2877 | struct nphy_txgains target, | ||
2878 | struct nphy_iqcal_params *params) | ||
2879 | { | ||
2880 | int i, j, indx; | ||
2881 | u16 gain; | ||
2882 | |||
2883 | if (dev->phy.rev >= 3) { | ||
2884 | params->txgm = target.txgm[core]; | ||
2885 | params->pga = target.pga[core]; | ||
2886 | params->pad = target.pad[core]; | ||
2887 | params->ipa = target.ipa[core]; | ||
2888 | params->cal_gain = (params->txgm << 12) | (params->pga << 8) | | ||
2889 | (params->pad << 4) | (params->ipa); | ||
2890 | for (j = 0; j < 5; j++) | ||
2891 | params->ncorr[j] = 0x79; | ||
2892 | } else { | ||
2893 | gain = (target.pad[core]) | (target.pga[core] << 4) | | ||
2894 | (target.txgm[core] << 8); | ||
2895 | |||
2896 | indx = (b43_current_band(dev->wl) == IEEE80211_BAND_5GHZ) ? | ||
2897 | 1 : 0; | ||
2898 | for (i = 0; i < 9; i++) | ||
2899 | if (tbl_iqcal_gainparams[indx][i][0] == gain) | ||
2900 | break; | ||
2901 | i = min(i, 8); | ||
2902 | |||
2903 | params->txgm = tbl_iqcal_gainparams[indx][i][1]; | ||
2904 | params->pga = tbl_iqcal_gainparams[indx][i][2]; | ||
2905 | params->pad = tbl_iqcal_gainparams[indx][i][3]; | ||
2906 | params->cal_gain = (params->txgm << 7) | (params->pga << 4) | | ||
2907 | (params->pad << 2); | ||
2908 | for (j = 0; j < 4; j++) | ||
2909 | params->ncorr[j] = tbl_iqcal_gainparams[indx][i][4 + j]; | ||
2910 | } | ||
2911 | } | ||
2912 | |||
2913 | /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/UpdateTxCalLadder */ | 2917 | /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/UpdateTxCalLadder */ |
2914 | static void b43_nphy_update_tx_cal_ladder(struct b43_wldev *dev, u16 core) | 2918 | static void b43_nphy_update_tx_cal_ladder(struct b43_wldev *dev, u16 core) |
2915 | { | 2919 | { |