]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/usb/usb_hub.h
clk: Move rockchip driver into the common directory
[FreeBSD/FreeBSD.git] / sys / dev / usb / usb_hub.h
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  */
27
28 #ifndef _USB_HUB_H_
29 #define _USB_HUB_H_
30
31 /*
32  * The following structure defines an USB port. 
33  */
34 struct usb_port {
35         uint8_t restartcnt;
36 #define USB_RESTART_MAX 5
37         uint8_t device_index;           /* zero means not valid */
38         enum usb_hc_mode usb_mode;      /* host or device mode */
39 #if USB_HAVE_TT_SUPPORT
40         struct usb_device_request req_reset_tt __aligned(4);
41 #endif
42 };
43
44 /*
45  * The following structure defines an USB HUB.
46  */
47 struct usb_hub {
48         struct usb_device *hubudev;     /* the HUB device */
49         usb_error_t (*explore) (struct usb_device *hub);
50         void   *hubsoftc;
51 #if USB_HAVE_TT_SUPPORT
52         struct usb_udev_msg tt_msg[2];
53 #endif
54         usb_size_t uframe_usage[USB_HS_MICRO_FRAMES_MAX];
55         uint16_t portpower;             /* mA per USB port */
56         uint8_t isoc_last_time;
57         uint8_t nports;
58 #if (USB_HAVE_FIXED_PORT == 0)
59         struct usb_port ports[0];
60 #else
61         struct usb_port ports[USB_MAX_PORTS];
62 #endif
63 };
64
65 /* function prototypes */
66
67 void    usb_hs_bandwidth_alloc(struct usb_xfer *xfer);
68 void    usb_hs_bandwidth_free(struct usb_xfer *xfer);
69 void    usb_bus_port_set_device(struct usb_bus *bus, struct usb_port *up,
70             struct usb_device *udev, uint8_t device_index);
71 struct usb_device *usb_bus_port_get_device(struct usb_bus *bus,
72             struct usb_port *up);
73 void    usb_needs_explore(struct usb_bus *bus, uint8_t do_probe);
74 void    usb_needs_explore_all(void);
75 void    usb_bus_power_update(struct usb_bus *bus);
76 void    usb_bus_powerd(struct usb_bus *bus);
77 void    uhub_root_intr(struct usb_bus *, const uint8_t *, uint8_t);
78 usb_error_t uhub_query_info(struct usb_device *, uint8_t *, uint8_t *);
79 void    uhub_explore_handle_re_enumerate(struct usb_device *);
80
81 #endif                                  /* _USB_HUB_H_ */