2 * Copyright (C) 2015 Jakub Kicinski <kubakici@wp.pl>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2
6 * as published by the Free Software Foundation
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
14 #ifndef __MT76X0U_USB_H
15 #define __MT76X0U_USB_H
19 #define MT7610_FIRMWARE "/*(DEBLOBBED)*/"
21 #define MT_VEND_REQ_MAX_RETRY 10
22 #define MT_VEND_REQ_TOUT_MS 300
24 #define MT_VEND_DEV_MODE_RESET 1
26 #define MT_VEND_BUF sizeof(__le32)
28 static inline struct usb_device *mt76x0_to_usb_dev(struct mt76x0_dev *mt76x0)
30 return interface_to_usbdev(to_usb_interface(mt76x0->mt76.dev));
33 static inline struct usb_device *mt76_to_usb_dev(struct mt76_dev *mt76)
35 return interface_to_usbdev(to_usb_interface(mt76->dev));
38 static inline bool mt76x0_urb_has_error(struct urb *urb)
41 urb->status != -ENOENT &&
42 urb->status != -ECONNRESET &&
43 urb->status != -ESHUTDOWN;
46 bool mt76x0_usb_alloc_buf(struct mt76x0_dev *dev, size_t len,
47 struct mt76x0_dma_buf *buf);
48 void mt76x0_usb_free_buf(struct mt76x0_dev *dev, struct mt76x0_dma_buf *buf);
49 int mt76x0_usb_submit_buf(struct mt76x0_dev *dev, int dir, int ep_idx,
50 struct mt76x0_dma_buf *buf, gfp_t gfp,
51 usb_complete_t complete_fn, void *context);
52 void mt76x0_complete_urb(struct urb *urb);
54 int mt76x0_vendor_request(struct mt76x0_dev *dev, const u8 req,
55 const u8 direction, const u16 val, const u16 offset,
56 void *buf, const size_t buflen);
57 void mt76x0_vendor_reset(struct mt76x0_dev *dev);
58 int mt76x0_vendor_single_wr(struct mt76x0_dev *dev, const u8 req,
59 const u16 offset, const u32 val);