xref: /onnv-gate/usr/src/uts/common/sys/usb/usba/usba_impl.h (revision 10316:d68e26bd3bfd)
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
53341Sgc161489  * Common Development and Distribution License (the "License").
63341Sgc161489  * 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 /*
229094SVincent.Wang@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_USBA_USBA_IMPL_H
270Sstevel@tonic-gate #define	_SYS_USB_USBA_USBA_IMPL_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #include <sys/usb/usba.h>
310Sstevel@tonic-gate #include <sys/usb/usba/hcdi.h>
320Sstevel@tonic-gate #include <sys/usb/usba/hubdi.h>
330Sstevel@tonic-gate #include <sys/usb/usba/usba_private.h>
340Sstevel@tonic-gate #include <sys/usb/usba/usba_types.h>
350Sstevel@tonic-gate #include <sys/taskq.h>
360Sstevel@tonic-gate #include <sys/disp.h>
370Sstevel@tonic-gate 
380Sstevel@tonic-gate #ifdef	__cplusplus
390Sstevel@tonic-gate extern "C" {
400Sstevel@tonic-gate #endif
410Sstevel@tonic-gate 
420Sstevel@tonic-gate 
430Sstevel@tonic-gate /*
440Sstevel@tonic-gate  * UGEN binding values specified in <hcd>.conf files
450Sstevel@tonic-gate  */
460Sstevel@tonic-gate #define	USBA_UGEN_DEVICE_BINDING	1
470Sstevel@tonic-gate #define	USBA_UGEN_INTERFACE_BINDING	2
483341Sgc161489 #define	USBA_UGEN_INTERFACE_ASSOCIATION_BINDING		3
490Sstevel@tonic-gate 
500Sstevel@tonic-gate /*
510Sstevel@tonic-gate  * Allocating a USB address
520Sstevel@tonic-gate  */
530Sstevel@tonic-gate #define	USBA_MAX_ADDRESS		127
540Sstevel@tonic-gate #define	USBA_ADDRESS_ARRAY_SIZE	((USBA_MAX_ADDRESS+8)/8)
550Sstevel@tonic-gate 
560Sstevel@tonic-gate /*
570Sstevel@tonic-gate  * async execution of usb_pipe_* functions which have a
580Sstevel@tonic-gate  * completion callback parameter (eg. usb_pipe_close(),
590Sstevel@tonic-gate  * usb_pipe_reset(), usb_pipe_stop_*_polling()
600Sstevel@tonic-gate  */
610Sstevel@tonic-gate typedef struct usba_pipe_async_req {
620Sstevel@tonic-gate 	dev_info_t		*dip;
630Sstevel@tonic-gate 	struct usba_ph_impl	*ph_impl;
640Sstevel@tonic-gate 	usb_opaque_t		arg;
650Sstevel@tonic-gate 	usb_flags_t		usb_flags;
660Sstevel@tonic-gate 	void			(*callback)(
670Sstevel@tonic-gate 					usb_pipe_handle_t	ph,
680Sstevel@tonic-gate 					usb_opaque_t		callback_arg,
690Sstevel@tonic-gate 					int			rval,
700Sstevel@tonic-gate 					usb_cb_flags_t		error_code);
710Sstevel@tonic-gate 	usb_opaque_t		callback_arg;
720Sstevel@tonic-gate 	int			(*sync_func)(dev_info_t *,
730Sstevel@tonic-gate 					usba_ph_impl_t *,
740Sstevel@tonic-gate 					struct usba_pipe_async_req *,
750Sstevel@tonic-gate 					usb_flags_t);
760Sstevel@tonic-gate } usba_pipe_async_req_t;
770Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("unique per call", usba_pipe_async_req_t))
780Sstevel@tonic-gate 
790Sstevel@tonic-gate /* per-pipe taskq */
800Sstevel@tonic-gate int	usba_async_ph_req(usba_pipe_handle_data_t *, void (*func)(void *),
810Sstevel@tonic-gate 							void *, usb_flags_t);
820Sstevel@tonic-gate 
830Sstevel@tonic-gate /*
840Sstevel@tonic-gate  * usb wrapper around pm_request_power_change to allow for
850Sstevel@tonic-gate  * non blocking behavior
860Sstevel@tonic-gate  */
870Sstevel@tonic-gate typedef struct usba_pm_req {
880Sstevel@tonic-gate 	dev_info_t	*dip;
890Sstevel@tonic-gate 	int		comp;
900Sstevel@tonic-gate 	int		old_level;
910Sstevel@tonic-gate 	int		level;
920Sstevel@tonic-gate 	void		(*cb)(void *, int);
930Sstevel@tonic-gate 	void		*arg;
940Sstevel@tonic-gate 	uint_t		flags;
950Sstevel@tonic-gate } usba_pm_req_t;
960Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("unique per call", usba_pm_req_t))
970Sstevel@tonic-gate 
980Sstevel@tonic-gate 
990Sstevel@tonic-gate /*
1000Sstevel@tonic-gate  * Request wrappers for control/bulk/interrupt and isoch pipes
1010Sstevel@tonic-gate  * These are hidden from client driver. They serve as place-holders
1020Sstevel@tonic-gate  * for doing callbacks
1030Sstevel@tonic-gate  *
1040Sstevel@tonic-gate  * Request allocation: wrapper + usb_*_req_t alloc'ed together:
1050Sstevel@tonic-gate  *
1060Sstevel@tonic-gate  *		+-----------------------+
1070Sstevel@tonic-gate  *		|	wr_queue	|		for callbacks
1080Sstevel@tonic-gate  *		+-----------------------+
1090Sstevel@tonic-gate  *		|	wr_req	|-------+	wr_req points to
1100Sstevel@tonic-gate  *		+-----------------------+	|	the req below.
1110Sstevel@tonic-gate  *		|			|	|
1120Sstevel@tonic-gate  *		|	....		|	|
1130Sstevel@tonic-gate  *		|	req_wrapper_t	|	|
1140Sstevel@tonic-gate  *		|			|	|
1150Sstevel@tonic-gate  *		+-----------------------+<------+
1160Sstevel@tonic-gate  *		|			|
1170Sstevel@tonic-gate  *		|	....		|
1180Sstevel@tonic-gate  *		| ctrl/bulk/intr/isoch	|
1190Sstevel@tonic-gate  *		|	req_t	|
1200Sstevel@tonic-gate  *		|			|
1210Sstevel@tonic-gate  *		|			|
1220Sstevel@tonic-gate  *		+-----------------------+
1230Sstevel@tonic-gate  */
1240Sstevel@tonic-gate typedef struct usba_req_wrapper {
1250Sstevel@tonic-gate 	/* queueing in either a request or callback queue */
1260Sstevel@tonic-gate 	usba_list_entry_t	wr_queue;
1270Sstevel@tonic-gate 
1280Sstevel@tonic-gate 	/*
1290Sstevel@tonic-gate 	 * The request could be control/bulk/intr/isoc
1300Sstevel@tonic-gate 	 * See usbai.h usb_ctrl_req_t/usb_bulk_req_t
1310Sstevel@tonic-gate 	 * usb_intr_req_t/usb_isoc_req_t
1320Sstevel@tonic-gate 	 */
1330Sstevel@tonic-gate 	usb_opaque_t		wr_req;
1340Sstevel@tonic-gate 
1350Sstevel@tonic-gate 	/* for allocation tracking in usba_device_t */
1360Sstevel@tonic-gate 	usba_list_entry_t	wr_allocated_list;
1370Sstevel@tonic-gate 
1380Sstevel@tonic-gate 	/*
1390Sstevel@tonic-gate 	 * All reqs that are synchronous sleep on this cv
1400Sstevel@tonic-gate 	 * for completion notification.
1410Sstevel@tonic-gate 	 * In hcdi soft interrupt handler we call cv_signal()
1420Sstevel@tonic-gate 	 */
1430Sstevel@tonic-gate 	kcondvar_t		wr_cv;
1440Sstevel@tonic-gate 
1450Sstevel@tonic-gate 	/*
1460Sstevel@tonic-gate 	 * This goes hand-in-hand with wr_cv. It is set by the soft intr hdlr
1470Sstevel@tonic-gate 	 * before doing a cv_signal
1480Sstevel@tonic-gate 	 */
1490Sstevel@tonic-gate 	boolean_t		wr_done;
1500Sstevel@tonic-gate 	dev_info_t		*wr_dip;	/* owner */
1510Sstevel@tonic-gate 
1520Sstevel@tonic-gate 	usb_opaque_t		wr_hcd_private;	/* for HCD's use */
1530Sstevel@tonic-gate 
1540Sstevel@tonic-gate 	usba_pipe_handle_data_t	*wr_ph_data;	/* ptr to pipe handle */
1550Sstevel@tonic-gate 
1560Sstevel@tonic-gate 	usb_cr_t		wr_cr;		/* save cr from HCDI */
1570Sstevel@tonic-gate 	usb_cb_flags_t		wr_cb_flags;	/* save cb_flags */
1580Sstevel@tonic-gate 	usb_flags_t		wr_usb_flags;	/* save usb flags from HCDI */
1590Sstevel@tonic-gate 	usb_req_attrs_t		wr_attrs;	/* save attrs from HCDI */
1600Sstevel@tonic-gate 
1610Sstevel@tonic-gate 	/* total lenght of wrapper and request */
1620Sstevel@tonic-gate 	size_t			wr_length;
1630Sstevel@tonic-gate } usba_req_wrapper_t;
1640Sstevel@tonic-gate 
1650Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("method", usba_req_wrapper))
1660Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("method", usb_ctrl_req))
1670Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("method", usb_bulk_req))
1680Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("method", usb_intr_req))
1690Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("method", usb_isoc_req))
1700Sstevel@tonic-gate 
1710Sstevel@tonic-gate /* additional flag for wr_usb_flags */
1720Sstevel@tonic-gate #define	USBA_WRP_FLAGS_WAIT	0x01
1730Sstevel@tonic-gate 
1740Sstevel@tonic-gate /* additional usb flags, not exposed to clients */
1750Sstevel@tonic-gate #define	USBA_FLAGS_PRIVILEGED	0x02	/* for default pipe operations */
1760Sstevel@tonic-gate 
1770Sstevel@tonic-gate /* Macros to convert wrapper to different request and vice-versa */
1780Sstevel@tonic-gate 
1790Sstevel@tonic-gate /* to get the wr->wr_req field */
1800Sstevel@tonic-gate #define	USBA_WRP2REQ(wrp)	((wrp)->wr_req)
1810Sstevel@tonic-gate 
1820Sstevel@tonic-gate /* to get the wrapper form the wr_req field */
1830Sstevel@tonic-gate #define	USBA_REQ2WRP(req)		(usba_req_wrapper_t *)\
1840Sstevel@tonic-gate 				((uintptr_t)(req) - sizeof (usba_req_wrapper_t))
1850Sstevel@tonic-gate 
1860Sstevel@tonic-gate /* to set the the address in the wr_req field */
1870Sstevel@tonic-gate #define	USBA_SETREQ_ADDR(wrp)	((uintptr_t)(wrp) + sizeof (*(wrp)))
1880Sstevel@tonic-gate 
1890Sstevel@tonic-gate /* to get the 4 xfer type requests */
1900Sstevel@tonic-gate #define	USBA_WRP2CTRL_REQ(wrp)	((usb_ctrl_req_t *)USBA_WRP2REQ((wrp)))
1910Sstevel@tonic-gate #define	USBA_WRP2INTR_REQ(wrp)	((usb_intr_req_t *)USBA_WRP2REQ((wrp)))
1920Sstevel@tonic-gate #define	USBA_WRP2BULK_REQ(wrp)	((usb_bulk_req_t *)USBA_WRP2REQ((wrp)))
1930Sstevel@tonic-gate #define	USBA_WRP2ISOC_REQ(wrp)	((usb_isoc_req_t *)USBA_WRP2REQ((wrp)))
1940Sstevel@tonic-gate 
1950Sstevel@tonic-gate /* to get pipe_handle from the wrapper */
1960Sstevel@tonic-gate #define	USBA_WRP2PH_DATA(wrp) \
1970Sstevel@tonic-gate 	(usba_pipe_handle_data_t *)((wrp)->wr_ph_data)
1980Sstevel@tonic-gate 
1990Sstevel@tonic-gate /* to get to the wr_queue from the wrapper */
2000Sstevel@tonic-gate #define	USBA_WRQUEUE2WRP(queue)	(usba_req_wrapper_t *)(queue)
2010Sstevel@tonic-gate 
2020Sstevel@tonic-gate /* to get to the wr_allocated queue from the wrapper */
2030Sstevel@tonic-gate #define	USBA_ALLOCQ2WRP(queue)	(usba_req_wrapper_t *)((uintptr_t) \
2040Sstevel@tonic-gate 	(queue)  - sizeof (usba_list_entry_t) - sizeof (usb_opaque_t))
2050Sstevel@tonic-gate 
2060Sstevel@tonic-gate 
2070Sstevel@tonic-gate /* alias for pipe handle member p_usba_private */
2080Sstevel@tonic-gate #define	p_active_cntrl_req_wrp	p_usba_private
2090Sstevel@tonic-gate 
2100Sstevel@tonic-gate /*
2110Sstevel@tonic-gate  * This function is used to get the HCD private field maintained by USBA.
2120Sstevel@tonic-gate  * HCD calls this function.
2130Sstevel@tonic-gate  */
2140Sstevel@tonic-gate usb_opaque_t usba_hcdi_get_ctrl_req_hcd_private(usb_ctrl_req_t *);
2150Sstevel@tonic-gate 
2160Sstevel@tonic-gate /*
2170Sstevel@tonic-gate  * This function is used to set the HCD private field maintained by USBA.
2180Sstevel@tonic-gate  * HCD calls this function.
2190Sstevel@tonic-gate  */
2200Sstevel@tonic-gate void	usba_hcdi_set_ctrl_req_hcd_private(usb_ctrl_req_t *, usb_opaque_t);
2210Sstevel@tonic-gate 
2220Sstevel@tonic-gate int	usba_set_usb_address(usba_device_t *);
2230Sstevel@tonic-gate void	usba_unset_usb_address(usba_device_t *);
2240Sstevel@tonic-gate 
2250Sstevel@tonic-gate /*
2260Sstevel@tonic-gate  * Per Hub Data Structures
2270Sstevel@tonic-gate  */
2280Sstevel@tonic-gate typedef  struct usba_hubdi {
2290Sstevel@tonic-gate 	usba_list_entry_t hubdi_list;	 /* linking in hubdi list */
2300Sstevel@tonic-gate 
2310Sstevel@tonic-gate 	dev_info_t	*hubdi_dip;	 /* ptr to devinfo struct */
2320Sstevel@tonic-gate 
2330Sstevel@tonic-gate 	int		hubdi_flags;	/* flag options */
2340Sstevel@tonic-gate 
2350Sstevel@tonic-gate } usba_hubdi_t;
2360Sstevel@tonic-gate 
2370Sstevel@tonic-gate /*
2380Sstevel@tonic-gate  * usba_get_mfg_prod_sn_str:
2390Sstevel@tonic-gate  *	Return a string containing mfg, product, serial number strings.
2400Sstevel@tonic-gate  *	Remove duplicates if some strings are the same.
2410Sstevel@tonic-gate  */
2420Sstevel@tonic-gate char	*usba_get_mfg_prod_sn_str(dev_info_t *, char *, int);
2430Sstevel@tonic-gate 
2440Sstevel@tonic-gate /* return value when user doesn't specify configuration index */
2450Sstevel@tonic-gate #define	USBA_DEV_CONFIG_INDEX_UNDEFINED	-1
2460Sstevel@tonic-gate 
2470Sstevel@tonic-gate /*
2480Sstevel@tonic-gate  * prototypes
2490Sstevel@tonic-gate  */
2500Sstevel@tonic-gate void	usba_usba_initialization();
2510Sstevel@tonic-gate void	usba_usba_destroy();
2520Sstevel@tonic-gate 
2530Sstevel@tonic-gate void	usba_usbai_register_initialization();
2540Sstevel@tonic-gate void	usba_usbai_register_destroy();
2550Sstevel@tonic-gate 
2560Sstevel@tonic-gate void	usba_usbai_initialization();
2570Sstevel@tonic-gate void	usba_usbai_destroy();
2580Sstevel@tonic-gate 
2590Sstevel@tonic-gate void	usba_hubdi_initialization();
2600Sstevel@tonic-gate void	usba_hubdi_destroy();
2610Sstevel@tonic-gate 
2620Sstevel@tonic-gate void	usba_devdb_initialization();
2630Sstevel@tonic-gate void	usba_devdb_destroy();
2640Sstevel@tonic-gate 
2659430SRaymond.Chen@Sun.COM int	usba_hubdi_register(dev_info_t	*, uint_t);
2669430SRaymond.Chen@Sun.COM int	usba_hubdi_unregister(dev_info_t *);
2679430SRaymond.Chen@Sun.COM 
2689430SRaymond.Chen@Sun.COM void	usba_whcdi_initialization();
2699430SRaymond.Chen@Sun.COM void	usba_whcdi_destroy();
2709430SRaymond.Chen@Sun.COM 
2710Sstevel@tonic-gate int	usba_is_root_hub(dev_info_t *dip);
2729430SRaymond.Chen@Sun.COM int	usba_is_wa(dev_info_t *dip);
2739430SRaymond.Chen@Sun.COM int	usba_is_hwa(dev_info_t *dip);
2740Sstevel@tonic-gate 
2750Sstevel@tonic-gate usba_device_t *usba_alloc_usba_device(dev_info_t *);
2769430SRaymond.Chen@Sun.COM void	usba_free_wireless_data(usba_wireless_data_t *wireless_data);
2770Sstevel@tonic-gate void	usba_free_usba_device(usba_device_t *usba_device_t);
2780Sstevel@tonic-gate void	usba_clear_data_toggle(usba_device_t *usba_device);
2790Sstevel@tonic-gate 
2800Sstevel@tonic-gate void	usba_start_next_req(usba_pipe_handle_data_t *ph);
2810Sstevel@tonic-gate 
2820Sstevel@tonic-gate int	usba_pipe_check_handle(usba_pipe_handle_data_t *);
2830Sstevel@tonic-gate int	usba_drain_cbs(usba_pipe_handle_data_t *, usb_cb_flags_t,
2840Sstevel@tonic-gate 			usb_cr_t);
2850Sstevel@tonic-gate int	usba_pipe_setup_func_call(dev_info_t *,
2860Sstevel@tonic-gate 			int (*sync_func)(dev_info_t *,
2870Sstevel@tonic-gate 				usba_ph_impl_t *, usba_pipe_async_req_t *,
2880Sstevel@tonic-gate 				usb_flags_t),
2890Sstevel@tonic-gate 			usba_ph_impl_t *,
2900Sstevel@tonic-gate 			usb_opaque_t,
2910Sstevel@tonic-gate 			usb_flags_t,
2920Sstevel@tonic-gate 			void (*cb)(usb_pipe_handle_t, usb_opaque_t,
2930Sstevel@tonic-gate 			    int, usb_cb_flags_t),
2940Sstevel@tonic-gate 			usb_opaque_t);
2950Sstevel@tonic-gate 
2960Sstevel@tonic-gate 
2970Sstevel@tonic-gate void	usba_pipe_new_state(usba_pipe_handle_data_t *, usb_pipe_state_t);
2980Sstevel@tonic-gate 
2999094SVincent.Wang@Sun.COM void usba_add_root_hub(dev_info_t *dip);
3009094SVincent.Wang@Sun.COM void usba_rem_root_hub(dev_info_t *dip);
3010Sstevel@tonic-gate 
3020Sstevel@tonic-gate /*
3030Sstevel@tonic-gate  * retrieve string descriptors for manufacturer, vendor and serial
3040Sstevel@tonic-gate  * number
3050Sstevel@tonic-gate  */
3060Sstevel@tonic-gate void usba_get_dev_string_descrs(dev_info_t *, usba_device_t *);
3070Sstevel@tonic-gate 
3080Sstevel@tonic-gate /*
3090Sstevel@tonic-gate  * Check if we are not in interrupt context and have
3100Sstevel@tonic-gate  * USB_FLAGS_SLEEP flags set.
3110Sstevel@tonic-gate  */
3120Sstevel@tonic-gate #define	USBA_CHECK_CONTEXT()	ASSERT(!(servicing_interrupt()))
3130Sstevel@tonic-gate 
3140Sstevel@tonic-gate /*
3150Sstevel@tonic-gate  * USBA module Masks
3160Sstevel@tonic-gate  */
3170Sstevel@tonic-gate #define	DPRINT_MASK_USBA		0x00000001
3180Sstevel@tonic-gate #define	DPRINT_MASK_USBAI		0x00000002
3190Sstevel@tonic-gate #define	DPRINT_MASK_HUBDI		0x00000004
3200Sstevel@tonic-gate #define	DPRINT_MASK_HCDI		0x00000008
3210Sstevel@tonic-gate #define	DPRINT_MASK_HCDI_DUMPING	0x00000010
3220Sstevel@tonic-gate #define	DPRINT_MASK_HUBDI_DUMPING	0x00000020
3230Sstevel@tonic-gate #define	DPRINT_MASK_REGISTER		0x00000040
3240Sstevel@tonic-gate #define	DPRINT_MASK_DEVDB		0x00000080
3259430SRaymond.Chen@Sun.COM #define	DPRINT_MASK_WHCDI		0x00000100
3260Sstevel@tonic-gate #define	DPRINT_MASK_ALL 		0xFFFFFFFF
3270Sstevel@tonic-gate 
3280Sstevel@tonic-gate typedef struct usba_log_handle_impl {
3290Sstevel@tonic-gate 	dev_info_t	*lh_dip;
3300Sstevel@tonic-gate 	char		*lh_name;
3310Sstevel@tonic-gate 	uint_t		*lh_errlevel;
3320Sstevel@tonic-gate 	uint_t		*lh_mask;
3330Sstevel@tonic-gate 	uint_t		*lh_instance_filter;
3340Sstevel@tonic-gate 	uint_t		lh_flags;
3350Sstevel@tonic-gate } usba_log_handle_impl_t;
3360Sstevel@tonic-gate 
3370Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("USBA managed data", usba_log_handle_impl))
3380Sstevel@tonic-gate 
3390Sstevel@tonic-gate /*
3400Sstevel@tonic-gate  * Miscellaneous definitions.
3410Sstevel@tonic-gate  */
3420Sstevel@tonic-gate 
3430Sstevel@tonic-gate /* possible strlen of a USB driver's name */
3440Sstevel@tonic-gate #define	USBA_DRVNAME_LEN	40
3450Sstevel@tonic-gate 
3460Sstevel@tonic-gate /* strings passed to usb_dprintfN() are this long */
3470Sstevel@tonic-gate #define	USBA_PRINT_BUF_LEN	256
3480Sstevel@tonic-gate 
3490Sstevel@tonic-gate /*
3500Sstevel@tonic-gate  * usba_set_node_name() sets a device info node name
3510Sstevel@tonic-gate  * according to class, subclass, and protocol.
3520Sstevel@tonic-gate  * a subclass == -1 or protocol == -1 is considered a "don't care".
3530Sstevel@tonic-gate  */
3540Sstevel@tonic-gate #define	DONTCARE		((int16_t)-1)
3550Sstevel@tonic-gate #define	FLAG_INTERFACE_NODE	0
3560Sstevel@tonic-gate #define	FLAG_DEVICE_NODE	1
3570Sstevel@tonic-gate #define	FLAG_COMBINED_NODE	2
3583341Sgc161489 #define	FLAG_INTERFACE_ASSOCIATION_NODE		3
3590Sstevel@tonic-gate 
3600Sstevel@tonic-gate typedef struct node_name_entry {
3610Sstevel@tonic-gate 	int16_t class;
3620Sstevel@tonic-gate 	int16_t subclass;
3630Sstevel@tonic-gate 	int16_t protocol;
3640Sstevel@tonic-gate 	char	*name;
3650Sstevel@tonic-gate } node_name_entry_t;
3660Sstevel@tonic-gate 
3670Sstevel@tonic-gate 
3680Sstevel@tonic-gate /*
3690Sstevel@tonic-gate  * USB enumeration statistics support
3700Sstevel@tonic-gate  */
3710Sstevel@tonic-gate 
3720Sstevel@tonic-gate /* Flags telling which stats usba_update_hotplug_stats should update */
3730Sstevel@tonic-gate #define	USBA_TOTAL_HOTPLUG_SUCCESS	0x01
3740Sstevel@tonic-gate #define	USBA_HOTPLUG_SUCCESS		0x02
3750Sstevel@tonic-gate #define	USBA_TOTAL_HOTPLUG_FAILURE	0x04
3760Sstevel@tonic-gate #define	USBA_HOTPLUG_FAILURE		0x08
3770Sstevel@tonic-gate 
3780Sstevel@tonic-gate /*
3790Sstevel@tonic-gate  * Increment enumeration stats indicated by the flags
3800Sstevel@tonic-gate  */
3810Sstevel@tonic-gate void	usba_update_hotplug_stats(dev_info_t *, usb_flags_t);
3820Sstevel@tonic-gate 
3830Sstevel@tonic-gate /* Retrieve the current enumeration hotplug statistics */
3840Sstevel@tonic-gate void	usba_get_hotplug_stats(dev_info_t *,
3850Sstevel@tonic-gate 		ulong_t	*, ulong_t *, ulong_t *,
3860Sstevel@tonic-gate 		ulong_t	*, uchar_t *);
3870Sstevel@tonic-gate 
3880Sstevel@tonic-gate /* Reset the resetable hotplug stats */
3890Sstevel@tonic-gate void	usba_reset_hotplug_stats(dev_info_t *);
3900Sstevel@tonic-gate 
3910Sstevel@tonic-gate 
3920Sstevel@tonic-gate extern usb_log_handle_t usbai_log_handle;
3930Sstevel@tonic-gate extern	kmutex_t usbai_mutex;
3940Sstevel@tonic-gate 
3950Sstevel@tonic-gate void	usba_req_normal_cb(usba_req_wrapper_t *);
3960Sstevel@tonic-gate void	usba_req_exc_cb(usba_req_wrapper_t *, usb_cr_t, usb_cb_flags_t);
3970Sstevel@tonic-gate void	usba_do_req_exc_cb(usba_req_wrapper_t *, usb_cr_t,
3980Sstevel@tonic-gate 						usb_cb_flags_t);
3990Sstevel@tonic-gate void	usba_req_set_cb_flags(usba_req_wrapper_t *, usb_cb_flags_t);
4000Sstevel@tonic-gate 
4010Sstevel@tonic-gate /*
4020Sstevel@tonic-gate  * Creating/Destroying children (root hub, and hub children)
4030Sstevel@tonic-gate  */
4040Sstevel@tonic-gate int	usba_create_child_devi(dev_info_t *, char *, usba_hcdi_ops_t *,
4050Sstevel@tonic-gate 		dev_info_t *, usb_port_status_t,
4060Sstevel@tonic-gate 		usba_device_t *, dev_info_t **);
4070Sstevel@tonic-gate 
4080Sstevel@tonic-gate int	usba_destroy_child_devi(dev_info_t *, uint_t);
4090Sstevel@tonic-gate 
4100Sstevel@tonic-gate /* utility function to map rval to a meaningful cr */
4110Sstevel@tonic-gate usb_cr_t usba_rval2cr(int);
4120Sstevel@tonic-gate 
4130Sstevel@tonic-gate /* various conversion functions */
4140Sstevel@tonic-gate usb_pipe_handle_t	usba_get_dflt_pipe_handle(dev_info_t *);
4150Sstevel@tonic-gate dev_info_t		*usba_get_dip(usb_pipe_handle_t);
4160Sstevel@tonic-gate usb_pipe_handle_t	usba_usbdev_to_dflt_pipe_handle(usba_device_t *);
4170Sstevel@tonic-gate usb_pipe_handle_t	usba_get_pipe_handle(usba_pipe_handle_data_t *);
4180Sstevel@tonic-gate usba_pipe_handle_data_t *usba_get_ph_data(usb_pipe_handle_t);
4190Sstevel@tonic-gate usb_pipe_state_t	usba_get_ph_state(usba_pipe_handle_data_t *);
4200Sstevel@tonic-gate int			usba_get_ph_ref_count(usba_pipe_handle_data_t *);
4210Sstevel@tonic-gate 
4220Sstevel@tonic-gate /* increment and decrement ref_count */
4230Sstevel@tonic-gate usba_pipe_handle_data_t *usba_hold_ph_data(usb_pipe_handle_t);
4240Sstevel@tonic-gate void			usba_release_ph_data(usba_ph_impl_t *);
4250Sstevel@tonic-gate 
4260Sstevel@tonic-gate /* close all pipe and mark them persistent */
4270Sstevel@tonic-gate void			usba_persistent_pipe_close(usba_device_t *);
4280Sstevel@tonic-gate 
4290Sstevel@tonic-gate /* reopen pipes that are marked persistent */
4300Sstevel@tonic-gate int			usba_persistent_pipe_open(usba_device_t *);
4310Sstevel@tonic-gate 
4320Sstevel@tonic-gate /* check for leaks in hubd and usb_mid */
4330Sstevel@tonic-gate void	usba_check_for_leaks(usba_device_t *);
4340Sstevel@tonic-gate 
4350Sstevel@tonic-gate /* free request wrappers */
4360Sstevel@tonic-gate void	usba_req_wrapper_free(usba_req_wrapper_t *);
4370Sstevel@tonic-gate 
438*10316SStrony.Zhang@Sun.COM /* usb device capture for the specific client driver */
439*10316SStrony.Zhang@Sun.COM typedef struct usb_dev_cap {
440*10316SStrony.Zhang@Sun.COM 	dev_info_t			*dip;
441*10316SStrony.Zhang@Sun.COM 	usb_dev_driver_callback_t	usba_dev_driver_cb;
442*10316SStrony.Zhang@Sun.COM } usb_dev_cap_t;
443*10316SStrony.Zhang@Sun.COM 
444*10316SStrony.Zhang@Sun.COM usb_dev_cap_t usb_cap;
445*10316SStrony.Zhang@Sun.COM _NOTE(SCHEME_PROTECTS_DATA("unique device capture data", usb_cap))
446*10316SStrony.Zhang@Sun.COM 
4470Sstevel@tonic-gate #ifdef __cplusplus
4480Sstevel@tonic-gate }
4490Sstevel@tonic-gate #endif
4500Sstevel@tonic-gate 
4510Sstevel@tonic-gate #endif /* _SYS_USB_USBA_USBA_IMPL_H */
452