]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
mt76: move set_{tx,rx}_path routines in mt76x02-lib module
authorLorenzo Bianconi <lorenzo.bianconi@redhat.com>
Fri, 28 Sep 2018 11:39:03 +0000 (13:39 +0200)
committerFelix Fietkau <nbd@nbd.name>
Mon, 1 Oct 2018 10:34:39 +0000 (12:34 +0200)
Move mt76x02_phy_set_rxpath and mt76x02_phy_tx_dac routines in
mt76x02_phy.c since they are shared between mt76x2 and mt76x0 drivers.
Moreover move chainmask variable from mt76x2/mt76x0 to mt76_dev data
structure

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
13 files changed:
drivers/net/wireless/mediatek/mt76/mt76.h
drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c
drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h
drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
drivers/net/wireless/mediatek/mt76/mt76x02_phy.c
drivers/net/wireless/mediatek/mt76/mt76x02_phy.h
drivers/net/wireless/mediatek/mt76/mt76x2.h
drivers/net/wireless/mediatek/mt76/mt76x2_init_common.c
drivers/net/wireless/mediatek/mt76/mt76x2_main.c
drivers/net/wireless/mediatek/mt76/mt76x2_mcu_common.c
drivers/net/wireless/mediatek/mt76/mt76x2u.h
drivers/net/wireless/mediatek/mt76/mt76x2u_init.c
drivers/net/wireless/mediatek/mt76/mt76x2u_phy.c

index 9b800f009e6ef3ead30dacf9fa93f01a1041add9..f2dd4d87e355a85800284ec49819ae66af41d1c0 100644 (file)
@@ -404,6 +404,7 @@ struct mt76_dev {
        unsigned long state;
 
        u8 antenna_mask;
+       u16 chainmask;
 
        struct mt76_sband sband_2g;
        struct mt76_sband sband_5g;
index 3d712f6d7078683978796e8902d5f001ae2726ab..ef9c3df6a1699be8feb4fcd466d26b9d52ec484e 100644 (file)
@@ -313,7 +313,7 @@ int mt76x0_eeprom_init(struct mt76x0_dev *dev)
        mt76x0_set_freq_offset(dev);
        mt76x0_set_temp_offset(dev);
 
-       dev->chainmask = 0x0101;
+       dev->mt76.chainmask = 0x0101;
 
        return 0;
 }
index e2e23df1b40aa38fd3131ba2936e1760802351e6..08e081e32852457a53ec4c9764c794c0c8b25329 100644 (file)
@@ -104,7 +104,6 @@ struct mt76x0_dev {
        int avg_rssi; /* starts at 0 and converges */
 
        u8 agc_save;
-       u16 chainmask;
 
        bool no_2ghz;
 
index fe754fe039cc54a21ed780a3524e8d8a4a7c952c..4fd2c65e196aa1ca7e4d70d9ec00b987aad60e08 100644 (file)
@@ -855,32 +855,6 @@ void mt76x0_phy_con_cal_onoff(struct mt76x0_dev *dev,
        spin_unlock_bh(&dev->con_mon_lock);
 }
 
-static void
-mt76x0_set_rx_chains(struct mt76x0_dev *dev)
-{
-       u32 val;
-
-       val = mt76_rr(dev, MT_BBP(AGC, 0));
-       val &= ~(BIT(3) | BIT(4));
-
-       if (dev->chainmask & BIT(1))
-               val |= BIT(3);
-
-       mt76_wr(dev, MT_BBP(AGC, 0), val);
-
-       mb();
-       val = mt76_rr(dev, MT_BBP(AGC, 0));
-}
-
-static void
-mt76x0_set_tx_dac(struct mt76x0_dev *dev)
-{
-       if (dev->chainmask & BIT(1))
-               mt76_set(dev, MT_BBP(TXBE, 5), 3);
-       else
-               mt76_clear(dev, MT_BBP(TXBE, 5), 3);
-}
-
 static void
 mt76x0_rf_init(struct mt76x0_dev *dev)
 {
@@ -940,7 +914,6 @@ void mt76x0_phy_init(struct mt76x0_dev *dev)
        INIT_DELAYED_WORK(&dev->cal_work, mt76x0_phy_calibrate);
 
        mt76x0_rf_init(dev);
-
-       mt76x0_set_rx_chains(dev);
-       mt76x0_set_tx_dac(dev);
+       mt76x02_phy_set_rxpath(&dev->mt76);
+       mt76x02_phy_set_txdac(&dev->mt76);
 }
index 969854b69981ab5ba569d3c3f5f8190adb4a7fe6..e29914d78b726b7dd0fa60e4125883a66e4a3f64 100644 (file)
 #include "mt76.h"
 #include "mt76x02_phy.h"
 
+void mt76x02_phy_set_rxpath(struct mt76_dev *dev)
+{
+       u32 val;
+
+       val = __mt76_rr(dev, MT_BBP(AGC, 0));
+       val &= ~BIT(4);
+
+       switch (dev->chainmask & 0xf) {
+       case 2:
+               val |= BIT(3);
+               break;
+       default:
+               val &= ~BIT(3);
+               break;
+       }
+
+       __mt76_wr(dev, MT_BBP(AGC, 0), val);
+       mb();
+       val = __mt76_rr(dev, MT_BBP(AGC, 0));
+}
+EXPORT_SYMBOL_GPL(mt76x02_phy_set_rxpath);
+
+void mt76x02_phy_set_txdac(struct mt76_dev *dev)
+{
+       int txpath;
+
+       txpath = (dev->chainmask >> 8) & 0xf;
+       switch (txpath) {
+       case 2:
+               __mt76_set(dev, MT_BBP(TXBE, 5), 0x3);
+               break;
+       default:
+               __mt76_clear(dev, MT_BBP(TXBE, 5), 0x3);
+               break;
+       }
+}
+EXPORT_SYMBOL_GPL(mt76x02_phy_set_txdac);
+
 static u32
 mt76x02_tx_power_mask(u8 v1, u8 v2, u8 v3, u8 v4)
 {
index 25567f9f507064d3418baca00dfd16d12a7c010f..df69f8fade753c3b4fb3bce3cd443cf402574b98 100644 (file)
@@ -23,5 +23,7 @@ void mt76x02_add_rate_power_offset(struct mt76_rate_power *r, int offset);
 void mt76x02_phy_set_txpower(struct mt76_dev *dev, int txp_0, int txp_2);
 void mt76x02_limit_rate_power(struct mt76_rate_power *r, int limit);
 int mt76x02_get_max_rate_power(struct mt76_rate_power *r);
+void mt76x02_phy_set_rxpath(struct mt76_dev *dev);
+void mt76x02_phy_set_txdac(struct mt76_dev *dev);
 
 #endif /* __MT76x02_PHY_H */
index 9bf8be5ea1cdccd32461aed46f81c24ecdc25ed4..d6ccab06a5940bb8b5a6c0b42dd32a74e3a644ec 100644 (file)
@@ -97,8 +97,6 @@ struct mt76x2_dev {
        u8 tbtt_count;
        u16 beacon_int;
 
-       u16 chainmask;
-
        struct mt76x2_calibration cal;
 
        s8 target_power;
index 4eacc681de497013d41f0f70a9eb0bf2cf5bcaa0..f4c4cde9301eca32ca9aeb24a1cf3ff33a47cb17 100644 (file)
@@ -177,7 +177,7 @@ void mt76x2_init_device(struct mt76x2_dev *dev)
        dev->mt76.sband_2g.sband.ht_cap.cap |= IEEE80211_HT_CAP_LDPC_CODING;
        dev->mt76.sband_5g.sband.ht_cap.cap |= IEEE80211_HT_CAP_LDPC_CODING;
 
-       dev->chainmask = 0x202;
+       dev->mt76.chainmask = 0x202;
        dev->mt76.global_wcid.idx = 255;
        dev->mt76.global_wcid.hw_key_idx = -1;
        dev->slottime = 9;
index 24b13eeba8af59b6c13b9ac0ef8b6a286b76d556..63691b68a436d815b27f5e4e9d094e360aed458e 100644 (file)
@@ -241,7 +241,7 @@ static int mt76x2_set_antenna(struct ieee80211_hw *hw, u32 tx_ant,
 
        mutex_lock(&dev->mt76.mutex);
 
-       dev->chainmask = (tx_ant == 3) ? 0x202 : 0x101;
+       dev->mt76.chainmask = (tx_ant == 3) ? 0x202 : 0x101;
        dev->mt76.antenna_mask = tx_ant;
 
        mt76_set_stream_caps(&dev->mt76, true);
index a3669c00ddd5d82ecd6f59dacf75f12969cb5166..eff4833331834ef5d30b430bc0a1d612d0406567 100644 (file)
@@ -42,7 +42,7 @@ int mt76x2_mcu_set_channel(struct mt76x2_dev *dev, u8 channel, u8 bw,
                .idx = channel,
                .scan = scan,
                .bw = bw,
-               .chainmask = cpu_to_le16(dev->chainmask),
+               .chainmask = cpu_to_le16(dev->mt76.chainmask),
        };
 
        /* first set the channel without the extension channel info */
index 74fde9f107e1172c4538cc3a0e4f96d31e7f744c..5d2ebdf42c639c90a4e02580813bcc1a26e20976 100644 (file)
@@ -45,8 +45,6 @@ int mt76x2u_phy_set_channel(struct mt76x2_dev *dev,
                            struct cfg80211_chan_def *chandef);
 void mt76x2u_phy_calibrate(struct work_struct *work);
 void mt76x2u_phy_channel_calibrate(struct mt76x2_dev *dev);
-void mt76x2u_phy_set_txdac(struct mt76x2_dev *dev);
-void mt76x2u_phy_set_rxpath(struct mt76x2_dev *dev);
 
 void mt76x2u_mcu_complete_urb(struct urb *urb);
 int mt76x2u_mcu_set_dynamic_vga(struct mt76x2_dev *dev, u8 channel, bool ap,
index 788c36aa0f7db498eb01d445bc85c71ddf1670f9..5759a72d7ef6ce94f3d385fc3ee96d2a1420ea61 100644 (file)
@@ -18,6 +18,7 @@
 
 #include "mt76x2u.h"
 #include "mt76x02_util.h"
+#include "mt76x02_phy.h"
 #include "mt76x2_eeprom.h"
 
 static void mt76x2u_init_dma(struct mt76x2_dev *dev)
@@ -236,8 +237,8 @@ int mt76x2u_init_hardware(struct mt76x2_dev *dev)
        if (err < 0)
                return err;
 
-       mt76x2u_phy_set_rxpath(dev);
-       mt76x2u_phy_set_txdac(dev);
+       mt76x02_phy_set_rxpath(&dev->mt76);
+       mt76x02_phy_set_txdac(&dev->mt76);
 
        return mt76x2u_mac_stop(dev);
 }
index b3ec56d35e7f484a0b87fc4d72cfaf217821c2c2..06362d3487be16ffae80b39e83f5c7b89e3b1a98 100644 (file)
 #include "mt76x2u.h"
 #include "mt76x2_eeprom.h"
 
-void mt76x2u_phy_set_rxpath(struct mt76x2_dev *dev)
-{
-       u32 val;
-
-       val = mt76_rr(dev, MT_BBP(AGC, 0));
-       val &= ~BIT(4);
-
-       switch (dev->chainmask & 0xf) {
-       case 2:
-               val |= BIT(3);
-               break;
-       default:
-               val &= ~BIT(3);
-               break;
-       }
-       mt76_wr(dev, MT_BBP(AGC, 0), val);
-}
-
-void mt76x2u_phy_set_txdac(struct mt76x2_dev *dev)
-{
-       int txpath;
-
-       txpath = (dev->chainmask >> 8) & 0xf;
-       switch (txpath) {
-       case 2:
-               mt76_set(dev, MT_BBP(TXBE, 5), 0x3);
-               break;
-       default:
-               mt76_clear(dev, MT_BBP(TXBE, 5), 0x3);
-               break;
-       }
-}
-
 void mt76x2u_phy_channel_calibrate(struct mt76x2_dev *dev)
 {
        struct ieee80211_channel *chan = dev->mt76.chandef.chan;