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