diff options
author | Lorenzo Bianconi <lorenzo.bianconi@redhat.com> | 2018-02-24 18:54:14 +0300 |
---|---|---|
committer | Kalle Valo <kvalo@codeaurora.org> | 2018-03-13 19:32:01 +0300 |
commit | 5ebdc3e0692fdea0c61b41a4e05f3b6790b24e8e (patch) | |
tree | bcfa5d7cb291b5cb6a650afe1bb9530d99e0e21f /drivers/net/wireless/mediatek/mt76/mt76x2_phy.c | |
parent | 551e1ef4d29134ff1bb01869d522dbae0438032e (diff) | |
download | linux-5ebdc3e0692fdea0c61b41a4e05f3b6790b24e8e.tar.xz |
mt76x2: add mac80211 {set,get}_antenna callbacks
Add capability to select tx/rx antennas. Possible values are:
- 1: to use only the first antenna
- 2: to use only the second antenna
- 3: to use both of them
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Diffstat (limited to 'drivers/net/wireless/mediatek/mt76/mt76x2_phy.c')
-rw-r--r-- | drivers/net/wireless/mediatek/mt76/mt76x2_phy.c | 55 |
1 files changed, 39 insertions, 16 deletions
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2_phy.c b/drivers/net/wireless/mediatek/mt76/mt76x2_phy.c index 5b742749d5de..fcc37eb7ce0b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2_phy.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2_phy.c @@ -361,30 +361,53 @@ mt76x2_phy_set_band(struct mt76x2_dev *dev, int band, bool primary_upper) primary_upper); } -static void -mt76x2_set_rx_chains(struct mt76x2_dev *dev) +void mt76x2_phy_set_antenna(struct mt76x2_dev *dev) { u32 val; val = mt76_rr(dev, MT_BBP(AGC, 0)); - val &= ~(BIT(3) | BIT(4)); + val &= ~(BIT(4) | BIT(1)); + switch (dev->mt76.antenna_mask) { + case 1: + /* disable mac DAC control */ + mt76_clear(dev, MT_BBP(IBI, 9), BIT(11)); + mt76_clear(dev, MT_BBP(TXBE, 5), 3); + mt76_rmw_field(dev, MT_TX_PIN_CFG, MT_TX_PIN_CFG_TXANT, 0x3); + mt76_rmw_field(dev, MT_BBP(CORE, 32), GENMASK(21, 20), 2); + /* disable DAC 1 */ + mt76_rmw_field(dev, MT_BBP(CORE, 33), GENMASK(12, 9), 4); - if (dev->chainmask & BIT(1)) - val |= BIT(3); + val &= ~(BIT(3) | BIT(0)); + break; + case 2: + /* disable mac DAC control */ + mt76_clear(dev, MT_BBP(IBI, 9), BIT(11)); + mt76_rmw_field(dev, MT_BBP(TXBE, 5), 3, 1); + mt76_rmw_field(dev, MT_TX_PIN_CFG, MT_TX_PIN_CFG_TXANT, 0xc); + mt76_rmw_field(dev, MT_BBP(CORE, 32), GENMASK(21, 20), 1); + /* disable DAC 0 */ + mt76_rmw_field(dev, MT_BBP(CORE, 33), GENMASK(12, 9), 1); + + val &= ~BIT(3); + val |= BIT(0); + break; + case 3: + default: + /* enable mac DAC control */ + mt76_set(dev, MT_BBP(IBI, 9), BIT(11)); + mt76_set(dev, MT_BBP(TXBE, 5), 3); + mt76_rmw_field(dev, MT_TX_PIN_CFG, MT_TX_PIN_CFG_TXANT, 0xf); + mt76_clear(dev, MT_BBP(CORE, 32), GENMASK(21, 20)); + mt76_clear(dev, MT_BBP(CORE, 33), GENMASK(12, 9)); + val &= ~BIT(0); + val |= BIT(3); + break; + } mt76_wr(dev, MT_BBP(AGC, 0), val); } static void -mt76x2_set_tx_dac(struct mt76x2_dev *dev) -{ - if (dev->chainmask & BIT(1)) - mt76_set(dev, MT_BBP(TXBE, 5), 3); - else - mt76_clear(dev, MT_BBP(TXBE, 5), 3); -} - -static void mt76x2_get_agc_gain(struct mt76x2_dev *dev, u8 *dest) { dest[0] = mt76_get_field(dev, MT_BBP(AGC, 8), MT_BBP_AGC_GAIN); @@ -585,10 +608,8 @@ int mt76x2_phy_set_channel(struct mt76x2_dev *dev, mt76x2_configure_tx_delay(dev, band, bw); mt76x2_phy_set_txpower(dev); - mt76x2_set_rx_chains(dev); mt76x2_phy_set_band(dev, chan->band, ch_group_index & 1); mt76x2_phy_set_bw(dev, chandef->width, ch_group_index); - mt76x2_set_tx_dac(dev); mt76_rmw(dev, MT_EXT_CCA_CFG, (MT_EXT_CCA_CFG_CCA0 | @@ -604,6 +625,8 @@ int mt76x2_phy_set_channel(struct mt76x2_dev *dev, mt76x2_mcu_init_gain(dev, channel, dev->cal.rx.mcu_gain, true); + mt76x2_phy_set_antenna(dev); + /* Enable LDPC Rx */ if (mt76xx_rev(dev) >= MT76XX_REV_E3) mt76_set(dev, MT_BBP(RXO, 13), BIT(10)); |