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