• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 /*
3  * Copyright (C) 2007 Stefan Kopp, Gechingen, Germany
4  * Copyright (C) 2008 Novell, Inc.
5  * Copyright (C) 2008 Greg Kroah-Hartman <gregkh@suse.de>
6  * Copyright (C) 2015 Dave Penkler <dpenkler@gmail.com>
7  * Copyright (C) 2018 IVI Foundation, Inc.
8  *
9  * This file holds USB constants defined by the USB Device Class
10  * and USB488 Subclass Definitions for Test and Measurement devices
11  * published by the USB-IF.
12  *
13  * It also has the ioctl and capability definitions for the
14  * usbtmc kernel driver that userspace needs to know about.
15  */
16 
17 #ifndef __LINUX_USB_TMC_H
18 #define __LINUX_USB_TMC_H
19 
20 #include <linux/types.h>   /* __u8 etc */
21 
22 /* USB TMC status values */
23 #define USBTMC_STATUS_SUCCESS				0x01
24 #define USBTMC_STATUS_PENDING				0x02
25 #define USBTMC_STATUS_FAILED				0x80
26 #define USBTMC_STATUS_TRANSFER_NOT_IN_PROGRESS		0x81
27 #define USBTMC_STATUS_SPLIT_NOT_IN_PROGRESS		0x82
28 #define USBTMC_STATUS_SPLIT_IN_PROGRESS			0x83
29 
30 /* USB TMC requests values */
31 #define USBTMC_REQUEST_INITIATE_ABORT_BULK_OUT		1
32 #define USBTMC_REQUEST_CHECK_ABORT_BULK_OUT_STATUS	2
33 #define USBTMC_REQUEST_INITIATE_ABORT_BULK_IN		3
34 #define USBTMC_REQUEST_CHECK_ABORT_BULK_IN_STATUS	4
35 #define USBTMC_REQUEST_INITIATE_CLEAR			5
36 #define USBTMC_REQUEST_CHECK_CLEAR_STATUS		6
37 #define USBTMC_REQUEST_GET_CAPABILITIES			7
38 #define USBTMC_REQUEST_INDICATOR_PULSE			64
39 #define USBTMC488_REQUEST_READ_STATUS_BYTE		128
40 #define USBTMC488_REQUEST_REN_CONTROL			160
41 #define USBTMC488_REQUEST_GOTO_LOCAL			161
42 #define USBTMC488_REQUEST_LOCAL_LOCKOUT			162
43 
44 struct usbtmc_request {
45 	__u8 bRequestType;
46 	__u8 bRequest;
47 	__u16 wValue;
48 	__u16 wIndex;
49 	__u16 wLength;
50 } __attribute__ ((packed));
51 
52 struct usbtmc_ctrlrequest {
53 	struct usbtmc_request req;
54 	void __user *data; /* pointer to user space */
55 } __attribute__ ((packed));
56 
57 struct usbtmc_termchar {
58 	__u8 term_char;
59 	__u8 term_char_enabled;
60 } __attribute__ ((packed));
61 
62 /*
63  * usbtmc_message->flags:
64  */
65 #define USBTMC_FLAG_ASYNC		0x0001
66 #define USBTMC_FLAG_APPEND		0x0002
67 #define USBTMC_FLAG_IGNORE_TRAILER	0x0004
68 
69 struct usbtmc_message {
70 	__u32 transfer_size; /* size of bytes to transfer */
71 	__u32 transferred; /* size of received/written bytes */
72 	__u32 flags; /* bit 0: 0 = synchronous; 1 = asynchronous */
73 	void __user *message; /* pointer to header and data in user space */
74 } __attribute__ ((packed));
75 
76 /* Request values for USBTMC driver's ioctl entry point */
77 #define USBTMC_IOC_NR			91
78 #define USBTMC_IOCTL_INDICATOR_PULSE	_IO(USBTMC_IOC_NR, 1)
79 #define USBTMC_IOCTL_CLEAR		_IO(USBTMC_IOC_NR, 2)
80 #define USBTMC_IOCTL_ABORT_BULK_OUT	_IO(USBTMC_IOC_NR, 3)
81 #define USBTMC_IOCTL_ABORT_BULK_IN	_IO(USBTMC_IOC_NR, 4)
82 #define USBTMC_IOCTL_CLEAR_OUT_HALT	_IO(USBTMC_IOC_NR, 6)
83 #define USBTMC_IOCTL_CLEAR_IN_HALT	_IO(USBTMC_IOC_NR, 7)
84 #define USBTMC_IOCTL_CTRL_REQUEST	_IOWR(USBTMC_IOC_NR, 8, struct usbtmc_ctrlrequest)
85 #define USBTMC_IOCTL_GET_TIMEOUT	_IOR(USBTMC_IOC_NR, 9, __u32)
86 #define USBTMC_IOCTL_SET_TIMEOUT	_IOW(USBTMC_IOC_NR, 10, __u32)
87 #define USBTMC_IOCTL_EOM_ENABLE	        _IOW(USBTMC_IOC_NR, 11, __u8)
88 #define USBTMC_IOCTL_CONFIG_TERMCHAR	_IOW(USBTMC_IOC_NR, 12, struct usbtmc_termchar)
89 #define USBTMC_IOCTL_WRITE		_IOWR(USBTMC_IOC_NR, 13, struct usbtmc_message)
90 #define USBTMC_IOCTL_READ		_IOWR(USBTMC_IOC_NR, 14, struct usbtmc_message)
91 #define USBTMC_IOCTL_WRITE_RESULT	_IOWR(USBTMC_IOC_NR, 15, __u32)
92 #define USBTMC_IOCTL_API_VERSION	_IOR(USBTMC_IOC_NR, 16, __u32)
93 
94 #define USBTMC488_IOCTL_GET_CAPS	_IOR(USBTMC_IOC_NR, 17, unsigned char)
95 #define USBTMC488_IOCTL_READ_STB	_IOR(USBTMC_IOC_NR, 18, unsigned char)
96 #define USBTMC488_IOCTL_REN_CONTROL	_IOW(USBTMC_IOC_NR, 19, unsigned char)
97 #define USBTMC488_IOCTL_GOTO_LOCAL	_IO(USBTMC_IOC_NR, 20)
98 #define USBTMC488_IOCTL_LOCAL_LOCKOUT	_IO(USBTMC_IOC_NR, 21)
99 #define USBTMC488_IOCTL_TRIGGER		_IO(USBTMC_IOC_NR, 22)
100 #define USBTMC488_IOCTL_WAIT_SRQ	_IOW(USBTMC_IOC_NR, 23, __u32)
101 
102 #define USBTMC_IOCTL_MSG_IN_ATTR	_IOR(USBTMC_IOC_NR, 24, __u8)
103 #define USBTMC_IOCTL_AUTO_ABORT		_IOW(USBTMC_IOC_NR, 25, __u8)
104 
105 /* Cancel and cleanup asynchronous calls */
106 #define USBTMC_IOCTL_CANCEL_IO		_IO(USBTMC_IOC_NR, 35)
107 #define USBTMC_IOCTL_CLEANUP_IO		_IO(USBTMC_IOC_NR, 36)
108 
109 /* Driver encoded usb488 capabilities */
110 #define USBTMC488_CAPABILITY_TRIGGER         1
111 #define USBTMC488_CAPABILITY_SIMPLE          2
112 #define USBTMC488_CAPABILITY_REN_CONTROL     2
113 #define USBTMC488_CAPABILITY_GOTO_LOCAL      2
114 #define USBTMC488_CAPABILITY_LOCAL_LOCKOUT   2
115 #define USBTMC488_CAPABILITY_488_DOT_2       4
116 #define USBTMC488_CAPABILITY_DT1             16
117 #define USBTMC488_CAPABILITY_RL1             32
118 #define USBTMC488_CAPABILITY_SR1             64
119 #define USBTMC488_CAPABILITY_FULL_SCPI       128
120 
121 #endif
122