xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/rockchip_wlan/rtl8723bs/include/usb_ops.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2017 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_IN_INT_EP_IDX	1
24 
25 enum {
26 	VENDOR_WRITE = 0x00,
27 	VENDOR_READ = 0x01,
28 };
29 #define ALIGNMENT_UNIT				16
30 #define MAX_VENDOR_REQ_CMD_SIZE	254		/* 8188cu SIE Support */
31 #define MAX_USB_IO_CTL_SIZE		(MAX_VENDOR_REQ_CMD_SIZE + ALIGNMENT_UNIT)
32 
33 #ifdef PLATFORM_LINUX
34 #include <usb_ops_linux.h>
35 #endif /* PLATFORM_LINUX */
36 
37 #ifdef CONFIG_RTL8188E
38 void rtl8188eu_set_hw_type(struct dvobj_priv *pdvobj);
39 #ifdef CONFIG_SUPPORT_USB_INT
40 void interrupt_handler_8188eu(_adapter *padapter, u16 pkt_len, u8 *pbuf);
41 #endif
42 #endif
43 
44 #if defined(CONFIG_RTL8812A) || defined(CONFIG_RTL8821A)
45 void rtl8812au_set_hw_type(struct dvobj_priv *pdvobj);
46 #ifdef CONFIG_SUPPORT_USB_INT
47 void interrupt_handler_8812au(_adapter *padapter, u16 pkt_len, u8 *pbuf);
48 #endif
49 #endif
50 
51 #ifdef CONFIG_RTL8814A
52 void rtl8814au_set_hw_type(struct dvobj_priv *pdvobj);
53 #ifdef CONFIG_SUPPORT_USB_INT
54 void interrupt_handler_8814au(_adapter *padapter, u16 pkt_len, u8 *pbuf);
55 #endif
56 #endif /* CONFIG_RTL8814 */
57 
58 #ifdef CONFIG_RTL8192E
59 void rtl8192eu_set_hw_type(struct dvobj_priv *pdvobj);
60 #ifdef CONFIG_SUPPORT_USB_INT
61 void interrupt_handler_8192eu(_adapter *padapter, u16 pkt_len, u8 *pbuf);
62 #endif
63 
64 #endif
65 
66 #ifdef CONFIG_RTL8188F
67 void rtl8188fu_set_hw_type(struct dvobj_priv *pdvobj);
68 #ifdef CONFIG_SUPPORT_USB_INT
69 void interrupt_handler_8188fu(_adapter *padapter, u16 pkt_len, u8 *pbuf);
70 #endif
71 #endif
72 
73 #ifdef CONFIG_RTL8723B
74 void rtl8723bu_set_hw_type(struct dvobj_priv *pdvobj);
75 #ifdef CONFIG_SUPPORT_USB_INT
76 void interrupt_handler_8723bu(_adapter *padapter, u16 pkt_len, u8 *pbuf);
77 #endif
78 #endif
79 
80 #ifdef CONFIG_RTL8703B
81 void rtl8703bu_set_hw_type(struct dvobj_priv *pdvobj);
82 #ifdef CONFIG_SUPPORT_USB_INT
83 void interrupt_handler_8703bu(_adapter *padapter, u16 pkt_len, u8 *pbuf);
84 #endif /* CONFIG_SUPPORT_USB_INT */
85 #endif /* CONFIG_RTL8703B */
86 
87 void usb_set_intf_ops(_adapter *padapter, struct _io_ops *pops);
88 
89 #ifdef CONFIG_RTL8723D
90 void rtl8723du_set_hw_type(struct dvobj_priv *pdvobj);
91 void rtl8723du_set_intf_ops(struct _io_ops *pops);
92 void rtl8723du_recv_tasklet(void *priv);
93 void rtl8723du_xmit_tasklet(void *priv);
94 #ifdef CONFIG_SUPPORT_USB_INT
95 void interrupt_handler_8723du(_adapter *padapter, u16 pkt_len, u8 *pbuf);
96 #endif /* CONFIG_SUPPORT_USB_INT */
97 #endif /* CONFIG_RTL8723D */
98 
99 enum RTW_USB_SPEED {
100 	RTW_USB_SPEED_UNKNOWN	= 0,
101 	RTW_USB_SPEED_1_1	= 1,
102 	RTW_USB_SPEED_2		= 2,
103 	RTW_USB_SPEED_3		= 3,
104 };
105 
106 #define IS_FULL_SPEED_USB(Adapter)	(adapter_to_dvobj(Adapter)->usb_speed == RTW_USB_SPEED_1_1)
107 #define IS_HIGH_SPEED_USB(Adapter)	(adapter_to_dvobj(Adapter)->usb_speed == RTW_USB_SPEED_2)
108 #define IS_SUPER_SPEED_USB(Adapter)	(adapter_to_dvobj(Adapter)->usb_speed == RTW_USB_SPEED_3)
109 
110 #define USB_SUPER_SPEED_BULK_SIZE	1024	/* usb 3.0 */
111 #define USB_HIGH_SPEED_BULK_SIZE	512		/* usb 2.0 */
112 #define USB_FULL_SPEED_BULK_SIZE	64		/* usb 1.1 */
113 
rtw_usb_bulk_size_boundary(_adapter * padapter,int buf_len)114 static inline u8 rtw_usb_bulk_size_boundary(_adapter *padapter, int buf_len)
115 {
116 	u8 rst = _TRUE;
117 
118 	if (IS_SUPER_SPEED_USB(padapter))
119 		rst = (0 == (buf_len) % USB_SUPER_SPEED_BULK_SIZE) ? _TRUE : _FALSE;
120 	else if (IS_HIGH_SPEED_USB(padapter))
121 		rst = (0 == (buf_len) % USB_HIGH_SPEED_BULK_SIZE) ? _TRUE : _FALSE;
122 	else
123 		rst = (0 == (buf_len) % USB_FULL_SPEED_BULK_SIZE) ? _TRUE : _FALSE;
124 	return rst;
125 }
126 
127 
128 #endif /* __USB_OPS_H_ */
129