190f05028Syq /*
290f05028Syq  * CDDL HEADER START
390f05028Syq  *
490f05028Syq  * The contents of this file are subject to the terms of the
590f05028Syq  * Common Development and Distribution License (the "License").
690f05028Syq  * You may not use this file except in compliance with the License.
790f05028Syq  *
890f05028Syq  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
990f05028Syq  * or http://www.opensolaris.org/os/licensing.
1090f05028Syq  * See the License for the specific language governing permissions
1190f05028Syq  * and limitations under the License.
1290f05028Syq  *
1390f05028Syq  * When distributing Covered Code, include this CDDL HEADER in each
1490f05028Syq  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1590f05028Syq  * If applicable, add the following below this CDDL HEADER, with the
1690f05028Syq  * fields enclosed by brackets "[]" replaced with your own identifying
1790f05028Syq  * information: Portions Copyright [yyyy] [name of copyright owner]
1890f05028Syq  *
1990f05028Syq  * CDDL HEADER END
2090f05028Syq  */
2190f05028Syq /*
22*0035018cSRaymond Chen  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
2390f05028Syq  * Use is subject to license terms.
2490f05028Syq  */
2590f05028Syq 
2690f05028Syq #ifndef _SYS_USB_USB_CDC_H
2790f05028Syq #define	_SYS_USB_USB_CDC_H
2890f05028Syq 
2990f05028Syq 
3090f05028Syq #include <sys/types.h>
3190f05028Syq #include <sys/dditypes.h>
3290f05028Syq 
3390f05028Syq #ifdef	__cplusplus
3490f05028Syq extern "C" {
3590f05028Syq #endif
3690f05028Syq 
3790f05028Syq /*
3890f05028Syq  * USB Communications Device Class
3990f05028Syq  */
4090f05028Syq 
4190f05028Syq /*
4290f05028Syq  * Class-specific descriptors
4390f05028Syq  */
4490f05028Syq #define	USB_CDC_CS_INTERFACE			0x24
4590f05028Syq #define	USB_CDC_CS_ENDPOINT			0x25
4690f05028Syq 
4790f05028Syq #define	USB_CDC_DESCR_TYPE_HEADER		0x00
4890f05028Syq #define	USB_CDC_DESCR_TYPE_CALL_MANAGEMENT	0x01
4990f05028Syq #define	USB_CDC_DESCR_TYPE_ACM			0x02
5090f05028Syq #define	USB_CDC_DESCR_TYPE_UNION		0x06
5190f05028Syq #define	USB_CDC_DESCR_TYPE_COUNTRY		0x07
5290f05028Syq #define	USB_CDC_DESCR_TYPE_NETWORK_TERMINAL	0x0a
5390f05028Syq #define	USB_CDC_DESCR_TYPE_ETHERNET		0x0f
5490f05028Syq 
5590f05028Syq /* Header Functional Descriptor */
5690f05028Syq typedef struct usb_cdc_header_descr {
5790f05028Syq 	uint8_t		bFunctionalLength;
5890f05028Syq 	uint8_t		bDescriptorType;
5990f05028Syq 	uint8_t		bDescriptorSubtype;
6090f05028Syq 	uint16_t	bcdCDC;
6190f05028Syq } usb_cdc_header_descr_t;
6290f05028Syq 
6390f05028Syq /* Call Management Descriptor */
6490f05028Syq typedef struct usb_cdc_call_mgmt_descr {
6590f05028Syq 	uint8_t		bFunctionalLength;
6690f05028Syq 	uint8_t		bDescriptorType;
6790f05028Syq 	uint8_t		bDescriptorSubtype;
6890f05028Syq 	uint8_t		bmCapabilities;
6990f05028Syq 	uint8_t		bDataInterface;
7090f05028Syq } usb_cdc_call_mgmt_descr_t;
7190f05028Syq 
7290f05028Syq #define	USB_CDC_CALL_MGMT_CAP_CALL_MGMT		0x01
7390f05028Syq #define	USB_CDC_CALL_MGMT_CAP_DATA_INTERFACE	0x02
7490f05028Syq 
7590f05028Syq /* Abstract Control Management Descriptor */
7690f05028Syq typedef struct usb_cdc_acm_descr {
7790f05028Syq 	uint8_t		bFunctionalLength;
7890f05028Syq 	uint8_t		bDescriptorType;
7990f05028Syq 	uint8_t		bDescriptorSubtype;
8090f05028Syq 	uint8_t		bmCapabilities;
8190f05028Syq } usb_cdc_acm_descr_t;
8290f05028Syq 
8390f05028Syq #define	USB_CDC_ACM_CAP_COMM_FEATURE		0x01
8490f05028Syq #define	USB_CDC_ACM_CAP_SERIAL_LINE		0x02
8590f05028Syq #define	USB_CDC_ACM_CAP_SEND_BREAK		0x04
8690f05028Syq #define	USB_CDC_ACM_CAP_NETWORK_CONNECTION	0x08
8790f05028Syq 
8890f05028Syq /* Union Functional Descriptor */
8990f05028Syq typedef struct usb_cdc_union_descr {
9090f05028Syq 	uint8_t		bFunctionalLength;
9190f05028Syq 	uint8_t		bDescriptorType;
9290f05028Syq 	uint8_t		bDescriptorSubtype;
9390f05028Syq 	uint8_t		bMasterInterface0;
9490f05028Syq 	uint8_t		bSlaveInterface0;
9590f05028Syq 	/* more slave interafce may follow */
9690f05028Syq } usb_cdc_union_descr_t;
9790f05028Syq 
98*0035018cSRaymond Chen /* Ethernet Control Model Functional Descriptor */
99*0035018cSRaymond Chen typedef struct usb_cdc_ecm_descr {
100*0035018cSRaymond Chen 	uint8_t		bFunctionalLength;
101*0035018cSRaymond Chen 	uint8_t		bDescriptorType;
102*0035018cSRaymond Chen 	uint8_t		bDescriptorSubtype;
103*0035018cSRaymond Chen 	uint8_t		iMACAddress;
104*0035018cSRaymond Chen 	uint32_t	bmEthernetStatistics;
105*0035018cSRaymond Chen 	uint16_t	wMaxSegmentSize;
106*0035018cSRaymond Chen 	uint16_t	wNumberMCFilters;
107*0035018cSRaymond Chen 	uint8_t		bNumberPowerFilters;
108*0035018cSRaymond Chen } usb_cdc_ecm_descr_t;
109*0035018cSRaymond Chen 
110*0035018cSRaymond Chen 
11190f05028Syq /*
11290f05028Syq  * Class-specific requests
11390f05028Syq  */
11490f05028Syq #define	USB_CDC_REQ_SEND_ENCAPSULATED_COMMAND	0x00
11590f05028Syq #define	USB_CDC_REQ_GET_ENCAPSULATED_RESPONSE	0x01
11690f05028Syq #define	USB_CDC_REQ_SET_LINE_CODING		0x20
11790f05028Syq #define	USB_CDC_REQ_GET_LINE_CODING		0x21
11890f05028Syq #define	USB_CDC_REQ_SET_CONTROL_LINE_STATE	0x22
11990f05028Syq #define	USB_CDC_REQ_SEND_BREAK			0x23
12090f05028Syq 
12190f05028Syq /* Line Coding */
12290f05028Syq typedef struct usb_cdc_line_coding {
12390f05028Syq 	uint32_t	dwDTERate;
12490f05028Syq 	uint8_t		bCharFormat;
12590f05028Syq 	uint8_t		bParityType;
12690f05028Syq 	uint8_t		bDataBits;
12790f05028Syq } usb_cdc_line_coding_t;
12890f05028Syq 
12990f05028Syq #define	USB_CDC_LINE_CODING_LEN			7
130*0035018cSRaymond Chen #define	USB_CDC_ECM_LEN				13
13190f05028Syq 
13290f05028Syq #define	USB_CDC_STOP_BITS_1			0
13390f05028Syq #define	USB_CDC_STOP_BITS_1_5			1
13490f05028Syq #define	USB_CDC_STOP_BITS_2			2
13590f05028Syq 
13690f05028Syq #define	USB_CDC_PARITY_NO			0
13790f05028Syq #define	USB_CDC_PARITY_ODD			1
13890f05028Syq #define	USB_CDC_PARITY_EVEN			2
13990f05028Syq #define	USB_CDC_PARITY_MARK			3
14090f05028Syq #define	USB_CDC_PARITY_SPACE			4
14190f05028Syq 
14290f05028Syq #define	USB_CDC_ACM_CONTROL_DTR			0x01
14390f05028Syq #define	USB_CDC_ACM_CONTROL_RTS			0x02
14490f05028Syq 
14590f05028Syq #define	USB_CDC_NOTIFICATION_REQUEST_TYPE	0xa1
14690f05028Syq /*
14790f05028Syq  * Class-specific notifications
14890f05028Syq  */
14990f05028Syq #define	USB_CDC_NOTIFICATION_NETWORK_CONNECTION	0x00
15090f05028Syq #define	USB_CDC_NOTIFICATION_RESPONSE_AVAILABLE	0x01
15190f05028Syq #define	USB_CDC_NOTIFICATION_SERIAL_STATE	0x20
15290f05028Syq #define	USB_CDC_NOTIFICATION_SPEED_CHANGE	0x2a
15390f05028Syq 
15490f05028Syq typedef struct usb_cdc_notification {
15590f05028Syq 	uint8_t		bmRequestType;
15690f05028Syq 	uint8_t		bNotificationType;
15790f05028Syq 	uint16_t	wValue;
15890f05028Syq 	uint16_t	wIndex;
15990f05028Syq 	uint16_t	wLength;
16090f05028Syq } usb_cdc_notification_t;
16190f05028Syq 
16290f05028Syq /* Serial State */
16390f05028Syq #define	USB_CDC_ACM_CONTROL_DCD			0x01
16490f05028Syq #define	USB_CDC_ACM_CONTROL_DSR			0x02
16590f05028Syq #define	USB_CDC_ACM_CONTROL_BREAK		0x04
16690f05028Syq #define	USB_CDC_ACM_CONTROL_RNG			0x08
16790f05028Syq #define	USB_CDC_ACM_CONTROL_FRAMING		0x10
16890f05028Syq #define	USB_CDC_ACM_CONTROL_PARITY		0x20
16990f05028Syq #define	USB_CDC_ACM_CONTROL_OVERRUN		0x40
17090f05028Syq 
17190f05028Syq 
17290f05028Syq #ifdef	__cplusplus
17390f05028Syq }
17490f05028Syq #endif
17590f05028Syq 
17690f05028Syq #endif	/* _SYS_USB_USB_CDC_H */
177