]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
mt76x2: move mt76x2_phy_tssi_compensate in mt76x2-common module
authorLorenzo Bianconi <lorenzo.bianconi@redhat.com>
Sun, 9 Sep 2018 21:58:05 +0000 (23:58 +0200)
committerFelix Fietkau <nbd@nbd.name>
Wed, 19 Sep 2018 10:31:42 +0000 (12:31 +0200)
Move mt76x2_phy_tssi_compensate routine in mt76x2-common module
since it is shared between mt76x2 and mt76x2u drivers

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt76x2.h
drivers/net/wireless/mediatek/mt76/mt76x2_phy.c
drivers/net/wireless/mediatek/mt76/mt76x2_phy_common.c
drivers/net/wireless/mediatek/mt76/mt76x2u_phy.c

index 3150e43a3e31d5e1a4e13eef2324b3719718e0e2..784962913d9a3c5f6b1332991f4de1adacf29e1d 100644 (file)
@@ -237,6 +237,7 @@ int mt76x2_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
                   u16 queue, const struct ieee80211_tx_queue_params *params);
 void mt76x2_txq_init(struct mt76x2_dev *dev, struct ieee80211_txq *txq);
 
+void mt76x2_phy_tssi_compensate(struct mt76x2_dev *dev, bool wait);
 void mt76x2_phy_set_txpower_regs(struct mt76x2_dev *dev,
                                 enum nl80211_band band);
 void mt76x2_configure_tx_delay(struct mt76x2_dev *dev,
index f3a4484a3efea5ea0cc10fbbff1c8ad26bf45592..920bb7c89af94acf9617b354f704bf650df5e123 100644 (file)
@@ -403,47 +403,6 @@ int mt76x2_phy_set_channel(struct mt76x2_dev *dev,
        return 0;
 }
 
-static void
-mt76x2_phy_tssi_compensate(struct mt76x2_dev *dev)
-{
-       struct ieee80211_channel *chan = dev->mt76.chandef.chan;
-       struct mt76x2_tx_power_info txp;
-       struct mt76x2_tssi_comp t = {};
-
-       if (!dev->cal.tssi_cal_done)
-               return;
-
-       if (!dev->cal.tssi_comp_pending) {
-               /* TSSI trigger */
-               t.cal_mode = BIT(0);
-               mt76x2_mcu_tssi_comp(dev, &t);
-               dev->cal.tssi_comp_pending = true;
-       } else {
-               if (mt76_rr(dev, MT_BBP(CORE, 34)) & BIT(4))
-                       return;
-
-               dev->cal.tssi_comp_pending = false;
-               mt76x2_get_power_info(dev, &txp, chan);
-
-               if (mt76x2_ext_pa_enabled(dev, chan->band))
-                       t.pa_mode = 1;
-
-               t.cal_mode = BIT(1);
-               t.slope0 = txp.chain[0].tssi_slope;
-               t.offset0 = txp.chain[0].tssi_offset;
-               t.slope1 = txp.chain[1].tssi_slope;
-               t.offset1 = txp.chain[1].tssi_offset;
-               mt76x2_mcu_tssi_comp(dev, &t);
-
-               if (t.pa_mode || dev->cal.dpd_cal_done)
-                       return;
-
-               usleep_range(10000, 20000);
-               mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_DPD, chan->hw_value, true);
-               dev->cal.dpd_cal_done = true;
-       }
-}
-
 static void
 mt76x2_phy_temp_compensate(struct mt76x2_dev *dev)
 {
@@ -478,7 +437,7 @@ void mt76x2_phy_calibrate(struct work_struct *work)
 
        dev = container_of(work, struct mt76x2_dev, cal_work.work);
        mt76x2_phy_channel_calibrate(dev, false);
-       mt76x2_phy_tssi_compensate(dev);
+       mt76x2_phy_tssi_compensate(dev, true);
        mt76x2_phy_temp_compensate(dev);
        mt76x2_phy_update_channel_gain(dev);
        ieee80211_queue_delayed_work(mt76_hw(dev), &dev->cal_work,
index c38855342731aa661215510a35b1e1801cb582f2..3b704a70fad1b5b784e29333729793a4d1555cb7 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "mt76x2.h"
 #include "mt76x2_eeprom.h"
+#include "mt76x2_mcu.h"
 
 static void
 mt76x2_adjust_high_lna_gain(struct mt76x2_dev *dev, int reg, s8 offset)
@@ -347,3 +348,45 @@ int mt76x2_phy_get_min_avg_rssi(struct mt76x2_dev *dev)
        return min_rssi;
 }
 EXPORT_SYMBOL_GPL(mt76x2_phy_get_min_avg_rssi);
+
+void mt76x2_phy_tssi_compensate(struct mt76x2_dev *dev, bool wait)
+{
+       struct ieee80211_channel *chan = dev->mt76.chandef.chan;
+       struct mt76x2_tx_power_info txp;
+       struct mt76x2_tssi_comp t = {};
+
+       if (!dev->cal.tssi_cal_done)
+               return;
+
+       if (!dev->cal.tssi_comp_pending) {
+               /* TSSI trigger */
+               t.cal_mode = BIT(0);
+               mt76x2_mcu_tssi_comp(dev, &t);
+               dev->cal.tssi_comp_pending = true;
+       } else {
+               if (mt76_rr(dev, MT_BBP(CORE, 34)) & BIT(4))
+                       return;
+
+               dev->cal.tssi_comp_pending = false;
+               mt76x2_get_power_info(dev, &txp, chan);
+
+               if (mt76x2_ext_pa_enabled(dev, chan->band))
+                       t.pa_mode = 1;
+
+               t.cal_mode = BIT(1);
+               t.slope0 = txp.chain[0].tssi_slope;
+               t.offset0 = txp.chain[0].tssi_offset;
+               t.slope1 = txp.chain[1].tssi_slope;
+               t.offset1 = txp.chain[1].tssi_offset;
+               mt76x2_mcu_tssi_comp(dev, &t);
+
+               if (t.pa_mode || dev->cal.dpd_cal_done)
+                       return;
+
+               usleep_range(10000, 20000);
+               mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_DPD,
+                                     chan->hw_value, wait);
+               dev->cal.dpd_cal_done = true;
+       }
+}
+EXPORT_SYMBOL_GPL(mt76x2_phy_tssi_compensate);
index c18e75478a6a7499b329ae4b1fb48ddfb3c1095d..97f40fef5559d2b97d717c6091b9cc095f864f15 100644 (file)
@@ -71,48 +71,6 @@ void mt76x2u_phy_channel_calibrate(struct mt76x2_dev *dev)
        mt76x2u_mac_resume(dev);
 }
 
-static void
-mt76x2u_phy_tssi_compensate(struct mt76x2_dev *dev)
-{
-       struct ieee80211_channel *chan = dev->mt76.chandef.chan;
-       struct mt76x2_tx_power_info txp;
-       struct mt76x2_tssi_comp t = {};
-
-       if (!dev->cal.tssi_cal_done)
-               return;
-
-       if (!dev->cal.tssi_comp_pending) {
-               /* TSSI trigger */
-               t.cal_mode = BIT(0);
-               mt76x2_mcu_tssi_comp(dev, &t);
-               dev->cal.tssi_comp_pending = true;
-       } else {
-               if (mt76_rr(dev, MT_BBP(CORE, 34)) & BIT(4))
-                       return;
-
-               dev->cal.tssi_comp_pending = false;
-               mt76x2_get_power_info(dev, &txp, chan);
-
-               if (mt76x2_ext_pa_enabled(dev, chan->band))
-                       t.pa_mode = 1;
-
-               t.cal_mode = BIT(1);
-               t.slope0 = txp.chain[0].tssi_slope;
-               t.offset0 = txp.chain[0].tssi_offset;
-               t.slope1 = txp.chain[1].tssi_slope;
-               t.offset1 = txp.chain[1].tssi_offset;
-               mt76x2_mcu_tssi_comp(dev, &t);
-
-               if (t.pa_mode || dev->cal.dpd_cal_done)
-                       return;
-
-               usleep_range(10000, 20000);
-               mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_DPD,
-                                     chan->hw_value, false);
-               dev->cal.dpd_cal_done = true;
-       }
-}
-
 static void
 mt76x2u_phy_update_channel_gain(struct mt76x2_dev *dev)
 {
@@ -156,7 +114,7 @@ void mt76x2u_phy_calibrate(struct work_struct *work)
        struct mt76x2_dev *dev;
 
        dev = container_of(work, struct mt76x2_dev, cal_work.work);
-       mt76x2u_phy_tssi_compensate(dev);
+       mt76x2_phy_tssi_compensate(dev, false);
        mt76x2u_phy_update_channel_gain(dev);
 
        ieee80211_queue_delayed_work(mt76_hw(dev), &dev->cal_work,