usb_freebsd.h revision 267654
154359Sroberto/* $FreeBSD: releng/9.3/sys/dev/usb/usb_freebsd.h 261466 2014-02-04 08:44:33Z hselasky $ */
254359Sroberto/*-
354359Sroberto * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
454359Sroberto *
554359Sroberto * Redistribution and use in source and binary forms, with or without
654359Sroberto * modification, are permitted provided that the following conditions
754359Sroberto * are met:
854359Sroberto * 1. Redistributions of source code must retain the above copyright
954359Sroberto *    notice, this list of conditions and the following disclaimer.
1054359Sroberto * 2. Redistributions in binary form must reproduce the above copyright
1154359Sroberto *    notice, this list of conditions and the following disclaimer in the
1254359Sroberto *    documentation and/or other materials provided with the distribution.
1354359Sroberto *
1454359Sroberto * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1554359Sroberto * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1654359Sroberto * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1754359Sroberto * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1854359Sroberto * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1954359Sroberto * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2054359Sroberto * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2154359Sroberto * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2254359Sroberto * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23182007Sroberto * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24182007Sroberto * SUCH DAMAGE.
25182007Sroberto */
26285612Sdelphij
27285612Sdelphij/*
28285612Sdelphij * Including this file is mandatory for all USB related c-files in the kernel.
29285612Sdelphij */
30285612Sdelphij
31182007Sroberto#ifndef _USB_FREEBSD_H_
32182007Sroberto#define	_USB_FREEBSD_H_
33285612Sdelphij
34285612Sdelphij/* Default USB configuration */
35285612Sdelphij#define	USB_HAVE_UGEN 1
36285612Sdelphij#define	USB_HAVE_DEVCTL 1
37182007Sroberto#define	USB_HAVE_BUSDMA 1
38182007Sroberto#define	USB_HAVE_COMPAT_LINUX 1
39285612Sdelphij#define	USB_HAVE_USER_IO 1
40182007Sroberto#define	USB_HAVE_MBUF 1
41182007Sroberto#define	USB_HAVE_TT_SUPPORT 1
42182007Sroberto#define	USB_HAVE_POWERD 1
43285612Sdelphij#define	USB_HAVE_MSCTEST 1
44285612Sdelphij#define	USB_HAVE_PF 1
45285612Sdelphij
4654359Sroberto/* define zero ticks callout value */
4754359Sroberto#define	USB_CALLOUT_ZERO_TICKS 1
4854359Sroberto
4954359Sroberto#define	USB_TD_GET_PROC(td) (td)->td_proc
5054359Sroberto#define	USB_PROC_GET_GID(td) (td)->p_pgid
5154359Sroberto
5254359Sroberto#if (!defined(USB_HOST_ALIGN)) || (USB_HOST_ALIGN <= 0)
5354359Sroberto/* Use default value. */
5454359Sroberto#undef USB_HOST_ALIGN
5554359Sroberto#define	USB_HOST_ALIGN    8		/* bytes, must be power of two */
5654359Sroberto#endif
5754359Sroberto/* Sanity check for USB_HOST_ALIGN: Verify power of two. */
5854359Sroberto#if ((-USB_HOST_ALIGN) & USB_HOST_ALIGN) != USB_HOST_ALIGN
5954359Sroberto#error "USB_HOST_ALIGN is not power of two."
6082498Sroberto#endif
6182498Sroberto#define	USB_FS_ISOC_UFRAME_MAX 4	/* exclusive unit */
6282498Sroberto#define	USB_BUS_MAX 256			/* units */
6382498Sroberto#define	USB_MAX_DEVICES 128		/* units */
6454359Sroberto#define	USB_IFACE_MAX 32		/* units */
6554359Sroberto#define	USB_FIFO_MAX 128		/* units */
6654359Sroberto
6754359Sroberto#define	USB_MAX_FS_ISOC_FRAMES_PER_XFER (120)	/* units */
6854359Sroberto#define	USB_MAX_HS_ISOC_FRAMES_PER_XFER (8*120)	/* units */
6954359Sroberto
7054359Sroberto#define	USB_HUB_MAX_DEPTH	5
7154359Sroberto#define	USB_EP0_BUFSIZE		1024	/* bytes */
7254359Sroberto#define	USB_CS_RESET_LIMIT	20	/* failures = 20 * 50 ms = 1sec */
7354359Sroberto
7454359Sroberto#define	USB_MAX_AUTO_QUIRK	4	/* maximum number of dynamic quirks */
7554359Sroberto
7654359Srobertotypedef uint32_t usb_timeout_t;		/* milliseconds */
7754359Srobertotypedef uint32_t usb_frlength_t;	/* bytes */
7854359Srobertotypedef uint32_t usb_frcount_t;		/* units */
7954359Srobertotypedef uint32_t usb_size_t;		/* bytes */
8054359Srobertotypedef uint32_t usb_ticks_t;		/* system defined */
8154359Srobertotypedef uint16_t usb_power_mask_t;	/* see "USB_HW_POWER_XXX" */
8254359Sroberto
8354359Sroberto#endif	/* _USB_FREEBSD_H_ */
84182007Sroberto