Lines Matching +full:com +full:- +full:seq

1 // SPDX-License-Identifier: ISC
3 * Copyright (C) 2018 Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
23 struct mt76_usb *usb = &dev->usb; in mt76x02u_multiple_mcu_reads()
26 WARN_ON_ONCE(len / 8 != usb->mcu.rp_len); in mt76x02u_multiple_mcu_reads()
28 for (i = 0; i < usb->mcu.rp_len; i++) { in mt76x02u_multiple_mcu_reads()
29 u32 reg = get_unaligned_le32(data + 8 * i) - usb->mcu.base; in mt76x02u_multiple_mcu_reads()
32 WARN_ON_ONCE(usb->mcu.rp[i].reg != reg); in mt76x02u_multiple_mcu_reads()
33 usb->mcu.rp[i].value = val; in mt76x02u_multiple_mcu_reads()
37 static int mt76x02u_mcu_wait_resp(struct mt76_dev *dev, u8 seq) in mt76x02u_mcu_wait_resp() argument
39 struct mt76_usb *usb = &dev->usb; in mt76x02u_mcu_wait_resp()
40 u8 *data = usb->mcu.data; in mt76x02u_mcu_wait_resp()
47 if (ret == -ETIMEDOUT) in mt76x02u_mcu_wait_resp()
52 if (usb->mcu.rp) in mt76x02u_mcu_wait_resp()
53 mt76x02u_multiple_mcu_reads(dev, data + 4, len - 8); in mt76x02u_mcu_wait_resp()
56 if (seq == FIELD_GET(MT_RX_FCE_INFO_CMD_SEQ, rxfce) && in mt76x02u_mcu_wait_resp()
60 dev_err(dev->dev, "error: MCU resp evt:%lx seq:%hhx-%lx\n", in mt76x02u_mcu_wait_resp()
62 seq, FIELD_GET(MT_RX_FCE_INFO_CMD_SEQ, rxfce)); in mt76x02u_mcu_wait_resp()
65 dev_err(dev->dev, "error: %s failed with %d\n", __func__, ret); in mt76x02u_mcu_wait_resp()
73 u8 seq = 0; in __mt76x02u_mcu_send_msg() local
77 if (test_bit(MT76_REMOVED, &dev->phy.state)) { in __mt76x02u_mcu_send_msg()
83 seq = ++dev->mcu.msg_seq & 0xf; in __mt76x02u_mcu_send_msg()
84 if (!seq) in __mt76x02u_mcu_send_msg()
85 seq = ++dev->mcu.msg_seq & 0xf; in __mt76x02u_mcu_send_msg()
88 info = FIELD_PREP(MT_MCU_MSG_CMD_SEQ, seq) | in __mt76x02u_mcu_send_msg()
95 ret = mt76u_bulk_msg(dev, skb->data, skb->len, NULL, 500, in __mt76x02u_mcu_send_msg()
101 ret = mt76x02u_mcu_wait_resp(dev, seq); in __mt76x02u_mcu_send_msg()
118 return -ENOMEM; in mt76x02u_mcu_send_msg()
120 mutex_lock(&dev->mcu.mutex); in mt76x02u_mcu_send_msg()
122 mutex_unlock(&dev->mcu.mutex); in mt76x02u_mcu_send_msg()
148 return -ENOMEM; in mt76x02u_mcu_wr_rp()
156 mutex_lock(&dev->mcu.mutex); in mt76x02u_mcu_wr_rp()
158 mutex_unlock(&dev->mcu.mutex); in mt76x02u_mcu_wr_rp()
162 return mt76x02u_mcu_wr_rp(dev, base, data + cnt, n - cnt); in mt76x02u_mcu_wr_rp()
171 struct mt76_usb *usb = &dev->usb; in mt76x02u_mcu_rd_rp()
180 return -EINVAL; in mt76x02u_mcu_rd_rp()
184 return -ENOMEM; in mt76x02u_mcu_rd_rp()
192 mutex_lock(&dev->mcu.mutex); in mt76x02u_mcu_rd_rp()
194 usb->mcu.rp = data; in mt76x02u_mcu_rd_rp()
195 usb->mcu.rp_len = n; in mt76x02u_mcu_rd_rp()
196 usb->mcu.base = base; in mt76x02u_mcu_rd_rp()
200 usb->mcu.rp = NULL; in mt76x02u_mcu_rd_rp()
202 mutex_unlock(&dev->mcu.mutex); in mt76x02u_mcu_rd_rp()
209 mt76u_vendor_request(&dev->mt76, MT_VEND_DEV_MODE, in mt76x02u_mcu_fw_reset()
231 mt76u_single_wr(&dev->mt76, MT_VEND_WRITE_FCE, in __mt76x02u_mcu_fw_send_data()
234 mt76u_single_wr(&dev->mt76, MT_VEND_WRITE_FCE, in __mt76x02u_mcu_fw_send_data()
239 err = mt76u_bulk_msg(&dev->mt76, data, data_len, NULL, 1000, in __mt76x02u_mcu_fw_send_data()
242 dev_err(dev->mt76.dev, "firmware upload failed: %d\n", err); in __mt76x02u_mcu_fw_send_data()
256 int len, err = 0, pos = 0, max_len = max_payload - 8; in mt76x02u_mcu_fw_send_data()
261 return -ENOMEM; in mt76x02u_mcu_fw_send_data()
270 data_len -= len; in mt76x02u_mcu_fw_send_data()
291 dev->mcu_ops = &mt76x02u_mcu_ops; in mt76x02u_init_mcu()
295 MODULE_AUTHOR("Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>");