102ac6454SAndrew Thompson /* $FreeBSD$ */ 202ac6454SAndrew Thompson /*- 302ac6454SAndrew Thompson * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 402ac6454SAndrew Thompson * 502ac6454SAndrew Thompson * Redistribution and use in source and binary forms, with or without 602ac6454SAndrew Thompson * modification, are permitted provided that the following conditions 702ac6454SAndrew Thompson * are met: 802ac6454SAndrew Thompson * 1. Redistributions of source code must retain the above copyright 902ac6454SAndrew Thompson * notice, this list of conditions and the following disclaimer. 1002ac6454SAndrew Thompson * 2. Redistributions in binary form must reproduce the above copyright 1102ac6454SAndrew Thompson * notice, this list of conditions and the following disclaimer in the 1202ac6454SAndrew Thompson * documentation and/or other materials provided with the distribution. 1302ac6454SAndrew Thompson * 1402ac6454SAndrew Thompson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1502ac6454SAndrew Thompson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1602ac6454SAndrew Thompson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1702ac6454SAndrew Thompson * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1802ac6454SAndrew Thompson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1902ac6454SAndrew Thompson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2002ac6454SAndrew Thompson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2102ac6454SAndrew Thompson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2202ac6454SAndrew Thompson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2302ac6454SAndrew Thompson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2402ac6454SAndrew Thompson * SUCH DAMAGE. 2502ac6454SAndrew Thompson */ 2602ac6454SAndrew Thompson 2775973647SAndrew Thompson #ifndef _USB_BUS_H_ 2875973647SAndrew Thompson #define _USB_BUS_H_ 2902ac6454SAndrew Thompson 3002ac6454SAndrew Thompson /* 31fde87526SAndrew Thompson * The following structure defines the USB explore message sent to the USB 32fde87526SAndrew Thompson * explore process. 3302ac6454SAndrew Thompson */ 3402ac6454SAndrew Thompson 35760bc48eSAndrew Thompson struct usb_bus_msg { 36760bc48eSAndrew Thompson struct usb_proc_msg hdr; 37760bc48eSAndrew Thompson struct usb_bus *bus; 3802ac6454SAndrew Thompson }; 3902ac6454SAndrew Thompson 4002ac6454SAndrew Thompson /* 4102ac6454SAndrew Thompson * The following structure defines the USB statistics structure. 4202ac6454SAndrew Thompson */ 43760bc48eSAndrew Thompson struct usb_bus_stat { 4402ac6454SAndrew Thompson uint32_t uds_requests[4]; 4502ac6454SAndrew Thompson }; 4602ac6454SAndrew Thompson 4702ac6454SAndrew Thompson /* 4802ac6454SAndrew Thompson * The following structure defines an USB BUS. There is one USB BUS 4902ac6454SAndrew Thompson * for every Host or Device controller. 5002ac6454SAndrew Thompson */ 51760bc48eSAndrew Thompson struct usb_bus { 52760bc48eSAndrew Thompson struct usb_bus_stat stats_err; 53760bc48eSAndrew Thompson struct usb_bus_stat stats_ok; 5402ac6454SAndrew Thompson struct root_hold_token *bus_roothold; 5502ac6454SAndrew Thompson /* 5602ac6454SAndrew Thompson * There are two callback processes. One for Giant locked 5702ac6454SAndrew Thompson * callbacks. One for non-Giant locked callbacks. This should 5802ac6454SAndrew Thompson * avoid congestion and reduce response time in most cases. 5902ac6454SAndrew Thompson */ 60760bc48eSAndrew Thompson struct usb_process giant_callback_proc; 61760bc48eSAndrew Thompson struct usb_process non_giant_callback_proc; 62672c9965SAndrew Thompson 63672c9965SAndrew Thompson /* Explore process */ 64760bc48eSAndrew Thompson struct usb_process explore_proc; 65672c9965SAndrew Thompson 66672c9965SAndrew Thompson /* Control request process */ 67760bc48eSAndrew Thompson struct usb_process control_xfer_proc; 68672c9965SAndrew Thompson 69760bc48eSAndrew Thompson struct usb_bus_msg explore_msg[2]; 70760bc48eSAndrew Thompson struct usb_bus_msg detach_msg[2]; 71760bc48eSAndrew Thompson struct usb_bus_msg attach_msg[2]; 7202ac6454SAndrew Thompson /* 7302ac6454SAndrew Thompson * This mutex protects the USB hardware: 7402ac6454SAndrew Thompson */ 7502ac6454SAndrew Thompson struct mtx bus_mtx; 76760bc48eSAndrew Thompson struct usb_xfer_queue intr_q; 77760bc48eSAndrew Thompson struct usb_callout power_wdog; /* power management */ 7802ac6454SAndrew Thompson 7902ac6454SAndrew Thompson device_t parent; 8002ac6454SAndrew Thompson device_t bdev; /* filled by HC driver */ 8102ac6454SAndrew Thompson 828755859aSAndrew Thompson #if USB_HAVE_BUSDMA 83760bc48eSAndrew Thompson struct usb_dma_parent_tag dma_parent_tag[1]; 84760bc48eSAndrew Thompson struct usb_dma_tag dma_tags[USB_BUS_DMA_TAG_MAX]; 858755859aSAndrew Thompson #endif 86760bc48eSAndrew Thompson struct usb_bus_methods *methods; /* filled by HC driver */ 87760bc48eSAndrew Thompson struct usb_device **devices; 8802ac6454SAndrew Thompson 89*e376f9c3SWeongyo Jeong struct ifnet *ifp; /* only for USB Packet Filter */ 9018ec6525SWeongyo Jeong 91e0a69b51SAndrew Thompson usb_power_mask_t hw_power_state; /* see USB_HW_POWER_XXX */ 92f9cb546cSAndrew Thompson usb_size_t uframe_usage[USB_HS_MICRO_FRAMES_MAX]; 93578d0effSAndrew Thompson 9402ac6454SAndrew Thompson uint16_t isoc_time_last; /* in milliseconds */ 9502ac6454SAndrew Thompson 9602ac6454SAndrew Thompson uint8_t alloc_failed; /* Set if memory allocation failed. */ 9702ac6454SAndrew Thompson uint8_t driver_added_refcount; /* Current driver generation count */ 988d2dd5ddSAndrew Thompson enum usb_revision usbrev; /* USB revision. See "USB_REV_XXX". */ 9902ac6454SAndrew Thompson 10002ac6454SAndrew Thompson uint8_t devices_max; /* maximum number of USB devices */ 10102ac6454SAndrew Thompson uint8_t do_probe; /* set if USB BUS should be re-probed */ 10202ac6454SAndrew Thompson 1037a918edfSAndrew Thompson /* 1047a918edfSAndrew Thompson * The scratch area can only be used inside the explore thread 1057a918edfSAndrew Thompson * belonging to the give serial bus. 1067a918edfSAndrew Thompson */ 10702ac6454SAndrew Thompson union { 108760bc48eSAndrew Thompson struct usb_hw_ep_scratch hw_ep_scratch[1]; 109760bc48eSAndrew Thompson struct usb_temp_setup temp_setup[1]; 1107a918edfSAndrew Thompson uint8_t data[255]; 11102ac6454SAndrew Thompson } scratch[1]; 11202ac6454SAndrew Thompson }; 11302ac6454SAndrew Thompson 11475973647SAndrew Thompson #endif /* _USB_BUS_H_ */ 115