summaryrefslogtreecommitdiff
path: root/drivers/usb/class/nv-usb.h
blob: 83922cc583e8d51a3e9bfe19cac583d6815abac2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
 * Copyright (c) 2012, NVIDIA CORPORATION.  All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef __LINUX_USB_NV_USB_BULK_H
#define  __LINUX_USB_NV_USB_BULK_H


#define NVUSB_BULK_WRITE	0X2000
#define NVUSB_BULK_READ	0X2001

/* command block wrapper */
struct nvusb_cb_wrap {
	__le32	Signature;
	__u32	Tag;
	__le32	DataTransferLength;
	__u8	Flags;
	__u8	Length;
	__u8	CDB[16];
};

#define US_BULK_CB_WRAP_LEN	31
#define US_BULK_CB_SIGN		0x43425355
#define US_BULK_FLAG_IN		(1 << 7)
#define US_BULK_FLAG_OUT	0

/* command status wrapper */
struct nvusb_cs_wrap {
	__le32	Signature;
	__u32	Tag;
	__le32	Residue;
	__u8	Status;
};

#define US_BULK_CS_WRAP_LEN	13
#define US_BULK_CS_SIGN		0x53425355
#define US_BULK_STAT_OK		0
#define US_BULK_STAT_FAIL	1
#define US_BULK_STAT_BAD_DATA	2

struct bulk_data {
	struct nv_usb *dev;
	__u8 data_direction;
	__u8 sub_cmd_length;
	__u8 *sub_cmd;
	__u32 length;
	__u8 *buf;
	__u8 write_char;
	__u32 data_transfer_time;
	__u32  g_data_transfer_time;
};

struct user_bulk_data {
	__u8 sub_cmd_length;
	__u8 __user *sub_cmd;
	__u32 length;
	__u8 __user *buf;
	__u8 write_char;
	__u32  data_transfer_time;
	__u32  g_data_transfer_time;

};


/* Structure to hold all of our device specific stuff */
struct nv_usb {
	/* the usb device for this device */
	struct usb_device	*udev;
	/* the interface for this device */
	struct usb_interface	*interface;
	/* in case we need to retract our submissions */
	struct usb_anchor	submitted;
	/* the size of the receive buffer */
	size_t			bulk_in_size;
	/* the address of the bulk in endpoint */
	__u8			bulk_in_endpointAddr;
	/* the address of the bulk out endpoint */
	__u8			bulk_out_endpointAddr;
	__u32			tag;
	struct kref		kref;
	struct mutex		mutex;
};
#define to_nv_usb_dev(d) container_of(d, struct nv_usb, kref)

#endif