Commit Graph

90 Commits

Author SHA1 Message Date
Hans Petter Selasky
e892b3fe36 USB method structures for USB controllers and USB pipes should be
constant and does not need to be modified. This also saves a small
amount of RAM.
2013-12-11 13:20:32 +00:00
Hans Petter Selasky
7b0866b032 Make use of USB ID sections configurable. 2013-02-01 07:05:43 +00:00
Hans Petter Selasky
d2b99310b1 Modify the FreeBSD USB kernel code so that it can be compiled directly
into the FreeBSD boot loader, typically for non-USB aware BIOSes, EFI systems
or embedded platforms. This is also useful for out of the system compilation
of the FreeBSD USB stack for various purposes. The USB kernel files can
now optionally include a global header file which should include all needed
definitions required to compile the FreeBSD USB stack. When the global USB
header file is included, no other USB header files will be included by
default.

Add new file containing the USB stack configuration for the
FreeBSD loader build.

Replace some __FBSDID()'s by /* $FreeBSD$ */ comments. Now all
USB files follow the same style.

Use cases:
 - console in loader via USB
 - loading kernel via USB

Discussed with:		Hiroki Sato, hrs @ EuroBSDCon
2013-01-30 15:26:04 +00:00
Hans Petter Selasky
a6d2f40ec8 Allocate separate USB buffers for DMA'ed data, so that
DMA data does not reside next to non DMA data. This
might cause more memory to be allocated, but solves
problems on platforms using manual cache
synchronization.

Add a convenience function to get the buffer only
from a USB transfer's page cache structure.

MFC after:	1 week
Suggested by:	imp
2012-12-20 18:13:37 +00:00
Hans Petter Selasky
a5cf1aaaff Add support for the so-called streams feature of BULK endpoints
in SUPER-speed mode, USB 3.0.

This feature has not been tested yet, due to lack of hardware.

This feature is useful when implementing protocols like UASP,
USB attached SCSI which promises higher USB mass storage throughput.

This patch also implements support for hardware processing of endpoints
for increased performance. The switching to hardware processing
of an endpoint is done via a callback to the USB controller driver. The
stream feature is implemented like a variant of a hardware USB protocol.

USB controller drivers implementing device mode needs to be updated to
implement the new "xfer_stall" USB controller method and remove the
"xfer" argument from the "set_stall" method.

The API's toward existing USB drivers are preserved. To setup a USB transfer
in stream mode, set the "stream_id" field of the USB config structure to
the desired value.

The maximum number of BULK streams is currently hardcoded and limited to 8
via a define in usb_freebsd.h.

All USB drivers should be re-compiled after this change.

LibUSB will be updated next week to support streams mode. A new IOCTL to
setup BULK streams as already been implemented. The ugen device nodes
currently only supports stream ID zero.

The FreeBSD version has been bumped.

MFC after:	2 weeks
2012-08-12 17:53:06 +00:00
Hans Petter Selasky
6d917491f5 Fix compiler warnings, mostly signed issues,
when USB modules are compiled with WARNS=9.

MFC after:	1 weeks
2012-04-02 10:50:42 +00:00
Hans Petter Selasky
3f37fb622c Refactor auto-quirk solution so that we break as few external
drivers as possible.

PR:		usb/160299
Approved by:	re (kib)
Suggested by:	rwatson
MFC after:	0 days
2011-09-10 15:55:36 +00:00
Hans Petter Selasky
d46dc4ad74 This patch adds automatic detection of USB mass storage devices
which does not support the no synchronize cache SCSI command.

The __FreeBSD_version version macro has been bumped and
external kernel modules needs to be recompiled after
this patch.

Approved by:    re (kib)
MFC after:      1 week
PR:		usb/160299
2011-09-02 18:50:44 +00:00
Hans Petter Selasky
2ffd5fdcc4 Use synchronous device destruction instead of asynchronous, so that a new
device having the same name like a previous one is not created before the old
one is gone. This fixes some panics due to asserts in the devfs code which
were added recently.

Approved by:    re (kib)
MFC after:      1 week
2011-08-11 11:30:21 +00:00
Hans Petter Selasky
1d63770b39 - Export the USB device ID format to userspace tools.
MFC after:	14 days
2011-06-25 15:51:44 +00:00
Hans Petter Selasky
f1a16106b6 - Move all USB device ID arrays into so-called sections,
sorted according to the mode which they support:
	host, device or dual mode
- Add generic tool to extract these data:
	tools/bus_autoconf

Discussed with:	imp
Suggested by:	Robert Millan <rmh@debian.org>
PR:		misc/157903
MFC after:	14 days
2011-06-24 02:30:02 +00:00
Hans Petter Selasky
9eb0d7025d Improve enumeration of Low- and Full-speed devices connected through a
High-speed USB HUB by resetting the transaction translator (TT)
before trying re-enumeration. Also when clear-stall fails multiple times
try a re-enumeration.

Suggested by:	Trevor Blackwell
MFC after:	14 days
2011-06-06 21:45:09 +00:00
Andriy Gapon
cd10bffa61 usb: change to one-pass probing of device drivers
This brings USB bus more in line with how newbus is supposed to be used.
Also, because of the two-pass probing the following message was produced
by devd in default configuration when almost any USB device was
connected:
	Unknown USB device: vendor <> product <> bus <>
This should be fixed now.

Note that many USB device drivers pass some information from probe
method to attach method via ivars.  For this to continue working we rely
on the fact that the subr_bus code calls probe method of a winning driver
again before calling its attach method in the case where multiple
drivers claim to support a device.  This is done because device
description is set in successful probe methods and we want to get a correct
device description from a winning driver.  So now this logic is re-used
for setting ivars too.

Reviewed by:	hselasky
MFC after:	1 month
2011-05-18 07:40:12 +00:00
Hans Petter Selasky
31a1169186 - Improvements to USB PF solution
- Add more fields for USB device and host mode
- Add more information to USB PF header so that decoding
  can easily be done by software analyzer tools like
  Wireshark.
- Optimise usbdump to display USB streams in text format
  more efficiently.
- Software using USB PF must be recompiled after
  this commit, due to structure changes.

MFC after:	7 days
Approved by:	thompsa (mentor)
2011-04-03 20:03:45 +00:00
Hans Petter Selasky
1c49736857 - Add support for software pre-scaling of ISOCHRONOUS transfers.
MFC after:	14 days
Approved by:	thompsa (mentor)
2011-02-28 17:23:15 +00:00
Hans Petter Selasky
8427ed847d Add support for setting per-interface PnP information.
Submitted by:	Nick Hibma
Approved by:	thompsa (mentor)
2010-10-27 17:38:05 +00:00
Hans Petter Selasky
963169b4af This commit adds full support for USB 3.0 devices in host and device
mode in the USB core.  The patch mostly consists of updating the USB
HUB code to support USB 3.0 HUBs. This patch also add some more USB
controller methods to support more active-alike USB controllers like
the XHCI which needs to be informed about various device state events.

USB 3.0 HUBs are not tested yet, due to lack of hardware, but are
believed to work.

After this update the initial device descriptor is only read twice
when we know that the bMaxPacketSize is too small for a single packet
transfer of this descriptor.

Approved by:    thompsa (mentor)
2010-10-04 23:18:05 +00:00
Andrew Thompson
d2d71ce7a8 Add support for power mode filtering as some USB hardware does not support
power saving.

Submitted by:	Hans Petter Selasky
2010-09-02 04:05:00 +00:00
Andrew Thompson
2a4c6157ca Use the EVENTHANDLER system to hook into the usb device configuration and
perform a function such as ejecting a 3G autoinstaller disk. The eventhandler
system properly tracks threads and is safe to unload, remove the
setting/clearing of a function pointer in the kernel by u3g(4) which included a
tsleep for safety.
2009-12-17 21:42:10 +00:00
Andrew Thompson
f12c6c2913 Improve High Speed slot allocation mechanism by moving the computation to the
endpoint rather than per xfer and provide functions around get/free of resources.

Submitted by:	Hans Petter Selasky
2009-11-22 21:16:43 +00:00
Andrew Thompson
883bb30022 improve support for high speed isochronous endpoints which does not run 1:1,
but needs intervalling 1:2, 1:4 or 1:8

Submitted by:	Hans Petter Selasky
2009-11-08 20:54:03 +00:00
Alfred Perlstein
9e90dc16ba Missed this file for r195963:
USB core:
  - add support for defragging of written device data.
  - improve handling of alternate settings in device side mode.
  - correct return value from usbd_get_no_alts() function.
  - reported by: HPS
  - P4 ID: 166156, 166168

  - report USB device release information to devd and pnpinfo.
  - reported by: MIHIRA Sanpei Yoshiro
  - P4 ID: 166221

Submitted by:	hps
Approved by:	re
2009-07-30 00:57:54 +00:00
Andrew Thompson
29bd7d7e9a Sync to p4
- Add support for devices that handle set and clear stall in hardware.
 - Add missing get timestamp function
 - Add more xfer flags

Submitted by:	Hans Petter Selasky
Approved by:	re (kib)
2009-06-27 21:23:30 +00:00
Andrew Thompson
8f9e0ef947 Fix a typeo in the frame len function to unbreak the build, make it shorter
while I am here.
2009-06-23 06:00:31 +00:00
Andrew Thompson
ed6d949afd - Make struct usb_xfer opaque so that drivers can not access the internals
- Reduce the number of headers needed for a usb driver, the common case is just   usb.h and usbdi.h
2009-06-23 02:19:59 +00:00
Andrew Thompson
3975e3a1ea Move usb to a graveyard location under sys/legacy/dev, it is intended that the
new USB2 stack will fully replace this for 8.0.

Remove kernel modules, a subsequent commit will update conf/files. Unhook
usbdevs from the build.
2009-02-23 18:16:17 +00:00
Sam Leffler
d212022417 Merge WIP from p4:
o recognize ixp435 cpu
o change memory layout for for ixp4xx to not assume memory is aliases
  to 0x10000000 (Cambria/ixp435 memory starts at zero)
o handle 64 irqs for ixp435
o dual EHCI USB 2.0 controller integral to ixp435
o overhaul NPE code for ixp435 and better MAC+MII naming
o updated NPE firmware (including NPE-A image for ixp435/ixp465)
o Gateworks Cambria board support:
  - IDE compact flash
  - MCU
  - front panel LED on i2c bus
  - Octal LED latch

Sanity-tested with NFS-root on Avila and Cambria boards.  Requires
pending boot2 mods for CF-boot on Cambria.
2008-12-13 01:21:37 +00:00
Nick Hibma
ab72d59941 Add a reset device command to ugen.c.
This is needed to make some devices work that require a firmware upload
and a USB reset afterwards.
2008-11-13 21:34:34 +00:00
Sam Leffler
9f55d2bb94 add support for %b printing of request + xfer flags 2008-03-20 03:09:59 +00:00
Warner Losh
c78c2f1bd2 Fix two more PRs:
(1) Add size parameter to usbd_get_string()
(2) Properly limit speed when a full speed hub is plugged into a high
    speed hub.

Submitted by: Hans Petter Selasky
PR: 80773, 79725
Approved by: re@ (kensmith)
2007-06-30 20:18:44 +00:00
Warner Losh
9ab3a4add1 First pass at removing __OtherBSD__. We can't blindly remove all of
them in bulk because there is at least one feature that's
unimplemented on FreeBSD that needs to be done and these are good
placeholders.
2007-06-12 19:40:20 +00:00
Ian Dowse
9145721957 Use a different task queue for host controller and peripheral driver
tasks. Since the host controllers rely on tasks to process transfer
timeouts, if a synchronous transfer from a driver was invoked from
a task and timed out, it would never complete because the single
task thread was stuck performing the synchronous transfer so couldn't
process the timeout.

This affected the axe, udav and ural drivers.

Problem hardware provided by:	guido
2006-10-19 01:15:58 +00:00
Warner Losh
56635f6bd3 s/Static/static/g
s/device_ptr_t/device_t/g

No md5 changes in the .o's

# Note to the md5 tracking club: $FreeBSD$ changes md5 after every commit
# so you need to checkout -kk to get $FreeBSD$ instead of the actual value
# of the keyword.
2006-09-06 23:44:25 +00:00
Warner Losh
ce86397a98 Add convenience functions to get port and interface. 2005-05-16 06:58:43 +00:00
Maxim Sobolev
ddbcc78273 Add /* _FOO_H_ */ after the final #endif to make danfe happy. 2005-03-25 13:22:58 +00:00
Maxim Sobolev
87fcbb8fe0 Protect against multiple inclusions. 2005-03-25 12:49:26 +00:00
Maxim Sobolev
21a69c81c0 Merge from NetBSD.
o usb_subr.c, add delta 1.119:

  Move usb_get_string() and make it public.

o usbdi.c, bring on par with 1.106, this includes:

  - Make an iterator abstraction for looping through all descriptors.

  - Whine about not being able to figure out default language if we are debugging.

  - Move usb_get_string() and make it public.

o usbdi.h, bring on par with 1.64, this includes:

  - Make an iterator abstraction for looping through all descriptors.

  - Move usb_get_string() and make it public.

o usbdi_util.c, bring on par with 1.42, this includes:

  - Add usbd_get_protocol().

  - Use NULL instead of 0.

  - Fix (mostly harmless) typo.

  - Move utility routine from uirda.c to usbdi_util.c.

o usbdi_util.h, bring on par with 1.31, this includes:

  - Add usbd_get_protocol().

  - Move utility routine from uirda.c to usbdi_util.c.

MFC after:	3 days
2005-03-01 08:01:22 +00:00
Ian Dowse
d83604e89a Add a new function usbd_abort_default_pipe() that aborts any transfers
on the default pipe. This is helpful in device detach routines to
stop any active control transfers.
2005-02-14 01:51:51 +00:00
Ian Dowse
a66e65f5a9 When attached to a high-speed device, report a more appropriate
base transfer speed to CAM. The actual value used (40MB/s) is fairly
arbitrary, but assumes the same 33% overhead as was implied by the
1MB/s figure we used for USB1 devices.
2005-02-13 21:38:34 +00:00
Warner Losh
098ca2bda9 Start each of the license/copyright comments with /*-, minor shuffle of lines 2005-01-06 01:43:34 +00:00
Julian Elischer
1cc7d59e34 Might as well get the right $NetBSD$ string while we are at it.
MFC after:	1 week
2004-12-13 08:12:06 +00:00
Julian Elischer
cd015c5e87 Diff reduction to NetBSD.
Now only things that are different between us and NetBSD show up.
Means that these files are more of NetBSD style in some places but
since thay are NetBSD files, um, that's ok.

Obtained from:	NetBSD
MFC after: 1 week
2004-12-13 08:08:57 +00:00
Warner Losh
1ff2328528 Tweak the compatibility macros a little so that the device printing is
moved into them.
2004-08-15 23:39:18 +00:00
Poul-Henning Kamp
c9c7976f7f Device megapatch 1/6:
Free approx 86 major numbers with a mostly automatically generated patch.

A number of strategic drivers have been left behind by caution, and a few
because they still (ab)use their major number.
2004-02-21 19:42:58 +00:00
Josef Karthauser
094fb32de7 Update to reflect the NetBSD patches that are already included. 2003-07-14 20:31:03 +00:00
John-Mark Gurney
c97325b0c8 WARNING: white space diff
This code reduces the number of trailing white space to be more in line
w/ NetBSD.  I don't regenerate usbdevs, saving that for when it really
changes.
2003-07-04 01:50:39 +00:00
Josef Karthauser
567f4af63d MFNetBSD: ugen.c (1.57), ulpt.c (1.48), usb.c (1.67), usbdi.c (1.96),
usbdi.h (1.60)
	  (and local changes compatibility changes to ufm.c and urio.c)

    date: 2002/02/11 15:11:49;  author: augustss;
    Give usbd_do_request_flags() an extra argument for the timeout.
2002-05-06 18:23:36 +00:00
Josef Karthauser
3aebbbbc02 Update $NetBSD$ idents. 2002-04-07 17:02:25 +00:00
Josef Karthauser
7c21b0290d MFNetBSD: ukbd.c (1.52), usbdi.c (1.54), usbdi.h (1.35)
date: 2000/01/16 09:37:18;  author: augustss;
    Let usbd_set_polling() work on a usbd_device_handle instead of
    a usbd_interface_handle.
2002-04-07 13:16:18 +00:00
Josef Karthauser
58af1b84da MFNetBSD: usbdi.c (1.93), usbdi.h (1.59)
date: 2001/12/24 21:36:15;  author: augustss;
    Add some more DIAGNOSTIC tests.
    Make usb_match_device() match on USB_PRODUCT_ANY.
2002-04-07 12:42:18 +00:00