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