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 5d29f5a71Szhigang lu - Sun Microsystems - Beijing China * Common Development and Distribution License (the "License"). 6d29f5a71Szhigang lu - Sun Microsystems - Beijing China * 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 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22d29f5a71Szhigang lu - Sun Microsystems - Beijing China * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _SYS_USB_USBA_USBAI_PRIVATE_H 277c478bd9Sstevel@tonic-gate #define _SYS_USB_USBA_USBAI_PRIVATE_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate /* 317c478bd9Sstevel@tonic-gate * Unstable interfaces not part of USBAI but used by Solaris client drivers. 327c478bd9Sstevel@tonic-gate * These interfaces may not be present in future releases and are highly 337c478bd9Sstevel@tonic-gate * unstable. 347c478bd9Sstevel@tonic-gate * 357c478bd9Sstevel@tonic-gate * Status key: 367c478bd9Sstevel@tonic-gate * C = Remove from Sun client drivers before removing from this file 377c478bd9Sstevel@tonic-gate * D = May be needed by legacy (DDK) drivers. 387c478bd9Sstevel@tonic-gate */ 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate #ifdef __cplusplus 417c478bd9Sstevel@tonic-gate extern "C" { 427c478bd9Sstevel@tonic-gate #endif 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate /* 457c478bd9Sstevel@tonic-gate * convenience function for getting default config index 467c478bd9Sstevel@tonic-gate * as saved in usba_device structure 477c478bd9Sstevel@tonic-gate * 487c478bd9Sstevel@tonic-gate * Status: C 497c478bd9Sstevel@tonic-gate */ 507c478bd9Sstevel@tonic-gate uint_t usb_get_current_cfgidx(dev_info_t *); 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gate /* 537c478bd9Sstevel@tonic-gate * ************************************************************************** 547c478bd9Sstevel@tonic-gate * Error and status definitions, and reporting functions 557c478bd9Sstevel@tonic-gate * ************************************************************************** 567c478bd9Sstevel@tonic-gate */ 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate /* 607c478bd9Sstevel@tonic-gate * convenience functions to get string corresponding to value 617c478bd9Sstevel@tonic-gate * usb_cb_flags_name requires a workbuffer of sufficient length 627c478bd9Sstevel@tonic-gate * for the concatenation of all strings as usb_cb_flags_t is a bit 637c478bd9Sstevel@tonic-gate * mask 647c478bd9Sstevel@tonic-gate * 657c478bd9Sstevel@tonic-gate * Status: C and D 667c478bd9Sstevel@tonic-gate */ 677c478bd9Sstevel@tonic-gate const char *usb_str_cr(usb_cr_t cr); 687c478bd9Sstevel@tonic-gate char *usb_str_cb_flags(usb_cb_flags_t cb_flags, 697c478bd9Sstevel@tonic-gate char *buffer, size_t length); 707c478bd9Sstevel@tonic-gate const char *usb_str_pipe_state(usb_pipe_state_t state); 717c478bd9Sstevel@tonic-gate const char *usb_str_dev_state(int state); 727c478bd9Sstevel@tonic-gate const char *usb_str_rval(int rval); 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate /* function convert a USB return value to an errno */ 757c478bd9Sstevel@tonic-gate int usb_rval2errno(int rval); 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate /* 787c478bd9Sstevel@tonic-gate * ************************************************************************** 797c478bd9Sstevel@tonic-gate * Transfer-related definitions and functions 807c478bd9Sstevel@tonic-gate * ************************************************************************** 817c478bd9Sstevel@tonic-gate */ 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate /* Status C and D for whole section. */ 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate /* Serialize callbacks per interface or device. */ 867c478bd9Sstevel@tonic-gate #define USB_FLAGS_SERIALIZED_CB 0x8000 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate /* default timeout for control requests (in seconds) */ 897c478bd9Sstevel@tonic-gate #define USB_PIPE_TIMEOUT 3 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate /* 927c478bd9Sstevel@tonic-gate * usb_pipe_sync_ctrl_xfer(): 937c478bd9Sstevel@tonic-gate * for simple synchronous control transactions this wrapper function 947c478bd9Sstevel@tonic-gate * will perform the allocation, xfer, and deallocation. 957c478bd9Sstevel@tonic-gate * USB_ATTRS_AUTOCLEARING will be enabled 967c478bd9Sstevel@tonic-gate * 977c478bd9Sstevel@tonic-gate * ARGUMENTS: 987c478bd9Sstevel@tonic-gate * dip - pointer to clients devinfo. 997c478bd9Sstevel@tonic-gate * pipe_handle - control pipe pipehandle (obtained via usb_pipe_open(). 1007c478bd9Sstevel@tonic-gate * bmRequestType - characteristics of request. 1017c478bd9Sstevel@tonic-gate * bRequest - specific request. 1027c478bd9Sstevel@tonic-gate * wValue - varies according to request. 1037c478bd9Sstevel@tonic-gate * wIndex - index or offset. 1047c478bd9Sstevel@tonic-gate * wLength - number of bytes to xfer. 1057c478bd9Sstevel@tonic-gate * data - pointer to pointer to data 1067c478bd9Sstevel@tonic-gate * IN: HCD will allocate data 1077c478bd9Sstevel@tonic-gate * OUT: clients driver allocates data. 1087c478bd9Sstevel@tonic-gate * attrs - required request attributes. 1097c478bd9Sstevel@tonic-gate * completion_reason - completion status. 1107c478bd9Sstevel@tonic-gate * cb_flags - request completions flags. 1117c478bd9Sstevel@tonic-gate * flags - none. 1127c478bd9Sstevel@tonic-gate * 1137c478bd9Sstevel@tonic-gate * RETURN VALUES: 1147c478bd9Sstevel@tonic-gate * USB_SUCCESS - request successfully executed. 1157c478bd9Sstevel@tonic-gate * USB_FAILURE - request failed. 1167c478bd9Sstevel@tonic-gate * 1177c478bd9Sstevel@tonic-gate * NOTES: 1187c478bd9Sstevel@tonic-gate * - in the case of failure, the client should check completion_reason and 1197c478bd9Sstevel@tonic-gate * and cb_flags and determine further recovery action 1207c478bd9Sstevel@tonic-gate * - the client should check data and if non-zero, free the data on 1217c478bd9Sstevel@tonic-gate * completion 1227c478bd9Sstevel@tonic-gate */ 1237c478bd9Sstevel@tonic-gate int usb_pipe_sync_ctrl_xfer( 1247c478bd9Sstevel@tonic-gate dev_info_t *dip, 1257c478bd9Sstevel@tonic-gate usb_pipe_handle_t pipe_handle, 1267c478bd9Sstevel@tonic-gate uchar_t bmRequestType, 1277c478bd9Sstevel@tonic-gate uchar_t bRequest, 1287c478bd9Sstevel@tonic-gate uint16_t wValue, 1297c478bd9Sstevel@tonic-gate uint16_t wIndex, 1307c478bd9Sstevel@tonic-gate uint16_t wLength, 1317c478bd9Sstevel@tonic-gate mblk_t **data, 1327c478bd9Sstevel@tonic-gate usb_req_attrs_t attrs, 1337c478bd9Sstevel@tonic-gate usb_cr_t *completion_reason, 1347c478bd9Sstevel@tonic-gate usb_cb_flags_t *cb_flags, 1357c478bd9Sstevel@tonic-gate usb_flags_t flags); 1367c478bd9Sstevel@tonic-gate 1377c478bd9Sstevel@tonic-gate /* 1387c478bd9Sstevel@tonic-gate * ************************************************************************** 1397c478bd9Sstevel@tonic-gate * Event registration / pre-suspend and post-resume handling 1407c478bd9Sstevel@tonic-gate * ************************************************************************** 1417c478bd9Sstevel@tonic-gate */ 1427c478bd9Sstevel@tonic-gate 1437c478bd9Sstevel@tonic-gate /* Status: C and D for whole section. */ 1447c478bd9Sstevel@tonic-gate 1457c478bd9Sstevel@tonic-gate /* 1467c478bd9Sstevel@tonic-gate * Event registration info for both hotplug and pre-suspend/post-resume 1477c478bd9Sstevel@tonic-gate * callbacks. Eventually pre-suspend and post-resume callbacks will not be 1487c478bd9Sstevel@tonic-gate * needed, so this is for this OS release only and will go away in a 1497c478bd9Sstevel@tonic-gate * subsequent release. 1507c478bd9Sstevel@tonic-gate */ 1517c478bd9Sstevel@tonic-gate typedef struct usb_event { 1527c478bd9Sstevel@tonic-gate /* device disconnected/unplugged */ 1537c478bd9Sstevel@tonic-gate int (*disconnect_event_handler)(dev_info_t *dip); 1547c478bd9Sstevel@tonic-gate 1557c478bd9Sstevel@tonic-gate /* device reconnected */ 1567c478bd9Sstevel@tonic-gate int (*reconnect_event_handler)(dev_info_t *dip); 1577c478bd9Sstevel@tonic-gate 1587c478bd9Sstevel@tonic-gate /* notification that system is about to checkpoint */ 1597c478bd9Sstevel@tonic-gate int (*pre_suspend_event_handler)(dev_info_t *dip); 1607c478bd9Sstevel@tonic-gate 1617c478bd9Sstevel@tonic-gate /* notification that system resumed after a checkpoint */ 1627c478bd9Sstevel@tonic-gate int (*post_resume_event_handler)(dev_info_t *dip); 1637c478bd9Sstevel@tonic-gate } usb_event_t; 1647c478bd9Sstevel@tonic-gate 1657c478bd9Sstevel@tonic-gate /* 1667c478bd9Sstevel@tonic-gate * Event callbacks 1677c478bd9Sstevel@tonic-gate * the callbacks should always return USB_SUCCESS. 1687c478bd9Sstevel@tonic-gate */ 1697c478bd9Sstevel@tonic-gate int usb_register_event_cbs( 1707c478bd9Sstevel@tonic-gate dev_info_t *dip, 1717c478bd9Sstevel@tonic-gate usb_event_t *usb_evt_data, 1727c478bd9Sstevel@tonic-gate usb_flags_t flags); 1737c478bd9Sstevel@tonic-gate 1747c478bd9Sstevel@tonic-gate void usb_unregister_event_cbs( 1757c478bd9Sstevel@tonic-gate dev_info_t *dip, 1767c478bd9Sstevel@tonic-gate usb_event_t *usb_evt_data); 1777c478bd9Sstevel@tonic-gate 1787c478bd9Sstevel@tonic-gate /* 1797c478bd9Sstevel@tonic-gate * USB CPR support 1807c478bd9Sstevel@tonic-gate * A client driver must call this funtion in pre-suspend event handler 1817c478bd9Sstevel@tonic-gate * to inform the USBA framework that it can't suspend because 1827c478bd9Sstevel@tonic-gate * driver instance or device could not be quiesced. 1837c478bd9Sstevel@tonic-gate */ 1847c478bd9Sstevel@tonic-gate void usb_fail_checkpoint( 1857c478bd9Sstevel@tonic-gate dev_info_t *dip, 1867c478bd9Sstevel@tonic-gate usb_flags_t flags); 1877c478bd9Sstevel@tonic-gate 1887c478bd9Sstevel@tonic-gate 1897c478bd9Sstevel@tonic-gate /* 1907c478bd9Sstevel@tonic-gate * ************************************************************************** 1917c478bd9Sstevel@tonic-gate * Logging functions remaining Contracted Consolidation Private 1927c478bd9Sstevel@tonic-gate * ************************************************************************** 1937c478bd9Sstevel@tonic-gate */ 1947c478bd9Sstevel@tonic-gate 1957c478bd9Sstevel@tonic-gate /* Status: C and D for whole section. */ 1967c478bd9Sstevel@tonic-gate 1977c478bd9Sstevel@tonic-gate /* 1987c478bd9Sstevel@tonic-gate * Usb logging, debug and console message handling. 1997c478bd9Sstevel@tonic-gate */ 2007c478bd9Sstevel@tonic-gate typedef struct usb_log_handle *usb_log_handle_t; 2017c478bd9Sstevel@tonic-gate 2027c478bd9Sstevel@tonic-gate #define USB_LOG_L0 0 /* warnings, console & syslog buffer */ 2037c478bd9Sstevel@tonic-gate #define USB_LOG_L1 1 /* errors, syslog buffer */ 2047c478bd9Sstevel@tonic-gate #define USB_LOG_L2 2 /* recoverable errors, debug only */ 2057c478bd9Sstevel@tonic-gate #define USB_LOG_L3 3 /* interesting data, debug only */ 2067c478bd9Sstevel@tonic-gate #define USB_LOG_L4 4 /* tracing, debug only */ 2077c478bd9Sstevel@tonic-gate 2087c478bd9Sstevel@tonic-gate #ifdef DEBUG 209*d235eb05SRichard PALO #define USB_DPRINTF_L4(...) usb_dprintf4(__VA_ARGS__) 210*d235eb05SRichard PALO #define USB_DPRINTF_L3(...) usb_dprintf3(__VA_ARGS__) 2117c478bd9Sstevel@tonic-gate 2127c478bd9Sstevel@tonic-gate /*PRINTFLIKE3*/ 2137c478bd9Sstevel@tonic-gate void usb_dprintf4( 2147c478bd9Sstevel@tonic-gate uint_t mask, 2157c478bd9Sstevel@tonic-gate usb_log_handle_t handle, 2167c478bd9Sstevel@tonic-gate char *fmt, ...); 2177c478bd9Sstevel@tonic-gate /*PRINTFLIKE3*/ 2187c478bd9Sstevel@tonic-gate void usb_dprintf3( 2197c478bd9Sstevel@tonic-gate uint_t mask, 2207c478bd9Sstevel@tonic-gate usb_log_handle_t handle, 2217c478bd9Sstevel@tonic-gate char *fmt, ...); 2227c478bd9Sstevel@tonic-gate #else 223*d235eb05SRichard PALO #define USB_DPRINTF_L4(...) ((void)0) 224*d235eb05SRichard PALO #define USB_DPRINTF_L3(...) ((void)0) 2257c478bd9Sstevel@tonic-gate #endif 2267c478bd9Sstevel@tonic-gate 2277c478bd9Sstevel@tonic-gate #define USB_DPRINTF_L2 usb_dprintf2 2287c478bd9Sstevel@tonic-gate #define USB_DPRINTF_L1 usb_dprintf1 2297c478bd9Sstevel@tonic-gate #define USB_DPRINTF_L0 usb_dprintf0 2307c478bd9Sstevel@tonic-gate 2317c478bd9Sstevel@tonic-gate /*PRINTFLIKE3*/ 2327c478bd9Sstevel@tonic-gate void usb_dprintf2( 2337c478bd9Sstevel@tonic-gate uint_t mask, 2347c478bd9Sstevel@tonic-gate usb_log_handle_t handle, 2357c478bd9Sstevel@tonic-gate char *fmt, ...); 2367c478bd9Sstevel@tonic-gate /*PRINTFLIKE3*/ 2377c478bd9Sstevel@tonic-gate void usb_dprintf1( 2387c478bd9Sstevel@tonic-gate uint_t mask, 2397c478bd9Sstevel@tonic-gate usb_log_handle_t handle, 2407c478bd9Sstevel@tonic-gate char *fmt, ...); 2417c478bd9Sstevel@tonic-gate /*PRINTFLIKE3*/ 2427c478bd9Sstevel@tonic-gate void usb_dprintf0( 2437c478bd9Sstevel@tonic-gate uint_t mask, 2447c478bd9Sstevel@tonic-gate usb_log_handle_t handle, 2457c478bd9Sstevel@tonic-gate char *fmt, ...); 2467c478bd9Sstevel@tonic-gate 2477c478bd9Sstevel@tonic-gate usb_log_handle_t usb_alloc_log_hdl( 2487c478bd9Sstevel@tonic-gate dev_info_t *dip, 2497c478bd9Sstevel@tonic-gate char *name, 2507c478bd9Sstevel@tonic-gate uint_t *errlevel, 2517c478bd9Sstevel@tonic-gate uint_t *mask, 2527c478bd9Sstevel@tonic-gate uint_t *instance_filter, 2537c478bd9Sstevel@tonic-gate usb_flags_t flags); 2547c478bd9Sstevel@tonic-gate 2557c478bd9Sstevel@tonic-gate /* free the log handle */ 2567c478bd9Sstevel@tonic-gate void usb_free_log_hdl( 2577c478bd9Sstevel@tonic-gate usb_log_handle_t handle); 2587c478bd9Sstevel@tonic-gate 2597c478bd9Sstevel@tonic-gate /* log message */ 2607c478bd9Sstevel@tonic-gate /*PRINTFLIKE4*/ 2617c478bd9Sstevel@tonic-gate int usb_log( 2627c478bd9Sstevel@tonic-gate usb_log_handle_t handle, 2637c478bd9Sstevel@tonic-gate uint_t level, 2647c478bd9Sstevel@tonic-gate uint_t mask, 2657c478bd9Sstevel@tonic-gate char *fmt, ...); 2667c478bd9Sstevel@tonic-gate 2677c478bd9Sstevel@tonic-gate /* 2687c478bd9Sstevel@tonic-gate * usb_check_same_device: 2697c478bd9Sstevel@tonic-gate * Check if the device connected to the port is the same as 2707c478bd9Sstevel@tonic-gate * the previous device that was in the port. The previous device is 2717c478bd9Sstevel@tonic-gate * represented by the dip on record for the port. Print a message 2727c478bd9Sstevel@tonic-gate * if the device is different. If device_string arg is not NULL, it is 2737c478bd9Sstevel@tonic-gate * included in the message. Can block. 2747c478bd9Sstevel@tonic-gate * 2757c478bd9Sstevel@tonic-gate * Arguments: 2767c478bd9Sstevel@tonic-gate * dip - pointer to devinfo of the client 2777c478bd9Sstevel@tonic-gate * log_handle - handle to which messages are logged 2787c478bd9Sstevel@tonic-gate * log_level - one of USB_LOG_* 2797c478bd9Sstevel@tonic-gate * log_mask - logging mask 2807c478bd9Sstevel@tonic-gate * check_mask - one mask containing things to check: 2817c478bd9Sstevel@tonic-gate * USB_CHK_BASIC: empty mask; 2827c478bd9Sstevel@tonic-gate * these checks are always done. 2837c478bd9Sstevel@tonic-gate * USB_CHK_SERIAL: check match on device 2847c478bd9Sstevel@tonic-gate * serial number. 2857c478bd9Sstevel@tonic-gate * USB_CHK_CFG: compare config clouds 2867c478bd9Sstevel@tonic-gate * byte by byte 2877c478bd9Sstevel@tonic-gate * USB_CHK_VIDPID: compare product 2887c478bd9Sstevel@tonic-gate * and vendor ID 2897c478bd9Sstevel@tonic-gate * USB_CHK_ALL: perform all checks 2907c478bd9Sstevel@tonic-gate * 2917c478bd9Sstevel@tonic-gate * NOTE: descr length and content always checked 2927c478bd9Sstevel@tonic-gate * device_string - Device string to appear in error message 2937c478bd9Sstevel@tonic-gate * 2947c478bd9Sstevel@tonic-gate * return values: 2957c478bd9Sstevel@tonic-gate * USB_SUCCESS: same device 2967c478bd9Sstevel@tonic-gate * USB_INVALID_VERSION not same device 2977c478bd9Sstevel@tonic-gate * USB_FAILURE: Failure processing request 2987c478bd9Sstevel@tonic-gate * USB_INVALID_ARG: dip is invalid 2997c478bd9Sstevel@tonic-gate */ 3007c478bd9Sstevel@tonic-gate 3017c478bd9Sstevel@tonic-gate /* Checking bits for checks made by usb_check_same_device */ 3027c478bd9Sstevel@tonic-gate #define USB_CHK_BASIC 0 /* Empty mask. Basics always done. */ 3037c478bd9Sstevel@tonic-gate #define USB_CHK_SERIAL 0x00000001 /* Compare device serial numbers. */ 3047c478bd9Sstevel@tonic-gate #define USB_CHK_CFG 0x00000002 /* Compare raw config clouds. */ 3057c478bd9Sstevel@tonic-gate #define USB_CHK_VIDPID 0x00000004 /* Compare product and vendor ID. */ 3067c478bd9Sstevel@tonic-gate #define USB_CHK_ALL 0xFFFFFFFF /* Perform maximum checking. */ 3077c478bd9Sstevel@tonic-gate 3087c478bd9Sstevel@tonic-gate int usb_check_same_device( 3097c478bd9Sstevel@tonic-gate dev_info_t *dip, 3107c478bd9Sstevel@tonic-gate usb_log_handle_t log_handle, 3117c478bd9Sstevel@tonic-gate int log_level, 3127c478bd9Sstevel@tonic-gate int log_mask, 3137c478bd9Sstevel@tonic-gate uint_t check_mask, 3147c478bd9Sstevel@tonic-gate char *device_string); 3157c478bd9Sstevel@tonic-gate 3167c478bd9Sstevel@tonic-gate /* 3177c478bd9Sstevel@tonic-gate * ************************************************************************** 3187c478bd9Sstevel@tonic-gate * Power management functions remaining Contracted Consolidation Private 3197c478bd9Sstevel@tonic-gate * ************************************************************************** 3207c478bd9Sstevel@tonic-gate */ 3217c478bd9Sstevel@tonic-gate 3227c478bd9Sstevel@tonic-gate /* 3237c478bd9Sstevel@tonic-gate * usb wrapper around pm_raise_power & pm_lower_power to allow for 3247c478bd9Sstevel@tonic-gate * non blocking behavior 3257c478bd9Sstevel@tonic-gate * 3267c478bd9Sstevel@tonic-gate * Arguments: 3277c478bd9Sstevel@tonic-gate * dip - pointer to devinfo node of client. 3287c478bd9Sstevel@tonic-gate * comp - component. 3297c478bd9Sstevel@tonic-gate * level - power level. 3307c478bd9Sstevel@tonic-gate * flags - USB_FLAGS_SLEEP: 3317c478bd9Sstevel@tonic-gate * wait for completion. 3327c478bd9Sstevel@tonic-gate * cb - function called on completion, may be NULL. 3337c478bd9Sstevel@tonic-gate * arg - callback argument. 3347c478bd9Sstevel@tonic-gate * rval - USB_SUCCESS or USB_FAILURE. 3357c478bd9Sstevel@tonic-gate * 3367c478bd9Sstevel@tonic-gate * Return Values: 3377c478bd9Sstevel@tonic-gate * USB_SUCCESS - if no USB_FLAGS_SLEEP has been specified, the request 3387c478bd9Sstevel@tonic-gate * has been queued for async execution. If 3397c478bd9Sstevel@tonic-gate * USB_FLAGS_SLEEP has been specified, the raising or 3407c478bd9Sstevel@tonic-gate * lowering of power 3417c478bd9Sstevel@tonic-gate * succeeded. 3427c478bd9Sstevel@tonic-gate * USB_FAILURE - request could not be queued or raising or lowering 3437c478bd9Sstevel@tonic-gate * of power failed. 3447c478bd9Sstevel@tonic-gate */ 3457c478bd9Sstevel@tonic-gate 3467c478bd9Sstevel@tonic-gate /* Status: C and D */ 3477c478bd9Sstevel@tonic-gate int usb_req_raise_power( 3487c478bd9Sstevel@tonic-gate dev_info_t *dip, 3497c478bd9Sstevel@tonic-gate int comp, 3507c478bd9Sstevel@tonic-gate int level, 3517c478bd9Sstevel@tonic-gate void (*cb)(void *arg, int rval), 3527c478bd9Sstevel@tonic-gate void *arg, 3537c478bd9Sstevel@tonic-gate usb_flags_t flags); 3547c478bd9Sstevel@tonic-gate 3557c478bd9Sstevel@tonic-gate /* Status: D */ 3567c478bd9Sstevel@tonic-gate int usb_req_lower_power( 3577c478bd9Sstevel@tonic-gate dev_info_t *dip, 3587c478bd9Sstevel@tonic-gate int comp, 3597c478bd9Sstevel@tonic-gate int level, 3607c478bd9Sstevel@tonic-gate void (*cb)(void *arg, int rval), 3617c478bd9Sstevel@tonic-gate void *arg, 3627c478bd9Sstevel@tonic-gate usb_flags_t flags); 3637c478bd9Sstevel@tonic-gate 3647c478bd9Sstevel@tonic-gate /* 3657c478bd9Sstevel@tonic-gate * USB wrapper functions to set usb device power level. 3667c478bd9Sstevel@tonic-gate * Note : Power levels indicated here are USB power levels 3677c478bd9Sstevel@tonic-gate * and not OS power levels. 3687c478bd9Sstevel@tonic-gate * 3697c478bd9Sstevel@tonic-gate * Note that these were never implemented, and are noops. However, they are 3707c478bd9Sstevel@tonic-gate * included here as the skeleton driver in DDK 0.8 and 0.9 mentioned them. 3717c478bd9Sstevel@tonic-gate * 3727c478bd9Sstevel@tonic-gate * Status: C and D. 3737c478bd9Sstevel@tonic-gate */ 3747c478bd9Sstevel@tonic-gate int usb_set_device_pwrlvl0( 3757c478bd9Sstevel@tonic-gate dev_info_t *dip); 3767c478bd9Sstevel@tonic-gate int usb_set_device_pwrlvl1( 3777c478bd9Sstevel@tonic-gate dev_info_t *dip); 3787c478bd9Sstevel@tonic-gate int usb_set_device_pwrlvl2( 3797c478bd9Sstevel@tonic-gate dev_info_t *dip); 3807c478bd9Sstevel@tonic-gate int usb_set_device_pwrlvl3( 3817c478bd9Sstevel@tonic-gate dev_info_t *dip); 3827c478bd9Sstevel@tonic-gate 3837c478bd9Sstevel@tonic-gate 3847c478bd9Sstevel@tonic-gate /* 3857c478bd9Sstevel@tonic-gate * ************************************************************************** 3867c478bd9Sstevel@tonic-gate * Serialization functions remaining Contracted Consolidation Private 3877c478bd9Sstevel@tonic-gate * ************************************************************************** 3887c478bd9Sstevel@tonic-gate */ 3897c478bd9Sstevel@tonic-gate 3907c478bd9Sstevel@tonic-gate /* This whole section: status: C and D. */ 3917c478bd9Sstevel@tonic-gate 3927c478bd9Sstevel@tonic-gate /* 3937c478bd9Sstevel@tonic-gate * opaque serialization handle. 3947c478bd9Sstevel@tonic-gate * Used by all usb_serialization routines. 3957c478bd9Sstevel@tonic-gate * 3967c478bd9Sstevel@tonic-gate * This handle is opaque to the client driver. 3977c478bd9Sstevel@tonic-gate */ 3987c478bd9Sstevel@tonic-gate typedef struct usb_serialization *usb_serialization_t; 3997c478bd9Sstevel@tonic-gate 4007c478bd9Sstevel@tonic-gate /* 4017c478bd9Sstevel@tonic-gate * usb_init_serialization 4027c478bd9Sstevel@tonic-gate * setup for serialization 4037c478bd9Sstevel@tonic-gate * 4047c478bd9Sstevel@tonic-gate * ARGUMENTS: 4057c478bd9Sstevel@tonic-gate * s_dip - devinfo pointer 4067c478bd9Sstevel@tonic-gate * flag - USB_INIT_SER_CHECK_SAME_THREAD 4077c478bd9Sstevel@tonic-gate * when set, usb_release_access() will 4087c478bd9Sstevel@tonic-gate * verify that the same thread releases 4097c478bd9Sstevel@tonic-gate * access. If not, a console warning will 4107c478bd9Sstevel@tonic-gate * be issued but access will be released 4117c478bd9Sstevel@tonic-gate * anyways. 4127c478bd9Sstevel@tonic-gate * 4137c478bd9Sstevel@tonic-gate * RETURNS: 4147c478bd9Sstevel@tonic-gate * usb_serialization handle 4157c478bd9Sstevel@tonic-gate * 4167c478bd9Sstevel@tonic-gate */ 4177c478bd9Sstevel@tonic-gate usb_serialization_t usb_init_serialization( 4187c478bd9Sstevel@tonic-gate dev_info_t *s_dip, 4197c478bd9Sstevel@tonic-gate uint_t flag); 4207c478bd9Sstevel@tonic-gate 4217c478bd9Sstevel@tonic-gate #define USB_INIT_SER_CHECK_SAME_THREAD 1 4227c478bd9Sstevel@tonic-gate 4237c478bd9Sstevel@tonic-gate /* fini for serialization */ 4247c478bd9Sstevel@tonic-gate void usb_fini_serialization( 4257c478bd9Sstevel@tonic-gate usb_serialization_t usb_serp); 4267c478bd9Sstevel@tonic-gate 4277c478bd9Sstevel@tonic-gate /* 4287c478bd9Sstevel@tonic-gate * Various ways of calling usb_serialize_access. These correspond to 4297c478bd9Sstevel@tonic-gate * their cv_*wait* function counterparts for usb_serialize_access. 4307c478bd9Sstevel@tonic-gate */ 4317c478bd9Sstevel@tonic-gate #define USB_WAIT 0 4327c478bd9Sstevel@tonic-gate #define USB_WAIT_SIG 1 4337c478bd9Sstevel@tonic-gate #define USB_TIMEDWAIT 2 4347c478bd9Sstevel@tonic-gate #define USB_TIMEDWAIT_SIG 3 4357c478bd9Sstevel@tonic-gate 4367c478bd9Sstevel@tonic-gate /* 4377c478bd9Sstevel@tonic-gate * usb_serialize_access: 4387c478bd9Sstevel@tonic-gate * acquire serialized access 4397c478bd9Sstevel@tonic-gate * ARGUMENTS: 4407c478bd9Sstevel@tonic-gate * usb_serp - usb_serialization handle 4417c478bd9Sstevel@tonic-gate * how_to_wait - Which cv_*wait* function to wait for condition. 4427c478bd9Sstevel@tonic-gate * USB_WAIT: use cv_wait 4437c478bd9Sstevel@tonic-gate * USB_WAIT_SIG: use cv_wait_sig 4447c478bd9Sstevel@tonic-gate * USB_TIMEDWAIT: use cv_timedwait 4457c478bd9Sstevel@tonic-gate * USB_TIMEDWAIT_SIG: use cv_timedwait_sig 4467c478bd9Sstevel@tonic-gate * delta_timeout - Time in ms from current time to timeout. Checked 4477c478bd9Sstevel@tonic-gate * only if USB_TIMEDWAIT or USB_TIMEDWAIT_SIG 4487c478bd9Sstevel@tonic-gate * specified in how_to_wait. 4497c478bd9Sstevel@tonic-gate * RETURNS: 4507c478bd9Sstevel@tonic-gate * Same as values returned by cv_*wait* functions, 4517c478bd9Sstevel@tonic-gate * except for when how_to_wait == USB_WAIT, where 0 is always returned. 4527c478bd9Sstevel@tonic-gate * For calls where a timeout or signal could be expected, use this value 4537c478bd9Sstevel@tonic-gate * to tell whether a kill(2) signal or timeout occurred. 4547c478bd9Sstevel@tonic-gate */ 4557c478bd9Sstevel@tonic-gate int usb_serialize_access( 4567c478bd9Sstevel@tonic-gate usb_serialization_t usb_serp, 4577c478bd9Sstevel@tonic-gate uint_t how_to_wait, 4587c478bd9Sstevel@tonic-gate uint_t delta_timeout); 4597c478bd9Sstevel@tonic-gate 4607c478bd9Sstevel@tonic-gate /* 4617c478bd9Sstevel@tonic-gate * usb_try_serialize_access: 4627c478bd9Sstevel@tonic-gate * try acquiring serialized access 4637c478bd9Sstevel@tonic-gate * 4647c478bd9Sstevel@tonic-gate * ARGUMENTS: 4657c478bd9Sstevel@tonic-gate * usb_serp - usb_serialization handle 4667c478bd9Sstevel@tonic-gate * flag - unused 4677c478bd9Sstevel@tonic-gate * 4687c478bd9Sstevel@tonic-gate * RETURNS: 4697c478bd9Sstevel@tonic-gate * USB_SUCCESS - access has been acquired 4707c478bd9Sstevel@tonic-gate * USB_FAILURE - access has not been acquired 4717c478bd9Sstevel@tonic-gate */ 4727c478bd9Sstevel@tonic-gate int usb_try_serialize_access(usb_serialization_t usb_serp, uint_t flag); 4737c478bd9Sstevel@tonic-gate 4747c478bd9Sstevel@tonic-gate /* 4757c478bd9Sstevel@tonic-gate * usb_release_access: 4767c478bd9Sstevel@tonic-gate * release serialized access 4777c478bd9Sstevel@tonic-gate * 4787c478bd9Sstevel@tonic-gate * ARGUMENTS: 4797c478bd9Sstevel@tonic-gate * usb_serp - usb_serialization handle 4807c478bd9Sstevel@tonic-gate */ 4817c478bd9Sstevel@tonic-gate void usb_release_access(usb_serialization_t usb_serp); 4827c478bd9Sstevel@tonic-gate 4837c478bd9Sstevel@tonic-gate 4847c478bd9Sstevel@tonic-gate /* 4857c478bd9Sstevel@tonic-gate * ************************************************************************** 4867c478bd9Sstevel@tonic-gate * Asynchronous functions remaining Contracted Consolidation Private 4877c478bd9Sstevel@tonic-gate * ************************************************************************** 4887c478bd9Sstevel@tonic-gate */ 4897c478bd9Sstevel@tonic-gate 4907c478bd9Sstevel@tonic-gate /* This whole section: status: C and D. */ 4917c478bd9Sstevel@tonic-gate 4927c478bd9Sstevel@tonic-gate /* For async_req functions. */ 4937c478bd9Sstevel@tonic-gate #define USB_FLAGS_NOQUEUE 0x200 4947c478bd9Sstevel@tonic-gate 4957c478bd9Sstevel@tonic-gate /* 4967c478bd9Sstevel@tonic-gate * Issue a request to the asynchronous request service 4977c478bd9Sstevel@tonic-gate * All async request functions return USB_SUCCESS or USB_FAILURE 4987c478bd9Sstevel@tonic-gate * Arguments: 4997c478bd9Sstevel@tonic-gate * dip - pointer to devinfo node 5007c478bd9Sstevel@tonic-gate * func - pointer of function to execute asynchronously 5017c478bd9Sstevel@tonic-gate * arg - argument to function 5027c478bd9Sstevel@tonic-gate * flag - USB_FLAGS_SLEEP or USB_FLAGS_NOSLEEP or 5037c478bd9Sstevel@tonic-gate * USB_FLAGS_NOQUEUE 5047c478bd9Sstevel@tonic-gate * Return Values: 5057c478bd9Sstevel@tonic-gate * USB_SUCCESS - function was scheduled 5067c478bd9Sstevel@tonic-gate * USB_FAILURE - function could not be scheduled 5077c478bd9Sstevel@tonic-gate * 5087c478bd9Sstevel@tonic-gate * Flag combinations: 5097c478bd9Sstevel@tonic-gate * SLEEP - block waiting for resources. always succeeds 5107c478bd9Sstevel@tonic-gate * NOSLEEP - do not wait for resources, may fail. 5117c478bd9Sstevel@tonic-gate * NOSLEEP+NOQUEUE - do not wait for resources, do not queue 5127c478bd9Sstevel@tonic-gate * SLEEP+NOQUEUE - block waiting for resources but may still fail 5137c478bd9Sstevel@tonic-gate * if no thread available 5147c478bd9Sstevel@tonic-gate */ 5157c478bd9Sstevel@tonic-gate int usb_async_req( 5167c478bd9Sstevel@tonic-gate dev_info_t *dip, 5177c478bd9Sstevel@tonic-gate void (*func)(void *), 5187c478bd9Sstevel@tonic-gate void *arg, 5197c478bd9Sstevel@tonic-gate usb_flags_t flag); 5207c478bd9Sstevel@tonic-gate 5217c478bd9Sstevel@tonic-gate 5227c478bd9Sstevel@tonic-gate /* 5237c478bd9Sstevel@tonic-gate * index for getting to usb_pipehandle_list in usba_device 5247c478bd9Sstevel@tonic-gate */ 5257c478bd9Sstevel@tonic-gate uchar_t usb_get_ep_index(uint8_t ep_addr); 5267c478bd9Sstevel@tonic-gate 5277c478bd9Sstevel@tonic-gate 5287c478bd9Sstevel@tonic-gate #ifdef ALLOCB_TEST 5297c478bd9Sstevel@tonic-gate #define allocb(s, p) usba_test_allocb(s, p) 5307c478bd9Sstevel@tonic-gate mblk_t *usba_test_allocb(size_t, uint_t); 5317c478bd9Sstevel@tonic-gate #endif /* ALLOCB_TEST */ 5327c478bd9Sstevel@tonic-gate 5337c478bd9Sstevel@tonic-gate /* create an USB style M_CTL message */ 5347c478bd9Sstevel@tonic-gate mblk_t *usba_mk_mctl(struct iocblk, void *, size_t); 5357c478bd9Sstevel@tonic-gate 5367c478bd9Sstevel@tonic-gate #ifdef __cplusplus 5377c478bd9Sstevel@tonic-gate } 5387c478bd9Sstevel@tonic-gate #endif 5397c478bd9Sstevel@tonic-gate 5407c478bd9Sstevel@tonic-gate #endif /* _SYS_USB_USBA_USBAI_PRIVATE_H */ 541