1 /****************************************************************************** 2 * 3 * Copyright(c) 2007 - 2019 Realtek Corporation. 4 * 5 * This program is free software; you can redistribute it and/or modify it 6 * under the terms of version 2 of the GNU General Public License as 7 * published by the Free Software Foundation. 8 * 9 * This program is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 * more details. 13 * 14 *****************************************************************************/ 15 #ifndef __USB_OPS_H_ 16 #define __USB_OPS_H_ 17 18 19 #define REALTEK_USB_VENQT_READ 0xC0 20 #define REALTEK_USB_VENQT_WRITE 0x40 21 #define REALTEK_USB_VENQT_CMD_REQ 0x05 22 #define REALTEK_USB_VENQT_CMD_IDX 0x00 23 #define REALTEK_USB_BULK_IN_EP_IDX 0 24 #define REALTEK_USB_IN_INT_EP_IDX 1 25 26 enum { 27 VENDOR_WRITE = 0x00, 28 VENDOR_READ = 0x01, 29 }; 30 #define ALIGNMENT_UNIT 16 31 #define MAX_VENDOR_REQ_CMD_SIZE 254 /* 8188cu SIE Support */ 32 #define MAX_USB_IO_CTL_SIZE (MAX_VENDOR_REQ_CMD_SIZE + ALIGNMENT_UNIT) 33 34 #ifdef PLATFORM_LINUX 35 #include <usb_ops_linux.h> 36 #endif /* PLATFORM_LINUX */ 37 38 #define IS_FULL_SPEED_USB(_dvobj) (dvobj_to_usb(_dvobj)->usb_speed == RTW_USB_SPEED_FULL) 39 #define IS_HIGH_SPEED_USB(_dvobj) (dvobj_to_usb(_dvobj)->usb_speed == RTW_USB_SPEED_HIGH) 40 #define IS_SUPER_SPEED_USB(_dvobj) (dvobj_to_usb(_dvobj)->usb_speed == RTW_USB_SPEED_SUPER) 41 #define IS_SUPER_PLUS_SPEED_USB(_dvobj) (dvobj_to_usb(_dvobj)->usb_speed == RTW_USB_SPEED_SUPER_10G) 42 rtw_usb_bulkout_size(struct dvobj_priv * dvobj)43static inline u16 rtw_usb_bulkout_size(struct dvobj_priv *dvobj) 44 { 45 if (IS_SUPER_SPEED_USB(dvobj)) 46 return USB_SUPER_SPEED_BULK_SIZE; 47 else if (IS_HIGH_SPEED_USB(dvobj)) 48 return USB_HIGH_SPEED_BULK_SIZE; 49 else 50 return USB_FULL_SPEED_BULK_SIZE; 51 } 52 rtw_usb_bulkout_size_boundary(struct dvobj_priv * dvobj,int buf_len)53static inline u8 rtw_usb_bulkout_size_boundary(struct dvobj_priv *dvobj, int buf_len) 54 { 55 u8 rst = _TRUE; 56 57 if (IS_SUPER_SPEED_USB(dvobj)) 58 rst = (0 == (buf_len) % USB_SUPER_SPEED_BULK_SIZE) ? _TRUE : _FALSE; 59 else if (IS_HIGH_SPEED_USB(dvobj)) 60 rst = (0 == (buf_len) % USB_HIGH_SPEED_BULK_SIZE) ? _TRUE : _FALSE; 61 else 62 rst = (0 == (buf_len) % USB_FULL_SPEED_BULK_SIZE) ? _TRUE : _FALSE; 63 return rst; 64 } 65 66 67 #endif /* __USB_OPS_H_ */ 68