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 2008 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 #include <sys/usb/clients/usbser/usbser_dsdi.h>
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 /*
39  * USB Communications Device Class
40  */
41 
42 /*
43  * Class-specific descriptors
44  */
45 #define	USB_CDC_CS_INTERFACE			0x24
46 #define	USB_CDC_CS_ENDPOINT			0x25
47 
48 #define	USB_CDC_DESCR_TYPE_HEADER		0x00
49 #define	USB_CDC_DESCR_TYPE_CALL_MANAGEMENT	0x01
50 #define	USB_CDC_DESCR_TYPE_ACM			0x02
51 #define	USB_CDC_DESCR_TYPE_UNION		0x06
52 #define	USB_CDC_DESCR_TYPE_COUNTRY		0x07
53 #define	USB_CDC_DESCR_TYPE_NETWORK_TERMINAL	0x0a
54 #define	USB_CDC_DESCR_TYPE_ETHERNET		0x0f
55 
56 /* Header Functional Descriptor */
57 typedef struct usb_cdc_header_descr {
58 	uint8_t		bFunctionalLength;
59 	uint8_t		bDescriptorType;
60 	uint8_t		bDescriptorSubtype;
61 	uint16_t	bcdCDC;
62 } usb_cdc_header_descr_t;
63 
64 /* Call Management Descriptor */
65 typedef struct usb_cdc_call_mgmt_descr {
66 	uint8_t		bFunctionalLength;
67 	uint8_t		bDescriptorType;
68 	uint8_t		bDescriptorSubtype;
69 	uint8_t		bmCapabilities;
70 	uint8_t		bDataInterface;
71 } usb_cdc_call_mgmt_descr_t;
72 
73 #define	USB_CDC_CALL_MGMT_CAP_CALL_MGMT		0x01
74 #define	USB_CDC_CALL_MGMT_CAP_DATA_INTERFACE	0x02
75 
76 /* Abstract Control Management Descriptor */
77 typedef struct usb_cdc_acm_descr {
78 	uint8_t		bFunctionalLength;
79 	uint8_t		bDescriptorType;
80 	uint8_t		bDescriptorSubtype;
81 	uint8_t		bmCapabilities;
82 } usb_cdc_acm_descr_t;
83 
84 #define	USB_CDC_ACM_CAP_COMM_FEATURE		0x01
85 #define	USB_CDC_ACM_CAP_SERIAL_LINE		0x02
86 #define	USB_CDC_ACM_CAP_SEND_BREAK		0x04
87 #define	USB_CDC_ACM_CAP_NETWORK_CONNECTION	0x08
88 
89 /* Union Functional Descriptor */
90 typedef struct usb_cdc_union_descr {
91 	uint8_t		bFunctionalLength;
92 	uint8_t		bDescriptorType;
93 	uint8_t		bDescriptorSubtype;
94 	uint8_t		bMasterInterface0;
95 	uint8_t		bSlaveInterface0;
96 	/* more slave interafce may follow */
97 } usb_cdc_union_descr_t;
98 
99 /*
100  * Class-specific requests
101  */
102 #define	USB_CDC_REQ_SEND_ENCAPSULATED_COMMAND	0x00
103 #define	USB_CDC_REQ_GET_ENCAPSULATED_RESPONSE	0x01
104 #define	USB_CDC_REQ_SET_LINE_CODING		0x20
105 #define	USB_CDC_REQ_GET_LINE_CODING		0x21
106 #define	USB_CDC_REQ_SET_CONTROL_LINE_STATE	0x22
107 #define	USB_CDC_REQ_SEND_BREAK			0x23
108 
109 /* Line Coding */
110 typedef struct usb_cdc_line_coding {
111 	uint32_t	dwDTERate;
112 	uint8_t		bCharFormat;
113 	uint8_t		bParityType;
114 	uint8_t		bDataBits;
115 } usb_cdc_line_coding_t;
116 
117 #define	USB_CDC_LINE_CODING_LEN			7
118 
119 #define	USB_CDC_STOP_BITS_1			0
120 #define	USB_CDC_STOP_BITS_1_5			1
121 #define	USB_CDC_STOP_BITS_2			2
122 
123 #define	USB_CDC_PARITY_NO			0
124 #define	USB_CDC_PARITY_ODD			1
125 #define	USB_CDC_PARITY_EVEN			2
126 #define	USB_CDC_PARITY_MARK			3
127 #define	USB_CDC_PARITY_SPACE			4
128 
129 #define	USB_CDC_ACM_CONTROL_DTR			0x01
130 #define	USB_CDC_ACM_CONTROL_RTS			0x02
131 
132 #define	USB_CDC_NOTIFICATION_REQUEST_TYPE	0xa1
133 /*
134  * Class-specific notifications
135  */
136 #define	USB_CDC_NOTIFICATION_NETWORK_CONNECTION	0x00
137 #define	USB_CDC_NOTIFICATION_RESPONSE_AVAILABLE	0x01
138 #define	USB_CDC_NOTIFICATION_SERIAL_STATE	0x20
139 #define	USB_CDC_NOTIFICATION_SPEED_CHANGE	0x2a
140 
141 typedef struct usb_cdc_notification {
142 	uint8_t		bmRequestType;
143 	uint8_t		bNotificationType;
144 	uint16_t	wValue;
145 	uint16_t	wIndex;
146 	uint16_t	wLength;
147 } usb_cdc_notification_t;
148 
149 /* Serial State */
150 #define	USB_CDC_ACM_CONTROL_DCD			0x01
151 #define	USB_CDC_ACM_CONTROL_DSR			0x02
152 #define	USB_CDC_ACM_CONTROL_BREAK		0x04
153 #define	USB_CDC_ACM_CONTROL_RNG			0x08
154 #define	USB_CDC_ACM_CONTROL_FRAMING		0x10
155 #define	USB_CDC_ACM_CONTROL_PARITY		0x20
156 #define	USB_CDC_ACM_CONTROL_OVERRUN		0x40
157 
158 
159 #ifdef	__cplusplus
160 }
161 #endif
162 
163 #endif	/* _SYS_USB_USB_CDC_H */
164