diff options
author | Lorenzo Bianconi <lorenzo.bianconi@redhat.com> | 2018-09-28 14:39:03 +0300 |
---|---|---|
committer | Felix Fietkau <nbd@nbd.name> | 2018-10-01 13:34:39 +0300 |
commit | 6034b2b07acc62603a0a97ec86f5b11202cdab3a (patch) | |
tree | 9dd6734ebe830203b66d25ab64636f29ead7ac1e /drivers/net/wireless/mediatek/mt76/mt76x02_phy.c | |
parent | 4468e92cf8d0a943878b0f47edfa8f5604ce2d2b (diff) | |
download | linux-6034b2b07acc62603a0a97ec86f5b11202cdab3a.tar.xz |
mt76: move set_{tx,rx}_path routines in mt76x02-lib module
Move mt76x02_phy_set_rxpath and mt76x02_phy_tx_dac routines in
mt76x02_phy.c since they are shared between mt76x2 and mt76x0 drivers.
Moreover move chainmask variable from mt76x2/mt76x0 to mt76_dev data
structure
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'drivers/net/wireless/mediatek/mt76/mt76x02_phy.c')
-rw-r--r-- | drivers/net/wireless/mediatek/mt76/mt76x02_phy.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_phy.c b/drivers/net/wireless/mediatek/mt76/mt76x02_phy.c index 969854b69981..e29914d78b72 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_phy.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_phy.c @@ -20,6 +20,44 @@ #include "mt76.h" #include "mt76x02_phy.h" +void mt76x02_phy_set_rxpath(struct mt76_dev *dev) +{ + u32 val; + + val = __mt76_rr(dev, MT_BBP(AGC, 0)); + val &= ~BIT(4); + + switch (dev->chainmask & 0xf) { + case 2: + val |= BIT(3); + break; + default: + val &= ~BIT(3); + break; + } + + __mt76_wr(dev, MT_BBP(AGC, 0), val); + mb(); + val = __mt76_rr(dev, MT_BBP(AGC, 0)); +} +EXPORT_SYMBOL_GPL(mt76x02_phy_set_rxpath); + +void mt76x02_phy_set_txdac(struct mt76_dev *dev) +{ + int txpath; + + txpath = (dev->chainmask >> 8) & 0xf; + switch (txpath) { + case 2: + __mt76_set(dev, MT_BBP(TXBE, 5), 0x3); + break; + default: + __mt76_clear(dev, MT_BBP(TXBE, 5), 0x3); + break; + } +} +EXPORT_SYMBOL_GPL(mt76x02_phy_set_txdac); + static u32 mt76x02_tx_power_mask(u8 v1, u8 v2, u8 v3, u8 v4) { |