Skip to content

Commit

Permalink
mt76: introduce mt76x02_init_agc_gain routine
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Lorenzo Bianconi authored and Felix Fietkau committed Oct 13, 2018
1 parent 9f884f0 commit e48797e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
12 changes: 12 additions & 0 deletions drivers/net/wireless/mediatek/mt76/mt76x02_phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,15 @@ bool mt76x02_phy_adjust_vga_gain(struct mt76x02_dev *dev)
return ret;
}
EXPORT_SYMBOL_GPL(mt76x02_phy_adjust_vga_gain);

void mt76x02_init_agc_gain(struct mt76x02_dev *dev)
{
dev->cal.agc_gain_init[0] = mt76_get_field(dev, MT_BBP(AGC, 8),
MT_BBP_AGC_GAIN);
dev->cal.agc_gain_init[1] = mt76_get_field(dev, MT_BBP(AGC, 9),
MT_BBP_AGC_GAIN);
memcpy(dev->cal.agc_gain_cur, dev->cal.agc_gain_init,
sizeof(dev->cal.agc_gain_cur));
dev->cal.low_gain = -1;
}
EXPORT_SYMBOL_GPL(mt76x02_init_agc_gain);
1 change: 1 addition & 0 deletions drivers/net/wireless/mediatek/mt76/mt76x02_phy.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@ void mt76x02_phy_set_bw(struct mt76x02_dev *dev, int width, u8 ctrl);
void mt76x02_phy_set_band(struct mt76x02_dev *dev, int band,
bool primary_upper);
bool mt76x02_phy_adjust_vga_gain(struct mt76x02_dev *dev);
void mt76x02_init_agc_gain(struct mt76x02_dev *dev);

#endif /* __MT76x02_PHY_H */
12 changes: 1 addition & 11 deletions drivers/net/wireless/mediatek/mt76/mt76x2/pci_phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,6 @@ void mt76x2_phy_set_antenna(struct mt76x02_dev *dev)
mt76_wr(dev, MT_BBP(AGC, 0), val);
}

static void
mt76x2_get_agc_gain(struct mt76x02_dev *dev, u8 *dest)
{
dest[0] = mt76_get_field(dev, MT_BBP(AGC, 8), MT_BBP_AGC_GAIN);
dest[1] = mt76_get_field(dev, MT_BBP(AGC, 9), MT_BBP_AGC_GAIN);
}

static void
mt76x2_phy_set_gain_val(struct mt76x02_dev *dev)
{
Expand Down Expand Up @@ -340,11 +333,8 @@ int mt76x2_phy_set_channel(struct mt76x02_dev *dev,
if (scan)
return 0;

dev->cal.low_gain = -1;
mt76x2_phy_channel_calibrate(dev, true);
mt76x2_get_agc_gain(dev, dev->cal.agc_gain_init);
memcpy(dev->cal.agc_gain_cur, dev->cal.agc_gain_init,
sizeof(dev->cal.agc_gain_cur));
mt76x02_init_agc_gain(dev);

/* init default values for temp compensation */
if (mt76x2_tssi_enabled(dev)) {
Expand Down

0 comments on commit e48797e

Please sign in to comment.