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  *
21*ff0e937bSRaymond Chen  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
227c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
237c478bd9Sstevel@tonic-gate  */
247c478bd9Sstevel@tonic-gate 
257c478bd9Sstevel@tonic-gate #ifndef	_SYS_USB_USBA_USBA_TYPES_H
267c478bd9Sstevel@tonic-gate #define	_SYS_USB_USBA_USBA_TYPES_H
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #include <sys/taskq.h>
307c478bd9Sstevel@tonic-gate #include <sys/usb/usba/usba_private.h>
317c478bd9Sstevel@tonic-gate #include <sys/usb/usba/usbai_private.h>
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
347c478bd9Sstevel@tonic-gate extern "C" {
357c478bd9Sstevel@tonic-gate #endif
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate /* backup structure for opaque usb_pipe_handle_t */
387c478bd9Sstevel@tonic-gate typedef struct usba_ph_impl {
397c478bd9Sstevel@tonic-gate 	kmutex_t			usba_ph_mutex;
407c478bd9Sstevel@tonic-gate 	struct usba_pipe_handle_data	*usba_ph_data;	/* actual pipe handle */
417c478bd9Sstevel@tonic-gate 	dev_info_t			*usba_ph_dip;	/* owner dip */
427c478bd9Sstevel@tonic-gate 	usb_ep_descr_t			usba_ph_ep;	/* save ep descr */
437c478bd9Sstevel@tonic-gate 	usb_pipe_policy_t		usba_ph_policy; /* saved pipe policy */
447c478bd9Sstevel@tonic-gate 	uint_t				usba_ph_flags;
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate 	/*
477c478bd9Sstevel@tonic-gate 	 * usba_ph_ref_count is a count of the number of
487c478bd9Sstevel@tonic-gate 	 * concurrent activities on this pipe
497c478bd9Sstevel@tonic-gate 	 */
507c478bd9Sstevel@tonic-gate 	int				usba_ph_ref_count;
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate 	/* pipe state management */
537c478bd9Sstevel@tonic-gate 	usb_pipe_state_t		usba_ph_state;
547c478bd9Sstevel@tonic-gate 	int				usba_ph_state_changing;
557c478bd9Sstevel@tonic-gate } usba_ph_impl_t;
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(usba_ph_impl::usba_ph_mutex, usba_ph_impl))
587c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_ph_impl::usba_ph_data))
597c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_ph_impl::usba_ph_dip))
607c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_ph_impl::usba_ph_ep))
617c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_ph_impl::usba_ph_policy))
627c478bd9Sstevel@tonic-gate 
637c478bd9Sstevel@tonic-gate /* for usba_ph_flags */
647c478bd9Sstevel@tonic-gate #define	USBA_PH_DATA_TOGGLE		0x01	/* mask for data toggle */
657c478bd9Sstevel@tonic-gate #define	USBA_PH_DATA_PERSISTENT 	0x02	/* persistent pipe */
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate /*
697c478bd9Sstevel@tonic-gate  * usba_pipe_handle_data
707c478bd9Sstevel@tonic-gate  *	allocated by USBA and used by USBA and HCD but opaque to
717c478bd9Sstevel@tonic-gate  *	client driver
727c478bd9Sstevel@tonic-gate  *
737c478bd9Sstevel@tonic-gate  *	pipes can be shared but pipe_handles are unique
747c478bd9Sstevel@tonic-gate  *
757c478bd9Sstevel@tonic-gate  * p_hcd_private is a pointer to private data for HCD. This space
767c478bd9Sstevel@tonic-gate  * is allocated and maintained by HCD
777c478bd9Sstevel@tonic-gate  */
787c478bd9Sstevel@tonic-gate typedef struct	usba_pipe_handle_data {
797c478bd9Sstevel@tonic-gate 	struct usba_ph_impl	*p_ph_impl;	/* backpointer to ph_impl */
807c478bd9Sstevel@tonic-gate 
817c478bd9Sstevel@tonic-gate 	/* For linking pipe requests on the pipe */
827c478bd9Sstevel@tonic-gate 	usba_list_entry_t	p_queue;
837c478bd9Sstevel@tonic-gate 
847c478bd9Sstevel@tonic-gate 	/* shared usba_device structure */
857c478bd9Sstevel@tonic-gate 	struct usba_device	*p_usba_device;	/* set on pipe open */
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate 	/* pipe policy and endpoint descriptor for this pipe */
887c478bd9Sstevel@tonic-gate 	usb_pipe_policy_t	p_policy;	/* maintained by USBA */
897c478bd9Sstevel@tonic-gate 	usb_ep_descr_t		p_ep;
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate 	/* passed during open. needed for reset etc. */
927c478bd9Sstevel@tonic-gate 	dev_info_t		*p_dip;
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate 	/* access control */
957c478bd9Sstevel@tonic-gate 	kmutex_t		p_mutex;   /* mutex protecting pipe handle */
967c478bd9Sstevel@tonic-gate 
977c478bd9Sstevel@tonic-gate 	/* per-pipe private data for HCD */
987c478bd9Sstevel@tonic-gate 	usb_opaque_t		p_hcd_private;
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate 	/* per-pipe private data for client */
1017c478bd9Sstevel@tonic-gate 	usb_opaque_t		p_client_private;
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate 	/*
1047c478bd9Sstevel@tonic-gate 	 * p_req_count is the count of number requests active
1057c478bd9Sstevel@tonic-gate 	 * on this pipe
1067c478bd9Sstevel@tonic-gate 	 */
1077c478bd9Sstevel@tonic-gate 	int			p_req_count;
1087c478bd9Sstevel@tonic-gate 
1097c478bd9Sstevel@tonic-gate 	/* private use by USBA */
1107c478bd9Sstevel@tonic-gate 	usb_opaque_t		p_usba_private;
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate 	/*
1137c478bd9Sstevel@tonic-gate 	 * each pipe handle has its own taskq for callbacks and async reqs
1147c478bd9Sstevel@tonic-gate 	 * Note that this will not be used for normal callbacks if
1157c478bd9Sstevel@tonic-gate 	 * USB_FLAGS_SERIALIZED_CB is passed to usb_pipe_open().
1167c478bd9Sstevel@tonic-gate 	 */
1177c478bd9Sstevel@tonic-gate 	taskq_t			*p_taskq;
1187c478bd9Sstevel@tonic-gate 
1197c478bd9Sstevel@tonic-gate 	/* thread currently serving the queue */
1207c478bd9Sstevel@tonic-gate 	kthread_t		*p_thread_id;
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate 	/* cb queue serviced by taskq thread */
1237c478bd9Sstevel@tonic-gate 	usba_list_entry_t	p_cb_queue;
1247c478bd9Sstevel@tonic-gate 
1257c478bd9Sstevel@tonic-gate 	/* count for soft interrupts */
1267c478bd9Sstevel@tonic-gate 	uint_t			p_soft_intr;
1277c478bd9Sstevel@tonic-gate 
1287c478bd9Sstevel@tonic-gate 	/* flag for special things */
1297c478bd9Sstevel@tonic-gate 	uint_t			p_spec_flag;
1307c478bd9Sstevel@tonic-gate 
1317c478bd9Sstevel@tonic-gate } usba_pipe_handle_data_t;
1327c478bd9Sstevel@tonic-gate 
1337c478bd9Sstevel@tonic-gate #define	USBA_PH_FLAG_USE_SOFT_INTR	0x1
1347c478bd9Sstevel@tonic-gate #define	USBA_PH_FLAG_TQ_SHARE		0x2	/* Shared TaskQ for callbacks */
1357c478bd9Sstevel@tonic-gate 
1367c478bd9Sstevel@tonic-gate 
1377c478bd9Sstevel@tonic-gate 
1387c478bd9Sstevel@tonic-gate /* macro to get the endpoint descriptor */
1397c478bd9Sstevel@tonic-gate #define	USBA_DEFAULT_PIPE_EP	0	/* ep 0 is default pipe */
1407c478bd9Sstevel@tonic-gate #define	USBA_PH2ENDPOINT(ph)  (((usba_pipe_handle_data_t *)(ph))->p_ep)
1417c478bd9Sstevel@tonic-gate 
1427c478bd9Sstevel@tonic-gate #define	USBA_PIPE_CLOSING(state) \
1437c478bd9Sstevel@tonic-gate 		(((state) == USB_PIPE_STATE_CLOSING) || \
1447c478bd9Sstevel@tonic-gate 		((state) == USB_PIPE_STATE_CLOSED))
1457c478bd9Sstevel@tonic-gate 
1467c478bd9Sstevel@tonic-gate #define	USBA_IS_DEFAULT_PIPE(ph)  ((ph) == \
1477c478bd9Sstevel@tonic-gate 	(ph)->p_usba_device->usb_ph_list[USBA_DEFAULT_PIPE_EP].usba_ph_data)
1487c478bd9Sstevel@tonic-gate 
1497c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(usba_pipe_handle_data::p_mutex, \
1507c478bd9Sstevel@tonic-gate 	usba_pipe_handle_data))
1517c478bd9Sstevel@tonic-gate 
1527c478bd9Sstevel@tonic-gate /* these should be really stable data */
1537c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_pipe_handle_data::p_ph_impl))
1547c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_pipe_handle_data::p_usba_device))
1557c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_pipe_handle_data::p_hcd_private))
1567c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_pipe_handle_data::p_client_private))
1577c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_pipe_handle_data::p_ep))
1587c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_pipe_handle_data::p_dip))
1597c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_pipe_handle_data::p_taskq))
1607c478bd9Sstevel@tonic-gate 
1617c478bd9Sstevel@tonic-gate 
1627c478bd9Sstevel@tonic-gate /*
1637c478bd9Sstevel@tonic-gate  * usb_addr:
1647c478bd9Sstevel@tonic-gate  *	This is	the USB	address	of a device
1657c478bd9Sstevel@tonic-gate  */
1667c478bd9Sstevel@tonic-gate typedef	uchar_t usb_addr_t;
1677c478bd9Sstevel@tonic-gate 
1687c478bd9Sstevel@tonic-gate #define	USBA_DEFAULT_ADDR	0
1697c478bd9Sstevel@tonic-gate 
1707c478bd9Sstevel@tonic-gate /*
1717c478bd9Sstevel@tonic-gate  * number of endpoint per device, 16 IN and 16 OUT.
1727c478bd9Sstevel@tonic-gate  * this define is used for pipehandle list, pipe reserved list
1737c478bd9Sstevel@tonic-gate  * and pipe open count array.
1747c478bd9Sstevel@tonic-gate  * these lists are indexed by endpoint number * ((address & direction)? 2 : 1)
1757c478bd9Sstevel@tonic-gate  *
1767c478bd9Sstevel@tonic-gate  * We use a bit mask for exclusive open tracking and therefore
1777c478bd9Sstevel@tonic-gate  * USB_N_ENDPOINTS must be equal to the bit size of int.
1787c478bd9Sstevel@tonic-gate  *
1797c478bd9Sstevel@tonic-gate  */
1807c478bd9Sstevel@tonic-gate #define	USBA_N_ENDPOINTS		32
1817c478bd9Sstevel@tonic-gate 
1827c478bd9Sstevel@tonic-gate /*
1837c478bd9Sstevel@tonic-gate  * USB spec defines 4 different power states of any usb device.
1847c478bd9Sstevel@tonic-gate  * They are D0, D1, D2 & D3. So, we need a total of 5 pm-components
1857c478bd9Sstevel@tonic-gate  * 4 for power and 1 for name.
1867c478bd9Sstevel@tonic-gate  */
1877c478bd9Sstevel@tonic-gate #define	USBA_N_PMCOMP		5
1887c478bd9Sstevel@tonic-gate 
1897c478bd9Sstevel@tonic-gate /*
1907c478bd9Sstevel@tonic-gate  * usb port status
1917c478bd9Sstevel@tonic-gate  */
1927c478bd9Sstevel@tonic-gate typedef uint8_t usb_port_status_t;
1937c478bd9Sstevel@tonic-gate typedef uint16_t usb_port_t;
1947c478bd9Sstevel@tonic-gate typedef uint32_t usb_port_mask_t;
1957c478bd9Sstevel@tonic-gate 
1967c478bd9Sstevel@tonic-gate #define	USBA_LOW_SPEED_DEV	0x1
1977c478bd9Sstevel@tonic-gate #define	USBA_FULL_SPEED_DEV	0x2
1987c478bd9Sstevel@tonic-gate #define	USBA_HIGH_SPEED_DEV	0x3
1997c478bd9Sstevel@tonic-gate 
2007c478bd9Sstevel@tonic-gate /*
2017c478bd9Sstevel@tonic-gate  * NDI event is registered on a per-dip basis. usba_device can be
2027c478bd9Sstevel@tonic-gate  * shared by multiple dips, hence the following structure is
2037c478bd9Sstevel@tonic-gate  * need to keep per-dip event info.
2047c478bd9Sstevel@tonic-gate  */
2057c478bd9Sstevel@tonic-gate typedef struct usba_evdata {
2067c478bd9Sstevel@tonic-gate 	struct usba_evdata	*ev_next;
2077c478bd9Sstevel@tonic-gate 	dev_info_t		*ev_dip;
2087c478bd9Sstevel@tonic-gate 
2097c478bd9Sstevel@tonic-gate 	/* NDI evetn service callback ids */
2107c478bd9Sstevel@tonic-gate 	ddi_callback_id_t	ev_rm_cb_id;
2117c478bd9Sstevel@tonic-gate 	ddi_callback_id_t	ev_ins_cb_id;
2127c478bd9Sstevel@tonic-gate 	ddi_callback_id_t	ev_suspend_cb_id;
2137c478bd9Sstevel@tonic-gate 	ddi_callback_id_t	ev_resume_cb_id;
2147c478bd9Sstevel@tonic-gate } usba_evdata_t;
2157c478bd9Sstevel@tonic-gate 
2167c478bd9Sstevel@tonic-gate /*
2177c478bd9Sstevel@tonic-gate  * a client may request dev_data multiple times (eg. for
2187c478bd9Sstevel@tonic-gate  * ugen support) so we need a linked list
2197c478bd9Sstevel@tonic-gate  */
2207c478bd9Sstevel@tonic-gate typedef struct usb_client_dev_data_list {
2217c478bd9Sstevel@tonic-gate 	struct usb_client_dev_data_list *cddl_next;
2227c478bd9Sstevel@tonic-gate 	struct usb_client_dev_data_list *cddl_prev;
2237c478bd9Sstevel@tonic-gate 	dev_info_t			*cddl_dip;
2247c478bd9Sstevel@tonic-gate 	usb_client_dev_data_t		*cddl_dev_data;
2257c478bd9Sstevel@tonic-gate 	uint_t				cddl_ifno;
2267c478bd9Sstevel@tonic-gate } usb_client_dev_data_list_t;
2277c478bd9Sstevel@tonic-gate 
228*ff0e937bSRaymond Chen /*
229*ff0e937bSRaymond Chen  * wireless usb specific data
230*ff0e937bSRaymond Chen  */
231*ff0e937bSRaymond Chen typedef struct usba_wireless_data {
232*ff0e937bSRaymond Chen 	uint8_t			*wusb_bos;	/* raw bos descr */
233*ff0e937bSRaymond Chen 	uint_t			wusb_bos_length; /* length of bos descr */
234*ff0e937bSRaymond Chen 	usb_uwb_cap_descr_t	*uwb_descr;	/* UWB capability descr */
235*ff0e937bSRaymond Chen } usba_wireless_data_t;
236*ff0e937bSRaymond Chen 
2377c478bd9Sstevel@tonic-gate /*
2387c478bd9Sstevel@tonic-gate  * This	structure uniquely identifies a USB device
2397c478bd9Sstevel@tonic-gate  * with all interfaces,	or just one interface of a USB device.
2407c478bd9Sstevel@tonic-gate  * usba_device is associated with a devinfo node
2417c478bd9Sstevel@tonic-gate  *
2427c478bd9Sstevel@tonic-gate  * This	structure is allocated and maintained by USBA and
2437c478bd9Sstevel@tonic-gate  * read-only for HCD
2447c478bd9Sstevel@tonic-gate  *
2457c478bd9Sstevel@tonic-gate  * There can be	multiple clients per device (multi-class
2467c478bd9Sstevel@tonic-gate  * device) in which case this structure is shared.
2477c478bd9Sstevel@tonic-gate  */
2487c478bd9Sstevel@tonic-gate typedef struct usba_device {
2497c478bd9Sstevel@tonic-gate 	/* for linking all usba_devices on this bus */
2507c478bd9Sstevel@tonic-gate 	usba_list_entry_t	usb_device_list;
2517c478bd9Sstevel@tonic-gate 
2527c478bd9Sstevel@tonic-gate 	/* linked list of all pipe handles on this device per endpoint */
2537c478bd9Sstevel@tonic-gate 	struct usba_ph_impl	usb_ph_list[USBA_N_ENDPOINTS];
2547c478bd9Sstevel@tonic-gate 
2557c478bd9Sstevel@tonic-gate 	kmutex_t		usb_mutex;   /* protecting usba_device */
2567c478bd9Sstevel@tonic-gate 
2577c478bd9Sstevel@tonic-gate 	dev_info_t		*usb_dip;
2587c478bd9Sstevel@tonic-gate 
2597c478bd9Sstevel@tonic-gate 	struct usba_hcdi_ops	*usb_hcdi_ops;	/* ptr to HCD ops */
2607c478bd9Sstevel@tonic-gate 
2617c478bd9Sstevel@tonic-gate 	struct usba_hubdi	*usb_hubdi;
2627c478bd9Sstevel@tonic-gate 
2637c478bd9Sstevel@tonic-gate 	usb_addr_t		usb_addr;	/* usb address */
2647c478bd9Sstevel@tonic-gate 
2657c478bd9Sstevel@tonic-gate 	uchar_t			usb_no_cpr;	/* CPR? */
2667c478bd9Sstevel@tonic-gate 
2677c478bd9Sstevel@tonic-gate 	dev_info_t		*usb_root_hub_dip;
268*ff0e937bSRaymond Chen 	struct hubd		*usb_root_hubd;	/* for HC or WA */
2697c478bd9Sstevel@tonic-gate 
2707c478bd9Sstevel@tonic-gate 	usb_dev_descr_t		*usb_dev_descr;	/* device descriptor */
2717c478bd9Sstevel@tonic-gate 
2727c478bd9Sstevel@tonic-gate 	uchar_t			*usb_cfg;	/* raw config descriptor */
2737c478bd9Sstevel@tonic-gate 	size_t			usb_cfg_length; /* length of raw descr */
2747c478bd9Sstevel@tonic-gate 
2757c478bd9Sstevel@tonic-gate 	char			*usb_mfg_str;	/* manufacturer string */
2767c478bd9Sstevel@tonic-gate 	char			*usb_product_str;	/* product string */
2777c478bd9Sstevel@tonic-gate 	char			*usb_serialno_str; /* serial number string */
2787c478bd9Sstevel@tonic-gate 	char			*usb_preferred_driver; /* user's choice */
2797c478bd9Sstevel@tonic-gate 
2807c478bd9Sstevel@tonic-gate 	usb_port_status_t	usb_port_status; /* usb hub port status */
2817c478bd9Sstevel@tonic-gate 	usb_port_t		usb_port;
2827c478bd9Sstevel@tonic-gate 
2837c478bd9Sstevel@tonic-gate 	/* To support split transactions */
2847c478bd9Sstevel@tonic-gate 	struct usba_device	*usb_hs_hub_usba_dev; /* HS hub usba device */
2857c478bd9Sstevel@tonic-gate 	usb_addr_t		usb_hs_hub_addr; /* High speed hub address */
2867c478bd9Sstevel@tonic-gate 	usb_port_t		usb_hs_hub_port; /* High speed hub port */
2877c478bd9Sstevel@tonic-gate 
2887c478bd9Sstevel@tonic-gate 	/* For high speed hub bandwidth allocation scheme */
2897c478bd9Sstevel@tonic-gate 	uint_t			usb_hs_hub_min_bandwidth;
2907c478bd9Sstevel@tonic-gate 	uint_t			usb_hs_hub_bandwidth[32];
2917c478bd9Sstevel@tonic-gate 
2927c478bd9Sstevel@tonic-gate 	/* store all config cloud here */
2937c478bd9Sstevel@tonic-gate 	uchar_t			**usb_cfg_array;
2947c478bd9Sstevel@tonic-gate 	uint_t			usb_cfg_array_length;
2957c478bd9Sstevel@tonic-gate 
2967c478bd9Sstevel@tonic-gate 	uint16_t		*usb_cfg_array_len;
2977c478bd9Sstevel@tonic-gate 	uint_t			usb_cfg_array_len_length;
2987c478bd9Sstevel@tonic-gate 
2997c478bd9Sstevel@tonic-gate 	uint_t			usb_cfg_value;
3007c478bd9Sstevel@tonic-gate 	uint_t			usb_active_cfg_ndx;
3017c478bd9Sstevel@tonic-gate 	char			**usb_cfg_str_descr;
3027c478bd9Sstevel@tonic-gate 	uchar_t			usb_n_cfgs;
3037c478bd9Sstevel@tonic-gate 	uchar_t			usb_n_ifs;
3047c478bd9Sstevel@tonic-gate 
305*ff0e937bSRaymond Chen 	/* To support WUSB */
306*ff0e937bSRaymond Chen 	boolean_t		usb_is_wa;
307*ff0e937bSRaymond Chen 	boolean_t		usb_is_wireless;
308*ff0e937bSRaymond Chen 	usba_wireless_data_t	*usb_wireless_data;
309*ff0e937bSRaymond Chen 
31035f36846Ssl 	/*
31135f36846Ssl 	 * power drawn from hub, if > 0, the power has been
31235f36846Ssl 	 * subtracted from the parent hub's power budget
31335f36846Ssl 	 */
31435f36846Ssl 	uint16_t		usb_pwr_from_hub;
31535f36846Ssl 
3167c478bd9Sstevel@tonic-gate 	/* ref count, if > 0, this structure is in use */
3177c478bd9Sstevel@tonic-gate 	int			usb_ref_count;
3187c478bd9Sstevel@tonic-gate 
3197c478bd9Sstevel@tonic-gate 	/* list of requests allocated for this device, detects leaks */
3207c478bd9Sstevel@tonic-gate 	usba_list_entry_t	usb_allocated;		/* alloc'ed reqs list */
3217c478bd9Sstevel@tonic-gate 
3227c478bd9Sstevel@tonic-gate 	/* NDI event service cookies */
3237c478bd9Sstevel@tonic-gate 	ddi_eventcookie_t	rm_cookie;
3247c478bd9Sstevel@tonic-gate 	ddi_eventcookie_t	ins_cookie;
3257c478bd9Sstevel@tonic-gate 	ddi_eventcookie_t	suspend_cookie;
3267c478bd9Sstevel@tonic-gate 	ddi_eventcookie_t	resume_cookie;
3277c478bd9Sstevel@tonic-gate 
3287c478bd9Sstevel@tonic-gate 	/* linked list of callid (per-devinfo) */
3297c478bd9Sstevel@tonic-gate 	usba_evdata_t		*usb_evdata;
3307c478bd9Sstevel@tonic-gate 
3317c478bd9Sstevel@tonic-gate 	/* client cleanup checks */
3327c478bd9Sstevel@tonic-gate 	uchar_t			*usb_client_flags;
3337c478bd9Sstevel@tonic-gate 
3347c478bd9Sstevel@tonic-gate 	struct {
3357c478bd9Sstevel@tonic-gate 		dev_info_t *dip;
3367c478bd9Sstevel@tonic-gate 	}			*usb_client_attach_list;
3377c478bd9Sstevel@tonic-gate 
3387c478bd9Sstevel@tonic-gate 	usb_client_dev_data_list_t usb_client_dev_data_list;
3397c478bd9Sstevel@tonic-gate 
3407c478bd9Sstevel@tonic-gate 	struct {
3417c478bd9Sstevel@tonic-gate 		dev_info_t *dip;
3427c478bd9Sstevel@tonic-gate 		usb_event_t *ev_data;
3437c478bd9Sstevel@tonic-gate 	}			*usb_client_ev_cb_list;
3447c478bd9Sstevel@tonic-gate 
3457c478bd9Sstevel@tonic-gate 	/* Shared task queue implementation. */
3467c478bd9Sstevel@tonic-gate 	taskq_t			*usb_shared_taskq[USBA_N_ENDPOINTS];
3477c478bd9Sstevel@tonic-gate 	uchar_t			usb_shared_taskq_ref_count
3487c478bd9Sstevel@tonic-gate 						[USBA_N_ENDPOINTS];
3497c478bd9Sstevel@tonic-gate } usba_device_t;
3507c478bd9Sstevel@tonic-gate 
3517c478bd9Sstevel@tonic-gate #define	USBA_CLIENT_FLAG_SIZE		1
3527c478bd9Sstevel@tonic-gate #define	USBA_CLIENT_FLAG_ATTACH		0x01
3537c478bd9Sstevel@tonic-gate #define	USBA_CLIENT_FLAG_EV_CBS		0x02
3547c478bd9Sstevel@tonic-gate #define	USBA_CLIENT_FLAG_DEV_DATA	0x04
3557c478bd9Sstevel@tonic-gate 
3567c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(usba_device::usb_mutex, usba_device))
3577c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(usba_device::usb_mutex, usba_evdata))
3587c478bd9Sstevel@tonic-gate 
3597c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
3607c478bd9Sstevel@tonic-gate 				usba_evdata::ev_rm_cb_id))
3617c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
3627c478bd9Sstevel@tonic-gate 				usba_evdata::ev_ins_cb_id))
3637c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
3647c478bd9Sstevel@tonic-gate 				usba_evdata::ev_suspend_cb_id))
3657c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
3667c478bd9Sstevel@tonic-gate 				usba_evdata::ev_resume_cb_id))
3677c478bd9Sstevel@tonic-gate 
3687c478bd9Sstevel@tonic-gate /* this should be really stable data */
3697c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_serialno_str))
3707c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_root_hub_dip))
3717c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_root_hubd))
3727c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_product_str))
3737c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_preferred_driver))
3747c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_port))
3757c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_n_ifs))
3767c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_n_cfgs))
3777c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_mfg_str))
3787c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_dev_descr))
3797c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_ph_list))
3807c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_cfg_value))
3817c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_cfg_str_descr))
3827c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_cfg_length))
3837c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_cfg_array))
3847c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_cfg_array_len))
3857c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_cfg_array_length))
3867c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_cfg_array_len_length))
3877c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_cfg))
3887c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_hcdi_ops))
3897c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_addr))
3907c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_port_status))
3917c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::rm_cookie))
3927c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::ins_cookie))
3937c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::suspend_cookie))
3947c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::resume_cookie))
3957c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_client_flags))
3967c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_client_attach_list))
3977c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_client_ev_cb_list))
3987c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_dip))
399*ff0e937bSRaymond Chen _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_is_wireless))
400*ff0e937bSRaymond Chen _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_wireless_data))
4017c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("set at device creation",
4027c478bd9Sstevel@tonic-gate 					usba_device::usb_shared_taskq))
4037c478bd9Sstevel@tonic-gate 
4047c478bd9Sstevel@tonic-gate /*
4057c478bd9Sstevel@tonic-gate  * serialization in drivers
4067c478bd9Sstevel@tonic-gate  */
4077c478bd9Sstevel@tonic-gate typedef struct usba_serialization_impl {
4087c478bd9Sstevel@tonic-gate 	dev_info_t	*s_dip;
4097c478bd9Sstevel@tonic-gate 	kcondvar_t	s_cv;
4107c478bd9Sstevel@tonic-gate 	kmutex_t	s_mutex;
4117c478bd9Sstevel@tonic-gate 	kthread_t	*s_thread;
4127c478bd9Sstevel@tonic-gate 	int		s_count;
4137c478bd9Sstevel@tonic-gate 	uint_t		s_flag;
4147c478bd9Sstevel@tonic-gate } usba_serialization_impl_t;
4157c478bd9Sstevel@tonic-gate 
4167c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("unshared private data",
4177c478bd9Sstevel@tonic-gate 				usba_serialization_impl))
4187c478bd9Sstevel@tonic-gate 
4197c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
4207c478bd9Sstevel@tonic-gate }
4217c478bd9Sstevel@tonic-gate #endif
4227c478bd9Sstevel@tonic-gate 
4237c478bd9Sstevel@tonic-gate #endif	/* _SYS_USB_USBA_USBA_TYPES_H */
424