-
Notifications
You must be signed in to change notification settings - Fork 7
/
exar.h
248 lines (218 loc) · 7.25 KB
/
exar.h
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that 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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <linux/ioctl.h>
#define XR_USB_SERIAL_IOC_MAGIC 'v'
#define XR_USB_SERIAL_GET_REG _IOWR(XR_USB_SERIAL_IOC_MAGIC, 1, int)
#define XR_USB_SERIAL_SET_REG _IOWR(XR_USB_SERIAL_IOC_MAGIC, 2, int)
#define XR_USB_SERIAL_SET_ADDRESS_MATCH _IO(XR_USB_SERIAL_IOC_MAGIC, 3)
#define XR_USB_SERIAL_SET_PRECISE_FLAGS _IO(XR_USB_SERIAL_IOC_MAGIC, 4)
#define XR_USB_SERIAL_TEST_MODE _IO(XR_USB_SERIAL_IOC_MAGIC, 5)
#define XR_USB_SERIAL_LOOPBACK _IO(XR_USB_SERIAL_IOC_MAGIC, 6)
#define XR_USB_SERIAL_SET_GPIO_MODE_REG _IO(XR_USB_SERIAL_IOC_MAGIC, 9)
#define XR_USB_SERIAL_GET_GPIO_MODE_REG _IO(XR_USB_SERIAL_IOC_MAGIC, 10)
#define XRIOC_SET_ANY_BAUD_RATE _IO(XR_USB_SERIAL_IOC_MAGIC, 11)
#define VZ_ADDRESS_UNICAST_S 0
#define VZ_ADDRESS_BROADCAST_S 8
#define VZ_ADDRESS_MATCH(U, B) (0x8000000 | \
((B) << VZ_ADDRESS_BROADCAST_S) | \
((U) << VZ_ADDRESS_UNICAST_S))
#define VZ_ADDRESS_MATCH_DISABLE 0
/*
* CMSPAR, some architectures can't have space and mark parity.
*/
#ifndef CMSPAR
#define CMSPAR 0
#endif
/*
* Major and minor numbers.
*/
#define XR_USB_SERIAL_TTY_MAJOR 266
#define XR_USB_SERIAL_TTY_MINORS 32
/*
* Requests.
*/
#define USB_RT_XR_USB_SERIAL (USB_TYPE_CLASS | USB_RECIP_INTERFACE)
/*
* Output control lines.
*/
#define XR_USB_SERIAL_CTRL_DTR 0x01
#define XR_USB_SERIAL_CTRL_RTS 0x02
/*
* Input control lines and line errors.
*/
#define XR_USB_SERIAL_CTRL_DCD 0x01
#define XR_USB_SERIAL_CTRL_DSR 0x02
#define XR_USB_SERIAL_CTRL_BRK 0x04
#define XR_USB_SERIAL_CTRL_RI 0x08
#define XR_USB_SERIAL_CTRL_FRAMING 0x10
#define XR_USB_SERIAL_CTRL_PARITY 0x20
#define XR_USB_SERIAL_CTRL_OVERRUN 0x40
/*
* Internal driver structures.
*/
/*
* The only reason to have several buffers is to accommodate assumptions
* in line disciplines. They ask for empty space amount, receive our URB size,
* and proceed to issue several 1-character writes, assuming they will fit.
* The very first write takes a complete URB. Fortunately, this only happens
* when processing onlcr, so we only need 2 buffers. These values must be
* powers of 2.
*/
#define XR_USB_SERIAL_NW 16
#define XR_USB_SERIAL_NR 16
struct xr_usb_serial_wb {
unsigned char *buf;
dma_addr_t dmah;
int len;
int use;
struct urb *urb;
struct xr_usb_serial *instance;
};
struct xr_usb_serial_rb {
int size;
unsigned char *base;
dma_addr_t dma;
int index;
struct xr_usb_serial *instance;
};
struct reg_addr_map {
unsigned int uart_enable_addr;
unsigned int uart_format_addr;
unsigned int uart_flow_addr;
unsigned int uart_loopback_addr;
unsigned int uart_xon_char_addr;
unsigned int uart_xoff_char_addr;
unsigned int uart_gpio_mode_addr;
unsigned int uart_gpio_dir_addr;
unsigned int uart_gpio_set_addr;
unsigned int uart_gpio_clr_addr;
unsigned int uart_gpio_status_addr;
unsigned int tx_break_addr;
unsigned int uart_custom_driver;
unsigned int uart_low_latency;
};
/**
* xr_usb_serial - structure used by the xr-usb-serial core for a device
* @dev: the correctioding usb device
* @control: control interface
* @data: data interface
* @port: our TTY port data
* @ctrlurb: URBs
* @ctrl_buffer: buffers of URBs
* @ctrl_dma: DMA handles of buffers
* @country_codes: country codes from device
* @country_code_size: size of the country code buffer
* @country_rel_date: release date of version
* @wb:
* @read_urbs_free:
* @read_urbs:
* @read_buffers:
* @rx_buflimit:
* @rx_endpoint:
* @read_lock:
* @write_used: number of non-empty write buffers
* @transmitting:
* @write_lock:
* @mutex:
* @disconnected:
* @line: bits, stop, parity
* @work: work queue entry for line discipline waking up
* @ctrlin: input control lines (DCD, DSR, RI, break, overruns)
* @ctrlout: output control lines (DTR, RTS)
* @writesize: max packet size for the output bulk endpoint
* @readsize, ctrlsize: buffer sizes for freeing
* @minor: xr_usb_serial minot number
* @clocal: termios CLOCAL
* @ctrl_caps: control capabilities from the class specific header
* @susp_count: number of suspended interfaces
* @combined_interfaces: control and data collapsed
* @is_int_ep: interrupt endpoints contrary to spec used
* @throttled: actually throttled
* @throttle_req: throttle requested
* @bInterval:
* @delayed_wb: write queue for a device about to be woken
* @channel:
* @DeviceVendor:
* @DeviceProduct:
* @reg_map:
*/
struct xr_usb_serial {
struct usb_device *dev;
struct usb_interface *control;
struct usb_interface *data;
struct tty_port port;
struct urb *ctrlurb;
u8 *ctrl_buffer;
dma_addr_t ctrl_dma;
u8 *country_codes;
unsigned int country_code_size;
unsigned int country_rel_date;
struct xr_usb_serial_wb wb[XR_USB_SERIAL_NW];
unsigned long read_urbs_free;
struct urb *read_urbs[XR_USB_SERIAL_NR];
struct xr_usb_serial_rb read_buffers[XR_USB_SERIAL_NR];
int rx_buflimit;
int rx_endpoint;
spinlock_t read_lock;
int write_used;
int transmitting;
spinlock_t write_lock;
struct mutex mutex;
bool disconnected;
struct usb_cdc_line_coding line;
struct work_struct work;
unsigned int ctrlin;
unsigned int ctrlout;
unsigned int writesize;
unsigned int readsize, ctrlsize;
unsigned int minor;
unsigned char clocal;
unsigned int ctrl_caps;
unsigned int susp_count;
unsigned int combined_interfaces : 1;
unsigned int is_int_ep : 1;
unsigned int throttled : 1;
unsigned int throttle_req : 1;
u8 bInterval;
struct xr_usb_serial_wb *delayed_wb;
unsigned int channel;
unsigned short DeviceVendor;
unsigned short DeviceProduct;
struct reg_addr_map reg_map;
};
#define CDC_DATA_INTERFACE_TYPE 0x0a
/* constants describing various quirks and errors */
#define NO_UNION_NORMAL 1
#define SINGLE_RX_URB 2
#define NO_CAP_LINE 4
#define NOT_A_MODEM 8
#define NO_DATA_INTERFACE 16
#define IGNORE_DEVICE 32
#define UART_ENABLE_TX 1
#define UART_ENABLE_RX 2
#define UART_GPIO_CLR_DTR 0x8
#define UART_GPIO_SET_DTR 0x8
#define UART_GPIO_CLR_RTS 0x20
#define UART_GPIO_SET_RTS 0x20
#define LOOPBACK_ENABLE_TX_RX 1
#define LOOPBACK_ENABLE_RTS_CTS 2
#define LOOPBACK_ENABLE_DTR_DSR 4
#define UART_FLOW_MODE_NONE 0x0
#define UART_FLOW_MODE_HW 0x1
#define UART_FLOW_MODE_SW 0x2
#define UART_GPIO_MODE_SEL_GPIO 0x0
#define UART_GPIO_MODE_SEL_RTS_CTS 0x1
#define XR2280x_FUNC_MGR_OFFSET 0x40