Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/drivers/gpib/agilent_82357a/agilent_82357a.h
38184 views
1
/* SPDX-License-Identifier: GPL-2.0 */
2
3
/***************************************************************************
4
* copyright : (C) 2004 by Frank Mori Hess *
5
***************************************************************************/
6
7
#include <linux/kernel.h>
8
#include <linux/mutex.h>
9
#include <linux/completion.h>
10
#include <linux/usb.h>
11
#include <linux/timer.h>
12
#include <linux/compiler_attributes.h>
13
#include "gpibP.h"
14
#include "tms9914.h"
15
16
enum usb_vendor_ids {
17
USB_VENDOR_ID_AGILENT = 0x0957
18
};
19
20
enum usb_device_ids {
21
USB_DEVICE_ID_AGILENT_82357A = 0x0107,
22
USB_DEVICE_ID_AGILENT_82357A_PREINIT = 0x0007, // device id before firmware is loaded
23
USB_DEVICE_ID_AGILENT_82357B = 0x0718, // device id before firmware is loaded
24
USB_DEVICE_ID_AGILENT_82357B_PREINIT = 0x0518, // device id before firmware is loaded
25
};
26
27
enum endpoint_addresses {
28
AGILENT_82357_CONTROL_ENDPOINT = 0x0,
29
AGILENT_82357_BULK_IN_ENDPOINT = 0x2,
30
AGILENT_82357A_BULK_OUT_ENDPOINT = 0x4,
31
AGILENT_82357A_INTERRUPT_IN_ENDPOINT = 0x6,
32
AGILENT_82357B_BULK_OUT_ENDPOINT = 0x6,
33
AGILENT_82357B_INTERRUPT_IN_ENDPOINT = 0x8,
34
};
35
36
enum bulk_commands {
37
DATA_PIPE_CMD_WRITE = 0x1,
38
DATA_PIPE_CMD_READ = 0x3,
39
DATA_PIPE_CMD_WR_REGS = 0x4,
40
DATA_PIPE_CMD_RD_REGS = 0x5
41
};
42
43
enum agilent_82357a_read_flags {
44
ARF_END_ON_EOI = 0x1,
45
ARF_NO_ADDRESS = 0x2,
46
ARF_END_ON_EOS_CHAR = 0x4,
47
ARF_SPOLL = 0x8
48
};
49
50
enum agilent_82357a_trailing_read_flags {
51
ATRF_EOI = 0x1,
52
ATRF_ATN = 0x2,
53
ATRF_IFC = 0x4,
54
ATRF_EOS = 0x8,
55
ATRF_ABORT = 0x10,
56
ATRF_COUNT = 0x20,
57
ATRF_DEAD_BUS = 0x40,
58
ATRF_UNADDRESSED = 0x80
59
};
60
61
enum agilent_82357a_write_flags {
62
AWF_SEND_EOI = 0x1,
63
AWF_NO_FAST_TALKER_FIRST_BYTE = 0x2,
64
AWF_NO_FAST_TALKER = 0x4,
65
AWF_NO_ADDRESS = 0x8,
66
AWF_ATN = 0x10,
67
AWF_SEPARATE_HEADER = 0x80
68
};
69
70
enum agilent_82357a_interrupt_flag_bit_numbers {
71
AIF_SRQ_BN = 0,
72
AIF_WRITE_COMPLETE_BN = 1,
73
AIF_READ_COMPLETE_BN = 2,
74
};
75
76
enum agilent_82357_error_codes {
77
UGP_SUCCESS = 0,
78
UGP_ERR_INVALID_CMD = 1,
79
UGP_ERR_INVALID_PARAM = 2,
80
UGP_ERR_INVALID_REG = 3,
81
UGP_ERR_GPIB_READ = 4,
82
UGP_ERR_GPIB_WRITE = 5,
83
UGP_ERR_FLUSHING = 6,
84
UGP_ERR_FLUSHING_ALREADY = 7,
85
UGP_ERR_UNSUPPORTED = 8,
86
UGP_ERR_OTHER = 9
87
};
88
89
enum agilent_82357_control_values {
90
XFER_ABORT = 0xa0,
91
XFER_STATUS = 0xb0,
92
};
93
94
enum xfer_status_bits {
95
XS_COMPLETED = 0x1,
96
XS_READ = 0x2,
97
};
98
99
enum xfer_status_completion_bits {
100
XSC_EOI = 0x1,
101
XSC_ATN = 0x2,
102
XSC_IFC = 0x4,
103
XSC_EOS = 0x8,
104
XSC_ABORT = 0x10,
105
XSC_COUNT = 0x20,
106
XSC_DEAD_BUS = 0x40,
107
XSC_BUS_NOT_ADDRESSED = 0x80
108
};
109
110
enum xfer_abort_type {
111
XA_FLUSH = 0x1
112
};
113
114
#define STATUS_DATA_LEN 8
115
#define INTERRUPT_BUF_LEN 8
116
117
struct agilent_82357a_urb_ctx {
118
struct completion complete;
119
unsigned timed_out : 1;
120
};
121
122
// struct which defines local data for each 82357 device
123
struct agilent_82357a_priv {
124
struct usb_interface *bus_interface;
125
unsigned short eos_char;
126
unsigned short eos_mode;
127
unsigned short hw_control_bits;
128
unsigned long interrupt_flags;
129
struct urb *bulk_urb;
130
struct urb *interrupt_urb;
131
u8 *interrupt_buffer;
132
struct mutex bulk_transfer_lock; // bulk transfer lock
133
struct mutex bulk_alloc_lock; // bulk transfer allocation lock
134
struct mutex interrupt_alloc_lock; // interrupt allocation lock
135
struct mutex control_alloc_lock; // control message allocation lock
136
struct timer_list bulk_timer;
137
struct agilent_82357a_urb_ctx context;
138
unsigned int bulk_out_endpoint;
139
unsigned int interrupt_in_endpoint;
140
unsigned is_cic : 1;
141
unsigned ren_state : 1;
142
};
143
144
struct agilent_82357a_register_pairlet {
145
short address;
146
unsigned short value;
147
};
148
149
enum firmware_registers {
150
HW_CONTROL = 0xa,
151
LED_CONTROL = 0xb,
152
RESET_TO_POWERUP = 0xc,
153
PROTOCOL_CONTROL = 0xd,
154
FAST_TALKER_T1 = 0xe
155
};
156
157
enum hardware_control_bits {
158
NOT_TI_RESET = 0x1,
159
SYSTEM_CONTROLLER = 0x2,
160
NOT_PARALLEL_POLL = 0x4,
161
OSCILLATOR_5V_ON = 0x8,
162
OUTPUT_5V_ON = 0x20,
163
CPLD_3V_ON = 0x80,
164
};
165
166
enum led_control_bits {
167
FIRMWARE_LED_CONTROL = 0x1,
168
FAIL_LED_ON = 0x20,
169
READY_LED_ON = 0x40,
170
ACCESS_LED_ON = 0x80
171
};
172
173
enum reset_to_powerup_bits {
174
RESET_SPACEBALL = 0x1, // wait 2 millisec after sending
175
};
176
177
enum protocol_control_bits {
178
WRITE_COMPLETE_INTERRUPT_EN = 0x1,
179
};
180
181
static const int agilent_82357a_control_request = 0x4;
182
183
184