Skip to content

Commit

Permalink
mt76: mt7915: add support to set tx frequency offset in testmode
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Shayne Chen authored and Felix Fietkau committed Dec 4, 2020
1 parent e0852d9 commit ed3c907
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/net/wireless/mediatek/mt76/mt7915/mcu.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ enum {

enum {
MCU_ATE_SET_TRX = 0x1,
MCU_ATE_SET_FREQ_OFFSET = 0xa,
};

struct mt7915_mcu_rxd {
Expand Down
20 changes: 20 additions & 0 deletions drivers/net/wireless/mediatek/mt76/mt7915/testmode.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@

enum {
TM_CHANGED_TXPOWER,
TM_CHANGED_FREQ_OFFSET,

/* must be last */
NUM_TM_CHANGED
};

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 {
Expand Down Expand Up @@ -82,6 +84,19 @@ mt7915_tm_set_tx_power(struct mt7915_phy *phy)
return ret;
}

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)
{
Expand Down Expand Up @@ -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);
}
Expand Down
6 changes: 6 additions & 0 deletions drivers/net/wireless/mediatek/mt76/mt7915/testmode.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,19 @@ struct mt7915_tm_trx {
u8 rsv;
};

struct mt7915_tm_freq_offset {
u8 band;
__le32 freq_offset;
};

struct mt7915_tm_cmd {
u8 testmode_en;
u8 param_idx;
u8 _rsv[2];
union {
__le32 data;
struct mt7915_tm_trx trx;
struct mt7915_tm_freq_offset freq;
u8 test[72];
} param;
} __packed;
Expand Down

0 comments on commit ed3c907

Please sign in to comment.