summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/mediatek/mt76/mt7915/testmode.c
diff options
context:
space:
mode:
authorShayne Chen <shayne.chen@mediatek.com>2020-10-22 05:28:20 +0300
committerFelix Fietkau <nbd@nbd.name>2020-12-04 16:31:13 +0300
commited3c9072fa4f8f23608e1705dd2bc704725da585 (patch)
tree95e7b61320e805939b76254a1e98031e6731db19 /drivers/net/wireless/mediatek/mt76/mt7915/testmode.c
parente0852d9083fa1a96aec2d3b7492f913c7371f75c (diff)
downloadlinux-ed3c9072fa4f8f23608e1705dd2bc704725da585.tar.xz
mt76: mt7915: add support to set tx frequency offset in testmode
Support to set tx frequency offset in testmode, which is usally used in the pre-calibration stage. Reviewed-by: Ryder Lee <ryder.lee@mediatek.com> Signed-off-by: Shayne Chen <shayne.chen@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'drivers/net/wireless/mediatek/mt76/mt7915/testmode.c')
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt7915/testmode.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/testmode.c b/drivers/net/wireless/mediatek/mt76/mt7915/testmode.c
index b3649bc23436..9ee82e2d262c 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/testmode.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/testmode.c
@@ -8,6 +8,7 @@
enum {
TM_CHANGED_TXPOWER,
+ TM_CHANGED_FREQ_OFFSET,
/* must be last */
NUM_TM_CHANGED
@@ -15,6 +16,7 @@ enum {
static const u8 tm_change_map[] = {
[TM_CHANGED_TXPOWER] = MT76_TM_ATTR_TX_POWER,
+ [TM_CHANGED_FREQ_OFFSET] = MT76_TM_ATTR_FREQ_OFFSET,
};
struct reg_band {
@@ -83,6 +85,19 @@ mt7915_tm_set_tx_power(struct mt7915_phy *phy)
}
static int
+mt7915_tm_set_freq_offset(struct mt7915_dev *dev, bool en, u32 val)
+{
+ struct mt7915_tm_cmd req = {
+ .testmode_en = en,
+ .param_idx = MCU_ATE_SET_FREQ_OFFSET,
+ .param.freq.freq_offset = cpu_to_le32(val),
+ };
+
+ return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_ATE_CTRL, &req,
+ sizeof(req), false);
+}
+
+static int
mt7915_tm_mode_ctrl(struct mt7915_dev *dev, bool enable)
{
struct {
@@ -226,6 +241,11 @@ mt7915_tm_set_rx_frames(struct mt7915_dev *dev, bool en)
static void
mt7915_tm_update_params(struct mt7915_dev *dev, u32 changed)
{
+ struct mt76_testmode_data *td = &dev->mt76.test;
+ bool en = dev->mt76.test.state != MT76_TM_STATE_OFF;
+
+ if (changed & BIT(TM_CHANGED_FREQ_OFFSET))
+ mt7915_tm_set_freq_offset(dev, en, en ? td->freq_offset : 0);
if (changed & BIT(TM_CHANGED_TXPOWER))
mt7915_tm_set_tx_power(&dev->phy);
}