xref: /illumos-gate/usr/src/uts/common/sys/usb/clients/usbskel/usbskel.h (revision d29f5a711240f866521445b1656d114da090335e)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SYS_USB_USBSKEL_H
27 #define	_SYS_USB_USBSKEL_H
28 
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 
35 /*
36  * Power Management support
37  */
38 typedef struct usbskel_power  {
39 
40 	void		*usbskel_state;	/* points back to usbskel_state */
41 	uint8_t		usbskel_pwr_states; /* bit mask of device pwr states */
42 	int		usbskel_pm_busy;
43 
44 	/* wakeup and power transistion capabilites of an interface */
45 	uint8_t		usbskel_pm_capabilities;
46 
47 	/* flag to indicate if driver is about to raise power level */
48 	boolean_t	usbskel_raise_power;
49 
50 	uint8_t		usbskel_current_power;
51 } usbskel_power_t;
52 
53 
54 /*
55  * State structure
56  */
57 typedef struct usbskel_state {
58 	dev_info_t		*usbskel_dip;	/* per-device info handle */
59 	usb_client_dev_data_t	*usbskel_reg;	/* registration data */
60 	usb_ep_descr_t		usbskel_intr_ep_descr;	/* Intr ep descr */
61 	usb_pipe_handle_t	usbskel_intr_ph;	/* Intr pipe handle.  */
62 	char			*usbskel_devinst;	/* Dev and instance */
63 	int			usbskel_dev_state; /* USB device states. */
64 	int			usbskel_drv_state; /* driver states. */
65 	kmutex_t		usbskel_mutex;
66 	kcondvar_t		usbskel_serial_cv;
67 	boolean_t		usbskel_serial_inuse;
68 	boolean_t		usbskel_locks_initialized;
69 	usbskel_power_t		*usbskel_pm;
70 } usbskel_state_t;
71 
72 
73 /* Macros */
74 #define	USBSKEL_OPEN		0x00000001
75 
76 #define	USBSKEL_REQUEST_SIZE	65535	/* Read request size maximum */
77 #define	USB_DEV_DESCR_SIZE	18	/* device descr size */
78 
79 /* Other */
80 #define	USBSKEL_DRAIN_TMO	15
81 
82 /* For serialization. */
83 #define	USBSKEL_SER_NOSIG	B_FALSE
84 #define	USBSKEL_SER_SIG		B_TRUE
85 
86 /* For logging. */
87 #define	USBSKEL_LOG_LOG		1
88 #define	USBSKEL_LOG_CONSOLE	0
89 
90 #ifdef __cplusplus
91 }
92 #endif
93 
94 #endif	/* _SYS_USB_USBSKEL_H */
95