Merge branch 'vendor/OPENSSL'
[dragonfly.git] / sys / bus / usb / usbcdc.h
1 /*
2  * $NetBSD: usbcdc.h,v 1.6 2000/04/27 15:26:50 augustss Exp $
3  * $FreeBSD: src/sys/dev/usb/usbcdc.h,v 1.10 2003/01/09 04:24:28 imp Exp $
4  */
5
6 /*
7  * Copyright (c) 1998 The NetBSD Foundation, Inc.
8  * All rights reserved.
9  *
10  * This code is derived from software contributed to The NetBSD Foundation
11  * by Lennart Augustsson (lennart@augustsson.net) at
12  * Carlstedt Research & Technology.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions
16  * are met:
17  * 1. Redistributions of source code must retain the above copyright
18  *    notice, this list of conditions and the following disclaimer.
19  * 2. Redistributions in binary form must reproduce the above copyright
20  *    notice, this list of conditions and the following disclaimer in the
21  *    documentation and/or other materials provided with the distribution.
22  * 3. All advertising materials mentioning features or use of this software
23  *    must display the following acknowledgement:
24  *        This product includes software developed by the NetBSD
25  *        Foundation, Inc. and its contributors.
26  * 4. Neither the name of The NetBSD Foundation nor the names of its
27  *    contributors may be used to endorse or promote products derived
28  *    from this software without specific prior written permission.
29  *
30  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
31  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
32  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
33  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
34  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
35  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
36  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
37  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
38  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
39  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
40  * POSSIBILITY OF SUCH DAMAGE.
41  */
42
43 #ifndef _USBCDC_H_
44 #define _USBCDC_H_
45
46 #define UDESCSUB_CDC_HEADER     0
47 #define UDESCSUB_CDC_CM         1 /* Call Management */
48 #define UDESCSUB_CDC_ACM        2 /* Abstract Control Model */
49 #define UDESCSUB_CDC_DLM        3 /* Direct Line Management */
50 #define UDESCSUB_CDC_TRF        4 /* Telephone Ringer */
51 #define UDESCSUB_CDC_TCLSR      5 /* Telephone Call ... */
52 #define UDESCSUB_CDC_UNION      6
53 #define UDESCSUB_CDC_CS         7 /* Country Selection */
54 #define UDESCSUB_CDC_TOM        8 /* Telephone Operational Modes */
55 #define UDESCSUB_CDC_USBT       9 /* USB Terminal */
56 #define UDESCSUB_CDC_ETHERNET 15 /* Ethernet Adapter */
57
58 typedef struct {
59         uByte           bLength;
60         uByte           bDescriptorType;
61         uByte           bDescriptorSubtype;
62         uWord           bcdCDC;
63 } usb_cdc_header_descriptor_t;
64
65 typedef struct {
66         uByte           bLength;
67         uByte           bDescriptorType;
68         uByte           bDescriptorSubtype;
69         uByte           bmCapabilities;
70 #define USB_CDC_CM_DOES_CM              0x01
71 #define USB_CDC_CM_OVER_DATA            0x02
72         uByte           bDataInterface;
73 } usb_cdc_cm_descriptor_t;
74
75 typedef struct {
76         uByte           bLength;
77         uByte           bDescriptorType;
78         uByte           bDescriptorSubtype;
79         uByte           bmCapabilities;
80 #define USB_CDC_ACM_HAS_FEATURE         0x01
81 #define USB_CDC_ACM_HAS_LINE            0x02
82 #define USB_CDC_ACM_HAS_BREAK           0x04
83 #define USB_CDC_ACM_HAS_NETWORK_CONN    0x08
84 } usb_cdc_acm_descriptor_t;
85
86 typedef struct {
87         uByte           bLength;
88         uByte           bDescriptorType;
89         uByte           bDescriptorSubtype;
90         uByte           bMasterInterface;
91         uByte           bSlaveInterface[1];
92 } usb_cdc_union_descriptor_t;
93
94 typedef struct {
95         uByte bLength;
96         uByte bDescriptorType;
97         uByte bDescriptorSubType;
98         uByte iMACAddress;
99         uDWord dwEthernetStatistics;
100         uWord wMaxSegmentSize;
101         uWord wNumberMCFilters;
102         uByte bNumberPowerFilters;
103 } usb_cdc_ethernet_descriptor_t;
104
105 #define UCDC_SEND_ENCAPSULATED_COMMAND  0x00
106 #define UCDC_GET_ENCAPSULATED_RESPONSE  0x01
107 #define UCDC_SET_COMM_FEATURE           0x02
108 #define UCDC_GET_COMM_FEATURE           0x03
109 #define  UCDC_ABSTRACT_STATE            0x01
110 #define  UCDC_COUNTRY_SETTING           0x02
111 #define UCDC_CLEAR_COMM_FEATURE         0x04
112 #define UCDC_SET_LINE_CODING            0x20
113 #define UCDC_GET_LINE_CODING            0x21
114 #define UCDC_SET_CONTROL_LINE_STATE     0x22
115 #define  UCDC_LINE_DTR                  0x0001
116 #define  UCDC_LINE_RTS                  0x0002
117 #define UCDC_SEND_BREAK                 0x23
118 #define  UCDC_BREAK_ON                  0xffff
119 #define  UCDC_BREAK_OFF                 0x0000
120
121 typedef struct {
122         uWord   wState;
123 #define UCDC_IDLE_SETTING               0x0001
124 #define UCDC_DATA_MULTIPLEXED           0x0002
125 } usb_cdc_abstract_state_t;
126 #define UCDC_ABSTRACT_STATE_LENGTH 2
127
128 typedef struct {
129         uDWord  dwDTERate;
130         uByte   bCharFormat;
131 #define UCDC_STOP_BIT_1                 0
132 #define UCDC_STOP_BIT_1_5               1
133 #define UCDC_STOP_BIT_2                 2
134         uByte   bParityType;
135 #define UCDC_PARITY_NONE                0
136 #define UCDC_PARITY_ODD                 1
137 #define UCDC_PARITY_EVEN                2
138 #define UCDC_PARITY_MARK                3
139 #define UCDC_PARITY_SPACE               4
140         uByte   bDataBits;
141 } usb_cdc_line_state_t;
142 #define UCDC_LINE_STATE_LENGTH 7
143
144 typedef struct {
145         uByte   bmRequestType;
146 #define UCDC_NOTIFICATION               0xa1
147         uByte   bNotification;
148 #define UCDC_N_NETWORK_CONNECTION       0x00
149 #define UCDC_N_RESPONSE_AVAILABLE       0x01
150 #define UCDC_N_AUX_JACK_HOOK_STATE      0x08
151 #define UCDC_N_RING_DETECT              0x09
152 #define UCDC_N_SERIAL_STATE             0x20
153 #define UCDC_N_CALL_STATE_CHANGED       0x28
154 #define UCDC_N_LINE_STATE_CHANGED       0x29
155 #define UCDC_N_CONNECTION_SPEED_CHANGE  0x2a
156         uWord   wValue;
157         uWord   wIndex;
158         uWord   wLength;
159         uByte   data[16];
160 } usb_cdc_notification_t;
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 #endif /* _USBCDC_H_ */