net: wireless: rockchip_wlan: add rtl8723cs support
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rtl8723cs / include / usb_ops_linux.h
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
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  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17  *
18  *
19  ******************************************************************************/
20 #ifndef __USB_OPS_LINUX_H__
21 #define __USB_OPS_LINUX_H__
22
23 #define VENDOR_CMD_MAX_DATA_LEN 254
24 #define FW_START_ADDRESS        0x1000
25
26 #define RTW_USB_CONTROL_MSG_TIMEOUT_TEST        10/* ms */
27 #define RTW_USB_CONTROL_MSG_TIMEOUT     500/* ms */
28
29 #define RECV_BULK_IN_ADDR               0x80/* assign by drv, not real address */
30 #define RECV_INT_IN_ADDR                0x81/* assign by drv, not real address */
31
32 #define INTERRUPT_MSG_FORMAT_LEN 60
33
34 #if defined(CONFIG_VENDOR_REQ_RETRY) && defined(CONFIG_USB_VENDOR_REQ_MUTEX)
35         /* vendor req retry should be in the situation when each vendor req is atomically submitted from others */
36         #define MAX_USBCTRL_VENDORREQ_TIMES     10
37 #else
38         #define MAX_USBCTRL_VENDORREQ_TIMES     1
39 #endif
40
41 #define RTW_USB_BULKOUT_TIMEOUT 5000/* ms */
42
43 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)) || (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 18))
44 #define _usbctrl_vendorreq_async_callback(urb, regs)    _usbctrl_vendorreq_async_callback(urb)
45 #define usb_bulkout_zero_complete(purb, regs)   usb_bulkout_zero_complete(purb)
46 #define usb_write_mem_complete(purb, regs)      usb_write_mem_complete(purb)
47 #define usb_write_port_complete(purb, regs)     usb_write_port_complete(purb)
48 #define usb_read_port_complete(purb, regs)      usb_read_port_complete(purb)
49 #define usb_read_interrupt_complete(purb, regs) usb_read_interrupt_complete(purb)
50 #endif
51
52 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 12))
53 #define rtw_usb_control_msg(dev, pipe, request, requesttype, value, index, data, size, timeout_ms) \
54         usb_control_msg((dev), (pipe), (request), (requesttype), (value), (index), (data), (size), (timeout_ms))
55 #define rtw_usb_bulk_msg(usb_dev, pipe, data, len, actual_length, timeout_ms) \
56         usb_bulk_msg((usb_dev), (pipe), (data), (len), (actual_length), (timeout_ms))
57 #else
58 #define rtw_usb_control_msg(dev, pipe, request, requesttype, value, index, data, size, timeout_ms) \
59         usb_control_msg((dev), (pipe), (request), (requesttype), (value), (index), (data), (size), \
60                 ((timeout_ms) == 0) || ((timeout_ms) * HZ / 1000 > 0) ? ((timeout_ms) * HZ / 1000) : 1)
61 #define rtw_usb_bulk_msg(usb_dev, pipe, data, len, actual_length, timeout_ms) \
62         usb_bulk_msg((usb_dev), (pipe), (data), (len), (actual_length), \
63                 ((timeout_ms) == 0) || ((timeout_ms) * HZ / 1000 > 0) ? ((timeout_ms) * HZ / 1000) : 1)
64 #endif
65
66
67 #ifdef CONFIG_USB_SUPPORT_ASYNC_VDN_REQ
68 int usb_async_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val);
69 int usb_async_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val);
70 int usb_async_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val);
71 #endif /* CONFIG_USB_SUPPORT_ASYNC_VDN_REQ */
72
73 unsigned int ffaddr2pipehdl(struct dvobj_priv *pdvobj, u32 addr);
74
75 void usb_read_mem(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem);
76 void usb_write_mem(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem);
77
78 void usb_read_port_cancel(struct intf_hdl *pintfhdl);
79
80 u32 usb_write_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem);
81 void usb_write_port_cancel(struct intf_hdl *pintfhdl);
82
83 int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u8 request, u16 value, u16 index, void *pdata, u16 len, u8 requesttype);
84 #ifdef CONFIG_USB_SUPPORT_ASYNC_VDN_REQ
85 int _usbctrl_vendorreq_async_write(struct usb_device *udev, u8 request,
86                 u16 value, u16 index, void *pdata, u16 len, u8 requesttype);
87 #endif /* CONFIG_USB_SUPPORT_ASYNC_VDN_REQ */
88
89 u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr);
90 u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr);
91 u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr);
92 int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val);
93 int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val);
94 int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val);
95 int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata);
96 u32 usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem);
97 void usb_recv_tasklet(void *priv);
98
99 #ifdef CONFIG_USB_INTERRUPT_IN_PIPE
100 void usb_read_interrupt_complete(struct urb *purb, struct pt_regs *regs);
101 u32 usb_read_interrupt(struct intf_hdl *pintfhdl, u32 addr);
102 #endif
103 #endif