From: Gabor Juhos <juhosg@openwrt.org>
To: John Linville <linville@tuxdriver.com>
Cc: linux-wireless@vger.kernel.org, users@rt2x00.serialmonkey.com,
Gabor Juhos <juhosg@openwrt.org>
Subject: [PATCH v3 12/20] rt2x00: rt2800lib: fix LNA_A[12] gain values for RT3593
Date: Mon, 8 Jul 2013 16:08:27 +0200 [thread overview]
Message-ID: <1373292515-21332-13-git-send-email-juhosg@openwrt.org> (raw)
In-Reply-To: <1373292515-21332-1-git-send-email-juhosg@openwrt.org>
The LNA_A[12] gain values are stored at a different
offset in the EEPROM on RT3593 based devices. However
the current code unconditionally reads those values
from the location used by other chipsets.
Fix the code to use the correct EEPROM offset.
Based on the DPO_RT5572_LinuxSTA_2.6.0.1_20120629
driver.
References:
RT3593_EEPROM_RSSI2_OFFSET_ALNAGAIN1_24G_READ in include/chip/rt3593.h
RT3593_EEPROM_RSSI2_OFFSET_ALNAGAIN2_5G_READ in include/chip/rt3593.h
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>
---
Changes since v2:
- replace 'rt2x00lib' with 'rt2800lib' in subject
---
drivers/net/wireless/rt2x00/rt2800.h | 4 +++
drivers/net/wireless/rt2x00/rt2800lib.c | 55 ++++++++++++++++++++++++-------
2 files changed, 47 insertions(+), 12 deletions(-)
diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h
index 69749ba5..7688e15 100644
--- a/drivers/net/wireless/rt2x00/rt2800.h
+++ b/drivers/net/wireless/rt2x00/rt2800.h
@@ -2672,6 +2672,10 @@ enum rt2800_eeprom_word {
#define EEPROM_BBP_VALUE FIELD16(0x00ff)
#define EEPROM_BBP_REG_ID FIELD16(0xff00)
+/* EEPROM_EXT_LNA2 */
+#define EEPROM_EXT_LNA2_A1 FIELD16(0x00ff)
+#define EEPROM_EXT_LNA2_A2 FIELD16(0xff00)
+
/*
* EEPROM IQ Calibration, unlike other entries those are byte addresses.
*/
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index 65045e0..419ea05 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -1826,11 +1826,25 @@ static void rt2800_config_lna_gain(struct rt2x00_dev *rt2x00dev,
rt2800_eeprom_read(rt2x00dev, EEPROM_LNA, &eeprom);
lna_gain = rt2x00_get_field16(eeprom, EEPROM_LNA_A0);
} else if (libconf->rf.channel <= 128) {
- rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &eeprom);
- lna_gain = rt2x00_get_field16(eeprom, EEPROM_RSSI_BG2_LNA_A1);
+ if (rt2x00_rt(rt2x00dev, RT3593)) {
+ rt2800_eeprom_read(rt2x00dev, EEPROM_EXT_LNA2, &eeprom);
+ lna_gain = rt2x00_get_field16(eeprom,
+ EEPROM_EXT_LNA2_A1);
+ } else {
+ rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &eeprom);
+ lna_gain = rt2x00_get_field16(eeprom,
+ EEPROM_RSSI_BG2_LNA_A1);
+ }
} else {
- rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, &eeprom);
- lna_gain = rt2x00_get_field16(eeprom, EEPROM_RSSI_A2_LNA_A2);
+ if (rt2x00_rt(rt2x00dev, RT3593)) {
+ rt2800_eeprom_read(rt2x00dev, EEPROM_EXT_LNA2, &eeprom);
+ lna_gain = rt2x00_get_field16(eeprom,
+ EEPROM_EXT_LNA2_A2);
+ } else {
+ rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, &eeprom);
+ lna_gain = rt2x00_get_field16(eeprom,
+ EEPROM_RSSI_A2_LNA_A2);
+ }
}
rt2x00dev->lna_gain = lna_gain;
@@ -6488,10 +6502,12 @@ static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &word);
if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG2_OFFSET2)) > 10)
rt2x00_set_field16(&word, EEPROM_RSSI_BG2_OFFSET2, 0);
- if (rt2x00_get_field16(word, EEPROM_RSSI_BG2_LNA_A1) == 0x00 ||
- rt2x00_get_field16(word, EEPROM_RSSI_BG2_LNA_A1) == 0xff)
- rt2x00_set_field16(&word, EEPROM_RSSI_BG2_LNA_A1,
- default_lna_gain);
+ if (!rt2x00_rt(rt2x00dev, RT3593)) {
+ if (rt2x00_get_field16(word, EEPROM_RSSI_BG2_LNA_A1) == 0x00 ||
+ rt2x00_get_field16(word, EEPROM_RSSI_BG2_LNA_A1) == 0xff)
+ rt2x00_set_field16(&word, EEPROM_RSSI_BG2_LNA_A1,
+ default_lna_gain);
+ }
rt2800_eeprom_write(rt2x00dev, EEPROM_RSSI_BG2, word);
drv_data->txmixer_gain_5g = rt2800_get_txmixer_gain_5g(rt2x00dev);
@@ -6506,12 +6522,27 @@ static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, &word);
if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A2_OFFSET2)) > 10)
rt2x00_set_field16(&word, EEPROM_RSSI_A2_OFFSET2, 0);
- if (rt2x00_get_field16(word, EEPROM_RSSI_A2_LNA_A2) == 0x00 ||
- rt2x00_get_field16(word, EEPROM_RSSI_A2_LNA_A2) == 0xff)
- rt2x00_set_field16(&word, EEPROM_RSSI_A2_LNA_A2,
- default_lna_gain);
+ if (!rt2x00_rt(rt2x00dev, RT3593)) {
+ if (rt2x00_get_field16(word, EEPROM_RSSI_A2_LNA_A2) == 0x00 ||
+ rt2x00_get_field16(word, EEPROM_RSSI_A2_LNA_A2) == 0xff)
+ rt2x00_set_field16(&word, EEPROM_RSSI_A2_LNA_A2,
+ default_lna_gain);
+ }
rt2800_eeprom_write(rt2x00dev, EEPROM_RSSI_A2, word);
+ if (rt2x00_rt(rt2x00dev, RT3593)) {
+ rt2800_eeprom_read(rt2x00dev, EEPROM_EXT_LNA2, &word);
+ if (rt2x00_get_field16(word, EEPROM_EXT_LNA2_A1) == 0x00 ||
+ rt2x00_get_field16(word, EEPROM_EXT_LNA2_A1) == 0xff)
+ rt2x00_set_field16(&word, EEPROM_EXT_LNA2_A1,
+ default_lna_gain);
+ if (rt2x00_get_field16(word, EEPROM_EXT_LNA2_A2) == 0x00 ||
+ rt2x00_get_field16(word, EEPROM_EXT_LNA2_A2) == 0xff)
+ rt2x00_set_field16(&word, EEPROM_EXT_LNA2_A1,
+ default_lna_gain);
+ rt2800_eeprom_write(rt2x00dev, EEPROM_EXT_LNA2, word);
+ }
+
return 0;
}
--
1.7.10
next prev parent reply other threads:[~2013-07-08 14:08 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-08 14:08 [PATCH v3 00/20] rt2x00: add experimental support for RT3593 Gabor Juhos
2013-07-08 14:08 ` [PATCH v3 01/20] rt2x00: rt2800lib: add MAC register initialization " Gabor Juhos
2013-07-08 14:08 ` [PATCH v3 02/20] rt2x00: rt2800lib: add BBP " Gabor Juhos
2013-07-08 14:08 ` [PATCH v3 03/20] rt2x00: rt2800lib: add RFCSR " Gabor Juhos
2013-07-08 14:08 ` [PATCH v3 04/20] rt2x00: rt2800lib: add BBP post " Gabor Juhos
2013-07-08 14:08 ` [PATCH v3 05/20] rt2x00: rt2800lib: add TX power configuration " Gabor Juhos
2013-07-08 14:08 ` [PATCH v3 06/20] rt2x00: rt2800lib: fix BBP1_TX_ANTENNA field configuration for 3T devices Gabor Juhos
2013-07-08 14:08 ` [PATCH v3 07/20] rt2x00: rt2800lib: fix antenna configuration for RT3593 Gabor Juhos
2013-07-08 14:08 ` [PATCH v3 08/20] rt2x00: rt2800lib: add rt2800_txpower_to_dev helper Gabor Juhos
2013-07-08 14:08 ` [PATCH v3 09/20] rt2x00: rt2800lib: fix default TX power values for RT3593 Gabor Juhos
2013-07-08 14:08 ` [PATCH v3 10/20] rt2x00: rt2800lib: introduce rt2800_get_txmixer_gain_{24,5}g helpers Gabor Juhos
2013-07-08 14:08 ` [PATCH v3 11/20] rt2x00: rt2800lib: hardcode TX mixer gain values for RT3593 Gabor Juhos
2013-07-08 14:08 ` Gabor Juhos [this message]
2013-07-08 14:08 ` [PATCH v3 13/20] rt2x00: rt2800lib: add default_power3 field for three-chain devices Gabor Juhos
2013-07-08 14:08 ` [PATCH v3 14/20] rt2x00: rt2800lib: add rf_vals for RF3053 Gabor Juhos
2013-07-08 14:08 ` [PATCH v3 15/20] rt2x00: rt2800lib: add channel configuration " Gabor Juhos
2013-07-08 14:08 ` [PATCH v3 16/20] rt2x00: rt2800lib: enable VCO recalibration " Gabor Juhos
2013-07-08 14:08 ` [PATCH v3 17/20] rt2x00: rt2800lib: enable RF3053 support Gabor Juhos
2013-07-08 14:08 ` [PATCH v3 18/20] rt2x00: rt2800lib: enable RT3593 support Gabor Juhos
2013-07-08 14:08 ` [PATCH v3 19/20] rt2x00: rt2800usb: use correct [RT]XWI size for RT3593 Gabor Juhos
2013-07-08 14:08 ` [PATCH v3 20/20] rt2x00: rt2800usb: add USB device ID for Linksys AE3000 Gabor Juhos
2013-07-22 15:48 ` [PATCH v3 00/20] rt2x00: add experimental support for RT3593 Gertjan van Wingerde
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1373292515-21332-13-git-send-email-juhosg@openwrt.org \
--to=juhosg@openwrt.org \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=users@rt2x00.serialmonkey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox