1 /* $OpenBSD: usbcdc.h,v 1.10 2022/01/09 05:43:02 jsg Exp $ */ 2 /* $NetBSD: usbcdc.h,v 1.8 2001/02/16 20:15:57 kenh Exp $ */ 3 /* $FreeBSD: src/sys/dev/usb/usbcdc.h,v 1.7 1999/11/17 22:33:48 n_hibma 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 * 22 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 23 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 24 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 26 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 * POSSIBILITY OF SUCH DAMAGE. 33 */ 34 35 #ifndef _USBCDC_H_ 36 #define _USBCDC_H_ 37 38 #define UDESCSUB_CDC_HEADER 0 39 #define UDESCSUB_CDC_CM 1 /* Call Management */ 40 #define UDESCSUB_CDC_ACM 2 /* Abstract Control Model */ 41 #define UDESCSUB_CDC_DLM 3 /* Direct Line Management */ 42 #define UDESCSUB_CDC_TRF 4 /* Telephone Ringer */ 43 #define UDESCSUB_CDC_TCLSR 5 /* Telephone Call ... */ 44 #define UDESCSUB_CDC_UNION 6 45 #define UDESCSUB_CDC_CS 7 /* Country Selection */ 46 #define UDESCSUB_CDC_TOM 8 /* Telephone Operational Modes */ 47 #define UDESCSUB_CDC_USBT 9 /* USB Terminal */ 48 #define UDESCSUB_CDC_NCT 10 /* Network Channel Terminal */ 49 #define UDESCSUB_CDC_PUF 11 /* Protocol Unit */ 50 #define UDESCSUB_CDC_EUF 12 /* Extension Unit */ 51 #define UDESCSUB_CDC_MCMF 13 /* Multi-Channel Management */ 52 #define UDESCSUB_CDC_CCMF 14 /* CAPI Control Management */ 53 #define UDESCSUB_CDC_ENF 15 /* Ethernet Networking */ 54 #define UDESCSUB_CDC_ANF 16 /* ATM Networking */ 55 56 struct usb_cdc_header_descriptor { 57 uByte bLength; 58 uByte bDescriptorType; 59 uByte bDescriptorSubtype; 60 uWord bcdCDC; 61 } __packed; 62 63 struct usb_cdc_cm_descriptor { 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 } __packed; 72 73 struct usb_cdc_acm_descriptor { 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 } __packed; 83 84 struct usb_cdc_union_descriptor { 85 uByte bLength; 86 uByte bDescriptorType; 87 uByte bDescriptorSubtype; 88 uByte bMasterInterface; 89 uByte bSlaveInterface[1]; 90 } __packed; 91 92 struct usb_cdc_ethernet_descriptor { 93 uByte bLength; 94 uByte bDescriptorType; 95 uByte bDescriptorSubtype; 96 uByte iMacAddress; 97 uDWord bmEthernetStatistics; 98 uWord wMaxSegmentSize; 99 uWord wNumberMCFilters; 100 uByte bNumberPowerFilters; 101 } __packed; 102 103 #define UCDC_SEND_ENCAPSULATED_COMMAND 0x00 104 #define UCDC_GET_ENCAPSULATED_RESPONSE 0x01 105 #define UCDC_SET_COMM_FEATURE 0x02 106 #define UCDC_GET_COMM_FEATURE 0x03 107 #define UCDC_ABSTRACT_STATE 0x01 108 #define UCDC_COUNTRY_SETTING 0x02 109 #define UCDC_CLEAR_COMM_FEATURE 0x04 110 #define UCDC_SET_LINE_CODING 0x20 111 #define UCDC_GET_LINE_CODING 0x21 112 #define UCDC_SET_CONTROL_LINE_STATE 0x22 113 #define UCDC_LINE_DTR 0x0001 114 #define UCDC_LINE_RTS 0x0002 115 #define UCDC_SEND_BREAK 0x23 116 #define UCDC_BREAK_ON 0xffff 117 #define UCDC_BREAK_OFF 0x0000 118 119 struct usb_cdc_abstract_state { 120 uWord wState; 121 #define UCDC_IDLE_SETTING 0x0001 122 #define UCDC_DATA_MULTIPLEXED 0x0002 123 } __packed; 124 #define UCDC_ABSTRACT_STATE_LENGTH 2 125 126 struct usb_cdc_line_state { 127 uDWord dwDTERate; 128 uByte bCharFormat; 129 #define UCDC_STOP_BIT_1 0 130 #define UCDC_STOP_BIT_1_5 1 131 #define UCDC_STOP_BIT_2 2 132 uByte bParityType; 133 #define UCDC_PARITY_NONE 0 134 #define UCDC_PARITY_ODD 1 135 #define UCDC_PARITY_EVEN 2 136 #define UCDC_PARITY_MARK 3 137 #define UCDC_PARITY_SPACE 4 138 uByte bDataBits; 139 } __packed; 140 #define UCDC_LINE_STATE_LENGTH 7 141 142 struct usb_cdc_notification { 143 uByte bmRequestType; 144 #define UCDC_NOTIFICATION 0xa1 145 uByte bNotification; 146 #define UCDC_N_NETWORK_CONNECTION 0x00 147 #define UCDC_N_RESPONSE_AVAILABLE 0x01 148 #define UCDC_N_AUX_JACK_HOOK_STATE 0x08 149 #define UCDC_N_RING_DETECT 0x09 150 #define UCDC_N_SERIAL_STATE 0x20 151 #define UCDC_N_CALL_STATE_CHANGED 0x28 152 #define UCDC_N_LINE_STATE_CHANGED 0x29 153 #define UCDC_N_CONNECTION_SPEED_CHANGE 0x2a 154 uWord wValue; 155 uWord wIndex; 156 uWord wLength; 157 uByte data[16]; 158 } __packed; 159 #define UCDC_NOTIFICATION_LENGTH 8 160 161 struct usb_cdc_connection_speed { 162 uDWord dwUSBitRate; 163 uDWord dwDSBitRate; 164 } __packed; 165 #define UCDC_CONNECTION_SPEED_LENGTH 8 166 167 /* 168 * Bits set in the SERIAL STATE notification (first byte of data) 169 */ 170 171 #define UCDC_N_SERIAL_OVERRUN 0x40 172 #define UCDC_N_SERIAL_PARITY 0x20 173 #define UCDC_N_SERIAL_FRAMING 0x10 174 #define UCDC_N_SERIAL_RI 0x08 175 #define UCDC_N_SERIAL_BREAK 0x04 176 #define UCDC_N_SERIAL_DSR 0x02 177 #define UCDC_N_SERIAL_DCD 0x01 178 179 #endif /* _USBCDC_H_ */ 180