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
26 #define MT_VEND_BUF sizeof(__le32)
31 MT_VEND_MULTI_READ
= 7,
32 MT_VEND_WRITE_FCE
= 0x42,
51 static inline struct usb_device
*mt7601u_to_usb_dev(struct mt7601u_dev
*mt7601u
)
53 return interface_to_usbdev(to_usb_interface(mt7601u
->dev
));
56 static inline bool mt7601u_urb_has_error(struct urb
*urb
)
59 urb
->status
!= -ENOENT
&&
60 urb
->status
!= -ECONNRESET
&&
61 urb
->status
!= -ESHUTDOWN
;
64 bool mt7601u_usb_alloc_buf(struct mt7601u_dev
*dev
, size_t len
,
65 struct mt7601u_dma_buf
*buf
);
66 void mt7601u_usb_free_buf(struct mt7601u_dev
*dev
, struct mt7601u_dma_buf
*buf
);
67 int mt7601u_usb_submit_buf(struct mt7601u_dev
*dev
, int dir
, int ep_idx
,
68 struct mt7601u_dma_buf
*buf
, gfp_t gfp
,
69 usb_complete_t complete_fn
, void *context
);
70 void mt7601u_complete_urb(struct urb
*urb
);
72 int mt7601u_vendor_request(struct mt7601u_dev
*dev
, const u8 req
,
73 const u8 direction
, const u16 val
, const u16 offset
,
74 void *buf
, const size_t buflen
);
75 void mt7601u_vendor_reset(struct mt7601u_dev
*dev
);
76 int mt7601u_vendor_single_wr(struct mt7601u_dev
*dev
, const u8 req
,
77 const u16 offset
, const u32 val
);