usb_freebsd.h revision 239214
1194677Sthompsa/* $FreeBSD: head/sys/dev/usb/usb_freebsd.h 239214 2012-08-12 17:53:06Z hselasky $ */
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
44217558Shselasky#define	USB_HAVE_PF 1
45194677Sthompsa
46194677Sthompsa#define	USB_TD_GET_PROC(td) (td)->td_proc
47194677Sthompsa#define	USB_PROC_GET_GID(td) (td)->p_pgid
48194677Sthompsa
49217793Shselasky#if (!defined(USB_HOST_ALIGN)) || (USB_HOST_ALIGN <= 0)
50217793Shselasky/* Use default value. */
51217718Shselasky#undef USB_HOST_ALIGN
52194677Sthompsa#define	USB_HOST_ALIGN    8		/* bytes, must be power of two */
53217718Shselasky#endif
54217793Shselasky/* Sanity check for USB_HOST_ALIGN: Verify power of two. */
55217793Shselasky#if ((-USB_HOST_ALIGN) & USB_HOST_ALIGN) != USB_HOST_ALIGN
56217793Shselasky#error "USB_HOST_ALIGN is not power of two."
57217793Shselasky#endif
58194677Sthompsa#define	USB_FS_ISOC_UFRAME_MAX 4	/* exclusive unit */
59194677Sthompsa#define	USB_BUS_MAX 256			/* units */
60194677Sthompsa#define	USB_MAX_DEVICES 128		/* units */
61194677Sthompsa#define	USB_IFACE_MAX 32		/* units */
62194677Sthompsa#define	USB_FIFO_MAX 128		/* units */
63239214Shselasky#define	USB_MAX_EP_STREAMS 8		/* units */
64194677Sthompsa
65194677Sthompsa#define	USB_MAX_FS_ISOC_FRAMES_PER_XFER (120)	/* units */
66194677Sthompsa#define	USB_MAX_HS_ISOC_FRAMES_PER_XFER (8*120)	/* units */
67194677Sthompsa
68194677Sthompsa#define	USB_HUB_MAX_DEPTH	5
69194677Sthompsa#define	USB_EP0_BUFSIZE		1024	/* bytes */
70222786Shselasky#define	USB_CS_RESET_LIMIT	20	/* failures = 20 * 50 ms = 1sec */
71194677Sthompsa
72225350Shselasky#define	USB_MAX_AUTO_QUIRK	4	/* maximum number of dynamic quirks */
73225350Shselasky
74194677Sthompsatypedef uint32_t usb_timeout_t;		/* milliseconds */
75194677Sthompsatypedef uint32_t usb_frlength_t;	/* bytes */
76194677Sthompsatypedef uint32_t usb_frcount_t;		/* units */
77194677Sthompsatypedef uint32_t usb_size_t;		/* bytes */
78194677Sthompsatypedef uint32_t usb_ticks_t;		/* system defined */
79194677Sthompsatypedef uint16_t usb_power_mask_t;	/* see "USB_HW_POWER_XXX" */
80239214Shselaskytypedef uint16_t usb_stream_t;		/* stream ID */
81194677Sthompsa
82194677Sthompsa#endif	/* _USB_FREEBSD_H_ */
83