xref: /illumos-gate/usr/src/uts/common/sys/usb/clients/usbcdc/usb_cdc.h (revision 0035018c6da861f1b758fb9bf6b50245c52b48e2)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SYS_USB_USB_CDC_H
27 #define	_SYS_USB_USB_CDC_H
28 
29 
30 #include <sys/types.h>
31 #include <sys/dditypes.h>
32 
33 #ifdef	__cplusplus
34 extern "C" {
35 #endif
36 
37 /*
38  * USB Communications Device Class
39  */
40 
41 /*
42  * Class-specific descriptors
43  */
44 #define	USB_CDC_CS_INTERFACE			0x24
45 #define	USB_CDC_CS_ENDPOINT			0x25
46 
47 #define	USB_CDC_DESCR_TYPE_HEADER		0x00
48 #define	USB_CDC_DESCR_TYPE_CALL_MANAGEMENT	0x01
49 #define	USB_CDC_DESCR_TYPE_ACM			0x02
50 #define	USB_CDC_DESCR_TYPE_UNION		0x06
51 #define	USB_CDC_DESCR_TYPE_COUNTRY		0x07
52 #define	USB_CDC_DESCR_TYPE_NETWORK_TERMINAL	0x0a
53 #define	USB_CDC_DESCR_TYPE_ETHERNET		0x0f
54 
55 /* Header Functional Descriptor */
56 typedef struct usb_cdc_header_descr {
57 	uint8_t		bFunctionalLength;
58 	uint8_t		bDescriptorType;
59 	uint8_t		bDescriptorSubtype;
60 	uint16_t	bcdCDC;
61 } usb_cdc_header_descr_t;
62 
63 /* Call Management Descriptor */
64 typedef struct usb_cdc_call_mgmt_descr {
65 	uint8_t		bFunctionalLength;
66 	uint8_t		bDescriptorType;
67 	uint8_t		bDescriptorSubtype;
68 	uint8_t		bmCapabilities;
69 	uint8_t		bDataInterface;
70 } usb_cdc_call_mgmt_descr_t;
71 
72 #define	USB_CDC_CALL_MGMT_CAP_CALL_MGMT		0x01
73 #define	USB_CDC_CALL_MGMT_CAP_DATA_INTERFACE	0x02
74 
75 /* Abstract Control Management Descriptor */
76 typedef struct usb_cdc_acm_descr {
77 	uint8_t		bFunctionalLength;
78 	uint8_t		bDescriptorType;
79 	uint8_t		bDescriptorSubtype;
80 	uint8_t		bmCapabilities;
81 } usb_cdc_acm_descr_t;
82 
83 #define	USB_CDC_ACM_CAP_COMM_FEATURE		0x01
84 #define	USB_CDC_ACM_CAP_SERIAL_LINE		0x02
85 #define	USB_CDC_ACM_CAP_SEND_BREAK		0x04
86 #define	USB_CDC_ACM_CAP_NETWORK_CONNECTION	0x08
87 
88 /* Union Functional Descriptor */
89 typedef struct usb_cdc_union_descr {
90 	uint8_t		bFunctionalLength;
91 	uint8_t		bDescriptorType;
92 	uint8_t		bDescriptorSubtype;
93 	uint8_t		bMasterInterface0;
94 	uint8_t		bSlaveInterface0;
95 	/* more slave interafce may follow */
96 } usb_cdc_union_descr_t;
97 
98 /* Ethernet Control Model Functional Descriptor */
99 typedef struct usb_cdc_ecm_descr {
100 	uint8_t		bFunctionalLength;
101 	uint8_t		bDescriptorType;
102 	uint8_t		bDescriptorSubtype;
103 	uint8_t		iMACAddress;
104 	uint32_t	bmEthernetStatistics;
105 	uint16_t	wMaxSegmentSize;
106 	uint16_t	wNumberMCFilters;
107 	uint8_t		bNumberPowerFilters;
108 } usb_cdc_ecm_descr_t;
109 
110 
111 /*
112  * Class-specific requests
113  */
114 #define	USB_CDC_REQ_SEND_ENCAPSULATED_COMMAND	0x00
115 #define	USB_CDC_REQ_GET_ENCAPSULATED_RESPONSE	0x01
116 #define	USB_CDC_REQ_SET_LINE_CODING		0x20
117 #define	USB_CDC_REQ_GET_LINE_CODING		0x21
118 #define	USB_CDC_REQ_SET_CONTROL_LINE_STATE	0x22
119 #define	USB_CDC_REQ_SEND_BREAK			0x23
120 
121 /* Line Coding */
122 typedef struct usb_cdc_line_coding {
123 	uint32_t	dwDTERate;
124 	uint8_t		bCharFormat;
125 	uint8_t		bParityType;
126 	uint8_t		bDataBits;
127 } usb_cdc_line_coding_t;
128 
129 #define	USB_CDC_LINE_CODING_LEN			7
130 #define	USB_CDC_ECM_LEN				13
131 
132 #define	USB_CDC_STOP_BITS_1			0
133 #define	USB_CDC_STOP_BITS_1_5			1
134 #define	USB_CDC_STOP_BITS_2			2
135 
136 #define	USB_CDC_PARITY_NO			0
137 #define	USB_CDC_PARITY_ODD			1
138 #define	USB_CDC_PARITY_EVEN			2
139 #define	USB_CDC_PARITY_MARK			3
140 #define	USB_CDC_PARITY_SPACE			4
141 
142 #define	USB_CDC_ACM_CONTROL_DTR			0x01
143 #define	USB_CDC_ACM_CONTROL_RTS			0x02
144 
145 #define	USB_CDC_NOTIFICATION_REQUEST_TYPE	0xa1
146 /*
147  * Class-specific notifications
148  */
149 #define	USB_CDC_NOTIFICATION_NETWORK_CONNECTION	0x00
150 #define	USB_CDC_NOTIFICATION_RESPONSE_AVAILABLE	0x01
151 #define	USB_CDC_NOTIFICATION_SERIAL_STATE	0x20
152 #define	USB_CDC_NOTIFICATION_SPEED_CHANGE	0x2a
153 
154 typedef struct usb_cdc_notification {
155 	uint8_t		bmRequestType;
156 	uint8_t		bNotificationType;
157 	uint16_t	wValue;
158 	uint16_t	wIndex;
159 	uint16_t	wLength;
160 } usb_cdc_notification_t;
161 
162 /* Serial State */
163 #define	USB_CDC_ACM_CONTROL_DCD			0x01
164 #define	USB_CDC_ACM_CONTROL_DSR			0x02
165 #define	USB_CDC_ACM_CONTROL_BREAK		0x04
166 #define	USB_CDC_ACM_CONTROL_RNG			0x08
167 #define	USB_CDC_ACM_CONTROL_FRAMING		0x10
168 #define	USB_CDC_ACM_CONTROL_PARITY		0x20
169 #define	USB_CDC_ACM_CONTROL_OVERRUN		0x40
170 
171 
172 #ifdef	__cplusplus
173 }
174 #endif
175 
176 #endif	/* _SYS_USB_USB_CDC_H */
177