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