xref: /onnv-gate/usr/src/uts/common/sys/usb/hubd/hubdvar.h (revision 9797:4b03a6b797a8)
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
52651Ssl147100  * Common Development and Distribution License (the "License").
62651Ssl147100  * 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 /*
229430SRaymond.Chen@Sun.COM  * Copyright 2009 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_HUBDVAR_H
270Sstevel@tonic-gate #define	_SYS_USB_HUBDVAR_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #ifdef	__cplusplus
310Sstevel@tonic-gate extern "C" {
320Sstevel@tonic-gate #endif
330Sstevel@tonic-gate 
340Sstevel@tonic-gate #include <sys/sunndi.h>
350Sstevel@tonic-gate #include <sys/ndi_impldefs.h>
360Sstevel@tonic-gate #include <sys/usb/usba/usba_types.h>
370Sstevel@tonic-gate #include <sys/callb.h>
380Sstevel@tonic-gate 
390Sstevel@tonic-gate /*
400Sstevel@tonic-gate  * HUB USB device state management :
410Sstevel@tonic-gate  *
420Sstevel@tonic-gate  *                          CHILD PWRLVL---1>--------+
430Sstevel@tonic-gate  *                               ^                   |
440Sstevel@tonic-gate  *                               8                   |
450Sstevel@tonic-gate  *                               |                   |
460Sstevel@tonic-gate  *                               9                   |
470Sstevel@tonic-gate  *                               v                   |
480Sstevel@tonic-gate  *	PWRED_DWN---<3----4>--ONLINE---<2-----1>-DISCONNECTED
490Sstevel@tonic-gate  *          |                  |  ^                |  |
500Sstevel@tonic-gate  *          |                  |  10               |  |
510Sstevel@tonic-gate  *          |                  |  |                |  |
520Sstevel@tonic-gate  *          |                  |  RECOVER-<2-------+  |
530Sstevel@tonic-gate  *          |                  |  ^                   |
540Sstevel@tonic-gate  *          |                  5  6                   |
550Sstevel@tonic-gate  *          |                  |  |                   |
560Sstevel@tonic-gate  *          |                  v  |                   |
570Sstevel@tonic-gate  *          +----5>----------SUSPENDED----<5----7>----+
580Sstevel@tonic-gate  *
590Sstevel@tonic-gate  *	1 = Device Unplug
600Sstevel@tonic-gate  *	2 = Original Device reconnected and after hub driver restores its own
610Sstevel@tonic-gate  *	    device state.
620Sstevel@tonic-gate  *	3 = Device idles for time T & transitions to low power state
630Sstevel@tonic-gate  *	4 = Remote wakeup by device OR Application kicking off IO to device
640Sstevel@tonic-gate  *	5 = Notification to save state prior to DDI_SUSPEND
650Sstevel@tonic-gate  *	6 = Notification to restore state after DDI_RESUME with correct device
660Sstevel@tonic-gate  *          and after hub driver restores its own device state.
670Sstevel@tonic-gate  *	7 = Notification to restore state after DDI_RESUME with device
680Sstevel@tonic-gate  *	    disconnected or a wrong device
690Sstevel@tonic-gate  *	8 = Hub detect child doing remote wakeup and request the PM
700Sstevel@tonic-gate  *	    framework to bring it to full power
710Sstevel@tonic-gate  *      9 = PM framework has compeleted call power entry point of the child
720Sstevel@tonic-gate  *	    and bus ctls of hub
730Sstevel@tonic-gate  *     10 = Restoring states of its children i.e. set addrs & config.
740Sstevel@tonic-gate  *
750Sstevel@tonic-gate  */
760Sstevel@tonic-gate 
770Sstevel@tonic-gate #define	HUBD_INITIAL_SOFT_SPACE	4
780Sstevel@tonic-gate 
790Sstevel@tonic-gate typedef struct hub_power_struct {
800Sstevel@tonic-gate 	void		*hubp_hubd;	/* points back to hubd_t */
810Sstevel@tonic-gate 
820Sstevel@tonic-gate 	uint8_t		hubp_wakeup_enabled;	/* remote wakeup enabled? */
830Sstevel@tonic-gate 
840Sstevel@tonic-gate 	/* this is the bit mask of the power states that device has */
850Sstevel@tonic-gate 	uint8_t		hubp_pwr_states;
860Sstevel@tonic-gate 
870Sstevel@tonic-gate 	int		hubp_busy_pm;	/* device busy accounting */
880Sstevel@tonic-gate 
890Sstevel@tonic-gate 	/* wakeup and power transition capabilities of an interface */
900Sstevel@tonic-gate 	uint8_t		hubp_pm_capabilities;
910Sstevel@tonic-gate 
920Sstevel@tonic-gate 	uint8_t		hubp_current_power;	/* current power level */
930Sstevel@tonic-gate 
940Sstevel@tonic-gate 	time_t		hubp_time_at_full_power;	/* timestamp 0->3 */
950Sstevel@tonic-gate 
960Sstevel@tonic-gate 	uint8_t		hubp_min_pm_threshold;		/* in seconds */
970Sstevel@tonic-gate 
980Sstevel@tonic-gate 	/* power state of all children are tracked here */
990Sstevel@tonic-gate 	uint8_t		*hubp_child_pwrstate;
1000Sstevel@tonic-gate 
1010Sstevel@tonic-gate 	/* pm-components properties are stored here */
1020Sstevel@tonic-gate 	char		*hubp_pmcomp[5];
1030Sstevel@tonic-gate 
1040Sstevel@tonic-gate 	usba_cfg_pwr_descr_t	hubp_confpwr_descr; /* config pwr descr */
1050Sstevel@tonic-gate } hub_power_t;
1060Sstevel@tonic-gate 
1070Sstevel@tonic-gate /* warlock directives, stable data */
1080Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(hub_power_t::hubp_hubd))
1090Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(hub_power_t::hubp_wakeup_enabled))
1100Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(hub_power_t::hubp_pwr_states))
1110Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(hub_power_t::hubp_time_at_full_power))
1120Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(hub_power_t::hubp_min_pm_threshold))
1130Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(hub_power_t::hubp_pm_capabilities))
1140Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(hub_power_t::hubp_pmcomp))
1150Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(hub_power_t::hubp_confpwr_descr))
1160Sstevel@tonic-gate 
1170Sstevel@tonic-gate 
1180Sstevel@tonic-gate #define	HUBD_APID_NAMELEN	32		/* max len in cfgadm display */
1190Sstevel@tonic-gate 
1200Sstevel@tonic-gate /*
1210Sstevel@tonic-gate  * hubd cpr data structure used for callback before kernel threads are
1220Sstevel@tonic-gate  * suspended
1230Sstevel@tonic-gate  */
1240Sstevel@tonic-gate typedef struct hubd_cpr {
1250Sstevel@tonic-gate 	callb_cpr_t		cpr;		/* for cpr related info */
1260Sstevel@tonic-gate 	struct hubd		*statep;	/* ohci soft state struct */
1270Sstevel@tonic-gate 	kmutex_t		lockp;
1280Sstevel@tonic-gate } hubd_cpr_t;
1290Sstevel@tonic-gate 
1300Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(hubd_cpr_t::cpr))
1310Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(hubd_cpr_t::statep))
1320Sstevel@tonic-gate 
1330Sstevel@tonic-gate 
1340Sstevel@tonic-gate /*
1350Sstevel@tonic-gate  * soft	state information for this hubd
1360Sstevel@tonic-gate  */
1370Sstevel@tonic-gate typedef struct hubd {
1380Sstevel@tonic-gate 	int			h_instance;
1390Sstevel@tonic-gate 	uint_t			h_init_state;
1400Sstevel@tonic-gate 	uint_t			h_dev_state;
1410Sstevel@tonic-gate 	int8_t			h_bus_ctls;
1420Sstevel@tonic-gate 	int8_t			h_bus_pwr;
1430Sstevel@tonic-gate 	hub_power_t		*h_hubpm; /* pointer to power struct */
1440Sstevel@tonic-gate 	dev_info_t		*h_dip;
1450Sstevel@tonic-gate 
1460Sstevel@tonic-gate 	/*
1470Sstevel@tonic-gate 	 * mutex to protect softstate and hw regs
1480Sstevel@tonic-gate 	 */
1490Sstevel@tonic-gate 	kmutex_t		h_mutex;
1500Sstevel@tonic-gate 
1510Sstevel@tonic-gate 	/*
1520Sstevel@tonic-gate 	 * save the usba_device pointer
1530Sstevel@tonic-gate 	 */
1540Sstevel@tonic-gate 	usba_device_t		*h_usba_device;
1550Sstevel@tonic-gate 
1560Sstevel@tonic-gate 	int			h_softstate;
1570Sstevel@tonic-gate 
1580Sstevel@tonic-gate 	/*
1590Sstevel@tonic-gate 	 * default pipe handle
1600Sstevel@tonic-gate 	 */
1610Sstevel@tonic-gate 	usb_pipe_handle_t	h_default_pipe;
1620Sstevel@tonic-gate 
1630Sstevel@tonic-gate 	/*
1640Sstevel@tonic-gate 	 * pipe handle for ep1
1650Sstevel@tonic-gate 	 */
1660Sstevel@tonic-gate 	usb_pipe_handle_t	h_ep1_ph;
1670Sstevel@tonic-gate 	usb_ep_descr_t		h_ep1_descr;
1680Sstevel@tonic-gate 	usb_pipe_policy_t	h_pipe_policy;
1690Sstevel@tonic-gate 	uint_t			h_intr_pipe_state;
1700Sstevel@tonic-gate 
1710Sstevel@tonic-gate 	/*
1720Sstevel@tonic-gate 	 * root hub descriptor
1730Sstevel@tonic-gate 	 */
1740Sstevel@tonic-gate 	struct usb_hub_descr	h_hub_descr;
1750Sstevel@tonic-gate 
1760Sstevel@tonic-gate 	/*
1770Sstevel@tonic-gate 	 * hotplug handling
1780Sstevel@tonic-gate 	 */
1790Sstevel@tonic-gate 	uint_t			h_hotplug_thread;
1800Sstevel@tonic-gate 
1810Sstevel@tonic-gate 	/*
1820Sstevel@tonic-gate 	 * h_children_dips is a  array for holding
1830Sstevel@tonic-gate 	 * each child dip indexed by port
1840Sstevel@tonic-gate 	 * h_usba_devices is the corresponding usba_device
1850Sstevel@tonic-gate 	 */
1860Sstevel@tonic-gate 	dev_info_t		**h_children_dips;
1870Sstevel@tonic-gate 	size_t			h_cd_list_length;
1880Sstevel@tonic-gate 	usba_device_t		**h_usba_devices;
1890Sstevel@tonic-gate 
1900Sstevel@tonic-gate 	/* change reported by hub, limited to 31 ports */
1910Sstevel@tonic-gate 	usb_port_mask_t		h_port_change;
1920Sstevel@tonic-gate 
1930Sstevel@tonic-gate 	/* waiting for reset completion callback */
1940Sstevel@tonic-gate 	usb_port_mask_t		h_port_reset_wait;
1950Sstevel@tonic-gate 
1960Sstevel@tonic-gate 	/* track transitions of child on each port */
1970Sstevel@tonic-gate 	uint16_t		h_port_state[MAX_PORTS + 1];
1980Sstevel@tonic-gate 
1994844Slg150142 	/* track reset state of each port */
2004844Slg150142 	boolean_t		h_reset_port[MAX_PORTS + 1];
2014844Slg150142 
2020Sstevel@tonic-gate 	/* track event registration of children */
2030Sstevel@tonic-gate 	uint8_t			h_child_events[MAX_PORTS + 1];
2040Sstevel@tonic-gate 
2050Sstevel@tonic-gate 	kcondvar_t		h_cv_reset_port;
2064844Slg150142 	kcondvar_t		h_cv_hotplug_dev;
2070Sstevel@tonic-gate 	uint_t			h_intr_completion_reason;
2080Sstevel@tonic-gate 	usb_log_handle_t	h_log_handle;	/* for logging msgs */
2090Sstevel@tonic-gate 
2100Sstevel@tonic-gate 	ndi_event_hdl_t		h_ndi_event_hdl;
2110Sstevel@tonic-gate 	hubd_cpr_t		*h_cpr_cb;
2120Sstevel@tonic-gate 
2130Sstevel@tonic-gate 	/*
2140Sstevel@tonic-gate 	 * Hotplug event statistics since hub was attached
2150Sstevel@tonic-gate 	 */
2160Sstevel@tonic-gate 	ulong_t			h_total_hotplug_success;
2170Sstevel@tonic-gate 	ulong_t			h_total_hotplug_failure;
2180Sstevel@tonic-gate 
2190Sstevel@tonic-gate 	/* for minor node */
2200Sstevel@tonic-gate 	char			*h_ancestry_str;
2210Sstevel@tonic-gate 
2220Sstevel@tonic-gate 	/* registration data */
2230Sstevel@tonic-gate 	usb_client_dev_data_t	*h_dev_data;
2240Sstevel@tonic-gate 
2250Sstevel@tonic-gate 	/* for deathrow implementation */
2260Sstevel@tonic-gate 	boolean_t		h_cleanup_enabled;
2270Sstevel@tonic-gate 	boolean_t		h_cleanup_needed;
2280Sstevel@tonic-gate 	boolean_t		h_cleanup_active;
2291001Ssl147100 
2301001Ssl147100 	/*
2311001Ssl147100 	 * for power budget support
2321001Ssl147100 	 * h_pwr_limit and h_pwr_left are expressed
2331001Ssl147100 	 * in 2mA units
2341001Ssl147100 	 */
2351001Ssl147100 	boolean_t		h_local_pwr_capable;
2361001Ssl147100 	boolean_t		h_local_pwr_on;
2371001Ssl147100 	uint16_t		h_pwr_limit; /* per port pwr limit */
2381001Ssl147100 	int16_t			h_pwr_left; /* limit on the whole hub */
2391001Ssl147100 
2401001Ssl147100 	/*
2411001Ssl147100 	 * conf file override to power budget property
2421001Ssl147100 	 * if 1, power budget is disabled
2431001Ssl147100 	 */
2441001Ssl147100 	boolean_t		h_ignore_pwr_budget;
2459430SRaymond.Chen@Sun.COM 
2469430SRaymond.Chen@Sun.COM 	/* for HWA to cleanup child, NULL for normal hubs */
2479430SRaymond.Chen@Sun.COM 	int			(*h_cleanup_child)(dev_info_t *);
2480Sstevel@tonic-gate } hubd_t;
2490Sstevel@tonic-gate 
2500Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(hubd::h_mutex, hubd))
2510Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(hubd::h_mutex, hub_power_t))
2520Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(hubd::h_default_pipe
2530Sstevel@tonic-gate 		hubd::h_usba_device
2540Sstevel@tonic-gate 		hubd::h_dev_data
2550Sstevel@tonic-gate 		hubd::h_ndi_event_hdl
2560Sstevel@tonic-gate 		hubd::h_cpr_cb
2570Sstevel@tonic-gate 		hubd::h_log_handle
2580Sstevel@tonic-gate 		hubd::h_ep1_ph
2590Sstevel@tonic-gate 		hubd::h_instance
2600Sstevel@tonic-gate 		hubd::h_hubpm
2610Sstevel@tonic-gate 		hubd::h_dip
2621001Ssl147100 		hubd::h_ignore_pwr_budget
263*9797SRaymond.Chen@Sun.COM 		hubd::h_hub_descr
264*9797SRaymond.Chen@Sun.COM 		hubd::h_cleanup_child
2650Sstevel@tonic-gate ))
2660Sstevel@tonic-gate 
2670Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("stable data", usb_ep_descr))
2680Sstevel@tonic-gate 
2692651Ssl147100 /*
2702651Ssl147100  * hubd hotplug thread argument data structure
2712651Ssl147100  */
2722651Ssl147100 typedef struct hubd_hotplug_arg {
2732651Ssl147100 	hubd_t		*hubd;
2742651Ssl147100 
2752651Ssl147100 	/*
2762651Ssl147100 	 * flag to indicate if a hotplug thread is started
2772651Ssl147100 	 * during hubd attach time, if true, it means the
2782651Ssl147100 	 * connected devices need to be enumerated regardless
2792651Ssl147100 	 * of the connect status change bit
2802651Ssl147100 	 */
2812651Ssl147100 	boolean_t	hotplug_during_attach;
2822651Ssl147100 } hubd_hotplug_arg_t;
2832651Ssl147100 
2844844Slg150142 /*
2854844Slg150142  * hubd reset thread argument data structure
2864844Slg150142  */
2874844Slg150142 typedef struct hubd_reset_arg {
2884844Slg150142 	hubd_t		*hubd;
2894844Slg150142 	/* The port needs to be reset */
2904844Slg150142 	uint16_t	reset_port;
2914844Slg150142 } hubd_reset_arg_t;
2924844Slg150142 
2932651Ssl147100 _NOTE(SCHEME_PROTECTS_DATA("unshared", hubd_hotplug_arg))
2944844Slg150142 _NOTE(SCHEME_PROTECTS_DATA("unshared", hubd_reset_arg))
2952651Ssl147100 
2960Sstevel@tonic-gate #define	HUBD_UNIT(dev)		(getminor((dev)))
2970Sstevel@tonic-gate #define	HUBD_MUTEX(hubd)	(&((hubd)->h_mutex))
2980Sstevel@tonic-gate #define	HUBD_SS_ISOPEN		0x0001
2990Sstevel@tonic-gate #define	HUBD_ACK_ALL_CHANGES	PORT_CHANGE_MASK
3000Sstevel@tonic-gate 
3010Sstevel@tonic-gate /* init state */
3020Sstevel@tonic-gate #define	HUBD_LOCKS_DONE		0x0001
3030Sstevel@tonic-gate #define	HUBD_HUBDI_REGISTERED	0x0002
3040Sstevel@tonic-gate #define	HUBD_MINOR_NODE_CREATED 0x0004
3051001Ssl147100 #define	HUBD_CHILDREN_CREATED	0x0008
3060Sstevel@tonic-gate #define	HUBD_EVENTS_REGISTERED	0x0020
3070Sstevel@tonic-gate 
3080Sstevel@tonic-gate /*
3090Sstevel@tonic-gate  * port flags : These are essentially extensions of  Port Status Field Bits
3100Sstevel@tonic-gate  * as in USB 2.0 spec Table 11-21 and #defined in hubd.h file. We make use
3110Sstevel@tonic-gate  * of the unused bits (5-7,13-15) here to track states of the hub's child.
3120Sstevel@tonic-gate  */
3130Sstevel@tonic-gate #define	HUBD_CHILD_ATTACHING		0x0020
3140Sstevel@tonic-gate #define	HUBD_CHILD_DETACHING		0x0040
3150Sstevel@tonic-gate #define	HUBD_CHILD_PWRLVL_CHNG		0x0080
3160Sstevel@tonic-gate #define	HUBD_CHILD_RAISE_POWER		0x2000
3170Sstevel@tonic-gate #define	HUBD_CHILD_ZAP			0x4000
3180Sstevel@tonic-gate 
3190Sstevel@tonic-gate /* Tracking events registered by children */
3200Sstevel@tonic-gate #define	HUBD_CHILD_EVENT_DISCONNECT	0x01
3210Sstevel@tonic-gate #define	HUBD_CHILD_EVENT_PRESUSPEND	0x02
3220Sstevel@tonic-gate 
3230Sstevel@tonic-gate /* This dev state is used exclusively by hub to change port suspend/resume */
3240Sstevel@tonic-gate #define	USB_DEV_HUB_CHILD_PWRLVL	0x80
3250Sstevel@tonic-gate #define	USB_DEV_HUB_STATE_RECOVER	0x81
3260Sstevel@tonic-gate 
3270Sstevel@tonic-gate /*
3280Sstevel@tonic-gate  * hubd interrupt pipe management :
3290Sstevel@tonic-gate  *
3300Sstevel@tonic-gate  * Following are the states of the interrupt pipe
3310Sstevel@tonic-gate  *
3320Sstevel@tonic-gate  * IDLE:
3330Sstevel@tonic-gate  *	initial state and after closing of the interrupt pipe
3340Sstevel@tonic-gate  *
3350Sstevel@tonic-gate  * OPENING:
3360Sstevel@tonic-gate  *	Set when the pipe is being opened
3370Sstevel@tonic-gate  *
3380Sstevel@tonic-gate  * ACTIVE:
3390Sstevel@tonic-gate  *	Set when the pipe has been opened in hubd_open_intr_pipe. This is
3400Sstevel@tonic-gate  *	typically after a hub has got enumerated and initialized.
3410Sstevel@tonic-gate  *
3420Sstevel@tonic-gate  * CLOSING :
3430Sstevel@tonic-gate  *	Set when the pipe is closed by calling hubd_close_intr_pipe(). This is
3440Sstevel@tonic-gate  *	typically called on hub disconnect via hubd_cleanup.
3450Sstevel@tonic-gate  */
3460Sstevel@tonic-gate #define	HUBD_INTR_PIPE_IDLE		0
3470Sstevel@tonic-gate #define	HUBD_INTR_PIPE_OPENING		1
3480Sstevel@tonic-gate #define	HUBD_INTR_PIPE_ACTIVE		2
3490Sstevel@tonic-gate #define	HUBD_INTR_PIPE_STOPPED		3
3500Sstevel@tonic-gate #define	HUBD_INTR_PIPE_CLOSING		4
3510Sstevel@tonic-gate 
3520Sstevel@tonic-gate 
3530Sstevel@tonic-gate /* request structure for putting dips on deathrow list */
3540Sstevel@tonic-gate typedef struct hubd_offline_req {
3550Sstevel@tonic-gate 	usba_list_entry_t	or_queue; /* DO NOT MOVE! */
3560Sstevel@tonic-gate 	hubd_t			*or_hubd;
3570Sstevel@tonic-gate 	usb_port_t		or_port;
3580Sstevel@tonic-gate 	dev_info_t		*or_dip;
3590Sstevel@tonic-gate 	uint_t			or_flag;
3600Sstevel@tonic-gate } hubd_offline_req_t;
3610Sstevel@tonic-gate 
3620Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("unshared", hubd_offline_req))
3630Sstevel@tonic-gate 
3640Sstevel@tonic-gate 
3650Sstevel@tonic-gate /*
3660Sstevel@tonic-gate  * cfgadm state values
3670Sstevel@tonic-gate  */
3680Sstevel@tonic-gate #define	HUBD_CFGADM_NORMAL		0	/* normal state */
3690Sstevel@tonic-gate #define	HUBD_CFGADM_DISCONNECTED	1	/* logically disconnected */
3700Sstevel@tonic-gate #define	HUBD_CFGADM_UNCONFIGURED	2	/* port is unconfigured */
3710Sstevel@tonic-gate #define	HUBD_CFGADM_EMPTY		3	/* port is empty */
3720Sstevel@tonic-gate #define	HUBD_CFGADM_STILL_REFERENCED	4	/* ndi_devi_offline failed */
3730Sstevel@tonic-gate #define	HUBD_CFGADM_CONFIGURED		5	/* port is configured */
3740Sstevel@tonic-gate 
3750Sstevel@tonic-gate /*
3760Sstevel@tonic-gate  * Debug printing
3770Sstevel@tonic-gate  * Masks
3780Sstevel@tonic-gate  */
3790Sstevel@tonic-gate #define	DPRINT_MASK_ATTA	0x00000001
3800Sstevel@tonic-gate #define	DPRINT_MASK_CBOPS	0x00000002
3810Sstevel@tonic-gate #define	DPRINT_MASK_CALLBACK	0x00000004
3820Sstevel@tonic-gate #define	DPRINT_MASK_PORT	0x00000008
3830Sstevel@tonic-gate #define	DPRINT_MASK_HUB 	0x00000010
3840Sstevel@tonic-gate #define	DPRINT_MASK_HOTPLUG	0x00000020
3850Sstevel@tonic-gate #define	DPRINT_MASK_EVENTS	0x00000040
3860Sstevel@tonic-gate #define	DPRINT_MASK_PM		0x00000080
3870Sstevel@tonic-gate #define	DPRINT_MASK_ALL 	0xFFFFFFFF
3880Sstevel@tonic-gate 
3890Sstevel@tonic-gate 
3900Sstevel@tonic-gate /* status length used in getting hub status */
3910Sstevel@tonic-gate #define	GET_STATUS_LENGTH	0x04		/* length of get status req */
3920Sstevel@tonic-gate 
3930Sstevel@tonic-gate /* flag for hubd_start_polling */
3940Sstevel@tonic-gate #define	HUBD_ALWAYS_START_POLLING	1
3950Sstevel@tonic-gate 
3960Sstevel@tonic-gate /* enumeration timeout */
3970Sstevel@tonic-gate #define	HUBDI_ENUM_TIMEOUT	1	/* 1 second */
3980Sstevel@tonic-gate 
3991001Ssl147100 /* power budget unit in mA */
4001001Ssl147100 #define	USB_PWR_UNIT_LOAD	100
4011001Ssl147100 
4021001Ssl147100 /* power values in 100mA units */
4031001Ssl147100 #define	USB_HIGH_PWR_VALUE	5
4041001Ssl147100 #define	USB_LOW_PWR_VALUE	1
4051001Ssl147100 
4061001Ssl147100 /*
4071001Ssl147100  * According to section 9.6.3 of USB 2.0 spec,
4081001Ssl147100  * bMaxPower in the device configuration descriptor
4091001Ssl147100  * is expressed in 2mA units
4101001Ssl147100  */
4111001Ssl147100 #define	USB_CFG_DESCR_PWR_UNIT	2
4121001Ssl147100 
4139430SRaymond.Chen@Sun.COM /* variables shared with wire adapter class drivers */
4149430SRaymond.Chen@Sun.COM extern uint_t hubd_errlevel;
4159430SRaymond.Chen@Sun.COM extern uint_t hubd_errmask;
4169430SRaymond.Chen@Sun.COM extern uint_t hubd_instance_debug;
4179430SRaymond.Chen@Sun.COM 
4189430SRaymond.Chen@Sun.COM /* common interfaces for hub and wire adapter class devices */
4199430SRaymond.Chen@Sun.COM hubd_t	*hubd_get_soft_state(dev_info_t *);
4209430SRaymond.Chen@Sun.COM void	hubd_get_ancestry_str(hubd_t *);
4219430SRaymond.Chen@Sun.COM int	hubd_get_all_device_config_cloud(hubd_t *, dev_info_t *,
4229430SRaymond.Chen@Sun.COM 	usba_device_t *);
4239430SRaymond.Chen@Sun.COM int	hubd_select_device_configuration(hubd_t *, usb_port_t,
4249430SRaymond.Chen@Sun.COM 	dev_info_t *, usba_device_t *);
4259430SRaymond.Chen@Sun.COM dev_info_t *hubd_ready_device(hubd_t *, dev_info_t *, usba_device_t *,
4269430SRaymond.Chen@Sun.COM 	uint_t);
4279430SRaymond.Chen@Sun.COM void	hubd_schedule_cleanup(dev_info_t *);
4289430SRaymond.Chen@Sun.COM 
4290Sstevel@tonic-gate #ifdef	__cplusplus
4300Sstevel@tonic-gate }
4310Sstevel@tonic-gate #endif
4320Sstevel@tonic-gate 
4330Sstevel@tonic-gate #endif	/* _SYS_USB_HUBDVAR_H */
434