102ac6454SAndrew Thompson /*- 24d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 3718cf2ccSPedro F. Giffuni * 402ac6454SAndrew Thompson * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 502ac6454SAndrew Thompson * Copyright (c) 1998 The NetBSD Foundation, Inc. All rights reserved. 602ac6454SAndrew Thompson * Copyright (c) 1998 Lennart Augustsson. All rights reserved. 702ac6454SAndrew Thompson * 802ac6454SAndrew Thompson * Redistribution and use in source and binary forms, with or without 902ac6454SAndrew Thompson * modification, are permitted provided that the following conditions 1002ac6454SAndrew Thompson * are met: 1102ac6454SAndrew Thompson * 1. Redistributions of source code must retain the above copyright 1202ac6454SAndrew Thompson * notice, this list of conditions and the following disclaimer. 1302ac6454SAndrew Thompson * 2. Redistributions in binary form must reproduce the above copyright 1402ac6454SAndrew Thompson * notice, this list of conditions and the following disclaimer in the 1502ac6454SAndrew Thompson * documentation and/or other materials provided with the distribution. 1602ac6454SAndrew Thompson * 1702ac6454SAndrew Thompson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1802ac6454SAndrew Thompson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1902ac6454SAndrew Thompson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2002ac6454SAndrew Thompson * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2102ac6454SAndrew Thompson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2202ac6454SAndrew Thompson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2302ac6454SAndrew Thompson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2402ac6454SAndrew Thompson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2502ac6454SAndrew Thompson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2602ac6454SAndrew Thompson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2702ac6454SAndrew Thompson * SUCH DAMAGE. 2802ac6454SAndrew Thompson */ 2902ac6454SAndrew Thompson 3075973647SAndrew Thompson #ifndef _USB_IOCTL_H_ 3175973647SAndrew Thompson #define _USB_IOCTL_H_ 3202ac6454SAndrew Thompson 33d2b99310SHans Petter Selasky #ifndef USB_GLOBAL_INCLUDE_FILE 3402ac6454SAndrew Thompson #include <sys/ioccom.h> 3562a963c5SHans Petter Selasky #include <sys/cdefs.h> 3602ac6454SAndrew Thompson 3702ac6454SAndrew Thompson /* Building "kdump" depends on these includes */ 3802ac6454SAndrew Thompson 3902ac6454SAndrew Thompson #include <dev/usb/usb_endian.h> 4002ac6454SAndrew Thompson #include <dev/usb/usb.h> 41d2b99310SHans Petter Selasky #endif 4202ac6454SAndrew Thompson 43ee3e3ff5SAndrew Thompson #define USB_DEVICE_NAME "usbctl" 44ee3e3ff5SAndrew Thompson #define USB_DEVICE_DIR "usb" 4502ac6454SAndrew Thompson #define USB_GENERIC_NAME "ugen" 46399e6543SHans Petter Selasky #define USB_TEMPLATE_SYSCTL "hw.usb.template" /* integer type */ 47399e6543SHans Petter Selasky 48399e6543SHans Petter Selasky /* Definition of valid template sysctl values */ 49399e6543SHans Petter Selasky 50399e6543SHans Petter Selasky enum { 51399e6543SHans Petter Selasky USB_TEMP_MSC, /* USB Mass Storage */ 52399e6543SHans Petter Selasky USB_TEMP_CDCE, /* USB CDC Ethernet */ 53399e6543SHans Petter Selasky USB_TEMP_MTP, /* Message Transfer Protocol */ 54399e6543SHans Petter Selasky USB_TEMP_MODEM, /* USB CDC Modem */ 55399e6543SHans Petter Selasky USB_TEMP_AUDIO, /* USB Audio */ 56399e6543SHans Petter Selasky USB_TEMP_KBD, /* USB Keyboard */ 57399e6543SHans Petter Selasky USB_TEMP_MOUSE, /* USB Mouse */ 58f9478f91SHans Petter Selasky USB_TEMP_PHONE, /* USB Phone */ 593e420a3eSRuslan Bukin USB_TEMP_SERIALNET, /* USB CDC Ethernet and Modem */ 600a76fe7cSHans Petter Selasky USB_TEMP_MIDI, /* USB MIDI */ 613dc87e52SEdward Tomasz Napierala USB_TEMP_MULTI, /* USB Ethernet, serial, and storage */ 6263722e52SEdward Tomasz Napierala USB_TEMP_CDCEEM, /* USB Ethernet Emulation Model */ 63399e6543SHans Petter Selasky USB_TEMP_MAX, 64399e6543SHans Petter Selasky }; 6502ac6454SAndrew Thompson 66760bc48eSAndrew Thompson struct usb_read_dir { 6702ac6454SAndrew Thompson void *urd_data; 6802ac6454SAndrew Thompson uint32_t urd_startentry; 6902ac6454SAndrew Thompson uint32_t urd_maxlen; 70ea972feeSBrooks Davis }; 7102ac6454SAndrew Thompson 72760bc48eSAndrew Thompson struct usb_ctl_request { 7302ac6454SAndrew Thompson void *ucr_data; 7402ac6454SAndrew Thompson uint16_t ucr_flags; 7502ac6454SAndrew Thompson uint16_t ucr_actlen; /* actual length transferred */ 7602ac6454SAndrew Thompson uint8_t ucr_addr; /* zero - currently not used */ 77760bc48eSAndrew Thompson struct usb_device_request ucr_request; 78ea972feeSBrooks Davis }; 7902ac6454SAndrew Thompson 80760bc48eSAndrew Thompson struct usb_alt_interface { 8102ac6454SAndrew Thompson uint8_t uai_interface_index; 8202ac6454SAndrew Thompson uint8_t uai_alt_index; 83ea972feeSBrooks Davis }; 8402ac6454SAndrew Thompson 85760bc48eSAndrew Thompson struct usb_gen_descriptor { 8602ac6454SAndrew Thompson void *ugd_data; 8702ac6454SAndrew Thompson uint16_t ugd_lang_id; 8802ac6454SAndrew Thompson uint16_t ugd_maxlen; 8902ac6454SAndrew Thompson uint16_t ugd_actlen; 9002ac6454SAndrew Thompson uint16_t ugd_offset; 9102ac6454SAndrew Thompson uint8_t ugd_config_index; 9202ac6454SAndrew Thompson uint8_t ugd_string_index; 9302ac6454SAndrew Thompson uint8_t ugd_iface_index; 9402ac6454SAndrew Thompson uint8_t ugd_altif_index; 9502ac6454SAndrew Thompson uint8_t ugd_endpt_index; 9602ac6454SAndrew Thompson uint8_t ugd_report_type; 9702ac6454SAndrew Thompson uint8_t reserved[8]; 98ea972feeSBrooks Davis }; 9902ac6454SAndrew Thompson 100760bc48eSAndrew Thompson struct usb_device_info { 10102ac6454SAndrew Thompson uint16_t udi_productNo; 10202ac6454SAndrew Thompson uint16_t udi_vendorNo; 10302ac6454SAndrew Thompson uint16_t udi_releaseNo; 10402ac6454SAndrew Thompson uint16_t udi_power; /* power consumption in mA, 0 if 10502ac6454SAndrew Thompson * selfpowered */ 10602ac6454SAndrew Thompson uint8_t udi_bus; 10702ac6454SAndrew Thompson uint8_t udi_addr; /* device address */ 10802ac6454SAndrew Thompson uint8_t udi_index; /* device index */ 10902ac6454SAndrew Thompson uint8_t udi_class; 11002ac6454SAndrew Thompson uint8_t udi_subclass; 11102ac6454SAndrew Thompson uint8_t udi_protocol; 11202ac6454SAndrew Thompson uint8_t udi_config_no; /* current config number */ 11302ac6454SAndrew Thompson uint8_t udi_config_index; /* current config index */ 11402ac6454SAndrew Thompson uint8_t udi_speed; /* see "USB_SPEED_XXX" */ 11502ac6454SAndrew Thompson uint8_t udi_mode; /* see "USB_MODE_XXX" */ 11602ac6454SAndrew Thompson uint8_t udi_nports; 11702ac6454SAndrew Thompson uint8_t udi_hubaddr; /* parent HUB address */ 11802ac6454SAndrew Thompson uint8_t udi_hubindex; /* parent HUB device index */ 11902ac6454SAndrew Thompson uint8_t udi_hubport; /* parent HUB port */ 12002ac6454SAndrew Thompson uint8_t udi_power_mode; /* see "USB_POWER_MODE_XXX" */ 12102ac6454SAndrew Thompson uint8_t udi_suspended; /* set if device is suspended */ 122*f1d955beSVladimir Kondratyev uint16_t udi_bustypeNo; 123*f1d955beSVladimir Kondratyev uint8_t udi_reserved[14]; /* leave space for the future */ 12402ac6454SAndrew Thompson char udi_product[128]; 12502ac6454SAndrew Thompson char udi_vendor[128]; 12602ac6454SAndrew Thompson char udi_serial[64]; 12702ac6454SAndrew Thompson char udi_release[8]; 128ea972feeSBrooks Davis }; 12902ac6454SAndrew Thompson 130c77a24c2SHans Petter Selasky #define USB_DEVICE_PORT_PATH_MAX 32 131c77a24c2SHans Petter Selasky 132c77a24c2SHans Petter Selasky struct usb_device_port_path { 133c77a24c2SHans Petter Selasky uint8_t udp_bus; /* which bus we are on */ 134c77a24c2SHans Petter Selasky uint8_t udp_index; /* which device index */ 135c77a24c2SHans Petter Selasky uint8_t udp_port_level; /* how many levels: 0, 1, 2 ... */ 136c77a24c2SHans Petter Selasky uint8_t udp_port_no[USB_DEVICE_PORT_PATH_MAX]; 137ea972feeSBrooks Davis }; 138c77a24c2SHans Petter Selasky 139760bc48eSAndrew Thompson struct usb_device_stats { 14002ac6454SAndrew Thompson uint32_t uds_requests_ok[4]; /* Indexed by transfer type UE_XXX */ 14102ac6454SAndrew Thompson uint32_t uds_requests_fail[4]; /* Indexed by transfer type UE_XXX */ 142ea972feeSBrooks Davis }; 14302ac6454SAndrew Thompson 144760bc48eSAndrew Thompson struct usb_fs_start { 14502ac6454SAndrew Thompson uint8_t ep_index; 146ea972feeSBrooks Davis }; 14702ac6454SAndrew Thompson 148760bc48eSAndrew Thompson struct usb_fs_stop { 14902ac6454SAndrew Thompson uint8_t ep_index; 150ea972feeSBrooks Davis }; 15102ac6454SAndrew Thompson 152760bc48eSAndrew Thompson struct usb_fs_complete { 15302ac6454SAndrew Thompson uint8_t ep_index; 154ea972feeSBrooks Davis }; 15502ac6454SAndrew Thompson 15602ac6454SAndrew Thompson /* This structure is used for all endpoint types */ 157760bc48eSAndrew Thompson struct usb_fs_endpoint { 15802ac6454SAndrew Thompson /* 15902ac6454SAndrew Thompson * NOTE: isochronous USB transfer only use one buffer, but can have 16002ac6454SAndrew Thompson * multiple frame lengths ! 16102ac6454SAndrew Thompson */ 16202ac6454SAndrew Thompson void **ppBuffer; /* pointer to userland buffers */ 16302ac6454SAndrew Thompson uint32_t *pLength; /* pointer to frame lengths, updated 16402ac6454SAndrew Thompson * to actual length */ 16502ac6454SAndrew Thompson uint32_t nFrames; /* number of frames */ 16602ac6454SAndrew Thompson uint32_t aFrames; /* actual number of frames */ 16702ac6454SAndrew Thompson uint16_t flags; 16802ac6454SAndrew Thompson /* a single short frame will terminate */ 16902ac6454SAndrew Thompson #define USB_FS_FLAG_SINGLE_SHORT_OK 0x0001 17002ac6454SAndrew Thompson /* multiple short frames are allowed */ 17102ac6454SAndrew Thompson #define USB_FS_FLAG_MULTI_SHORT_OK 0x0002 17202ac6454SAndrew Thompson /* all frame(s) transmitted are short terminated */ 17302ac6454SAndrew Thompson #define USB_FS_FLAG_FORCE_SHORT 0x0004 17402ac6454SAndrew Thompson /* will do a clear-stall before xfer */ 17502ac6454SAndrew Thompson #define USB_FS_FLAG_CLEAR_STALL 0x0008 17602ac6454SAndrew Thompson uint16_t timeout; /* in milliseconds */ 17702ac6454SAndrew Thompson /* isocronous completion time in milliseconds - used for echo cancel */ 17802ac6454SAndrew Thompson uint16_t isoc_time_complete; 17902ac6454SAndrew Thompson /* timeout value for no timeout */ 18002ac6454SAndrew Thompson #define USB_FS_TIMEOUT_NONE 0 181ed6d949aSAndrew Thompson int status; /* see USB_ERR_XXX */ 182ea972feeSBrooks Davis }; 18302ac6454SAndrew Thompson 184760bc48eSAndrew Thompson struct usb_fs_init { 18502ac6454SAndrew Thompson /* userland pointer to endpoints structure */ 186760bc48eSAndrew Thompson struct usb_fs_endpoint *pEndpoints; 18702ac6454SAndrew Thompson /* maximum number of endpoints */ 18802ac6454SAndrew Thompson uint8_t ep_index_max; 189ea972feeSBrooks Davis }; 19002ac6454SAndrew Thompson 191760bc48eSAndrew Thompson struct usb_fs_uninit { 19202ac6454SAndrew Thompson uint8_t dummy; /* zero */ 193ea972feeSBrooks Davis }; 19402ac6454SAndrew Thompson 195760bc48eSAndrew Thompson struct usb_fs_open { 1964631d7f7SHans Petter Selasky #define USB_FS_MAX_BUFSIZE (1 << 25) /* 32 MBytes */ 19702ac6454SAndrew Thompson uint32_t max_bufsize; 1981c497368SHans Petter Selasky #define USB_FS_MAX_FRAMES (1U << 12) 1991c497368SHans Petter Selasky #define USB_FS_MAX_FRAMES_PRE_SCALE (1U << 31) /* for ISOCHRONOUS transfers */ 2001c497368SHans Petter Selasky uint32_t max_frames; /* read and write */ 20102ac6454SAndrew Thompson uint16_t max_packet_length; /* read only */ 20202ac6454SAndrew Thompson uint8_t dev_index; /* currently unused */ 20302ac6454SAndrew Thompson uint8_t ep_index; 20402ac6454SAndrew Thompson uint8_t ep_no; /* bEndpointNumber */ 205ea972feeSBrooks Davis }; 20602ac6454SAndrew Thompson 207e9cec016SHans Petter Selasky struct usb_fs_open_stream { 208a5cf1aaaSHans Petter Selasky struct usb_fs_open fs_open; 20962a963c5SHans Petter Selasky uint16_t stream_id; /* stream ID */ 210ea972feeSBrooks Davis }; 211a5cf1aaaSHans Petter Selasky 212760bc48eSAndrew Thompson struct usb_fs_close { 21302ac6454SAndrew Thompson uint8_t ep_index; 214ea972feeSBrooks Davis }; 21502ac6454SAndrew Thompson 216760bc48eSAndrew Thompson struct usb_fs_clear_stall_sync { 21702ac6454SAndrew Thompson uint8_t ep_index; 218ea972feeSBrooks Davis }; 21902ac6454SAndrew Thompson 220760bc48eSAndrew Thompson struct usb_gen_quirk { 22102ac6454SAndrew Thompson uint16_t index; /* Quirk Index */ 22202ac6454SAndrew Thompson uint16_t vid; /* Vendor ID */ 22302ac6454SAndrew Thompson uint16_t pid; /* Product ID */ 22402ac6454SAndrew Thompson uint16_t bcdDeviceLow; /* Low Device Revision */ 22502ac6454SAndrew Thompson uint16_t bcdDeviceHigh; /* High Device Revision */ 22602ac6454SAndrew Thompson uint16_t reserved[2]; 22702ac6454SAndrew Thompson /* 22862a963c5SHans Petter Selasky * String version of quirk including terminating zero. See 22962a963c5SHans Petter Selasky * UQ_XXX in "usb_quirk.h". 23002ac6454SAndrew Thompson */ 23102ac6454SAndrew Thompson char quirkname[64 - 14]; 232ea972feeSBrooks Davis }; 23302ac6454SAndrew Thompson 23402ac6454SAndrew Thompson /* USB controller */ 235760bc48eSAndrew Thompson #define USB_REQUEST _IOWR('U', 1, struct usb_ctl_request) 23602ac6454SAndrew Thompson #define USB_SETDEBUG _IOW ('U', 2, int) 23702ac6454SAndrew Thompson #define USB_DISCOVER _IO ('U', 3) 238760bc48eSAndrew Thompson #define USB_DEVICEINFO _IOWR('U', 4, struct usb_device_info) 239760bc48eSAndrew Thompson #define USB_DEVICESTATS _IOR ('U', 5, struct usb_device_stats) 24002ac6454SAndrew Thompson #define USB_DEVICEENUMERATE _IOW ('U', 6, int) 24102ac6454SAndrew Thompson 24294773907SVladimir Kondratyev /* Generic HID device. Numbers 26 and 30-39 are occupied by hidraw. */ 243760bc48eSAndrew Thompson #define USB_GET_REPORT_DESC _IOWR('U', 21, struct usb_gen_descriptor) 24402ac6454SAndrew Thompson #define USB_SET_IMMED _IOW ('U', 22, int) 245760bc48eSAndrew Thompson #define USB_GET_REPORT _IOWR('U', 23, struct usb_gen_descriptor) 246760bc48eSAndrew Thompson #define USB_SET_REPORT _IOW ('U', 24, struct usb_gen_descriptor) 24702ac6454SAndrew Thompson #define USB_GET_REPORT_ID _IOR ('U', 25, int) 24802ac6454SAndrew Thompson 24902ac6454SAndrew Thompson /* Generic USB device */ 25002ac6454SAndrew Thompson #define USB_GET_CONFIG _IOR ('U', 100, int) 25102ac6454SAndrew Thompson #define USB_SET_CONFIG _IOW ('U', 101, int) 252760bc48eSAndrew Thompson #define USB_GET_ALTINTERFACE _IOWR('U', 102, struct usb_alt_interface) 253760bc48eSAndrew Thompson #define USB_SET_ALTINTERFACE _IOWR('U', 103, struct usb_alt_interface) 254760bc48eSAndrew Thompson #define USB_GET_DEVICE_DESC _IOR ('U', 105, struct usb_device_descriptor) 255760bc48eSAndrew Thompson #define USB_GET_CONFIG_DESC _IOR ('U', 106, struct usb_config_descriptor) 256760bc48eSAndrew Thompson #define USB_GET_RX_INTERFACE_DESC _IOR ('U', 107, struct usb_interface_descriptor) 257760bc48eSAndrew Thompson #define USB_GET_RX_ENDPOINT_DESC _IOR ('U', 108, struct usb_endpoint_descriptor) 258760bc48eSAndrew Thompson #define USB_GET_FULL_DESC _IOWR('U', 109, struct usb_gen_descriptor) 259760bc48eSAndrew Thompson #define USB_GET_STRING_DESC _IOWR('U', 110, struct usb_gen_descriptor) 260760bc48eSAndrew Thompson #define USB_DO_REQUEST _IOWR('U', 111, struct usb_ctl_request) 261760bc48eSAndrew Thompson #define USB_GET_DEVICEINFO _IOR ('U', 112, struct usb_device_info) 26202ac6454SAndrew Thompson #define USB_SET_RX_SHORT_XFER _IOW ('U', 113, int) 26302ac6454SAndrew Thompson #define USB_SET_RX_TIMEOUT _IOW ('U', 114, int) 26402ac6454SAndrew Thompson #define USB_GET_RX_FRAME_SIZE _IOR ('U', 115, int) 26502ac6454SAndrew Thompson #define USB_GET_RX_BUFFER_SIZE _IOR ('U', 117, int) 26602ac6454SAndrew Thompson #define USB_SET_RX_BUFFER_SIZE _IOW ('U', 118, int) 26702ac6454SAndrew Thompson #define USB_SET_RX_STALL_FLAG _IOW ('U', 119, int) 26802ac6454SAndrew Thompson #define USB_SET_TX_STALL_FLAG _IOW ('U', 120, int) 269760bc48eSAndrew Thompson #define USB_GET_IFACE_DRIVER _IOWR('U', 121, struct usb_gen_descriptor) 27002ac6454SAndrew Thompson #define USB_CLAIM_INTERFACE _IOW ('U', 122, int) 27102ac6454SAndrew Thompson #define USB_RELEASE_INTERFACE _IOW ('U', 123, int) 27202ac6454SAndrew Thompson #define USB_IFACE_DRIVER_ACTIVE _IOW ('U', 124, int) 27302ac6454SAndrew Thompson #define USB_IFACE_DRIVER_DETACH _IOW ('U', 125, int) 27402ac6454SAndrew Thompson #define USB_GET_PLUGTIME _IOR ('U', 126, uint32_t) 275760bc48eSAndrew Thompson #define USB_READ_DIR _IOW ('U', 127, struct usb_read_dir) 276c77a24c2SHans Petter Selasky /* 128 - 133 unused */ 277c77a24c2SHans Petter Selasky #define USB_GET_DEV_PORT_PATH _IOR ('U', 134, struct usb_device_port_path) 278aafcb732SHans Petter Selasky #define USB_GET_POWER_USAGE _IOR ('U', 135, int) 27902ac6454SAndrew Thompson #define USB_SET_TX_FORCE_SHORT _IOW ('U', 136, int) 28002ac6454SAndrew Thompson #define USB_SET_TX_TIMEOUT _IOW ('U', 137, int) 28102ac6454SAndrew Thompson #define USB_GET_TX_FRAME_SIZE _IOR ('U', 138, int) 28202ac6454SAndrew Thompson #define USB_GET_TX_BUFFER_SIZE _IOR ('U', 139, int) 28302ac6454SAndrew Thompson #define USB_SET_TX_BUFFER_SIZE _IOW ('U', 140, int) 284760bc48eSAndrew Thompson #define USB_GET_TX_INTERFACE_DESC _IOR ('U', 141, struct usb_interface_descriptor) 285760bc48eSAndrew Thompson #define USB_GET_TX_ENDPOINT_DESC _IOR ('U', 142, struct usb_endpoint_descriptor) 28602ac6454SAndrew Thompson #define USB_SET_PORT_ENABLE _IOW ('U', 143, int) 28702ac6454SAndrew Thompson #define USB_SET_PORT_DISABLE _IOW ('U', 144, int) 28802ac6454SAndrew Thompson #define USB_SET_POWER_MODE _IOW ('U', 145, int) 28902ac6454SAndrew Thompson #define USB_GET_POWER_MODE _IOR ('U', 146, int) 290f78fa6b6SAndrew Thompson #define USB_SET_TEMPLATE _IOW ('U', 147, int) 291f78fa6b6SAndrew Thompson #define USB_GET_TEMPLATE _IOR ('U', 148, int) 29202ac6454SAndrew Thompson 29302ac6454SAndrew Thompson /* Modem device */ 29402ac6454SAndrew Thompson #define USB_GET_CM_OVER_DATA _IOR ('U', 180, int) 29502ac6454SAndrew Thompson #define USB_SET_CM_OVER_DATA _IOW ('U', 181, int) 29602ac6454SAndrew Thompson 29717c78d34SHans Petter Selasky /* GPIO control */ 29817c78d34SHans Petter Selasky #define USB_GET_GPIO _IOR ('U', 182, int) 29917c78d34SHans Petter Selasky #define USB_SET_GPIO _IOW ('U', 183, int) 30017c78d34SHans Petter Selasky 30102ac6454SAndrew Thompson /* USB file system interface */ 302760bc48eSAndrew Thompson #define USB_FS_START _IOW ('U', 192, struct usb_fs_start) 303760bc48eSAndrew Thompson #define USB_FS_STOP _IOW ('U', 193, struct usb_fs_stop) 304760bc48eSAndrew Thompson #define USB_FS_COMPLETE _IOR ('U', 194, struct usb_fs_complete) 305760bc48eSAndrew Thompson #define USB_FS_INIT _IOW ('U', 195, struct usb_fs_init) 306760bc48eSAndrew Thompson #define USB_FS_UNINIT _IOW ('U', 196, struct usb_fs_uninit) 307760bc48eSAndrew Thompson #define USB_FS_OPEN _IOWR('U', 197, struct usb_fs_open) 308760bc48eSAndrew Thompson #define USB_FS_CLOSE _IOW ('U', 198, struct usb_fs_close) 309760bc48eSAndrew Thompson #define USB_FS_CLEAR_STALL_SYNC _IOW ('U', 199, struct usb_fs_clear_stall_sync) 310e9cec016SHans Petter Selasky #define USB_FS_OPEN_STREAM _IOWR('U', 200, struct usb_fs_open_stream) 31102ac6454SAndrew Thompson 31202ac6454SAndrew Thompson /* USB quirk system interface */ 313760bc48eSAndrew Thompson #define USB_DEV_QUIRK_GET _IOWR('Q', 0, struct usb_gen_quirk) 314760bc48eSAndrew Thompson #define USB_QUIRK_NAME_GET _IOWR('Q', 1, struct usb_gen_quirk) 315760bc48eSAndrew Thompson #define USB_DEV_QUIRK_ADD _IOW ('Q', 2, struct usb_gen_quirk) 316760bc48eSAndrew Thompson #define USB_DEV_QUIRK_REMOVE _IOW ('Q', 3, struct usb_gen_quirk) 31702ac6454SAndrew Thompson 31845b48cbcSBrooks Davis #ifdef _KERNEL 31945b48cbcSBrooks Davis #ifdef COMPAT_FREEBSD32 32045b48cbcSBrooks Davis 32145b48cbcSBrooks Davis struct usb_read_dir32 { 32245b48cbcSBrooks Davis uint32_t urd_data; 32345b48cbcSBrooks Davis uint32_t urd_startentry; 32445b48cbcSBrooks Davis uint32_t urd_maxlen; 32545b48cbcSBrooks Davis }; 32645b48cbcSBrooks Davis #define USB_READ_DIR32 \ 32745b48cbcSBrooks Davis _IOC_NEWTYPE(USB_READ_DIR, struct usb_read_dir32) 32845b48cbcSBrooks Davis 32945b48cbcSBrooks Davis struct usb_ctl_request32 { 33045b48cbcSBrooks Davis uint32_t ucr_data; 33145b48cbcSBrooks Davis uint16_t ucr_flags; 33245b48cbcSBrooks Davis uint16_t ucr_actlen; 33345b48cbcSBrooks Davis uint8_t ucr_addr; 33445b48cbcSBrooks Davis struct usb_device_request ucr_request; 33545b48cbcSBrooks Davis }; 33645b48cbcSBrooks Davis #define USB_REQUEST32 _IOC_NEWTYPE(USB_REQUEST, struct usb_ctl_request32) 33745b48cbcSBrooks Davis #define USB_DO_REQUEST32 _IOC_NEWTYPE(USB_DO_REQUEST, struct usb_ctl_request32) 33845b48cbcSBrooks Davis 33945b48cbcSBrooks Davis struct usb_gen_descriptor32 { 34045b48cbcSBrooks Davis uint32_t ugd_data; /* void * */ 34145b48cbcSBrooks Davis uint16_t ugd_lang_id; 34245b48cbcSBrooks Davis uint16_t ugd_maxlen; 34345b48cbcSBrooks Davis uint16_t ugd_actlen; 34445b48cbcSBrooks Davis uint16_t ugd_offset; 34545b48cbcSBrooks Davis uint8_t ugd_config_index; 34645b48cbcSBrooks Davis uint8_t ugd_string_index; 34745b48cbcSBrooks Davis uint8_t ugd_iface_index; 34845b48cbcSBrooks Davis uint8_t ugd_altif_index; 34945b48cbcSBrooks Davis uint8_t ugd_endpt_index; 35045b48cbcSBrooks Davis uint8_t ugd_report_type; 35145b48cbcSBrooks Davis uint8_t reserved[8]; 35245b48cbcSBrooks Davis }; 35345b48cbcSBrooks Davis 35445b48cbcSBrooks Davis #define USB_GET_REPORT_DESC32 \ 35545b48cbcSBrooks Davis _IOC_NEWTYPE(USB_GET_REPORT_DESC, struct usb_gen_descriptor32) 35645b48cbcSBrooks Davis #define USB_GET_REPORT32 \ 35745b48cbcSBrooks Davis _IOC_NEWTYPE(USB_GET_REPORT, struct usb_gen_descriptor32) 35845b48cbcSBrooks Davis #define USB_SET_REPORT32 \ 35945b48cbcSBrooks Davis _IOC_NEWTYPE(USB_SET_REPORT, struct usb_gen_descriptor32) 36045b48cbcSBrooks Davis #define USB_GET_FULL_DESC32 \ 36145b48cbcSBrooks Davis _IOC_NEWTYPE(USB_GET_FULL_DESC, struct usb_gen_descriptor32) 36245b48cbcSBrooks Davis #define USB_GET_STRING_DESC32 \ 36345b48cbcSBrooks Davis _IOC_NEWTYPE(USB_GET_STRING_DESC, struct usb_gen_descriptor32) 36445b48cbcSBrooks Davis #define USB_GET_IFACE_DRIVER32 \ 36545b48cbcSBrooks Davis _IOC_NEWTYPE(USB_GET_IFACE_DRIVER, struct usb_gen_descriptor32) 36645b48cbcSBrooks Davis 36745b48cbcSBrooks Davis void usb_gen_descriptor_from32(struct usb_gen_descriptor *ugd, 36845b48cbcSBrooks Davis const struct usb_gen_descriptor32 *ugd32); 36945b48cbcSBrooks Davis void update_usb_gen_descriptor32(struct usb_gen_descriptor32 *ugd32, 37045b48cbcSBrooks Davis struct usb_gen_descriptor *ugd); 37145b48cbcSBrooks Davis 3720ec590d2SBrooks Davis struct usb_fs_endpoint32 { 3730ec590d2SBrooks Davis uint32_t ppBuffer; /* void ** */ 3740ec590d2SBrooks Davis uint32_t pLength; /* uint32_t * */ 3750ec590d2SBrooks Davis uint32_t nFrames; 3760ec590d2SBrooks Davis uint32_t aFrames; 3770ec590d2SBrooks Davis uint16_t flags; 3780ec590d2SBrooks Davis uint16_t timeout; 3790ec590d2SBrooks Davis uint16_t isoc_time_complete; 3800ec590d2SBrooks Davis int status; 3810ec590d2SBrooks Davis }; 3820ec590d2SBrooks Davis 3830ec590d2SBrooks Davis struct usb_fs_init32 { 3840ec590d2SBrooks Davis uint32_t pEndpoints; /* struct usb_fs_endpoint32 * */ 3850ec590d2SBrooks Davis uint8_t ep_index_max; 3860ec590d2SBrooks Davis }; 3870ec590d2SBrooks Davis 3880ec590d2SBrooks Davis #define USB_FS_INIT32 _IOC_NEWTYPE(USB_FS_INIT, struct usb_fs_init32) 3890ec590d2SBrooks Davis 39045b48cbcSBrooks Davis #endif /* COMPAT_FREEBSD32 */ 39145b48cbcSBrooks Davis #endif /* _KERNEL */ 39245b48cbcSBrooks Davis 39375973647SAndrew Thompson #endif /* _USB_IOCTL_H_ */ 394