Commit cc173875 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

mt76: mt7603: initialize mt76_mcu_ops data structure

Use __mt76_mcu_send_msg wrapper instead of mt7603_mcu_msg_send.
This is a preliminary patch for mt7615-mt7603 mcu code unification
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 11ca82d7
...@@ -543,6 +543,7 @@ struct mt76_rx_status { ...@@ -543,6 +543,7 @@ struct mt76_rx_status {
#define mt76_rd_rp(dev, ...) (dev)->mt76.bus->rd_rp(&((dev)->mt76), __VA_ARGS__) #define mt76_rd_rp(dev, ...) (dev)->mt76.bus->rd_rp(&((dev)->mt76), __VA_ARGS__)
#define mt76_mcu_send_msg(dev, ...) (dev)->mt76.mcu_ops->mcu_send_msg(&((dev)->mt76), __VA_ARGS__) #define mt76_mcu_send_msg(dev, ...) (dev)->mt76.mcu_ops->mcu_send_msg(&((dev)->mt76), __VA_ARGS__)
#define __mt76_mcu_send_msg(dev, ...) (dev)->mcu_ops->mcu_send_msg((dev), __VA_ARGS__)
#define mt76_set(dev, offset, val) mt76_rmw(dev, offset, 0, val) #define mt76_set(dev, offset, val) mt76_rmw(dev, offset, 0, val)
#define mt76_clear(dev, offset, val) mt76_rmw(dev, offset, val, 0) #define mt76_clear(dev, offset, val) mt76_rmw(dev, offset, val, 0)
......
...@@ -283,7 +283,7 @@ mt7603_init_hardware(struct mt7603_dev *dev) ...@@ -283,7 +283,7 @@ mt7603_init_hardware(struct mt7603_dev *dev)
mt76_poll(dev, MT_PSE_RTA, MT_PSE_RTA_BUSY, 0, 5000); mt76_poll(dev, MT_PSE_RTA, MT_PSE_RTA_BUSY, 0, 5000);
} }
ret = mt7603_load_firmware(dev); ret = mt7603_mcu_init(dev);
if (ret) if (ret)
return ret; return ret;
......
...@@ -54,10 +54,10 @@ __mt7603_mcu_msg_send(struct mt7603_dev *dev, struct sk_buff *skb, ...@@ -54,10 +54,10 @@ __mt7603_mcu_msg_send(struct mt7603_dev *dev, struct sk_buff *skb,
} }
static int static int
mt7603_mcu_msg_send(struct mt7603_dev *dev, int cmd, const void *data, mt7603_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data,
int len, bool wait_resp) int len, bool wait_resp)
{ {
struct mt76_dev *mdev = &dev->mt76; struct mt7603_dev *dev = container_of(mdev, struct mt7603_dev, mt76);
unsigned long expires = jiffies + 3 * HZ; unsigned long expires = jiffies + 3 * HZ;
struct mt7603_mcu_rxd *rxd; struct mt7603_mcu_rxd *rxd;
struct sk_buff *skb; struct sk_buff *skb;
...@@ -115,7 +115,7 @@ mt7603_mcu_init_download(struct mt7603_dev *dev, u32 addr, u32 len) ...@@ -115,7 +115,7 @@ mt7603_mcu_init_download(struct mt7603_dev *dev, u32 addr, u32 len)
.mode = cpu_to_le32(BIT(31)), .mode = cpu_to_le32(BIT(31)),
}; };
return mt7603_mcu_msg_send(dev, -MCU_CMD_TARGET_ADDRESS_LEN_REQ, return __mt76_mcu_send_msg(&dev->mt76, -MCU_CMD_TARGET_ADDRESS_LEN_REQ,
&req, sizeof(req), true); &req, sizeof(req), true);
} }
...@@ -156,18 +156,18 @@ mt7603_mcu_start_firmware(struct mt7603_dev *dev, u32 addr) ...@@ -156,18 +156,18 @@ mt7603_mcu_start_firmware(struct mt7603_dev *dev, u32 addr)
.addr = cpu_to_le32(addr), .addr = cpu_to_le32(addr),
}; };
return mt7603_mcu_msg_send(dev, -MCU_CMD_FW_START_REQ, return __mt76_mcu_send_msg(&dev->mt76, -MCU_CMD_FW_START_REQ,
&req, sizeof(req), true); &req, sizeof(req), true);
} }
static int static int
mt7603_mcu_restart(struct mt7603_dev *dev) mt7603_mcu_restart(struct mt7603_dev *dev)
{ {
return mt7603_mcu_msg_send(dev, -MCU_CMD_RESTART_DL_REQ, return __mt76_mcu_send_msg(&dev->mt76, -MCU_CMD_RESTART_DL_REQ,
NULL, 0, true); NULL, 0, true);
} }
int mt7603_load_firmware(struct mt7603_dev *dev) static int mt7603_load_firmware(struct mt7603_dev *dev)
{ {
const struct firmware *fw; const struct firmware *fw;
const struct mt7603_fw_trailer *hdr; const struct mt7603_fw_trailer *hdr;
...@@ -265,6 +265,16 @@ int mt7603_load_firmware(struct mt7603_dev *dev) ...@@ -265,6 +265,16 @@ int mt7603_load_firmware(struct mt7603_dev *dev)
return ret; return ret;
} }
int mt7603_mcu_init(struct mt7603_dev *dev)
{
static const struct mt76_mcu_ops mt7603_mcu_ops = {
.mcu_send_msg = mt7603_mcu_msg_send,
};
dev->mt76.mcu_ops = &mt7603_mcu_ops;
return mt7603_load_firmware(dev);
}
void mt7603_mcu_exit(struct mt7603_dev *dev) void mt7603_mcu_exit(struct mt7603_dev *dev)
{ {
mt7603_mcu_restart(dev); mt7603_mcu_restart(dev);
...@@ -361,7 +371,7 @@ int mt7603_mcu_set_eeprom(struct mt7603_dev *dev) ...@@ -361,7 +371,7 @@ int mt7603_mcu_set_eeprom(struct mt7603_dev *dev)
req.data[i].pad = 0; req.data[i].pad = 0;
} }
return mt7603_mcu_msg_send(dev, MCU_EXT_CMD_EFUSE_BUFFER_MODE, return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_EFUSE_BUFFER_MODE,
&req, sizeof(req), true); &req, sizeof(req), true);
} }
...@@ -405,7 +415,7 @@ static int mt7603_mcu_set_tx_power(struct mt7603_dev *dev) ...@@ -405,7 +415,7 @@ static int mt7603_mcu_set_tx_power(struct mt7603_dev *dev)
memcpy(req.temp_comp_power, eep + MT_EE_STEP_NUM_NEG_6_7, memcpy(req.temp_comp_power, eep + MT_EE_STEP_NUM_NEG_6_7,
sizeof(req.temp_comp_power)); sizeof(req.temp_comp_power));
return mt7603_mcu_msg_send(dev, MCU_EXT_CMD_SET_TX_POWER_CTRL, return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_SET_TX_POWER_CTRL,
&req, sizeof(req), true); &req, sizeof(req), true);
} }
...@@ -451,7 +461,7 @@ int mt7603_mcu_set_channel(struct mt7603_dev *dev) ...@@ -451,7 +461,7 @@ int mt7603_mcu_set_channel(struct mt7603_dev *dev)
for (i = 0; i < ARRAY_SIZE(req.txpower); i++) for (i = 0; i < ARRAY_SIZE(req.txpower); i++)
req.txpower[i] = tx_power; req.txpower[i] = tx_power;
ret = mt7603_mcu_msg_send(dev, MCU_EXT_CMD_CHANNEL_SWITCH, ret = __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_CHANNEL_SWITCH,
&req, sizeof(req), true); &req, sizeof(req), true);
if (ret) if (ret)
return ret; return ret;
......
...@@ -174,7 +174,7 @@ void mt7603_unregister_device(struct mt7603_dev *dev); ...@@ -174,7 +174,7 @@ void mt7603_unregister_device(struct mt7603_dev *dev);
int mt7603_eeprom_init(struct mt7603_dev *dev); int mt7603_eeprom_init(struct mt7603_dev *dev);
int mt7603_dma_init(struct mt7603_dev *dev); int mt7603_dma_init(struct mt7603_dev *dev);
void mt7603_dma_cleanup(struct mt7603_dev *dev); void mt7603_dma_cleanup(struct mt7603_dev *dev);
int mt7603_load_firmware(struct mt7603_dev *dev); int mt7603_mcu_init(struct mt7603_dev *dev);
void mt7603_init_debugfs(struct mt7603_dev *dev); void mt7603_init_debugfs(struct mt7603_dev *dev);
static inline void mt7603_irq_enable(struct mt7603_dev *dev, u32 mask) static inline void mt7603_irq_enable(struct mt7603_dev *dev, u32 mask)
......
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