aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt61pci.c
diff options
context:
space:
mode:
authorIvo van Doorn <ivdoorn@gmail.com>2008-08-06 10:22:17 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-08-22 16:29:59 -0400
commitba2ab47129eee76f6f0ef52b4beae30a12cee7f6 (patch)
treeaded96a0180e0e09122f1400a307f8d3d525feb0 /drivers/net/wireless/rt2x00/rt61pci.c
parent48c2fc59aa415ba92be0ad3a7e741c46883e3944 (diff)
rt2x00: Move lna_gain calculation to config() callback
We can optimize lna calculation in IRQ context by calculating most of the value during the config() callback when most of the value is actually influenced. This will be required later by rt2800pci and rt2800usb as well, since they need the lna_gain value during config(). Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt61pci.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.c48
1 files changed, 31 insertions, 17 deletions
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c
index 87012f88461f..0fcc45636834 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.c
+++ b/drivers/net/wireless/rt2x00/rt61pci.c
@@ -638,6 +638,30 @@ static void rt61pci_config_erp(struct rt2x00_dev *rt2x00dev,
638 rt2x00pci_register_write(rt2x00dev, TXRX_CSR4, reg); 638 rt2x00pci_register_write(rt2x00dev, TXRX_CSR4, reg);
639} 639}
640 640
641
642static void rt61pci_config_lna_gain(struct rt2x00_dev *rt2x00dev,
643 struct rt2x00lib_conf *libconf)
644{
645 u16 eeprom;
646 short lna_gain = 0;
647
648 if (libconf->band == IEEE80211_BAND_2GHZ) {
649 if (test_bit(CONFIG_EXTERNAL_LNA_BG, &rt2x00dev->flags))
650 lna_gain += 14;
651
652 rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_OFFSET_BG, &eeprom);
653 lna_gain -= rt2x00_get_field16(eeprom, EEPROM_RSSI_OFFSET_BG_1);
654 } else {
655 if (test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags))
656 lna_gain += 14;
657
658 rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_OFFSET_A, &eeprom);
659 lna_gain -= rt2x00_get_field16(eeprom, EEPROM_RSSI_OFFSET_A_1);
660 }
661
662 rt2x00dev->lna_gain = lna_gain;
663}
664
641static void rt61pci_config_phymode(struct rt2x00_dev *rt2x00dev, 665static void rt61pci_config_phymode(struct rt2x00_dev *rt2x00dev,
642 const int basic_rate_mask) 666 const int basic_rate_mask)
643{ 667{
@@ -956,6 +980,9 @@ static void rt61pci_config(struct rt2x00_dev *rt2x00dev,
956 struct rt2x00lib_conf *libconf, 980 struct rt2x00lib_conf *libconf,
957 const unsigned int flags) 981 const unsigned int flags)
958{ 982{
983 /* Always recalculate LNA gain before changing configuration */
984 rt61pci_config_lna_gain(rt2x00dev, libconf);
985
959 if (flags & CONFIG_UPDATE_PHYMODE) 986 if (flags & CONFIG_UPDATE_PHYMODE)
960 rt61pci_config_phymode(rt2x00dev, libconf->basic_rates); 987 rt61pci_config_phymode(rt2x00dev, libconf->basic_rates);
961 if (flags & CONFIG_UPDATE_CHANNEL) 988 if (flags & CONFIG_UPDATE_CHANNEL)
@@ -1883,40 +1910,27 @@ static void rt61pci_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
1883 */ 1910 */
1884static int rt61pci_agc_to_rssi(struct rt2x00_dev *rt2x00dev, int rxd_w1) 1911static int rt61pci_agc_to_rssi(struct rt2x00_dev *rt2x00dev, int rxd_w1)
1885{ 1912{
1886 u16 eeprom; 1913 u8 offset = rt2x00dev->lna_gain;
1887 u8 offset;
1888 u8 lna; 1914 u8 lna;
1889 1915
1890 lna = rt2x00_get_field32(rxd_w1, RXD_W1_RSSI_LNA); 1916 lna = rt2x00_get_field32(rxd_w1, RXD_W1_RSSI_LNA);
1891 switch (lna) { 1917 switch (lna) {
1892 case 3: 1918 case 3:
1893 offset = 90; 1919 offset += 90;
1894 break; 1920 break;
1895 case 2: 1921 case 2:
1896 offset = 74; 1922 offset += 74;
1897 break; 1923 break;
1898 case 1: 1924 case 1:
1899 offset = 64; 1925 offset += 64;
1900 break; 1926 break;
1901 default: 1927 default:
1902 return 0; 1928 return 0;
1903 } 1929 }
1904 1930
1905 if (rt2x00dev->rx_status.band == IEEE80211_BAND_5GHZ) { 1931 if (rt2x00dev->rx_status.band == IEEE80211_BAND_5GHZ) {
1906 if (test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags))
1907 offset += 14;
1908
1909 if (lna == 3 || lna == 2) 1932 if (lna == 3 || lna == 2)
1910 offset += 10; 1933 offset += 10;
1911
1912 rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_OFFSET_A, &eeprom);
1913 offset -= rt2x00_get_field16(eeprom, EEPROM_RSSI_OFFSET_A_1);
1914 } else {
1915 if (test_bit(CONFIG_EXTERNAL_LNA_BG, &rt2x00dev->flags))
1916 offset += 14;
1917
1918 rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_OFFSET_BG, &eeprom);
1919 offset -= rt2x00_get_field16(eeprom, EEPROM_RSSI_OFFSET_BG_1);
1920 } 1934 }
1921 1935
1922 return rt2x00_get_field32(rxd_w1, RXD_W1_RSSI_AGC) * 2 - offset; 1936 return rt2x00_get_field32(rxd_w1, RXD_W1_RSSI_AGC) * 2 - offset;