[4317827] | 1 | /*
|
---|
| 2 | * Copyright (c) 2010 Vojtech Horky
|
---|
[3b617579] | 3 | * Copyright (c) 2011 Vojtech Horky
|
---|
[e0a5d4c] | 4 | * Copyright (c) 2018 Ondrej Hlavaty, Petr Manek
|
---|
[4317827] | 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 | */
|
---|
[58563585] | 30 |
|
---|
[281ebae] | 31 | /** @addtogroup drvusbhub
|
---|
[4317827] | 32 | * @{
|
---|
| 33 | */
|
---|
| 34 | /** @file
|
---|
| 35 | * @brief Hub driver.
|
---|
| 36 | */
|
---|
[58563585] | 37 |
|
---|
[4317827] | 38 | #ifndef DRV_USBHUB_USBHUB_H
|
---|
| 39 | #define DRV_USBHUB_USBHUB_H
|
---|
| 40 |
|
---|
[eb1a2f4] | 41 | #include <ddf/driver.h>
|
---|
[91173333] | 42 | #include <fibril_synch.h>
|
---|
[4317827] | 43 |
|
---|
[6c399765] | 44 | #include <usb/classes/hub.h>
|
---|
[b5ec347] | 45 |
|
---|
[7d521e24] | 46 | #include <usb/dev/pipes.h>
|
---|
| 47 | #include <usb/dev/driver.h>
|
---|
[71f211f] | 48 | #include <usb/dev/poll.h>
|
---|
[09daa8b] | 49 |
|
---|
[1e1b1a9] | 50 | #define NAME "usbhub"
|
---|
[3e490eb] | 51 |
|
---|
[a590a23] | 52 | #include "port.h"
|
---|
[c4e84ed6] | 53 | #include "status.h"
|
---|
[3e490eb] | 54 |
|
---|
[b5ec347] | 55 | /** Information about attached hub. */
|
---|
[6626bba9] | 56 | struct usb_hub_dev {
|
---|
[b5ec347] | 57 | /** Number of ports. */
|
---|
[3e490eb] | 58 | size_t port_count;
|
---|
[6626bba9] | 59 | /** Port structures, one for each port */
|
---|
[3e490eb] | 60 | usb_hub_port_t *ports;
|
---|
[129b821f] | 61 | /** Speed of the hub */
|
---|
| 62 | usb_speed_t speed;
|
---|
[983e135] | 63 | /** Generic usb device data*/
|
---|
| 64 | usb_device_t *usb_device;
|
---|
[71f211f] | 65 | /** Data polling handle. */
|
---|
[8b71f3e] | 66 | usb_polling_t polling;
|
---|
[d15797d] | 67 | /** Pointer to usbhub function. */
|
---|
[196fbb0] | 68 | ddf_fun_t *hub_fun;
|
---|
[c4e84ed6] | 69 | /** Device communication pipe. */
|
---|
| 70 | usb_pipe_t *control_pipe;
|
---|
[54d1ad9] | 71 | /** Hub supports port power switching. */
|
---|
| 72 | bool power_switched;
|
---|
| 73 | /** Each port is switched individually. */
|
---|
| 74 | bool per_port_power;
|
---|
[9f685aa] | 75 | /** Whether MTT is available */
|
---|
| 76 | bool mtt_available;
|
---|
[b79c31f9] | 77 | };
|
---|
[b5ec347] | 78 |
|
---|
[9f685aa] | 79 | extern const usb_endpoint_description_t *usb_hub_endpoints [];
|
---|
[bb70637] | 80 |
|
---|
[5a6cc679] | 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 *);
|
---|
[a209648] | 84 |
|
---|
[5a6cc679] | 85 | errno_t usb_hub_set_depth(const usb_hub_dev_t *);
|
---|
[ae3a941] | 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);
|
---|
[c4e84ed6] | 92 |
|
---|
| 93 | bool hub_port_changes_callback(usb_device_t *, uint8_t *, size_t, void *);
|
---|
[1e1b1a9] | 94 |
|
---|
[ae3a941] | 95 | errno_t usb_hub_reserve_default_address(usb_hub_dev_t *, async_exch_t *,
|
---|
| 96 | usb_port_t *);
|
---|
[5a6cc679] | 97 | errno_t usb_hub_release_default_address(usb_hub_dev_t *, async_exch_t *);
|
---|
[51a51be] | 98 |
|
---|
[4317827] | 99 | #endif
|
---|
[58563585] | 100 |
|
---|
[4317827] | 101 | /**
|
---|
| 102 | * @}
|
---|
| 103 | */
|
---|