1 /* SPDX-License-Identifier: GPL-2.0 */
2 
3 /***************************************************************************
4  *    copyright            : (C) 2002 by Frank Mori Hess
5  ***************************************************************************/
6 
7 #ifndef _GPIB_IOCTL_H
8 #define _GPIB_IOCTL_H
9 
10 #include <asm/ioctl.h>
11 #include <linux/types.h>
12 
13 #define GPIB_CODE 160
14 
15 typedef struct {
16 	char name[100];
17 } board_type_ioctl_t;
18 
19 /* argument for read/write/command ioctls */
20 typedef struct {
21 	uint64_t buffer_ptr;
22 	unsigned int requested_transfer_count;
23 	unsigned int completed_transfer_count;
24 	int end; /* end flag return for reads, end io suppression request for cmd*/
25 	int handle;
26 } read_write_ioctl_t;
27 
28 typedef struct {
29 	unsigned int handle;
30 	unsigned int pad;
31 	int sad;
32 	unsigned is_board : 1;
33 } open_dev_ioctl_t;
34 
35 typedef struct {
36 	unsigned int handle;
37 } close_dev_ioctl_t;
38 
39 typedef struct {
40 	unsigned int pad;
41 	int sad;
42 	uint8_t status_byte;
43 } serial_poll_ioctl_t;
44 
45 typedef struct {
46 	int eos;
47 	int eos_flags;
48 } eos_ioctl_t;
49 
50 typedef struct {
51 	int handle;
52 	int wait_mask;
53 	int clear_mask;
54 	int set_mask;
55 	int ibsta;
56 	int pad;
57 	int sad;
58 	unsigned int usec_timeout;
59 } wait_ioctl_t;
60 
61 typedef struct {
62 	uint64_t init_data_ptr;
63 	int init_data_length;
64 	int online;
65 } online_ioctl_t;
66 
67 typedef struct {
68 	unsigned int num_bytes;
69 	unsigned int pad;
70 	int sad;
71 } spoll_bytes_ioctl_t;
72 
73 typedef struct {
74 	unsigned int pad;
75 	int sad;
76 	int parallel_poll_configuration;
77 	int autopolling;
78 	int is_system_controller;
79 	unsigned int t1_delay;
80 	unsigned ist : 1;
81 	unsigned no_7_bit_eos : 1;
82 } board_info_ioctl_t;
83 
84 typedef struct {
85 	int pci_bus;
86 	int pci_slot;
87 } select_pci_ioctl_t;
88 
89 typedef struct {
90 	uint8_t config;
91 	unsigned set_ist : 1;
92 	unsigned clear_ist : 1;
93 }	ppoll_config_ioctl_t;
94 
95 typedef struct {
96 	unsigned int handle;
97 	unsigned int pad;
98 } pad_ioctl_t;
99 
100 typedef struct {
101 	unsigned int handle;
102 	int sad;
103 } sad_ioctl_t;
104 
105 // select a piece of hardware to attach by its sysfs device path
106 typedef struct {
107 	char device_path[0x1000];
108 } select_device_path_ioctl_t;
109 
110 typedef short event_ioctl_t;
111 typedef int rsc_ioctl_t;
112 typedef unsigned int t1_delay_ioctl_t;
113 typedef short autospoll_ioctl_t;
114 typedef short local_ppoll_mode_ioctl_t;
115 
116 // update status byte and request service
117 typedef struct {
118 	uint8_t status_byte;
119 	int new_reason_for_service;
120 } request_service2_t;
121 
122 /* Standard functions. */
123 enum gpib_ioctl {
124 	IBRD = _IOWR(GPIB_CODE, 100, read_write_ioctl_t),
125 	IBWRT = _IOWR(GPIB_CODE, 101, read_write_ioctl_t),
126 	IBCMD = _IOWR(GPIB_CODE, 102, read_write_ioctl_t),
127 	IBOPENDEV = _IOWR(GPIB_CODE, 3, open_dev_ioctl_t),
128 	IBCLOSEDEV = _IOW(GPIB_CODE, 4, close_dev_ioctl_t),
129 	IBWAIT = _IOWR(GPIB_CODE, 5, wait_ioctl_t),
130 	IBRPP = _IOWR(GPIB_CODE, 6, uint8_t),
131 
132 	IBSIC = _IOW(GPIB_CODE, 9, unsigned int),
133 	IBSRE = _IOW(GPIB_CODE, 10, int),
134 	IBGTS = _IO(GPIB_CODE, 11),
135 	IBCAC = _IOW(GPIB_CODE, 12, int),
136 	IBLINES = _IOR(GPIB_CODE, 14, short),
137 	IBPAD = _IOW(GPIB_CODE, 15, pad_ioctl_t),
138 	IBSAD = _IOW(GPIB_CODE, 16, sad_ioctl_t),
139 	IBTMO = _IOW(GPIB_CODE, 17, unsigned int),
140 	IBRSP = _IOWR(GPIB_CODE, 18, serial_poll_ioctl_t),
141 	IBEOS = _IOW(GPIB_CODE, 19, eos_ioctl_t),
142 	IBRSV = _IOW(GPIB_CODE, 20, uint8_t),
143 	CFCBASE = _IOW(GPIB_CODE, 21, uint64_t),
144 	CFCIRQ = _IOW(GPIB_CODE, 22, unsigned int),
145 	CFCDMA = _IOW(GPIB_CODE, 23, unsigned int),
146 	CFCBOARDTYPE = _IOW(GPIB_CODE, 24, board_type_ioctl_t),
147 
148 	IBMUTEX = _IOW(GPIB_CODE, 26, int),
149 	IBSPOLL_BYTES = _IOWR(GPIB_CODE, 27, spoll_bytes_ioctl_t),
150 	IBPPC = _IOW(GPIB_CODE, 28, ppoll_config_ioctl_t),
151 	IBBOARD_INFO = _IOR(GPIB_CODE, 29, board_info_ioctl_t),
152 
153 	IBQUERY_BOARD_RSV = _IOR(GPIB_CODE, 31, int),
154 	IBSELECT_PCI = _IOWR(GPIB_CODE, 32, select_pci_ioctl_t),
155 	IBEVENT = _IOR(GPIB_CODE, 33, event_ioctl_t),
156 	IBRSC = _IOW(GPIB_CODE, 34, rsc_ioctl_t),
157 	IB_T1_DELAY = _IOW(GPIB_CODE, 35, t1_delay_ioctl_t),
158 	IBLOC = _IO(GPIB_CODE, 36),
159 
160 	IBAUTOSPOLL = _IOW(GPIB_CODE, 38, autospoll_ioctl_t),
161 	IBONL = _IOW(GPIB_CODE, 39, online_ioctl_t),
162 	IBPP2_SET = _IOW(GPIB_CODE, 40, local_ppoll_mode_ioctl_t),
163 	IBPP2_GET = _IOR(GPIB_CODE, 41, local_ppoll_mode_ioctl_t),
164 	IBSELECT_DEVICE_PATH = _IOW(GPIB_CODE, 43, select_device_path_ioctl_t),
165 	// 44 was IBSELECT_SERIAL_NUMBER
166 	IBRSV2 = _IOW(GPIB_CODE, 45, request_service2_t)
167 };
168 
169 #endif	/* _GPIB_IOCTL_H */
170