OSDN Git Service

mt76: move mt76x02_phy_set_bw in mt76x02-lib module
authorLorenzo Bianconi <lorenzo.bianconi@redhat.com>
Fri, 12 Oct 2018 10:16:17 +0000 (12:16 +0200)
committerFelix Fietkau <nbd@nbd.name>
Sat, 13 Oct 2018 15:39:40 +0000 (17:39 +0200)
Move mt76x02_phy_set_bw routine in mt76x02_phy.c since
it is shared between mt76x0 and mt76x2 drivers and remove
duplicated code

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
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/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 7c30ba4..3bc6d7b 100644 (file)
@@ -214,33 +214,6 @@ int mt76x0_wait_bbp_ready(struct mt76x02_dev *dev)
        return 0;
 }
 
-static void
-mt76x0_bbp_set_ctrlch(struct mt76x02_dev *dev, enum nl80211_chan_width width,
-                     u8 ctrl)
-{
-       int core_val, agc_val;
-
-       switch (width) {
-       case NL80211_CHAN_WIDTH_80:
-               core_val = 3;
-               agc_val = 7;
-               break;
-       case NL80211_CHAN_WIDTH_40:
-               core_val = 2;
-               agc_val = 3;
-               break;
-       default:
-               core_val = 0;
-               agc_val = 1;
-               break;
-       }
-
-       mt76_rmw_field(dev, MT_BBP(CORE, 1), MT_BBP_CORE_R1_BW, core_val);
-       mt76_rmw_field(dev, MT_BBP(AGC, 0), MT_BBP_AGC_R0_BW, agc_val);
-       mt76_rmw_field(dev, MT_BBP(AGC, 0), MT_BBP_AGC_R0_CTRL_CHAN, ctrl);
-       mt76_rmw_field(dev, MT_BBP(TXBE, 0), MT_BBP_TXBE_R0_CTRL_CHAN, ctrl);
-}
-
 static void mt76x0_vco_cal(struct mt76x02_dev *dev, u8 channel)
 {
        u8 val;
@@ -681,7 +654,7 @@ int mt76x0_phy_set_channel(struct mt76x02_dev *dev,
        }
 
        mt76x0_bbp_set_bw(dev, chandef->width);
-       mt76x0_bbp_set_ctrlch(dev, chandef->width, ch_group_index);
+       mt76x02_phy_set_bw(dev, chandef->width, ch_group_index);
        mt76x0_mac_set_ctrlch(dev, ch_group_index & 1);
        mt76x0_ant_select(dev);
 
index c398471..3de7170 100644 (file)
@@ -178,3 +178,29 @@ int mt76x02_phy_get_min_avg_rssi(struct mt76x02_dev *dev)
        return min_rssi;
 }
 EXPORT_SYMBOL_GPL(mt76x02_phy_get_min_avg_rssi);
+
+void mt76x02_phy_set_bw(struct mt76x02_dev *dev, int width, u8 ctrl)
+{
+       int core_val, agc_val;
+
+       switch (width) {
+       case NL80211_CHAN_WIDTH_80:
+               core_val = 3;
+               agc_val = 7;
+               break;
+       case NL80211_CHAN_WIDTH_40:
+               core_val = 2;
+               agc_val = 3;
+               break;
+       default:
+               core_val = 0;
+               agc_val = 1;
+               break;
+       }
+
+       mt76_rmw_field(dev, MT_BBP(CORE, 1), MT_BBP_CORE_R1_BW, core_val);
+       mt76_rmw_field(dev, MT_BBP(AGC, 0), MT_BBP_AGC_R0_BW, agc_val);
+       mt76_rmw_field(dev, MT_BBP(AGC, 0), MT_BBP_AGC_R0_CTRL_CHAN, ctrl);
+       mt76_rmw_field(dev, MT_BBP(TXBE, 0), MT_BBP_TXBE_R0_CTRL_CHAN, ctrl);
+}
+EXPORT_SYMBOL_GPL(mt76x02_phy_set_bw);
index c370b4c..e0ca44e 100644 (file)
@@ -26,5 +26,6 @@ int mt76x02_get_max_rate_power(struct mt76_rate_power *r);
 void mt76x02_phy_set_rxpath(struct mt76x02_dev *dev);
 void mt76x02_phy_set_txdac(struct mt76x02_dev *dev);
 int mt76x02_phy_get_min_avg_rssi(struct mt76x02_dev *dev);
+void mt76x02_phy_set_bw(struct mt76x02_dev *dev, int width, u8 ctrl);
 
 #endif /* __MT76x02_PHY_H */
index cbec8c6..8b18aca 100644 (file)
@@ -100,7 +100,6 @@ void mt76x2_phy_set_txpower_regs(struct mt76x02_dev *dev,
                                 enum nl80211_band band);
 void mt76x2_configure_tx_delay(struct mt76x02_dev *dev,
                               enum nl80211_band band, u8 bw);
-void mt76x2_phy_set_bw(struct mt76x02_dev *dev, int width, u8 ctrl);
 void mt76x2_phy_set_band(struct mt76x02_dev *dev, int band, bool primary_upper);
 void mt76x2_apply_gain_adj(struct mt76x02_dev *dev);
 
index dbb63d4..991db4f 100644 (file)
@@ -338,7 +338,7 @@ int mt76x2_phy_set_channel(struct mt76x02_dev *dev,
        mt76x2_phy_set_txpower(dev);
 
        mt76x2_phy_set_band(dev, chan->band, ch_group_index & 1);
-       mt76x2_phy_set_bw(dev, chandef->width, ch_group_index);
+       mt76x02_phy_set_bw(dev, chandef->width, ch_group_index);
 
        mt76_rmw(dev, MT_EXT_CCA_CFG,
                 (MT_EXT_CCA_CFG_CCA0 |
index fd077e8..dcb3381 100644 (file)
@@ -210,32 +210,6 @@ void mt76x2_configure_tx_delay(struct mt76x02_dev *dev,
 }
 EXPORT_SYMBOL_GPL(mt76x2_configure_tx_delay);
 
-void mt76x2_phy_set_bw(struct mt76x02_dev *dev, int width, u8 ctrl)
-{
-       int core_val, agc_val;
-
-       switch (width) {
-       case NL80211_CHAN_WIDTH_80:
-               core_val = 3;
-               agc_val = 7;
-               break;
-       case NL80211_CHAN_WIDTH_40:
-               core_val = 2;
-               agc_val = 3;
-               break;
-       default:
-               core_val = 0;
-               agc_val = 1;
-               break;
-       }
-
-       mt76_rmw_field(dev, MT_BBP(CORE, 1), MT_BBP_CORE_R1_BW, core_val);
-       mt76_rmw_field(dev, MT_BBP(AGC, 0), MT_BBP_AGC_R0_BW, agc_val);
-       mt76_rmw_field(dev, MT_BBP(AGC, 0), MT_BBP_AGC_R0_CTRL_CHAN, ctrl);
-       mt76_rmw_field(dev, MT_BBP(TXBE, 0), MT_BBP_TXBE_R0_CTRL_CHAN, ctrl);
-}
-EXPORT_SYMBOL_GPL(mt76x2_phy_set_bw);
-
 void mt76x2_phy_set_band(struct mt76x02_dev *dev, int band, bool primary_upper)
 {
        switch (band) {
index 422114d..ff2fd71 100644 (file)
@@ -156,7 +156,7 @@ int mt76x2u_phy_set_channel(struct mt76x02_dev *dev,
        mt76x2_phy_set_txpower(dev);
 
        mt76x2_phy_set_band(dev, chan->band, ch_group_index & 1);
-       mt76x2_phy_set_bw(dev, chandef->width, ch_group_index);
+       mt76x02_phy_set_bw(dev, chandef->width, ch_group_index);
 
        mt76_rmw(dev, MT_EXT_CCA_CFG,
                 (MT_EXT_CCA_CFG_CCA0 |