1 | /*
|
---|
2 | * Copyright (c) 2010 Vojtech Horky
|
---|
3 | * Copyright (c) 2011 Vojtech Horky
|
---|
4 | * Copyright (c) 2018 Ondrej Hlavaty, Petr Manek
|
---|
5 | * All rights reserved.
|
---|
6 | *
|
---|
7 | * Redistribution and use in source and binary forms, with or without
|
---|
8 | * modification, are permitted provided that the following conditions
|
---|
9 | * are met:
|
---|
10 | *
|
---|
11 | * - Redistributions of source code must retain the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer.
|
---|
13 | * - 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 | * - The name of the author may not be used to endorse or promote products
|
---|
17 | * derived from this software without specific prior written permission.
|
---|
18 | *
|
---|
19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
28 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
29 | */
|
---|
30 |
|
---|
31 | /** @addtogroup drvusbhub
|
---|
32 | * @{
|
---|
33 | */
|
---|
34 | /** @file
|
---|
35 | * @brief Hub driver.
|
---|
36 | */
|
---|
37 |
|
---|
38 | #ifndef DRV_USBHUB_USBHUB_H
|
---|
39 | #define DRV_USBHUB_USBHUB_H
|
---|
40 |
|
---|
41 | #include <ddf/driver.h>
|
---|
42 | #include <fibril_synch.h>
|
---|
43 |
|
---|
44 | #include <usb/classes/hub.h>
|
---|
45 |
|
---|
46 | #include <usb/dev/pipes.h>
|
---|
47 | #include <usb/dev/driver.h>
|
---|
48 | #include <usb/dev/poll.h>
|
---|
49 |
|
---|
50 | #define NAME "usbhub"
|
---|
51 |
|
---|
52 | #include "port.h"
|
---|
53 | #include "status.h"
|
---|
54 |
|
---|
55 | /** Information about attached hub. */
|
---|
56 | struct usb_hub_dev {
|
---|
57 | /** Number of ports. */
|
---|
58 | size_t port_count;
|
---|
59 | /** Port structures, one for each port */
|
---|
60 | usb_hub_port_t *ports;
|
---|
61 | /** Speed of the hub */
|
---|
62 | usb_speed_t speed;
|
---|
63 | /** Generic usb device data*/
|
---|
64 | usb_device_t *usb_device;
|
---|
65 | /** Data polling handle. */
|
---|
66 | usb_polling_t polling;
|
---|
67 | /** Pointer to usbhub function. */
|
---|
68 | ddf_fun_t *hub_fun;
|
---|
69 | /** Device communication pipe. */
|
---|
70 | usb_pipe_t *control_pipe;
|
---|
71 | /** Hub supports port power switching. */
|
---|
72 | bool power_switched;
|
---|
73 | /** Each port is switched individually. */
|
---|
74 | bool per_port_power;
|
---|
75 | /** Whether MTT is available */
|
---|
76 | bool mtt_available;
|
---|
77 | };
|
---|
78 |
|
---|
79 | extern const usb_endpoint_description_t *usb_hub_endpoints [];
|
---|
80 |
|
---|
81 | errno_t usb_hub_device_add(usb_device_t *);
|
---|
82 | errno_t usb_hub_device_remove(usb_device_t *);
|
---|
83 | errno_t usb_hub_device_gone(usb_device_t *);
|
---|
84 |
|
---|
85 | errno_t usb_hub_set_depth(const usb_hub_dev_t *);
|
---|
86 | errno_t usb_hub_get_port_status(const usb_hub_dev_t *, size_t,
|
---|
87 | usb_port_status_t *);
|
---|
88 | errno_t usb_hub_set_port_feature(const usb_hub_dev_t *, size_t,
|
---|
89 | usb_hub_class_feature_t);
|
---|
90 | errno_t usb_hub_clear_port_feature(const usb_hub_dev_t *, size_t,
|
---|
91 | usb_hub_class_feature_t);
|
---|
92 |
|
---|
93 | bool hub_port_changes_callback(usb_device_t *, uint8_t *, size_t, void *);
|
---|
94 |
|
---|
95 | errno_t usb_hub_reserve_default_address(usb_hub_dev_t *, async_exch_t *,
|
---|
96 | usb_port_t *);
|
---|
97 | errno_t usb_hub_release_default_address(usb_hub_dev_t *, async_exch_t *);
|
---|
98 |
|
---|
99 | #endif
|
---|
100 |
|
---|
101 | /**
|
---|
102 | * @}
|
---|
103 | */
|
---|