xref: /freebsd/sys/dev/usb/usb_hub_private.h (revision 71625ec9ad2a9bc8c09784fbd23b759830e0ee5f)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 1998 The NetBSD Foundation, Inc. All rights reserved.
5  * Copyright (c) 1998 Lennart Augustsson. All rights reserved.
6  * Copyright (c) 2008-2010 Hans Petter Selasky. All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  */
29 
30 /*
31  * USB spec: http://www.usb.org/developers/docs/usbspec.zip
32  */
33 
34 #ifndef USB_HUB_PRIVATE_H_
35 #define    USB_HUB_PRIVATE_H_
36 #define	UHUB_INTR_INTERVAL 250		/* ms */
37 
38 enum {
39 	UHUB_INTR_TRANSFER,
40 #if USB_HAVE_TT_SUPPORT
41 	UHUB_RESET_TT_TRANSFER,
42 #endif
43 	UHUB_N_TRANSFER,
44 };
45 
46 struct uhub_current_state {
47 	uint16_t port_change;
48 	uint16_t port_status;
49 };
50 
51 struct uhub_softc {
52 	struct uhub_current_state sc_st;	/* current state */
53 #if (USB_HAVE_FIXED_PORT != 0)
54 	struct usb_hub sc_hub;
55 #endif
56 	device_t sc_dev;		/* base device */
57 	struct mtx sc_mtx;		/* our mutex */
58 	struct usb_device *sc_udev;	/* USB device */
59 	struct usb_xfer *sc_xfer[UHUB_N_TRANSFER];	/* interrupt xfer */
60 #if USB_HAVE_DISABLE_ENUM
61 	int	sc_disable_enumeration;
62 	int	sc_disable_port_power;
63 #endif
64 	uint8_t	sc_usb_port_errors;	/* error counter */
65 #define	UHUB_USB_PORT_ERRORS_MAX 4
66 	uint8_t	sc_flags;
67 #define	UHUB_FLAG_DID_EXPLORE 0x01
68 };
69 struct hub_result {
70 	struct usb_device *udev;
71 	uint8_t	portno;
72 	uint8_t	iface_index;
73 };
74 
75 void
76 uhub_find_iface_index(struct usb_hub *hub, device_t child,
77     struct hub_result *res);
78 
79 device_probe_t uhub_probe;
80 device_attach_t uhub_attach;
81 device_detach_t uhub_detach;
82 bus_child_location_t uhub_child_location;
83 bus_get_device_path_t uhub_get_device_path;
84 
85 #endif
86