FreeBSD/Linux Kernel Cross Reference
sys/dev/usb/usb_cdc.h
1 /* $NetBSD: usbcdc.h,v 1.9 2004/10/23 13:24:24 augustss Exp $ */
2 /* $FreeBSD$ */
3
4 /*-
5 * Copyright (c) 1998 The NetBSD Foundation, Inc.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Lennart Augustsson (lennart@augustsson.net) at
10 * Carlstedt Research & Technology.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. All advertising materials mentioning features or use of this software
21 * must display the following acknowledgement:
22 * This product includes software developed by the NetBSD
23 * Foundation, Inc. and its contributors.
24 * 4. Neither the name of The NetBSD Foundation nor the names of its
25 * contributors may be used to endorse or promote products derived
26 * from this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
29 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
32 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGE.
39 */
40
41 #ifndef _USB_CDC_H_
42 #define _USB_CDC_H_
43
44 #define UDESCSUB_CDC_HEADER 0
45 #define UDESCSUB_CDC_CM 1 /* Call Management */
46 #define UDESCSUB_CDC_ACM 2 /* Abstract Control Model */
47 #define UDESCSUB_CDC_DLM 3 /* Direct Line Management */
48 #define UDESCSUB_CDC_TRF 4 /* Telephone Ringer */
49 #define UDESCSUB_CDC_TCLSR 5 /* Telephone Call */
50 #define UDESCSUB_CDC_UNION 6
51 #define UDESCSUB_CDC_CS 7 /* Country Selection */
52 #define UDESCSUB_CDC_TOM 8 /* Telephone Operational Modes */
53 #define UDESCSUB_CDC_USBT 9 /* USB Terminal */
54 #define UDESCSUB_CDC_NCT 10
55 #define UDESCSUB_CDC_PUF 11
56 #define UDESCSUB_CDC_EUF 12
57 #define UDESCSUB_CDC_MCMF 13
58 #define UDESCSUB_CDC_CCMF 14
59 #define UDESCSUB_CDC_ENF 15
60 #define UDESCSUB_CDC_ANF 16
61
62 struct usb_cdc_header_descriptor {
63 uByte bLength;
64 uByte bDescriptorType;
65 uByte bDescriptorSubtype;
66 uWord bcdCDC;
67 } __packed;
68
69 struct usb_cdc_cm_descriptor {
70 uByte bLength;
71 uByte bDescriptorType;
72 uByte bDescriptorSubtype;
73 uByte bmCapabilities;
74 #define USB_CDC_CM_DOES_CM 0x01
75 #define USB_CDC_CM_OVER_DATA 0x02
76 uByte bDataInterface;
77 } __packed;
78
79 struct usb_cdc_acm_descriptor {
80 uByte bLength;
81 uByte bDescriptorType;
82 uByte bDescriptorSubtype;
83 uByte bmCapabilities;
84 #define USB_CDC_ACM_HAS_FEATURE 0x01
85 #define USB_CDC_ACM_HAS_LINE 0x02
86 #define USB_CDC_ACM_HAS_BREAK 0x04
87 #define USB_CDC_ACM_HAS_NETWORK_CONN 0x08
88 } __packed;
89
90 struct usb_cdc_union_descriptor {
91 uByte bLength;
92 uByte bDescriptorType;
93 uByte bDescriptorSubtype;
94 uByte bMasterInterface;
95 uByte bSlaveInterface[1];
96 } __packed;
97
98 struct usb_cdc_ethernet_descriptor {
99 uByte bLength;
100 uByte bDescriptorType;
101 uByte bDescriptorSubtype;
102 uByte iMacAddress;
103 uDWord bmEthernetStatistics;
104 uWord wMaxSegmentSize;
105 uWord wNumberMCFilters;
106 uByte bNumberPowerFilters;
107 } __packed;
108
109 #define UCDC_SEND_ENCAPSULATED_COMMAND 0x00
110 #define UCDC_GET_ENCAPSULATED_RESPONSE 0x01
111 #define UCDC_SET_COMM_FEATURE 0x02
112 #define UCDC_GET_COMM_FEATURE 0x03
113 #define UCDC_ABSTRACT_STATE 0x01
114 #define UCDC_COUNTRY_SETTING 0x02
115 #define UCDC_CLEAR_COMM_FEATURE 0x04
116 #define UCDC_SET_LINE_CODING 0x20
117 #define UCDC_GET_LINE_CODING 0x21
118 #define UCDC_SET_CONTROL_LINE_STATE 0x22
119 #define UCDC_LINE_DTR 0x0001
120 #define UCDC_LINE_RTS 0x0002
121 #define UCDC_SEND_BREAK 0x23
122 #define UCDC_BREAK_ON 0xffff
123 #define UCDC_BREAK_OFF 0x0000
124
125 struct usb_cdc_abstract_state {
126 uWord wState;
127 #define UCDC_IDLE_SETTING 0x0001
128 #define UCDC_DATA_MULTIPLEXED 0x0002
129 } __packed;
130
131 #define UCDC_ABSTRACT_STATE_LENGTH 2
132
133 struct usb_cdc_line_state {
134 uDWord dwDTERate;
135 uByte bCharFormat;
136 #define UCDC_STOP_BIT_1 0
137 #define UCDC_STOP_BIT_1_5 1
138 #define UCDC_STOP_BIT_2 2
139 uByte bParityType;
140 #define UCDC_PARITY_NONE 0
141 #define UCDC_PARITY_ODD 1
142 #define UCDC_PARITY_EVEN 2
143 #define UCDC_PARITY_MARK 3
144 #define UCDC_PARITY_SPACE 4
145 uByte bDataBits;
146 } __packed;
147
148 #define UCDC_LINE_STATE_LENGTH 7
149
150 struct usb_cdc_notification {
151 uByte bmRequestType;
152 #define UCDC_NOTIFICATION 0xa1
153 uByte bNotification;
154 #define UCDC_N_NETWORK_CONNECTION 0x00
155 #define UCDC_N_RESPONSE_AVAILABLE 0x01
156 #define UCDC_N_AUX_JACK_HOOK_STATE 0x08
157 #define UCDC_N_RING_DETECT 0x09
158 #define UCDC_N_SERIAL_STATE 0x20
159 #define UCDC_N_CALL_STATE_CHANGED 0x28
160 #define UCDC_N_LINE_STATE_CHANGED 0x29
161 #define UCDC_N_CONNECTION_SPEED_CHANGE 0x2a
162 uWord wValue;
163 uWord wIndex;
164 uWord wLength;
165 uByte data[16];
166 } __packed;
167
168 #define UCDC_NOTIFICATION_LENGTH 8
169
170 /*
171 * Bits set in the SERIAL STATE notifcation (first byte of data)
172 */
173
174 #define UCDC_N_SERIAL_OVERRUN 0x40
175 #define UCDC_N_SERIAL_PARITY 0x20
176 #define UCDC_N_SERIAL_FRAMING 0x10
177 #define UCDC_N_SERIAL_RI 0x08
178 #define UCDC_N_SERIAL_BREAK 0x04
179 #define UCDC_N_SERIAL_DSR 0x02
180 #define UCDC_N_SERIAL_DCD 0x01
181
182 /* Serial state bit masks */
183 #define UCDC_MDM_RXCARRIER 0x01
184 #define UCDC_MDM_TXCARRIER 0x02
185 #define UCDC_MDM_BREAK 0x04
186 #define UCDC_MDM_RING 0x08
187 #define UCDC_MDM_FRAMING_ERR 0x10
188 #define UCDC_MDM_PARITY_ERR 0x20
189 #define UCDC_MDM_OVERRUN_ERR 0x40
190
191 /*
192 * Network Control Model, NCM16 + NCM32, protocol definitions
193 */
194 struct usb_ncm16_hdr {
195 uDWord dwSignature;
196 uWord wHeaderLength;
197 uWord wSequence;
198 uWord wBlockLength;
199 uWord wDptIndex;
200 } __packed;
201
202 struct usb_ncm16_dp {
203 uWord wFrameIndex;
204 uWord wFrameLength;
205 } __packed;
206
207 struct usb_ncm16_dpt {
208 uDWord dwSignature;
209 uWord wLength;
210 uWord wNextNdpIndex;
211 struct usb_ncm16_dp dp[0];
212 } __packed;
213
214 struct usb_ncm32_hdr {
215 uDWord dwSignature;
216 uWord wHeaderLength;
217 uWord wSequence;
218 uDWord dwBlockLength;
219 uDWord dwDptIndex;
220 } __packed;
221
222 struct usb_ncm32_dp {
223 uDWord dwFrameIndex;
224 uDWord dwFrameLength;
225 } __packed;
226
227 struct usb_ncm32_dpt {
228 uDWord dwSignature;
229 uWord wLength;
230 uWord wReserved6;
231 uDWord dwNextNdpIndex;
232 uDWord dwReserved12;
233 struct usb_ncm32_dp dp[0];
234 } __packed;
235
236 /* Communications interface class specific descriptors */
237
238 #define UCDC_NCM_FUNC_DESC_SUBTYPE 0x1A
239
240 struct usb_ncm_func_descriptor {
241 uByte bLength;
242 uByte bDescriptorType;
243 uByte bDescriptorSubtype;
244 uByte bcdNcmVersion[2];
245 uByte bmNetworkCapabilities;
246 #define UCDC_NCM_CAP_FILTER 0x01
247 #define UCDC_NCM_CAP_MAC_ADDR 0x02
248 #define UCDC_NCM_CAP_ENCAP 0x04
249 #define UCDC_NCM_CAP_MAX_DATA 0x08
250 #define UCDC_NCM_CAP_CRCMODE 0x10
251 } __packed;
252
253 /* Communications interface specific class request codes */
254
255 #define UCDC_NCM_SET_ETHERNET_MULTICAST_FILTERS 0x40
256 #define UCDC_NCM_SET_ETHERNET_POWER_MGMT_PATTERN_FILTER 0x41
257 #define UCDC_NCM_GET_ETHERNET_POWER_MGMT_PATTERN_FILTER 0x42
258 #define UCDC_NCM_SET_ETHERNET_PACKET_FILTER 0x43
259 #define UCDC_NCM_GET_ETHERNET_STATISTIC 0x44
260 #define UCDC_NCM_GET_NTB_PARAMETERS 0x80
261 #define UCDC_NCM_GET_NET_ADDRESS 0x81
262 #define UCDC_NCM_SET_NET_ADDRESS 0x82
263 #define UCDC_NCM_GET_NTB_FORMAT 0x83
264 #define UCDC_NCM_SET_NTB_FORMAT 0x84
265 #define UCDC_NCM_GET_NTB_INPUT_SIZE 0x85
266 #define UCDC_NCM_SET_NTB_INPUT_SIZE 0x86
267 #define UCDC_NCM_GET_MAX_DATAGRAM_SIZE 0x87
268 #define UCDC_NCM_SET_MAX_DATAGRAM_SIZE 0x88
269 #define UCDC_NCM_GET_CRC_MODE 0x89
270 #define UCDC_NCM_SET_CRC_MODE 0x8A
271
272 struct usb_ncm_parameters {
273 uWord wLength;
274 uWord bmNtbFormatsSupported;
275 #define UCDC_NCM_FORMAT_NTB16 0x0001
276 #define UCDC_NCM_FORMAT_NTB32 0x0002
277 uDWord dwNtbInMaxSize;
278 uWord wNdpInDivisor;
279 uWord wNdpInPayloadRemainder;
280 uWord wNdpInAlignment;
281 uWord wReserved14;
282 uDWord dwNtbOutMaxSize;
283 uWord wNdpOutDivisor;
284 uWord wNdpOutPayloadRemainder;
285 uWord wNdpOutAlignment;
286 uWord wReserved26;
287 } __packed;
288
289 /* Communications interface specific class notification codes */
290 #define UCDC_NCM_NOTIF_NETWORK_CONNECTION 0x00
291 #define UCDC_NCM_NOTIF_RESPONSE_AVAILABLE 0x01
292 #define UCDC_NCM_NOTIF_CONNECTION_SPEED_CHANGE 0x2A
293
294 #endif /* _USB_CDC_H_ */
Cache object: f4c3237e2045452633c386952acf4e1d
|