mt76x0: unify temperature offset parsing
Unify temperature offset parsing with mt76x2 driver using eeprom utility routines available in mt76x02-lib module Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:

committed by
Felix Fietkau

vanhempi
564d7f0acc
commit
2c0db839b4
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -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];
|
||||
|
@@ -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);
|
||||
|
@@ -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,
|
||||
|
Viittaa uudesa ongelmassa
Block a user