Commit 1c2d366e authored by Shayne Chen's avatar Shayne Chen Committed by Felix Fietkau

mt76: mt7915: fix eeprom fields of txpower init values

A-die 7976 has different offset and uses different channel group
definition on txpower init values.

Fixes: 99ad32a4 ("mt76: mt7915: add support for MT7986")
Signed-off-by: default avatarShayne Chen <shayne.chen@mediatek.com>
Signed-off-by: default avatarMeiChia Chiu <MeiChia.Chiu@mediatek.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent b4d093e3
...@@ -263,32 +263,38 @@ int mt7915_eeprom_get_target_power(struct mt7915_dev *dev, ...@@ -263,32 +263,38 @@ int mt7915_eeprom_get_target_power(struct mt7915_dev *dev,
{ {
u8 *eeprom = dev->mt76.eeprom.data; u8 *eeprom = dev->mt76.eeprom.data;
int index, target_power; int index, target_power;
bool tssi_on; bool tssi_on, is_7976;
if (chain_idx > 3) if (chain_idx > 3)
return -EINVAL; return -EINVAL;
tssi_on = mt7915_tssi_enabled(dev, chan->band); tssi_on = mt7915_tssi_enabled(dev, chan->band);
is_7976 = mt7915_check_adie(dev, false) || is_mt7916(&dev->mt76);
if (chan->band == NL80211_BAND_2GHZ) { if (chan->band == NL80211_BAND_2GHZ) {
u32 power = is_mt7915(&dev->mt76) ? if (is_7976) {
MT_EE_TX0_POWER_2G : MT_EE_TX0_POWER_2G_V2; index = MT_EE_TX0_POWER_2G_V2 + chain_idx;
target_power = eeprom[index];
index = power + chain_idx * 3; } else {
target_power = eeprom[index]; index = MT_EE_TX0_POWER_2G + chain_idx * 3;
target_power = eeprom[index];
if (!tssi_on) if (!tssi_on)
target_power += eeprom[index + 1]; target_power += eeprom[index + 1];
}
} else { } else {
int group = mt7915_get_channel_group(chan->hw_value); int group = mt7915_get_channel_group(chan->hw_value, is_7976);
u32 power = is_mt7915(&dev->mt76) ?
MT_EE_TX0_POWER_5G : MT_EE_TX0_POWER_5G_V2;
index = power + chain_idx * 12; if (is_7976) {
target_power = eeprom[index + group]; index = MT_EE_TX0_POWER_5G_V2 + chain_idx * 5;
target_power = eeprom[index + group];
} else {
index = MT_EE_TX0_POWER_5G + chain_idx * 12;
target_power = eeprom[index + group];
if (!tssi_on) if (!tssi_on)
target_power += eeprom[index + 8]; target_power += eeprom[index + 8];
}
} }
return target_power; return target_power;
...@@ -297,20 +303,16 @@ int mt7915_eeprom_get_target_power(struct mt7915_dev *dev, ...@@ -297,20 +303,16 @@ int mt7915_eeprom_get_target_power(struct mt7915_dev *dev,
s8 mt7915_eeprom_get_power_delta(struct mt7915_dev *dev, int band) s8 mt7915_eeprom_get_power_delta(struct mt7915_dev *dev, int band)
{ {
u8 *eeprom = dev->mt76.eeprom.data; u8 *eeprom = dev->mt76.eeprom.data;
u32 val; u32 val, offs;
s8 delta; s8 delta;
u32 rate_2g, rate_5g; bool is_7976 = mt7915_check_adie(dev, false) || is_mt7916(&dev->mt76);
rate_2g = is_mt7915(&dev->mt76) ?
MT_EE_RATE_DELTA_2G : MT_EE_RATE_DELTA_2G_V2;
rate_5g = is_mt7915(&dev->mt76) ?
MT_EE_RATE_DELTA_5G : MT_EE_RATE_DELTA_5G_V2;
if (band == NL80211_BAND_2GHZ) if (band == NL80211_BAND_2GHZ)
val = eeprom[rate_2g]; offs = is_7976 ? MT_EE_RATE_DELTA_2G_V2 : MT_EE_RATE_DELTA_2G;
else else
val = eeprom[rate_5g]; offs = is_7976 ? MT_EE_RATE_DELTA_5G_V2 : MT_EE_RATE_DELTA_5G;
val = eeprom[offs];
if (!(val & MT_EE_RATE_DELTA_EN)) if (!(val & MT_EE_RATE_DELTA_EN))
return 0; return 0;
......
...@@ -103,8 +103,20 @@ enum mt7915_sku_rate_group { ...@@ -103,8 +103,20 @@ enum mt7915_sku_rate_group {
}; };
static inline int static inline int
mt7915_get_channel_group(int channel) mt7915_get_channel_group(int channel, bool is_7976)
{ {
if (is_7976) {
if (channel <= 64)
return 0;
if (channel <= 96)
return 1;
if (channel <= 128)
return 2;
if (channel <= 144)
return 3;
return 4;
}
if (channel >= 184 && channel <= 196) if (channel >= 184 && channel <= 196)
return 0; return 0;
if (channel <= 48) if (channel <= 48)
......
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