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 __MT7601U_USB_H
15 #define __MT7601U_USB_H
19 #define MT7601U_FIRMWARE "mt7601u.bin"
21 #define MT_VEND_REQ_MAX_RETRY 10
22 #define MT_VEND_REQ_TOUT_MS 300
24 #define MT_VEND_DEV_MODE_RESET 1
29 MT_VEND_MULTI_READ = 7,
30 MT_VEND_WRITE_FCE = 0x42,
49 static inline struct usb_device *mt7601u_to_usb_dev(struct mt7601u_dev *mt7601u)
51 return interface_to_usbdev(to_usb_interface(mt7601u->dev));
54 static inline bool mt7601u_urb_has_error(struct urb *urb)
57 urb->status != -ENOENT &&
58 urb->status != -ECONNRESET &&
59 urb->status != -ESHUTDOWN;
62 bool mt7601u_usb_alloc_buf(struct mt7601u_dev *dev, size_t len,
63 struct mt7601u_dma_buf *buf);
64 void mt7601u_usb_free_buf(struct mt7601u_dev *dev, struct mt7601u_dma_buf *buf);
65 int mt7601u_usb_submit_buf(struct mt7601u_dev *dev, int dir, int ep_idx,
66 struct mt7601u_dma_buf *buf, gfp_t gfp,
67 usb_complete_t complete_fn, void *context);
68 void mt7601u_complete_urb(struct urb *urb);
70 int mt7601u_vendor_request(struct mt7601u_dev *dev, const u8 req,
71 const u8 direction, const u16 val, const u16 offset,
72 void *buf, const size_t buflen);
73 void mt7601u_vendor_reset(struct mt7601u_dev *dev);
74 int mt7601u_vendor_single_wr(struct mt7601u_dev *dev, const u8 req,
75 const u16 offset, const u32 val);