1184610Salfred/* $NetBSD: usbcdc.h,v 1.9 2004/10/23 13:24:24 augustss Exp $ */ 2184610Salfred/* $FreeBSD$ */ 3184610Salfred 4184610Salfred/*- 5184610Salfred * Copyright (c) 1998 The NetBSD Foundation, Inc. 6184610Salfred * All rights reserved. 7184610Salfred * 8184610Salfred * This code is derived from software contributed to The NetBSD Foundation 9184610Salfred * by Lennart Augustsson (lennart@augustsson.net) at 10184610Salfred * Carlstedt Research & Technology. 11184610Salfred * 12184610Salfred * Redistribution and use in source and binary forms, with or without 13184610Salfred * modification, are permitted provided that the following conditions 14184610Salfred * are met: 15184610Salfred * 1. Redistributions of source code must retain the above copyright 16184610Salfred * notice, this list of conditions and the following disclaimer. 17184610Salfred * 2. Redistributions in binary form must reproduce the above copyright 18184610Salfred * notice, this list of conditions and the following disclaimer in the 19184610Salfred * documentation and/or other materials provided with the distribution. 20184610Salfred * 21184610Salfred * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 22184610Salfred * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 23184610Salfred * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24184610Salfred * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 25184610Salfred * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26184610Salfred * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27184610Salfred * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28184610Salfred * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29184610Salfred * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30184610Salfred * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31184610Salfred * POSSIBILITY OF SUCH DAMAGE. 32184610Salfred */ 33184610Salfred 34184610Salfred#ifndef _USB_CDC_H_ 35184610Salfred#define _USB_CDC_H_ 36184610Salfred 37184610Salfred#define UDESCSUB_CDC_HEADER 0 38184610Salfred#define UDESCSUB_CDC_CM 1 /* Call Management */ 39184610Salfred#define UDESCSUB_CDC_ACM 2 /* Abstract Control Model */ 40184610Salfred#define UDESCSUB_CDC_DLM 3 /* Direct Line Management */ 41184610Salfred#define UDESCSUB_CDC_TRF 4 /* Telephone Ringer */ 42184610Salfred#define UDESCSUB_CDC_TCLSR 5 /* Telephone Call */ 43184610Salfred#define UDESCSUB_CDC_UNION 6 44184610Salfred#define UDESCSUB_CDC_CS 7 /* Country Selection */ 45184610Salfred#define UDESCSUB_CDC_TOM 8 /* Telephone Operational Modes */ 46184610Salfred#define UDESCSUB_CDC_USBT 9 /* USB Terminal */ 47184610Salfred#define UDESCSUB_CDC_NCT 10 48184610Salfred#define UDESCSUB_CDC_PUF 11 49184610Salfred#define UDESCSUB_CDC_EUF 12 50184610Salfred#define UDESCSUB_CDC_MCMF 13 51184610Salfred#define UDESCSUB_CDC_CCMF 14 52184610Salfred#define UDESCSUB_CDC_ENF 15 53184610Salfred#define UDESCSUB_CDC_ANF 16 54184610Salfred 55192984Sthompsastruct usb_cdc_header_descriptor { 56184610Salfred uByte bLength; 57184610Salfred uByte bDescriptorType; 58184610Salfred uByte bDescriptorSubtype; 59184610Salfred uWord bcdCDC; 60184610Salfred} __packed; 61184610Salfred 62192984Sthompsastruct usb_cdc_cm_descriptor { 63184610Salfred uByte bLength; 64184610Salfred uByte bDescriptorType; 65184610Salfred uByte bDescriptorSubtype; 66184610Salfred uByte bmCapabilities; 67184610Salfred#define USB_CDC_CM_DOES_CM 0x01 68184610Salfred#define USB_CDC_CM_OVER_DATA 0x02 69184610Salfred uByte bDataInterface; 70184610Salfred} __packed; 71184610Salfred 72192984Sthompsastruct usb_cdc_acm_descriptor { 73184610Salfred uByte bLength; 74184610Salfred uByte bDescriptorType; 75184610Salfred uByte bDescriptorSubtype; 76184610Salfred uByte bmCapabilities; 77184610Salfred#define USB_CDC_ACM_HAS_FEATURE 0x01 78184610Salfred#define USB_CDC_ACM_HAS_LINE 0x02 79184610Salfred#define USB_CDC_ACM_HAS_BREAK 0x04 80184610Salfred#define USB_CDC_ACM_HAS_NETWORK_CONN 0x08 81184610Salfred} __packed; 82184610Salfred 83192984Sthompsastruct usb_cdc_union_descriptor { 84184610Salfred uByte bLength; 85184610Salfred uByte bDescriptorType; 86184610Salfred uByte bDescriptorSubtype; 87184610Salfred uByte bMasterInterface; 88184610Salfred uByte bSlaveInterface[1]; 89184610Salfred} __packed; 90184610Salfred 91192984Sthompsastruct usb_cdc_ethernet_descriptor { 92184610Salfred uByte bLength; 93184610Salfred uByte bDescriptorType; 94184610Salfred uByte bDescriptorSubtype; 95184610Salfred uByte iMacAddress; 96184610Salfred uDWord bmEthernetStatistics; 97184610Salfred uWord wMaxSegmentSize; 98184610Salfred uWord wNumberMCFilters; 99184610Salfred uByte bNumberPowerFilters; 100184610Salfred} __packed; 101184610Salfred 102184610Salfred#define UCDC_SEND_ENCAPSULATED_COMMAND 0x00 103184610Salfred#define UCDC_GET_ENCAPSULATED_RESPONSE 0x01 104184610Salfred#define UCDC_SET_COMM_FEATURE 0x02 105184610Salfred#define UCDC_GET_COMM_FEATURE 0x03 106184610Salfred#define UCDC_ABSTRACT_STATE 0x01 107184610Salfred#define UCDC_COUNTRY_SETTING 0x02 108184610Salfred#define UCDC_CLEAR_COMM_FEATURE 0x04 109184610Salfred#define UCDC_SET_LINE_CODING 0x20 110184610Salfred#define UCDC_GET_LINE_CODING 0x21 111184610Salfred#define UCDC_SET_CONTROL_LINE_STATE 0x22 112184610Salfred#define UCDC_LINE_DTR 0x0001 113184610Salfred#define UCDC_LINE_RTS 0x0002 114184610Salfred#define UCDC_SEND_BREAK 0x23 115184610Salfred#define UCDC_BREAK_ON 0xffff 116184610Salfred#define UCDC_BREAK_OFF 0x0000 117184610Salfred 118192984Sthompsastruct usb_cdc_abstract_state { 119184610Salfred uWord wState; 120184610Salfred#define UCDC_IDLE_SETTING 0x0001 121184610Salfred#define UCDC_DATA_MULTIPLEXED 0x0002 122184610Salfred} __packed; 123184610Salfred 124184610Salfred#define UCDC_ABSTRACT_STATE_LENGTH 2 125184610Salfred 126192984Sthompsastruct usb_cdc_line_state { 127184610Salfred uDWord dwDTERate; 128184610Salfred uByte bCharFormat; 129184610Salfred#define UCDC_STOP_BIT_1 0 130184610Salfred#define UCDC_STOP_BIT_1_5 1 131184610Salfred#define UCDC_STOP_BIT_2 2 132184610Salfred uByte bParityType; 133184610Salfred#define UCDC_PARITY_NONE 0 134184610Salfred#define UCDC_PARITY_ODD 1 135184610Salfred#define UCDC_PARITY_EVEN 2 136184610Salfred#define UCDC_PARITY_MARK 3 137184610Salfred#define UCDC_PARITY_SPACE 4 138184610Salfred uByte bDataBits; 139184610Salfred} __packed; 140184610Salfred 141184610Salfred#define UCDC_LINE_STATE_LENGTH 7 142184610Salfred 143192984Sthompsastruct usb_cdc_notification { 144184610Salfred uByte bmRequestType; 145184610Salfred#define UCDC_NOTIFICATION 0xa1 146184610Salfred uByte bNotification; 147184610Salfred#define UCDC_N_NETWORK_CONNECTION 0x00 148184610Salfred#define UCDC_N_RESPONSE_AVAILABLE 0x01 149184610Salfred#define UCDC_N_AUX_JACK_HOOK_STATE 0x08 150184610Salfred#define UCDC_N_RING_DETECT 0x09 151184610Salfred#define UCDC_N_SERIAL_STATE 0x20 152184610Salfred#define UCDC_N_CALL_STATE_CHANGED 0x28 153184610Salfred#define UCDC_N_LINE_STATE_CHANGED 0x29 154184610Salfred#define UCDC_N_CONNECTION_SPEED_CHANGE 0x2a 155184610Salfred uWord wValue; 156184610Salfred uWord wIndex; 157184610Salfred uWord wLength; 158184610Salfred uByte data[16]; 159184610Salfred} __packed; 160184610Salfred 161184610Salfred#define UCDC_NOTIFICATION_LENGTH 8 162184610Salfred 163184610Salfred/* 164184610Salfred * Bits set in the SERIAL STATE notifcation (first byte of data) 165184610Salfred */ 166184610Salfred 167184610Salfred#define UCDC_N_SERIAL_OVERRUN 0x40 168184610Salfred#define UCDC_N_SERIAL_PARITY 0x20 169184610Salfred#define UCDC_N_SERIAL_FRAMING 0x10 170184610Salfred#define UCDC_N_SERIAL_RI 0x08 171184610Salfred#define UCDC_N_SERIAL_BREAK 0x04 172184610Salfred#define UCDC_N_SERIAL_DSR 0x02 173184610Salfred#define UCDC_N_SERIAL_DCD 0x01 174184610Salfred 175184610Salfred/* Serial state bit masks */ 176184610Salfred#define UCDC_MDM_RXCARRIER 0x01 177184610Salfred#define UCDC_MDM_TXCARRIER 0x02 178184610Salfred#define UCDC_MDM_BREAK 0x04 179184610Salfred#define UCDC_MDM_RING 0x08 180184610Salfred#define UCDC_MDM_FRAMING_ERR 0x10 181184610Salfred#define UCDC_MDM_PARITY_ERR 0x20 182184610Salfred#define UCDC_MDM_OVERRUN_ERR 0x40 183184610Salfred 184197563Sthompsa/* 185197563Sthompsa * Network Control Model, NCM16 + NCM32, protocol definitions 186197563Sthompsa */ 187197563Sthompsastruct usb_ncm16_hdr { 188197563Sthompsa uDWord dwSignature; 189197563Sthompsa uWord wHeaderLength; 190197563Sthompsa uWord wSequence; 191197563Sthompsa uWord wBlockLength; 192197563Sthompsa uWord wDptIndex; 193197563Sthompsa} __packed; 194197563Sthompsa 195197563Sthompsastruct usb_ncm16_dp { 196197563Sthompsa uWord wFrameIndex; 197197563Sthompsa uWord wFrameLength; 198197563Sthompsa} __packed; 199197563Sthompsa 200197563Sthompsastruct usb_ncm16_dpt { 201197563Sthompsa uDWord dwSignature; 202197563Sthompsa uWord wLength; 203197563Sthompsa uWord wNextNdpIndex; 204197563Sthompsa struct usb_ncm16_dp dp[0]; 205197563Sthompsa} __packed; 206197563Sthompsa 207197563Sthompsastruct usb_ncm32_hdr { 208197563Sthompsa uDWord dwSignature; 209197563Sthompsa uWord wHeaderLength; 210197563Sthompsa uWord wSequence; 211197563Sthompsa uDWord dwBlockLength; 212197563Sthompsa uDWord dwDptIndex; 213197563Sthompsa} __packed; 214197563Sthompsa 215197563Sthompsastruct usb_ncm32_dp { 216197563Sthompsa uDWord dwFrameIndex; 217197563Sthompsa uDWord dwFrameLength; 218197563Sthompsa} __packed; 219197563Sthompsa 220197563Sthompsastruct usb_ncm32_dpt { 221197563Sthompsa uDWord dwSignature; 222197563Sthompsa uWord wLength; 223197563Sthompsa uWord wReserved6; 224197563Sthompsa uDWord dwNextNdpIndex; 225197563Sthompsa uDWord dwReserved12; 226197563Sthompsa struct usb_ncm32_dp dp[0]; 227197563Sthompsa} __packed; 228197563Sthompsa 229197563Sthompsa/* Communications interface class specific descriptors */ 230197563Sthompsa 231197563Sthompsa#define UCDC_NCM_FUNC_DESC_SUBTYPE 0x1A 232197563Sthompsa 233197563Sthompsastruct usb_ncm_func_descriptor { 234197563Sthompsa uByte bLength; 235197563Sthompsa uByte bDescriptorType; 236197563Sthompsa uByte bDescriptorSubtype; 237197563Sthompsa uByte bcdNcmVersion[2]; 238197563Sthompsa uByte bmNetworkCapabilities; 239197563Sthompsa#define UCDC_NCM_CAP_FILTER 0x01 240197563Sthompsa#define UCDC_NCM_CAP_MAC_ADDR 0x02 241197563Sthompsa#define UCDC_NCM_CAP_ENCAP 0x04 242197563Sthompsa#define UCDC_NCM_CAP_MAX_DATA 0x08 243197563Sthompsa#define UCDC_NCM_CAP_CRCMODE 0x10 244213809Shselasky#define UCDC_NCM_CAP_MAX_DGRAM 0x20 245197563Sthompsa} __packed; 246197563Sthompsa 247197563Sthompsa/* Communications interface specific class request codes */ 248197563Sthompsa 249197563Sthompsa#define UCDC_NCM_SET_ETHERNET_MULTICAST_FILTERS 0x40 250197563Sthompsa#define UCDC_NCM_SET_ETHERNET_POWER_MGMT_PATTERN_FILTER 0x41 251197563Sthompsa#define UCDC_NCM_GET_ETHERNET_POWER_MGMT_PATTERN_FILTER 0x42 252197563Sthompsa#define UCDC_NCM_SET_ETHERNET_PACKET_FILTER 0x43 253197563Sthompsa#define UCDC_NCM_GET_ETHERNET_STATISTIC 0x44 254197563Sthompsa#define UCDC_NCM_GET_NTB_PARAMETERS 0x80 255197563Sthompsa#define UCDC_NCM_GET_NET_ADDRESS 0x81 256197563Sthompsa#define UCDC_NCM_SET_NET_ADDRESS 0x82 257197563Sthompsa#define UCDC_NCM_GET_NTB_FORMAT 0x83 258197563Sthompsa#define UCDC_NCM_SET_NTB_FORMAT 0x84 259197563Sthompsa#define UCDC_NCM_GET_NTB_INPUT_SIZE 0x85 260197563Sthompsa#define UCDC_NCM_SET_NTB_INPUT_SIZE 0x86 261197563Sthompsa#define UCDC_NCM_GET_MAX_DATAGRAM_SIZE 0x87 262197563Sthompsa#define UCDC_NCM_SET_MAX_DATAGRAM_SIZE 0x88 263197563Sthompsa#define UCDC_NCM_GET_CRC_MODE 0x89 264197563Sthompsa#define UCDC_NCM_SET_CRC_MODE 0x8A 265197563Sthompsa 266197563Sthompsastruct usb_ncm_parameters { 267197563Sthompsa uWord wLength; 268197563Sthompsa uWord bmNtbFormatsSupported; 269197563Sthompsa#define UCDC_NCM_FORMAT_NTB16 0x0001 270197563Sthompsa#define UCDC_NCM_FORMAT_NTB32 0x0002 271197563Sthompsa uDWord dwNtbInMaxSize; 272197563Sthompsa uWord wNdpInDivisor; 273197563Sthompsa uWord wNdpInPayloadRemainder; 274197563Sthompsa uWord wNdpInAlignment; 275197563Sthompsa uWord wReserved14; 276197563Sthompsa uDWord dwNtbOutMaxSize; 277197563Sthompsa uWord wNdpOutDivisor; 278197563Sthompsa uWord wNdpOutPayloadRemainder; 279197563Sthompsa uWord wNdpOutAlignment; 280213809Shselasky uWord wNtbOutMaxDatagrams; 281197563Sthompsa} __packed; 282197563Sthompsa 283197563Sthompsa/* Communications interface specific class notification codes */ 284197563Sthompsa#define UCDC_NCM_NOTIF_NETWORK_CONNECTION 0x00 285197563Sthompsa#define UCDC_NCM_NOTIF_RESPONSE_AVAILABLE 0x01 286197563Sthompsa#define UCDC_NCM_NOTIF_CONNECTION_SPEED_CHANGE 0x2A 287197563Sthompsa 288184610Salfred#endif /* _USB_CDC_H_ */ 289