From: Lorenzo Bianconi <lorenzo.bianconi-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: nbd-Vt+b4OUoWG0@public.gmane.org
Cc: linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
sgruszka-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: [PATCH 13/20] mt76x0: unify temperature offset parsing
Date: Thu, 20 Sep 2018 11:12:00 +0200 [thread overview]
Message-ID: <fc9f2c95df42d3d7ca5bbbb4ecd9f3771cd01aa8.1537433365.git.lorenzo.bianconi@redhat.com> (raw)
In-Reply-To: <cover.1537433365.git.lorenzo.bianconi-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Unify temperature offset parsing with mt76x2 driver using
eeprom utility routines available in mt76x02-lib module
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
.../net/wireless/mediatek/mt76/mt76x0/debugfs.c | 3 ++-
drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c | 14 +++++++-------
drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.h | 3 ++-
drivers/net/wireless/mediatek/mt76/mt76x0/phy.c | 2 +-
.../net/wireless/mediatek/mt76/mt76x02_eeprom.h | 1 +
5 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt76x0/debugfs.c
index b6f467e7ee8c..d138ed3bda17 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/debugfs.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/debugfs.c
@@ -105,7 +105,8 @@ mt76x0_eeprom_param_read(struct seq_file *file, void *data)
seq_printf(file, "RF freq offset: %hhx\n", dev->ee->rf_freq_off);
seq_printf(file, "RSSI offset: %hhx %hhx\n",
dev->caldata.rssi_offset[0], dev->caldata.rssi_offset[1]);
- seq_printf(file, "Temperature offset: %hhx\n", dev->ee->temp_off);
+ seq_printf(file, "Temperature offset: %hhx\n",
+ dev->caldata.temp_offset);
seq_printf(file, "LNA gain: %x\n", dev->caldata.lna_gain);
val = mt76x02_eeprom_get(&dev->mt76, MT_EE_NIC_CONF_0);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c b/drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c
index 6c24274d23f4..ae7c11519b0a 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c
@@ -92,15 +92,15 @@ mt76x0_set_chip_cap(struct mt76x0_dev *dev, u8 *eeprom)
"Error: device has more than 1 RX/TX stream!\n");
}
-static void
-mt76x0_set_temp_offset(struct mt76x0_dev *dev, u8 *eeprom)
+static void mt76x0_set_temp_offset(struct mt76x0_dev *dev)
{
- u8 temp = eeprom[MT_EE_TEMP_OFFSET];
+ u8 val;
- if (mt76x02_field_valid(temp))
- dev->ee->temp_off = mt76x02_sign_extend(temp, 8);
+ val = mt76x02_eeprom_get(&dev->mt76, MT_EE_2G_TARGET_POWER) >> 8;
+ if (mt76x02_field_valid(val))
+ dev->caldata.temp_offset = mt76x02_sign_extend(val, 8);
else
- dev->ee->temp_off = -10;
+ dev->caldata.temp_offset = -10;
}
static void
@@ -287,7 +287,7 @@ mt76x0_eeprom_init(struct mt76x0_dev *dev)
mt76x02_mac_setaddr(&dev->mt76, eeprom + MT_EE_MAC_ADDR);
mt76x0_set_chip_cap(dev, eeprom);
mt76x0_set_rf_freq_off(dev, eeprom);
- mt76x0_set_temp_offset(dev, eeprom);
+ mt76x0_set_temp_offset(dev);
dev->chainmask = 0x0101;
mt76x0_set_tx_power_per_rate(dev, eeprom);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.h b/drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.h
index dd9cb0d2de41..55e624cf7f2a 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.h
@@ -31,11 +31,12 @@ struct reg_channel_bounds {
struct mt76x0_caldata {
s8 rssi_offset[2];
s8 lna_gain;
+
+ s16 temp_offset;
};
struct mt76x0_eeprom_params {
u8 rf_freq_off;
- s16 temp_off;
/* TX_PWR_CFG_* values from EEPROM for 20 and 40 Mhz bandwidths. */
u32 tx_pwr_cfg_2g[5][2];
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
index 72d0ddc381b9..dbe9e2ee5def 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
@@ -836,7 +836,7 @@ static void mt76x0_temp_sensor(struct mt76x0_dev *dev)
else
sval |= 0xffffff00; /* Negative */
- temp = (35 * (sval - dev->ee->temp_off))/ 10 + 25;
+ temp = (35 * (sval - dev->caldata.temp_offset)) / 10 + 25;
done:
rf_wr(dev, MT_RF(7, 73), rf_b7_73);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.h b/drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.h
index c22ca507b418..2132af9f8c94 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.h
@@ -72,6 +72,7 @@ enum mt76x02_eeprom_field {
MT_EE_TX_POWER_VHT_MCS4 = 0x0bc,
MT_EE_TX_POWER_VHT_MCS8 = 0x0be,
+ MT_EE_2G_TARGET_POWER = 0x0d0,
MT_EE_TEMP_OFFSET = 0x0d1,
MT_EE_FREQ_OFFSET_COMPENSATION = 0x0db,
MT_EE_TX_POWER_BYRATE_BASE = 0x0de,
--
2.17.1
next prev parent reply other threads:[~2018-09-20 9:12 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-20 9:11 [PATCH 00/20] unify mt76x2 and mt76x0 eeprom code Lorenzo Bianconi
[not found] ` <cover.1537433365.git.lorenzo.bianconi-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2018-09-20 9:11 ` [PATCH 01/20] mt76: move seq_put_array in mt76-core module Lorenzo Bianconi
2018-09-20 9:11 ` [PATCH 02/20] mt76: add stbc entries to mt76_rate_power Lorenzo Bianconi
[not found] ` <15d756db7fef57befcc2e2e28e640be10493df88.1537433365.git.lorenzo.bianconi-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2018-09-21 16:09 ` Felix Fietkau
2018-09-20 9:11 ` [PATCH 03/20] mt76: move common eeprom definitions in mt76x02-lib module Lorenzo Bianconi
2018-09-20 9:11 ` [PATCH 04/20] mt76: move eeprom utility routines in mt76x02_eeprom.h Lorenzo Bianconi
2018-09-20 9:11 ` [PATCH 05/20] mt76: move mt76x2_eeprom_get " Lorenzo Bianconi
2018-09-20 9:11 ` [PATCH 06/20] mt76: move mt76x02_mac_setaddr in mt76x02-lib module Lorenzo Bianconi
2018-09-20 9:11 ` [PATCH 07/20] mt76: move mt76x2_get_efuse_data " Lorenzo Bianconi
2018-09-20 9:11 ` [PATCH 08/20] mt76: move mt76x2_ext_pa_enabled routine in mt76x02_eeprom.c Lorenzo Bianconi
2018-09-20 9:11 ` [PATCH 09/20] mt76x0: remove mt76x0_set_country_reg routine Lorenzo Bianconi
2018-09-20 9:11 ` [PATCH 10/20] mt76: add mt76x02_get_rx_gain and mt76x02_get_lna_gain utility routines Lorenzo Bianconi
2018-09-20 9:11 ` [PATCH 11/20] mt76x0: unify lna_gain parsing Lorenzo Bianconi
2018-09-20 9:11 ` [PATCH 12/20] mt76x0: unify rssi_offset parsing Lorenzo Bianconi
2018-09-20 9:12 ` Lorenzo Bianconi [this message]
2018-09-20 9:12 ` [PATCH 14/20] mt76x0: unify freq offset parsing Lorenzo Bianconi
2018-09-20 9:12 ` [PATCH 15/20] mt76: move mt76x02_eeprom_parse_hw_cap in mt76x02-lib module Lorenzo Bianconi
2018-09-20 9:12 ` [PATCH 16/20] mt76x0: unify parse hw capabilities Lorenzo Bianconi
2018-09-20 9:12 ` [PATCH 17/20] mt76: move mt76x2_tssi_enabled in mt76x02_eeprom.h Lorenzo Bianconi
2018-09-20 9:12 ` [PATCH 18/20] mt76x0: remove eeprom dependency from mt76x0_set_tx_power_per_rate Lorenzo Bianconi
2018-09-20 9:12 ` [PATCH 19/20] mt76x0: remove eeprom dependency from mt76x0_set_tx_power_per_chan Lorenzo Bianconi
2018-09-20 9:12 ` [PATCH 20/20] mt76x0: use shared debugfs implementation Lorenzo Bianconi
2018-09-20 12:40 ` [PATCH 00/20] unify mt76x2 and mt76x0 eeprom code Felix Fietkau
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=fc9f2c95df42d3d7ca5bbbb4ecd9f3771cd01aa8.1537433365.git.lorenzo.bianconi@redhat.com \
--to=lorenzo.bianconi-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
--cc=linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=nbd-Vt+b4OUoWG0@public.gmane.org \
--cc=sgruszka-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
/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