xref: /onnv-gate/usr/src/uts/common/sys/usb/clients/usbcdc/usb_cdc.h (revision 11900:3d14975ff34e)
13227Syq193411 /*
23227Syq193411  * CDDL HEADER START
33227Syq193411  *
43227Syq193411  * The contents of this file are subject to the terms of the
53227Syq193411  * Common Development and Distribution License (the "License").
63227Syq193411  * You may not use this file except in compliance with the License.
73227Syq193411  *
83227Syq193411  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
93227Syq193411  * or http://www.opensolaris.org/os/licensing.
103227Syq193411  * See the License for the specific language governing permissions
113227Syq193411  * and limitations under the License.
123227Syq193411  *
133227Syq193411  * When distributing Covered Code, include this CDDL HEADER in each
143227Syq193411  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
153227Syq193411  * If applicable, add the following below this CDDL HEADER, with the
163227Syq193411  * fields enclosed by brackets "[]" replaced with your own identifying
173227Syq193411  * information: Portions Copyright [yyyy] [name of copyright owner]
183227Syq193411  *
193227Syq193411  * CDDL HEADER END
203227Syq193411  */
213227Syq193411 /*
22*11900SRaymond.Chen@Sun.COM  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
233227Syq193411  * Use is subject to license terms.
243227Syq193411  */
253227Syq193411 
263227Syq193411 #ifndef _SYS_USB_USB_CDC_H
273227Syq193411 #define	_SYS_USB_USB_CDC_H
283227Syq193411 
293227Syq193411 
303227Syq193411 #include <sys/types.h>
313227Syq193411 #include <sys/dditypes.h>
323227Syq193411 
333227Syq193411 #ifdef	__cplusplus
343227Syq193411 extern "C" {
353227Syq193411 #endif
363227Syq193411 
373227Syq193411 /*
383227Syq193411  * USB Communications Device Class
393227Syq193411  */
403227Syq193411 
413227Syq193411 /*
423227Syq193411  * Class-specific descriptors
433227Syq193411  */
443227Syq193411 #define	USB_CDC_CS_INTERFACE			0x24
453227Syq193411 #define	USB_CDC_CS_ENDPOINT			0x25
463227Syq193411 
473227Syq193411 #define	USB_CDC_DESCR_TYPE_HEADER		0x00
483227Syq193411 #define	USB_CDC_DESCR_TYPE_CALL_MANAGEMENT	0x01
493227Syq193411 #define	USB_CDC_DESCR_TYPE_ACM			0x02
503227Syq193411 #define	USB_CDC_DESCR_TYPE_UNION		0x06
513227Syq193411 #define	USB_CDC_DESCR_TYPE_COUNTRY		0x07
523227Syq193411 #define	USB_CDC_DESCR_TYPE_NETWORK_TERMINAL	0x0a
533227Syq193411 #define	USB_CDC_DESCR_TYPE_ETHERNET		0x0f
543227Syq193411 
553227Syq193411 /* Header Functional Descriptor */
563227Syq193411 typedef struct usb_cdc_header_descr {
573227Syq193411 	uint8_t		bFunctionalLength;
583227Syq193411 	uint8_t		bDescriptorType;
593227Syq193411 	uint8_t		bDescriptorSubtype;
603227Syq193411 	uint16_t	bcdCDC;
613227Syq193411 } usb_cdc_header_descr_t;
623227Syq193411 
633227Syq193411 /* Call Management Descriptor */
643227Syq193411 typedef struct usb_cdc_call_mgmt_descr {
653227Syq193411 	uint8_t		bFunctionalLength;
663227Syq193411 	uint8_t		bDescriptorType;
673227Syq193411 	uint8_t		bDescriptorSubtype;
683227Syq193411 	uint8_t		bmCapabilities;
693227Syq193411 	uint8_t		bDataInterface;
703227Syq193411 } usb_cdc_call_mgmt_descr_t;
713227Syq193411 
723227Syq193411 #define	USB_CDC_CALL_MGMT_CAP_CALL_MGMT		0x01
733227Syq193411 #define	USB_CDC_CALL_MGMT_CAP_DATA_INTERFACE	0x02
743227Syq193411 
753227Syq193411 /* Abstract Control Management Descriptor */
763227Syq193411 typedef struct usb_cdc_acm_descr {
773227Syq193411 	uint8_t		bFunctionalLength;
783227Syq193411 	uint8_t		bDescriptorType;
793227Syq193411 	uint8_t		bDescriptorSubtype;
803227Syq193411 	uint8_t		bmCapabilities;
813227Syq193411 } usb_cdc_acm_descr_t;
823227Syq193411 
833227Syq193411 #define	USB_CDC_ACM_CAP_COMM_FEATURE		0x01
843227Syq193411 #define	USB_CDC_ACM_CAP_SERIAL_LINE		0x02
853227Syq193411 #define	USB_CDC_ACM_CAP_SEND_BREAK		0x04
863227Syq193411 #define	USB_CDC_ACM_CAP_NETWORK_CONNECTION	0x08
873227Syq193411 
883227Syq193411 /* Union Functional Descriptor */
893227Syq193411 typedef struct usb_cdc_union_descr {
903227Syq193411 	uint8_t		bFunctionalLength;
913227Syq193411 	uint8_t		bDescriptorType;
923227Syq193411 	uint8_t		bDescriptorSubtype;
933227Syq193411 	uint8_t		bMasterInterface0;
943227Syq193411 	uint8_t		bSlaveInterface0;
953227Syq193411 	/* more slave interafce may follow */
963227Syq193411 } usb_cdc_union_descr_t;
973227Syq193411 
98*11900SRaymond.Chen@Sun.COM /* Ethernet Control Model Functional Descriptor */
99*11900SRaymond.Chen@Sun.COM typedef struct usb_cdc_ecm_descr {
100*11900SRaymond.Chen@Sun.COM 	uint8_t		bFunctionalLength;
101*11900SRaymond.Chen@Sun.COM 	uint8_t		bDescriptorType;
102*11900SRaymond.Chen@Sun.COM 	uint8_t		bDescriptorSubtype;
103*11900SRaymond.Chen@Sun.COM 	uint8_t		iMACAddress;
104*11900SRaymond.Chen@Sun.COM 	uint32_t	bmEthernetStatistics;
105*11900SRaymond.Chen@Sun.COM 	uint16_t	wMaxSegmentSize;
106*11900SRaymond.Chen@Sun.COM 	uint16_t	wNumberMCFilters;
107*11900SRaymond.Chen@Sun.COM 	uint8_t		bNumberPowerFilters;
108*11900SRaymond.Chen@Sun.COM } usb_cdc_ecm_descr_t;
109*11900SRaymond.Chen@Sun.COM 
110*11900SRaymond.Chen@Sun.COM 
1113227Syq193411 /*
1123227Syq193411  * Class-specific requests
1133227Syq193411  */
1143227Syq193411 #define	USB_CDC_REQ_SEND_ENCAPSULATED_COMMAND	0x00
1153227Syq193411 #define	USB_CDC_REQ_GET_ENCAPSULATED_RESPONSE	0x01
1163227Syq193411 #define	USB_CDC_REQ_SET_LINE_CODING		0x20
1173227Syq193411 #define	USB_CDC_REQ_GET_LINE_CODING		0x21
1183227Syq193411 #define	USB_CDC_REQ_SET_CONTROL_LINE_STATE	0x22
1193227Syq193411 #define	USB_CDC_REQ_SEND_BREAK			0x23
1203227Syq193411 
1213227Syq193411 /* Line Coding */
1223227Syq193411 typedef struct usb_cdc_line_coding {
1233227Syq193411 	uint32_t	dwDTERate;
1243227Syq193411 	uint8_t		bCharFormat;
1253227Syq193411 	uint8_t		bParityType;
1263227Syq193411 	uint8_t		bDataBits;
1273227Syq193411 } usb_cdc_line_coding_t;
1283227Syq193411 
1293227Syq193411 #define	USB_CDC_LINE_CODING_LEN			7
130*11900SRaymond.Chen@Sun.COM #define	USB_CDC_ECM_LEN				13
1313227Syq193411 
1323227Syq193411 #define	USB_CDC_STOP_BITS_1			0
1333227Syq193411 #define	USB_CDC_STOP_BITS_1_5			1
1343227Syq193411 #define	USB_CDC_STOP_BITS_2			2
1353227Syq193411 
1363227Syq193411 #define	USB_CDC_PARITY_NO			0
1373227Syq193411 #define	USB_CDC_PARITY_ODD			1
1383227Syq193411 #define	USB_CDC_PARITY_EVEN			2
1393227Syq193411 #define	USB_CDC_PARITY_MARK			3
1403227Syq193411 #define	USB_CDC_PARITY_SPACE			4
1413227Syq193411 
1423227Syq193411 #define	USB_CDC_ACM_CONTROL_DTR			0x01
1433227Syq193411 #define	USB_CDC_ACM_CONTROL_RTS			0x02
1443227Syq193411 
1453227Syq193411 #define	USB_CDC_NOTIFICATION_REQUEST_TYPE	0xa1
1463227Syq193411 /*
1473227Syq193411  * Class-specific notifications
1483227Syq193411  */
1493227Syq193411 #define	USB_CDC_NOTIFICATION_NETWORK_CONNECTION	0x00
1503227Syq193411 #define	USB_CDC_NOTIFICATION_RESPONSE_AVAILABLE	0x01
1513227Syq193411 #define	USB_CDC_NOTIFICATION_SERIAL_STATE	0x20
1523227Syq193411 #define	USB_CDC_NOTIFICATION_SPEED_CHANGE	0x2a
1533227Syq193411 
1543227Syq193411 typedef struct usb_cdc_notification {
1553227Syq193411 	uint8_t		bmRequestType;
1563227Syq193411 	uint8_t		bNotificationType;
1573227Syq193411 	uint16_t	wValue;
1583227Syq193411 	uint16_t	wIndex;
1593227Syq193411 	uint16_t	wLength;
1603227Syq193411 } usb_cdc_notification_t;
1613227Syq193411 
1623227Syq193411 /* Serial State */
1633227Syq193411 #define	USB_CDC_ACM_CONTROL_DCD			0x01
1643227Syq193411 #define	USB_CDC_ACM_CONTROL_DSR			0x02
1653227Syq193411 #define	USB_CDC_ACM_CONTROL_BREAK		0x04
1663227Syq193411 #define	USB_CDC_ACM_CONTROL_RNG			0x08
1673227Syq193411 #define	USB_CDC_ACM_CONTROL_FRAMING		0x10
1683227Syq193411 #define	USB_CDC_ACM_CONTROL_PARITY		0x20
1693227Syq193411 #define	USB_CDC_ACM_CONTROL_OVERRUN		0x40
1703227Syq193411 
1713227Syq193411 
1723227Syq193411 #ifdef	__cplusplus
1733227Syq193411 }
1743227Syq193411 #endif
1753227Syq193411 
1763227Syq193411 #endif	/* _SYS_USB_USB_CDC_H */
177