]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
mt76: remove wait argument from mt76x02_mcu_calibrate
authorStanislaw Gruszka <sgruszka@redhat.com>
Fri, 9 Nov 2018 10:56:10 +0000 (11:56 +0100)
committerFelix Fietkau <nbd@nbd.name>
Fri, 30 Nov 2018 11:29:31 +0000 (12:29 +0100)
We always wait for CMD_CALIBRATION_OP mcu message, but wait argument is used
for do additional MT_MCU_COM_REG0 register operations, which are needed
for mt76x2e devices and we can use appropriate check instead of wait argument.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
drivers/net/wireless/mediatek/mt76/mt76x02_mcu.c
drivers/net/wireless/mediatek/mt76/mt76x02_mcu.h
drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2.h
drivers/net/wireless/mediatek/mt76/mt76x2/pci_phy.c
drivers/net/wireless/mediatek/mt76/mt76x2/phy.c
drivers/net/wireless/mediatek/mt76/mt76x2/usb_phy.c

index 275458891ce4ee60a87da6bdef775895b191fa1f..1eb1a802ed20d2a8744fa6496c4857c43a762046 100644 (file)
@@ -868,9 +868,8 @@ void mt76x0_phy_calibrate(struct mt76x02_dev *dev, bool power_on)
                return;
 
        if (power_on) {
-               mt76x02_mcu_calibrate(dev, MCU_CAL_R, 0, false);
-               mt76x02_mcu_calibrate(dev, MCU_CAL_VCO, chan->hw_value,
-                                     false);
+               mt76x02_mcu_calibrate(dev, MCU_CAL_R, 0);
+               mt76x02_mcu_calibrate(dev, MCU_CAL_VCO, chan->hw_value);
                usleep_range(10, 20);
 
                if (mt76x0_tssi_enabled(dev)) {
@@ -901,14 +900,14 @@ void mt76x0_phy_calibrate(struct mt76x02_dev *dev, bool power_on)
                val = 0x600;
        }
 
-       mt76x02_mcu_calibrate(dev, MCU_CAL_FULL, val, false);
+       mt76x02_mcu_calibrate(dev, MCU_CAL_FULL, val);
        msleep(350);
-       mt76x02_mcu_calibrate(dev, MCU_CAL_LC, is_5ghz, false);
+       mt76x02_mcu_calibrate(dev, MCU_CAL_LC, is_5ghz);
        usleep_range(15000, 20000);
 
        mt76_wr(dev, MT_BBP(IBI, 9), reg_val);
        mt76_wr(dev, MT_TX_ALC_CFG_0, tx_alc);
-       mt76x02_mcu_calibrate(dev, MCU_CAL_RXDCOC, 1, false);
+       mt76x02_mcu_calibrate(dev, MCU_CAL_RXDCOC, 1);
 }
 EXPORT_SYMBOL_GPL(mt76x0_phy_calibrate);
 
@@ -1044,8 +1043,7 @@ static void mt76x0_phy_temp_sensor(struct mt76x02_dev *dev)
 
        if (abs(val - dev->cal.temp_vco) > 20) {
                mt76x02_mcu_calibrate(dev, MCU_CAL_VCO,
-                                     dev->mt76.chandef.chan->hw_value,
-                                     false);
+                                     dev->mt76.chandef.chan->hw_value);
                dev->cal.temp_vco = val;
        }
        if (abs(val - dev->cal.temp) > 30) {
index 6015ba9ffdac47ccbaef3a5d786a8d84faa554ed..b7f4edb729e38842362f2b4dac4d70abae232eb2 100644 (file)
@@ -165,8 +165,7 @@ int mt76x02_mcu_set_radio_state(struct mt76x02_dev *dev, bool on)
 }
 EXPORT_SYMBOL_GPL(mt76x02_mcu_set_radio_state);
 
-int mt76x02_mcu_calibrate(struct mt76x02_dev *dev, int type,
-                         u32 param, bool wait)
+int mt76x02_mcu_calibrate(struct mt76x02_dev *dev, int type, u32 param)
 {
        struct {
                __le32 id;
@@ -175,9 +174,10 @@ int mt76x02_mcu_calibrate(struct mt76x02_dev *dev, int type,
                .id = cpu_to_le32(type),
                .value = cpu_to_le32(param),
        };
+       bool is_mt76x2e = mt76_is_mmio(dev) && is_mt76x2(dev);
        int ret;
 
-       if (wait)
+       if (is_mt76x2e)
                mt76_rmw(dev, MT_MCU_COM_REG0, BIT(31), 0);
 
        ret = mt76_mcu_send_msg(dev, CMD_CALIBRATION_OP, &msg, sizeof(msg),
@@ -185,7 +185,7 @@ int mt76x02_mcu_calibrate(struct mt76x02_dev *dev, int type,
        if (ret)
                return ret;
 
-       if (wait &&
+       if (is_mt76x2e &&
            WARN_ON(!mt76_poll_msec(dev, MT_MCU_COM_REG0,
                                    BIT(31), BIT(31), 100)))
                return -ETIMEDOUT;
index 97025c31a986bc84f20c2f71cc83b8b140a92863..7e4004120102724a53d39d42095fdecba970cbf0 100644 (file)
@@ -97,8 +97,7 @@ struct mt76x02_patch_header {
 };
 
 int mt76x02_mcu_cleanup(struct mt76x02_dev *dev);
-int mt76x02_mcu_calibrate(struct mt76x02_dev *dev, int type,
-                         u32 param, bool wait);
+int mt76x02_mcu_calibrate(struct mt76x02_dev *dev, int type, u32 param);
 int mt76x02_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data,
                         int len, bool wait_resp);
 int mt76x02_mcu_function_select(struct mt76x02_dev *dev, enum mcu_function func,
index e5846a85d6abc27b89ad6134c40ce7e8b0c19181..b259e4b50f1e09dfae1e657981a71aa5f555e81c 100644 (file)
@@ -78,7 +78,7 @@ void mt76x2_init_txpower(struct mt76x02_dev *dev,
                         struct ieee80211_supported_band *sband);
 void mt76_write_mac_initvals(struct mt76x02_dev *dev);
 
-void mt76x2_phy_tssi_compensate(struct mt76x02_dev *dev, bool wait);
+void mt76x2_phy_tssi_compensate(struct mt76x02_dev *dev);
 void mt76x2_phy_set_txpower_regs(struct mt76x02_dev *dev,
                                 enum nl80211_band band);
 void mt76x2_configure_tx_delay(struct mt76x02_dev *dev,
index 63866b2fec647c83ff6e30a8e31313dfc3e3b199..da7cd40f56ffb01ffe943dd2d8238f0e0915191d 100644 (file)
@@ -38,7 +38,7 @@ mt76x2_phy_tssi_init_cal(struct mt76x02_dev *dev)
        if (mt76x02_ext_pa_enabled(dev, chan->band))
                flag |= BIT(8);
 
-       mt76x02_mcu_calibrate(dev, MCU_CAL_TSSI, flag, true);
+       mt76x02_mcu_calibrate(dev, MCU_CAL_TSSI, flag);
        dev->cal.tssi_cal_done = true;
        return true;
 }
@@ -62,13 +62,13 @@ mt76x2_phy_channel_calibrate(struct mt76x02_dev *dev, bool mac_stopped)
                mt76x2_mac_stop(dev, false);
 
        if (is_5ghz)
-               mt76x02_mcu_calibrate(dev, MCU_CAL_LC, 0, true);
+               mt76x02_mcu_calibrate(dev, MCU_CAL_LC, 0);
 
-       mt76x02_mcu_calibrate(dev, MCU_CAL_TX_LOFT, is_5ghz, true);
-       mt76x02_mcu_calibrate(dev, MCU_CAL_TXIQ, is_5ghz, true);
-       mt76x02_mcu_calibrate(dev, MCU_CAL_RXIQC_FI, is_5ghz, true);
-       mt76x02_mcu_calibrate(dev, MCU_CAL_TEMP_SENSOR, 0, true);
-       mt76x02_mcu_calibrate(dev, MCU_CAL_TX_SHAPING, 0, true);
+       mt76x02_mcu_calibrate(dev, MCU_CAL_TX_LOFT, is_5ghz);
+       mt76x02_mcu_calibrate(dev, MCU_CAL_TXIQ, is_5ghz);
+       mt76x02_mcu_calibrate(dev, MCU_CAL_RXIQC_FI, is_5ghz);
+       mt76x02_mcu_calibrate(dev, MCU_CAL_TEMP_SENSOR, 0);
+       mt76x02_mcu_calibrate(dev, MCU_CAL_TX_SHAPING, 0);
 
        if (!mac_stopped)
                mt76x2_mac_resume(dev);
@@ -223,14 +223,14 @@ int mt76x2_phy_set_channel(struct mt76x02_dev *dev,
                u8 val = mt76x02_eeprom_get(dev, MT_EE_BT_RCAL_RESULT);
 
                if (val != 0xff)
-                       mt76x02_mcu_calibrate(dev, MCU_CAL_R, 0, true);
+                       mt76x02_mcu_calibrate(dev, MCU_CAL_R, 0);
        }
 
-       mt76x02_mcu_calibrate(dev, MCU_CAL_RXDCOC, channel, true);
+       mt76x02_mcu_calibrate(dev, MCU_CAL_RXDCOC, channel);
 
        /* Rx LPF calibration */
        if (!dev->cal.init_cal_done)
-               mt76x02_mcu_calibrate(dev, MCU_CAL_RC, 0, true);
+               mt76x02_mcu_calibrate(dev, MCU_CAL_RC, 0);
 
        dev->cal.init_cal_done = true;
 
@@ -294,7 +294,7 @@ void mt76x2_phy_calibrate(struct work_struct *work)
 
        dev = container_of(work, struct mt76x02_dev, cal_work.work);
        mt76x2_phy_channel_calibrate(dev, false);
-       mt76x2_phy_tssi_compensate(dev, true);
+       mt76x2_phy_tssi_compensate(dev);
        mt76x2_phy_temp_compensate(dev);
        mt76x2_phy_update_channel_gain(dev);
        ieee80211_queue_delayed_work(mt76_hw(dev), &dev->cal_work,
index 1b85fb4155485081be50f0f8d8ac2a9fa26e15e5..c9634a774705278dfa08e3e7b304b809ead2ec44 100644 (file)
@@ -210,7 +210,7 @@ void mt76x2_configure_tx_delay(struct mt76x02_dev *dev,
 }
 EXPORT_SYMBOL_GPL(mt76x2_configure_tx_delay);
 
-void mt76x2_phy_tssi_compensate(struct mt76x02_dev *dev, bool wait)
+void mt76x2_phy_tssi_compensate(struct mt76x02_dev *dev)
 {
        struct ieee80211_channel *chan = dev->mt76.chandef.chan;
        struct mt76x2_tx_power_info txp;
@@ -245,7 +245,7 @@ void mt76x2_phy_tssi_compensate(struct mt76x02_dev *dev, bool wait)
                        return;
 
                usleep_range(10000, 20000);
-               mt76x02_mcu_calibrate(dev, MCU_CAL_DPD, chan->hw_value, wait);
+               mt76x02_mcu_calibrate(dev, MCU_CAL_DPD, chan->hw_value);
                dev->cal.dpd_cal_done = true;
        }
 }
index a64268e8db42c64598205a729610ca76a69d2db2..11d414d86c68edf59fe4b919c770abd9c24f8bc9 100644 (file)
@@ -34,13 +34,13 @@ mt76x2u_phy_channel_calibrate(struct mt76x02_dev *dev, bool mac_stopped)
                mt76x2u_mac_stop(dev);
 
        if (is_5ghz)
-               mt76x02_mcu_calibrate(dev, MCU_CAL_LC, 0, false);
+               mt76x02_mcu_calibrate(dev, MCU_CAL_LC, 0);
 
-       mt76x02_mcu_calibrate(dev, MCU_CAL_TX_LOFT, is_5ghz, false);
-       mt76x02_mcu_calibrate(dev, MCU_CAL_TXIQ, is_5ghz, false);
-       mt76x02_mcu_calibrate(dev, MCU_CAL_RXIQC_FI, is_5ghz, false);
-       mt76x02_mcu_calibrate(dev, MCU_CAL_TEMP_SENSOR, 0, false);
-       mt76x02_mcu_calibrate(dev, MCU_CAL_TX_SHAPING, 0, false);
+       mt76x02_mcu_calibrate(dev, MCU_CAL_TX_LOFT, is_5ghz);
+       mt76x02_mcu_calibrate(dev, MCU_CAL_TXIQ, is_5ghz);
+       mt76x02_mcu_calibrate(dev, MCU_CAL_RXIQC_FI, is_5ghz);
+       mt76x02_mcu_calibrate(dev, MCU_CAL_TEMP_SENSOR, 0);
+       mt76x02_mcu_calibrate(dev, MCU_CAL_TX_SHAPING, 0);
 
        if (!mac_stopped)
                mt76x2u_mac_resume(dev);
@@ -55,7 +55,7 @@ void mt76x2u_phy_calibrate(struct work_struct *work)
 
        dev = container_of(work, struct mt76x02_dev, cal_work.work);
        mt76x2u_phy_channel_calibrate(dev, false);
-       mt76x2_phy_tssi_compensate(dev, false);
+       mt76x2_phy_tssi_compensate(dev);
        mt76x2_phy_update_channel_gain(dev);
 
        ieee80211_queue_delayed_work(mt76_hw(dev), &dev->cal_work,
@@ -153,14 +153,14 @@ int mt76x2u_phy_set_channel(struct mt76x02_dev *dev,
                u8 val = mt76x02_eeprom_get(dev, MT_EE_BT_RCAL_RESULT);
 
                if (val != 0xff)
-                       mt76x02_mcu_calibrate(dev, MCU_CAL_R, 0, false);
+                       mt76x02_mcu_calibrate(dev, MCU_CAL_R, 0);
        }
 
-       mt76x02_mcu_calibrate(dev, MCU_CAL_RXDCOC, channel, false);
+       mt76x02_mcu_calibrate(dev, MCU_CAL_RXDCOC, channel);
 
        /* Rx LPF calibration */
        if (!dev->cal.init_cal_done)
-               mt76x02_mcu_calibrate(dev, MCU_CAL_RC, 0, false);
+               mt76x02_mcu_calibrate(dev, MCU_CAL_RC, 0);
        dev->cal.init_cal_done = true;
 
        mt76_wr(dev, MT_BBP(AGC, 61), 0xff64a4e2);
@@ -195,7 +195,7 @@ int mt76x2u_phy_set_channel(struct mt76x02_dev *dev,
                                flag |= BIT(0);
                        if (mt76x02_ext_pa_enabled(dev, chan->band))
                                flag |= BIT(8);
-                       mt76x02_mcu_calibrate(dev, MCU_CAL_TSSI, flag, false);
+                       mt76x02_mcu_calibrate(dev, MCU_CAL_TSSI, flag);
                        dev->cal.tssi_cal_done = true;
                }
        }