wifi: mt76: mt76x02: simplify struct mt76x02_rate_power
authorFelix Fietkau <nbd@nbd.name>
Wed, 28 Sep 2022 09:29:45 +0000 (11:29 +0200)
committerFelix Fietkau <nbd@nbd.name>
Thu, 1 Dec 2022 16:29:12 +0000 (17:29 +0100)
- remove stbc, because mt76x0 doesn't support it and mt76x2 uses the same
  values as HT/VHT
- reduce vht array to 2 elements, because VHT MCS0-7 are the same as HT

Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c
drivers/net/wireless/mediatek/mt76/mt76x02.h
drivers/net/wireless/mediatek/mt76/mt76x02_debugfs.c
drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.h
drivers/net/wireless/mediatek/mt76/mt76x02_phy.c
drivers/net/wireless/mediatek/mt76/mt76x02_txrx.c
drivers/net/wireless/mediatek/mt76/mt76x2/eeprom.c

index 103a6d3a1e1352c2d26a698dabcaa2e0a10c9c73..c3a392a1a659e8a0581809a3a5e03d9847085496 100644 (file)
@@ -179,31 +179,19 @@ void mt76x0_get_tx_power_per_rate(struct mt76x02_dev *dev,
        /* ht-vht mcs 1ss 0, 1, 2, 3 */
        addr = is_2ghz ? MT_EE_TX_POWER_BYRATE_BASE + 6 : 0x124;
        val = mt76x02_eeprom_get(dev, addr);
-       t->ht[0] = t->ht[1] = t->vht[0] = t->vht[1] = s6_to_s8(val);
-       t->ht[2] = t->ht[3] = t->vht[2] = t->vht[3] = s6_to_s8(val >> 8);
+       t->ht[0] = t->ht[1] = s6_to_s8(val);
+       t->ht[2] = t->ht[3] = s6_to_s8(val >> 8);
 
        /* ht-vht mcs 1ss 4, 5, 6 */
        addr = is_2ghz ? MT_EE_TX_POWER_BYRATE_BASE + 8 : 0x126;
        val = mt76x02_eeprom_get(dev, addr);
-       t->ht[4] = t->ht[5] = t->vht[4] = t->vht[5] = s6_to_s8(val);
-       t->ht[6] = t->ht[7] = t->vht[6] = t->vht[7] = s6_to_s8(val >> 8);
-
-       /* ht-vht mcs 1ss 0, 1, 2, 3 stbc */
-       addr = is_2ghz ? MT_EE_TX_POWER_BYRATE_BASE + 14 : 0xec;
-       val = mt76x02_eeprom_get(dev, addr);
-       t->stbc[0] = t->stbc[1] = s6_to_s8(val);
-       t->stbc[2] = t->stbc[3] = s6_to_s8(val >> 8);
-
-       /* ht-vht mcs 1ss 4, 5, 6 stbc */
-       addr = is_2ghz ? MT_EE_TX_POWER_BYRATE_BASE + 16 : 0xee;
-       val = mt76x02_eeprom_get(dev, addr);
-       t->stbc[4] = t->stbc[5] = s6_to_s8(val);
-       t->stbc[6] = t->stbc[7] = s6_to_s8(val >> 8);
+       t->ht[4] = t->ht[5] = s6_to_s8(val);
+       t->ht[6] = t->ht[7] = s6_to_s8(val >> 8);
 
        /* vht mcs 8, 9 5GHz */
        val = mt76x02_eeprom_get(dev, 0x12c);
-       t->vht[8] = s6_to_s8(val);
-       t->vht[9] = s6_to_s8(val >> 8);
+       t->vht[0] = s6_to_s8(val);
+       t->vht[1] = s6_to_s8(val >> 8);
 
        delta = mt76x0_tssi_enabled(dev) ? 0 : mt76x0_get_delta(dev);
        mt76x02_add_rate_power_offset(t, delta);
index ae6ba35e863d9283ab65da4d2aa79714e39eb166..a19176bb2433e4bdfa16a2a58aa2917a9a14465c 100644 (file)
@@ -77,11 +77,10 @@ struct mt76x02_rate_power {
                struct {
                        s8 cck[4];
                        s8 ofdm[8];
-                       s8 stbc[10];
                        s8 ht[16];
-                       s8 vht[10];
+                       s8 vht[2];
                };
-               s8 all[48];
+               s8 all[30];
        };
 };
 
index 066801620eb262522002b982c7a347bdb96369b5..981ac8e8480724b2f062bc3b5a850d135eec3364 100644 (file)
@@ -122,8 +122,6 @@ static int mt76x02_read_rate_txpower(struct seq_file *s, void *data)
                            ARRAY_SIZE(dev->rate_power.cck));
        mt76_seq_puts_array(s, "OFDM", dev->rate_power.ofdm,
                            ARRAY_SIZE(dev->rate_power.ofdm));
-       mt76_seq_puts_array(s, "STBC", dev->rate_power.stbc,
-                           ARRAY_SIZE(dev->rate_power.stbc));
        mt76_seq_puts_array(s, "HT", dev->rate_power.ht,
                            ARRAY_SIZE(dev->rate_power.ht));
        mt76_seq_puts_array(s, "VHT", dev->rate_power.vht,
index 99941a4700f35481c9ffd4a20a6e00eda778b3c8..13fa70853b0dbc62685a0deaf4829eb350e3a92e 100644 (file)
@@ -62,8 +62,6 @@ enum mt76x02_eeprom_field {
        MT_EE_TX_POWER_HT_MCS4 =                0x0a8,
        MT_EE_TX_POWER_HT_MCS8 =                0x0aa,
        MT_EE_TX_POWER_HT_MCS12 =               0x0ac,
-       MT_EE_TX_POWER_VHT_MCS0 =               0x0ba,
-       MT_EE_TX_POWER_VHT_MCS4 =               0x0bc,
        MT_EE_TX_POWER_VHT_MCS8 =               0x0be,
 
        MT_EE_2G_TARGET_POWER =                 0x0d0,
index 722dc2a7dea606727cb96a17516f7c3e4f629719..cbe7e6f0c29a4b51a77d3c1e28c3fa27c0097339 100644 (file)
@@ -107,17 +107,17 @@ void mt76x02_phy_set_txpower(struct mt76x02_dev *dev, int txp_0, int txp_1)
                mt76x02_tx_power_mask(t->ht[4], t->ht[6], t->ht[8],
                                      t->ht[10]));
        mt76_wr(dev, MT_TX_PWR_CFG_3,
-               mt76x02_tx_power_mask(t->ht[12], t->ht[14], t->stbc[0],
-                                     t->stbc[2]));
+               mt76x02_tx_power_mask(t->ht[12], t->ht[14], t->ht[0],
+                                     t->ht[2]));
        mt76_wr(dev, MT_TX_PWR_CFG_4,
-               mt76x02_tx_power_mask(t->stbc[4], t->stbc[6], 0, 0));
+               mt76x02_tx_power_mask(t->ht[4], t->ht[6], 0, 0));
        mt76_wr(dev, MT_TX_PWR_CFG_7,
-               mt76x02_tx_power_mask(t->ofdm[7], t->vht[8], t->ht[7],
-                                     t->vht[9]));
+               mt76x02_tx_power_mask(t->ofdm[7], t->vht[0], t->ht[7],
+                                     t->vht[1]));
        mt76_wr(dev, MT_TX_PWR_CFG_8,
-               mt76x02_tx_power_mask(t->ht[14], 0, t->vht[8], t->vht[9]));
+               mt76x02_tx_power_mask(t->ht[14], 0, t->vht[0], t->vht[1]));
        mt76_wr(dev, MT_TX_PWR_CFG_9,
-               mt76x02_tx_power_mask(t->ht[7], 0, t->stbc[8], t->stbc[9]));
+               mt76x02_tx_power_mask(t->ht[7], 0, t->vht[0], t->vht[1]));
 }
 EXPORT_SYMBOL_GPL(mt76x02_phy_set_txpower);
 
index 1e1ef24999775f1e3f16695672680cd1d337c188..3a313075a9e3f6dc6ce07f876c0d6c6733ecef62 100644 (file)
@@ -62,7 +62,7 @@ s8 mt76x02_tx_get_max_txpwr_adj(struct mt76x02_dev *dev,
                u8 mcs = ieee80211_rate_get_vht_mcs(rate);
 
                if (mcs == 8 || mcs == 9) {
-                       max_txpwr = dev->rate_power.vht[8];
+                       max_txpwr = dev->rate_power.vht[0];
                } else {
                        u8 nss, idx;
 
index d1d7e06c3fa5773804b06247fe8c51398ac3da7e..d5809408d1d3720fbfb7f7396242b5e5cae1301a 100644 (file)
@@ -324,22 +324,10 @@ void mt76x2_get_rate_power(struct mt76x02_dev *dev, struct mt76x02_rate_power *t
        t->ht[12] = t->ht[13] = mt76x02_rate_power_val(val);
        t->ht[14] = t->ht[15] = mt76x02_rate_power_val(val >> 8);
 
-       val = mt76x02_eeprom_get(dev, MT_EE_TX_POWER_VHT_MCS0);
-       t->vht[0] = t->vht[1] = mt76x02_rate_power_val(val);
-       t->vht[2] = t->vht[3] = mt76x02_rate_power_val(val >> 8);
-
-       val = mt76x02_eeprom_get(dev, MT_EE_TX_POWER_VHT_MCS4);
-       t->vht[4] = t->vht[5] = mt76x02_rate_power_val(val);
-       t->vht[6] = t->vht[7] = mt76x02_rate_power_val(val >> 8);
-
        val = mt76x02_eeprom_get(dev, MT_EE_TX_POWER_VHT_MCS8);
        if (!is_5ghz)
                val >>= 8;
-       t->vht[8] = t->vht[9] = mt76x02_rate_power_val(val >> 8);
-
-       memcpy(t->stbc, t->ht, sizeof(t->stbc[0]) * 8);
-       t->stbc[8] = t->vht[8];
-       t->stbc[9] = t->vht[9];
+       t->vht[0] = t->vht[1] = mt76x02_rate_power_val(val >> 8);
 }
 EXPORT_SYMBOL_GPL(mt76x2_get_rate_power);