Commit Graph

411 Commits

Author SHA1 Message Date
Ruslan Bukin
ead1785e1e Declare dwc_otg_detach as non-static (same as dwc_otg_attach),
so it can be called from fdt-glue drivers.

Submitted by:	kan
Sponsored by:	DARPA, AFRL
2016-11-17 15:12:03 +00:00
Ruslan Bukin
cec8009ca1 Allow operation with UTMI+ phy.
Submitted by:	kan
Sponsored by:	DARPA, AFRL
2016-11-17 15:08:30 +00:00
Alexander Motin
2b064d4653 Add some device IDs found in my new laptop. 2016-11-09 08:57:59 +00:00
Hans Petter Selasky
d3bf5efc1f Fix device delete child function.
When detaching device trees parent devices must be detached prior to
detaching its children. This is because parent devices can have
pointers to the child devices in their softcs which are not
invalidated by device_delete_child(). This can cause use after free
issues and panic().

Device drivers implementing trees, must ensure its detach function
detaches or deletes all its children before returning.

While at it remove now redundant device_detach() calls before
device_delete_child() and device_delete_children(), mostly in
the USB controller drivers.

Tested by:		Jan Henrik Sylvester <me@janh.de>
Reviewed by:		jhb
Differential Revision:	https://reviews.freebsd.org/D8070
MFC after:		2 weeks
2016-10-17 10:20:38 +00:00
Oleksandr Tymoshenko
bf798f819a Make BCM28x USB driver compatible with upstream device tree
This should have been committed in r307093: resource allocation depends
on source of the device tree. upstream dts has extra interrupt that we can
ignore
2016-10-12 03:36:46 +00:00
Hans Petter Selasky
f81d0b43f1 Don't separate the status stage of the XHCI USB control transfers into
its own job because this breaks the simplified QEMU XHCI TRB parser,
which expects the complete USB control transfer as a series of back to
back TRBs. The old behaviour is kept under #ifdef in case this change
breaks enumeration of any USB devices.

PR:		212021
MFC after:	1 week
2016-08-22 19:32:50 +00:00
Hans Petter Selasky
7816434a4f Fix for invalid use of bits in input context. Basically split
configuring of EP0 and non-EP0 into xhci_cmd_evaluate_ctx() and
xhci_cmd_configure_ep() respectivly. This resolves some errors when
using XHCI under QEMU and gets is more in line with the XHCI
specification.

PR:		212021
MFC after:	1 week
2016-08-22 10:21:25 +00:00
Pedro F. Giffuni
f0be707d74 sys/dev: replace comma with semicolon when pertinent.
Uses of commas instead of a semicolons can easily go undetected. The comma
can serve as a statement separator but this shouldn't be abused when
statements are meant to be standalone.

Detected with devel/coccinelle following a hint from DragonFlyBSD.

MFC after:	1 month
2016-08-09 19:41:46 +00:00
Andrew Turner
eda295b9e5 Add a generic EHCI USB driver based on the Allwinner A10 driver. It is ACPI
only for now, but wouldn't be too difficult to add support for FDT.

Reviewed by:	hselasky
Obtained from:	ABT Systems Ltd
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D7352
2016-07-29 08:50:36 +00:00
Michal Meloun
dac935533b EXTRES: Add OF node as argument to all <foo>_get_by_ofw_<bar>() functions.
In some cases, the driver must handle given properties located in
specific OF subnode. Instead of creating duplicate set of function, add
'node' as argument to existing functions, defaulting it to device OF node.

MFC after: 3 weeks
2016-07-10 18:28:15 +00:00
Hans Petter Selasky
c5390e5ab4 Fix regression issue with XHCI on 32-bit ARMv7 Armada-38x. Make sure
"struct xhci_dev_ctx_addr" fits into a single 4K page until further.

Approved by:	re (hrs)
MFC after:	1 week
2016-07-06 10:57:04 +00:00
Hans Petter Selasky
e4d1732068 Fix interrupt loop when switching from USB device to USB host mode by
clearing all endpoint interrupt bits.

PR:		210736
Approved by:	re (glebius)
MFC after:	1 week
2016-07-04 17:12:22 +00:00
Hans Petter Selasky
2d8904583c Fix detection of USB device disconnects in USB host mode when the USB
device is connected directly to the USB port of the DWC OTG, in this
case a RPI-zero.

PR:		210695
Approved by:	re (gjb)
MFC after:	1 week
2016-07-01 07:27:33 +00:00
Hans Petter Selasky
bbd41717f0 Update the definition for number of scratch pages to match the latest
version of the XHCI specification. Make sure the code can handle the
maximum number of allowed scratch pages.

Submitted by:	Shichun_Ma@Dell.com
Approved by:	re (hrs)
MFC after:	1 week
2016-06-22 09:03:55 +00:00
Jared McNeill
627c360fa7 Enable USB PHY regulators when requested by the host controller driver.
Previously the USB PHY driver would enable all regulators at attach time.
This prevented boards from booting when powered by the USB OTG port, as
it didn't take VBUS presence into consideration.
2016-05-26 10:50:39 +00:00
Hans Petter Selasky
6e2392aea4 Fix bad sizeof().
Submitted by:	David Binderman <dcb314@hotmail.com>
PR:	209636
2016-05-19 11:02:39 +00:00
Emmanuel Vadot
d71896a76a Add driver for "generic-ohci" as defined by FDT.
If platform support EXT_RESOURCES, clocks and resets are handled out of
the box.
If not driver can be subclassed using the generic_usb interface.
generic_usb name was choosed because at one point I'll add generic-ehci
FDT driver.

Reviewed by:	jmcneill, hselasky
Approved by:	andrew (mentor)
Differential Revision:	https://reviews.freebsd.org/D5481
2016-05-17 17:46:12 +00:00
Oleksandr Tymoshenko
27b917c85e Use OF_prop_free instead of direct call to free(9) 2016-05-14 18:44:30 +00:00
Alexander Motin
71733a504f Add some device IDs from Intel Sunrise Point chipsets.
MFC after:	2 weeks
2016-05-03 15:27:47 +00:00
Pedro F. Giffuni
207332450e dev/usb: minor spelling fixes in comments.
No functional change.

Reviewed by:	hselasky
2016-05-02 17:44:03 +00:00
Pedro F. Giffuni
057b4402bf sys/dev: extend use of the howmany() macro when available.
We have a howmany() macro in the <sys/param.h> header that is
convenient to re-use as it makes things easier to read.
2016-04-26 15:03:15 +00:00
Oleksandr Tymoshenko
e2bb79f70f Remove misleading comment. musb supports host mode for more than two years now
Spotted by: jmcneill
2016-04-05 18:07:13 +00:00
Michal Meloun
c520cb4f50 ehci_interrupt is MPSAFE code. Most drivers in tree calls bus_setup_intr
with MPSAFE, some are not. Fix those.

Submitted by: Howard Su <howard0su@gmail.com>
Differential Revision: https://reviews.freebsd.org/D5755
2016-04-05 12:13:53 +00:00
Alexander Motin
15e01a35e1 Add some device IDs found on AMD FCH shipsets.
MFC after:	2 weeks
2016-03-29 12:50:42 +00:00
Hans Petter Selasky
6227e59635 Add more UHCI PCI IDs.
Submitted by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
2016-03-24 09:35:29 +00:00
Alexander Motin
cb6b0ad147 Add IDs for Intel Wellsburg USB controllers.
MFC after:	1 week
2016-03-19 09:20:18 +00:00
Wojciech Macek
9147c9b8b2 Add xhci_mv.c
Add missing xhci driver for Marvell systems.

Submitted by:          Bartosz Szczepanek <bsz@semihalf.com>
Obtained from:         Semihalf
Sponsored by:          Stormshield
Reviewed by:           hselasky
Approved by:           cognet (mentor)
Differential Revision: https://reviews.freebsd.org/D5031
2016-03-14 07:24:08 +00:00
Hans Petter Selasky
b265897c37 Configure the correct bMaxPacketSize for control endpoints before
requesting the initial complete device descriptor and not as part of
the subsequent babble error recovery. Babble means that the received
USB packet was bigger than than configured maximum packet size. This
only affects enumeration of FULL speed USB devices which use a
bMaxPacketSize different from 8 bytes. This patch might help fix
enumeration of USB devices which exhibit USB I/O errors in dmesg
during boot.

MFC after:	1 week
2016-02-23 18:17:01 +00:00
Hans Petter Selasky
4bc7e098c7 Correct PCI device description.
Submitted by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
2016-02-10 08:03:10 +00:00
Michal Meloun
477aff3eae EHCI: Correct address of EHCI_USBMODE_LPM register is 0xC8, not 0xA8. 2016-01-30 08:27:09 +00:00
Michal Meloun
cdf4ec6873 EHCI: Make core reset and port speed reading more generic.
Use driver settable callbacks for handling of:
- core post reset
- reading actual port speed

Typically, OTG enabled EHCI cores wants setting of USBMODE register,
but this register is not defined in EHCI specification and different
cores can have it on different offset.

Also, for cores with TT extension, actual port speed must be determinable.
But again, EHCI specification not covers this so this patch provides
function for two most common variant of speed bits layout.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D5088
2016-01-28 14:11:59 +00:00
Zbigniew Bodek
5c8fae4064 Improve attachment of the ehci_mv driver
Driver was modified to ensure it attaches properly to "marvell,orion-ehci"
node, which doesn't have error interrupt line defined. Neccessary
ofw_compat_data struct was added and probe procedure was altered.

Reviewed by:    andrew, ian
Obtained from:  Semihalf
Sponsored by:   Stormshield
Submitted by:   Bartosz Szczepanek <bsz@semihalf.com>
Differential revision:  https://reviews.freebsd.org/D4369
2016-01-20 13:58:07 +00:00
Warner Losh
64535e84f6 Move ohci files to their proper place in the tree for atmel.
Fix when it is included (we don't have a at91rm9200 device).
From a similar patch in the PR, with tweaked names.

PR: 206229
2016-01-16 04:47:32 +00:00
Hans Petter Selasky
076daeda4f Fix for directly connected FULL or LOW speed USB devices.
Found by:	Sebastian Huber <sebastian.huber@embedded-brains.de>
MFC after:	1 week
2016-01-05 09:18:43 +00:00
Andrew Turner
2245b38f73 Ads support to the xhci pci attachment to use MSI-X interrupts when
available. As with MSI interrupts these can be disabled by setting
hw.usb.xhci.msix to 0 in the loader.

MSI-X interrupts are needed on some hardware, for example the Cavium
ThunderX only supports them, and with this we don't fall back to polling.

PR:		204378
Reviewed by:	hselasky, jhb
MFC after:	1 week (after r292669)
Sponsored by:	ABT Systems Ltd
Differential Revision:	https://reviews.freebsd.org/D4698
2015-12-24 09:40:29 +00:00
Hans Petter Selasky
db8409e00a Fix compile warning about shifting signed negative constant.
MFC after:	3 days
2015-11-23 12:55:37 +00:00
Hans Petter Selasky
c2472ff8fb Avoid using the bounce buffer when the source or destination buffer is
32-bits aligned. Merge the two bounce buffers into a single one. Some
rough tests showed that the DWC OTG throughput on RPI2 increased by
10% after this patch.

MFC after:	1 week
2015-11-08 09:37:26 +00:00
Hans Petter Selasky
52d7c63839 Reduce the DWC OTG interrupt load by not reading all the host channel
status registers for every interrupt. Check a common host channel
status interrupt register first, then conditionally read the
individual host channel status registers.

Submitted by:	Sebastian Huber <sebastian.huber@embedded-brains.de>
MFC after:	1 week
2015-10-30 14:50:29 +00:00
Hans Petter Selasky
4be283b9be Add quirk for USB 3.0 PCI device.
Submitted by:	philipp.maechler@mamo.li
PR:		203650
MFC after:	1 week
2015-10-19 07:21:57 +00:00
Kevin Lo
dd4c159043 Add support for Fresco Logic USB 3.0 host controller.
Fresco Logic hosts advertise MSI, but fail to actually generate MSI
interrupts.  We have to disable MSI use.

Reviewed by:	hselasky
2015-10-08 15:13:57 +00:00
Hans Petter Selasky
0e8fa8c3bc Add quirk for USB 3.0 PCI device.
Submitted by:	Gary Jennejohn <gj@freebsd.org>
MFC after:	1 week
2015-10-08 13:39:27 +00:00
Ed Maste
aafbd0257a Add Cavium ThunderX xHCI controller PCI ID
There is an issue with interrupts at the moment, but it works with
polling mode set (hw.usb.xhci.use_polling=1).

Reviewed by:	hselasky
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D3665
2015-09-15 16:08:25 +00:00
Hans Petter Selasky
6eed0dd7c4 Correct PCI ID.
Submitted by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after:	1 month
PR:		202807
2015-09-14 07:08:29 +00:00
Andrew Turner
504a0067c7 Add support for the dwc usb in the HiSilicon hi6220 in the HiKey board. For
this we need to force the driver into host mode, as without this the driver
fails to detect any devices.

Relnotes:	yes
Sponsored by:	ABT Systems Ltd
2015-09-01 17:13:04 +00:00
Hans Petter Selasky
6840adf6da Add new PCI ID.
Submitted by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after:	1 month
PR:		202807
2015-09-01 09:33:24 +00:00
Hans Petter Selasky
ce842cec42 Fixes for HIGH speed ISOCHRONOUS traffic. HS ISOCHRONOUS traffic at
intervals less than 250us was not handled properly. Add support for
high-bandwidth ISOCHRONOUS packets. USB webcams, USB audio and USB DVB
devices are expected to work better. High-bandwidth INTERRUPT
endpoints is not yet supported.

MFC after:	2 weeks
2015-08-15 12:06:15 +00:00
Hans Petter Selasky
e4344dae5b Handle NYET high speed tokens and predict NAK'ing is up next.
MFC after:	2 weeks
2015-08-14 14:20:10 +00:00
Hans Petter Selasky
7462a4dda1 Minor code refactor to avoid duplicating code.
MFC after:	2 weeks
2015-08-14 13:58:18 +00:00
Hans Petter Selasky
43ea03d756 Improve the realtime properties of USB transfers for embedded systems
like RPI-B and RPI-2.

Description of problem:
USB transfers can process data in their callbacks sometimes causing
unacceptable latency for other USB transfers. Separate BULK completion
callbacks from CONTROL, INTERRUPT and ISOCHRONOUS callbacks, and give
BULK completion callbacks lesser execution priority than the
others. This way USB audio won't be interfered by heavy USB ethernet
usage for example.

Further serve USB transfer completion in a round robin fashion,
instead of only serving the most CPU hungry. This has been done by
adding a third flag to USB transfer queue structure which keeps track
of looping callbacks. The "command" callback function then decides
what to do when looping.

MFC after:		2 weeks
2015-08-14 12:57:53 +00:00
Hans Petter Selasky
56d6361d92 Limit the number of times we loop inside the DWC OTG poll handler to
avoid starving other fast interrupts. Fix a comment while at it.

MFC after:	1 week
Suggested by:	Svatopluk Kraus <onwahe@gmail.com>
2015-07-31 09:12:31 +00:00