1194677Sthompsa/* $FreeBSD: stable/11/sys/dev/usb/usb_freebsd.h 363665 2020-07-29 14:33:31Z markj $ */ 2194677Sthompsa/*- 3194677Sthompsa * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 4194677Sthompsa * 5194677Sthompsa * Redistribution and use in source and binary forms, with or without 6194677Sthompsa * modification, are permitted provided that the following conditions 7194677Sthompsa * are met: 8194677Sthompsa * 1. Redistributions of source code must retain the above copyright 9194677Sthompsa * notice, this list of conditions and the following disclaimer. 10194677Sthompsa * 2. Redistributions in binary form must reproduce the above copyright 11194677Sthompsa * notice, this list of conditions and the following disclaimer in the 12194677Sthompsa * documentation and/or other materials provided with the distribution. 13194677Sthompsa * 14194677Sthompsa * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15194677Sthompsa * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16194677Sthompsa * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17194677Sthompsa * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18194677Sthompsa * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19194677Sthompsa * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20194677Sthompsa * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21194677Sthompsa * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22194677Sthompsa * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23194677Sthompsa * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24194677Sthompsa * SUCH DAMAGE. 25194677Sthompsa */ 26194677Sthompsa 27194677Sthompsa/* 28194677Sthompsa * Including this file is mandatory for all USB related c-files in the kernel. 29194677Sthompsa */ 30194677Sthompsa 31194677Sthompsa#ifndef _USB_FREEBSD_H_ 32194677Sthompsa#define _USB_FREEBSD_H_ 33194677Sthompsa 34194677Sthompsa/* Default USB configuration */ 35194677Sthompsa#define USB_HAVE_UGEN 1 36214221Shselasky#define USB_HAVE_DEVCTL 1 37194677Sthompsa#define USB_HAVE_BUSDMA 1 38194677Sthompsa#define USB_HAVE_COMPAT_LINUX 1 39194677Sthompsa#define USB_HAVE_USER_IO 1 40194677Sthompsa#define USB_HAVE_MBUF 1 41194677Sthompsa#define USB_HAVE_TT_SUPPORT 1 42194677Sthompsa#define USB_HAVE_POWERD 1 43194677Sthompsa#define USB_HAVE_MSCTEST 1 44266884Shselasky#define USB_HAVE_MSCTEST_DETACH 1 45217558Shselasky#define USB_HAVE_PF 1 46246122Shselasky#define USB_HAVE_ROOT_MOUNT_HOLD 1 47246194Shselasky#define USB_HAVE_ID_SECTION 1 48246363Shselasky#define USB_HAVE_PER_BUS_PROCESS 1 49250204Shselasky#define USB_HAVE_FIXED_ENDPOINT 0 50250204Shselasky#define USB_HAVE_FIXED_IFACE 0 51250207Shselasky#define USB_HAVE_FIXED_CONFIG 0 52250207Shselasky#define USB_HAVE_FIXED_PORT 0 53272733Shselasky#define USB_HAVE_DISABLE_ENUM 1 54363665Smarkj#define USB_HAVE_MALLOC_WAITOK 1 55194677Sthompsa 56261005Shselasky/* define zero ticks callout value */ 57261005Shselasky#define USB_CALLOUT_ZERO_TICKS 1 58261005Shselasky 59194677Sthompsa#define USB_TD_GET_PROC(td) (td)->td_proc 60194677Sthompsa#define USB_PROC_GET_GID(td) (td)->p_pgid 61194677Sthompsa 62217793Shselasky#if (!defined(USB_HOST_ALIGN)) || (USB_HOST_ALIGN <= 0) 63217793Shselasky/* Use default value. */ 64217718Shselasky#undef USB_HOST_ALIGN 65250753Simp#if defined(__arm__) || defined(__mips__) || defined(__powerpc__) 66250753Simp#define USB_HOST_ALIGN 32 /* Arm and MIPS need at least this much, if not more */ 67250753Simp#else 68194677Sthompsa#define USB_HOST_ALIGN 8 /* bytes, must be power of two */ 69217718Shselasky#endif 70250753Simp#endif 71217793Shselasky/* Sanity check for USB_HOST_ALIGN: Verify power of two. */ 72217793Shselasky#if ((-USB_HOST_ALIGN) & USB_HOST_ALIGN) != USB_HOST_ALIGN 73217793Shselasky#error "USB_HOST_ALIGN is not power of two." 74217793Shselasky#endif 75194677Sthompsa#define USB_FS_ISOC_UFRAME_MAX 4 /* exclusive unit */ 76194677Sthompsa#define USB_BUS_MAX 256 /* units */ 77194677Sthompsa#define USB_MAX_DEVICES 128 /* units */ 78250204Shselasky#define USB_CONFIG_MAX 65535 /* bytes */ 79194677Sthompsa#define USB_IFACE_MAX 32 /* units */ 80194677Sthompsa#define USB_FIFO_MAX 128 /* units */ 81239214Shselasky#define USB_MAX_EP_STREAMS 8 /* units */ 82250204Shselasky#define USB_MAX_EP_UNITS 32 /* units */ 83250207Shselasky#define USB_MAX_PORTS 255 /* units */ 84194677Sthompsa 85194677Sthompsa#define USB_MAX_FS_ISOC_FRAMES_PER_XFER (120) /* units */ 86194677Sthompsa#define USB_MAX_HS_ISOC_FRAMES_PER_XFER (8*120) /* units */ 87194677Sthompsa 88194677Sthompsa#define USB_HUB_MAX_DEPTH 5 89194677Sthompsa#define USB_EP0_BUFSIZE 1024 /* bytes */ 90222786Shselasky#define USB_CS_RESET_LIMIT 20 /* failures = 20 * 50 ms = 1sec */ 91194677Sthompsa 92277044Shselasky#define USB_MAX_AUTO_QUIRK 8 /* maximum number of dynamic quirks */ 93225350Shselasky 94194677Sthompsatypedef uint32_t usb_timeout_t; /* milliseconds */ 95194677Sthompsatypedef uint32_t usb_frlength_t; /* bytes */ 96194677Sthompsatypedef uint32_t usb_frcount_t; /* units */ 97194677Sthompsatypedef uint32_t usb_size_t; /* bytes */ 98194677Sthompsatypedef uint32_t usb_ticks_t; /* system defined */ 99194677Sthompsatypedef uint16_t usb_power_mask_t; /* see "USB_HW_POWER_XXX" */ 100239214Shselaskytypedef uint16_t usb_stream_t; /* stream ID */ 101194677Sthompsa 102194677Sthompsa#endif /* _USB_FREEBSD_H_ */ 103