xref: /onnv-gate/usr/src/uts/common/sys/usb/usba/usbai_private.h (revision 7492:2387323b838f)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7492SZhigang.Lu@Sun.COM  * Common Development and Distribution License (the "License").
6*7492SZhigang.Lu@Sun.COM  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*7492SZhigang.Lu@Sun.COM  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_SYS_USB_USBA_USBAI_PRIVATE_H
270Sstevel@tonic-gate #define	_SYS_USB_USBA_USBAI_PRIVATE_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate 
300Sstevel@tonic-gate /*
310Sstevel@tonic-gate  * Unstable interfaces not part of USBAI but used by Solaris client drivers.
320Sstevel@tonic-gate  * These interfaces may not be present in future releases and are highly
330Sstevel@tonic-gate  * unstable.
340Sstevel@tonic-gate  *
350Sstevel@tonic-gate  * Status key:
360Sstevel@tonic-gate  *	C = Remove from Sun client drivers before removing from this file
370Sstevel@tonic-gate  *	D = May be needed by legacy (DDK) drivers.
380Sstevel@tonic-gate  */
390Sstevel@tonic-gate 
400Sstevel@tonic-gate #ifdef	__cplusplus
410Sstevel@tonic-gate extern "C" {
420Sstevel@tonic-gate #endif
430Sstevel@tonic-gate 
440Sstevel@tonic-gate /*
450Sstevel@tonic-gate  * convenience function for getting default config index
460Sstevel@tonic-gate  * as saved in usba_device structure
470Sstevel@tonic-gate  *
480Sstevel@tonic-gate  * Status: C
490Sstevel@tonic-gate  */
500Sstevel@tonic-gate uint_t usb_get_current_cfgidx(dev_info_t *);
510Sstevel@tonic-gate 
520Sstevel@tonic-gate /*
530Sstevel@tonic-gate  * **************************************************************************
540Sstevel@tonic-gate  * Error and status definitions, and reporting functions
550Sstevel@tonic-gate  * **************************************************************************
560Sstevel@tonic-gate  */
570Sstevel@tonic-gate 
580Sstevel@tonic-gate 
590Sstevel@tonic-gate /*
600Sstevel@tonic-gate  * convenience functions to get string corresponding to value
610Sstevel@tonic-gate  * usb_cb_flags_name requires a workbuffer of sufficient length
620Sstevel@tonic-gate  * for the concatenation of all strings as usb_cb_flags_t is a bit
630Sstevel@tonic-gate  * mask
640Sstevel@tonic-gate  *
650Sstevel@tonic-gate  * Status: C and D
660Sstevel@tonic-gate  */
670Sstevel@tonic-gate const char	*usb_str_cr(usb_cr_t cr);
680Sstevel@tonic-gate char		*usb_str_cb_flags(usb_cb_flags_t cb_flags,
690Sstevel@tonic-gate 		char *buffer, size_t length);
700Sstevel@tonic-gate const char	*usb_str_pipe_state(usb_pipe_state_t state);
710Sstevel@tonic-gate const char	*usb_str_dev_state(int state);
720Sstevel@tonic-gate const char	*usb_str_rval(int rval);
730Sstevel@tonic-gate 
740Sstevel@tonic-gate /* function convert a USB return value to an errno */
750Sstevel@tonic-gate int		usb_rval2errno(int rval);
760Sstevel@tonic-gate 
770Sstevel@tonic-gate /*
780Sstevel@tonic-gate  * **************************************************************************
790Sstevel@tonic-gate  * Transfer-related definitions and functions
800Sstevel@tonic-gate  * **************************************************************************
810Sstevel@tonic-gate  */
820Sstevel@tonic-gate 
830Sstevel@tonic-gate /* Status C and D for whole section. */
840Sstevel@tonic-gate 
850Sstevel@tonic-gate /* Serialize callbacks per interface or device. */
860Sstevel@tonic-gate #define	USB_FLAGS_SERIALIZED_CB	0x8000
870Sstevel@tonic-gate 
880Sstevel@tonic-gate /* default timeout for control requests (in seconds) */
890Sstevel@tonic-gate #define	USB_PIPE_TIMEOUT	3
900Sstevel@tonic-gate 
910Sstevel@tonic-gate /*
920Sstevel@tonic-gate  * usb_pipe_sync_ctrl_xfer():
930Sstevel@tonic-gate  *	for simple synchronous control transactions this wrapper function
940Sstevel@tonic-gate  *	will perform the allocation, xfer, and deallocation.
950Sstevel@tonic-gate  *	USB_ATTRS_AUTOCLEARING will be enabled
960Sstevel@tonic-gate  *
970Sstevel@tonic-gate  * ARGUMENTS:
980Sstevel@tonic-gate  *	dip		- pointer to clients devinfo.
990Sstevel@tonic-gate  *	pipe_handle	- control pipe pipehandle (obtained via usb_pipe_open().
1000Sstevel@tonic-gate  *	bmRequestType	- characteristics of request.
1010Sstevel@tonic-gate  *	bRequest	- specific request.
1020Sstevel@tonic-gate  *	wValue		- varies according to request.
1030Sstevel@tonic-gate  *	wIndex		- index or offset.
1040Sstevel@tonic-gate  *	wLength		- number of bytes to xfer.
1050Sstevel@tonic-gate  *	data		- pointer to pointer to data
1060Sstevel@tonic-gate  *			  IN: HCD will allocate data
1070Sstevel@tonic-gate  *			  OUT: clients driver allocates data.
1080Sstevel@tonic-gate  *	attrs		- required request attributes.
1090Sstevel@tonic-gate  *	completion_reason - completion status.
1100Sstevel@tonic-gate  *	cb_flags	- request completions flags.
1110Sstevel@tonic-gate  *	flags		- none.
1120Sstevel@tonic-gate  *
1130Sstevel@tonic-gate  * RETURN VALUES:
1140Sstevel@tonic-gate  *	USB_SUCCESS	- request successfully executed.
1150Sstevel@tonic-gate  *	USB_FAILURE	- request failed.
1160Sstevel@tonic-gate  *
1170Sstevel@tonic-gate  * NOTES:
1180Sstevel@tonic-gate  * - in the case of failure, the client should check completion_reason and
1190Sstevel@tonic-gate  *   and cb_flags and determine further recovery action
1200Sstevel@tonic-gate  * - the client should check data and if non-zero, free the data on
1210Sstevel@tonic-gate  *   completion
1220Sstevel@tonic-gate  */
1230Sstevel@tonic-gate int usb_pipe_sync_ctrl_xfer(
1240Sstevel@tonic-gate 	dev_info_t	*dip,
1250Sstevel@tonic-gate 	usb_pipe_handle_t pipe_handle,
1260Sstevel@tonic-gate 	uchar_t 	bmRequestType,
1270Sstevel@tonic-gate 	uchar_t 	bRequest,
1280Sstevel@tonic-gate 	uint16_t	wValue,
1290Sstevel@tonic-gate 	uint16_t	wIndex,
1300Sstevel@tonic-gate 	uint16_t	wLength,
1310Sstevel@tonic-gate 	mblk_t		**data,
1320Sstevel@tonic-gate 	usb_req_attrs_t attrs,
1330Sstevel@tonic-gate 	usb_cr_t	*completion_reason,
1340Sstevel@tonic-gate 	usb_cb_flags_t	*cb_flags,
1350Sstevel@tonic-gate 	usb_flags_t	flags);
1360Sstevel@tonic-gate 
1370Sstevel@tonic-gate /*
1380Sstevel@tonic-gate  * **************************************************************************
1390Sstevel@tonic-gate  * Event registration / pre-suspend and post-resume handling
1400Sstevel@tonic-gate  * **************************************************************************
1410Sstevel@tonic-gate  */
1420Sstevel@tonic-gate 
1430Sstevel@tonic-gate /* Status: C and D for whole section. */
1440Sstevel@tonic-gate 
1450Sstevel@tonic-gate /*
1460Sstevel@tonic-gate  * Event registration info for both hotplug and pre-suspend/post-resume
1470Sstevel@tonic-gate  * callbacks.  Eventually pre-suspend and post-resume callbacks will not be
1480Sstevel@tonic-gate  * needed, so this is for this OS release only and will go away in a
1490Sstevel@tonic-gate  * subsequent release.
1500Sstevel@tonic-gate  */
1510Sstevel@tonic-gate typedef struct usb_event {
1520Sstevel@tonic-gate 	/* device disconnected/unplugged */
1530Sstevel@tonic-gate 	int	(*disconnect_event_handler)(dev_info_t *dip);
1540Sstevel@tonic-gate 
1550Sstevel@tonic-gate 	/* device reconnected */
1560Sstevel@tonic-gate 	int	(*reconnect_event_handler)(dev_info_t *dip);
1570Sstevel@tonic-gate 
1580Sstevel@tonic-gate 	/* notification that system is about to checkpoint */
1590Sstevel@tonic-gate 	int	(*pre_suspend_event_handler)(dev_info_t *dip);
1600Sstevel@tonic-gate 
1610Sstevel@tonic-gate 	/* notification that system resumed after a checkpoint */
1620Sstevel@tonic-gate 	int	(*post_resume_event_handler)(dev_info_t *dip);
1630Sstevel@tonic-gate } usb_event_t;
1640Sstevel@tonic-gate 
1650Sstevel@tonic-gate /*
1660Sstevel@tonic-gate  * Event callbacks
1670Sstevel@tonic-gate  *	the callbacks should always return USB_SUCCESS.
1680Sstevel@tonic-gate  */
1690Sstevel@tonic-gate int usb_register_event_cbs(
1700Sstevel@tonic-gate 	dev_info_t	*dip,
1710Sstevel@tonic-gate 	usb_event_t	*usb_evt_data,
1720Sstevel@tonic-gate 	usb_flags_t	flags);
1730Sstevel@tonic-gate 
1740Sstevel@tonic-gate void usb_unregister_event_cbs(
1750Sstevel@tonic-gate 	dev_info_t	*dip,
1760Sstevel@tonic-gate 	usb_event_t	*usb_evt_data);
1770Sstevel@tonic-gate 
1780Sstevel@tonic-gate /*
1790Sstevel@tonic-gate  * USB CPR support
1800Sstevel@tonic-gate  *	A client driver must call this funtion in pre-suspend event handler
1810Sstevel@tonic-gate  *	to inform the USBA framework that it can't suspend because
1820Sstevel@tonic-gate  *	driver instance or device could not be quiesced.
1830Sstevel@tonic-gate  */
1840Sstevel@tonic-gate void usb_fail_checkpoint(
1850Sstevel@tonic-gate 	dev_info_t	*dip,
1860Sstevel@tonic-gate 	usb_flags_t	flags);
1870Sstevel@tonic-gate 
1880Sstevel@tonic-gate 
1890Sstevel@tonic-gate /*
1900Sstevel@tonic-gate  * **************************************************************************
1910Sstevel@tonic-gate  * Logging functions remaining Contracted Consolidation Private
1920Sstevel@tonic-gate  * **************************************************************************
1930Sstevel@tonic-gate  */
1940Sstevel@tonic-gate 
1950Sstevel@tonic-gate /* Status: C and D for whole section. */
1960Sstevel@tonic-gate 
1970Sstevel@tonic-gate /*
1980Sstevel@tonic-gate  * Usb logging, debug and console message handling.
1990Sstevel@tonic-gate  */
2000Sstevel@tonic-gate typedef struct usb_log_handle *usb_log_handle_t;
2010Sstevel@tonic-gate 
2020Sstevel@tonic-gate #define	USB_LOG_L0	0	/* warnings, console & syslog buffer */
2030Sstevel@tonic-gate #define	USB_LOG_L1	1	/* errors, syslog buffer */
2040Sstevel@tonic-gate #define	USB_LOG_L2	2	/* recoverable errors, debug only */
2050Sstevel@tonic-gate #define	USB_LOG_L3	3	/* interesting data, debug only */
2060Sstevel@tonic-gate #define	USB_LOG_L4	4	/* tracing, debug only */
2070Sstevel@tonic-gate 
2080Sstevel@tonic-gate #ifdef DEBUG
2090Sstevel@tonic-gate #define	USB_DPRINTF_L4	usb_dprintf4
2100Sstevel@tonic-gate #define	USB_DPRINTF_L3	usb_dprintf3
2110Sstevel@tonic-gate 
2120Sstevel@tonic-gate /*PRINTFLIKE3*/
2130Sstevel@tonic-gate void usb_dprintf4(
2140Sstevel@tonic-gate 	uint_t		mask,
2150Sstevel@tonic-gate 	usb_log_handle_t handle,
2160Sstevel@tonic-gate 	char		*fmt, ...);
2170Sstevel@tonic-gate /*PRINTFLIKE3*/
2180Sstevel@tonic-gate void usb_dprintf3(
2190Sstevel@tonic-gate 	uint_t		mask,
2200Sstevel@tonic-gate 	usb_log_handle_t handle,
2210Sstevel@tonic-gate 	char		*fmt, ...);
2220Sstevel@tonic-gate #else
2230Sstevel@tonic-gate #define	USB_DPRINTF_L4 0 &&
2240Sstevel@tonic-gate #define	USB_DPRINTF_L3 0 &&
2250Sstevel@tonic-gate #endif
2260Sstevel@tonic-gate 
2270Sstevel@tonic-gate #define	USB_DPRINTF_L2	usb_dprintf2
2280Sstevel@tonic-gate #define	USB_DPRINTF_L1	usb_dprintf1
2290Sstevel@tonic-gate #define	USB_DPRINTF_L0	usb_dprintf0
2300Sstevel@tonic-gate 
2310Sstevel@tonic-gate /*PRINTFLIKE3*/
2320Sstevel@tonic-gate void usb_dprintf2(
2330Sstevel@tonic-gate 	uint_t		mask,
2340Sstevel@tonic-gate 	usb_log_handle_t handle,
2350Sstevel@tonic-gate 	char		*fmt, ...);
2360Sstevel@tonic-gate /*PRINTFLIKE3*/
2370Sstevel@tonic-gate void usb_dprintf1(
2380Sstevel@tonic-gate 	uint_t		mask,
2390Sstevel@tonic-gate 	usb_log_handle_t handle,
2400Sstevel@tonic-gate 	char		*fmt, ...);
2410Sstevel@tonic-gate /*PRINTFLIKE3*/
2420Sstevel@tonic-gate void usb_dprintf0(
2430Sstevel@tonic-gate 	uint_t		mask,
2440Sstevel@tonic-gate 	usb_log_handle_t handle,
2450Sstevel@tonic-gate 	char		*fmt, ...);
2460Sstevel@tonic-gate 
2470Sstevel@tonic-gate usb_log_handle_t usb_alloc_log_hdl(
2480Sstevel@tonic-gate 	dev_info_t	*dip,
2490Sstevel@tonic-gate 	char		*name,
2500Sstevel@tonic-gate 	uint_t		*errlevel,
2510Sstevel@tonic-gate 	uint_t		*mask,
2520Sstevel@tonic-gate 	uint_t		*instance_filter,
2530Sstevel@tonic-gate 	usb_flags_t	flags);
2540Sstevel@tonic-gate 
2550Sstevel@tonic-gate /* free the log handle */
2560Sstevel@tonic-gate void usb_free_log_hdl(
2570Sstevel@tonic-gate 	usb_log_handle_t handle);
2580Sstevel@tonic-gate 
2590Sstevel@tonic-gate /* log message */
2600Sstevel@tonic-gate /*PRINTFLIKE4*/
2610Sstevel@tonic-gate int usb_log(
2620Sstevel@tonic-gate 	usb_log_handle_t handle,
2630Sstevel@tonic-gate 	uint_t		level,
2640Sstevel@tonic-gate 	uint_t		mask,
2650Sstevel@tonic-gate 	char		*fmt, ...);
2660Sstevel@tonic-gate 
2670Sstevel@tonic-gate /*
2680Sstevel@tonic-gate  * usb_check_same_device:
2690Sstevel@tonic-gate  *	Check if the device connected to the port is the same as
2700Sstevel@tonic-gate  *	the previous device that was in the port.  The previous device is
2710Sstevel@tonic-gate  *	represented by the dip on record for the port.	Print a message
2720Sstevel@tonic-gate  *	if the device is different.  If device_string arg is not NULL, it is
2730Sstevel@tonic-gate  *	included in the message.  Can block.
2740Sstevel@tonic-gate  *
2750Sstevel@tonic-gate  * Arguments:
2760Sstevel@tonic-gate  *	dip			- pointer to devinfo of the client
2770Sstevel@tonic-gate  *	log_handle		- handle to which messages are logged
2780Sstevel@tonic-gate  *	log_level		- one of USB_LOG_*
2790Sstevel@tonic-gate  *	log_mask		- logging mask
2800Sstevel@tonic-gate  *	check_mask		- one mask containing things to check:
2810Sstevel@tonic-gate  *					USB_CHK_BASIC: empty mask;
2820Sstevel@tonic-gate  *						these checks are always done.
2830Sstevel@tonic-gate  *					USB_CHK_SERIAL: check match on device
2840Sstevel@tonic-gate  *						serial number.
2850Sstevel@tonic-gate  *					USB_CHK_CFG: compare config clouds
2860Sstevel@tonic-gate  *						byte by byte
2870Sstevel@tonic-gate  *					USB_CHK_VIDPID: compare product
2880Sstevel@tonic-gate  *						and vendor ID
2890Sstevel@tonic-gate  *					USB_CHK_ALL: perform all checks
2900Sstevel@tonic-gate  *
2910Sstevel@tonic-gate  *				NOTE: descr length and content always checked
2920Sstevel@tonic-gate  *	device_string		- Device string to appear in error message
2930Sstevel@tonic-gate  *
2940Sstevel@tonic-gate  * return values:
2950Sstevel@tonic-gate  *	USB_SUCCESS:		same device
2960Sstevel@tonic-gate  *	USB_INVALID_VERSION	not same device
2970Sstevel@tonic-gate  *	USB_FAILURE:		Failure processing request
2980Sstevel@tonic-gate  *	USB_INVALID_ARG:	dip is invalid
2990Sstevel@tonic-gate  */
3000Sstevel@tonic-gate 
3010Sstevel@tonic-gate /* Checking bits for checks made by usb_check_same_device */
3020Sstevel@tonic-gate #define	USB_CHK_BASIC	0		/* Empty mask.	Basics always done. */
3030Sstevel@tonic-gate #define	USB_CHK_SERIAL	0x00000001	/* Compare device serial numbers. */
3040Sstevel@tonic-gate #define	USB_CHK_CFG	0x00000002	/* Compare raw config clouds. */
3050Sstevel@tonic-gate #define	USB_CHK_VIDPID	0x00000004	/* Compare product and vendor ID. */
3060Sstevel@tonic-gate #define	USB_CHK_ALL	0xFFFFFFFF	/* Perform maximum checking. */
3070Sstevel@tonic-gate 
3080Sstevel@tonic-gate int usb_check_same_device(
3090Sstevel@tonic-gate 	dev_info_t		*dip,
3100Sstevel@tonic-gate 	usb_log_handle_t	log_handle,
3110Sstevel@tonic-gate 	int			log_level,
3120Sstevel@tonic-gate 	int			log_mask,
3130Sstevel@tonic-gate 	uint_t			check_mask,
3140Sstevel@tonic-gate 	char			*device_string);
3150Sstevel@tonic-gate 
3160Sstevel@tonic-gate /*
3170Sstevel@tonic-gate  * **************************************************************************
3180Sstevel@tonic-gate  * Power management functions remaining Contracted Consolidation Private
3190Sstevel@tonic-gate  * **************************************************************************
3200Sstevel@tonic-gate  */
3210Sstevel@tonic-gate 
3220Sstevel@tonic-gate /*
3230Sstevel@tonic-gate  * usb wrapper around pm_raise_power & pm_lower_power to allow for
3240Sstevel@tonic-gate  * non blocking behavior
3250Sstevel@tonic-gate  *
3260Sstevel@tonic-gate  * Arguments:
3270Sstevel@tonic-gate  *	dip		- pointer to devinfo node of client.
3280Sstevel@tonic-gate  *	comp		- component.
3290Sstevel@tonic-gate  *	level		- power level.
3300Sstevel@tonic-gate  *	flags		- USB_FLAGS_SLEEP:
3310Sstevel@tonic-gate  *				wait for completion.
3320Sstevel@tonic-gate  *	cb		- function called on completion, may be NULL.
3330Sstevel@tonic-gate  *	arg		- callback argument.
3340Sstevel@tonic-gate  *	rval		- USB_SUCCESS or USB_FAILURE.
3350Sstevel@tonic-gate  *
3360Sstevel@tonic-gate  * Return Values:
3370Sstevel@tonic-gate  *	USB_SUCCESS	-  if no USB_FLAGS_SLEEP has been specified, the request
3380Sstevel@tonic-gate  *			   has been queued for async execution. If
3390Sstevel@tonic-gate  *			   USB_FLAGS_SLEEP has been specified, the raising or
3400Sstevel@tonic-gate  *			   lowering of power
3410Sstevel@tonic-gate  *			   succeeded.
3420Sstevel@tonic-gate  *	USB_FAILURE	-  request could not be queued or raising or lowering
3430Sstevel@tonic-gate  *			   of power failed.
3440Sstevel@tonic-gate  */
3450Sstevel@tonic-gate 
3460Sstevel@tonic-gate /* Status: C and D */
3470Sstevel@tonic-gate int usb_req_raise_power(
3480Sstevel@tonic-gate 	dev_info_t	*dip,
3490Sstevel@tonic-gate 	int		comp,
3500Sstevel@tonic-gate 	int		level,
3510Sstevel@tonic-gate 	void		(*cb)(void *arg, int rval),
3520Sstevel@tonic-gate 	void		*arg,
3530Sstevel@tonic-gate 	usb_flags_t	flags);
3540Sstevel@tonic-gate 
3550Sstevel@tonic-gate /* Status: D */
3560Sstevel@tonic-gate int usb_req_lower_power(
3570Sstevel@tonic-gate 	dev_info_t	*dip,
3580Sstevel@tonic-gate 	int		comp,
3590Sstevel@tonic-gate 	int		level,
3600Sstevel@tonic-gate 	void		(*cb)(void *arg, int rval),
3610Sstevel@tonic-gate 	void		*arg,
3620Sstevel@tonic-gate 	usb_flags_t	flags);
3630Sstevel@tonic-gate 
3640Sstevel@tonic-gate /*
3650Sstevel@tonic-gate  * USB wrapper functions to set usb device power level.
3660Sstevel@tonic-gate  * Note : Power levels indicated here are USB power levels
3670Sstevel@tonic-gate  * and not OS power levels.
3680Sstevel@tonic-gate  *
3690Sstevel@tonic-gate  * Note that these were never implemented, and are noops.  However, they are
3700Sstevel@tonic-gate  * included here as the skeleton driver in DDK 0.8 and 0.9 mentioned them.
3710Sstevel@tonic-gate  *
3720Sstevel@tonic-gate  * Status: C and D.
3730Sstevel@tonic-gate  */
3740Sstevel@tonic-gate int usb_set_device_pwrlvl0(
3750Sstevel@tonic-gate 	dev_info_t	*dip);
3760Sstevel@tonic-gate int usb_set_device_pwrlvl1(
3770Sstevel@tonic-gate 	dev_info_t	*dip);
3780Sstevel@tonic-gate int usb_set_device_pwrlvl2(
3790Sstevel@tonic-gate 	dev_info_t	*dip);
3800Sstevel@tonic-gate int usb_set_device_pwrlvl3(
3810Sstevel@tonic-gate 	dev_info_t	*dip);
3820Sstevel@tonic-gate 
3830Sstevel@tonic-gate 
3840Sstevel@tonic-gate /*
3850Sstevel@tonic-gate  * **************************************************************************
3860Sstevel@tonic-gate  * Serialization functions remaining Contracted Consolidation Private
3870Sstevel@tonic-gate  * **************************************************************************
3880Sstevel@tonic-gate  */
3890Sstevel@tonic-gate 
3900Sstevel@tonic-gate /* This whole section: status: C and D. */
3910Sstevel@tonic-gate 
3920Sstevel@tonic-gate /*
3930Sstevel@tonic-gate  * opaque serialization handle.
3940Sstevel@tonic-gate  *	Used by all usb_serialization routines.
3950Sstevel@tonic-gate  *
3960Sstevel@tonic-gate  *	This handle is opaque to the client driver.
3970Sstevel@tonic-gate  */
3980Sstevel@tonic-gate typedef	struct usb_serialization	*usb_serialization_t;
3990Sstevel@tonic-gate 
4000Sstevel@tonic-gate /*
4010Sstevel@tonic-gate  * usb_init_serialization
4020Sstevel@tonic-gate  *	setup for serialization
4030Sstevel@tonic-gate  *
4040Sstevel@tonic-gate  * ARGUMENTS:
4050Sstevel@tonic-gate  *	s_dip		- devinfo pointer
4060Sstevel@tonic-gate  *	flag		- USB_INIT_SER_CHECK_SAME_THREAD
4070Sstevel@tonic-gate  *			  when set, usb_release_access() will
4080Sstevel@tonic-gate  *			  verify that the same thread releases
4090Sstevel@tonic-gate  *			  access. If not, a console warning will
4100Sstevel@tonic-gate  *			  be issued but access will be released
4110Sstevel@tonic-gate  *			  anyways.
4120Sstevel@tonic-gate  *
4130Sstevel@tonic-gate  * RETURNS:
4140Sstevel@tonic-gate  *	usb_serialization handle
4150Sstevel@tonic-gate  *
4160Sstevel@tonic-gate  */
4170Sstevel@tonic-gate usb_serialization_t usb_init_serialization(
4180Sstevel@tonic-gate 	dev_info_t	*s_dip,
4190Sstevel@tonic-gate 	uint_t		flag);
4200Sstevel@tonic-gate 
4210Sstevel@tonic-gate #define	USB_INIT_SER_CHECK_SAME_THREAD	1
4220Sstevel@tonic-gate 
4230Sstevel@tonic-gate /* fini for serialization */
4240Sstevel@tonic-gate void usb_fini_serialization(
4250Sstevel@tonic-gate 	usb_serialization_t usb_serp);
4260Sstevel@tonic-gate 
4270Sstevel@tonic-gate /*
4280Sstevel@tonic-gate  * Various ways of calling usb_serialize_access.  These correspond to
4290Sstevel@tonic-gate  * their cv_*wait* function counterparts for usb_serialize_access.
4300Sstevel@tonic-gate  */
4310Sstevel@tonic-gate #define	USB_WAIT		0
4320Sstevel@tonic-gate #define	USB_WAIT_SIG		1
4330Sstevel@tonic-gate #define	USB_TIMEDWAIT		2
4340Sstevel@tonic-gate #define	USB_TIMEDWAIT_SIG	3
4350Sstevel@tonic-gate 
4360Sstevel@tonic-gate /*
4370Sstevel@tonic-gate  * usb_serialize_access:
4380Sstevel@tonic-gate  *	acquire serialized access
4390Sstevel@tonic-gate  * ARGUMENTS:
4400Sstevel@tonic-gate  *	usb_serp	- usb_serialization handle
4410Sstevel@tonic-gate  *	how_to_wait	- Which cv_*wait* function to wait for condition.
4420Sstevel@tonic-gate  *				USB_WAIT:		use cv_wait
4430Sstevel@tonic-gate  *				USB_WAIT_SIG:		use cv_wait_sig
4440Sstevel@tonic-gate  *				USB_TIMEDWAIT:		use cv_timedwait
4450Sstevel@tonic-gate  *				USB_TIMEDWAIT_SIG:	use cv_timedwait_sig
4460Sstevel@tonic-gate  *	delta_timeout	- Time in ms from current time to timeout.  Checked
4470Sstevel@tonic-gate  *			  only if USB_TIMEDWAIT or USB_TIMEDWAIT_SIG
4480Sstevel@tonic-gate  *			  specified in how_to_wait.
4490Sstevel@tonic-gate  * RETURNS:
4500Sstevel@tonic-gate  *	Same as values returned by cv_*wait* functions,
4510Sstevel@tonic-gate  *	except for when how_to_wait == USB_WAIT, where 0 is always returned.
4520Sstevel@tonic-gate  *	For calls where a timeout or signal could be expected, use this value
4530Sstevel@tonic-gate  *	to tell whether a kill(2) signal or timeout occurred.
4540Sstevel@tonic-gate  */
4550Sstevel@tonic-gate int usb_serialize_access(
4560Sstevel@tonic-gate 	usb_serialization_t	usb_serp,
4570Sstevel@tonic-gate 	uint_t			how_to_wait,
4580Sstevel@tonic-gate 	uint_t			delta_timeout);
4590Sstevel@tonic-gate 
4600Sstevel@tonic-gate /*
4610Sstevel@tonic-gate  * usb_try_serialize_access:
4620Sstevel@tonic-gate  *	try acquiring serialized access
4630Sstevel@tonic-gate  *
4640Sstevel@tonic-gate  * ARGUMENTS:
4650Sstevel@tonic-gate  *	usb_serp	- usb_serialization handle
4660Sstevel@tonic-gate  *	flag		- unused
4670Sstevel@tonic-gate  *
4680Sstevel@tonic-gate  * RETURNS:
4690Sstevel@tonic-gate  *	USB_SUCCESS	- access has been acquired
4700Sstevel@tonic-gate  *	USB_FAILURE	- access has not been acquired
4710Sstevel@tonic-gate  */
4720Sstevel@tonic-gate int usb_try_serialize_access(usb_serialization_t usb_serp, uint_t flag);
4730Sstevel@tonic-gate 
4740Sstevel@tonic-gate /*
4750Sstevel@tonic-gate  * usb_release_access:
4760Sstevel@tonic-gate  *	release serialized access
4770Sstevel@tonic-gate  *
4780Sstevel@tonic-gate  * ARGUMENTS:
4790Sstevel@tonic-gate  *	usb_serp	- usb_serialization handle
4800Sstevel@tonic-gate  */
4810Sstevel@tonic-gate void usb_release_access(usb_serialization_t usb_serp);
4820Sstevel@tonic-gate 
4830Sstevel@tonic-gate 
4840Sstevel@tonic-gate /*
4850Sstevel@tonic-gate  * **************************************************************************
4860Sstevel@tonic-gate  * Asynchronous functions remaining Contracted Consolidation Private
4870Sstevel@tonic-gate  * **************************************************************************
4880Sstevel@tonic-gate  */
4890Sstevel@tonic-gate 
4900Sstevel@tonic-gate /* This whole section: status: C and D. */
4910Sstevel@tonic-gate 
4920Sstevel@tonic-gate /* For async_req functions. */
4930Sstevel@tonic-gate #define	USB_FLAGS_NOQUEUE	0x200
4940Sstevel@tonic-gate 
4950Sstevel@tonic-gate /*
4960Sstevel@tonic-gate  * Issue a request to the asynchronous request service
4970Sstevel@tonic-gate  * All async request functions return USB_SUCCESS or USB_FAILURE
4980Sstevel@tonic-gate  * Arguments:
4990Sstevel@tonic-gate  *	dip		- pointer to devinfo node
5000Sstevel@tonic-gate  *	func		- pointer of function to execute asynchronously
5010Sstevel@tonic-gate  *	arg		- argument to function
5020Sstevel@tonic-gate  *	flag		- USB_FLAGS_SLEEP or USB_FLAGS_NOSLEEP or
5030Sstevel@tonic-gate  *			  USB_FLAGS_NOQUEUE
5040Sstevel@tonic-gate  * Return Values:
5050Sstevel@tonic-gate  *	USB_SUCCESS	- function was scheduled
5060Sstevel@tonic-gate  *	USB_FAILURE	- function could not be scheduled
5070Sstevel@tonic-gate  *
5080Sstevel@tonic-gate  * Flag combinations:
5090Sstevel@tonic-gate  *	SLEEP		- block waiting for resources. always succeeds
5100Sstevel@tonic-gate  *	NOSLEEP		- do not wait for resources, may fail.
5110Sstevel@tonic-gate  *	NOSLEEP+NOQUEUE - do not wait for resources, do not queue
5120Sstevel@tonic-gate  *	SLEEP+NOQUEUE	- block waiting for resources but may still fail
5130Sstevel@tonic-gate  *			  if no thread available
5140Sstevel@tonic-gate  */
5150Sstevel@tonic-gate int usb_async_req(
5160Sstevel@tonic-gate 	dev_info_t	*dip,
5170Sstevel@tonic-gate 	void		(*func)(void *),
5180Sstevel@tonic-gate 	void		*arg,
5190Sstevel@tonic-gate 	usb_flags_t	flag);
5200Sstevel@tonic-gate 
5210Sstevel@tonic-gate 
5220Sstevel@tonic-gate /*
5230Sstevel@tonic-gate  * index for getting to usb_pipehandle_list in usba_device
5240Sstevel@tonic-gate  */
5250Sstevel@tonic-gate uchar_t usb_get_ep_index(uint8_t ep_addr);
5260Sstevel@tonic-gate 
5270Sstevel@tonic-gate 
5280Sstevel@tonic-gate #ifdef ALLOCB_TEST
5290Sstevel@tonic-gate #define	allocb(s, p) usba_test_allocb(s, p)
5300Sstevel@tonic-gate mblk_t *usba_test_allocb(size_t, uint_t);
5310Sstevel@tonic-gate #endif /* ALLOCB_TEST */
5320Sstevel@tonic-gate 
5330Sstevel@tonic-gate /* create an USB style M_CTL message */
5340Sstevel@tonic-gate mblk_t *usba_mk_mctl(struct iocblk, void *, size_t);
5350Sstevel@tonic-gate 
5360Sstevel@tonic-gate #ifdef __cplusplus
5370Sstevel@tonic-gate }
5380Sstevel@tonic-gate #endif
5390Sstevel@tonic-gate 
5400Sstevel@tonic-gate #endif	/* _SYS_USB_USBA_USBAI_PRIVATE_H */
541