From ff69c75ee5392320ab3a8dd01db46d3cd097eb46 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 31 Jul 2018 14:40:53 +0200 Subject: mt76x0: usb files Add usb files of mt76x0 driver. Signed-off-by: Stanislaw Gruszka Signed-off-by: Kalle Valo --- drivers/net/wireless/mediatek/mt76/mt76x0/usb.c | 377 ++++++++++++++++++++++++ 1 file changed, 377 insertions(+) create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x0/usb.c (limited to 'drivers/net/wireless/mediatek/mt76/mt76x0/usb.c') diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c new file mode 100644 index 000000000000..0871fdef59c3 --- /dev/null +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c @@ -0,0 +1,377 @@ +/* + * Copyright (C) 2015 Jakub Kicinski + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include + +#include "mt76x0.h" +#include "usb.h" +#include "trace.h" + +static struct usb_device_id mt76x0_device_table[] = { + { USB_DEVICE(0x148F, 0x7610) }, /* MT7610U */ + { USB_DEVICE(0x13B1, 0x003E) }, /* Linksys AE6000 */ + { USB_DEVICE(0x0E8D, 0x7610) }, /* Sabrent NTWLAC */ + { USB_DEVICE(0x7392, 0xa711) }, /* Edimax 7711mac */ + { USB_DEVICE(0x7392, 0xb711) }, /* Edimax / Elecom */ + { USB_DEVICE(0x148f, 0x761a) }, /* TP-Link TL-WDN5200 */ + { USB_DEVICE(0x148f, 0x760a) }, /* TP-Link unknown */ + { USB_DEVICE(0x0b05, 0x17d1) }, /* Asus USB-AC51 */ + { USB_DEVICE(0x0b05, 0x17db) }, /* Asus USB-AC50 */ + { USB_DEVICE(0x0df6, 0x0075) }, /* Sitecom WLA-3100 */ + { USB_DEVICE(0x2019, 0xab31) }, /* Planex GW-450D */ + { USB_DEVICE(0x2001, 0x3d02) }, /* D-LINK DWA-171 rev B1 */ + { USB_DEVICE(0x0586, 0x3425) }, /* Zyxel NWD6505 */ + { USB_DEVICE(0x07b8, 0x7610) }, /* AboCom AU7212 */ + { USB_DEVICE(0x04bb, 0x0951) }, /* I-O DATA WN-AC433UK */ + { USB_DEVICE(0x057c, 0x8502) }, /* AVM FRITZ!WLAN USB Stick AC 430 */ + { USB_DEVICE(0x293c, 0x5702) }, /* Comcast Xfinity KXW02AAA */ + { USB_DEVICE(0x20f4, 0x806b) }, /* TRENDnet TEW-806UBH */ + { USB_DEVICE(0x7392, 0xc711) }, /* Devolo Wifi ac Stick */ + { USB_DEVICE(0x0df6, 0x0079) }, /* Sitecom Europe B.V. ac Stick */ + { USB_DEVICE(0x2357, 0x0105) }, /* TP-LINK Archer T1U */ + { USB_DEVICE_AND_INTERFACE_INFO(0x0E8D, 0x7630, 0xff, 0x2, 0xff)}, /* MT7630U */ + { USB_DEVICE_AND_INTERFACE_INFO(0x0E8D, 0x7650, 0xff, 0x2, 0xff)}, /* MT7650U */ + { 0, } +}; + +bool mt76x0_usb_alloc_buf(struct mt76x0_dev *dev, size_t len, + struct mt76x0_dma_buf *buf) +{ + struct usb_device *usb_dev = mt76x0_to_usb_dev(dev); + + buf->len = len; + buf->urb = usb_alloc_urb(0, GFP_KERNEL); + buf->buf = usb_alloc_coherent(usb_dev, buf->len, GFP_KERNEL, &buf->dma); + + return !buf->urb || !buf->buf; +} + +void mt76x0_usb_free_buf(struct mt76x0_dev *dev, struct mt76x0_dma_buf *buf) +{ + struct usb_device *usb_dev = mt76x0_to_usb_dev(dev); + + usb_free_coherent(usb_dev, buf->len, buf->buf, buf->dma); + usb_free_urb(buf->urb); +} + +int mt76x0_usb_submit_buf(struct mt76x0_dev *dev, int dir, int ep_idx, + struct mt76x0_dma_buf *buf, gfp_t gfp, + usb_complete_t complete_fn, void *context) +{ + struct usb_device *usb_dev = mt76x0_to_usb_dev(dev); + unsigned pipe; + int ret; + + if (dir == USB_DIR_IN) + pipe = usb_rcvbulkpipe(usb_dev, dev->in_ep[ep_idx]); + else + pipe = usb_sndbulkpipe(usb_dev, dev->out_ep[ep_idx]); + + usb_fill_bulk_urb(buf->urb, usb_dev, pipe, buf->buf, buf->len, + complete_fn, context); + buf->urb->transfer_dma = buf->dma; + buf->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; + + trace_mt_submit_urb(&dev->mt76, buf->urb); + ret = usb_submit_urb(buf->urb, gfp); + if (ret) + dev_err(dev->mt76.dev, "Error: submit URB dir:%d ep:%d failed:%d\n", + dir, ep_idx, ret); + return ret; +} + +void mt76x0_complete_urb(struct urb *urb) +{ + struct completion *cmpl = urb->context; + + complete(cmpl); +} + +int mt76x0_vendor_request(struct mt76x0_dev *dev, const u8 req, + const u8 direction, const u16 val, const u16 offset, + void *buf, const size_t buflen) +{ + int i, ret; + struct usb_device *usb_dev = mt76x0_to_usb_dev(dev); + const u8 req_type = direction | USB_TYPE_VENDOR | USB_RECIP_DEVICE; + const unsigned int pipe = (direction == USB_DIR_IN) ? + usb_rcvctrlpipe(usb_dev, 0) : usb_sndctrlpipe(usb_dev, 0); + + for (i = 0; i < MT_VEND_REQ_MAX_RETRY; i++) { + ret = usb_control_msg(usb_dev, pipe, req, req_type, + val, offset, buf, buflen, + MT_VEND_REQ_TOUT_MS); + trace_mt_vend_req(&dev->mt76, pipe, req, req_type, val, offset, + buf, buflen, ret); + + if (ret == -ENODEV) + set_bit(MT76_REMOVED, &dev->mt76.state); + if (ret >= 0 || ret == -ENODEV) + return ret; + + msleep(5); + } + + dev_err(dev->mt76.dev, "Vendor request req:%02x off:%04x failed:%d\n", + req, offset, ret); + + return ret; +} + +void mt76x0_vendor_reset(struct mt76x0_dev *dev) +{ + mt76x0_vendor_request(dev, MT_VEND_DEV_MODE, USB_DIR_OUT, + MT_VEND_DEV_MODE_RESET, 0, NULL, 0); +} + +static u32 mt76x0_rr(struct mt76_dev *dev, u32 offset) +{ + struct mt76x0_dev *mdev = (struct mt76x0_dev *) dev; + int ret; + u32 val = ~0; + + WARN_ONCE(offset > USHRT_MAX, "read high off:%08x", offset); + + mutex_lock(&mdev->usb_ctrl_mtx); + + ret = mt76x0_vendor_request((struct mt76x0_dev *)dev, MT_VEND_MULTI_READ, USB_DIR_IN, + 0, offset, mdev->data, MT_VEND_BUF); + if (ret == MT_VEND_BUF) + val = get_unaligned_le32(mdev->data); + else if (ret > 0) + dev_err(dev->dev, "Error: wrong size read:%d off:%08x\n", + ret, offset); + + mutex_unlock(&mdev->usb_ctrl_mtx); + + trace_reg_read(dev, offset, val); + return val; +} + +int mt76x0_vendor_single_wr(struct mt76x0_dev *dev, const u8 req, + const u16 offset, const u32 val) +{ + struct mt76x0_dev *mdev = dev; + int ret; + + mutex_lock(&mdev->usb_ctrl_mtx); + + ret = mt76x0_vendor_request(dev, req, USB_DIR_OUT, + val & 0xffff, offset, NULL, 0); + if (!ret) + ret = mt76x0_vendor_request(dev, req, USB_DIR_OUT, + val >> 16, offset + 2, NULL, 0); + + mutex_unlock(&mdev->usb_ctrl_mtx); + + return ret; +} + +static void mt76x0_wr(struct mt76_dev *dev, u32 offset, u32 val) +{ + struct mt76x0_dev *mdev = (struct mt76x0_dev *) dev; + int ret; + + WARN_ONCE(offset > USHRT_MAX, "write high off:%08x", offset); + + mutex_lock(&mdev->usb_ctrl_mtx); + + put_unaligned_le32(val, mdev->data); + ret = mt76x0_vendor_request(mdev, MT_VEND_MULTI_WRITE, USB_DIR_OUT, + 0, offset, mdev->data, MT_VEND_BUF); + trace_reg_write(dev, offset, val); + + mutex_unlock(&mdev->usb_ctrl_mtx); +} + +static u32 mt76x0_rmw(struct mt76_dev *dev, u32 offset, u32 mask, u32 val) +{ + val |= mt76x0_rr(dev, offset) & ~mask; + mt76x0_wr(dev, offset, val); + return val; +} + +static void mt76x0_wr_copy(struct mt76_dev *dev, u32 offset, + const void *data, int len) +{ + WARN_ONCE(offset & 3, "unaligned write copy off:%08x", offset); + WARN_ONCE(len & 3, "short write copy off:%08x", offset); + + mt76x0_burst_write_regs((struct mt76x0_dev *) dev, offset, data, len / 4); +} + +void mt76x0_addr_wr(struct mt76x0_dev *dev, const u32 offset, const u8 *addr) +{ + mt76_wr(dev, offset, get_unaligned_le32(addr)); + mt76_wr(dev, offset + 4, addr[4] | addr[5] << 8); +} + +static int mt76x0_assign_pipes(struct usb_interface *usb_intf, + struct mt76x0_dev *dev) +{ + struct usb_endpoint_descriptor *ep_desc; + struct usb_host_interface *intf_desc = usb_intf->cur_altsetting; + unsigned i, ep_i = 0, ep_o = 0; + + BUILD_BUG_ON(sizeof(dev->in_ep) < __MT_EP_IN_MAX); + BUILD_BUG_ON(sizeof(dev->out_ep) < __MT_EP_OUT_MAX); + + for (i = 0; i < intf_desc->desc.bNumEndpoints; i++) { + ep_desc = &intf_desc->endpoint[i].desc; + + if (usb_endpoint_is_bulk_in(ep_desc) && + ep_i++ < __MT_EP_IN_MAX) { + dev->in_ep[ep_i - 1] = usb_endpoint_num(ep_desc); + dev->in_max_packet = usb_endpoint_maxp(ep_desc); + /* Note: this is ignored by usb sub-system but vendor + * code does it. We can drop this at some point. + */ + dev->in_ep[ep_i - 1] |= USB_DIR_IN; + } else if (usb_endpoint_is_bulk_out(ep_desc) && + ep_o++ < __MT_EP_OUT_MAX) { + dev->out_ep[ep_o - 1] = usb_endpoint_num(ep_desc); + dev->out_max_packet = usb_endpoint_maxp(ep_desc); + } + } + + if (ep_i != __MT_EP_IN_MAX || ep_o != __MT_EP_OUT_MAX) { + dev_err(dev->mt76.dev, "Error: wrong pipe number in:%d out:%d\n", + ep_i, ep_o); + return -EINVAL; + } + + return 0; +} + +static int mt76x0_probe(struct usb_interface *usb_intf, + const struct usb_device_id *id) +{ + struct usb_device *usb_dev = interface_to_usbdev(usb_intf); + struct mt76x0_dev *dev; + u32 asic_rev, mac_rev; + int ret; + static const struct mt76_bus_ops usb_ops = { + .rr = mt76x0_rr, + .wr = mt76x0_wr, + .rmw = mt76x0_rmw, + .copy = mt76x0_wr_copy, + }; + + dev = mt76x0_alloc_device(&usb_intf->dev); + if (!dev) + return -ENOMEM; + + usb_dev = usb_get_dev(usb_dev); + usb_reset_device(usb_dev); + + usb_set_intfdata(usb_intf, dev); + + dev->mt76.bus = &usb_ops; + + ret = mt76x0_assign_pipes(usb_intf, dev); + if (ret) + goto err; + ret = mt76x0_wait_asic_ready(dev); + if (ret) + goto err; + + asic_rev = mt76_rr(dev, MT_ASIC_VERSION); + mac_rev = mt76_rr(dev, MT_MAC_CSR0); + dev_info(dev->mt76.dev, "ASIC revision: %08x MAC revision: %08x\n", + asic_rev, mac_rev); + + /* Note: vendor driver skips this check for MT76X0U */ + if (!(mt76_rr(dev, MT_EFUSE_CTRL) & MT_EFUSE_CTRL_SEL)) + dev_warn(dev->mt76.dev, "Warning: eFUSE not present\n"); + + ret = mt76x0_init_hardware(dev); + if (ret) + goto err; + + ret = mt76x0_register_device(dev); + if (ret) + goto err_hw; + + set_bit(MT76_STATE_INITIALIZED, &dev->mt76.state); + + return 0; +err_hw: + mt76x0_cleanup(dev); +err: + usb_set_intfdata(usb_intf, NULL); + usb_put_dev(interface_to_usbdev(usb_intf)); + + destroy_workqueue(dev->stat_wq); + ieee80211_free_hw(dev->mt76.hw); + return ret; +} + +static void mt76x0_disconnect(struct usb_interface *usb_intf) +{ + struct mt76x0_dev *dev = usb_get_intfdata(usb_intf); + bool initalized = test_bit(MT76_STATE_INITIALIZED, &dev->mt76.state); + + if (!initalized) + return; + + ieee80211_unregister_hw(dev->mt76.hw); + mt76x0_cleanup(dev); + + usb_set_intfdata(usb_intf, NULL); + usb_put_dev(interface_to_usbdev(usb_intf)); + + destroy_workqueue(dev->stat_wq); + ieee80211_free_hw(dev->mt76.hw); +} + +static int mt76x0_suspend(struct usb_interface *usb_intf, pm_message_t state) +{ + struct mt76x0_dev *dev = usb_get_intfdata(usb_intf); + + mt76x0_cleanup(dev); + + return 0; +} + +static int mt76x0_resume(struct usb_interface *usb_intf) +{ + struct mt76x0_dev *dev = usb_get_intfdata(usb_intf); + int ret; + + ret = mt76x0_init_hardware(dev); + if (ret) + return ret; + + set_bit(MT76_STATE_INITIALIZED, &dev->mt76.state); + + return 0; +} + +MODULE_DEVICE_TABLE(usb, mt76x0_device_table); +MODULE_FIRMWARE(MT7610_FIRMWARE); +MODULE_LICENSE("GPL"); + +static struct usb_driver mt76x0_driver = { + .name = KBUILD_MODNAME, + .id_table = mt76x0_device_table, + .probe = mt76x0_probe, + .disconnect = mt76x0_disconnect, + .suspend = mt76x0_suspend, + .resume = mt76x0_resume, + .reset_resume = mt76x0_resume, + .soft_unbind = 1, + .disable_hub_initiated_lpm = 1, +}; +module_usb_driver(mt76x0_driver); -- cgit v1.2.3 From 369bbecdbb2def6265c06512c44e1fbe6ad8e556 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 31 Jul 2018 14:41:03 +0200 Subject: mt76x0: disable HW before probe Disable HW before probe, otherwise after reboot we will fail to initialize MCU. Signed-off-by: Stanislaw Gruszka Signed-off-by: Kalle Valo --- drivers/net/wireless/mediatek/mt76/mt76x0/init.c | 2 +- drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h | 1 + drivers/net/wireless/mediatek/mt76/mt76x0/usb.c | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) (limited to 'drivers/net/wireless/mediatek/mt76/mt76x0/usb.c') diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/init.c b/drivers/net/wireless/mediatek/mt76/mt76x0/init.c index b65b76d80906..7cdb3e740522 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/init.c @@ -62,7 +62,7 @@ mt76x0_set_wlan_state(struct mt76x0_dev *dev, u32 val, bool enable) dev_err(dev->mt76.dev, "Error: PLL and XTAL check failed!\n"); } -static void mt76x0_chip_onoff(struct mt76x0_dev *dev, bool enable, bool reset) +void mt76x0_chip_onoff(struct mt76x0_dev *dev, bool enable, bool reset) { u32 val; diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h b/drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h index 49b82a23533c..9e60fcb14687 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h @@ -288,6 +288,7 @@ struct mt76x0_dev *mt76x0_alloc_device(struct device *dev); int mt76x0_init_hardware(struct mt76x0_dev *dev); int mt76x0_register_device(struct mt76x0_dev *dev); void mt76x0_cleanup(struct mt76x0_dev *dev); +void mt76x0_chip_onoff(struct mt76x0_dev *dev, bool enable, bool reset); int mt76x0_mac_start(struct mt76x0_dev *dev); void mt76x0_mac_stop(struct mt76x0_dev *dev); diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c index 0871fdef59c3..7a635cdcbae0 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c @@ -283,6 +283,10 @@ static int mt76x0_probe(struct usb_interface *usb_intf, ret = mt76x0_assign_pipes(usb_intf, dev); if (ret) goto err; + + /* Disable the HW, otherwise MCU fail to initalize on hot reboot */ + mt76x0_chip_onoff(dev, false, false); + ret = mt76x0_wait_asic_ready(dev); if (ret) goto err; -- cgit v1.2.3 From e800a333135bef633ffb21bdd471b8ffc491db7b Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 3 Aug 2018 13:44:40 +0200 Subject: mt76x0: rename trace symbols Rename trace symbols that conflict with mt7601u and remove some definitions that are not used. Patch fixes build errors like this: ld: drivers/net/wireless/mediatek/mt76/mt76x0/trace.o:(__tracepoints+0x0): multiple definition of `__tracepoint_set_shared_key'; drivers/net/wireless/mediatek/mt7601u/trace.o:(__tracepoints+0x0): first defined here Reported-by: Stephen Rothwell Fixes: 7b4859026ccd ("mt76x0: core files") Signed-off-by: Stanislaw Gruszka Signed-off-by: Kalle Valo --- drivers/net/wireless/mediatek/mt76/mt76x0/dma.c | 8 +- drivers/net/wireless/mediatek/mt76/mt76x0/mac.c | 4 +- drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c | 8 +- drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h | 6 -- drivers/net/wireless/mediatek/mt76/mt76x0/phy.c | 4 +- drivers/net/wireless/mediatek/mt76/mt76x0/trace.h | 87 +++++----------------- drivers/net/wireless/mediatek/mt76/mt76x0/tx.c | 4 +- drivers/net/wireless/mediatek/mt76/mt76x0/usb.c | 8 +- 8 files changed, 35 insertions(+), 94 deletions(-) (limited to 'drivers/net/wireless/mediatek/mt76/mt76x0/usb.c') diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/dma.c b/drivers/net/wireless/mediatek/mt76/mt76x0/dma.c index d91b1bb8fcc7..e2efb430419b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/dma.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/dma.c @@ -105,7 +105,7 @@ static void mt76x0_rx_process_seg(struct mt76x0_dev *dev, u8 *data, if (unlikely(FIELD_GET(MT_RXD_INFO_TYPE, fce_info))) dev_err_once(dev->mt76.dev, "Error: RX path seen a non-pkt urb\n"); - trace_mt_rx(&dev->mt76, rxwi, fce_info); + trace_mt76x0_rx(&dev->mt76, rxwi, fce_info); skb = mt76x0_rx_skb_from_seg(dev, rxwi, data, seg_len, truesize, p); if (!skb) @@ -155,7 +155,7 @@ mt76x0_rx_process_entry(struct mt76x0_dev *dev, struct mt76x0_dma_buf_rx *e) } if (cnt > 1) - trace_mt_rx_dma_aggr(&dev->mt76, cnt, !!new_p); + trace_mt76x0_rx_dma_aggr(&dev->mt76, cnt, !!new_p); if (new_p) { /* we have one extra ref from the allocator */ @@ -235,7 +235,7 @@ static void mt76x0_complete_tx(struct urb *urb) goto out; skb = q->e[q->start].skb; - trace_mt_tx_dma_done(&dev->mt76, skb); + trace_mt76x0_tx_dma_done(&dev->mt76, skb); __skb_queue_tail(&dev->tx_skb_done, skb); tasklet_schedule(&dev->tx_tasklet); @@ -384,7 +384,7 @@ static int mt76x0_submit_rx_buf(struct mt76x0_dev *dev, usb_fill_bulk_urb(e->urb, usb_dev, pipe, buf, MT_RX_URB_SIZE, mt76x0_complete_rx, dev); - trace_mt_submit_urb(&dev->mt76, e->urb); + trace_mt76x0_submit_urb(&dev->mt76, e->urb); ret = usb_submit_urb(e->urb, gfp); if (ret) dev_err(dev->mt76.dev, "Error: submit RX URB failed:%d\n", ret); diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/mac.c b/drivers/net/wireless/mediatek/mt76/mt76x0/mac.c index 5f12724eeb62..95f28492a843 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/mac.c @@ -606,7 +606,7 @@ int mt76x0_mac_wcid_set_key(struct mt76x0_dev *dev, u8 idx, if (cipher == MT_CIPHER_NONE && key) return -EINVAL; - trace_set_key(&dev->mt76, idx); + trace_mt76x0_set_key(&dev->mt76, idx); mt76_wr_copy(dev, MT_WCID_KEY(idx), key_data, sizeof(key_data)); @@ -646,7 +646,7 @@ int mt76x0_mac_shared_key_setup(struct mt76x0_dev *dev, u8 vif_idx, u8 key_idx, if (cipher == MT_CIPHER_NONE && key) return -EINVAL; - trace_set_shared_key(&dev->mt76, vif_idx, key_idx); + trace_mt76x0_set_shared_key(&dev->mt76, vif_idx, key_idx); mt76_wr_copy(dev, MT_SKEY(vif_idx, key_idx), key_data, sizeof(key_data)); diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c b/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c index 979ba519e54f..8affacbab90a 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c @@ -48,7 +48,7 @@ static inline void mt76x0_dma_skb_wrap_cmd(struct sk_buff *skb, FIELD_PREP(MT_TXD_CMD_TYPE, cmd))); } -static inline void trace_mt_mcu_msg_send_cs(struct mt76_dev *dev, +static inline void trace_mt76x0_mcu_msg_send_cs(struct mt76_dev *dev, struct sk_buff *skb, bool need_resp) { u32 i, csum = 0; @@ -56,7 +56,7 @@ static inline void trace_mt_mcu_msg_send_cs(struct mt76_dev *dev, for (i = 0; i < skb->len / 4; i++) csum ^= get_unaligned_le32(skb->data + i * 4); - trace_mt_mcu_msg_send(dev, skb, csum, need_resp); + trace_mt76x0_mcu_msg_send(dev, skb, csum, need_resp); } static struct sk_buff * @@ -168,8 +168,8 @@ __mt76x0_mcu_msg_send(struct mt76x0_dev *dev, struct sk_buff *skb, if (dev->mcu.resp_cmpl.done) dev_err(dev->mt76.dev, "Error: MCU response pre-completed!\n"); - trace_mt_mcu_msg_send_cs(&dev->mt76, skb, wait_resp); - trace_mt_submit_urb_sync(&dev->mt76, cmd_pipe, skb->len); + trace_mt76x0_mcu_msg_send_cs(&dev->mt76, skb, wait_resp); + trace_mt76x0_submit_urb_sync(&dev->mt76, cmd_pipe, skb->len); ret = usb_bulk_msg(usb_dev, cmd_pipe, skb->data, skb->len, &sent, 500); if (ret) { diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h b/drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h index c1feca3ea016..fc9857f61771 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h @@ -124,12 +124,6 @@ struct mt76x0_eeprom_params; #define MT_VEND_ADDR(type, n) (MT_VEND_TYPE_##type | (n)) -enum mt_temp_mode { - MT_TEMP_MODE_NORMAL, - MT_TEMP_MODE_HIGH, - MT_TEMP_MODE_LOW, -}; - enum mt_bw { MT_BW_20, MT_BW_40, diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c index e52a50661b1a..5da7bfbe907f 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c @@ -52,7 +52,7 @@ mt76x0_rf_csr_wr(struct mt76x0_dev *dev, u32 offset, u8 value) FIELD_PREP(MT_RF_CSR_CFG_REG_ID, reg) | MT_RF_CSR_CFG_WR | MT_RF_CSR_CFG_KICK); - trace_rf_write(&dev->mt76, bank, offset, value); + trace_mt76x0_rf_write(&dev->mt76, bank, offset, value); out: mutex_unlock(&dev->reg_atomic_mutex); @@ -96,7 +96,7 @@ mt76x0_rf_csr_rr(struct mt76x0_dev *dev, u32 offset) if (FIELD_GET(MT_RF_CSR_CFG_REG_ID, val) == reg && FIELD_GET(MT_RF_CSR_CFG_REG_BANK, val) == bank) { ret = FIELD_GET(MT_RF_CSR_CFG_DATA, val); - trace_rf_read(&dev->mt76, bank, offset, ret); + trace_mt76x0_rf_read(&dev->mt76, bank, offset, ret); } out: mutex_unlock(&dev->reg_atomic_mutex); diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/trace.h b/drivers/net/wireless/mediatek/mt76/mt76x0/trace.h index cdf53e5442d8..8a752a09f2dc 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/trace.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/trace.h @@ -51,17 +51,17 @@ DECLARE_EVENT_CLASS(dev_reg_evt, ) ); -DEFINE_EVENT(dev_reg_evt, reg_read, +DEFINE_EVENT(dev_reg_evt, mt76x0_reg_read, TP_PROTO(struct mt76_dev *dev, u32 reg, u32 val), TP_ARGS(dev, reg, val) ); -DEFINE_EVENT(dev_reg_evt, reg_write, +DEFINE_EVENT(dev_reg_evt, mt76x0_reg_write, TP_PROTO(struct mt76_dev *dev, u32 reg, u32 val), TP_ARGS(dev, reg, val) ); -TRACE_EVENT(mt_submit_urb, +TRACE_EVENT(mt76x0_submit_urb, TP_PROTO(struct mt76_dev *dev, struct urb *u), TP_ARGS(dev, u), TP_STRUCT__entry( @@ -76,14 +76,14 @@ TRACE_EVENT(mt_submit_urb, DEV_PR_ARG, __entry->pipe, __entry->len) ); -#define trace_mt_submit_urb_sync(__dev, __pipe, __len) ({ \ +#define trace_mt76x0_submit_urb_sync(__dev, __pipe, __len) ({ \ struct urb u; \ u.pipe = __pipe; \ u.transfer_buffer_length = __len; \ - trace_mt_submit_urb(__dev, &u); \ + trace_mt76x0_submit_urb(__dev, &u); \ }) -TRACE_EVENT(mt_mcu_msg_send, +TRACE_EVENT(mt76x0_mcu_msg_send, TP_PROTO(struct mt76_dev *dev, struct sk_buff *skb, u32 csum, bool resp), TP_ARGS(dev, skb, csum, resp), @@ -103,7 +103,7 @@ TRACE_EVENT(mt_mcu_msg_send, DEV_PR_ARG, __entry->info, __entry->csum, __entry->resp) ); -TRACE_EVENT(mt_vend_req, +TRACE_EVENT(mt76x0_vend_req, TP_PROTO(struct mt76_dev *dev, unsigned pipe, u8 req, u8 req_type, u16 val, u16 offset, void *buf, size_t buflen, int ret), TP_ARGS(dev, pipe, req, req_type, val, offset, buf, buflen, ret), @@ -131,21 +131,6 @@ TRACE_EVENT(mt_vend_req, !!__entry->buf, __entry->buflen) ); -TRACE_EVENT(ee_read, - TP_PROTO(struct mt76_dev *dev, int offset, u16 val), - TP_ARGS(dev, offset, val), - TP_STRUCT__entry( - DEV_ENTRY - __field(int, o) __field(u16, v) - ), - TP_fast_assign( - DEV_ASSIGN; - __entry->o = offset; - __entry->v = val; - ), - TP_printk(DEV_PR_FMT "%04x=%04x", DEV_PR_ARG, __entry->o, __entry->v) -); - DECLARE_EVENT_CLASS(dev_rf_reg_evt, TP_PROTO(struct mt76_dev *dev, u8 bank, u8 reg, u8 val), TP_ARGS(dev, bank, reg, val), @@ -166,44 +151,16 @@ DECLARE_EVENT_CLASS(dev_rf_reg_evt, ) ); -DEFINE_EVENT(dev_rf_reg_evt, rf_read, +DEFINE_EVENT(dev_rf_reg_evt, mt76x0_rf_read, TP_PROTO(struct mt76_dev *dev, u8 bank, u8 reg, u8 val), TP_ARGS(dev, bank, reg, val) ); -DEFINE_EVENT(dev_rf_reg_evt, rf_write, +DEFINE_EVENT(dev_rf_reg_evt, mt76x0_rf_write, TP_PROTO(struct mt76_dev *dev, u8 bank, u8 reg, u8 val), TP_ARGS(dev, bank, reg, val) ); -DECLARE_EVENT_CLASS(dev_bbp_reg_evt, - TP_PROTO(struct mt76_dev *dev, u8 reg, u8 val), - TP_ARGS(dev, reg, val), - TP_STRUCT__entry( - DEV_ENTRY - __field(u8, reg) - __field(u8, val) - ), - TP_fast_assign( - DEV_ASSIGN; - REG_ASSIGN; - ), - TP_printk( - DEV_PR_FMT "%02hhx=%02hhx", - DEV_PR_ARG, __entry->reg, __entry->val - ) -); - -DEFINE_EVENT(dev_bbp_reg_evt, bbp_read, - TP_PROTO(struct mt76_dev *dev, u8 reg, u8 val), - TP_ARGS(dev, reg, val) -); - -DEFINE_EVENT(dev_bbp_reg_evt, bbp_write, - TP_PROTO(struct mt76_dev *dev, u8 reg, u8 val), - TP_ARGS(dev, reg, val) -); - DECLARE_EVENT_CLASS(dev_simple_evt, TP_PROTO(struct mt76_dev *dev, u8 val), TP_ARGS(dev, val), @@ -220,17 +177,7 @@ DECLARE_EVENT_CLASS(dev_simple_evt, ) ); -DEFINE_EVENT(dev_simple_evt, temp_mode, - TP_PROTO(struct mt76_dev *dev, u8 val), - TP_ARGS(dev, val) -); - -DEFINE_EVENT(dev_simple_evt, read_temp, - TP_PROTO(struct mt76_dev *dev, u8 val), - TP_ARGS(dev, val) -); - -TRACE_EVENT(mt_rx, +TRACE_EVENT(mt76x0_rx, TP_PROTO(struct mt76_dev *dev, struct mt76x0_rxwi *rxwi, u32 f), TP_ARGS(dev, rxwi, f), TP_STRUCT__entry( @@ -248,7 +195,7 @@ TRACE_EVENT(mt_rx, le32_to_cpu(__entry->rxwi.ctl)) ); -TRACE_EVENT(mt_tx, +TRACE_EVENT(mt76x0_tx, TP_PROTO(struct mt76_dev *dev, struct sk_buff *skb, struct mt76_sta *sta, struct mt76_txwi *h), TP_ARGS(dev, skb, sta, h), @@ -273,7 +220,7 @@ TRACE_EVENT(mt_tx, le16_to_cpu(__entry->h.len_ctl)) ); -TRACE_EVENT(mt_tx_dma_done, +TRACE_EVENT(mt76x0_tx_dma_done, TP_PROTO(struct mt76_dev *dev, struct sk_buff *skb), TP_ARGS(dev, skb), TP_STRUCT__entry( @@ -287,7 +234,7 @@ TRACE_EVENT(mt_tx_dma_done, TP_printk(DEV_PR_FMT "%p", DEV_PR_ARG, __entry->skb) ); -TRACE_EVENT(mt_tx_status_cleaned, +TRACE_EVENT(mt76x0_tx_status_cleaned, TP_PROTO(struct mt76_dev *dev, int cleaned), TP_ARGS(dev, cleaned), TP_STRUCT__entry( @@ -301,7 +248,7 @@ TRACE_EVENT(mt_tx_status_cleaned, TP_printk(DEV_PR_FMT "%d", DEV_PR_ARG, __entry->cleaned) ); -TRACE_EVENT(mt_tx_status, +TRACE_EVENT(mt76x0_tx_status, TP_PROTO(struct mt76_dev *dev, u32 stat1, u32 stat2), TP_ARGS(dev, stat1, stat2), TP_STRUCT__entry( @@ -317,7 +264,7 @@ TRACE_EVENT(mt_tx_status, DEV_PR_ARG, __entry->stat1, __entry->stat2) ); -TRACE_EVENT(mt_rx_dma_aggr, +TRACE_EVENT(mt76x0_rx_dma_aggr, TP_PROTO(struct mt76_dev *dev, int cnt, bool paged), TP_ARGS(dev, cnt, paged), TP_STRUCT__entry( @@ -334,12 +281,12 @@ TRACE_EVENT(mt_rx_dma_aggr, DEV_PR_ARG, __entry->cnt, __entry->paged) ); -DEFINE_EVENT(dev_simple_evt, set_key, +DEFINE_EVENT(dev_simple_evt, mt76x0_set_key, TP_PROTO(struct mt76_dev *dev, u8 val), TP_ARGS(dev, val) ); -TRACE_EVENT(set_shared_key, +TRACE_EVENT(mt76x0_set_shared_key, TP_PROTO(struct mt76_dev *dev, u8 vid, u8 key), TP_ARGS(dev, vid, key), TP_STRUCT__entry( diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/tx.c b/drivers/net/wireless/mediatek/mt76/mt76x0/tx.c index 976d3ee91f67..751b49c28ae5 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/tx.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/tx.c @@ -177,7 +177,7 @@ void mt76x0_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control, if (mt76x0_dma_enqueue_tx(dev, skb, wcid, hw_q)) return; - trace_mt_tx(&dev->mt76, skb, msta, txwi); + trace_mt76x0_tx(&dev->mt76, skb, msta, txwi); } void mt76x0_tx_stat(struct work_struct *work) @@ -198,7 +198,7 @@ void mt76x0_tx_stat(struct work_struct *work) cleaned++; } - trace_mt_tx_status_cleaned(&dev->mt76, cleaned); + trace_mt76x0_tx_status_cleaned(&dev->mt76, cleaned); spin_lock_irqsave(&dev->tx_lock, flags); if (cleaned) diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c index 7a635cdcbae0..54ae1f113be2 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c @@ -84,7 +84,7 @@ int mt76x0_usb_submit_buf(struct mt76x0_dev *dev, int dir, int ep_idx, buf->urb->transfer_dma = buf->dma; buf->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; - trace_mt_submit_urb(&dev->mt76, buf->urb); + trace_mt76x0_submit_urb(&dev->mt76, buf->urb); ret = usb_submit_urb(buf->urb, gfp); if (ret) dev_err(dev->mt76.dev, "Error: submit URB dir:%d ep:%d failed:%d\n", @@ -113,7 +113,7 @@ int mt76x0_vendor_request(struct mt76x0_dev *dev, const u8 req, ret = usb_control_msg(usb_dev, pipe, req, req_type, val, offset, buf, buflen, MT_VEND_REQ_TOUT_MS); - trace_mt_vend_req(&dev->mt76, pipe, req, req_type, val, offset, + trace_mt76x0_vend_req(&dev->mt76, pipe, req, req_type, val, offset, buf, buflen, ret); if (ret == -ENODEV) @@ -156,7 +156,7 @@ static u32 mt76x0_rr(struct mt76_dev *dev, u32 offset) mutex_unlock(&mdev->usb_ctrl_mtx); - trace_reg_read(dev, offset, val); + trace_mt76x0_reg_read(dev, offset, val); return val; } @@ -191,7 +191,7 @@ static void mt76x0_wr(struct mt76_dev *dev, u32 offset, u32 val) put_unaligned_le32(val, mdev->data); ret = mt76x0_vendor_request(mdev, MT_VEND_MULTI_WRITE, USB_DIR_OUT, 0, offset, mdev->data, MT_VEND_BUF); - trace_reg_write(dev, offset, val); + trace_mt76x0_reg_write(dev, offset, val); mutex_unlock(&mdev->usb_ctrl_mtx); } -- cgit v1.2.3