Commit a3f1625d authored by Gabor Juhos's avatar Gabor Juhos Committed by John W. Linville

rt2x00: rt2800lib: introduce rt2800_get_txmixer_gain_{24,5}g helpers

Move the TX mixer gain reading code into separate
helper functions in preparation for RT3593 support.
Signed-off-by: default avatarGabor Juhos <juhosg@openwrt.org>
Acked-by: default avatarStanislaw Gruszka <stf_xl@wp.pl>
Acked-by: default avatarGertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent fc739cfe
...@@ -6361,6 +6361,28 @@ int rt2800_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev) ...@@ -6361,6 +6361,28 @@ int rt2800_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
} }
EXPORT_SYMBOL_GPL(rt2800_read_eeprom_efuse); EXPORT_SYMBOL_GPL(rt2800_read_eeprom_efuse);
static u8 rt2800_get_txmixer_gain_24g(struct rt2x00_dev *rt2x00dev)
{
u16 word;
rt2800_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_BG, &word);
if ((word & 0x00ff) != 0x00ff)
return rt2x00_get_field16(word, EEPROM_TXMIXER_GAIN_BG_VAL);
return 0;
}
static u8 rt2800_get_txmixer_gain_5g(struct rt2x00_dev *rt2x00dev)
{
u16 word;
rt2800_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_A, &word);
if ((word & 0x00ff) != 0x00ff)
return rt2x00_get_field16(word, EEPROM_TXMIXER_GAIN_A_VAL);
return 0;
}
static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev) static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
{ {
struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; struct rt2800_drv_data *drv_data = rt2x00dev->drv_data;
...@@ -6455,13 +6477,7 @@ static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev) ...@@ -6455,13 +6477,7 @@ static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
rt2x00_set_field16(&word, EEPROM_RSSI_BG_OFFSET1, 0); rt2x00_set_field16(&word, EEPROM_RSSI_BG_OFFSET1, 0);
rt2800_eeprom_write(rt2x00dev, EEPROM_RSSI_BG, word); rt2800_eeprom_write(rt2x00dev, EEPROM_RSSI_BG, word);
rt2800_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_BG, &word); drv_data->txmixer_gain_24g = rt2800_get_txmixer_gain_24g(rt2x00dev);
if ((word & 0x00ff) != 0x00ff) {
drv_data->txmixer_gain_24g =
rt2x00_get_field16(word, EEPROM_TXMIXER_GAIN_BG_VAL);
} else {
drv_data->txmixer_gain_24g = 0;
}
rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &word); rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &word);
if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG2_OFFSET2)) > 10) if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG2_OFFSET2)) > 10)
...@@ -6472,13 +6488,7 @@ static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev) ...@@ -6472,13 +6488,7 @@ static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
default_lna_gain); default_lna_gain);
rt2800_eeprom_write(rt2x00dev, EEPROM_RSSI_BG2, word); rt2800_eeprom_write(rt2x00dev, EEPROM_RSSI_BG2, word);
rt2800_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_A, &word); drv_data->txmixer_gain_5g = rt2800_get_txmixer_gain_5g(rt2x00dev);
if ((word & 0x00ff) != 0x00ff) {
drv_data->txmixer_gain_5g =
rt2x00_get_field16(word, EEPROM_TXMIXER_GAIN_A_VAL);
} else {
drv_data->txmixer_gain_5g = 0;
}
rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_A, &word); rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_A, &word);
if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A_OFFSET0)) > 10) if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A_OFFSET0)) > 10)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment