Commit 8cff1237 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

mt76x2: use common helpers for mcu_alloc_msg()/mcu_send_msg()

Use mcu common helpers instead of mt76x2 specific routines for
mcu_alloc_msg()/mcu_send_msg(). This is a preliminary patch to
unify mt76e and mt76u mcu code
Signed-off-by: default avatarLorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 0ed821bb
...@@ -255,8 +255,8 @@ mt76x2_mcu_function_select(struct mt76x2_dev *dev, enum mcu_function func, ...@@ -255,8 +255,8 @@ mt76x2_mcu_function_select(struct mt76x2_dev *dev, enum mcu_function func,
.value = cpu_to_le32(val), .value = cpu_to_le32(val),
}; };
skb = mt76x2_mcu_msg_alloc(&msg, sizeof(msg)); skb = mt76_mcu_msg_alloc(dev, &msg, sizeof(msg));
return mt76x2_mcu_msg_send(&dev->mt76, skb, CMD_FUN_SET_OP, true); return mt76_mcu_send_msg(dev, skb, CMD_FUN_SET_OP, true);
} }
int mt76x2_mcu_load_cr(struct mt76x2_dev *dev, u8 type, u8 temp_level, int mt76x2_mcu_load_cr(struct mt76x2_dev *dev, u8 type, u8 temp_level,
...@@ -283,8 +283,8 @@ int mt76x2_mcu_load_cr(struct mt76x2_dev *dev, u8 type, u8 temp_level, ...@@ -283,8 +283,8 @@ int mt76x2_mcu_load_cr(struct mt76x2_dev *dev, u8 type, u8 temp_level,
msg.cfg = cpu_to_le32(val); msg.cfg = cpu_to_le32(val);
/* first set the channel without the extension channel info */ /* first set the channel without the extension channel info */
skb = mt76x2_mcu_msg_alloc(&msg, sizeof(msg)); skb = mt76_mcu_msg_alloc(dev, &msg, sizeof(msg));
return mt76x2_mcu_msg_send(&dev->mt76, skb, CMD_LOAD_CR, true); return mt76_mcu_send_msg(dev, skb, CMD_LOAD_CR, true);
} }
int mt76x2_mcu_set_channel(struct mt76x2_dev *dev, u8 channel, u8 bw, int mt76x2_mcu_set_channel(struct mt76x2_dev *dev, u8 channel, u8 bw,
...@@ -309,15 +309,14 @@ int mt76x2_mcu_set_channel(struct mt76x2_dev *dev, u8 channel, u8 bw, ...@@ -309,15 +309,14 @@ int mt76x2_mcu_set_channel(struct mt76x2_dev *dev, u8 channel, u8 bw,
}; };
/* first set the channel without the extension channel info */ /* first set the channel without the extension channel info */
skb = mt76x2_mcu_msg_alloc(&msg, sizeof(msg)); skb = mt76_mcu_msg_alloc(dev, &msg, sizeof(msg));
mt76x2_mcu_msg_send(&dev->mt76, skb, CMD_SWITCH_CHANNEL_OP, true); mt76_mcu_send_msg(dev, skb, CMD_SWITCH_CHANNEL_OP, true);
usleep_range(5000, 10000); usleep_range(5000, 10000);
msg.ext_chan = 0xe0 + bw_index; msg.ext_chan = 0xe0 + bw_index;
skb = mt76x2_mcu_msg_alloc(&msg, sizeof(msg)); skb = mt76_mcu_msg_alloc(dev, &msg, sizeof(msg));
return mt76x2_mcu_msg_send(&dev->mt76, skb, CMD_SWITCH_CHANNEL_OP, return mt76_mcu_send_msg(dev, skb, CMD_SWITCH_CHANNEL_OP, true);
true);
} }
int mt76x2_mcu_set_radio_state(struct mt76x2_dev *dev, bool on) int mt76x2_mcu_set_radio_state(struct mt76x2_dev *dev, bool on)
...@@ -331,9 +330,8 @@ int mt76x2_mcu_set_radio_state(struct mt76x2_dev *dev, bool on) ...@@ -331,9 +330,8 @@ int mt76x2_mcu_set_radio_state(struct mt76x2_dev *dev, bool on)
.level = cpu_to_le32(0), .level = cpu_to_le32(0),
}; };
skb = mt76x2_mcu_msg_alloc(&msg, sizeof(msg)); skb = mt76_mcu_msg_alloc(dev, &msg, sizeof(msg));
return mt76x2_mcu_msg_send(&dev->mt76, skb, CMD_POWER_SAVING_OP, return mt76_mcu_send_msg(dev, skb, CMD_POWER_SAVING_OP, true);
true);
} }
int mt76x2_mcu_calibrate(struct mt76x2_dev *dev, enum mcu_calibration type, int mt76x2_mcu_calibrate(struct mt76x2_dev *dev, enum mcu_calibration type,
...@@ -351,9 +349,8 @@ int mt76x2_mcu_calibrate(struct mt76x2_dev *dev, enum mcu_calibration type, ...@@ -351,9 +349,8 @@ int mt76x2_mcu_calibrate(struct mt76x2_dev *dev, enum mcu_calibration type,
mt76_clear(dev, MT_MCU_COM_REG0, BIT(31)); mt76_clear(dev, MT_MCU_COM_REG0, BIT(31));
skb = mt76x2_mcu_msg_alloc(&msg, sizeof(msg)); skb = mt76_mcu_msg_alloc(dev, &msg, sizeof(msg));
ret = mt76x2_mcu_msg_send(&dev->mt76, skb, CMD_CALIBRATION_OP, ret = mt76_mcu_send_msg(dev, skb, CMD_CALIBRATION_OP, true);
true);
if (ret) if (ret)
return ret; return ret;
...@@ -376,9 +373,8 @@ int mt76x2_mcu_tssi_comp(struct mt76x2_dev *dev, ...@@ -376,9 +373,8 @@ int mt76x2_mcu_tssi_comp(struct mt76x2_dev *dev,
.data = *tssi_data, .data = *tssi_data,
}; };
skb = mt76x2_mcu_msg_alloc(&msg, sizeof(msg)); skb = mt76_mcu_msg_alloc(dev, &msg, sizeof(msg));
return mt76x2_mcu_msg_send(&dev->mt76, skb, CMD_CALIBRATION_OP, return mt76_mcu_send_msg(dev, skb, CMD_CALIBRATION_OP, true);
true);
} }
int mt76x2_mcu_init_gain(struct mt76x2_dev *dev, u8 channel, u32 gain, int mt76x2_mcu_init_gain(struct mt76x2_dev *dev, u8 channel, u32 gain,
...@@ -396,15 +392,20 @@ int mt76x2_mcu_init_gain(struct mt76x2_dev *dev, u8 channel, u32 gain, ...@@ -396,15 +392,20 @@ int mt76x2_mcu_init_gain(struct mt76x2_dev *dev, u8 channel, u32 gain,
if (force) if (force)
msg.channel |= cpu_to_le32(BIT(31)); msg.channel |= cpu_to_le32(BIT(31));
skb = mt76x2_mcu_msg_alloc(&msg, sizeof(msg)); skb = mt76_mcu_msg_alloc(dev, &msg, sizeof(msg));
return mt76x2_mcu_msg_send(&dev->mt76, skb, CMD_INIT_GAIN_OP, return mt76_mcu_send_msg(dev, skb, CMD_INIT_GAIN_OP, true);
true);
} }
int mt76x2_mcu_init(struct mt76x2_dev *dev) int mt76x2_mcu_init(struct mt76x2_dev *dev)
{ {
static const struct mt76_mcu_ops mt76x2_mcu_ops = {
.mcu_msg_alloc = mt76x2_mcu_msg_alloc,
.mcu_send_msg = mt76x2_mcu_msg_send,
};
int ret; int ret;
dev->mt76.mcu_ops = &mt76x2_mcu_ops;
ret = mt76pci_load_rom_patch(dev); ret = mt76pci_load_rom_patch(dev);
if (ret) if (ret)
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment