102ac6454SAndrew Thompson /* $NetBSD: usbcdc.h,v 1.9 2004/10/23 13:24:24 augustss Exp $ */ 202ac6454SAndrew Thompson 302ac6454SAndrew Thompson /*- 4*b61a5730SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 5718cf2ccSPedro F. Giffuni * 602ac6454SAndrew Thompson * Copyright (c) 1998 The NetBSD Foundation, Inc. 702ac6454SAndrew Thompson * All rights reserved. 802ac6454SAndrew Thompson * 902ac6454SAndrew Thompson * This code is derived from software contributed to The NetBSD Foundation 1002ac6454SAndrew Thompson * by Lennart Augustsson (lennart@augustsson.net) at 1102ac6454SAndrew Thompson * Carlstedt Research & Technology. 1202ac6454SAndrew Thompson * 1302ac6454SAndrew Thompson * Redistribution and use in source and binary forms, with or without 1402ac6454SAndrew Thompson * modification, are permitted provided that the following conditions 1502ac6454SAndrew Thompson * are met: 1602ac6454SAndrew Thompson * 1. Redistributions of source code must retain the above copyright 1702ac6454SAndrew Thompson * notice, this list of conditions and the following disclaimer. 1802ac6454SAndrew Thompson * 2. Redistributions in binary form must reproduce the above copyright 1902ac6454SAndrew Thompson * notice, this list of conditions and the following disclaimer in the 2002ac6454SAndrew Thompson * documentation and/or other materials provided with the distribution. 2102ac6454SAndrew Thompson * 2202ac6454SAndrew Thompson * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 2302ac6454SAndrew Thompson * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 2402ac6454SAndrew Thompson * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2502ac6454SAndrew Thompson * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 2602ac6454SAndrew Thompson * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2702ac6454SAndrew Thompson * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2802ac6454SAndrew Thompson * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2902ac6454SAndrew Thompson * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 3002ac6454SAndrew Thompson * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 3102ac6454SAndrew Thompson * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 3202ac6454SAndrew Thompson * POSSIBILITY OF SUCH DAMAGE. 3302ac6454SAndrew Thompson */ 3402ac6454SAndrew Thompson 3502ac6454SAndrew Thompson #ifndef _USB_CDC_H_ 3602ac6454SAndrew Thompson #define _USB_CDC_H_ 3702ac6454SAndrew Thompson 3802ac6454SAndrew Thompson #define UDESCSUB_CDC_HEADER 0 3902ac6454SAndrew Thompson #define UDESCSUB_CDC_CM 1 /* Call Management */ 4002ac6454SAndrew Thompson #define UDESCSUB_CDC_ACM 2 /* Abstract Control Model */ 4102ac6454SAndrew Thompson #define UDESCSUB_CDC_DLM 3 /* Direct Line Management */ 4202ac6454SAndrew Thompson #define UDESCSUB_CDC_TRF 4 /* Telephone Ringer */ 4302ac6454SAndrew Thompson #define UDESCSUB_CDC_TCLSR 5 /* Telephone Call */ 4402ac6454SAndrew Thompson #define UDESCSUB_CDC_UNION 6 4502ac6454SAndrew Thompson #define UDESCSUB_CDC_CS 7 /* Country Selection */ 4602ac6454SAndrew Thompson #define UDESCSUB_CDC_TOM 8 /* Telephone Operational Modes */ 4702ac6454SAndrew Thompson #define UDESCSUB_CDC_USBT 9 /* USB Terminal */ 4802ac6454SAndrew Thompson #define UDESCSUB_CDC_NCT 10 4902ac6454SAndrew Thompson #define UDESCSUB_CDC_PUF 11 5002ac6454SAndrew Thompson #define UDESCSUB_CDC_EUF 12 5102ac6454SAndrew Thompson #define UDESCSUB_CDC_MCMF 13 5202ac6454SAndrew Thompson #define UDESCSUB_CDC_CCMF 14 5302ac6454SAndrew Thompson #define UDESCSUB_CDC_ENF 15 5402ac6454SAndrew Thompson #define UDESCSUB_CDC_ANF 16 5502ac6454SAndrew Thompson 56760bc48eSAndrew Thompson struct usb_cdc_header_descriptor { 5702ac6454SAndrew Thompson uByte bLength; 5802ac6454SAndrew Thompson uByte bDescriptorType; 5902ac6454SAndrew Thompson uByte bDescriptorSubtype; 6002ac6454SAndrew Thompson uWord bcdCDC; 6102ac6454SAndrew Thompson } __packed; 6202ac6454SAndrew Thompson 63760bc48eSAndrew Thompson struct usb_cdc_cm_descriptor { 6402ac6454SAndrew Thompson uByte bLength; 6502ac6454SAndrew Thompson uByte bDescriptorType; 6602ac6454SAndrew Thompson uByte bDescriptorSubtype; 6702ac6454SAndrew Thompson uByte bmCapabilities; 6802ac6454SAndrew Thompson #define USB_CDC_CM_DOES_CM 0x01 6902ac6454SAndrew Thompson #define USB_CDC_CM_OVER_DATA 0x02 7002ac6454SAndrew Thompson uByte bDataInterface; 7102ac6454SAndrew Thompson } __packed; 7202ac6454SAndrew Thompson 73760bc48eSAndrew Thompson struct usb_cdc_acm_descriptor { 7402ac6454SAndrew Thompson uByte bLength; 7502ac6454SAndrew Thompson uByte bDescriptorType; 7602ac6454SAndrew Thompson uByte bDescriptorSubtype; 7702ac6454SAndrew Thompson uByte bmCapabilities; 7802ac6454SAndrew Thompson #define USB_CDC_ACM_HAS_FEATURE 0x01 7902ac6454SAndrew Thompson #define USB_CDC_ACM_HAS_LINE 0x02 8002ac6454SAndrew Thompson #define USB_CDC_ACM_HAS_BREAK 0x04 8102ac6454SAndrew Thompson #define USB_CDC_ACM_HAS_NETWORK_CONN 0x08 8202ac6454SAndrew Thompson } __packed; 8302ac6454SAndrew Thompson 84760bc48eSAndrew Thompson struct usb_cdc_union_descriptor { 8502ac6454SAndrew Thompson uByte bLength; 8602ac6454SAndrew Thompson uByte bDescriptorType; 8702ac6454SAndrew Thompson uByte bDescriptorSubtype; 8802ac6454SAndrew Thompson uByte bMasterInterface; 8902ac6454SAndrew Thompson uByte bSlaveInterface[1]; 9002ac6454SAndrew Thompson } __packed; 9102ac6454SAndrew Thompson 92760bc48eSAndrew Thompson struct usb_cdc_ethernet_descriptor { 9302ac6454SAndrew Thompson uByte bLength; 9402ac6454SAndrew Thompson uByte bDescriptorType; 9502ac6454SAndrew Thompson uByte bDescriptorSubtype; 9602ac6454SAndrew Thompson uByte iMacAddress; 9702ac6454SAndrew Thompson uDWord bmEthernetStatistics; 9802ac6454SAndrew Thompson uWord wMaxSegmentSize; 9902ac6454SAndrew Thompson uWord wNumberMCFilters; 10002ac6454SAndrew Thompson uByte bNumberPowerFilters; 10102ac6454SAndrew Thompson } __packed; 10202ac6454SAndrew Thompson 10302ac6454SAndrew Thompson #define UCDC_SEND_ENCAPSULATED_COMMAND 0x00 10402ac6454SAndrew Thompson #define UCDC_GET_ENCAPSULATED_RESPONSE 0x01 10502ac6454SAndrew Thompson #define UCDC_SET_COMM_FEATURE 0x02 10602ac6454SAndrew Thompson #define UCDC_GET_COMM_FEATURE 0x03 10702ac6454SAndrew Thompson #define UCDC_ABSTRACT_STATE 0x01 10802ac6454SAndrew Thompson #define UCDC_COUNTRY_SETTING 0x02 10902ac6454SAndrew Thompson #define UCDC_CLEAR_COMM_FEATURE 0x04 11002ac6454SAndrew Thompson #define UCDC_SET_LINE_CODING 0x20 11102ac6454SAndrew Thompson #define UCDC_GET_LINE_CODING 0x21 11202ac6454SAndrew Thompson #define UCDC_SET_CONTROL_LINE_STATE 0x22 11302ac6454SAndrew Thompson #define UCDC_LINE_DTR 0x0001 11402ac6454SAndrew Thompson #define UCDC_LINE_RTS 0x0002 11502ac6454SAndrew Thompson #define UCDC_SEND_BREAK 0x23 11602ac6454SAndrew Thompson #define UCDC_BREAK_ON 0xffff 11702ac6454SAndrew Thompson #define UCDC_BREAK_OFF 0x0000 11802ac6454SAndrew Thompson 119760bc48eSAndrew Thompson struct usb_cdc_abstract_state { 12002ac6454SAndrew Thompson uWord wState; 12102ac6454SAndrew Thompson #define UCDC_IDLE_SETTING 0x0001 12202ac6454SAndrew Thompson #define UCDC_DATA_MULTIPLEXED 0x0002 12302ac6454SAndrew Thompson } __packed; 12402ac6454SAndrew Thompson 12502ac6454SAndrew Thompson #define UCDC_ABSTRACT_STATE_LENGTH 2 12602ac6454SAndrew Thompson 127760bc48eSAndrew Thompson struct usb_cdc_line_state { 12802ac6454SAndrew Thompson uDWord dwDTERate; 12902ac6454SAndrew Thompson uByte bCharFormat; 13002ac6454SAndrew Thompson #define UCDC_STOP_BIT_1 0 13102ac6454SAndrew Thompson #define UCDC_STOP_BIT_1_5 1 13202ac6454SAndrew Thompson #define UCDC_STOP_BIT_2 2 13302ac6454SAndrew Thompson uByte bParityType; 13402ac6454SAndrew Thompson #define UCDC_PARITY_NONE 0 13502ac6454SAndrew Thompson #define UCDC_PARITY_ODD 1 13602ac6454SAndrew Thompson #define UCDC_PARITY_EVEN 2 13702ac6454SAndrew Thompson #define UCDC_PARITY_MARK 3 13802ac6454SAndrew Thompson #define UCDC_PARITY_SPACE 4 13902ac6454SAndrew Thompson uByte bDataBits; 14002ac6454SAndrew Thompson } __packed; 14102ac6454SAndrew Thompson 14202ac6454SAndrew Thompson #define UCDC_LINE_STATE_LENGTH 7 14302ac6454SAndrew Thompson 144760bc48eSAndrew Thompson struct usb_cdc_notification { 14502ac6454SAndrew Thompson uByte bmRequestType; 14602ac6454SAndrew Thompson #define UCDC_NOTIFICATION 0xa1 14702ac6454SAndrew Thompson uByte bNotification; 14802ac6454SAndrew Thompson #define UCDC_N_NETWORK_CONNECTION 0x00 14902ac6454SAndrew Thompson #define UCDC_N_RESPONSE_AVAILABLE 0x01 15002ac6454SAndrew Thompson #define UCDC_N_AUX_JACK_HOOK_STATE 0x08 15102ac6454SAndrew Thompson #define UCDC_N_RING_DETECT 0x09 15202ac6454SAndrew Thompson #define UCDC_N_SERIAL_STATE 0x20 15302ac6454SAndrew Thompson #define UCDC_N_CALL_STATE_CHANGED 0x28 15402ac6454SAndrew Thompson #define UCDC_N_LINE_STATE_CHANGED 0x29 15502ac6454SAndrew Thompson #define UCDC_N_CONNECTION_SPEED_CHANGE 0x2a 15602ac6454SAndrew Thompson uWord wValue; 15702ac6454SAndrew Thompson uWord wIndex; 15802ac6454SAndrew Thompson uWord wLength; 15902ac6454SAndrew Thompson uByte data[16]; 16002ac6454SAndrew Thompson } __packed; 16102ac6454SAndrew Thompson 16202ac6454SAndrew Thompson #define UCDC_NOTIFICATION_LENGTH 8 16302ac6454SAndrew Thompson 16402ac6454SAndrew Thompson /* 16520733245SPedro F. Giffuni * Bits set in the SERIAL STATE notification (first byte of data) 16602ac6454SAndrew Thompson */ 16702ac6454SAndrew Thompson 16802ac6454SAndrew Thompson #define UCDC_N_SERIAL_OVERRUN 0x40 16902ac6454SAndrew Thompson #define UCDC_N_SERIAL_PARITY 0x20 17002ac6454SAndrew Thompson #define UCDC_N_SERIAL_FRAMING 0x10 17102ac6454SAndrew Thompson #define UCDC_N_SERIAL_RI 0x08 17202ac6454SAndrew Thompson #define UCDC_N_SERIAL_BREAK 0x04 17302ac6454SAndrew Thompson #define UCDC_N_SERIAL_DSR 0x02 17402ac6454SAndrew Thompson #define UCDC_N_SERIAL_DCD 0x01 17502ac6454SAndrew Thompson 17602ac6454SAndrew Thompson /* Serial state bit masks */ 17702ac6454SAndrew Thompson #define UCDC_MDM_RXCARRIER 0x01 17802ac6454SAndrew Thompson #define UCDC_MDM_TXCARRIER 0x02 17902ac6454SAndrew Thompson #define UCDC_MDM_BREAK 0x04 18002ac6454SAndrew Thompson #define UCDC_MDM_RING 0x08 18102ac6454SAndrew Thompson #define UCDC_MDM_FRAMING_ERR 0x10 18202ac6454SAndrew Thompson #define UCDC_MDM_PARITY_ERR 0x20 18302ac6454SAndrew Thompson #define UCDC_MDM_OVERRUN_ERR 0x40 18402ac6454SAndrew Thompson 1854076dd23SAndrew Thompson /* 1864076dd23SAndrew Thompson * Network Control Model, NCM16 + NCM32, protocol definitions 1874076dd23SAndrew Thompson */ 1884076dd23SAndrew Thompson struct usb_ncm16_hdr { 1894076dd23SAndrew Thompson uDWord dwSignature; 1904076dd23SAndrew Thompson uWord wHeaderLength; 1914076dd23SAndrew Thompson uWord wSequence; 1924076dd23SAndrew Thompson uWord wBlockLength; 1934076dd23SAndrew Thompson uWord wDptIndex; 1944076dd23SAndrew Thompson } __packed; 1954076dd23SAndrew Thompson 1964076dd23SAndrew Thompson struct usb_ncm16_dp { 1974076dd23SAndrew Thompson uWord wFrameIndex; 1984076dd23SAndrew Thompson uWord wFrameLength; 1994076dd23SAndrew Thompson } __packed; 2004076dd23SAndrew Thompson 2014076dd23SAndrew Thompson struct usb_ncm16_dpt { 2024076dd23SAndrew Thompson uDWord dwSignature; 2034076dd23SAndrew Thompson uWord wLength; 2044076dd23SAndrew Thompson uWord wNextNdpIndex; 2054076dd23SAndrew Thompson struct usb_ncm16_dp dp[0]; 2064076dd23SAndrew Thompson } __packed; 2074076dd23SAndrew Thompson 2084076dd23SAndrew Thompson struct usb_ncm32_hdr { 2094076dd23SAndrew Thompson uDWord dwSignature; 2104076dd23SAndrew Thompson uWord wHeaderLength; 2114076dd23SAndrew Thompson uWord wSequence; 2124076dd23SAndrew Thompson uDWord dwBlockLength; 2134076dd23SAndrew Thompson uDWord dwDptIndex; 2144076dd23SAndrew Thompson } __packed; 2154076dd23SAndrew Thompson 2164076dd23SAndrew Thompson struct usb_ncm32_dp { 2174076dd23SAndrew Thompson uDWord dwFrameIndex; 2184076dd23SAndrew Thompson uDWord dwFrameLength; 2194076dd23SAndrew Thompson } __packed; 2204076dd23SAndrew Thompson 2214076dd23SAndrew Thompson struct usb_ncm32_dpt { 2224076dd23SAndrew Thompson uDWord dwSignature; 2234076dd23SAndrew Thompson uWord wLength; 2244076dd23SAndrew Thompson uWord wReserved6; 2254076dd23SAndrew Thompson uDWord dwNextNdpIndex; 2264076dd23SAndrew Thompson uDWord dwReserved12; 2274076dd23SAndrew Thompson struct usb_ncm32_dp dp[0]; 2284076dd23SAndrew Thompson } __packed; 2294076dd23SAndrew Thompson 2304076dd23SAndrew Thompson /* Communications interface class specific descriptors */ 2314076dd23SAndrew Thompson 2324076dd23SAndrew Thompson #define UCDC_NCM_FUNC_DESC_SUBTYPE 0x1A 2334076dd23SAndrew Thompson 2344076dd23SAndrew Thompson struct usb_ncm_func_descriptor { 2354076dd23SAndrew Thompson uByte bLength; 2364076dd23SAndrew Thompson uByte bDescriptorType; 2374076dd23SAndrew Thompson uByte bDescriptorSubtype; 2384076dd23SAndrew Thompson uByte bcdNcmVersion[2]; 2394076dd23SAndrew Thompson uByte bmNetworkCapabilities; 2404076dd23SAndrew Thompson #define UCDC_NCM_CAP_FILTER 0x01 2414076dd23SAndrew Thompson #define UCDC_NCM_CAP_MAC_ADDR 0x02 2424076dd23SAndrew Thompson #define UCDC_NCM_CAP_ENCAP 0x04 2434076dd23SAndrew Thompson #define UCDC_NCM_CAP_MAX_DATA 0x08 2444076dd23SAndrew Thompson #define UCDC_NCM_CAP_CRCMODE 0x10 2457e05daaeSHans Petter Selasky #define UCDC_NCM_CAP_MAX_DGRAM 0x20 2464076dd23SAndrew Thompson } __packed; 2474076dd23SAndrew Thompson 2484076dd23SAndrew Thompson /* Communications interface specific class request codes */ 2494076dd23SAndrew Thompson 2504076dd23SAndrew Thompson #define UCDC_NCM_SET_ETHERNET_MULTICAST_FILTERS 0x40 2514076dd23SAndrew Thompson #define UCDC_NCM_SET_ETHERNET_POWER_MGMT_PATTERN_FILTER 0x41 2524076dd23SAndrew Thompson #define UCDC_NCM_GET_ETHERNET_POWER_MGMT_PATTERN_FILTER 0x42 2534076dd23SAndrew Thompson #define UCDC_NCM_SET_ETHERNET_PACKET_FILTER 0x43 2544076dd23SAndrew Thompson #define UCDC_NCM_GET_ETHERNET_STATISTIC 0x44 2554076dd23SAndrew Thompson #define UCDC_NCM_GET_NTB_PARAMETERS 0x80 2564076dd23SAndrew Thompson #define UCDC_NCM_GET_NET_ADDRESS 0x81 2574076dd23SAndrew Thompson #define UCDC_NCM_SET_NET_ADDRESS 0x82 2584076dd23SAndrew Thompson #define UCDC_NCM_GET_NTB_FORMAT 0x83 2594076dd23SAndrew Thompson #define UCDC_NCM_SET_NTB_FORMAT 0x84 2604076dd23SAndrew Thompson #define UCDC_NCM_GET_NTB_INPUT_SIZE 0x85 2614076dd23SAndrew Thompson #define UCDC_NCM_SET_NTB_INPUT_SIZE 0x86 2624076dd23SAndrew Thompson #define UCDC_NCM_GET_MAX_DATAGRAM_SIZE 0x87 2634076dd23SAndrew Thompson #define UCDC_NCM_SET_MAX_DATAGRAM_SIZE 0x88 2644076dd23SAndrew Thompson #define UCDC_NCM_GET_CRC_MODE 0x89 2654076dd23SAndrew Thompson #define UCDC_NCM_SET_CRC_MODE 0x8A 2664076dd23SAndrew Thompson 2674076dd23SAndrew Thompson struct usb_ncm_parameters { 2684076dd23SAndrew Thompson uWord wLength; 2694076dd23SAndrew Thompson uWord bmNtbFormatsSupported; 2704076dd23SAndrew Thompson #define UCDC_NCM_FORMAT_NTB16 0x0001 2714076dd23SAndrew Thompson #define UCDC_NCM_FORMAT_NTB32 0x0002 2724076dd23SAndrew Thompson uDWord dwNtbInMaxSize; 2734076dd23SAndrew Thompson uWord wNdpInDivisor; 2744076dd23SAndrew Thompson uWord wNdpInPayloadRemainder; 2754076dd23SAndrew Thompson uWord wNdpInAlignment; 2764076dd23SAndrew Thompson uWord wReserved14; 2774076dd23SAndrew Thompson uDWord dwNtbOutMaxSize; 2784076dd23SAndrew Thompson uWord wNdpOutDivisor; 2794076dd23SAndrew Thompson uWord wNdpOutPayloadRemainder; 2804076dd23SAndrew Thompson uWord wNdpOutAlignment; 2817e05daaeSHans Petter Selasky uWord wNtbOutMaxDatagrams; 2824076dd23SAndrew Thompson } __packed; 2834076dd23SAndrew Thompson 2844076dd23SAndrew Thompson /* Communications interface specific class notification codes */ 2854076dd23SAndrew Thompson #define UCDC_NCM_NOTIF_NETWORK_CONNECTION 0x00 2864076dd23SAndrew Thompson #define UCDC_NCM_NOTIF_RESPONSE_AVAILABLE 0x01 2874076dd23SAndrew Thompson #define UCDC_NCM_NOTIF_CONNECTION_SPEED_CHANGE 0x2A 2884076dd23SAndrew Thompson 28902ac6454SAndrew Thompson #endif /* _USB_CDC_H_ */ 290