1 /* 2 * Copyright (C) 2015 Jakub Kicinski <kubakici@wp.pl> 3 * 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 7 * 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. 12 */ 13 14 #ifndef __MT7601U_USB_H 15 #define __MT7601U_USB_H 16 17 #include "mt7601u.h" 18 19 #define MT7601U_FIRMWARE "mt7601u.bin" 20 21 #define MT_VEND_REQ_MAX_RETRY 10 22 #define MT_VEND_REQ_TOUT_MS 300 23 24 #define MT_VEND_DEV_MODE_RESET 1 25 26 enum mt_vendor_req { 27 MT_VEND_DEV_MODE = 1, 28 MT_VEND_WRITE = 2, 29 MT_VEND_MULTI_READ = 7, 30 MT_VEND_WRITE_FCE = 0x42, 31 }; 32 33 enum mt_usb_ep_in { 34 MT_EP_IN_PKT_RX, 35 MT_EP_IN_CMD_RESP, 36 __MT_EP_IN_MAX, 37 }; 38 39 enum mt_usb_ep_out { 40 MT_EP_OUT_INBAND_CMD, 41 MT_EP_OUT_AC_BK, 42 MT_EP_OUT_AC_BE, 43 MT_EP_OUT_AC_VI, 44 MT_EP_OUT_AC_VO, 45 MT_EP_OUT_HCCA, 46 __MT_EP_OUT_MAX, 47 }; 48 49 static inline struct usb_device *mt7601u_to_usb_dev(struct mt7601u_dev *mt7601u) 50 { 51 return interface_to_usbdev(to_usb_interface(mt7601u->dev)); 52 } 53 54 static inline bool mt7601u_urb_has_error(struct urb *urb) 55 { 56 return urb->status && 57 urb->status != -ENOENT && 58 urb->status != -ECONNRESET && 59 urb->status != -ESHUTDOWN; 60 } 61 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); 69 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); 76 77 #endif 78