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
25#define RTW_USB_CONTROL_MSG_TIMEOUT_TEST	10/* ms */
26#define RTW_USB_CONTROL_MSG_TIMEOUT	500/* ms */
27
28#define MAX_USBCTRL_VENDORREQ_TIMES	10
29
30#define RTW_USB_BULKOUT_TIME	5000/* ms */
31
32#define REALTEK_USB_VENQT_READ		0xC0
33#define REALTEK_USB_VENQT_WRITE		0x40
34
35#define ALIGNMENT_UNIT			16
36#define MAX_VENDOR_REQ_CMD_SIZE	254	/* 8188cu SIE Support */
37#define MAX_USB_IO_CTL_SIZE	(MAX_VENDOR_REQ_CMD_SIZE + ALIGNMENT_UNIT)
38
39#define USB_HIGH_SPEED_BULK_SIZE	512
40#define USB_FULL_SPEED_BULK_SIZE	64
41
42#define _usbctrl_vendorreq_async_callback(urb, regs)	\
43	_usbctrl_vendorreq_async_callback(urb)
44#define usb_bulkout_zero_complete(purb, regs)		\
45	usb_bulkout_zero_complete(purb)
46#define usb_write_mem_complete(purb, regs)		\
47	usb_write_mem_complete(purb)
48#define usb_write_port_complete(purb, regs)		\
49	usb_write_port_complete(purb)
50#define usb_read_port_complete(purb, regs)		\
51	usb_read_port_complete(purb)
52#define usb_read_interrupt_complete(purb, regs)		\
53	usb_read_interrupt_complete(purb)
54
55static inline u8 rtw_usb_bulk_size_boundary(struct adapter *padapter,
56					    int buf_len)
57{
58	u8 rst = true;
59	struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter);
60
61	if (pdvobjpriv->ishighspeed)
62		rst = (0 == (buf_len) % USB_HIGH_SPEED_BULK_SIZE) ?
63		      true : false;
64	else
65		rst = (0 == (buf_len) % USB_FULL_SPEED_BULK_SIZE) ?
66		      true : false;
67	return rst;
68}
69
70unsigned int ffaddr2pipehdl(struct dvobj_priv *pdvobj, u32 addr);
71
72u8 usb_read8(struct adapter *adapter, u32 addr);
73u16 usb_read16(struct adapter *adapter, u32 addr);
74u32 usb_read32(struct adapter *adapter, u32 addr);
75
76u32 usb_read_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
77void usb_read_port_cancel(struct adapter *adapter);
78
79int usb_write8(struct adapter *adapter, u32 addr, u8 val);
80int usb_write16(struct adapter *adapter, u32 addr, u16 val);
81int usb_write32(struct adapter *adapter, u32 addr, u32 val);
82int usb_writeN(struct adapter *adapter, u32 addr, u32 length, u8 *pdata);
83
84u32 usb_write_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
85void usb_write_port_cancel(struct adapter *adapter);
86
87#endif
88