aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless
diff options
context:
space:
mode:
authorLorenzo Bianconi <lorenzo.bianconi@redhat.com>2018-10-12 06:16:26 -0400
committerFelix Fietkau <nbd@nbd.name>2018-10-13 11:39:50 -0400
commite48797e9b6810383badfec429904a369c3e830da (patch)
tree9d594d6d96851cd93df6935a8b4c42d1550266da /drivers/net/wireless
parent9f884f0f9d000998a3e413232e9efcdbb5901139 (diff)
mt76: introduce mt76x02_init_agc_gain routine
Add mt76x02_init_agc_gain routine in mt76x02-lib moudule in order to be reused by mt76x0 for vga initalization Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76x02_phy.c12
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76x02_phy.h1
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76x2/pci_phy.c12
3 files changed, 14 insertions, 11 deletions
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_phy.c b/drivers/net/wireless/mediatek/mt76/mt76x02_phy.c
index 97310da37d77..0f1d7b5c9f68 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_phy.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_phy.c
@@ -244,3 +244,15 @@ bool mt76x02_phy_adjust_vga_gain(struct mt76x02_dev *dev)
244 return ret; 244 return ret;
245} 245}
246EXPORT_SYMBOL_GPL(mt76x02_phy_adjust_vga_gain); 246EXPORT_SYMBOL_GPL(mt76x02_phy_adjust_vga_gain);
247
248void mt76x02_init_agc_gain(struct mt76x02_dev *dev)
249{
250 dev->cal.agc_gain_init[0] = mt76_get_field(dev, MT_BBP(AGC, 8),
251 MT_BBP_AGC_GAIN);
252 dev->cal.agc_gain_init[1] = mt76_get_field(dev, MT_BBP(AGC, 9),
253 MT_BBP_AGC_GAIN);
254 memcpy(dev->cal.agc_gain_cur, dev->cal.agc_gain_init,
255 sizeof(dev->cal.agc_gain_cur));
256 dev->cal.low_gain = -1;
257}
258EXPORT_SYMBOL_GPL(mt76x02_init_agc_gain);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_phy.h b/drivers/net/wireless/mediatek/mt76/mt76x02_phy.h
index 8e3a0f93ca80..2b316cf7c70c 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_phy.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_phy.h
@@ -56,5 +56,6 @@ void mt76x02_phy_set_bw(struct mt76x02_dev *dev, int width, u8 ctrl);
56void mt76x02_phy_set_band(struct mt76x02_dev *dev, int band, 56void mt76x02_phy_set_band(struct mt76x02_dev *dev, int band,
57 bool primary_upper); 57 bool primary_upper);
58bool mt76x02_phy_adjust_vga_gain(struct mt76x02_dev *dev); 58bool mt76x02_phy_adjust_vga_gain(struct mt76x02_dev *dev);
59void mt76x02_init_agc_gain(struct mt76x02_dev *dev);
59 60
60#endif /* __MT76x02_PHY_H */ 61#endif /* __MT76x02_PHY_H */
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_phy.c b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_phy.c
index 818d2f3e8ac9..5bda44540225 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_phy.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_phy.c
@@ -125,13 +125,6 @@ void mt76x2_phy_set_antenna(struct mt76x02_dev *dev)
125} 125}
126 126
127static void 127static void
128mt76x2_get_agc_gain(struct mt76x02_dev *dev, u8 *dest)
129{
130 dest[0] = mt76_get_field(dev, MT_BBP(AGC, 8), MT_BBP_AGC_GAIN);
131 dest[1] = mt76_get_field(dev, MT_BBP(AGC, 9), MT_BBP_AGC_GAIN);
132}
133
134static void
135mt76x2_phy_set_gain_val(struct mt76x02_dev *dev) 128mt76x2_phy_set_gain_val(struct mt76x02_dev *dev)
136{ 129{
137 u32 val; 130 u32 val;
@@ -340,11 +333,8 @@ int mt76x2_phy_set_channel(struct mt76x02_dev *dev,
340 if (scan) 333 if (scan)
341 return 0; 334 return 0;
342 335
343 dev->cal.low_gain = -1;
344 mt76x2_phy_channel_calibrate(dev, true); 336 mt76x2_phy_channel_calibrate(dev, true);
345 mt76x2_get_agc_gain(dev, dev->cal.agc_gain_init); 337 mt76x02_init_agc_gain(dev);
346 memcpy(dev->cal.agc_gain_cur, dev->cal.agc_gain_init,
347 sizeof(dev->cal.agc_gain_cur));
348 338
349 /* init default values for temp compensation */ 339 /* init default values for temp compensation */
350 if (mt76x2_tssi_enabled(dev)) { 340 if (mt76x2_tssi_enabled(dev)) {