17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5b3001defSlg150142 * Common Development and Distribution License (the "License"). 6b3001defSlg150142 * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 20b3001defSlg150142 */ 21b3001defSlg150142 /* 22ff0e937bSRaymond Chen * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 24*e2c88f0cSGarrett D'Amore * 25*e2c88f0cSGarrett D'Amore * Copyright 2014 Garrett D'Amore <garrett@damore.org> 267c478bd9Sstevel@tonic-gate */ 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate #ifndef _SYS_USB_USBAI_H 297c478bd9Sstevel@tonic-gate #define _SYS_USB_USBAI_H 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #ifdef __cplusplus 337c478bd9Sstevel@tonic-gate extern "C" { 347c478bd9Sstevel@tonic-gate #endif 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate /* This header file is for USBA2.0 */ 377c478bd9Sstevel@tonic-gate #define USBA_MAJOR_VER 2 387c478bd9Sstevel@tonic-gate #define USBA_MINOR_VER 0 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate /* 417c478bd9Sstevel@tonic-gate * USBAI: Interfaces Between USBA and Client Driver 427c478bd9Sstevel@tonic-gate * 437c478bd9Sstevel@tonic-gate * 447c478bd9Sstevel@tonic-gate * Universal USB device state management : 457c478bd9Sstevel@tonic-gate * 467c478bd9Sstevel@tonic-gate * PWRED_DWN---<3----4>--ONLINE---<2-----1>-DISCONNECTED 477c478bd9Sstevel@tonic-gate * | ^ | 487c478bd9Sstevel@tonic-gate * | 6 | 497c478bd9Sstevel@tonic-gate * | | | 507c478bd9Sstevel@tonic-gate * | 5 | 517c478bd9Sstevel@tonic-gate * | v | 527c478bd9Sstevel@tonic-gate * +----5>----------SUSPENDED----<5----7>---+ 537c478bd9Sstevel@tonic-gate * 547c478bd9Sstevel@tonic-gate * 1 = Device Unplug 557c478bd9Sstevel@tonic-gate * 2 = Original Device reconnected 567c478bd9Sstevel@tonic-gate * 3 = Device idles for time T & transitions to low power state 577c478bd9Sstevel@tonic-gate * 4 = Remote wakeup by device OR Application kicking off IO to device 587c478bd9Sstevel@tonic-gate * 5 = Notification to save state prior to DDI_SUSPEND 597c478bd9Sstevel@tonic-gate * 6 = Notification to restore state after DDI_RESUME with correct device 607c478bd9Sstevel@tonic-gate * 7 = Notification to restore state after DDI_RESUME with device 617c478bd9Sstevel@tonic-gate * disconnected or a wrong device 627c478bd9Sstevel@tonic-gate * 637c478bd9Sstevel@tonic-gate * NOTE: device states 0x80 to 0xff are device specific and can be 647c478bd9Sstevel@tonic-gate * used by client drivers 657c478bd9Sstevel@tonic-gate */ 667c478bd9Sstevel@tonic-gate #define USB_DEV_ONLINE 1 /* device is online */ 677c478bd9Sstevel@tonic-gate #define USB_DEV_DISCONNECTED 2 /* indicates disconnect */ 687c478bd9Sstevel@tonic-gate #define USB_DEV_SUSPENDED 3 /* DDI_SUSPEND operation */ 697c478bd9Sstevel@tonic-gate #define USB_DEV_PWRED_DOWN 4 /* indicates power off state */ 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate /* 737c478bd9Sstevel@tonic-gate * *************************************************************************** 747c478bd9Sstevel@tonic-gate * USBA error and status definitions 757c478bd9Sstevel@tonic-gate * *************************************************************************** 767c478bd9Sstevel@tonic-gate */ 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate /* 807c478bd9Sstevel@tonic-gate * USBA function return values 817c478bd9Sstevel@tonic-gate */ 827c478bd9Sstevel@tonic-gate #define USB_SUCCESS 0 /* call success */ 837c478bd9Sstevel@tonic-gate #define USB_FAILURE -1 /* unspecified USBA or HCD error */ 847c478bd9Sstevel@tonic-gate #define USB_NO_RESOURCES -2 /* no resources available */ 857c478bd9Sstevel@tonic-gate #define USB_NO_BANDWIDTH -3 /* no bandwidth available */ 867c478bd9Sstevel@tonic-gate #define USB_NOT_SUPPORTED -4 /* function not supported by HCD */ 877c478bd9Sstevel@tonic-gate #define USB_PIPE_ERROR -5 /* error occured on the pipe */ 887c478bd9Sstevel@tonic-gate #define USB_INVALID_PIPE -6 /* pipe handle passed is invalid */ 897c478bd9Sstevel@tonic-gate #define USB_NO_FRAME_NUMBER -7 /* frame No or ASAP not specified */ 907c478bd9Sstevel@tonic-gate #define USB_INVALID_START_FRAME -8 /* starting USB frame not valid */ 917c478bd9Sstevel@tonic-gate #define USB_HC_HARDWARE_ERROR -9 /* usb host controller error */ 927c478bd9Sstevel@tonic-gate #define USB_INVALID_REQUEST -10 /* request had invalid values */ 937c478bd9Sstevel@tonic-gate #define USB_INVALID_CONTEXT -11 /* sleep flag in interrupt context */ 947c478bd9Sstevel@tonic-gate #define USB_INVALID_VERSION -12 /* invalid version specified */ 957c478bd9Sstevel@tonic-gate #define USB_INVALID_ARGS -13 /* invalid func args specified */ 967c478bd9Sstevel@tonic-gate #define USB_INVALID_PERM -14 /* privileged operation */ 977c478bd9Sstevel@tonic-gate #define USB_BUSY -15 /* busy condition */ 987c478bd9Sstevel@tonic-gate 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate /* 1017c478bd9Sstevel@tonic-gate * USB request completion flags, more than one may be set. 1027c478bd9Sstevel@tonic-gate * The following flags are returned after a recovery action by 1037c478bd9Sstevel@tonic-gate * HCD or USBA (autoclearing) or callbacks from pipe_close, 1047c478bd9Sstevel@tonic-gate * abort, reset, or stop polling. More than one may be set. 1057c478bd9Sstevel@tonic-gate * 1067c478bd9Sstevel@tonic-gate * For sync requests, the client should check the request structure 1077c478bd9Sstevel@tonic-gate * for this flag to determine what has happened. 1087c478bd9Sstevel@tonic-gate * 1097c478bd9Sstevel@tonic-gate * All callbacks are queued to preserve order. Note that if a normal callback 1107c478bd9Sstevel@tonic-gate * uses a kernel thread, order is not guaranteed since each callback may use 1117c478bd9Sstevel@tonic-gate * its own thread. The next request will be submitted to the 1127c478bd9Sstevel@tonic-gate * HCD after the threads exits. 1137c478bd9Sstevel@tonic-gate * 1147c478bd9Sstevel@tonic-gate * Exception callbacks using a kernel thread may do auto clearing and no 1157c478bd9Sstevel@tonic-gate * new request will be started until this thread has completed its work. 1167c478bd9Sstevel@tonic-gate */ 1177c478bd9Sstevel@tonic-gate typedef enum { 1187c478bd9Sstevel@tonic-gate USB_CB_NO_INFO = 0x00, /* no exception */ 1197c478bd9Sstevel@tonic-gate USB_CB_STALL_CLEARED = 0x01, /* func stall cleared */ 1207c478bd9Sstevel@tonic-gate USB_CB_FUNCTIONAL_STALL = 0x02, /* func stall occurred */ 1217c478bd9Sstevel@tonic-gate USB_CB_PROTOCOL_STALL = 0x04, /* protocal stall occurred */ 1227c478bd9Sstevel@tonic-gate USB_CB_RESET_PIPE = 0x10, /* pipe was reset */ 1237c478bd9Sstevel@tonic-gate USB_CB_ASYNC_REQ_FAILED = 0x80, /* thread couldn't be started */ 1247c478bd9Sstevel@tonic-gate USB_CB_NO_RESOURCES = 0x100, /* no resources */ 1257c478bd9Sstevel@tonic-gate USB_CB_SUBMIT_FAILED = 0x200, /* req was queued then submitted */ 1267c478bd9Sstevel@tonic-gate /* to HCD which rejected it */ 1277c478bd9Sstevel@tonic-gate USB_CB_INTR_CONTEXT = 0x400 /* Callback is in interrupt context. */ 1287c478bd9Sstevel@tonic-gate } usb_cb_flags_t; 1297c478bd9Sstevel@tonic-gate 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate /* 1327c478bd9Sstevel@tonic-gate * completion reason 1337c478bd9Sstevel@tonic-gate * 1347c478bd9Sstevel@tonic-gate * Set by HCD; only one can be set. 1357c478bd9Sstevel@tonic-gate */ 1367c478bd9Sstevel@tonic-gate typedef enum { 1377c478bd9Sstevel@tonic-gate USB_CR_OK = 0, /* no errors detected */ 1387c478bd9Sstevel@tonic-gate USB_CR_CRC = 1, /* crc error detected */ 1397c478bd9Sstevel@tonic-gate USB_CR_BITSTUFFING = 2, /* bit stuffing violation */ 1407c478bd9Sstevel@tonic-gate USB_CR_DATA_TOGGLE_MM = 3, /* d/t PID did not match */ 1417c478bd9Sstevel@tonic-gate USB_CR_STALL = 4, /* e/p returned stall PID */ 1427c478bd9Sstevel@tonic-gate USB_CR_DEV_NOT_RESP = 5, /* device not responding */ 1437c478bd9Sstevel@tonic-gate USB_CR_PID_CHECKFAILURE = 6, /* check bits on PID failed */ 1447c478bd9Sstevel@tonic-gate USB_CR_UNEXP_PID = 7, /* receive PID was not valid */ 1457c478bd9Sstevel@tonic-gate USB_CR_DATA_OVERRUN = 8, /* data size exceeded */ 1467c478bd9Sstevel@tonic-gate USB_CR_DATA_UNDERRUN = 9, /* less data received */ 1477c478bd9Sstevel@tonic-gate USB_CR_BUFFER_OVERRUN = 10, /* memory write can't keep up */ 1487c478bd9Sstevel@tonic-gate USB_CR_BUFFER_UNDERRUN = 11, /* buffer underrun */ 1497c478bd9Sstevel@tonic-gate USB_CR_TIMEOUT = 12, /* command timed out */ 1507c478bd9Sstevel@tonic-gate USB_CR_NOT_ACCESSED = 13, /* Not accessed by hardware */ 1517c478bd9Sstevel@tonic-gate USB_CR_NO_RESOURCES = 14, /* no resources */ 1527c478bd9Sstevel@tonic-gate USB_CR_UNSPECIFIED_ERR = 15, /* unspecified usba or hcd err */ 1537c478bd9Sstevel@tonic-gate USB_CR_STOPPED_POLLING = 16, /* intr/isoc IN polling stopped */ 1547c478bd9Sstevel@tonic-gate USB_CR_PIPE_CLOSING = 17, /* intr/isoc IN pipe closed */ 1557c478bd9Sstevel@tonic-gate USB_CR_PIPE_RESET = 18, /* intr/isoc IN pipe reset */ 1567c478bd9Sstevel@tonic-gate USB_CR_NOT_SUPPORTED = 19, /* command not supported */ 1577c478bd9Sstevel@tonic-gate USB_CR_FLUSHED = 20, /* this request was flushed */ 1587c478bd9Sstevel@tonic-gate USB_CR_HC_HARDWARE_ERR = 21 /* usb host controller error */ 1597c478bd9Sstevel@tonic-gate } usb_cr_t; 1607c478bd9Sstevel@tonic-gate 1617c478bd9Sstevel@tonic-gate 1627c478bd9Sstevel@tonic-gate /* 1637c478bd9Sstevel@tonic-gate * *************************************************************************** 1647c478bd9Sstevel@tonic-gate * General definitions, used all over 1657c478bd9Sstevel@tonic-gate * *************************************************************************** 1667c478bd9Sstevel@tonic-gate * 1677c478bd9Sstevel@tonic-gate * A pipe handle is returned by usb_pipe_open() on success for 1687c478bd9Sstevel@tonic-gate * all pipes except the default pipe which is accessed from 1697c478bd9Sstevel@tonic-gate * the registration structure. Placed here as forward referenced by 1707c478bd9Sstevel@tonic-gate * usb_client_dev_data_t below. 1717c478bd9Sstevel@tonic-gate * 1727c478bd9Sstevel@tonic-gate * The pipe_handle is opaque to the client driver. 1737c478bd9Sstevel@tonic-gate */ 1747c478bd9Sstevel@tonic-gate typedef struct usb_pipe_handle *usb_pipe_handle_t; 1757c478bd9Sstevel@tonic-gate 1767c478bd9Sstevel@tonic-gate /* 1777c478bd9Sstevel@tonic-gate * General opaque pointer. 1787c478bd9Sstevel@tonic-gate */ 1797c478bd9Sstevel@tonic-gate typedef struct usb_opaque *usb_opaque_t; 1807c478bd9Sstevel@tonic-gate 1817c478bd9Sstevel@tonic-gate 1827c478bd9Sstevel@tonic-gate /* 1837c478bd9Sstevel@tonic-gate * USB flags argument to USBA interfaces 1847c478bd9Sstevel@tonic-gate */ 1857c478bd9Sstevel@tonic-gate typedef enum { 1867c478bd9Sstevel@tonic-gate /* do not block until resources are available */ 1877c478bd9Sstevel@tonic-gate USB_FLAGS_NOSLEEP = 0x0000, 1887c478bd9Sstevel@tonic-gate /* block until resources are available */ 1897c478bd9Sstevel@tonic-gate USB_FLAGS_SLEEP = 0x0100, 1907c478bd9Sstevel@tonic-gate /* reserved */ 1917c478bd9Sstevel@tonic-gate USB_FLAGS_RESERVED = 0xFE00 1927c478bd9Sstevel@tonic-gate } usb_flags_t; 1937c478bd9Sstevel@tonic-gate 1947c478bd9Sstevel@tonic-gate 1957c478bd9Sstevel@tonic-gate /* 1967c478bd9Sstevel@tonic-gate * *************************************************************************** 1977c478bd9Sstevel@tonic-gate * Descriptor definitions (from USB 2.0 specification, chapter 9) 1987c478bd9Sstevel@tonic-gate * *************************************************************************** 1997c478bd9Sstevel@tonic-gate */ 2007c478bd9Sstevel@tonic-gate 2017c478bd9Sstevel@tonic-gate 2027c478bd9Sstevel@tonic-gate /* 2037c478bd9Sstevel@tonic-gate * USB Descriptor Management 2047c478bd9Sstevel@tonic-gate * 2057c478bd9Sstevel@tonic-gate * Standard USB descriptors: 2067c478bd9Sstevel@tonic-gate * 2077c478bd9Sstevel@tonic-gate * USB devices present their configuration information in response to 2087c478bd9Sstevel@tonic-gate * a GET_DESCRIPTOR request in a form which is little-endian and, 2097c478bd9Sstevel@tonic-gate * for multibyte integers, unaligned. It is also position-dependent, 2107c478bd9Sstevel@tonic-gate * which makes non-sequential access to particular interface or 2117c478bd9Sstevel@tonic-gate * endpoint data inconvenient. 2127c478bd9Sstevel@tonic-gate * A GET_DESCRIPTOR request may yield a chunk of data that contains 2137c478bd9Sstevel@tonic-gate * multiple descriptor types. For example, a GET_DESCRIPTOR request 2147c478bd9Sstevel@tonic-gate * for a CONFIGURATION descriptor could return the configuration 2157c478bd9Sstevel@tonic-gate * descriptor followed by an interface descriptor and the relevant 2167c478bd9Sstevel@tonic-gate * endpoint descriptors. 2177c478bd9Sstevel@tonic-gate * 2187c478bd9Sstevel@tonic-gate * usb_get_dev_data() interface provides an easy way to get all 2197c478bd9Sstevel@tonic-gate * the descriptors and avoids parsing standard descriptors by each 2207c478bd9Sstevel@tonic-gate * client driver 2217c478bd9Sstevel@tonic-gate * 2227c478bd9Sstevel@tonic-gate * usb_dev_descr: 2237c478bd9Sstevel@tonic-gate * usb device descriptor, refer to USB 2.0/9.6.1, 2247c478bd9Sstevel@tonic-gate */ 2257c478bd9Sstevel@tonic-gate typedef struct usb_dev_descr { 2267c478bd9Sstevel@tonic-gate uint8_t bLength; /* descriptor size */ 2277c478bd9Sstevel@tonic-gate uint8_t bDescriptorType; /* set to DEVICE */ 2287c478bd9Sstevel@tonic-gate uint16_t bcdUSB; /* USB spec rel. number in bcd */ 2297c478bd9Sstevel@tonic-gate uint8_t bDeviceClass; /* class code */ 2307c478bd9Sstevel@tonic-gate uint8_t bDeviceSubClass; /* sub class code */ 2317c478bd9Sstevel@tonic-gate uint8_t bDeviceProtocol; /* protocol code */ 2327c478bd9Sstevel@tonic-gate uint8_t bMaxPacketSize0; /* max pkt size of e/p 0 */ 2337c478bd9Sstevel@tonic-gate uint16_t idVendor; /* vendor ID */ 2347c478bd9Sstevel@tonic-gate uint16_t idProduct; /* product ID */ 2357c478bd9Sstevel@tonic-gate uint16_t bcdDevice; /* device release number in bcd */ 2367c478bd9Sstevel@tonic-gate uint8_t iManufacturer; /* manufacturing string */ 2377c478bd9Sstevel@tonic-gate uint8_t iProduct; /* product string */ 2387c478bd9Sstevel@tonic-gate uint8_t iSerialNumber; /* serial number string index */ 2397c478bd9Sstevel@tonic-gate uint8_t bNumConfigurations; /* #configs for device */ 2407c478bd9Sstevel@tonic-gate } usb_dev_descr_t; 2417c478bd9Sstevel@tonic-gate 2427c478bd9Sstevel@tonic-gate 2437c478bd9Sstevel@tonic-gate /* 2447c478bd9Sstevel@tonic-gate * USB Device Qualifier Descriptor 2457c478bd9Sstevel@tonic-gate * 2467c478bd9Sstevel@tonic-gate * The device_qualifier descriptor describes information about a High 2477c478bd9Sstevel@tonic-gate * speed capable device that would change if the device were operating 2487c478bd9Sstevel@tonic-gate * at other (Full) speed. Example: if the device is currently operating 2497c478bd9Sstevel@tonic-gate * at Full-speed, the device_qualifier returns information about how if 2507c478bd9Sstevel@tonic-gate * would operate at high-speed and vice-versa. 2517c478bd9Sstevel@tonic-gate * 2527c478bd9Sstevel@tonic-gate * usb_dev_qlf_descr: 2537c478bd9Sstevel@tonic-gate * 2547c478bd9Sstevel@tonic-gate * usb device qualifier descriptor, refer to USB 2.0/9.6.2 2557c478bd9Sstevel@tonic-gate */ 2567c478bd9Sstevel@tonic-gate typedef struct usb_dev_qlf_descr { 2577c478bd9Sstevel@tonic-gate uint8_t bLength; /* descriptor size */ 2587c478bd9Sstevel@tonic-gate uint8_t bDescriptorType; /* set to DEVICE */ 2597c478bd9Sstevel@tonic-gate uint16_t bcdUSB; /* USB spec rel. number in bcd */ 2607c478bd9Sstevel@tonic-gate uint8_t bDeviceClass; /* class code */ 2617c478bd9Sstevel@tonic-gate uint8_t bDeviceSubClass; /* sub class code */ 2627c478bd9Sstevel@tonic-gate uint8_t bDeviceProtocol; /* protocol code */ 2637c478bd9Sstevel@tonic-gate uint8_t bMaxPacketSize0; /* max pkt size of e/p 0 */ 2647c478bd9Sstevel@tonic-gate uint8_t bNumConfigurations; /* #configs for device */ 2657c478bd9Sstevel@tonic-gate uint8_t bReserved; /* reserved field */ 2667c478bd9Sstevel@tonic-gate } usb_dev_qlf_descr_t; 2677c478bd9Sstevel@tonic-gate 2687c478bd9Sstevel@tonic-gate 2697c478bd9Sstevel@tonic-gate /* 2707c478bd9Sstevel@tonic-gate * usb_cfg_descr: 2717c478bd9Sstevel@tonic-gate * usb configuration descriptor, refer to USB 2.0/9.6.3 2727c478bd9Sstevel@tonic-gate */ 2737c478bd9Sstevel@tonic-gate typedef struct usb_cfg_descr { 2747c478bd9Sstevel@tonic-gate uint8_t bLength; /* descriptor size */ 2757c478bd9Sstevel@tonic-gate uint8_t bDescriptorType; /* set to CONFIGURATION */ 2767c478bd9Sstevel@tonic-gate uint16_t wTotalLength; /* total length of data returned */ 2777c478bd9Sstevel@tonic-gate uint8_t bNumInterfaces; /* # interfaces in config */ 2787c478bd9Sstevel@tonic-gate uint8_t bConfigurationValue; /* arg for SetConfiguration */ 2797c478bd9Sstevel@tonic-gate uint8_t iConfiguration; /* configuration string */ 2807c478bd9Sstevel@tonic-gate uint8_t bmAttributes; /* config characteristics */ 2817c478bd9Sstevel@tonic-gate uint8_t bMaxPower; /* max pwr consumption */ 2827c478bd9Sstevel@tonic-gate } usb_cfg_descr_t; 2837c478bd9Sstevel@tonic-gate 2847c478bd9Sstevel@tonic-gate /* 2857c478bd9Sstevel@tonic-gate * Default configuration index setting for devices with multiple 2867c478bd9Sstevel@tonic-gate * configurations. Note the distinction between config index and config 2877c478bd9Sstevel@tonic-gate * number 2887c478bd9Sstevel@tonic-gate */ 2897c478bd9Sstevel@tonic-gate #define USB_DEV_DEFAULT_CONFIG_INDEX 0 2907c478bd9Sstevel@tonic-gate 2917c478bd9Sstevel@tonic-gate /* 2927c478bd9Sstevel@tonic-gate * bmAttribute values for Configuration Descriptor 2937c478bd9Sstevel@tonic-gate */ 2947c478bd9Sstevel@tonic-gate #define USB_CFG_ATTR_SELFPWR 0x40 2957c478bd9Sstevel@tonic-gate #define USB_CFG_ATTR_REMOTE_WAKEUP 0x20 296ff0e937bSRaymond Chen #define USB_CFG_ATTR_BAT_PWR 0x10 2977c478bd9Sstevel@tonic-gate 2987c478bd9Sstevel@tonic-gate /* 2997c478bd9Sstevel@tonic-gate * USB Other Speed Configuration Descriptor 3007c478bd9Sstevel@tonic-gate * 3017c478bd9Sstevel@tonic-gate * The other_speed_configuration descriptor describes a configuration of 3027c478bd9Sstevel@tonic-gate * a High speed capable device if it were operating at its other possible 3037c478bd9Sstevel@tonic-gate * (Full) speed and vice-versa. 3047c478bd9Sstevel@tonic-gate * 3057c478bd9Sstevel@tonic-gate * usb_other_speed_cfg_descr: 3067c478bd9Sstevel@tonic-gate * usb other speed configuration descriptor, refer to USB 2.0/9.6.4 3077c478bd9Sstevel@tonic-gate */ 3087c478bd9Sstevel@tonic-gate typedef struct usb_other_speed_cfg_descr { 3097c478bd9Sstevel@tonic-gate uint8_t bLength; /* descriptor size */ 3107c478bd9Sstevel@tonic-gate uint8_t bDescriptorType; /* set to CONFIGURATION */ 3117c478bd9Sstevel@tonic-gate uint16_t wTotalLength; /* total length of data returned */ 3127c478bd9Sstevel@tonic-gate uint8_t bNumInterfaces; /* # interfaces in config */ 3137c478bd9Sstevel@tonic-gate uint8_t bConfigurationValue; /* arg for SetConfiguration */ 3147c478bd9Sstevel@tonic-gate uint8_t iConfiguration; /* configuration string */ 3157c478bd9Sstevel@tonic-gate uint8_t bmAttributes; /* config characteristics */ 3167c478bd9Sstevel@tonic-gate uint8_t bMaxPower; /* max pwr consumption */ 3177c478bd9Sstevel@tonic-gate } usb_other_speed_cfg_descr_t; 3187c478bd9Sstevel@tonic-gate 3197c478bd9Sstevel@tonic-gate 3207c478bd9Sstevel@tonic-gate /* 321d73ae94eSgc161489 * usb_ia_descr: 322d73ae94eSgc161489 * usb interface association descriptor, refer to USB 2.0 ECN(IAD) 323d73ae94eSgc161489 */ 324d73ae94eSgc161489 typedef struct usb_ia_descr { 325d73ae94eSgc161489 uint8_t bLength; /* descriptor size */ 326d73ae94eSgc161489 uint8_t bDescriptorType; /* INTERFACE_ASSOCIATION */ 327d73ae94eSgc161489 uint8_t bFirstInterface; /* 1st interface number */ 328d73ae94eSgc161489 uint8_t bInterfaceCount; /* number of interfaces */ 329d73ae94eSgc161489 uint8_t bFunctionClass; /* class code */ 330d73ae94eSgc161489 uint8_t bFunctionSubClass; /* sub class code */ 331d73ae94eSgc161489 uint8_t bFunctionProtocol; /* protocol code */ 332d73ae94eSgc161489 uint8_t iFunction; /* description string */ 333d73ae94eSgc161489 } usb_ia_descr_t; 334d73ae94eSgc161489 335d73ae94eSgc161489 336d73ae94eSgc161489 /* 3377c478bd9Sstevel@tonic-gate * usb_if_descr: 3387c478bd9Sstevel@tonic-gate * usb interface descriptor, refer to USB 2.0/9.6.5 3397c478bd9Sstevel@tonic-gate */ 3407c478bd9Sstevel@tonic-gate typedef struct usb_if_descr { 3417c478bd9Sstevel@tonic-gate uint8_t bLength; /* descriptor size */ 3427c478bd9Sstevel@tonic-gate uint8_t bDescriptorType; /* set to INTERFACE */ 3437c478bd9Sstevel@tonic-gate uint8_t bInterfaceNumber; /* interface number */ 3447c478bd9Sstevel@tonic-gate uint8_t bAlternateSetting; /* alt. interface number */ 3457c478bd9Sstevel@tonic-gate uint8_t bNumEndpoints; /* # of endpoints */ 3467c478bd9Sstevel@tonic-gate uint8_t bInterfaceClass; /* class code */ 3477c478bd9Sstevel@tonic-gate uint8_t bInterfaceSubClass; /* sub class code */ 3487c478bd9Sstevel@tonic-gate uint8_t bInterfaceProtocol; /* protocol code */ 3497c478bd9Sstevel@tonic-gate uint8_t iInterface; /* description string */ 3507c478bd9Sstevel@tonic-gate } usb_if_descr_t; 3517c478bd9Sstevel@tonic-gate 3527c478bd9Sstevel@tonic-gate 3537c478bd9Sstevel@tonic-gate /* 3547c478bd9Sstevel@tonic-gate * usb_ep_descr: 3557c478bd9Sstevel@tonic-gate * usb endpoint descriptor, refer to USB 2.0/9.6.6 3567c478bd9Sstevel@tonic-gate */ 3577c478bd9Sstevel@tonic-gate typedef struct usb_ep_descr { 3587c478bd9Sstevel@tonic-gate uint8_t bLength; /* descriptor size */ 3597c478bd9Sstevel@tonic-gate uint8_t bDescriptorType; /* set to ENDPOINT */ 3607c478bd9Sstevel@tonic-gate uint8_t bEndpointAddress; /* address of this e/p */ 3617c478bd9Sstevel@tonic-gate uint8_t bmAttributes; /* transfer type */ 3627c478bd9Sstevel@tonic-gate uint16_t wMaxPacketSize; /* maximum packet size */ 3637c478bd9Sstevel@tonic-gate uint8_t bInterval; /* e/p polling interval */ 3647c478bd9Sstevel@tonic-gate } usb_ep_descr_t; 3657c478bd9Sstevel@tonic-gate 3667c478bd9Sstevel@tonic-gate /* 3677c478bd9Sstevel@tonic-gate * bEndpointAddress masks 3687c478bd9Sstevel@tonic-gate */ 3697c478bd9Sstevel@tonic-gate #define USB_EP_NUM_MASK 0x0F /* endpoint number mask */ 3707c478bd9Sstevel@tonic-gate #define USB_EP_DIR_MASK 0x80 /* direction mask */ 3717c478bd9Sstevel@tonic-gate #define USB_EP_DIR_OUT 0x00 /* OUT endpoint */ 3727c478bd9Sstevel@tonic-gate #define USB_EP_DIR_IN 0x80 /* IN endpoint */ 3737c478bd9Sstevel@tonic-gate 3747c478bd9Sstevel@tonic-gate /* 3757c478bd9Sstevel@tonic-gate * bmAttribute transfer types for endpoints 3767c478bd9Sstevel@tonic-gate */ 3777c478bd9Sstevel@tonic-gate #define USB_EP_ATTR_MASK 0x03 /* transfer type mask */ 3787c478bd9Sstevel@tonic-gate #define USB_EP_ATTR_CONTROL 0x00 /* control transfer */ 3797c478bd9Sstevel@tonic-gate #define USB_EP_ATTR_ISOCH 0x01 /* isochronous transfer */ 3807c478bd9Sstevel@tonic-gate #define USB_EP_ATTR_BULK 0x02 /* bulk transfer */ 3817c478bd9Sstevel@tonic-gate #define USB_EP_ATTR_INTR 0x03 /* interrupt transfer */ 3827c478bd9Sstevel@tonic-gate 3837c478bd9Sstevel@tonic-gate /* 3847c478bd9Sstevel@tonic-gate * bmAttribute synchronization types for endpoints (isochronous only) 3857c478bd9Sstevel@tonic-gate */ 3867c478bd9Sstevel@tonic-gate #define USB_EP_SYNC_MASK 0x0C /* synchronization mask */ 3877c478bd9Sstevel@tonic-gate #define USB_EP_SYNC_NONE 0x00 /* no synchronization */ 3887c478bd9Sstevel@tonic-gate #define USB_EP_SYNC_ASYNC 0x04 /* asynchronous */ 3897c478bd9Sstevel@tonic-gate #define USB_EP_SYNC_ADPT 0x08 /* adaptive */ 3907c478bd9Sstevel@tonic-gate #define USB_EP_SYNC_SYNC 0x0C /* synchronous */ 3917c478bd9Sstevel@tonic-gate 3927c478bd9Sstevel@tonic-gate /* 3937c478bd9Sstevel@tonic-gate * bmAttribute synchronization feedback types for endpoints (isochronous only) 3947c478bd9Sstevel@tonic-gate */ 3957c478bd9Sstevel@tonic-gate #define USB_EP_USAGE_MASK 0x30 /* sync feedback mask */ 3967c478bd9Sstevel@tonic-gate #define USB_EP_USAGE_DATA 0x00 /* data endpoint */ 3977c478bd9Sstevel@tonic-gate #define USB_EP_USAGE_FEED 0x10 /* feedback endpoint */ 3987c478bd9Sstevel@tonic-gate #define USB_EP_USAGE_IMPL 0x20 /* implicit feedback endpoint */ 3997c478bd9Sstevel@tonic-gate 4007c478bd9Sstevel@tonic-gate /* 4017c478bd9Sstevel@tonic-gate * wMaxPacketSize values for endpoints (isoch and interrupt, high speed only) 4027c478bd9Sstevel@tonic-gate */ 4037c478bd9Sstevel@tonic-gate #define USB_EP_MAX_PKTSZ_MASK 0x03FF /* Mask for packetsize bits */ 4047c478bd9Sstevel@tonic-gate #define USB_EP_MAX_XACTS_MASK 0x0C00 /* Max Transactns/microframe */ 4057c478bd9Sstevel@tonic-gate #define USB_EP_MAX_XACTS_SHIFT 10 /* Above is 10 bits from end */ 4067c478bd9Sstevel@tonic-gate 4077c478bd9Sstevel@tonic-gate /* 4087c478bd9Sstevel@tonic-gate * Ranges for endpoint parameter values. 4097c478bd9Sstevel@tonic-gate */ 4107c478bd9Sstevel@tonic-gate 4117c478bd9Sstevel@tonic-gate /* Min and Max NAK rates for high sped control endpoints. */ 4127c478bd9Sstevel@tonic-gate #define USB_EP_MIN_HIGH_CONTROL_INTRVL 0 4137c478bd9Sstevel@tonic-gate #define USB_EP_MAX_HIGH_CONTROL_INTRVL 255 4147c478bd9Sstevel@tonic-gate 4157c478bd9Sstevel@tonic-gate /* Min and Max NAK rates for high speed bulk endpoints. */ 4167c478bd9Sstevel@tonic-gate #define USB_EP_MIN_HIGH_BULK_INTRVL 0 4177c478bd9Sstevel@tonic-gate #define USB_EP_MAX_HIGH_BULK_INTRVL 255 4187c478bd9Sstevel@tonic-gate 4197c478bd9Sstevel@tonic-gate /* Min and Max polling intervals for low, full speed interrupt endpoints. */ 4207c478bd9Sstevel@tonic-gate #define USB_EP_MIN_LOW_INTR_INTRVL 1 4217c478bd9Sstevel@tonic-gate #define USB_EP_MAX_LOW_INTR_INTRVL 255 4227c478bd9Sstevel@tonic-gate #define USB_EP_MIN_FULL_INTR_INTRVL 1 4237c478bd9Sstevel@tonic-gate #define USB_EP_MAX_FULL_INTR_INTRVL 255 4247c478bd9Sstevel@tonic-gate 4257c478bd9Sstevel@tonic-gate /* 4267c478bd9Sstevel@tonic-gate * Min and Max polling intervals for high speed interrupt endpoints, and for 4277c478bd9Sstevel@tonic-gate * isochronous endpoints. 4287c478bd9Sstevel@tonic-gate * Note that the interval is 2**(value-1). See Section 9.6.6 of USB 2.0 spec. 4297c478bd9Sstevel@tonic-gate */ 4307c478bd9Sstevel@tonic-gate #define USB_EP_MIN_HIGH_INTR_INTRVL 1 4317c478bd9Sstevel@tonic-gate #define USB_EP_MAX_HIGH_INTR_INTRVL 16 4327c478bd9Sstevel@tonic-gate #define USB_EP_MIN_FULL_ISOCH_INTRVL 1 4337c478bd9Sstevel@tonic-gate #define USB_EP_MAX_FULL_ISOCH_INTRVL 16 4347c478bd9Sstevel@tonic-gate #define USB_EP_MIN_HIGH_ISOCH_INTRVL 1 4357c478bd9Sstevel@tonic-gate #define USB_EP_MAX_HIGH_ISOCH_INTRVL 16 4367c478bd9Sstevel@tonic-gate 4377c478bd9Sstevel@tonic-gate /* 4387c478bd9Sstevel@tonic-gate * usb_string_descr: 4397c478bd9Sstevel@tonic-gate * usb string descriptor, refer to USB 2.0/9.6.7 4407c478bd9Sstevel@tonic-gate */ 4417c478bd9Sstevel@tonic-gate typedef struct usb_string_descr { 4427c478bd9Sstevel@tonic-gate uint8_t bLength; /* descr size */ 4437c478bd9Sstevel@tonic-gate uint8_t bDescriptorType; /* set to STRING */ 4447c478bd9Sstevel@tonic-gate uint8_t bString[1]; /* variable length unicode */ 4457c478bd9Sstevel@tonic-gate /* encoded string */ 4467c478bd9Sstevel@tonic-gate } usb_string_descr_t; 4477c478bd9Sstevel@tonic-gate 4487c478bd9Sstevel@tonic-gate #define USB_MAXSTRINGLEN 255 /* max string descr length */ 4497c478bd9Sstevel@tonic-gate 450ff0e937bSRaymond Chen /* 4517c478bd9Sstevel@tonic-gate * *************************************************************************** 4527c478bd9Sstevel@tonic-gate * Client driver registration with USBA 4537c478bd9Sstevel@tonic-gate * *************************************************************************** 4547c478bd9Sstevel@tonic-gate * 4557c478bd9Sstevel@tonic-gate * The client registers with USBA during attach in two steps 4567c478bd9Sstevel@tonic-gate * using usb_client_attach() and usb_get_dev_data(). On completion, the 4577c478bd9Sstevel@tonic-gate * registration data has been initialized. Most data items are 4587c478bd9Sstevel@tonic-gate * straightforward. Among the items returned in the data is the tree of 4597c478bd9Sstevel@tonic-gate * parsed descriptors, in dev_cfg; the number of configurations parsed, 4607c478bd9Sstevel@tonic-gate * in dev_n_cfg; a pointer to the current configuration in the tree, 4617c478bd9Sstevel@tonic-gate * in dev_curr_cfg; the index of the first valid interface in the 4627c478bd9Sstevel@tonic-gate * tree, in dev_curr_if, and a parse level that accurately reflects what 4637c478bd9Sstevel@tonic-gate * is in the tree, in dev_parse_level. 4647c478bd9Sstevel@tonic-gate */ 4657c478bd9Sstevel@tonic-gate 4667c478bd9Sstevel@tonic-gate 4677c478bd9Sstevel@tonic-gate /* 4687c478bd9Sstevel@tonic-gate * *************************************************************************** 4697c478bd9Sstevel@tonic-gate * Data structures used in the configuration tree 4707c478bd9Sstevel@tonic-gate * *************************************************************************** 4717c478bd9Sstevel@tonic-gate */ 4727c478bd9Sstevel@tonic-gate 4737c478bd9Sstevel@tonic-gate /* 4747c478bd9Sstevel@tonic-gate * Tree data structure for each configuration in the tree 4757c478bd9Sstevel@tonic-gate */ 4767c478bd9Sstevel@tonic-gate typedef struct usb_cfg_data { 4777c478bd9Sstevel@tonic-gate struct usb_cfg_descr cfg_descr; /* parsed config descr */ 4787c478bd9Sstevel@tonic-gate struct usb_if_data *cfg_if; /* interfaces for this cfg */ 4797c478bd9Sstevel@tonic-gate /* indexed by interface num */ 4807c478bd9Sstevel@tonic-gate struct usb_cvs_data *cfg_cvs; /* class/vendor specific */ 4817c478bd9Sstevel@tonic-gate /* descrs mod/extend cfg */ 4827c478bd9Sstevel@tonic-gate char *cfg_str; /* string descriptor */ 4837c478bd9Sstevel@tonic-gate uint_t cfg_n_if; /* #elements in cfg_if[] */ 4847c478bd9Sstevel@tonic-gate uint_t cfg_n_cvs; /* #elements in cfg_cvs[] */ 4857c478bd9Sstevel@tonic-gate uint_t cfg_strsize; /* size of string descr */ 4867c478bd9Sstevel@tonic-gate } usb_cfg_data_t; 4877c478bd9Sstevel@tonic-gate 4887c478bd9Sstevel@tonic-gate 4897c478bd9Sstevel@tonic-gate /* 4907c478bd9Sstevel@tonic-gate * Tree data structure for each alternate interface set 4917c478bd9Sstevel@tonic-gate * in each represented configuration 4927c478bd9Sstevel@tonic-gate */ 4937c478bd9Sstevel@tonic-gate typedef struct usb_if_data { 4947c478bd9Sstevel@tonic-gate struct usb_alt_if_data *if_alt; /* sparse array of alts */ 4957c478bd9Sstevel@tonic-gate /* indexed by alt setting */ 4967c478bd9Sstevel@tonic-gate uint_t if_n_alt; /* #elements in if_alt[] */ 4977c478bd9Sstevel@tonic-gate } usb_if_data_t; 4987c478bd9Sstevel@tonic-gate 4997c478bd9Sstevel@tonic-gate 5007c478bd9Sstevel@tonic-gate /* 5017c478bd9Sstevel@tonic-gate * Tree data structure for each alternate of each alternate interface set 5027c478bd9Sstevel@tonic-gate */ 5037c478bd9Sstevel@tonic-gate typedef struct usb_alt_if_data { 5047c478bd9Sstevel@tonic-gate usb_if_descr_t altif_descr; /* parsed alternate if descr */ 5057c478bd9Sstevel@tonic-gate struct usb_ep_data *altif_ep; /* endpts for alt if */ 5067c478bd9Sstevel@tonic-gate /* (not a sparse array */ 5077c478bd9Sstevel@tonic-gate struct usb_cvs_data *altif_cvs; /* cvs for this alt if */ 5087c478bd9Sstevel@tonic-gate char *altif_str; /* string descriptor */ 5097c478bd9Sstevel@tonic-gate uint_t altif_n_ep; /* #elements in altif_ep[] */ 5107c478bd9Sstevel@tonic-gate uint_t altif_n_cvs; /* #elements in altif_cvs[] */ 5117c478bd9Sstevel@tonic-gate uint_t altif_strsize; /* size of string descr */ 5127c478bd9Sstevel@tonic-gate } usb_alt_if_data_t; 5137c478bd9Sstevel@tonic-gate 5147c478bd9Sstevel@tonic-gate 5157c478bd9Sstevel@tonic-gate /* 5167c478bd9Sstevel@tonic-gate * Tree data structure for each endpoint of each alternate 5177c478bd9Sstevel@tonic-gate */ 5187c478bd9Sstevel@tonic-gate typedef struct usb_ep_data { 5197c478bd9Sstevel@tonic-gate usb_ep_descr_t ep_descr; /* endpoint descriptor */ 5207c478bd9Sstevel@tonic-gate struct usb_cvs_data *ep_cvs; /* cv mod/extending this ep */ 5217c478bd9Sstevel@tonic-gate uint_t ep_n_cvs; /* #elements in ep_cvs[] */ 5227c478bd9Sstevel@tonic-gate } usb_ep_data_t; 5237c478bd9Sstevel@tonic-gate 5247c478bd9Sstevel@tonic-gate 5257c478bd9Sstevel@tonic-gate /* 5267c478bd9Sstevel@tonic-gate * Tree data structure for each class/vendor specific descriptor 5277c478bd9Sstevel@tonic-gate */ 5287c478bd9Sstevel@tonic-gate typedef struct usb_cvs_data { 5297c478bd9Sstevel@tonic-gate uchar_t *cvs_buf; /* raw data of cvs descr */ 5307c478bd9Sstevel@tonic-gate uint_t cvs_buf_len; /* cvs_buf size */ 5317c478bd9Sstevel@tonic-gate } usb_cvs_data_t; 5327c478bd9Sstevel@tonic-gate 5337c478bd9Sstevel@tonic-gate 5347c478bd9Sstevel@tonic-gate /* 5357c478bd9Sstevel@tonic-gate * Parse_level determines the extent to which the tree is built, the amount 5367c478bd9Sstevel@tonic-gate * of parsing usb_client_attach() is to do. It has the following values: 5377c478bd9Sstevel@tonic-gate * 5387c478bd9Sstevel@tonic-gate * USB_PARSE_LVL_NONE - Build no tree. dev_n_cfg will return 0, dev_cfg 5397c478bd9Sstevel@tonic-gate * will return NULL, the dev_curr_xxx fields will be 5407c478bd9Sstevel@tonic-gate * invalid. 5417c478bd9Sstevel@tonic-gate * USB_PARSE_LVL_IF - Parse configured interface only, if configuration# 5427c478bd9Sstevel@tonic-gate * and interface properties are set (as when different 5437c478bd9Sstevel@tonic-gate * interfaces are viewed by the OS as different device 5447c478bd9Sstevel@tonic-gate * instances). If an OS device instance is set up to 5457c478bd9Sstevel@tonic-gate * represent an entire physical device, this works 5467c478bd9Sstevel@tonic-gate * like USB_PARSE_LVL_ALL. 5477c478bd9Sstevel@tonic-gate * USB_PARSE_LVL_CFG - Parse entire configuration of configured interface 5487c478bd9Sstevel@tonic-gate * only. This is like USB_PARSE_LVL_IF except entire 5497c478bd9Sstevel@tonic-gate * configuration is returned. 5507c478bd9Sstevel@tonic-gate * USB_PARSE_LVL_ALL - Parse entire device (all configurations), even 5517c478bd9Sstevel@tonic-gate * when driver is bound to a single interface of a 5527c478bd9Sstevel@tonic-gate * single configuration. 5537c478bd9Sstevel@tonic-gate */ 5547c478bd9Sstevel@tonic-gate typedef enum { 5557c478bd9Sstevel@tonic-gate USB_PARSE_LVL_NONE = 0, 5567c478bd9Sstevel@tonic-gate USB_PARSE_LVL_IF = 1, 5577c478bd9Sstevel@tonic-gate USB_PARSE_LVL_CFG = 2, 5587c478bd9Sstevel@tonic-gate USB_PARSE_LVL_ALL = 3 5597c478bd9Sstevel@tonic-gate } usb_reg_parse_lvl_t; 5607c478bd9Sstevel@tonic-gate 5617c478bd9Sstevel@tonic-gate 5627c478bd9Sstevel@tonic-gate /* 5637c478bd9Sstevel@tonic-gate * Registration data returned by usb_get_dev_data(). Configuration tree roots 5647c478bd9Sstevel@tonic-gate * are returned in dev_cfg array. 5657c478bd9Sstevel@tonic-gate */ 5667c478bd9Sstevel@tonic-gate typedef struct usb_client_dev_data { 5677c478bd9Sstevel@tonic-gate usb_pipe_handle_t dev_default_ph; /* default pipe handle */ 5687c478bd9Sstevel@tonic-gate ddi_iblock_cookie_t dev_iblock_cookie; /* for mutex_init's */ 5697c478bd9Sstevel@tonic-gate struct usb_dev_descr *dev_descr; /* cooked device descriptor */ 5707c478bd9Sstevel@tonic-gate char *dev_mfg; /* manufacturing ID */ 5717c478bd9Sstevel@tonic-gate char *dev_product; /* product ID */ 5727c478bd9Sstevel@tonic-gate char *dev_serial; /* serial number */ 5737c478bd9Sstevel@tonic-gate usb_reg_parse_lvl_t dev_parse_level; /* USB_PARSE_LVL_* flag */ 5747c478bd9Sstevel@tonic-gate struct usb_cfg_data *dev_cfg; /* configs for this device */ 5757c478bd9Sstevel@tonic-gate /* indexed by config index */ 5767c478bd9Sstevel@tonic-gate uint_t dev_n_cfg; /* #elements in dev_cfg[] */ 5777c478bd9Sstevel@tonic-gate struct usb_cfg_data *dev_curr_cfg; /* current cfg */ 5787c478bd9Sstevel@tonic-gate int dev_curr_if; /* current interface number */ 5797c478bd9Sstevel@tonic-gate } usb_client_dev_data_t; 5807c478bd9Sstevel@tonic-gate 5817c478bd9Sstevel@tonic-gate 5827c478bd9Sstevel@tonic-gate /* 5837c478bd9Sstevel@tonic-gate * *************************************************************************** 5847c478bd9Sstevel@tonic-gate * Device configuration descriptor tree functions 5857c478bd9Sstevel@tonic-gate * *************************************************************************** 5867c478bd9Sstevel@tonic-gate */ 5877c478bd9Sstevel@tonic-gate 5887c478bd9Sstevel@tonic-gate /* 5897c478bd9Sstevel@tonic-gate * usb_get_dev_data: 5907c478bd9Sstevel@tonic-gate * returns initialized registration data. Most data items are clear. 5917c478bd9Sstevel@tonic-gate * Among the items returned is the tree ofparsed descriptors in dev_cfg; 5927c478bd9Sstevel@tonic-gate * and the number of configurations parsed in dev_n_cfg. 5937c478bd9Sstevel@tonic-gate * 5947c478bd9Sstevel@tonic-gate * Arguments: 5957c478bd9Sstevel@tonic-gate * dip - pointer to devinfo node of the client 5967c478bd9Sstevel@tonic-gate * dev_data - return registration data at this address 5977c478bd9Sstevel@tonic-gate * parse_level - See above 5987c478bd9Sstevel@tonic-gate * flags - None used 5997c478bd9Sstevel@tonic-gate * 6007c478bd9Sstevel@tonic-gate * Return Values: 6017c478bd9Sstevel@tonic-gate * USB_SUCCESS - usb_register_client succeeded 6027c478bd9Sstevel@tonic-gate * USB_INVALID_ARGS - received null dip or reg argument 6037c478bd9Sstevel@tonic-gate * USB_INVALID_CONTEXT - called with sleep from callback context 6047c478bd9Sstevel@tonic-gate * USB_FAILURE - bad descriptor info or other internal failure 6057c478bd9Sstevel@tonic-gate * 6067c478bd9Sstevel@tonic-gate * Notes: 6077c478bd9Sstevel@tonic-gate * 1) The non-standard USB descriptors are returned in RAW format. 6087c478bd9Sstevel@tonic-gate * 6097c478bd9Sstevel@tonic-gate * 2) The registration data is unshared. Each client receives its own copy. 6107c478bd9Sstevel@tonic-gate * (The default control pipe may be shared, even though its tree 6117c478bd9Sstevel@tonic-gate * description will be unique per device.) 6127c478bd9Sstevel@tonic-gate * 6137c478bd9Sstevel@tonic-gate */ 6147c478bd9Sstevel@tonic-gate int usb_get_dev_data( 6157c478bd9Sstevel@tonic-gate dev_info_t *dip, 6167c478bd9Sstevel@tonic-gate usb_client_dev_data_t **dev_data, 6177c478bd9Sstevel@tonic-gate usb_reg_parse_lvl_t parse_level, 6187c478bd9Sstevel@tonic-gate usb_flags_t flags); 6197c478bd9Sstevel@tonic-gate 6207c478bd9Sstevel@tonic-gate /* 6217c478bd9Sstevel@tonic-gate * usb_free_dev_data: 6227c478bd9Sstevel@tonic-gate * undoes what usb_get_dev_data() set up. It releases 6237c478bd9Sstevel@tonic-gate * memory for all strings, descriptors, and trees set up by usb_get_dev_data(). 6247c478bd9Sstevel@tonic-gate * 6257c478bd9Sstevel@tonic-gate * Arguments: 6267c478bd9Sstevel@tonic-gate * dip - pointer to devinfo node of the client 6277c478bd9Sstevel@tonic-gate * dev_data - pointer to registration data containing the tree. 6287c478bd9Sstevel@tonic-gate */ 6297c478bd9Sstevel@tonic-gate void usb_free_dev_data( 6307c478bd9Sstevel@tonic-gate dev_info_t *dip, 6317c478bd9Sstevel@tonic-gate usb_client_dev_data_t *dev_data); 6327c478bd9Sstevel@tonic-gate 6337c478bd9Sstevel@tonic-gate /* 6347c478bd9Sstevel@tonic-gate * usb_free_descr_tree: 6357c478bd9Sstevel@tonic-gate * Take down the configuration tree while leaving the rest of the 6367c478bd9Sstevel@tonic-gate * registration intact. This can be used, for example, after attach has 6377c478bd9Sstevel@tonic-gate * copied any descriptors it needs from the tree, but the rest of the 6387c478bd9Sstevel@tonic-gate * registration data needs to remain intact. 6397c478bd9Sstevel@tonic-gate * 6407c478bd9Sstevel@tonic-gate * The following usb_client_dev_data_t fields will be modified: 6417c478bd9Sstevel@tonic-gate * dev_cfg will be NULL 6427c478bd9Sstevel@tonic-gate * dev_n_cfg will be 0 6437c478bd9Sstevel@tonic-gate * dev_curr_cfg_ndx and dev_curr_if will be invalid 6447c478bd9Sstevel@tonic-gate * dev_parse_level will be USB_REG_DESCR_NONE 6457c478bd9Sstevel@tonic-gate * 6467c478bd9Sstevel@tonic-gate * Arguments: 6477c478bd9Sstevel@tonic-gate * dip - pointer to devinfo node of the client 6487c478bd9Sstevel@tonic-gate * dev_data - pointer to registration data containing the tree. 6497c478bd9Sstevel@tonic-gate */ 6507c478bd9Sstevel@tonic-gate void usb_free_descr_tree( 6517c478bd9Sstevel@tonic-gate dev_info_t *dip, 6527c478bd9Sstevel@tonic-gate usb_client_dev_data_t *dev_data); 6537c478bd9Sstevel@tonic-gate 6547c478bd9Sstevel@tonic-gate 6557c478bd9Sstevel@tonic-gate /* 6567c478bd9Sstevel@tonic-gate * usb_print_descr_tree: 6577c478bd9Sstevel@tonic-gate * Dump to the screen a descriptor tree as returned by 6587c478bd9Sstevel@tonic-gate * usbai_register_client. 6597c478bd9Sstevel@tonic-gate * 6607c478bd9Sstevel@tonic-gate * Arguments: 6617c478bd9Sstevel@tonic-gate * dip - pointer to devinfo of the client 6627c478bd9Sstevel@tonic-gate * dev_data - pointer to registration area containing the tree 6637c478bd9Sstevel@tonic-gate * 6647c478bd9Sstevel@tonic-gate * Returns: 6657c478bd9Sstevel@tonic-gate * USB_SUCCESS - tree successfully dumped 6667c478bd9Sstevel@tonic-gate * USB_INVALID_CONTEXT - called from callback context 6677c478bd9Sstevel@tonic-gate * USB_INVALID_ARGS - bad arguments given 6687c478bd9Sstevel@tonic-gate */ 6697c478bd9Sstevel@tonic-gate int usb_print_descr_tree( 6707c478bd9Sstevel@tonic-gate dev_info_t *dip, 6717c478bd9Sstevel@tonic-gate usb_client_dev_data_t *dev_data); 6727c478bd9Sstevel@tonic-gate 6737c478bd9Sstevel@tonic-gate 6747c478bd9Sstevel@tonic-gate /* 6757c478bd9Sstevel@tonic-gate * *************************************************************************** 6767c478bd9Sstevel@tonic-gate * Registration and versioning 6777c478bd9Sstevel@tonic-gate * *************************************************************************** 6787c478bd9Sstevel@tonic-gate */ 6797c478bd9Sstevel@tonic-gate 6807c478bd9Sstevel@tonic-gate 6817c478bd9Sstevel@tonic-gate /* 6827c478bd9Sstevel@tonic-gate * USBA client drivers are required to define USBDRV_MAJOR_VER 6837c478bd9Sstevel@tonic-gate * USBDRV_MINOR_VER and pass USBDRV_VERSION as the version 6847c478bd9Sstevel@tonic-gate * number to usb_client_attach 6857c478bd9Sstevel@tonic-gate */ 6867c478bd9Sstevel@tonic-gate #if !defined(USBA_MAJOR_VER) || !defined(USBA_MINOR_VER) 6877c478bd9Sstevel@tonic-gate #error incorrect USBA header 6887c478bd9Sstevel@tonic-gate #endif 6897c478bd9Sstevel@tonic-gate 6907c478bd9Sstevel@tonic-gate /* 6917c478bd9Sstevel@tonic-gate * Driver major version must be the same as USBA major version, and 6927c478bd9Sstevel@tonic-gate * driver minor version must be <= USBA minor version 6937c478bd9Sstevel@tonic-gate */ 6947c478bd9Sstevel@tonic-gate #if !defined(USBA_FRAMEWORK) 6957c478bd9Sstevel@tonic-gate #if defined(USBDRV_MAJOR_VER) && defined(USBDRV_MINOR_VER) 6967c478bd9Sstevel@tonic-gate 6977c478bd9Sstevel@tonic-gate #if (USBDRV_MAJOR_VER != USBA_MAJOR_VER) 6987c478bd9Sstevel@tonic-gate #error USBA and driver major versions do not match 6997c478bd9Sstevel@tonic-gate #endif 7007c478bd9Sstevel@tonic-gate #if (USBDRV_MINOR_VER > USBA_MINOR_VER) 7017c478bd9Sstevel@tonic-gate #error USBA and driver minor versions do not match 7027c478bd9Sstevel@tonic-gate #endif 7037c478bd9Sstevel@tonic-gate 7047c478bd9Sstevel@tonic-gate #endif 7057c478bd9Sstevel@tonic-gate #endif 7067c478bd9Sstevel@tonic-gate 7077c478bd9Sstevel@tonic-gate #define USBA_MAKE_VER(major, minor) ((major) << 8 | (minor)) 7087c478bd9Sstevel@tonic-gate #define USBA_GET_MAJOR(ver) ((ver) >> 8) 7097c478bd9Sstevel@tonic-gate #define USBA_GET_MINOR(ver) ((ver) & 0xff) 7107c478bd9Sstevel@tonic-gate 7117c478bd9Sstevel@tonic-gate #define USBDRV_VERSION USBA_MAKE_VER(USBDRV_MAJOR_VER, USBDRV_MINOR_VER) 7127c478bd9Sstevel@tonic-gate 7137c478bd9Sstevel@tonic-gate 7147c478bd9Sstevel@tonic-gate /* 7157c478bd9Sstevel@tonic-gate * usb_client_attach: 7167c478bd9Sstevel@tonic-gate * 7177c478bd9Sstevel@tonic-gate * Arguments: 7187c478bd9Sstevel@tonic-gate * dip - pointer to devinfo node of the client 7197c478bd9Sstevel@tonic-gate * version - USBA registration version number 7207c478bd9Sstevel@tonic-gate * flags - None used 7217c478bd9Sstevel@tonic-gate * 7227c478bd9Sstevel@tonic-gate * Return Values: 7237c478bd9Sstevel@tonic-gate * USB_SUCCESS - attach succeeded 7247c478bd9Sstevel@tonic-gate * USB_INVALID_ARGS - received null dip or reg argument 7257c478bd9Sstevel@tonic-gate * USB_INVALID_CONTEXT - called with sleep from callback context 7267c478bd9Sstevel@tonic-gate * or not at attach time 7277c478bd9Sstevel@tonic-gate * USB_INVALID_VERSION - version argument is incorrect. 7287c478bd9Sstevel@tonic-gate * USB_FAILURE - other internal failure 7297c478bd9Sstevel@tonic-gate */ 7307c478bd9Sstevel@tonic-gate int usb_client_attach( 7317c478bd9Sstevel@tonic-gate dev_info_t *dip, 7327c478bd9Sstevel@tonic-gate uint_t version, 7337c478bd9Sstevel@tonic-gate usb_flags_t flags); 7347c478bd9Sstevel@tonic-gate 7357c478bd9Sstevel@tonic-gate /* 7367c478bd9Sstevel@tonic-gate * usb_client_detach: 7377c478bd9Sstevel@tonic-gate * 7387c478bd9Sstevel@tonic-gate * Arguments: 7397c478bd9Sstevel@tonic-gate * dip - pointer to devinfo node of the client 7407c478bd9Sstevel@tonic-gate * dev_data - pointer to data to free. may be NULL 7417c478bd9Sstevel@tonic-gate */ 7427c478bd9Sstevel@tonic-gate void usb_client_detach( 7437c478bd9Sstevel@tonic-gate dev_info_t *dip, 7447c478bd9Sstevel@tonic-gate struct usb_client_dev_data *dev_data); 7457c478bd9Sstevel@tonic-gate 7467c478bd9Sstevel@tonic-gate /* 7477c478bd9Sstevel@tonic-gate * *************************************************************************** 7487c478bd9Sstevel@tonic-gate * Functions for parsing / retrieving data from the descriptor tree 7497c478bd9Sstevel@tonic-gate * *************************************************************************** 7507c478bd9Sstevel@tonic-gate */ 7517c478bd9Sstevel@tonic-gate 7527c478bd9Sstevel@tonic-gate /* 7537c478bd9Sstevel@tonic-gate * Function for unpacking any kind of little endian data, usually desriptors 7547c478bd9Sstevel@tonic-gate * 7557c478bd9Sstevel@tonic-gate * Arguments: 7567c478bd9Sstevel@tonic-gate * format - string indicating the format in c, s, w, eg. "2c4ws" 7577c478bd9Sstevel@tonic-gate * which describes 2 bytes, 4 int, one short. 7587c478bd9Sstevel@tonic-gate * The number prefix parses the number of items of 7597c478bd9Sstevel@tonic-gate * the following type. 7607c478bd9Sstevel@tonic-gate * data - pointer to the LE data buffer 7617c478bd9Sstevel@tonic-gate * datalen - length of the data 7627c478bd9Sstevel@tonic-gate * structure - pointer to return structure where the unpacked data 7637c478bd9Sstevel@tonic-gate * will be written 7647c478bd9Sstevel@tonic-gate * structlen - length of the return structure 7657c478bd9Sstevel@tonic-gate * 7667c478bd9Sstevel@tonic-gate * return value: 7677c478bd9Sstevel@tonic-gate * total number of bytes of the original data that was unpacked 7687c478bd9Sstevel@tonic-gate * or USB_PARSE_ERROR 7697c478bd9Sstevel@tonic-gate */ 7707c478bd9Sstevel@tonic-gate #define USB_PARSE_ERROR 0 7717c478bd9Sstevel@tonic-gate 7727c478bd9Sstevel@tonic-gate size_t usb_parse_data( 7737c478bd9Sstevel@tonic-gate char *format, 7747c478bd9Sstevel@tonic-gate uchar_t *data, 7757c478bd9Sstevel@tonic-gate size_t datalen, 7767c478bd9Sstevel@tonic-gate void *structure, 7777c478bd9Sstevel@tonic-gate size_t structlen); 7787c478bd9Sstevel@tonic-gate 7797c478bd9Sstevel@tonic-gate /* 7807c478bd9Sstevel@tonic-gate * usb_lookup_ep_data: 7817c478bd9Sstevel@tonic-gate * Function to get specific endpoint data 7827c478bd9Sstevel@tonic-gate * This function will not access the device. 7837c478bd9Sstevel@tonic-gate * 7847c478bd9Sstevel@tonic-gate * Arguments: 7857c478bd9Sstevel@tonic-gate * dip - pointer to dev info 7867c478bd9Sstevel@tonic-gate * dev_datap - pointer to registration data 7877c478bd9Sstevel@tonic-gate * interface - requested interface 7887c478bd9Sstevel@tonic-gate * alternate - requested alternate 7897c478bd9Sstevel@tonic-gate * skip - number of endpoints which match the requested type and 7907c478bd9Sstevel@tonic-gate * direction to skip before finding one to retrieve 7917c478bd9Sstevel@tonic-gate * type - endpoint type 7927c478bd9Sstevel@tonic-gate * direction - endpoint direction: USB_EP_DIR_IN/OUT or none 7937c478bd9Sstevel@tonic-gate * 7947c478bd9Sstevel@tonic-gate * Return Values: 7957c478bd9Sstevel@tonic-gate * NULL or an endpoint data pointer 7967c478bd9Sstevel@tonic-gate */ 7977c478bd9Sstevel@tonic-gate usb_ep_data_t *usb_lookup_ep_data( 7987c478bd9Sstevel@tonic-gate dev_info_t *dip, 7997c478bd9Sstevel@tonic-gate usb_client_dev_data_t *dev_datap, 8007c478bd9Sstevel@tonic-gate uint_t interface, 8017c478bd9Sstevel@tonic-gate uint_t alternate, 8027c478bd9Sstevel@tonic-gate uint_t skip, 8037c478bd9Sstevel@tonic-gate uint_t type, 8047c478bd9Sstevel@tonic-gate uint_t direction); 8057c478bd9Sstevel@tonic-gate 8067c478bd9Sstevel@tonic-gate 8077c478bd9Sstevel@tonic-gate /* Language ID for string descriptors. */ 8087c478bd9Sstevel@tonic-gate #define USB_LANG_ID 0x0409 /* English, US */ 8097c478bd9Sstevel@tonic-gate 8107c478bd9Sstevel@tonic-gate /* 8117c478bd9Sstevel@tonic-gate * usb_get_string_descr: 8127c478bd9Sstevel@tonic-gate * Reads the string descriptor. This function access the device and 8137c478bd9Sstevel@tonic-gate * blocks. 8147c478bd9Sstevel@tonic-gate * 8157c478bd9Sstevel@tonic-gate * Arguments: 8167c478bd9Sstevel@tonic-gate * dip - pointer to devinfo of the client. 8177c478bd9Sstevel@tonic-gate * langid - LANGID to read different LOCALEs. 8187c478bd9Sstevel@tonic-gate * index - index to the string. 8197c478bd9Sstevel@tonic-gate * buf - user provided buffer for string descriptor. 8207c478bd9Sstevel@tonic-gate * buflen - user provided length of the buffer. 8217c478bd9Sstevel@tonic-gate * 8227c478bd9Sstevel@tonic-gate * Return Values: 8237c478bd9Sstevel@tonic-gate * USB_SUCCESS - descriptor is valid. 8247c478bd9Sstevel@tonic-gate * USB_FAILURE - full descriptor could not be retrieved. 8257c478bd9Sstevel@tonic-gate */ 8267c478bd9Sstevel@tonic-gate int usb_get_string_descr( 8277c478bd9Sstevel@tonic-gate dev_info_t *dip, 8287c478bd9Sstevel@tonic-gate uint16_t langid, 8297c478bd9Sstevel@tonic-gate uint8_t index, 8307c478bd9Sstevel@tonic-gate char *buf, 8317c478bd9Sstevel@tonic-gate size_t buflen); 8327c478bd9Sstevel@tonic-gate 8337c478bd9Sstevel@tonic-gate 8347c478bd9Sstevel@tonic-gate /* 8357c478bd9Sstevel@tonic-gate * *************************************************************************** 8367c478bd9Sstevel@tonic-gate * Addressing utility functions 8377c478bd9Sstevel@tonic-gate * *************************************************************************** 8387c478bd9Sstevel@tonic-gate */ 8397c478bd9Sstevel@tonic-gate 8407c478bd9Sstevel@tonic-gate /* 8417c478bd9Sstevel@tonic-gate * usb_get_addr returns the current usb address, mostly for debugging 8427c478bd9Sstevel@tonic-gate * purposes. The address may change after hotremove/insert. 8437c478bd9Sstevel@tonic-gate * This address will not change on a disconnect/reconnect of open device. 8447c478bd9Sstevel@tonic-gate */ 8457c478bd9Sstevel@tonic-gate int usb_get_addr(dev_info_t *dip); 8467c478bd9Sstevel@tonic-gate 8477c478bd9Sstevel@tonic-gate 8487c478bd9Sstevel@tonic-gate /* 8497c478bd9Sstevel@tonic-gate * usb_get_if_number returns USB_COMBINED_NODE or USB_DEVICE_NODE 8507c478bd9Sstevel@tonic-gate * if the driver is responsible for the entire device. 8517c478bd9Sstevel@tonic-gate * Otherwise it returns the interface number. 8527c478bd9Sstevel@tonic-gate */ 8537c478bd9Sstevel@tonic-gate #define USB_COMBINED_NODE -1 8547c478bd9Sstevel@tonic-gate #define USB_DEVICE_NODE -2 8557c478bd9Sstevel@tonic-gate 8567c478bd9Sstevel@tonic-gate int usb_get_if_number( 8577c478bd9Sstevel@tonic-gate dev_info_t *dip); 8587c478bd9Sstevel@tonic-gate 8597c478bd9Sstevel@tonic-gate boolean_t usb_owns_device( 8607c478bd9Sstevel@tonic-gate dev_info_t *dip); 8617c478bd9Sstevel@tonic-gate 8627c478bd9Sstevel@tonic-gate 8637c478bd9Sstevel@tonic-gate /* 8647c478bd9Sstevel@tonic-gate * *************************************************************************** 8657c478bd9Sstevel@tonic-gate * Pipe Management definitions and functions 8667c478bd9Sstevel@tonic-gate * *************************************************************************** 8677c478bd9Sstevel@tonic-gate */ 8687c478bd9Sstevel@tonic-gate 8697c478bd9Sstevel@tonic-gate 8707c478bd9Sstevel@tonic-gate /* 8717c478bd9Sstevel@tonic-gate * 8727c478bd9Sstevel@tonic-gate * usb_pipe_state: 8737c478bd9Sstevel@tonic-gate * 8747c478bd9Sstevel@tonic-gate * PIPE_STATE_IDLE: 8757c478bd9Sstevel@tonic-gate * The pipe's policy is set, but the pipe currently isn't transferring 8767c478bd9Sstevel@tonic-gate * data. 8777c478bd9Sstevel@tonic-gate * 8787c478bd9Sstevel@tonic-gate * PIPE_STATE_ACTIVE: 8797c478bd9Sstevel@tonic-gate * The pipe's policy has been set, and the pipe is able to transmit data. 8807c478bd9Sstevel@tonic-gate * When a control or bulk pipe is opened, the pipe's state is 8817c478bd9Sstevel@tonic-gate * automatically set to PIPE_STATE_ACTIVE. For an interrupt or 8827c478bd9Sstevel@tonic-gate * isochronous pipe, the pipe state becomes PIPE_STATE_ACTIVE once 8837c478bd9Sstevel@tonic-gate * the polling on the pipe has been initiated. 8847c478bd9Sstevel@tonic-gate * 8857c478bd9Sstevel@tonic-gate * PIPE_STATE_ERROR: 8867c478bd9Sstevel@tonic-gate * The device has generated a error on the pipe. The client driver 8877c478bd9Sstevel@tonic-gate * must call usb_pipe_reset() to clear any leftover state that's associated 8887c478bd9Sstevel@tonic-gate * with the pipe, clear the data toggle, and reset the state of the pipe. 8897c478bd9Sstevel@tonic-gate * 8907c478bd9Sstevel@tonic-gate * Calling usb_pipe_reset() on a control or bulk pipe resets the state to 8917c478bd9Sstevel@tonic-gate * PIPE_STATE_ACTIVE. Calling usb_pipe_reset() on an interrupt or 8927c478bd9Sstevel@tonic-gate * isochronous pipe, resets the state to PIPE_STATE_IDLE. 8937c478bd9Sstevel@tonic-gate * 8947c478bd9Sstevel@tonic-gate * State Diagram for Bulk/Control 8957c478bd9Sstevel@tonic-gate * 8967c478bd9Sstevel@tonic-gate * +-<--normal completion------------------<-------^ 8977c478bd9Sstevel@tonic-gate * | | 8987c478bd9Sstevel@tonic-gate * V | 8997c478bd9Sstevel@tonic-gate * usb_pipe_open-->[PIPE_STATE_IDLE]-usb_pipe_*_xfer->[PIPE_STATE_ACTIVE] 9007c478bd9Sstevel@tonic-gate * ^ | 9017c478bd9Sstevel@tonic-gate * | v 9027c478bd9Sstevel@tonic-gate * - usb_pipe_reset<-[PIPE_STATE_ERROR]<-device error 9037c478bd9Sstevel@tonic-gate * 9047c478bd9Sstevel@tonic-gate * State Diagram for Interrupt/Isochronous IN 9057c478bd9Sstevel@tonic-gate * 9067c478bd9Sstevel@tonic-gate * +-<--usb_pipe_stop_isoc/intr_polling----<-------^ 9077c478bd9Sstevel@tonic-gate * | | 9087c478bd9Sstevel@tonic-gate * V | 9097c478bd9Sstevel@tonic-gate * usb_pipe_open-->[PIPE_STATE_IDLE]-usb_pipe_*_xfer->[PIPE_STATE_ACTIVE] 9107c478bd9Sstevel@tonic-gate * ^ | 9117c478bd9Sstevel@tonic-gate * | v 9127c478bd9Sstevel@tonic-gate * + usb_pipe_reset<-[PIPE_STATE_ERROR]<-device error 9137c478bd9Sstevel@tonic-gate * 9147c478bd9Sstevel@tonic-gate * State Diagram for Interrupt/Isochronous OUT 9157c478bd9Sstevel@tonic-gate * 9167c478bd9Sstevel@tonic-gate * +-<--normal completion------------------<-------^ 9177c478bd9Sstevel@tonic-gate * | | 9187c478bd9Sstevel@tonic-gate * V | 9197c478bd9Sstevel@tonic-gate * usb_pipe_open-->[PIPE_STATE_IDLE]-usb_pipe_*_xfer->[PIPE_STATE_ACTIVE] 9207c478bd9Sstevel@tonic-gate * ^ | 9217c478bd9Sstevel@tonic-gate * | v 9227c478bd9Sstevel@tonic-gate * + usb_pipe_reset<-[PIPE_STATE_ERROR]<-device error 9237c478bd9Sstevel@tonic-gate * 9247c478bd9Sstevel@tonic-gate * 9257c478bd9Sstevel@tonic-gate * The following table indicates which operations are allowed with each 9267c478bd9Sstevel@tonic-gate * pipe state: 9277c478bd9Sstevel@tonic-gate * 9287c478bd9Sstevel@tonic-gate * -------------------------------------------------------------------------+ 9297c478bd9Sstevel@tonic-gate * ctrl/bulk | idle | active | error | sync closing | async closing| 9307c478bd9Sstevel@tonic-gate * -------------------------------------------------------------------------+ 9317c478bd9Sstevel@tonic-gate * pipe xfer | OK |queue (USBA)| reject | reject | reject | 9327c478bd9Sstevel@tonic-gate * pipe reset | no-op | OK | OK | reject | reject | 9337c478bd9Sstevel@tonic-gate * pipe close | OK | wait&close | OK | no-op | no-op | 9347c478bd9Sstevel@tonic-gate * -------------------------------------------------------------------------+ 9357c478bd9Sstevel@tonic-gate * 9367c478bd9Sstevel@tonic-gate * -------------------------------------------------------------------------+ 9377c478bd9Sstevel@tonic-gate * intr/isoc IN | idle | active | error | sync closing | async closing| 9387c478bd9Sstevel@tonic-gate * -------------------------------------------------------------------------+ 9397c478bd9Sstevel@tonic-gate * pipe xfer | OK | reject | reject | reject | reject | 9407c478bd9Sstevel@tonic-gate * pipe stoppoll| no-op | OK | no-op | reject | reject | 9417c478bd9Sstevel@tonic-gate * pipe reset | no-op | OK | OK | reject | reject | 9427c478bd9Sstevel@tonic-gate * pipe close | OK | wait&close | OK | no-op | no-op | 9437c478bd9Sstevel@tonic-gate * -------------------------------------------------------------------------+ 9447c478bd9Sstevel@tonic-gate * 9457c478bd9Sstevel@tonic-gate * -------------------------------------------------------------------------+ 9467c478bd9Sstevel@tonic-gate * intr/isoc OUT| idle | active | error | sync closing | async closing| 9477c478bd9Sstevel@tonic-gate * -------------------------------------------------------------------------+ 9487c478bd9Sstevel@tonic-gate * pipe xfer | OK |queue (HCD) | reject | reject | reject | 9497c478bd9Sstevel@tonic-gate * pipe stoppoll| reject| reject | reject | reject | reject | 9507c478bd9Sstevel@tonic-gate * pipe reset | no-op | OK | OK | reject | reject | 9517c478bd9Sstevel@tonic-gate * pipe close | OK | wait&close | OK | no-op | no-op | 9527c478bd9Sstevel@tonic-gate * -------------------------------------------------------------------------+ 9537c478bd9Sstevel@tonic-gate */ 9547c478bd9Sstevel@tonic-gate typedef enum { 9557c478bd9Sstevel@tonic-gate USB_PIPE_STATE_CLOSED = 0, 9567c478bd9Sstevel@tonic-gate USB_PIPE_STATE_IDLE = 1, 9577c478bd9Sstevel@tonic-gate USB_PIPE_STATE_ACTIVE = 2, 9587c478bd9Sstevel@tonic-gate USB_PIPE_STATE_ERROR = 3, 9597c478bd9Sstevel@tonic-gate USB_PIPE_STATE_CLOSING = 4 9607c478bd9Sstevel@tonic-gate } usb_pipe_state_t; 9617c478bd9Sstevel@tonic-gate 9627c478bd9Sstevel@tonic-gate 9637c478bd9Sstevel@tonic-gate /* 9647c478bd9Sstevel@tonic-gate * pipe state control: 9657c478bd9Sstevel@tonic-gate * 9667c478bd9Sstevel@tonic-gate * return values: 9677c478bd9Sstevel@tonic-gate * USB_SUCCESS - success 9687c478bd9Sstevel@tonic-gate * USB_FAILURE - unspecified failure 9697c478bd9Sstevel@tonic-gate */ 9707c478bd9Sstevel@tonic-gate int usb_pipe_get_state( 9717c478bd9Sstevel@tonic-gate usb_pipe_handle_t pipe_handle, 9727c478bd9Sstevel@tonic-gate usb_pipe_state_t *pipe_state, 9737c478bd9Sstevel@tonic-gate usb_flags_t flags); 9747c478bd9Sstevel@tonic-gate 9757c478bd9Sstevel@tonic-gate 9767c478bd9Sstevel@tonic-gate /* 9777c478bd9Sstevel@tonic-gate * usb_pipe_policy 9787c478bd9Sstevel@tonic-gate * 9797c478bd9Sstevel@tonic-gate * Pipe policy specifies how a pipe to an endpoint should be used 9807c478bd9Sstevel@tonic-gate * by the client driver and the HCD. 9817c478bd9Sstevel@tonic-gate */ 9827c478bd9Sstevel@tonic-gate typedef struct usb_pipe_policy { 9837c478bd9Sstevel@tonic-gate /* 9847c478bd9Sstevel@tonic-gate * This is a hint indicating how many asynchronous operations 9857c478bd9Sstevel@tonic-gate * requiring a kernel thread will be concurrently active. 9867c478bd9Sstevel@tonic-gate * Allow at least one for synch exception callback handling 9877c478bd9Sstevel@tonic-gate * and another for asynchronous closing of pipes. 9887c478bd9Sstevel@tonic-gate */ 9897c478bd9Sstevel@tonic-gate uchar_t pp_max_async_reqs; 9907c478bd9Sstevel@tonic-gate } usb_pipe_policy_t; 9917c478bd9Sstevel@tonic-gate 9927c478bd9Sstevel@tonic-gate 9937c478bd9Sstevel@tonic-gate /* 9947c478bd9Sstevel@tonic-gate * usb_pipe_open(): 9957c478bd9Sstevel@tonic-gate * 9967c478bd9Sstevel@tonic-gate * Before using any pipe including the default pipe, it must be opened. 9977c478bd9Sstevel@tonic-gate * On success, a pipe handle is returned for use in other usb_pipe_*() 9987c478bd9Sstevel@tonic-gate * functions. 9997c478bd9Sstevel@tonic-gate * 10007c478bd9Sstevel@tonic-gate * The default pipe can only be opened by the hub driver. 10017c478bd9Sstevel@tonic-gate * 10027c478bd9Sstevel@tonic-gate * For isochronous and interrupt pipes, bandwidth has been allocated and 10037c478bd9Sstevel@tonic-gate * guaranteed. 10047c478bd9Sstevel@tonic-gate * 10057c478bd9Sstevel@tonic-gate * Only the default pipe can be shared. All other control pipes are 10067c478bd9Sstevel@tonic-gate * excusively opened by default. A pipe policy and endpoint descriptor 10077c478bd9Sstevel@tonic-gate * must always be provided except for default pipe. 10087c478bd9Sstevel@tonic-gate * 10097c478bd9Sstevel@tonic-gate * Arguments: 10107c478bd9Sstevel@tonic-gate * dip - devinfo ptr. 10117c478bd9Sstevel@tonic-gate * ep - endpoint descriptor pointer. 10127c478bd9Sstevel@tonic-gate * pipe_policy - pointer to pipe policy which provides hints on how 10137c478bd9Sstevel@tonic-gate * the pipe will be used. 10147c478bd9Sstevel@tonic-gate * flags - USB_FLAGS_SLEEP wait for resources to become 10157c478bd9Sstevel@tonic-gate * available. 10167c478bd9Sstevel@tonic-gate * pipe_handle - a pipe handle pointer. on a successful open, 10177c478bd9Sstevel@tonic-gate * a pipe_handle is returned in this pointer. 10187c478bd9Sstevel@tonic-gate * 10197c478bd9Sstevel@tonic-gate * Return values: 10207c478bd9Sstevel@tonic-gate * USB_SUCCESS - open succeeded. 10217c478bd9Sstevel@tonic-gate * USB_FAILURE - unspecified open failure or pipe is already open. 10227c478bd9Sstevel@tonic-gate * USB_NO_RESOURCES - no resources were available to complete the open. 10237c478bd9Sstevel@tonic-gate * USB_NO_BANDWIDTH - no bandwidth available (isoc/intr pipes). 10247c478bd9Sstevel@tonic-gate * USB_* - refer to list of all possible return values in 10257c478bd9Sstevel@tonic-gate * this file 10267c478bd9Sstevel@tonic-gate */ 10277c478bd9Sstevel@tonic-gate int usb_pipe_open( 10287c478bd9Sstevel@tonic-gate dev_info_t *dip, 10297c478bd9Sstevel@tonic-gate usb_ep_descr_t *ep, 10307c478bd9Sstevel@tonic-gate usb_pipe_policy_t *pipe_policy, 10317c478bd9Sstevel@tonic-gate usb_flags_t flags, 10327c478bd9Sstevel@tonic-gate usb_pipe_handle_t *pipe_handle); 10337c478bd9Sstevel@tonic-gate 10347c478bd9Sstevel@tonic-gate 10357c478bd9Sstevel@tonic-gate /* 10367c478bd9Sstevel@tonic-gate * usb_pipe_close(): 10377c478bd9Sstevel@tonic-gate * 10387c478bd9Sstevel@tonic-gate * Closes the pipe, releases resources and frees the pipe_handle. 10397c478bd9Sstevel@tonic-gate * Automatic polling, if active, will be terminated. 10407c478bd9Sstevel@tonic-gate * 10417c478bd9Sstevel@tonic-gate * Arguments: 10427c478bd9Sstevel@tonic-gate * dip - devinfo ptr. 10437c478bd9Sstevel@tonic-gate * pipe_handle - pipe handle. 10447c478bd9Sstevel@tonic-gate * flags - USB_FLAGS_SLEEP: 10457c478bd9Sstevel@tonic-gate * wait for resources, pipe 10467c478bd9Sstevel@tonic-gate * to become free, and all callbacks completed. 10477c478bd9Sstevel@tonic-gate * cb - If USB_FLAGS_SLEEP has not been specified, a 10487c478bd9Sstevel@tonic-gate * callback will be performed. 10497c478bd9Sstevel@tonic-gate * cb_arg - the 2nd argument of the callback. Note that the 10507c478bd9Sstevel@tonic-gate * pipehandle will be zeroed and therefore not passed. 10517c478bd9Sstevel@tonic-gate * 10527c478bd9Sstevel@tonic-gate * Notes: 10537c478bd9Sstevel@tonic-gate * 10547c478bd9Sstevel@tonic-gate * Pipe close always succeeds regardless whether USB_FLAGS_SLEEP has been 10557c478bd9Sstevel@tonic-gate * specified or not. An async close will always succeed if the hint in the 10567c478bd9Sstevel@tonic-gate * pipe policy has been correct about the max number of async requests 10577c478bd9Sstevel@tonic-gate * required. 10587c478bd9Sstevel@tonic-gate * In the unlikely event that no async requests can be queued, this 10597c478bd9Sstevel@tonic-gate * function will continue retrying before returning 10607c478bd9Sstevel@tonic-gate * 10617c478bd9Sstevel@tonic-gate * USBA prevents the client from submitting subsequent requests to a pipe 10627c478bd9Sstevel@tonic-gate * that is being closed. 10637c478bd9Sstevel@tonic-gate * Additional usb_pipe_close() requests on the same pipe causes USBA to 10647c478bd9Sstevel@tonic-gate * wait for the previous close(s) to complete. 10657c478bd9Sstevel@tonic-gate * 10667c478bd9Sstevel@tonic-gate * The pipe will not be destroyed until all activity on the pipe has 10677c478bd9Sstevel@tonic-gate * been drained, including outstanding request callbacks, async requests, 10687c478bd9Sstevel@tonic-gate * and other usb_pipe_*() calls. 10697c478bd9Sstevel@tonic-gate * 10707c478bd9Sstevel@tonic-gate * Calling usb_pipe_close() from a deferred callback (in kernel context) 10717c478bd9Sstevel@tonic-gate * with USB_FLAGS_SLEEP set, will cause deadlock 10727c478bd9Sstevel@tonic-gate */ 10737c478bd9Sstevel@tonic-gate void usb_pipe_close( 10747c478bd9Sstevel@tonic-gate dev_info_t *dip, 10757c478bd9Sstevel@tonic-gate usb_pipe_handle_t pipe_handle, 10767c478bd9Sstevel@tonic-gate usb_flags_t flags, 10777c478bd9Sstevel@tonic-gate void (*cb)( 10787c478bd9Sstevel@tonic-gate usb_pipe_handle_t ph, 10797c478bd9Sstevel@tonic-gate usb_opaque_t arg, /* cb arg */ 10807c478bd9Sstevel@tonic-gate int rval, 10817c478bd9Sstevel@tonic-gate usb_cb_flags_t flags), 10827c478bd9Sstevel@tonic-gate usb_opaque_t cb_arg); 10837c478bd9Sstevel@tonic-gate 10847c478bd9Sstevel@tonic-gate 10857c478bd9Sstevel@tonic-gate /* 10867c478bd9Sstevel@tonic-gate * usb_pipe_drain_reqs 10877c478bd9Sstevel@tonic-gate * this function blocks until there are no more requests 10887c478bd9Sstevel@tonic-gate * owned by this dip on the pipe 10897c478bd9Sstevel@tonic-gate * 10907c478bd9Sstevel@tonic-gate * Arguments: 10917c478bd9Sstevel@tonic-gate * dip - devinfo pointer 10927c478bd9Sstevel@tonic-gate * pipe_handle - opaque pipe handle 10937c478bd9Sstevel@tonic-gate * timeout - timeout in seconds 10947c478bd9Sstevel@tonic-gate * flags - USB_FLAGS_SLEEP: 10957c478bd9Sstevel@tonic-gate * wait for completion. 10967c478bd9Sstevel@tonic-gate * cb - if USB_FLAGS_SLEEP has not been specified 10977c478bd9Sstevel@tonic-gate * this callback function will be called on 10987c478bd9Sstevel@tonic-gate * completion. This callback may be NULL 10997c478bd9Sstevel@tonic-gate * and no notification of completion will then 11007c478bd9Sstevel@tonic-gate * be provided. 11017c478bd9Sstevel@tonic-gate * cb_arg - 2nd argument to callback function. 11027c478bd9Sstevel@tonic-gate * 11037c478bd9Sstevel@tonic-gate * callback and callback_arg should be NULL if USB_FLAGS_SLEEP has 11047c478bd9Sstevel@tonic-gate * been specified 11057c478bd9Sstevel@tonic-gate * 11067c478bd9Sstevel@tonic-gate * Returns: 11077c478bd9Sstevel@tonic-gate * USB_SUCCESS - pipe successfully reset or request queued 11087c478bd9Sstevel@tonic-gate * USB_FAILURE - timeout 11097c478bd9Sstevel@tonic-gate * USB_INVALID_PIPE - pipe is invalid or already closed 11107c478bd9Sstevel@tonic-gate * USB_INVALID_CONTEXT - called from interrupt context 11117c478bd9Sstevel@tonic-gate * USB_INVALID_ARGS - invalid arguments 11127c478bd9Sstevel@tonic-gate * USB_* - refer to return values defines in this file 11137c478bd9Sstevel@tonic-gate */ 11147c478bd9Sstevel@tonic-gate int usb_pipe_drain_reqs( 11157c478bd9Sstevel@tonic-gate dev_info_t *dip, 11167c478bd9Sstevel@tonic-gate usb_pipe_handle_t pipe_handle, 11177c478bd9Sstevel@tonic-gate uint_t time, 11187c478bd9Sstevel@tonic-gate usb_flags_t flags, 11197c478bd9Sstevel@tonic-gate void (*cb)( 11207c478bd9Sstevel@tonic-gate usb_pipe_handle_t ph, 11217c478bd9Sstevel@tonic-gate usb_opaque_t arg, /* cb arg */ 11227c478bd9Sstevel@tonic-gate int rval, 11237c478bd9Sstevel@tonic-gate usb_cb_flags_t flags), 11247c478bd9Sstevel@tonic-gate usb_opaque_t cb_arg); 11257c478bd9Sstevel@tonic-gate 11267c478bd9Sstevel@tonic-gate 11277c478bd9Sstevel@tonic-gate /* 11287c478bd9Sstevel@tonic-gate * Resetting a pipe: Refer to USB 2.0/10.5.2.2 11297c478bd9Sstevel@tonic-gate * The pipe's requests are retired and the pipe is cleared. The host state 11307c478bd9Sstevel@tonic-gate * is moved to active. If the reflected endpoint state needs to be changed, 11317c478bd9Sstevel@tonic-gate * that must be explicitly requested by the client driver. The reset 11327c478bd9Sstevel@tonic-gate * completes after all request callbacks have been completed. 11337c478bd9Sstevel@tonic-gate * 11347c478bd9Sstevel@tonic-gate * Arguments: 11357c478bd9Sstevel@tonic-gate * dip - devinfo pointer. 11367c478bd9Sstevel@tonic-gate * pipe_handle - pipe handle. 11377c478bd9Sstevel@tonic-gate * flags - USB_FLAGS_SLEEP: 11387c478bd9Sstevel@tonic-gate * wait for completion. 11397c478bd9Sstevel@tonic-gate * cb - if USB_FLAGS_SLEEP has not been specified 11407c478bd9Sstevel@tonic-gate * this callback function will be called on 11417c478bd9Sstevel@tonic-gate * completion. This callback may be NULL 11427c478bd9Sstevel@tonic-gate * and no notification of completion will then 11437c478bd9Sstevel@tonic-gate * be provided. 11447c478bd9Sstevel@tonic-gate * cb_arg - 2nd argument to callback function. 11457c478bd9Sstevel@tonic-gate * 11467c478bd9Sstevel@tonic-gate * callback and callback_arg should be NULL if USB_FLAGS_SLEEP has 11477c478bd9Sstevel@tonic-gate * been specified 11487c478bd9Sstevel@tonic-gate * 11497c478bd9Sstevel@tonic-gate * Note: Completion notification may be *before* all async request threads 11507c478bd9Sstevel@tonic-gate * have completed but *after* all immediate callbacks have completed. 11517c478bd9Sstevel@tonic-gate */ 11527c478bd9Sstevel@tonic-gate void usb_pipe_reset( 11537c478bd9Sstevel@tonic-gate dev_info_t *dip, 11547c478bd9Sstevel@tonic-gate usb_pipe_handle_t pipe_handle, 11557c478bd9Sstevel@tonic-gate usb_flags_t usb_flags, 11567c478bd9Sstevel@tonic-gate void (*cb)( 11577c478bd9Sstevel@tonic-gate usb_pipe_handle_t ph, 11587c478bd9Sstevel@tonic-gate usb_opaque_t arg, 11597c478bd9Sstevel@tonic-gate int rval, 11607c478bd9Sstevel@tonic-gate usb_cb_flags_t flags), 11617c478bd9Sstevel@tonic-gate usb_opaque_t cb_arg); 11627c478bd9Sstevel@tonic-gate 11637c478bd9Sstevel@tonic-gate 11647c478bd9Sstevel@tonic-gate /* 11657c478bd9Sstevel@tonic-gate * The client driver can store a private data pointer in the 11667c478bd9Sstevel@tonic-gate * pipe_handle. 11677c478bd9Sstevel@tonic-gate * 11687c478bd9Sstevel@tonic-gate * return values: 11697c478bd9Sstevel@tonic-gate * USB_SUCCESS - success 11707c478bd9Sstevel@tonic-gate * USB_FAILURE - unspecified failure 11717c478bd9Sstevel@tonic-gate */ 11727c478bd9Sstevel@tonic-gate int usb_pipe_set_private( 11737c478bd9Sstevel@tonic-gate usb_pipe_handle_t pipe_handle, 11747c478bd9Sstevel@tonic-gate usb_opaque_t data); 11757c478bd9Sstevel@tonic-gate 11767c478bd9Sstevel@tonic-gate 11777c478bd9Sstevel@tonic-gate usb_opaque_t usb_pipe_get_private( 11787c478bd9Sstevel@tonic-gate usb_pipe_handle_t pipe_handle); 11797c478bd9Sstevel@tonic-gate 11807c478bd9Sstevel@tonic-gate 11817c478bd9Sstevel@tonic-gate /* 11827c478bd9Sstevel@tonic-gate * *************************************************************************** 11837c478bd9Sstevel@tonic-gate * Transfer request definitions and functions 11847c478bd9Sstevel@tonic-gate * *************************************************************************** 11857c478bd9Sstevel@tonic-gate */ 11867c478bd9Sstevel@tonic-gate 11877c478bd9Sstevel@tonic-gate 11887c478bd9Sstevel@tonic-gate /* 11897c478bd9Sstevel@tonic-gate * USB xfer request attributes. 11907c478bd9Sstevel@tonic-gate * Set by the client driver, more than one may be set 11917c478bd9Sstevel@tonic-gate * 11927c478bd9Sstevel@tonic-gate * SHORT_XFER_OK if less data is transferred than specified, no error is 11937c478bd9Sstevel@tonic-gate * returned. 11947c478bd9Sstevel@tonic-gate * AUTOCLEARING if there is an exception, the pipe will be reset first 11957c478bd9Sstevel@tonic-gate * and a functional stall cleared before a callback is done. 11967c478bd9Sstevel@tonic-gate * PIPE_RESET if there is an exception, the pipe will be reset only 11977c478bd9Sstevel@tonic-gate * ONE_XFER polling will automatically stop on the first callback. 11987c478bd9Sstevel@tonic-gate * ISOC_START_FRAME use startframe specified. 11997c478bd9Sstevel@tonic-gate * USB_ATTRS_ISOC_XFER_ASAP let the host controller decide on the first 12007c478bd9Sstevel@tonic-gate * available frame. 12017c478bd9Sstevel@tonic-gate * 12027c478bd9Sstevel@tonic-gate * USB_ATTRS_ISOC_START_FRAME and USB_ATTRS_ISOC_XFER_ASAP are mutually 12037c478bd9Sstevel@tonic-gate * exclusive 12047c478bd9Sstevel@tonic-gate * 12057c478bd9Sstevel@tonic-gate * combinations of flag and attributes: 12067c478bd9Sstevel@tonic-gate * 12077c478bd9Sstevel@tonic-gate * usb_flags usb_req_attrs semantics 12087c478bd9Sstevel@tonic-gate * --------------------------------------------------------- 12097c478bd9Sstevel@tonic-gate * SLEEP USB_ATTRS_SHORT_XFER_OK legal for IN pipes 12107c478bd9Sstevel@tonic-gate * SLEEP USB_ATTRS_AUTOCLEARING legal 12117c478bd9Sstevel@tonic-gate * SLEEP USB_ATTRS_PIPE_RESET legal 12127c478bd9Sstevel@tonic-gate * SLEEP USB_ATTRS_ONE_XFER legal for interrupt IN pipes 12137c478bd9Sstevel@tonic-gate * SLEEP USB_ATTRS_ISOC_START_FRAME illegal 12147c478bd9Sstevel@tonic-gate * SLEEP USB_ATTRS_ISOC_XFER_ASAP illegal 12157c478bd9Sstevel@tonic-gate * 12167c478bd9Sstevel@tonic-gate * noSLEEP USB_ATTRS_SHORT_XFER_OK legal for all IN pipes 12177c478bd9Sstevel@tonic-gate * noSLEEP USB_ATTRS_AUTOCLEARING legal 12187c478bd9Sstevel@tonic-gate * noSLEEP USB_ATTRS_PIPE_RESET legal 12197c478bd9Sstevel@tonic-gate * noSLEEP USB_ATTRS_ONE_XFER legal 12207c478bd9Sstevel@tonic-gate * noSLEEP USB_ATTRS_ISOC_START_FRAME legal 12217c478bd9Sstevel@tonic-gate * noSLEEP USB_ATTRS_ISOC_XFER_ASAP legal 12227c478bd9Sstevel@tonic-gate */ 12237c478bd9Sstevel@tonic-gate typedef enum { 12247c478bd9Sstevel@tonic-gate USB_ATTRS_NONE = 0, 12257c478bd9Sstevel@tonic-gate 12267c478bd9Sstevel@tonic-gate /* only ctrl/bulk/intr IN pipes */ 12277c478bd9Sstevel@tonic-gate USB_ATTRS_SHORT_XFER_OK = 0x01, /* short data xfer is ok */ 12287c478bd9Sstevel@tonic-gate USB_ATTRS_PIPE_RESET = 0x02, /* reset pipe only on exc */ 12297c478bd9Sstevel@tonic-gate USB_ATTRS_AUTOCLEARING = 0x12, /* autoclear STALLs */ 12307c478bd9Sstevel@tonic-gate 12317c478bd9Sstevel@tonic-gate /* intr pipes only: one poll with data */ 12327c478bd9Sstevel@tonic-gate USB_ATTRS_ONE_XFER = 0x100, 12337c478bd9Sstevel@tonic-gate 12347c478bd9Sstevel@tonic-gate /* only for isoch pipe */ 12357c478bd9Sstevel@tonic-gate USB_ATTRS_ISOC_START_FRAME = 0x200, /* Starting frame# specified */ 12367c478bd9Sstevel@tonic-gate USB_ATTRS_ISOC_XFER_ASAP = 0x400 /* HCD decides START_FRAME# */ 12377c478bd9Sstevel@tonic-gate } usb_req_attrs_t; 12387c478bd9Sstevel@tonic-gate 12397c478bd9Sstevel@tonic-gate 12407c478bd9Sstevel@tonic-gate /* 12417c478bd9Sstevel@tonic-gate * Note: client drivers are required to provide data buffers (mblks) for most 12427c478bd9Sstevel@tonic-gate * requests 12437c478bd9Sstevel@tonic-gate * IN OUT 12447c478bd9Sstevel@tonic-gate * ctlr request if wLength > 0 if wLength > 0 12457c478bd9Sstevel@tonic-gate * bulk request yes yes 12467c478bd9Sstevel@tonic-gate * intr request no yes 12477c478bd9Sstevel@tonic-gate * isoc request no yes 12487c478bd9Sstevel@tonic-gate */ 12497c478bd9Sstevel@tonic-gate 12507c478bd9Sstevel@tonic-gate /* 12517c478bd9Sstevel@tonic-gate * =========================================================================== 12527c478bd9Sstevel@tonic-gate * USB control request management 12537c478bd9Sstevel@tonic-gate * =========================================================================== 12547c478bd9Sstevel@tonic-gate */ 12557c478bd9Sstevel@tonic-gate 12567c478bd9Sstevel@tonic-gate /* 12577c478bd9Sstevel@tonic-gate * A client driver allocates and uses the usb_ctrl_req_t for all control 12587c478bd9Sstevel@tonic-gate * pipe requests. 12597c478bd9Sstevel@tonic-gate * 12607c478bd9Sstevel@tonic-gate * Direction of the xfer will be determined based on the bmRequestType. 12617c478bd9Sstevel@tonic-gate * 12627c478bd9Sstevel@tonic-gate * NULL callbacks are permitted, timeout = 0 indicates infinite timeout. 12637c478bd9Sstevel@tonic-gate * All timeouts are in seconds. 12647c478bd9Sstevel@tonic-gate * 12657c478bd9Sstevel@tonic-gate * All fields are initialized by client except for data on IN request 12667c478bd9Sstevel@tonic-gate * in which case the client is responsible for deallocating. 12677c478bd9Sstevel@tonic-gate * 12687c478bd9Sstevel@tonic-gate * Control requests may be reused. The client driver is responsible 12697c478bd9Sstevel@tonic-gate * for reinitializing some fields, eg data read/write pointers. 12707c478bd9Sstevel@tonic-gate * 12717c478bd9Sstevel@tonic-gate * Control requests can be queued. 12727c478bd9Sstevel@tonic-gate */ 12737c478bd9Sstevel@tonic-gate typedef struct usb_ctrl_req { 12747c478bd9Sstevel@tonic-gate uint8_t ctrl_bmRequestType; /* characteristics of request */ 12757c478bd9Sstevel@tonic-gate uint8_t ctrl_bRequest; /* specific request */ 12767c478bd9Sstevel@tonic-gate uint16_t ctrl_wValue; /* varies according to request */ 12777c478bd9Sstevel@tonic-gate uint16_t ctrl_wIndex; /* index or offset */ 12787c478bd9Sstevel@tonic-gate uint16_t ctrl_wLength; /* number of bytes to xfer */ 12797c478bd9Sstevel@tonic-gate 12807c478bd9Sstevel@tonic-gate mblk_t *ctrl_data; /* the data for the data phase */ 12817c478bd9Sstevel@tonic-gate /* IN: allocated by HCD */ 12827c478bd9Sstevel@tonic-gate /* OUT: allocated by client */ 12837c478bd9Sstevel@tonic-gate uint_t ctrl_timeout; /* how long before HCD retires req */ 12847c478bd9Sstevel@tonic-gate usb_opaque_t ctrl_client_private; /* for client private info */ 12857c478bd9Sstevel@tonic-gate usb_req_attrs_t ctrl_attributes; /* attributes for this req */ 12867c478bd9Sstevel@tonic-gate 12877c478bd9Sstevel@tonic-gate /* 12887c478bd9Sstevel@tonic-gate * callback function for control pipe requests 12897c478bd9Sstevel@tonic-gate * 12907c478bd9Sstevel@tonic-gate * a normal callback will be done upon: 12917c478bd9Sstevel@tonic-gate * - successful completion of a control pipe request 12927c478bd9Sstevel@tonic-gate * 12937c478bd9Sstevel@tonic-gate * callback arguments are: 12947c478bd9Sstevel@tonic-gate * - the pipe_handle 12957c478bd9Sstevel@tonic-gate * - usb_ctrl_req_t pointer 12967c478bd9Sstevel@tonic-gate */ 12977c478bd9Sstevel@tonic-gate void (*ctrl_cb)(usb_pipe_handle_t ph, 12987c478bd9Sstevel@tonic-gate struct usb_ctrl_req *req); 12997c478bd9Sstevel@tonic-gate 13007c478bd9Sstevel@tonic-gate /* 13017c478bd9Sstevel@tonic-gate * exception callback function for control pipe 13027c478bd9Sstevel@tonic-gate * 13037c478bd9Sstevel@tonic-gate * a exception callback will be done upon: 13047c478bd9Sstevel@tonic-gate * - an exception/error (all types) 13057c478bd9Sstevel@tonic-gate * - partial xfer of data unless SHORT_XFER_OK has been set 13067c478bd9Sstevel@tonic-gate * 13077c478bd9Sstevel@tonic-gate * callback arguments are: 13087c478bd9Sstevel@tonic-gate * - the pipe_handle 13097c478bd9Sstevel@tonic-gate * - usb_ctrl_req_t pointer 13107c478bd9Sstevel@tonic-gate * 13117c478bd9Sstevel@tonic-gate * if USB_ATTRS_AUTOCLEARING was set, autoclearing will be attempted 13127c478bd9Sstevel@tonic-gate * and usb_cb_flags_t in usb_ctrl_req may indicate what was done 13137c478bd9Sstevel@tonic-gate */ 13147c478bd9Sstevel@tonic-gate void (*ctrl_exc_cb)(usb_pipe_handle_t ph, 13157c478bd9Sstevel@tonic-gate struct usb_ctrl_req *req); 13167c478bd9Sstevel@tonic-gate 13177c478bd9Sstevel@tonic-gate /* set by USBA/HCD on completion */ 13187c478bd9Sstevel@tonic-gate usb_cr_t ctrl_completion_reason; /* set by HCD */ 13197c478bd9Sstevel@tonic-gate usb_cb_flags_t ctrl_cb_flags; /* Callback context / handling flgs */ 13207c478bd9Sstevel@tonic-gate } usb_ctrl_req_t; 13217c478bd9Sstevel@tonic-gate 13227c478bd9Sstevel@tonic-gate 13237c478bd9Sstevel@tonic-gate /* 13247c478bd9Sstevel@tonic-gate * In the setup packet, the descriptor type is passed in the high byte of the 13257c478bd9Sstevel@tonic-gate * wValue field. 13267c478bd9Sstevel@tonic-gate * descriptor types: 13277c478bd9Sstevel@tonic-gate */ 13287c478bd9Sstevel@tonic-gate #define USB_DESCR_TYPE_SETUP_DEV 0x0100 13297c478bd9Sstevel@tonic-gate #define USB_DESCR_TYPE_SETUP_CFG 0x0200 13307c478bd9Sstevel@tonic-gate #define USB_DESCR_TYPE_SETUP_STRING 0x0300 13317c478bd9Sstevel@tonic-gate #define USB_DESCR_TYPE_SETUP_IF 0x0400 13327c478bd9Sstevel@tonic-gate #define USB_DESCR_TYPE_SETUP_EP 0x0500 13337c478bd9Sstevel@tonic-gate #define USB_DESCR_TYPE_SETUP_DEV_QLF 0x0600 13347c478bd9Sstevel@tonic-gate #define USB_DESCR_TYPE_SETUP_OTHER_SPEED_CFG 0x0700 13357c478bd9Sstevel@tonic-gate #define USB_DESCR_TYPE_SETUP_IF_PWR 0x0800 13367c478bd9Sstevel@tonic-gate 13377c478bd9Sstevel@tonic-gate #define USB_DESCR_TYPE_DEV 0x01 13387c478bd9Sstevel@tonic-gate #define USB_DESCR_TYPE_CFG 0x02 13397c478bd9Sstevel@tonic-gate #define USB_DESCR_TYPE_STRING 0x03 13407c478bd9Sstevel@tonic-gate #define USB_DESCR_TYPE_IF 0x04 13417c478bd9Sstevel@tonic-gate #define USB_DESCR_TYPE_EP 0x05 13427c478bd9Sstevel@tonic-gate #define USB_DESCR_TYPE_DEV_QLF 0x06 13437c478bd9Sstevel@tonic-gate #define USB_DESCR_TYPE_OTHER_SPEED_CFG 0x07 13447c478bd9Sstevel@tonic-gate #define USB_DESCR_TYPE_IF_PWR 0x08 1345d73ae94eSgc161489 #define USB_DESCR_TYPE_IA 0x0B 13467c478bd9Sstevel@tonic-gate 1347ff0e937bSRaymond Chen #define USB_DESCR_TYPE_WA 0x21 1348ff0e937bSRaymond Chen #define USB_DESCR_TYPE_RPIPE 0x22 1349ff0e937bSRaymond Chen 1350ff0e937bSRaymond Chen /* Wireless USB extension, refer to WUSB 1.0/7.4 */ 1351ff0e937bSRaymond Chen #define USB_DESCR_TYPE_SECURITY 0x0c 1352ff0e937bSRaymond Chen #define USB_DESCR_TYPE_KEY 0x0d 1353ff0e937bSRaymond Chen #define USB_DESCR_TYPE_ENCRYPTION 0x0e 1354ff0e937bSRaymond Chen #define USB_DESCR_TYPE_BOS 0x0f 1355ff0e937bSRaymond Chen #define USB_DESCR_TYPE_DEV_CAPABILITY 0x10 1356ff0e937bSRaymond Chen #define USB_DESCR_TYPE_WIRELESS_EP_COMP 0x11 1357ff0e937bSRaymond Chen 1358ff0e937bSRaymond Chen #define USB_WA_DESCR_SIZE 14 1359ff0e937bSRaymond Chen #define USB_RPIPE_DESCR_SIZE 28 1360ff0e937bSRaymond Chen 13617c478bd9Sstevel@tonic-gate /* 13627c478bd9Sstevel@tonic-gate * device request type 13637c478bd9Sstevel@tonic-gate */ 13647c478bd9Sstevel@tonic-gate #define USB_DEV_REQ_HOST_TO_DEV 0x00 13657c478bd9Sstevel@tonic-gate #define USB_DEV_REQ_DEV_TO_HOST 0x80 13667c478bd9Sstevel@tonic-gate #define USB_DEV_REQ_DIR_MASK 0x80 13677c478bd9Sstevel@tonic-gate 13687c478bd9Sstevel@tonic-gate #define USB_DEV_REQ_TYPE_STANDARD 0x00 13697c478bd9Sstevel@tonic-gate #define USB_DEV_REQ_TYPE_CLASS 0x20 13707c478bd9Sstevel@tonic-gate #define USB_DEV_REQ_TYPE_VENDOR 0x40 13717c478bd9Sstevel@tonic-gate #define USB_DEV_REQ_TYPE_MASK 0x60 13727c478bd9Sstevel@tonic-gate 13737c478bd9Sstevel@tonic-gate #define USB_DEV_REQ_RCPT_DEV 0x00 13747c478bd9Sstevel@tonic-gate #define USB_DEV_REQ_RCPT_IF 0x01 13757c478bd9Sstevel@tonic-gate #define USB_DEV_REQ_RCPT_EP 0x02 13767c478bd9Sstevel@tonic-gate #define USB_DEV_REQ_RCPT_OTHER 0x03 13777c478bd9Sstevel@tonic-gate #define USB_DEV_REQ_RCPT_MASK 0x03 13787c478bd9Sstevel@tonic-gate 1379ff0e937bSRaymond Chen /* Wire adapter class extension for request recipient */ 1380ff0e937bSRaymond Chen #define USB_DEV_REQ_RCPT_PORT 0x04 1381ff0e937bSRaymond Chen #define USB_DEV_REQ_RCPT_RPIPE 0x05 1382ff0e937bSRaymond Chen 13837c478bd9Sstevel@tonic-gate /* 13847c478bd9Sstevel@tonic-gate * device request 13857c478bd9Sstevel@tonic-gate */ 13867c478bd9Sstevel@tonic-gate #define USB_REQ_GET_STATUS 0x00 13877c478bd9Sstevel@tonic-gate #define USB_REQ_CLEAR_FEATURE 0x01 13887c478bd9Sstevel@tonic-gate #define USB_REQ_SET_FEATURE 0x03 13897c478bd9Sstevel@tonic-gate #define USB_REQ_SET_ADDRESS 0x05 13907c478bd9Sstevel@tonic-gate #define USB_REQ_GET_DESCR 0x06 13917c478bd9Sstevel@tonic-gate #define USB_REQ_SET_DESCR 0x07 13927c478bd9Sstevel@tonic-gate #define USB_REQ_GET_CFG 0x08 13937c478bd9Sstevel@tonic-gate #define USB_REQ_SET_CFG 0x09 13947c478bd9Sstevel@tonic-gate #define USB_REQ_GET_IF 0x0a 13957c478bd9Sstevel@tonic-gate #define USB_REQ_SET_IF 0x0b 13967c478bd9Sstevel@tonic-gate #define USB_REQ_SYNC_FRAME 0x0c 1397ff0e937bSRaymond Chen /* Wireless USB extension, refer to WUSB 1.0/7.3.1 */ 1398ff0e937bSRaymond Chen #define USB_REQ_SET_ENCRYPTION 0x0d 1399ff0e937bSRaymond Chen #define USB_REQ_GET_ENCRYPTION 0x0e 1400ff0e937bSRaymond Chen #define USB_REQ_RPIPE_ABORT 0x0e 1401ff0e937bSRaymond Chen #define USB_REQ_SET_HANDSHAKE 0x0f 1402ff0e937bSRaymond Chen #define USB_REQ_RPIPE_RESET 0x0f 1403ff0e937bSRaymond Chen #define USB_REQ_GET_HANDSHAKE 0x10 1404ff0e937bSRaymond Chen #define USB_REQ_SET_CONNECTION 0x11 1405ff0e937bSRaymond Chen #define USB_REQ_SET_SECURITY_DATA 0x12 1406ff0e937bSRaymond Chen #define USB_REQ_GET_SECURITY_DATA 0x13 1407ff0e937bSRaymond Chen #define USB_REQ_SET_WUSB_DATA 0x14 1408ff0e937bSRaymond Chen #define USB_REQ_LOOPBACK_DATA_WRITE 0x15 1409ff0e937bSRaymond Chen #define USB_REQ_LOOPBACK_DATA_READ 0x16 1410ff0e937bSRaymond Chen #define USB_REQ_SET_INTERFACE_DS 0x17 14117c478bd9Sstevel@tonic-gate 14127c478bd9Sstevel@tonic-gate /* language ID for string descriptors */ 14137c478bd9Sstevel@tonic-gate #define USB_LANG_ID 0x0409 14147c478bd9Sstevel@tonic-gate 14157c478bd9Sstevel@tonic-gate /* 14167c478bd9Sstevel@tonic-gate * Standard Feature Selectors 14177c478bd9Sstevel@tonic-gate */ 14187c478bd9Sstevel@tonic-gate #define USB_EP_HALT 0x0000 14197c478bd9Sstevel@tonic-gate #define USB_DEV_REMOTE_WAKEUP 0x0001 14207c478bd9Sstevel@tonic-gate #define USB_DEV_TEST_MODE 0x0002 1421ff0e937bSRaymond Chen /* Wireless USB extension, refer to WUSB 1.0/7.3.1 */ 1422ff0e937bSRaymond Chen #define USB_DEV_WUSB 0x0003 14237c478bd9Sstevel@tonic-gate 14247c478bd9Sstevel@tonic-gate 14257c478bd9Sstevel@tonic-gate /* 14267c478bd9Sstevel@tonic-gate * Allocate usb control request 14277c478bd9Sstevel@tonic-gate * 14287c478bd9Sstevel@tonic-gate * Arguments: 14297c478bd9Sstevel@tonic-gate * dip - dev_info pointer of the client driver 14307c478bd9Sstevel@tonic-gate * len - length of "data" for this control request. 14317c478bd9Sstevel@tonic-gate * if 0, no mblk is alloc'ed 14327c478bd9Sstevel@tonic-gate * flags - USB_FLAGS_SLEEP: Sleep if resources are not available 14337c478bd9Sstevel@tonic-gate * 14347c478bd9Sstevel@tonic-gate * Return Values: 14357c478bd9Sstevel@tonic-gate * usb_ctrl_req_t pointer on success, NULL on failure 14367c478bd9Sstevel@tonic-gate * 14377c478bd9Sstevel@tonic-gate * Implementation NOTE: the dip allows checking on detach for memory leaks 14387c478bd9Sstevel@tonic-gate */ 14397c478bd9Sstevel@tonic-gate usb_ctrl_req_t *usb_alloc_ctrl_req( 14407c478bd9Sstevel@tonic-gate dev_info_t *dip, 14417c478bd9Sstevel@tonic-gate size_t len, 14427c478bd9Sstevel@tonic-gate usb_flags_t flags); 14437c478bd9Sstevel@tonic-gate 14447c478bd9Sstevel@tonic-gate 14457c478bd9Sstevel@tonic-gate /* 14467c478bd9Sstevel@tonic-gate * free USB control request 14477c478bd9Sstevel@tonic-gate */ 14487c478bd9Sstevel@tonic-gate void usb_free_ctrl_req( 14497c478bd9Sstevel@tonic-gate usb_ctrl_req_t *reqp); 14507c478bd9Sstevel@tonic-gate 14517c478bd9Sstevel@tonic-gate 14527c478bd9Sstevel@tonic-gate /* 14537c478bd9Sstevel@tonic-gate * usb_pipe_ctrl_xfer(); 14547c478bd9Sstevel@tonic-gate * Client driver calls this function to issue the control 14557c478bd9Sstevel@tonic-gate * request to the USBA which will queue or transport it to the device 14567c478bd9Sstevel@tonic-gate * 14577c478bd9Sstevel@tonic-gate * Arguments: 14587c478bd9Sstevel@tonic-gate * pipe_handle - control pipe pipehandle (obtained via usb_pipe_open() 14597c478bd9Sstevel@tonic-gate * reqp - pointer to control request 14607c478bd9Sstevel@tonic-gate * flags - USB_FLAGS_SLEEP: 14617c478bd9Sstevel@tonic-gate * wait for the request to complete 14627c478bd9Sstevel@tonic-gate * 14637c478bd9Sstevel@tonic-gate * Return values: 14647c478bd9Sstevel@tonic-gate * USB_SUCCESS - successfully queued (no sleep) or successfully 14657c478bd9Sstevel@tonic-gate * completed (with sleep specified) 14667c478bd9Sstevel@tonic-gate * USB_FAILURE - failure 14677c478bd9Sstevel@tonic-gate * USB_NO_RESOURCES - no resources 14687c478bd9Sstevel@tonic-gate */ 14697c478bd9Sstevel@tonic-gate int usb_pipe_ctrl_xfer(usb_pipe_handle_t pipe_handle, 14707c478bd9Sstevel@tonic-gate usb_ctrl_req_t *reqp, 14717c478bd9Sstevel@tonic-gate usb_flags_t flags); 14727c478bd9Sstevel@tonic-gate 14737c478bd9Sstevel@tonic-gate 14747c478bd9Sstevel@tonic-gate /* 14757c478bd9Sstevel@tonic-gate * --------------------------------------------------------------------------- 14767c478bd9Sstevel@tonic-gate * Wrapper function which allocates and deallocates a request structure, and 14777c478bd9Sstevel@tonic-gate * performs a control transfer. 14787c478bd9Sstevel@tonic-gate * --------------------------------------------------------------------------- 14797c478bd9Sstevel@tonic-gate */ 14807c478bd9Sstevel@tonic-gate 14817c478bd9Sstevel@tonic-gate /* 14827c478bd9Sstevel@tonic-gate * Setup arguments for usb_pipe_ctrl_xfer_wait: 14837c478bd9Sstevel@tonic-gate * 14847c478bd9Sstevel@tonic-gate * bmRequestType - characteristics of request 14857c478bd9Sstevel@tonic-gate * bRequest - specific request 14867c478bd9Sstevel@tonic-gate * wValue - varies according to request 14877c478bd9Sstevel@tonic-gate * wIndex - index or offset 14887c478bd9Sstevel@tonic-gate * wLength - number of bytes to xfer 14897c478bd9Sstevel@tonic-gate * attrs - required request attributes 14907c478bd9Sstevel@tonic-gate * data - pointer to pointer to data 14917c478bd9Sstevel@tonic-gate * IN: HCD will allocate data 14927c478bd9Sstevel@tonic-gate * OUT: clients driver allocates data 14937c478bd9Sstevel@tonic-gate */ 14947c478bd9Sstevel@tonic-gate typedef struct usb_ctrl_setup { 14957c478bd9Sstevel@tonic-gate uchar_t bmRequestType; 14967c478bd9Sstevel@tonic-gate uchar_t bRequest; 14977c478bd9Sstevel@tonic-gate uint16_t wValue; 14987c478bd9Sstevel@tonic-gate uint16_t wIndex; 14997c478bd9Sstevel@tonic-gate uint16_t wLength; 15007c478bd9Sstevel@tonic-gate usb_req_attrs_t attrs; 15017c478bd9Sstevel@tonic-gate } usb_ctrl_setup_t; 15027c478bd9Sstevel@tonic-gate 15037c478bd9Sstevel@tonic-gate 15047c478bd9Sstevel@tonic-gate /* 15057c478bd9Sstevel@tonic-gate * usb_pipe_ctrl_xfer_wait(): 15067c478bd9Sstevel@tonic-gate * for simple synchronous control transactions this wrapper function 15077c478bd9Sstevel@tonic-gate * will perform the allocation, xfer, and deallocation. 15087c478bd9Sstevel@tonic-gate * USB_ATTRS_AUTOCLEARING will be enabled 15097c478bd9Sstevel@tonic-gate * 15107c478bd9Sstevel@tonic-gate * Arguments: 15117c478bd9Sstevel@tonic-gate * pipe_handle - control pipe pipehandle (obtained via usb_pipe_open()) 15127c478bd9Sstevel@tonic-gate * setup - contains pointer to client's devinfo, 15137c478bd9Sstevel@tonic-gate * setup descriptor params, attributes and data 15147c478bd9Sstevel@tonic-gate * completion_reason - completion status. 15157c478bd9Sstevel@tonic-gate * cb_flags - request completions flags. 15167c478bd9Sstevel@tonic-gate * flags - none. 15177c478bd9Sstevel@tonic-gate * 15187c478bd9Sstevel@tonic-gate * Return Values: 15197c478bd9Sstevel@tonic-gate * USB_SUCCESS - request successfully executed. 15207c478bd9Sstevel@tonic-gate * USB_FAILURE - request failed. 15217c478bd9Sstevel@tonic-gate * USB_* - refer to list of all possible return values in 15227c478bd9Sstevel@tonic-gate * this file 15237c478bd9Sstevel@tonic-gate * 15247c478bd9Sstevel@tonic-gate * NOTES: 15257c478bd9Sstevel@tonic-gate * - in the case of failure, the client should check completion_reason and 15267c478bd9Sstevel@tonic-gate * and cb_flags and determine further recovery action 15277c478bd9Sstevel@tonic-gate * - the client should check data and if non-zero, free the data on 15287c478bd9Sstevel@tonic-gate * completion 15297c478bd9Sstevel@tonic-gate */ 15307c478bd9Sstevel@tonic-gate int usb_pipe_ctrl_xfer_wait( 15317c478bd9Sstevel@tonic-gate usb_pipe_handle_t pipe_handle, 15327c478bd9Sstevel@tonic-gate usb_ctrl_setup_t *setup, 15337c478bd9Sstevel@tonic-gate mblk_t **data, 15347c478bd9Sstevel@tonic-gate usb_cr_t *completion_reason, 15357c478bd9Sstevel@tonic-gate usb_cb_flags_t *cb_flags, 15367c478bd9Sstevel@tonic-gate usb_flags_t flags); 15377c478bd9Sstevel@tonic-gate 15387c478bd9Sstevel@tonic-gate 15397c478bd9Sstevel@tonic-gate /* 15407c478bd9Sstevel@tonic-gate * --------------------------------------------------------------------------- 15417c478bd9Sstevel@tonic-gate * Some utility defines and wrapper functions for standard control requests. 15427c478bd9Sstevel@tonic-gate * --------------------------------------------------------------------------- 15437c478bd9Sstevel@tonic-gate */ 15447c478bd9Sstevel@tonic-gate 15457c478bd9Sstevel@tonic-gate /* 15467c478bd9Sstevel@tonic-gate * 15477c478bd9Sstevel@tonic-gate * Status bits returned by a usb_get_status(). 15487c478bd9Sstevel@tonic-gate */ 15497c478bd9Sstevel@tonic-gate #define USB_DEV_SLF_PWRD_STATUS 1 /* Supports Self Power */ 15507c478bd9Sstevel@tonic-gate #define USB_DEV_RWAKEUP_STATUS 2 /* Remote Wakeup Enabled */ 1551ff0e937bSRaymond Chen #define USB_DEV_BAT_PWRD_STATUS 4 /* Battery Powered */ 15527c478bd9Sstevel@tonic-gate #define USB_EP_HALT_STATUS 1 /* Endpoint is Halted */ 15537c478bd9Sstevel@tonic-gate #define USB_IF_STATUS 0 /* Interface Status is 0 */ 15547c478bd9Sstevel@tonic-gate 15557c478bd9Sstevel@tonic-gate /* length of data returned by USB_REQ_GET_STATUS */ 15567c478bd9Sstevel@tonic-gate #define USB_GET_STATUS_LEN 2 15577c478bd9Sstevel@tonic-gate 15587c478bd9Sstevel@tonic-gate /* 15597c478bd9Sstevel@tonic-gate * wrapper function returning status of device, interface, or endpoint 15607c478bd9Sstevel@tonic-gate * 15617c478bd9Sstevel@tonic-gate * Arguments: 15627c478bd9Sstevel@tonic-gate * dip - devinfo pointer. 15637c478bd9Sstevel@tonic-gate * ph - pipe handle 15647c478bd9Sstevel@tonic-gate * type - bmRequestType to be used 15657c478bd9Sstevel@tonic-gate * what - 0 for device, otherwise interface or ep number 15667c478bd9Sstevel@tonic-gate * status - pointer to returned status. 15677c478bd9Sstevel@tonic-gate * flags - USB_FLAGS_SLEEP (mandatory) 15687c478bd9Sstevel@tonic-gate * 15697c478bd9Sstevel@tonic-gate * Return Values: 15707c478bd9Sstevel@tonic-gate * valid usb_status_t or USB_FAILURE 15717c478bd9Sstevel@tonic-gate * 15727c478bd9Sstevel@tonic-gate */ 15737c478bd9Sstevel@tonic-gate int usb_get_status( 15747c478bd9Sstevel@tonic-gate dev_info_t *dip, 15757c478bd9Sstevel@tonic-gate usb_pipe_handle_t ph, 15767c478bd9Sstevel@tonic-gate uint_t type, /* bmRequestType */ 15777c478bd9Sstevel@tonic-gate uint_t what, /* 0, interface, endpoint number */ 15787c478bd9Sstevel@tonic-gate uint16_t *status, 15797c478bd9Sstevel@tonic-gate usb_flags_t flags); 15807c478bd9Sstevel@tonic-gate 15817c478bd9Sstevel@tonic-gate 15827c478bd9Sstevel@tonic-gate /* 15837c478bd9Sstevel@tonic-gate * function for clearing feature of device, interface, or endpoint 15847c478bd9Sstevel@tonic-gate * 15857c478bd9Sstevel@tonic-gate * Arguments: 15867c478bd9Sstevel@tonic-gate * dip - devinfo pointer. 15877c478bd9Sstevel@tonic-gate * type - bmRequestType to be used 15887c478bd9Sstevel@tonic-gate * feature - feature to be cleared 15897c478bd9Sstevel@tonic-gate * what - 0 for device, otherwise interface or ep number 15907c478bd9Sstevel@tonic-gate * flags - USB_FLAGS_SLEEP (mandatory) 15917c478bd9Sstevel@tonic-gate * cb - if USB_FLAGS_SLEEP has not been specified 15927c478bd9Sstevel@tonic-gate * this callback function will be called on 15937c478bd9Sstevel@tonic-gate * completion. This callback may be NULL 15947c478bd9Sstevel@tonic-gate * and no notification of completion will then 15957c478bd9Sstevel@tonic-gate * be provided. 15967c478bd9Sstevel@tonic-gate * cb_arg - 2nd argument to callback function. 15977c478bd9Sstevel@tonic-gate * 15987c478bd9Sstevel@tonic-gate * Return Values: 15997c478bd9Sstevel@tonic-gate * USB_SUCCESS clearing feature succeeded 16007c478bd9Sstevel@tonic-gate * USB_FAILURE clearing feature failed 16017c478bd9Sstevel@tonic-gate * USB_* refer to list of all possible return values in 16027c478bd9Sstevel@tonic-gate * this file 16037c478bd9Sstevel@tonic-gate */ 16047c478bd9Sstevel@tonic-gate int usb_clr_feature( 16057c478bd9Sstevel@tonic-gate dev_info_t *dip, 16067c478bd9Sstevel@tonic-gate uint_t type, /* bmRequestType */ 16077c478bd9Sstevel@tonic-gate uint_t feature, 16087c478bd9Sstevel@tonic-gate uint_t what, /* 0, interface, endpoint number */ 16097c478bd9Sstevel@tonic-gate usb_flags_t flags, 16107c478bd9Sstevel@tonic-gate void (*cb)( 16117c478bd9Sstevel@tonic-gate usb_pipe_handle_t ph, 16127c478bd9Sstevel@tonic-gate usb_opaque_t arg, 16137c478bd9Sstevel@tonic-gate int rval, 16147c478bd9Sstevel@tonic-gate usb_cb_flags_t flags), 16157c478bd9Sstevel@tonic-gate usb_opaque_t cb_arg); 16167c478bd9Sstevel@tonic-gate 16177c478bd9Sstevel@tonic-gate 16187c478bd9Sstevel@tonic-gate /* 16197c478bd9Sstevel@tonic-gate * usb_set_cfg(): 16207c478bd9Sstevel@tonic-gate * Sets the configuration. Use this function with caution as 16217c478bd9Sstevel@tonic-gate * the framework is normally responsible for configuration changes. 16227c478bd9Sstevel@tonic-gate * Changing configuration will fail if pipes are still open or 16237c478bd9Sstevel@tonic-gate * when invoked from a driver bound to an interface on a composite 16247c478bd9Sstevel@tonic-gate * device. This function access the device and blocks. 16257c478bd9Sstevel@tonic-gate * 16267c478bd9Sstevel@tonic-gate * Arguments: 16277c478bd9Sstevel@tonic-gate * dip - devinfo pointer. 16287c478bd9Sstevel@tonic-gate * cfg_index - Index of configuration to set. Corresponds to 16297c478bd9Sstevel@tonic-gate * index in the usb_client_dev_data_t tree of 16307c478bd9Sstevel@tonic-gate * configurations. See usb_client_dev_data_t(9F). 16317c478bd9Sstevel@tonic-gate * usb_flags - USB_FLAGS_SLEEP: 16327c478bd9Sstevel@tonic-gate * wait for completion. 16337c478bd9Sstevel@tonic-gate * cb - if USB_FLAGS_SLEEP has not been specified 16347c478bd9Sstevel@tonic-gate * this callback function will be called on 16357c478bd9Sstevel@tonic-gate * completion. This callback may be NULL 16367c478bd9Sstevel@tonic-gate * and no notification of completion will then 16377c478bd9Sstevel@tonic-gate * be provided. 16387c478bd9Sstevel@tonic-gate * cb_arg - 2nd argument to callback function. 16397c478bd9Sstevel@tonic-gate * 16407c478bd9Sstevel@tonic-gate * callback and callback_arg should be NULL if USB_FLAGS_SLEEP has 16417c478bd9Sstevel@tonic-gate * been specified 16427c478bd9Sstevel@tonic-gate * 16437c478bd9Sstevel@tonic-gate * Return Values: 16447c478bd9Sstevel@tonic-gate * USB_SUCCESS: new configuration was set or async request 16457c478bd9Sstevel@tonic-gate * submitted successfully. 16467c478bd9Sstevel@tonic-gate * USB_FAILURE: new configuration could not be set because 16477c478bd9Sstevel@tonic-gate * it may been illegal configuration or this 16487c478bd9Sstevel@tonic-gate * caller was not allowed to change configs or 16497c478bd9Sstevel@tonic-gate * pipes were still open or async request 16507c478bd9Sstevel@tonic-gate * could not be submitted. 16517c478bd9Sstevel@tonic-gate * USB_* refer to list of all possible return values in 16527c478bd9Sstevel@tonic-gate * this file 16537c478bd9Sstevel@tonic-gate * 16547c478bd9Sstevel@tonic-gate * the pipe handle argument in the callback will be the default pipe handle 16557c478bd9Sstevel@tonic-gate */ 16567c478bd9Sstevel@tonic-gate int usb_set_cfg( 16577c478bd9Sstevel@tonic-gate dev_info_t *dip, 16587c478bd9Sstevel@tonic-gate uint_t cfg_index, 16597c478bd9Sstevel@tonic-gate usb_flags_t usb_flags, 16607c478bd9Sstevel@tonic-gate void (*cb)( 16617c478bd9Sstevel@tonic-gate usb_pipe_handle_t ph, 16627c478bd9Sstevel@tonic-gate usb_opaque_t arg, 16637c478bd9Sstevel@tonic-gate int rval, 16647c478bd9Sstevel@tonic-gate usb_cb_flags_t flags), 16657c478bd9Sstevel@tonic-gate usb_opaque_t cb_arg); 16667c478bd9Sstevel@tonic-gate 16677c478bd9Sstevel@tonic-gate 16687c478bd9Sstevel@tonic-gate /* 16697c478bd9Sstevel@tonic-gate * usb_get_cfg: 16707c478bd9Sstevel@tonic-gate * dip - pointer to devinfo node 16717c478bd9Sstevel@tonic-gate * cfgval - pointer to cfgval 16727c478bd9Sstevel@tonic-gate * usb_flags - none, will always block 16737c478bd9Sstevel@tonic-gate * 16747c478bd9Sstevel@tonic-gate * return values: 16757c478bd9Sstevel@tonic-gate * USB_SUCCESS - current cfg value is returned to cfgval 16767c478bd9Sstevel@tonic-gate * USB_* - refer to list of all possible return values in 16777c478bd9Sstevel@tonic-gate * this file 16787c478bd9Sstevel@tonic-gate */ 16797c478bd9Sstevel@tonic-gate int usb_get_cfg( 16807c478bd9Sstevel@tonic-gate dev_info_t *dip, 16817c478bd9Sstevel@tonic-gate uint_t *cfgval, 16827c478bd9Sstevel@tonic-gate usb_flags_t usb_flags); 16837c478bd9Sstevel@tonic-gate 16847c478bd9Sstevel@tonic-gate 16857c478bd9Sstevel@tonic-gate /* 16867c478bd9Sstevel@tonic-gate * The following functions set or get the alternate interface 16877c478bd9Sstevel@tonic-gate * setting. 16887c478bd9Sstevel@tonic-gate * 16897c478bd9Sstevel@tonic-gate * usb_set_alt_if: 16907c478bd9Sstevel@tonic-gate * dip - pointer to devinfo node 16917c478bd9Sstevel@tonic-gate * interface - interface 16927c478bd9Sstevel@tonic-gate * alt_number - alternate to set to 16937c478bd9Sstevel@tonic-gate * usb_flags - USB_FLAGS_SLEEP: 16947c478bd9Sstevel@tonic-gate * wait for completion. 16957c478bd9Sstevel@tonic-gate * cb - if USB_FLAGS_SLEEP has not been specified 16967c478bd9Sstevel@tonic-gate * this callback function will be called on 16977c478bd9Sstevel@tonic-gate * completion. This callback may be NULL 16987c478bd9Sstevel@tonic-gate * and no notification of completion will then 16997c478bd9Sstevel@tonic-gate * be provided. 17007c478bd9Sstevel@tonic-gate * cb_arg - 2nd argument to callback function. 17017c478bd9Sstevel@tonic-gate * 17027c478bd9Sstevel@tonic-gate * callback and callback_arg should be NULL if USB_FLAGS_SLEEP has 17037c478bd9Sstevel@tonic-gate * been specified 17047c478bd9Sstevel@tonic-gate * 17057c478bd9Sstevel@tonic-gate * the pipe handle argument in the callback will be the default pipe handle 17067c478bd9Sstevel@tonic-gate * 17077c478bd9Sstevel@tonic-gate * return values: 17087c478bd9Sstevel@tonic-gate * USB_SUCCESS: alternate was set or async request was 17097c478bd9Sstevel@tonic-gate * submitted. 17107c478bd9Sstevel@tonic-gate * USB_FAILURE: alternate could not be set because pipes 17117c478bd9Sstevel@tonic-gate * were still open or some access error occurred 17127c478bd9Sstevel@tonic-gate * or an invalid alt if value was passed or 17137c478bd9Sstevel@tonic-gate * async request could not be submitted 17147c478bd9Sstevel@tonic-gate * USB_INVALID_PERM the driver does not own the device or the interface 17157c478bd9Sstevel@tonic-gate * USB_* refer to list of all possible return values in 17167c478bd9Sstevel@tonic-gate * this file 17177c478bd9Sstevel@tonic-gate */ 17187c478bd9Sstevel@tonic-gate int usb_set_alt_if( 17197c478bd9Sstevel@tonic-gate dev_info_t *dip, 17207c478bd9Sstevel@tonic-gate uint_t interface, 17217c478bd9Sstevel@tonic-gate uint_t alt_number, 17227c478bd9Sstevel@tonic-gate usb_flags_t usb_flags, 17237c478bd9Sstevel@tonic-gate void (*cb)( 17247c478bd9Sstevel@tonic-gate usb_pipe_handle_t ph, 17257c478bd9Sstevel@tonic-gate usb_opaque_t arg, 17267c478bd9Sstevel@tonic-gate int rval, 17277c478bd9Sstevel@tonic-gate usb_cb_flags_t flags), 17287c478bd9Sstevel@tonic-gate usb_opaque_t cb_arg); 17297c478bd9Sstevel@tonic-gate 17307c478bd9Sstevel@tonic-gate 17317c478bd9Sstevel@tonic-gate 17327c478bd9Sstevel@tonic-gate /* flags must be USB_FLAGS_SLEEP, and this function will block */ 17337c478bd9Sstevel@tonic-gate int usb_get_alt_if( 17347c478bd9Sstevel@tonic-gate dev_info_t *dip, 17357c478bd9Sstevel@tonic-gate uint_t if_number, 17367c478bd9Sstevel@tonic-gate uint_t *alt_number, 17377c478bd9Sstevel@tonic-gate usb_flags_t flags); 17387c478bd9Sstevel@tonic-gate 17397c478bd9Sstevel@tonic-gate 17407c478bd9Sstevel@tonic-gate /* 17417c478bd9Sstevel@tonic-gate * =========================================================================== 17427c478bd9Sstevel@tonic-gate * USB bulk request management 17437c478bd9Sstevel@tonic-gate * =========================================================================== 17447c478bd9Sstevel@tonic-gate */ 17457c478bd9Sstevel@tonic-gate 17467c478bd9Sstevel@tonic-gate /* 17477c478bd9Sstevel@tonic-gate * A client driver allocates/uses the usb_bulk_req_t for bulk pipe xfers. 17487c478bd9Sstevel@tonic-gate * 17497c478bd9Sstevel@tonic-gate * NOTES: 17507c478bd9Sstevel@tonic-gate * - bulk pipe sharing is not supported 17517c478bd9Sstevel@tonic-gate * - semantics of combinations of flag and attributes: 17527c478bd9Sstevel@tonic-gate * 17537c478bd9Sstevel@tonic-gate * flags Type attributes data timeout semantics 17547c478bd9Sstevel@tonic-gate * ---------------------------------------------------------------- 17557c478bd9Sstevel@tonic-gate * x x x == NULL x illegal 17567c478bd9Sstevel@tonic-gate * 17577c478bd9Sstevel@tonic-gate * no sleep IN x != NULL 0 fill buffer, no timeout 17587c478bd9Sstevel@tonic-gate * callback when xfer-len has 17597c478bd9Sstevel@tonic-gate * been xferred 17607c478bd9Sstevel@tonic-gate * no sleep IN x != NULL > 0 fill buffer, with timeout 17617c478bd9Sstevel@tonic-gate * callback when xfer-len has 17627c478bd9Sstevel@tonic-gate * been xferred 17637c478bd9Sstevel@tonic-gate * 17647c478bd9Sstevel@tonic-gate * sleep IN x != NULL 0 fill buffer, no timeout 17657c478bd9Sstevel@tonic-gate * unblock when xfer-len has 17667c478bd9Sstevel@tonic-gate * been xferred 17677c478bd9Sstevel@tonic-gate * no callback 17687c478bd9Sstevel@tonic-gate * sleep IN x != NULL > 0 fill buffer, with timeout 17697c478bd9Sstevel@tonic-gate * unblock when xfer-len has 17707c478bd9Sstevel@tonic-gate * been xferred or timeout 17717c478bd9Sstevel@tonic-gate * no callback 17727c478bd9Sstevel@tonic-gate * 17737c478bd9Sstevel@tonic-gate * X OUT SHORT_XFER_OK x x illegal 17747c478bd9Sstevel@tonic-gate * 17757c478bd9Sstevel@tonic-gate * no sleep OUT x != NULL 0 empty buffer, no timeout 17767c478bd9Sstevel@tonic-gate * callback when xfer-len has 17777c478bd9Sstevel@tonic-gate * been xferred 17787c478bd9Sstevel@tonic-gate * no sleep OUT x != NULL > 0 empty buffer, with timeout 17797c478bd9Sstevel@tonic-gate * callback when xfer-len has 17807c478bd9Sstevel@tonic-gate * been xferred or timeout 17817c478bd9Sstevel@tonic-gate * 17827c478bd9Sstevel@tonic-gate * sleep OUT x != NULL 0 empty buffer, no timeout 17837c478bd9Sstevel@tonic-gate * unblock when xfer-len has 17847c478bd9Sstevel@tonic-gate * been xferred 17857c478bd9Sstevel@tonic-gate * no callback 17867c478bd9Sstevel@tonic-gate * sleep OUT x != NULL > 0 empty buffer, with timeout 17877c478bd9Sstevel@tonic-gate * unblock when xfer-len has 17887c478bd9Sstevel@tonic-gate * been xferred or timeout 17897c478bd9Sstevel@tonic-gate * no callback 17907c478bd9Sstevel@tonic-gate * 17917c478bd9Sstevel@tonic-gate * - bulk_len and bulk_data must be > 0. SHORT_XFER_OK is not applicable. 17927c478bd9Sstevel@tonic-gate * 17937c478bd9Sstevel@tonic-gate * - multiple bulk requests can be queued 17947c478bd9Sstevel@tonic-gate * 17957c478bd9Sstevel@tonic-gate * - Splitting large Bulk xfer: 17967c478bd9Sstevel@tonic-gate * The HCD driver, due to internal constraints, can only do a limited size bulk 17977c478bd9Sstevel@tonic-gate * data xfer per request. The current limitations are 32K for UHCI and 128K 17987c478bd9Sstevel@tonic-gate * for OHCI. So, a client driver may first determine this limitation (by 17997c478bd9Sstevel@tonic-gate * calling the USBA interface usb_pipe_bulk_transfer_size()); and restrict 18007c478bd9Sstevel@tonic-gate * itself to doing xfers in multiples of this fixed size. This forces a client 18017c478bd9Sstevel@tonic-gate * driver to do data xfers in a loop for a large request, splitting it into 18027c478bd9Sstevel@tonic-gate * multiple chunks of fixed size. 18037c478bd9Sstevel@tonic-gate */ 18047c478bd9Sstevel@tonic-gate typedef struct usb_bulk_req { 18057c478bd9Sstevel@tonic-gate uint_t bulk_len; /* number of bytes to xfer */ 18067c478bd9Sstevel@tonic-gate mblk_t *bulk_data; /* the data for the data phase */ 18077c478bd9Sstevel@tonic-gate /* IN: allocated by HCD */ 18087c478bd9Sstevel@tonic-gate /* OUT: allocated by client */ 18097c478bd9Sstevel@tonic-gate uint_t bulk_timeout; /* xfer timeout value in secs */ 18107c478bd9Sstevel@tonic-gate usb_opaque_t bulk_client_private; /* Client specific information */ 18117c478bd9Sstevel@tonic-gate usb_req_attrs_t bulk_attributes; /* xfer-attributes */ 18127c478bd9Sstevel@tonic-gate 18137c478bd9Sstevel@tonic-gate /* Normal Callback function (For synch xfers) */ 18147c478bd9Sstevel@tonic-gate void (*bulk_cb)(usb_pipe_handle_t ph, 18157c478bd9Sstevel@tonic-gate struct usb_bulk_req *req); 18167c478bd9Sstevel@tonic-gate 18177c478bd9Sstevel@tonic-gate /* Exception Callback function (For asynch xfers) */ 18187c478bd9Sstevel@tonic-gate void (*bulk_exc_cb)(usb_pipe_handle_t ph, 18197c478bd9Sstevel@tonic-gate struct usb_bulk_req *req); 18207c478bd9Sstevel@tonic-gate 18217c478bd9Sstevel@tonic-gate /* set by USBA/HCD on completion */ 18227c478bd9Sstevel@tonic-gate usb_cr_t bulk_completion_reason; /* set by HCD */ 18237c478bd9Sstevel@tonic-gate usb_cb_flags_t bulk_cb_flags; /* Callback context / handling flgs */ 18247c478bd9Sstevel@tonic-gate } usb_bulk_req_t; 18257c478bd9Sstevel@tonic-gate 18267c478bd9Sstevel@tonic-gate 18277c478bd9Sstevel@tonic-gate /* 18287c478bd9Sstevel@tonic-gate * Allocate/free usb bulk request 18297c478bd9Sstevel@tonic-gate * 18307c478bd9Sstevel@tonic-gate * Arguments: 18317c478bd9Sstevel@tonic-gate * dip - pointer to dev_info_t of the client driver 18327c478bd9Sstevel@tonic-gate * len - 0 or length of mblk to be allocated 18337c478bd9Sstevel@tonic-gate * flags - USB_FLAGS_SLEEP: 18347c478bd9Sstevel@tonic-gate * wait for resources 18357c478bd9Sstevel@tonic-gate * 18367c478bd9Sstevel@tonic-gate * Return Values: 18377c478bd9Sstevel@tonic-gate * usb_bulk_req_t on success, NULL on failure 18387c478bd9Sstevel@tonic-gate */ 18397c478bd9Sstevel@tonic-gate usb_bulk_req_t *usb_alloc_bulk_req( 18407c478bd9Sstevel@tonic-gate dev_info_t *dip, 18417c478bd9Sstevel@tonic-gate size_t len, 18427c478bd9Sstevel@tonic-gate usb_flags_t flags); 18437c478bd9Sstevel@tonic-gate 18447c478bd9Sstevel@tonic-gate 18457c478bd9Sstevel@tonic-gate void usb_free_bulk_req( 18467c478bd9Sstevel@tonic-gate usb_bulk_req_t *reqp); 18477c478bd9Sstevel@tonic-gate 18487c478bd9Sstevel@tonic-gate 18497c478bd9Sstevel@tonic-gate /* 18507c478bd9Sstevel@tonic-gate * usb_pipe_bulk_xfer(): 18517c478bd9Sstevel@tonic-gate * 18527c478bd9Sstevel@tonic-gate * Client drivers call this function to issue the bulk xfer to the USBA 18537c478bd9Sstevel@tonic-gate * which will queue or transfer it to the device 18547c478bd9Sstevel@tonic-gate * 18557c478bd9Sstevel@tonic-gate * Arguments: 18567c478bd9Sstevel@tonic-gate * pipe_handle - bulk pipe handle (obtained via usb_pipe_open() 18577c478bd9Sstevel@tonic-gate * reqp - pointer to bulk data xfer request (IN or OUT) 18587c478bd9Sstevel@tonic-gate * flags - USB_FLAGS_SLEEP: 18597c478bd9Sstevel@tonic-gate * wait for the request to complete 18607c478bd9Sstevel@tonic-gate * 18617c478bd9Sstevel@tonic-gate * Return Values: 18627c478bd9Sstevel@tonic-gate * USB_SUCCESS - success 18637c478bd9Sstevel@tonic-gate * USB_FAILURE - unspecified failure 18647c478bd9Sstevel@tonic-gate * USB_NO_RESOURCES - no resources 18657c478bd9Sstevel@tonic-gate * 18667c478bd9Sstevel@tonic-gate */ 18677c478bd9Sstevel@tonic-gate int usb_pipe_bulk_xfer( 18687c478bd9Sstevel@tonic-gate usb_pipe_handle_t pipe_handle, 18697c478bd9Sstevel@tonic-gate usb_bulk_req_t *reqp, 18707c478bd9Sstevel@tonic-gate usb_flags_t flags); 18717c478bd9Sstevel@tonic-gate 18727c478bd9Sstevel@tonic-gate /* Get maximum bulk transfer size */ 18737c478bd9Sstevel@tonic-gate int usb_pipe_get_max_bulk_transfer_size( 18747c478bd9Sstevel@tonic-gate dev_info_t *dip, 18757c478bd9Sstevel@tonic-gate size_t *size); 18767c478bd9Sstevel@tonic-gate 18777c478bd9Sstevel@tonic-gate 18787c478bd9Sstevel@tonic-gate /* 18797c478bd9Sstevel@tonic-gate * =========================================================================== 18807c478bd9Sstevel@tonic-gate * USB interrupt pipe request management 18817c478bd9Sstevel@tonic-gate * =========================================================================== 18827c478bd9Sstevel@tonic-gate */ 18837c478bd9Sstevel@tonic-gate 18847c478bd9Sstevel@tonic-gate /* 18857c478bd9Sstevel@tonic-gate * A client driver allocates and uses the usb_intr_req_t for 18867c478bd9Sstevel@tonic-gate * all interrupt pipe transfers. 18877c478bd9Sstevel@tonic-gate * 18887c478bd9Sstevel@tonic-gate * USB_FLAGS_SLEEP indicates here just to wait for resources except 18897c478bd9Sstevel@tonic-gate * for ONE_XFER where we also wait for completion 18907c478bd9Sstevel@tonic-gate * 18917c478bd9Sstevel@tonic-gate * semantics flags and attribute combinations: 18927c478bd9Sstevel@tonic-gate * 18937c478bd9Sstevel@tonic-gate * Notes: 18947c478bd9Sstevel@tonic-gate * none attributes indicates neither ONE_XFER nor SHORT_XFER_OK 18957c478bd9Sstevel@tonic-gate * 18967c478bd9Sstevel@tonic-gate * flags Type attributes data timeout semantics 18977c478bd9Sstevel@tonic-gate * ---------------------------------------------------------------- 18987c478bd9Sstevel@tonic-gate * x IN x != NULL x illegal 18997c478bd9Sstevel@tonic-gate * x IN ONE_XFER=0 x !=0 illegal 19007c478bd9Sstevel@tonic-gate * 19017c478bd9Sstevel@tonic-gate * x IN ONE_XFER=0 NULL 0 continuous polling, 19027c478bd9Sstevel@tonic-gate * many callbacks 19037c478bd9Sstevel@tonic-gate * request is returned on 19047c478bd9Sstevel@tonic-gate * stop polling 19057c478bd9Sstevel@tonic-gate * 19067c478bd9Sstevel@tonic-gate * no sleep IN ONE_XFER NULL 0 one time poll, no timeout, 19077c478bd9Sstevel@tonic-gate * one callback 19087c478bd9Sstevel@tonic-gate * no sleep IN ONE_XFER NULL !=0 one time poll, with 19097c478bd9Sstevel@tonic-gate * timeout, one callback 19107c478bd9Sstevel@tonic-gate * 19117c478bd9Sstevel@tonic-gate * sleep IN ONE_XFER NULL 0 one time poll, no timeout, 19127c478bd9Sstevel@tonic-gate * no callback, 19137c478bd9Sstevel@tonic-gate * block for completion 19147c478bd9Sstevel@tonic-gate * sleep IN ONE_XFER NULL !=0 one time poll, with timeout, 19157c478bd9Sstevel@tonic-gate * no callback 19167c478bd9Sstevel@tonic-gate * block for completion 19177c478bd9Sstevel@tonic-gate * 19187c478bd9Sstevel@tonic-gate * x OUT x NULL x illegal 19197c478bd9Sstevel@tonic-gate * x OUT ONE_XFER x x illegal 19207c478bd9Sstevel@tonic-gate * x OUT SHORT_XFER_OK x x illegal 19217c478bd9Sstevel@tonic-gate * 19227c478bd9Sstevel@tonic-gate * x OUT none != NULL 0 xfer until data exhausted, 19237c478bd9Sstevel@tonic-gate * no timeout, one callback 19247c478bd9Sstevel@tonic-gate * x OUT none != NULL !=0 xfer until data exhausted, 19257c478bd9Sstevel@tonic-gate * with timeout, one callback 19267c478bd9Sstevel@tonic-gate * 19277c478bd9Sstevel@tonic-gate * - Reads (IN): 19287c478bd9Sstevel@tonic-gate * 19297c478bd9Sstevel@tonic-gate * The client driver does *not* provide a data buffer. 19307c478bd9Sstevel@tonic-gate * By default, a READ request would mean continuous polling for data IN. The 19317c478bd9Sstevel@tonic-gate * HCD typically reads "wMaxPacketSize" amount of 'periodic data'. A client 19327c478bd9Sstevel@tonic-gate * driver may force the HCD to read instead intr_len 19337c478bd9Sstevel@tonic-gate * amount of 'periodic data' (See section 1). 19347c478bd9Sstevel@tonic-gate * 19357c478bd9Sstevel@tonic-gate * The HCD issues a callback to the client after each polling interval if 19367c478bd9Sstevel@tonic-gate * it has read in some data. Note that the amount of data read IN is either 19377c478bd9Sstevel@tonic-gate * intr_len or 'wMaxPacketSize' in length. 19387c478bd9Sstevel@tonic-gate * 19397c478bd9Sstevel@tonic-gate * Normally, the HCD keeps polling interrupt pipe forever even if there is 19407c478bd9Sstevel@tonic-gate * no data to be read IN. A client driver may stop this polling by 19417c478bd9Sstevel@tonic-gate * calling usb_pipe_stop_intr_polling(). 19427c478bd9Sstevel@tonic-gate * 19437c478bd9Sstevel@tonic-gate * If a client driver chooses to pass USB_ATTRS_ONE_XFER as 19447c478bd9Sstevel@tonic-gate * 'xfer_attributes' the HCD will poll for data until some data is received. 19457c478bd9Sstevel@tonic-gate * HCD reads in the data and does a callback and stops polling for any more 19467c478bd9Sstevel@tonic-gate * data. In this case, the client driver need not explicitly call 19477c478bd9Sstevel@tonic-gate * usb_pipe_stop_intr_polling(). 19487c478bd9Sstevel@tonic-gate * 19497c478bd9Sstevel@tonic-gate * When continuous polling is stopped, the original request is returned with 19507c478bd9Sstevel@tonic-gate * USB_CR_STOPPED_POLLING. 19517c478bd9Sstevel@tonic-gate * 19527c478bd9Sstevel@tonic-gate * - Writes (OUT): 19537c478bd9Sstevel@tonic-gate * 19547c478bd9Sstevel@tonic-gate * A client driver provides the data buffer, and data, needed for intr write. 19557c478bd9Sstevel@tonic-gate * There is no continuous write mode, a la read (See previous section). 19567c478bd9Sstevel@tonic-gate * The USB_ATTRS_ONE_XFER attribute is illegal. 19577c478bd9Sstevel@tonic-gate * By default USBA keeps writing intr data until the provided data buffer 19587c478bd9Sstevel@tonic-gate * has been written out. The HCD does ONE callback to the client driver. 19597c478bd9Sstevel@tonic-gate * Queueing is supported. 19607c478bd9Sstevel@tonic-gate * Max size is 8k 19617c478bd9Sstevel@tonic-gate */ 19627c478bd9Sstevel@tonic-gate typedef struct usb_intr_req { 19637c478bd9Sstevel@tonic-gate uint_t intr_len; /* OUT: size of total xfer */ 19647c478bd9Sstevel@tonic-gate /* IN : packet size */ 19657c478bd9Sstevel@tonic-gate mblk_t *intr_data; /* the data for the data phase */ 19667c478bd9Sstevel@tonic-gate /* IN: allocated by HCD */ 19677c478bd9Sstevel@tonic-gate /* OUT: allocated by client */ 19687c478bd9Sstevel@tonic-gate usb_opaque_t intr_client_private; /* Client specific information */ 19697c478bd9Sstevel@tonic-gate uint_t intr_timeout; /* only with ONE TIME POLL, in secs */ 19707c478bd9Sstevel@tonic-gate usb_req_attrs_t intr_attributes; 19717c478bd9Sstevel@tonic-gate 19727c478bd9Sstevel@tonic-gate /* Normal callback function (For synch transfers) */ 19737c478bd9Sstevel@tonic-gate void (*intr_cb)(usb_pipe_handle_t ph, 19747c478bd9Sstevel@tonic-gate struct usb_intr_req *req); 19757c478bd9Sstevel@tonic-gate 19767c478bd9Sstevel@tonic-gate /* Exception callback function (For asynch transfers) */ 19777c478bd9Sstevel@tonic-gate void (*intr_exc_cb)(usb_pipe_handle_t ph, 19787c478bd9Sstevel@tonic-gate struct usb_intr_req *req); 19797c478bd9Sstevel@tonic-gate 19807c478bd9Sstevel@tonic-gate /* set by USBA/HCD on completion */ 19817c478bd9Sstevel@tonic-gate usb_cr_t intr_completion_reason; /* set by HCD */ 19827c478bd9Sstevel@tonic-gate usb_cb_flags_t intr_cb_flags; /* Callback context / handling flgs */ 19837c478bd9Sstevel@tonic-gate } usb_intr_req_t; 19847c478bd9Sstevel@tonic-gate 19857c478bd9Sstevel@tonic-gate 19867c478bd9Sstevel@tonic-gate /* 19877c478bd9Sstevel@tonic-gate * Allocate/free usb interrupt pipe request 19887c478bd9Sstevel@tonic-gate * 19897c478bd9Sstevel@tonic-gate * Arguments: 19907c478bd9Sstevel@tonic-gate * dip - pointer to dev_info_t of the client driver 19917c478bd9Sstevel@tonic-gate * reqp - pointer to request structure 19927c478bd9Sstevel@tonic-gate * len - 0 or length of mblk for this interrupt request 19937c478bd9Sstevel@tonic-gate * flags - USB_FLAGS_SLEEP: 19947c478bd9Sstevel@tonic-gate * Sleep if resources are not available 19957c478bd9Sstevel@tonic-gate * 19967c478bd9Sstevel@tonic-gate * Return Values: 19977c478bd9Sstevel@tonic-gate * usb_intr_req_t on success, NULL on failure 19987c478bd9Sstevel@tonic-gate */ 19997c478bd9Sstevel@tonic-gate usb_intr_req_t *usb_alloc_intr_req( 20007c478bd9Sstevel@tonic-gate dev_info_t *dip, 20017c478bd9Sstevel@tonic-gate size_t len, 20027c478bd9Sstevel@tonic-gate usb_flags_t flags); 20037c478bd9Sstevel@tonic-gate 20047c478bd9Sstevel@tonic-gate 20057c478bd9Sstevel@tonic-gate void usb_free_intr_req( 20067c478bd9Sstevel@tonic-gate usb_intr_req_t *reqp); 20077c478bd9Sstevel@tonic-gate 20087c478bd9Sstevel@tonic-gate 20097c478bd9Sstevel@tonic-gate /* 20107c478bd9Sstevel@tonic-gate * usb_pipe_intr_xfer(): 20117c478bd9Sstevel@tonic-gate * 20127c478bd9Sstevel@tonic-gate * Client drivers call this function to issue the intr xfer to USBA/HCD 20137c478bd9Sstevel@tonic-gate * which starts polling the device 20147c478bd9Sstevel@tonic-gate * 20157c478bd9Sstevel@tonic-gate * Arguments: 20167c478bd9Sstevel@tonic-gate * pipe_handle - interrupt pipe handle (obtained via usb_pipe_open() 20177c478bd9Sstevel@tonic-gate * reqp - pointer tothe interrupt pipe xfer request (IN or OUT) 20187c478bd9Sstevel@tonic-gate * flags - USB_FLAGS_SLEEP: 20197c478bd9Sstevel@tonic-gate * wait for resources to be available 20207c478bd9Sstevel@tonic-gate * 20217c478bd9Sstevel@tonic-gate * return values: 20227c478bd9Sstevel@tonic-gate * USB_SUCCESS - success 20237c478bd9Sstevel@tonic-gate * USB_FAILURE - unspecified failure 20247c478bd9Sstevel@tonic-gate * USB_NO_RESOURCES - no resources 20257c478bd9Sstevel@tonic-gate * 20267c478bd9Sstevel@tonic-gate * NOTE: start polling on an IN pipe that is already being polled is a NOP. 20277c478bd9Sstevel@tonic-gate * We don't queue requests on OUT pipe 20287c478bd9Sstevel@tonic-gate */ 20297c478bd9Sstevel@tonic-gate int usb_pipe_intr_xfer( 20307c478bd9Sstevel@tonic-gate usb_pipe_handle_t pipe_handle, 20317c478bd9Sstevel@tonic-gate usb_intr_req_t *req, 20327c478bd9Sstevel@tonic-gate usb_flags_t flags); 20337c478bd9Sstevel@tonic-gate 20347c478bd9Sstevel@tonic-gate 20357c478bd9Sstevel@tonic-gate /* 20367c478bd9Sstevel@tonic-gate * usb_pipe_stop_intr_polling(): 20377c478bd9Sstevel@tonic-gate * 20387c478bd9Sstevel@tonic-gate * Client drivers call this function to stop the automatic data-in/out transfers 20397c478bd9Sstevel@tonic-gate * without closing the pipe. 20407c478bd9Sstevel@tonic-gate * 20417c478bd9Sstevel@tonic-gate * If USB_FLAGS_SLEEP has been specified then this function will block until 20427c478bd9Sstevel@tonic-gate * polling has been stopped and all callbacks completed. If USB_FLAGS_SLEEP 20437c478bd9Sstevel@tonic-gate * has NOT been specified then polling is terminated when the original 20447c478bd9Sstevel@tonic-gate * request that started the polling has been returned with 20457c478bd9Sstevel@tonic-gate * USB_CR_STOPPED_POLLING 20467c478bd9Sstevel@tonic-gate * 20477c478bd9Sstevel@tonic-gate * Stop polling should never fail. 20487c478bd9Sstevel@tonic-gate * 20497c478bd9Sstevel@tonic-gate * Args:- 20507c478bd9Sstevel@tonic-gate * pipe_handle - interrupt pipe handle (obtained via usb_pipe_open()). 20517c478bd9Sstevel@tonic-gate * flags - USB_FLAGS_SLEEP: 20527c478bd9Sstevel@tonic-gate * wait for the resources to be available. 20537c478bd9Sstevel@tonic-gate */ 20547c478bd9Sstevel@tonic-gate void usb_pipe_stop_intr_polling( 20557c478bd9Sstevel@tonic-gate usb_pipe_handle_t pipe_handle, 20567c478bd9Sstevel@tonic-gate usb_flags_t flags); 20577c478bd9Sstevel@tonic-gate 20587c478bd9Sstevel@tonic-gate 20597c478bd9Sstevel@tonic-gate /* 20607c478bd9Sstevel@tonic-gate * =========================================================================== 20617c478bd9Sstevel@tonic-gate * USB isochronous xfer management 20627c478bd9Sstevel@tonic-gate * =========================================================================== 20637c478bd9Sstevel@tonic-gate */ 20647c478bd9Sstevel@tonic-gate 20657c478bd9Sstevel@tonic-gate /* 20667c478bd9Sstevel@tonic-gate * The usb frame number is an absolute number since boot and incremented 20677c478bd9Sstevel@tonic-gate * every 1 ms. 20687c478bd9Sstevel@tonic-gate */ 20697c478bd9Sstevel@tonic-gate typedef uint64_t usb_frame_number_t; 20707c478bd9Sstevel@tonic-gate 20717c478bd9Sstevel@tonic-gate /* 20727c478bd9Sstevel@tonic-gate * USB ischronous packet descriptor 20737c478bd9Sstevel@tonic-gate * 20747c478bd9Sstevel@tonic-gate * An array of structures of type usb_isoc_pkt_descr_t must be allocated and 20757c478bd9Sstevel@tonic-gate * initialized by the client driver using usb_alloc_isoc_req(). The client 20767c478bd9Sstevel@tonic-gate * driver must set isoc_pkt_length in each packet descriptor before submitting 20777c478bd9Sstevel@tonic-gate * the request. 20787c478bd9Sstevel@tonic-gate */ 20797c478bd9Sstevel@tonic-gate typedef struct usb_isoc_pkt_descr { 20807c478bd9Sstevel@tonic-gate /* 20817c478bd9Sstevel@tonic-gate * Set by the client driver, for all isochronous requests, to the 20827c478bd9Sstevel@tonic-gate * number of bytes to transfer in a frame. 20837c478bd9Sstevel@tonic-gate */ 20847c478bd9Sstevel@tonic-gate ushort_t isoc_pkt_length; 20857c478bd9Sstevel@tonic-gate 20867c478bd9Sstevel@tonic-gate /* 20877c478bd9Sstevel@tonic-gate * Set by HCD to actual number of bytes sent/received in frame. 20887c478bd9Sstevel@tonic-gate */ 20897c478bd9Sstevel@tonic-gate ushort_t isoc_pkt_actual_length; 20907c478bd9Sstevel@tonic-gate 20917c478bd9Sstevel@tonic-gate /* 20927c478bd9Sstevel@tonic-gate * Per frame status set by HCD both for the isochronous IN and OUT 20937c478bd9Sstevel@tonic-gate * requests. If any status is non-zero then isoc_error_count in the 20947c478bd9Sstevel@tonic-gate * isoc_req will be non-zero. 20957c478bd9Sstevel@tonic-gate */ 20967c478bd9Sstevel@tonic-gate usb_cr_t isoc_pkt_status; 20977c478bd9Sstevel@tonic-gate } usb_isoc_pkt_descr_t; 20987c478bd9Sstevel@tonic-gate 20997c478bd9Sstevel@tonic-gate 21007c478bd9Sstevel@tonic-gate /* 21017c478bd9Sstevel@tonic-gate * USB isochronous request 21027c478bd9Sstevel@tonic-gate * 21037c478bd9Sstevel@tonic-gate * The client driver allocates the usb_isoc_req_t before sending an 21047c478bd9Sstevel@tonic-gate * isochronous requests. 21057c478bd9Sstevel@tonic-gate * 21067c478bd9Sstevel@tonic-gate * USB_FLAGS_SLEEP indicates here just to wait for resources but not 21077c478bd9Sstevel@tonic-gate * to wait for completion 21087c478bd9Sstevel@tonic-gate * 21097c478bd9Sstevel@tonic-gate * Semantics of various combinations for data xfers: 21107c478bd9Sstevel@tonic-gate * 21117c478bd9Sstevel@tonic-gate * Note: attributes considered in this table are ONE_XFER, START_FRAME, 21127c478bd9Sstevel@tonic-gate * XFER_ASAP, SHORT_XFER 21137c478bd9Sstevel@tonic-gate * 21147c478bd9Sstevel@tonic-gate * 21157c478bd9Sstevel@tonic-gate * flags Type attributes data semantics 21167c478bd9Sstevel@tonic-gate * --------------------------------------------------------------------- 21177c478bd9Sstevel@tonic-gate * x x x NULL illegal 21187c478bd9Sstevel@tonic-gate * 21197c478bd9Sstevel@tonic-gate * x x ONE_XFER x illegal 21207c478bd9Sstevel@tonic-gate * 21217c478bd9Sstevel@tonic-gate * x IN x !=NULL continuous polling, 21227c478bd9Sstevel@tonic-gate * many callbacks 21237c478bd9Sstevel@tonic-gate * 21247c478bd9Sstevel@tonic-gate * x IN ISOC_START_FRAME !=NULL invalid if Current_frame# > 21257c478bd9Sstevel@tonic-gate * "isoc_frame_no" 21267c478bd9Sstevel@tonic-gate * x IN ISOC_XFER_ASAP !=NULL "isoc_frame_no" ignored. 21277c478bd9Sstevel@tonic-gate * HCD determines when to 21287c478bd9Sstevel@tonic-gate * insert xfer 21297c478bd9Sstevel@tonic-gate * 21307c478bd9Sstevel@tonic-gate * x OUT ONE_XFER x illegal 21317c478bd9Sstevel@tonic-gate * x OUT SHORT_XFER_OK x illegal 21327c478bd9Sstevel@tonic-gate * 21337c478bd9Sstevel@tonic-gate * x OUT ISOC_START_FRAME !=NULL invalid if Current_frame# > 21347c478bd9Sstevel@tonic-gate * "isoc_frame_no" 21357c478bd9Sstevel@tonic-gate * x OUT ISOC_XFER_ASAP !=NULL "isoc_frame_no" ignored. 21367c478bd9Sstevel@tonic-gate * HCD determines when to 21377c478bd9Sstevel@tonic-gate * insert xfer 21387c478bd9Sstevel@tonic-gate */ 21397c478bd9Sstevel@tonic-gate typedef struct usb_isoc_req { 21407c478bd9Sstevel@tonic-gate /* 21417c478bd9Sstevel@tonic-gate * Starting frame number will be set by the client driver in which 21427c478bd9Sstevel@tonic-gate * to begin this request. This frame number is used to synchronize 21437c478bd9Sstevel@tonic-gate * requests queued to different isochronous pipes. The frame number 21447c478bd9Sstevel@tonic-gate * is optional and client driver can skip starting frame number by 21457c478bd9Sstevel@tonic-gate * setting USB_ISOC_ATTRS_ASAP. In this case, HCD will decide starting 21467c478bd9Sstevel@tonic-gate * frame number for this isochronous request. If this field is 0, 21477c478bd9Sstevel@tonic-gate * then this indicates an invalid frame number. 21487c478bd9Sstevel@tonic-gate */ 21497c478bd9Sstevel@tonic-gate usb_frame_number_t isoc_frame_no; 21507c478bd9Sstevel@tonic-gate 21517c478bd9Sstevel@tonic-gate /* 2152b3001defSlg150142 * Number of isochronous data packets. 21537c478bd9Sstevel@tonic-gate * The first field is set by client driver and may not exceed 21547c478bd9Sstevel@tonic-gate * the maximum number of entries in the usb isochronous packet 21557c478bd9Sstevel@tonic-gate * descriptors. 21567c478bd9Sstevel@tonic-gate */ 21577c478bd9Sstevel@tonic-gate ushort_t isoc_pkts_count; 2158b3001defSlg150142 2159b3001defSlg150142 /* 2160b3001defSlg150142 * The sum of all pkt lengths in the isoc request. Recommend to 2161b3001defSlg150142 * set it to zero, so the sum of isoc_pkt_length in the 2162b3001defSlg150142 * isoc_pkt_descr list will be used automatically and no check 2163b3001defSlg150142 * will be apply to this element. 2164b3001defSlg150142 */ 21657c478bd9Sstevel@tonic-gate ushort_t isoc_pkts_length; 21667c478bd9Sstevel@tonic-gate 21677c478bd9Sstevel@tonic-gate /* 21687c478bd9Sstevel@tonic-gate * This field will be set by HCD and this field indicates the number 21697c478bd9Sstevel@tonic-gate * of packets that completed with errors. 21707c478bd9Sstevel@tonic-gate */ 21717c478bd9Sstevel@tonic-gate ushort_t isoc_error_count; 21727c478bd9Sstevel@tonic-gate 21737c478bd9Sstevel@tonic-gate /* 21747c478bd9Sstevel@tonic-gate * Attributes specific to particular usb isochronous request. 21757c478bd9Sstevel@tonic-gate * Supported values are: USB_ATTRS_ISOC_START_FRAME, 21767c478bd9Sstevel@tonic-gate * USB_ATTRS_ISOC_XFER_ASAP. 21777c478bd9Sstevel@tonic-gate */ 21787c478bd9Sstevel@tonic-gate usb_req_attrs_t isoc_attributes; 21797c478bd9Sstevel@tonic-gate 21807c478bd9Sstevel@tonic-gate /* 21817c478bd9Sstevel@tonic-gate * Isochronous OUT: 21827c478bd9Sstevel@tonic-gate * allocated and set by client driver, freed and zeroed by HCD 21837c478bd9Sstevel@tonic-gate * on successful completion 21847c478bd9Sstevel@tonic-gate * Isochronous IN: 21857c478bd9Sstevel@tonic-gate * allocated and set by HCD, freed by client driver 21867c478bd9Sstevel@tonic-gate */ 21877c478bd9Sstevel@tonic-gate mblk_t *isoc_data; 21887c478bd9Sstevel@tonic-gate 21897c478bd9Sstevel@tonic-gate /* 21907c478bd9Sstevel@tonic-gate * The client driver specific private information. 21917c478bd9Sstevel@tonic-gate */ 21927c478bd9Sstevel@tonic-gate usb_opaque_t isoc_client_private; 21937c478bd9Sstevel@tonic-gate 21947c478bd9Sstevel@tonic-gate /* 21957c478bd9Sstevel@tonic-gate * Isochronous OUT: 21967c478bd9Sstevel@tonic-gate * must be allocated & initialized by client driver 21977c478bd9Sstevel@tonic-gate * Isochronous IN: 21987c478bd9Sstevel@tonic-gate * must be allocated by client driver 21997c478bd9Sstevel@tonic-gate */ 22007c478bd9Sstevel@tonic-gate struct usb_isoc_pkt_descr *isoc_pkt_descr; 22017c478bd9Sstevel@tonic-gate 22027c478bd9Sstevel@tonic-gate /* Normal callback function (For synch transfers) */ 22037c478bd9Sstevel@tonic-gate void (*isoc_cb)(usb_pipe_handle_t ph, 22047c478bd9Sstevel@tonic-gate struct usb_isoc_req *req); 22057c478bd9Sstevel@tonic-gate 22067c478bd9Sstevel@tonic-gate /* Exception callback function (For asynch transfers) */ 22077c478bd9Sstevel@tonic-gate void (*isoc_exc_cb)(usb_pipe_handle_t ph, 22087c478bd9Sstevel@tonic-gate struct usb_isoc_req *req); 22097c478bd9Sstevel@tonic-gate 22107c478bd9Sstevel@tonic-gate /* set by USBA/HCD on completion */ 22117c478bd9Sstevel@tonic-gate usb_cr_t isoc_completion_reason; /* set by HCD */ 22127c478bd9Sstevel@tonic-gate /* Callback context / handling flgs */ 22137c478bd9Sstevel@tonic-gate usb_cb_flags_t isoc_cb_flags; 22147c478bd9Sstevel@tonic-gate } usb_isoc_req_t; 22157c478bd9Sstevel@tonic-gate 22167c478bd9Sstevel@tonic-gate 22177c478bd9Sstevel@tonic-gate /* 22187c478bd9Sstevel@tonic-gate * Allocate/free usb isochronous resources 22197c478bd9Sstevel@tonic-gate * 22207c478bd9Sstevel@tonic-gate * isoc_pkts_count must be > 0 22217c478bd9Sstevel@tonic-gate * 22227c478bd9Sstevel@tonic-gate * Arguments: 22237c478bd9Sstevel@tonic-gate * dip - client driver's devinfo pointer 22247c478bd9Sstevel@tonic-gate * isoc_pkts_count - number of pkts required 22257c478bd9Sstevel@tonic-gate * len - 0 or size of mblk to allocate 22267c478bd9Sstevel@tonic-gate * flags - USB_FLAGS_SLEEP: 22277c478bd9Sstevel@tonic-gate * wait for resources 22287c478bd9Sstevel@tonic-gate * 22297c478bd9Sstevel@tonic-gate * Return Values: 22307c478bd9Sstevel@tonic-gate * usb_isoc_req pointer or NULL 22317c478bd9Sstevel@tonic-gate */ 22327c478bd9Sstevel@tonic-gate usb_isoc_req_t *usb_alloc_isoc_req( 22337c478bd9Sstevel@tonic-gate dev_info_t *dip, 22347c478bd9Sstevel@tonic-gate uint_t isoc_pkts_count, 22357c478bd9Sstevel@tonic-gate size_t len, 22367c478bd9Sstevel@tonic-gate usb_flags_t flags); 22377c478bd9Sstevel@tonic-gate 22387c478bd9Sstevel@tonic-gate void usb_free_isoc_req( 22397c478bd9Sstevel@tonic-gate usb_isoc_req_t *usb_isoc_req); 22407c478bd9Sstevel@tonic-gate 22417c478bd9Sstevel@tonic-gate /* 22427c478bd9Sstevel@tonic-gate * Returns current usb frame number. 22437c478bd9Sstevel@tonic-gate */ 22447c478bd9Sstevel@tonic-gate usb_frame_number_t usb_get_current_frame_number( 22457c478bd9Sstevel@tonic-gate dev_info_t *dip); 22467c478bd9Sstevel@tonic-gate 22477c478bd9Sstevel@tonic-gate /* 22487c478bd9Sstevel@tonic-gate * Get maximum isochronous packets per usb isochronous request 22497c478bd9Sstevel@tonic-gate */ 22507c478bd9Sstevel@tonic-gate uint_t usb_get_max_pkts_per_isoc_request( 22517c478bd9Sstevel@tonic-gate dev_info_t *dip); 22527c478bd9Sstevel@tonic-gate 22537c478bd9Sstevel@tonic-gate /* 22547c478bd9Sstevel@tonic-gate * usb_pipe_isoc_xfer() 22557c478bd9Sstevel@tonic-gate * 22567c478bd9Sstevel@tonic-gate * Client drivers call this to issue the isoch xfer (IN and OUT) to the USBA 22577c478bd9Sstevel@tonic-gate * which starts polling the device. 22587c478bd9Sstevel@tonic-gate * 22597c478bd9Sstevel@tonic-gate * Arguments: 22607c478bd9Sstevel@tonic-gate * pipe_handle - isoc pipe handle (obtained via usb_pipe_open(). 22617c478bd9Sstevel@tonic-gate * reqp - pointer to the isochronous pipe IN xfer request 22627c478bd9Sstevel@tonic-gate * allocated by the client driver. 22637c478bd9Sstevel@tonic-gate * flags - USB_FLAGS_SLEEP: 22647c478bd9Sstevel@tonic-gate * wait for the resources to be available. 22657c478bd9Sstevel@tonic-gate * 22667c478bd9Sstevel@tonic-gate * return values: 22677c478bd9Sstevel@tonic-gate * USB_SUCCESS - success. 22687c478bd9Sstevel@tonic-gate * USB_FAILURE - unspecified failure. 22697c478bd9Sstevel@tonic-gate * USB_NO_RESOURCES - no resources. 22707c478bd9Sstevel@tonic-gate * USB_NO_FRAME_NUMBER - START_FRAME, ASAP flags not specified. 22717c478bd9Sstevel@tonic-gate * USB_INVALID_START_FRAME - Starting USB frame number invalid. 22727c478bd9Sstevel@tonic-gate * 22737c478bd9Sstevel@tonic-gate * Notes: 22747c478bd9Sstevel@tonic-gate * - usb_pipe_isoc_xfer on an IN pipe that is already being polled is a NOP. 22757c478bd9Sstevel@tonic-gate * - requests can be queued on an OUT pipe. 22767c478bd9Sstevel@tonic-gate */ 22777c478bd9Sstevel@tonic-gate int usb_pipe_isoc_xfer( 22787c478bd9Sstevel@tonic-gate usb_pipe_handle_t pipe_handle, 22797c478bd9Sstevel@tonic-gate usb_isoc_req_t *reqp, 22807c478bd9Sstevel@tonic-gate usb_flags_t flags); 22817c478bd9Sstevel@tonic-gate 22827c478bd9Sstevel@tonic-gate /* 22837c478bd9Sstevel@tonic-gate * usb_pipe_stop_isoc_polling(): 22847c478bd9Sstevel@tonic-gate * 22857c478bd9Sstevel@tonic-gate * Client drivers call this function to stop the automatic data-in/out 22867c478bd9Sstevel@tonic-gate * transfers without closing the isoc pipe. 22877c478bd9Sstevel@tonic-gate * 22887c478bd9Sstevel@tonic-gate * If USB_FLAGS_SLEEP has been specified then this function will block until 22897c478bd9Sstevel@tonic-gate * polling has been stopped and all callbacks completed. If USB_FLAGS_SLEEP 22907c478bd9Sstevel@tonic-gate * has NOT been specified then polling is terminated when the original 22917c478bd9Sstevel@tonic-gate * request that started the polling has been returned with 22927c478bd9Sstevel@tonic-gate * USB_CR_STOPPED_POLLING 22937c478bd9Sstevel@tonic-gate * 22947c478bd9Sstevel@tonic-gate * Stop polling should never fail. 22957c478bd9Sstevel@tonic-gate * 22967c478bd9Sstevel@tonic-gate * Arguments: 22977c478bd9Sstevel@tonic-gate * pipe_handle - isoc pipe handle (obtained via usb_pipe_open(). 22987c478bd9Sstevel@tonic-gate * flags - USB_FLAGS_SLEEP: 22997c478bd9Sstevel@tonic-gate * wait for polling to be stopped and all 23007c478bd9Sstevel@tonic-gate * callbacks completed. 23017c478bd9Sstevel@tonic-gate */ 23027c478bd9Sstevel@tonic-gate void usb_pipe_stop_isoc_polling( 23037c478bd9Sstevel@tonic-gate usb_pipe_handle_t pipe_handle, 23047c478bd9Sstevel@tonic-gate usb_flags_t flags); 23057c478bd9Sstevel@tonic-gate 23067c478bd9Sstevel@tonic-gate /* 23077c478bd9Sstevel@tonic-gate * *************************************************************************** 23087c478bd9Sstevel@tonic-gate * USB device power management: 23097c478bd9Sstevel@tonic-gate * *************************************************************************** 23107c478bd9Sstevel@tonic-gate */ 23117c478bd9Sstevel@tonic-gate 23127c478bd9Sstevel@tonic-gate /* 23137c478bd9Sstevel@tonic-gate * 23147c478bd9Sstevel@tonic-gate * As any usb device will have a max of 4 possible power states 23157c478bd9Sstevel@tonic-gate * the #define for them are provided below with mapping to the 23167c478bd9Sstevel@tonic-gate * corresponding OS power levels. 23177c478bd9Sstevel@tonic-gate */ 23187c478bd9Sstevel@tonic-gate #define USB_DEV_PWR_D0 USB_DEV_OS_FULL_PWR 23197c478bd9Sstevel@tonic-gate #define USB_DEV_PWR_D1 5 23207c478bd9Sstevel@tonic-gate #define USB_DEV_PWR_D2 6 23217c478bd9Sstevel@tonic-gate #define USB_DEV_PWR_D3 USB_DEV_OS_PWR_OFF 23227c478bd9Sstevel@tonic-gate 23237c478bd9Sstevel@tonic-gate #define USB_DEV_OS_PWR_0 0 23247c478bd9Sstevel@tonic-gate #define USB_DEV_OS_PWR_1 1 23257c478bd9Sstevel@tonic-gate #define USB_DEV_OS_PWR_2 2 23267c478bd9Sstevel@tonic-gate #define USB_DEV_OS_PWR_3 3 23277c478bd9Sstevel@tonic-gate #define USB_DEV_OS_PWR_OFF USB_DEV_OS_PWR_0 23287c478bd9Sstevel@tonic-gate #define USB_DEV_OS_FULL_PWR USB_DEV_OS_PWR_3 23297c478bd9Sstevel@tonic-gate 23307c478bd9Sstevel@tonic-gate /* Bit Masks for Power States */ 23317c478bd9Sstevel@tonic-gate #define USB_DEV_OS_PWRMASK_D0 1 23327c478bd9Sstevel@tonic-gate #define USB_DEV_OS_PWRMASK_D1 2 23337c478bd9Sstevel@tonic-gate #define USB_DEV_OS_PWRMASK_D2 4 23347c478bd9Sstevel@tonic-gate #define USB_DEV_OS_PWRMASK_D3 8 23357c478bd9Sstevel@tonic-gate 23367c478bd9Sstevel@tonic-gate /* conversion for OS to Dx levels */ 23377c478bd9Sstevel@tonic-gate #define USB_DEV_OS_PWR2USB_PWR(l) (USB_DEV_OS_FULL_PWR - (l)) 23387c478bd9Sstevel@tonic-gate 23397c478bd9Sstevel@tonic-gate /* from OS level to Dx mask */ 23407c478bd9Sstevel@tonic-gate #define USB_DEV_PWRMASK(l) (1 << (USB_DEV_OS_FULL_PWR - (l))) 23417c478bd9Sstevel@tonic-gate 23427c478bd9Sstevel@tonic-gate /* Macro to check valid power level */ 23437c478bd9Sstevel@tonic-gate #define USB_DEV_PWRSTATE_OK(state, level) \ 23447c478bd9Sstevel@tonic-gate (((state) & USB_DEV_PWRMASK((level))) == 0) 23457c478bd9Sstevel@tonic-gate 23467c478bd9Sstevel@tonic-gate int usb_handle_remote_wakeup( 23477c478bd9Sstevel@tonic-gate dev_info_t *dip, 23487c478bd9Sstevel@tonic-gate int cmd); 23497c478bd9Sstevel@tonic-gate 23507c478bd9Sstevel@tonic-gate /* argument to usb_handle_remote wakeup function */ 23517c478bd9Sstevel@tonic-gate #define USB_REMOTE_WAKEUP_ENABLE 1 23527c478bd9Sstevel@tonic-gate #define USB_REMOTE_WAKEUP_DISABLE 2 23537c478bd9Sstevel@tonic-gate 23547c478bd9Sstevel@tonic-gate int usb_create_pm_components( 23557c478bd9Sstevel@tonic-gate dev_info_t *dip, 23567c478bd9Sstevel@tonic-gate uint_t *pwrstates); 23577c478bd9Sstevel@tonic-gate 23587c478bd9Sstevel@tonic-gate /* 23597c478bd9Sstevel@tonic-gate * *************************************************************************** 23607c478bd9Sstevel@tonic-gate * System event registration 23617c478bd9Sstevel@tonic-gate * *************************************************************************** 23627c478bd9Sstevel@tonic-gate */ 23637c478bd9Sstevel@tonic-gate 23647c478bd9Sstevel@tonic-gate /* Functions for registering hotplug callback functions. */ 23657c478bd9Sstevel@tonic-gate 23667c478bd9Sstevel@tonic-gate int usb_register_hotplug_cbs( 23677c478bd9Sstevel@tonic-gate dev_info_t *dip, 23687c478bd9Sstevel@tonic-gate int (*disconnect_event_handler)(dev_info_t *dip), 23697c478bd9Sstevel@tonic-gate int (*reconnect_event_handler)(dev_info_t *dip)); 23707c478bd9Sstevel@tonic-gate 23717c478bd9Sstevel@tonic-gate void usb_unregister_hotplug_cbs(dev_info_t *dip); 23727c478bd9Sstevel@tonic-gate 2373ffcd51f3Slg150142 /* 2374ffcd51f3Slg150142 * Reset_level determines the extent to which the device is reset, 2375ffcd51f3Slg150142 * It has the following values: 2376ffcd51f3Slg150142 * 2377ffcd51f3Slg150142 * USB_RESET_LVL_REATTACH - The device is reset, the original driver is 2378ffcd51f3Slg150142 * detached and a new driver attaching process 2379ffcd51f3Slg150142 * is started according to the updated 2380ffcd51f3Slg150142 * compatible name. This reset level applies to 2381ffcd51f3Slg150142 * the firmware download with the descriptors 2382ffcd51f3Slg150142 * changing, or other situations in which the 2383ffcd51f3Slg150142 * device needs to be reenumerated. 2384ffcd51f3Slg150142 * 2385ffcd51f3Slg150142 * USB_RESET_LVL_DEFAULT - Default reset level. The device is reset, all 2386ffcd51f3Slg150142 * error status is cleared, the device state 2387ffcd51f3Slg150142 * machines and registers are also cleared and 2388ffcd51f3Slg150142 * need to be reinitialized in the driver. The 2389ffcd51f3Slg150142 * current driver remains attached. This reset 2390ffcd51f3Slg150142 * level applies to hardware error recovery, or 2391ffcd51f3Slg150142 * firmware download without descriptors 2392ffcd51f3Slg150142 * changing. 2393ffcd51f3Slg150142 */ 2394ffcd51f3Slg150142 typedef enum { 2395ffcd51f3Slg150142 USB_RESET_LVL_REATTACH = 0, 2396ffcd51f3Slg150142 USB_RESET_LVL_DEFAULT = 1 2397ffcd51f3Slg150142 } usb_dev_reset_lvl_t; 2398ffcd51f3Slg150142 2399ffcd51f3Slg150142 /* 2400ffcd51f3Slg150142 * usb_reset_device: 2401ffcd51f3Slg150142 * 2402ffcd51f3Slg150142 * Client drivers call this function to request hardware reset for themselves, 2403ffcd51f3Slg150142 * which may be required in some situations such as: 2404ffcd51f3Slg150142 * 2405ffcd51f3Slg150142 * 1) Some USB devices need the driver to upload firmware into devices' RAM 2406ffcd51f3Slg150142 * and initiate a hardware reset in order to activate the new firmware. 2407ffcd51f3Slg150142 * 2) Hardware reset may help drivers to recover devices from an error state 2408ffcd51f3Slg150142 * caused by physical or firmware defects. 2409ffcd51f3Slg150142 * 2410ffcd51f3Slg150142 * Arguments: 2411ffcd51f3Slg150142 * dip - pointer to devinfo of the client 2412ffcd51f3Slg150142 * reset_level - see above 2413ffcd51f3Slg150142 * 2414ffcd51f3Slg150142 * Return values: 2415ffcd51f3Slg150142 * USB_SUCCESS - With USB_RESET_LVL_DEFAULT: the device was reset 2416ffcd51f3Slg150142 * successfully. 2417ffcd51f3Slg150142 * - With USB_RESET_LVL_REATTACH: reenumeration was 2418ffcd51f3Slg150142 * started successfully or a previous reset is still 2419ffcd51f3Slg150142 * in progress. 2420ffcd51f3Slg150142 * USB_FAILURE - The state of the device's parent hub is invalid 2421ffcd51f3Slg150142 * (disconnected or suspended). 2422ffcd51f3Slg150142 * - Called when the driver being detached. 2423ffcd51f3Slg150142 * - The device failed to be reset with 2424ffcd51f3Slg150142 * USB_RESET_LVL_DEFAULT specified. 2425ffcd51f3Slg150142 * - Reenumeration failed to start up with 2426ffcd51f3Slg150142 * - USB_RESET_LVL_REATTACH specified. 2427ffcd51f3Slg150142 * USB_INVALID_ARGS - Invalid arguments. 2428ffcd51f3Slg150142 * USB_INVALID_PERM - The driver of the dip doesn't own entire device. 2429ffcd51f3Slg150142 * USB_BUSY - One or more pipes other than the default control 2430ffcd51f3Slg150142 * pipe are open on the device with 2431ffcd51f3Slg150142 * USB_RESET_LVL_DEFAULT specified. 2432ffcd51f3Slg150142 * USB_INVALID_CONTEXT - Called from interrupt context with 2433ffcd51f3Slg150142 * USB_RESET_LVL_DEFAULT specified. 2434ffcd51f3Slg150142 */ 2435ffcd51f3Slg150142 2436ffcd51f3Slg150142 int usb_reset_device( 2437ffcd51f3Slg150142 dev_info_t *dip, 2438ffcd51f3Slg150142 usb_dev_reset_lvl_t reset_level); 2439ffcd51f3Slg150142 24407c478bd9Sstevel@tonic-gate 24417c478bd9Sstevel@tonic-gate /* 2442a7df97baSStrony Zhang - Solaris China Team * ************************************************************************** 2443a7df97baSStrony Zhang - Solaris China Team * USB device driver registration and callback functions remaining 2444a7df97baSStrony Zhang - Solaris China Team * Contracted Project Private (for VirtualBox USB Device Capture) 2445a7df97baSStrony Zhang - Solaris China Team * ************************************************************************** 2446a7df97baSStrony Zhang - Solaris China Team */ 2447a7df97baSStrony Zhang - Solaris China Team 2448a7df97baSStrony Zhang - Solaris China Team /* 2449a7df97baSStrony Zhang - Solaris China Team * getting the device strings of manufacturer, product and serial number 2450a7df97baSStrony Zhang - Solaris China Team */ 2451a7df97baSStrony Zhang - Solaris China Team typedef struct usb_dev_str { 2452a7df97baSStrony Zhang - Solaris China Team char *usb_mfg; /* manufacturer string */ 2453a7df97baSStrony Zhang - Solaris China Team char *usb_product; /* product string */ 2454a7df97baSStrony Zhang - Solaris China Team char *usb_serialno; /* serial number string */ 2455a7df97baSStrony Zhang - Solaris China Team } usb_dev_str_t; 2456a7df97baSStrony Zhang - Solaris China Team 2457a7df97baSStrony Zhang - Solaris China Team /* 2458a7df97baSStrony Zhang - Solaris China Team * It is the callback function type for capture driver. 2459a7df97baSStrony Zhang - Solaris China Team * Arguments: 2460a7df97baSStrony Zhang - Solaris China Team * dev_descr - pointer to device descriptor 2461a7df97baSStrony Zhang - Solaris China Team * dev_str - pointer to device strings 2462a7df97baSStrony Zhang - Solaris China Team * path - pointer to device physical path 2463a7df97baSStrony Zhang - Solaris China Team * bus - USB bus address 2464a7df97baSStrony Zhang - Solaris China Team * port - USB port number 2465a7df97baSStrony Zhang - Solaris China Team * drv - capture driver name. 2466a7df97baSStrony Zhang - Solaris China Team * It is returned by the callback func. 2467a7df97baSStrony Zhang - Solaris China Team * Return Values: 2468a7df97baSStrony Zhang - Solaris China Team * USB_SUCCESS - VirtualBox will capture the device 2469a7df97baSStrony Zhang - Solaris China Team * USB_FAILURE - VirtualBox will not capture the device 2470a7df97baSStrony Zhang - Solaris China Team */ 2471a7df97baSStrony Zhang - Solaris China Team typedef int (*usb_dev_driver_callback_t)( 2472a7df97baSStrony Zhang - Solaris China Team usb_dev_descr_t *dev_descr, 2473a7df97baSStrony Zhang - Solaris China Team usb_dev_str_t *dev_str, 2474a7df97baSStrony Zhang - Solaris China Team char *path, 2475a7df97baSStrony Zhang - Solaris China Team int bus, 2476a7df97baSStrony Zhang - Solaris China Team int port, 2477a7df97baSStrony Zhang - Solaris China Team char **drv, 2478a7df97baSStrony Zhang - Solaris China Team void *reserved); 2479a7df97baSStrony Zhang - Solaris China Team 2480a7df97baSStrony Zhang - Solaris China Team /* 2481a7df97baSStrony Zhang - Solaris China Team * Register the callback function in the usba. 2482a7df97baSStrony Zhang - Solaris China Team * Argument: 2483a7df97baSStrony Zhang - Solaris China Team * dip - client driver's devinfo pointer 2484a7df97baSStrony Zhang - Solaris China Team * cb - callback function 2485a7df97baSStrony Zhang - Solaris China Team * 2486a7df97baSStrony Zhang - Solaris China Team * Return Values: 2487a7df97baSStrony Zhang - Solaris China Team * USB_SUCCESS - the registeration was successful 2488a7df97baSStrony Zhang - Solaris China Team * USB_FAILURE - the registeration failed 2489a7df97baSStrony Zhang - Solaris China Team */ 2490a7df97baSStrony Zhang - Solaris China Team int usb_register_dev_driver( 2491a7df97baSStrony Zhang - Solaris China Team dev_info_t *dip, 2492a7df97baSStrony Zhang - Solaris China Team usb_dev_driver_callback_t cb); 2493a7df97baSStrony Zhang - Solaris China Team 2494a7df97baSStrony Zhang - Solaris China Team /* 2495a7df97baSStrony Zhang - Solaris China Team * Unregister the callback function in the usba. 2496a7df97baSStrony Zhang - Solaris China Team */ 2497a7df97baSStrony Zhang - Solaris China Team void usb_unregister_dev_driver(dev_info_t *dip); 2498a7df97baSStrony Zhang - Solaris China Team 2499a7df97baSStrony Zhang - Solaris China Team 2500a7df97baSStrony Zhang - Solaris China Team /* 25017c478bd9Sstevel@tonic-gate * *************************************************************************** 25027c478bd9Sstevel@tonic-gate * USB Device and interface class, subclass and protocol codes 25037c478bd9Sstevel@tonic-gate * *************************************************************************** 25047c478bd9Sstevel@tonic-gate */ 25057c478bd9Sstevel@tonic-gate 25067c478bd9Sstevel@tonic-gate /* 25077c478bd9Sstevel@tonic-gate * Available device and interface class codes. 25087c478bd9Sstevel@tonic-gate * Those which are device class codes are noted. 25097c478bd9Sstevel@tonic-gate */ 25107c478bd9Sstevel@tonic-gate 25117c478bd9Sstevel@tonic-gate #define USB_CLASS_AUDIO 1 25127c478bd9Sstevel@tonic-gate #define USB_CLASS_COMM 2 /* Communication device class and */ 25137c478bd9Sstevel@tonic-gate #define USB_CLASS_CDC_CTRL 2 /* CDC-control iface class, also 2 */ 25147c478bd9Sstevel@tonic-gate #define USB_CLASS_HID 3 25157c478bd9Sstevel@tonic-gate #define USB_CLASS_PHYSICAL 5 2516d73ae94eSgc161489 #define USB_CLASS_IMAGE 6 25177c478bd9Sstevel@tonic-gate #define USB_CLASS_PRINTER 7 25187c478bd9Sstevel@tonic-gate #define USB_CLASS_MASS_STORAGE 8 25197c478bd9Sstevel@tonic-gate #define USB_CLASS_HUB 9 /* Device class */ 25207c478bd9Sstevel@tonic-gate #define USB_CLASS_CDC_DATA 10 25217c478bd9Sstevel@tonic-gate #define USB_CLASS_CCID 11 25227c478bd9Sstevel@tonic-gate #define USB_CLASS_SECURITY 13 2523d73ae94eSgc161489 #define USB_CLASS_VIDEO 14 25247c478bd9Sstevel@tonic-gate #define USB_CLASS_DIAG 220 /* Device class */ 2525d73ae94eSgc161489 #define USB_CLASS_WIRELESS 224 25267c478bd9Sstevel@tonic-gate #define USB_CLASS_MISC 239 /* Device class */ 25277c478bd9Sstevel@tonic-gate #define USB_CLASS_APP 254 25287c478bd9Sstevel@tonic-gate #define USB_CLASS_VENDOR_SPEC 255 /* Device class */ 25297c478bd9Sstevel@tonic-gate 25307c478bd9Sstevel@tonic-gate #define USB_CLASS_PER_INTERFACE 0 /* Class info is at interface level */ 25317c478bd9Sstevel@tonic-gate 25327c478bd9Sstevel@tonic-gate /* Audio subclass. */ 25337c478bd9Sstevel@tonic-gate #define USB_SUBCLS_AUD_CONTROL 0x01 25347c478bd9Sstevel@tonic-gate #define USB_SUBCLS_AUD_STREAMING 0x02 25357c478bd9Sstevel@tonic-gate #define USB_SUBCLS_AUD_MIDI_STREAMING 0x03 25367c478bd9Sstevel@tonic-gate 25377c478bd9Sstevel@tonic-gate /* Comms subclass. */ 25387c478bd9Sstevel@tonic-gate #define USB_SUBCLS_CDCC_DIRECT_LINE 0x01 25397c478bd9Sstevel@tonic-gate #define USB_SUBCLS_CDCC_ABSTRCT_CTRL 0x02 25407c478bd9Sstevel@tonic-gate #define USB_SUBCLS_CDCC_PHONE_CTRL 0x03 25417c478bd9Sstevel@tonic-gate #define USB_SUBCLS_CDCC_MULTCNL_ISDN 0x04 25427c478bd9Sstevel@tonic-gate #define USB_SUBCLS_CDCC_ISDN 0x05 25437c478bd9Sstevel@tonic-gate #define USB_SUBCLS_CDCC_ETHERNET 0x06 25447c478bd9Sstevel@tonic-gate #define USB_SUBCLS_CDCC_ATM_NETWORK 0x07 25457c478bd9Sstevel@tonic-gate 25467c478bd9Sstevel@tonic-gate /* HID subclass and protocols. */ 25477c478bd9Sstevel@tonic-gate #define USB_SUBCLS_HID_1 1 25487c478bd9Sstevel@tonic-gate 25497c478bd9Sstevel@tonic-gate #define USB_PROTO_HID_KEYBOARD 0x01 /* legacy keyboard */ 25507c478bd9Sstevel@tonic-gate #define USB_PROTO_HID_MOUSE 0x02 /* legacy mouse */ 25517c478bd9Sstevel@tonic-gate 25527c478bd9Sstevel@tonic-gate /* Printer subclass and protocols. */ 25537c478bd9Sstevel@tonic-gate #define USB_SUBCLS_PRINTER_1 1 25547c478bd9Sstevel@tonic-gate 25557c478bd9Sstevel@tonic-gate #define USB_PROTO_PRINTER_UNI 0x01 /* Unidirectional interface */ 25567c478bd9Sstevel@tonic-gate #define USB_PROTO_PRINTER_BI 0x02 /* Bidirectional interface */ 25577c478bd9Sstevel@tonic-gate 25587c478bd9Sstevel@tonic-gate /* Mass storage subclasses and protocols. */ 25597c478bd9Sstevel@tonic-gate #define USB_SUBCLS_MS_RBC_T10 0x1 /* flash */ 25607c478bd9Sstevel@tonic-gate #define USB_SUBCLS_MS_SFF8020I 0x2 /* CD-ROM */ 25617c478bd9Sstevel@tonic-gate #define USB_SUBCLS_MS_QIC_157 0x3 /* tape */ 25627c478bd9Sstevel@tonic-gate #define USB_SUBCLS_MS_UFI 0x4 /* USB Floppy Disk Drive */ 25637c478bd9Sstevel@tonic-gate #define USB_SUBCLS_MS_SFF8070I 0x5 /* floppy */ 25647c478bd9Sstevel@tonic-gate #define USB_SUBCLS_MS_SCSI 0x6 /* transparent scsi */ 25657c478bd9Sstevel@tonic-gate 25667c478bd9Sstevel@tonic-gate #define USB_PROTO_MS_CBI_WC 0x00 /* USB CBI Proto w/cmp intr */ 25677c478bd9Sstevel@tonic-gate #define USB_PROTO_MS_CBI 0x01 /* USB CBI Protocol */ 25687c478bd9Sstevel@tonic-gate #define USB_PROTO_MS_ISD_1999_SILICN 0x02 /* ZIP Protocol */ 25697c478bd9Sstevel@tonic-gate #define USB_PROTO_MS_BULK_ONLY 0x50 /* USB Bulk Only Protocol */ 25707c478bd9Sstevel@tonic-gate 25717c478bd9Sstevel@tonic-gate /* Application subclasses. */ 25727c478bd9Sstevel@tonic-gate #define USB_SUBCLS_APP_FIRMWARE 0x01 /* app spec f/w subclass */ 25737c478bd9Sstevel@tonic-gate #define USB_SUBCLS_APP_IRDA 0x02 /* app spec IrDa subclass */ 25747c478bd9Sstevel@tonic-gate #define USB_SUBCLS_APP_TEST 0x03 /* app spec test subclass */ 25757c478bd9Sstevel@tonic-gate 2576d73ae94eSgc161489 /* Video subclasses */ 2577d73ae94eSgc161489 #define USB_SUBCLS_VIDEO_CONTROL 0x01 /* video control */ 2578d73ae94eSgc161489 #define USB_SUBCLS_VIDEO_STREAM 0x02 /* video stream */ 2579d73ae94eSgc161489 #define USB_SUBCLS_VIDEO_COLLECTION 0x03 /* video interface collection */ 25807c478bd9Sstevel@tonic-gate 2581ff0e937bSRaymond Chen /* Wireless controller subclasses and protocols, refer to WUSB 1.0 chapter 8 */ 2582ff0e937bSRaymond Chen #define USB_SUBCLS_WUSB_1 0x01 /* RF controller */ 2583ff0e937bSRaymond Chen #define USB_SUBCLS_WUSB_2 0x02 /* Wireless adapter */ 2584d73ae94eSgc161489 #define USB_PROTO_WUSB_HWA 0x01 /* host wire adapter */ 2585d73ae94eSgc161489 #define USB_PROTO_WUSB_DWA 0x02 /* device wire adapter */ 2586d73ae94eSgc161489 #define USB_PROTO_WUSB_DWA_ISO 0x03 /* device wire adapter isoc */ 2587ff0e937bSRaymond Chen #define USB_PROTO_WUSB_RC 0x02 /* UWB radio controller */ 2588ff0e937bSRaymond Chen 2589ff0e937bSRaymond Chen /* Association subclass and protocol, Association Model Supplement to WUSB1.0 */ 2590ff0e937bSRaymond Chen #define USB_SUBCLS_CBAF 0x03 /* cable association */ 2591ff0e937bSRaymond Chen #define USB_PROTO_CBAF 0x01 /* CBAF protocol */ 2592ff0e937bSRaymond Chen 2593ff0e937bSRaymond Chen /* Misc subclasses and protocols, refer to WUSB 1.0 chapter 8 */ 2594ff0e937bSRaymond Chen #define USB_SUBCLS_MISC_COMMON 0x02 /* common class */ 2595ff0e937bSRaymond Chen #define USB_PROTO_MISC_WA 0x02 /* multifunction wire adapter */ 25967c478bd9Sstevel@tonic-gate 25977c478bd9Sstevel@tonic-gate #ifdef __cplusplus 25987c478bd9Sstevel@tonic-gate } 25997c478bd9Sstevel@tonic-gate #endif 26007c478bd9Sstevel@tonic-gate 26017c478bd9Sstevel@tonic-gate #endif /* _SYS_USB_USBAI_H */ 2602