Commit graph

542 commits

Author SHA1 Message Date
Warner Losh
b02419fc40 Revert "mips: remove saf1761"
Mips is still in stable/13, so this should not have been merged.

This reverts commit 622ab2c483.

Sponsored by:		Netflix
2023-01-24 21:00:23 -07:00
Warner Losh
622ab2c483 mips: remove saf1761
The saf1761 OTG support was only for mips targets (BERI?). Retire it.

Sponsored by:		Netflix
Reviewed by:		brooks
Differential Revision:	https://reviews.freebsd.org/D33706

(cherry picked from commit 44796b7e82)
2023-01-24 14:49:19 -07:00
Andrew Turner
52583b734d Check for more XHCI ACPI IDs
The Windows Dev Kit 2023 uses the XHCI-compliant USB controller without
standard debug ID in its ACPI tables. Check for both ID values found
on [1] in the XHCI ACPI attachment.

[1] https://learn.microsoft.com/en-us/windows-hardware/drivers/bringup/device-management-namespace-objects

Tested by:	Robert Clausecker <fuz@fuz.su>
Sponsored by:	Arm Ltd

(cherry picked from commit 8793196ca2)
2023-01-23 12:36:28 +00:00
Hans Petter Selasky
d68c00757d xhci(4): Don't allocate an IRQ vector if hw.usb.xhci.use_polling=1 is set.
This is useful for debugging purposes.

Sponsored by:	NVIDIA Networking

(cherry picked from commit 3346ae0d24)
2022-11-12 13:00:06 +01:00
Mitchell Horne
501f703023 usb: musb_otg_allwinner: de-constify bus_space_tags
The SAN interceptors simply take a bus_space_tag_t, so we're
dropping qualifiers here.  const semantics with a ptr typedef mean we'd
have to drop or change the bus_space_tag_t abstraction used in the SAN
sanitizers in order to make a compatible change there, which likely
isn't worth it.

Reviewed by:	andrew, markj
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.

(cherry picked from commit 26d786331b)
2022-11-02 12:02:24 -05:00
Alexander Motin
7e53019b06 Add random VMware device IDs.
Just to make dmesg look nicer there.

MFC after:	1 week

(cherry picked from commit 2a31a06bf1)
2022-10-26 22:48:56 -04:00
Hans Petter Selasky
38b1cbc87b usb(4): Make the enumeration thread nice time a variable.
Depends on "options USB_DEBUG".

Suggested by:	koobs@
Sponsored by:	NVIDIA Networking

(cherry picked from commit 8758aabb16)
2022-10-12 17:53:22 +02:00
Hans Petter Selasky
1069b3b514 usb(4): Make sure the enumeration thread doesn't loop too fast.
Sponsored by:	NVIDIA Networking

(cherry picked from commit 55a3bd000d)
2022-10-12 17:53:22 +02:00
Warner Losh
0fdc327e5d uss820dci: eliminate unused variables sc, ep_no
Sponsored by:		Netflix

(cherry picked from commit 12312f7583)
2022-10-01 22:25:56 -06:00
Warner Losh
61181185cf uhci_xfer_setup: eliminate write only variable sc
Sponsored by:		Netflix

(cherry picked from commit 6ccdcae1b9)
2022-10-01 22:25:55 -06:00
Warner Losh
bbc7627317 musb: eliminate write only variable sc
Sponsored by:		Netflix

(cherry picked from commit ab59cd6a0b)
2022-10-01 22:25:55 -06:00
Warner Losh
3f07688cf6 atmegadci: eliminate unused variables sc, ep_no
Sponsored by:		Netflix

(cherry picked from commit e73b02f66b)
2022-10-01 22:25:55 -06:00
Bjoern A. Zeeb
c147c214e6 XHCI: remove a self-assignment
x = x is an unneeded operation, remove it.
The value is read and assigned above for real.

(cherry picked from commit d3ef3c4cf8)
2022-09-21 11:39:03 +00:00
Bjoern A. Zeeb
30f6e37522 dwc3: add ACPI attachment
Split the current FDT-only implementation up into an FDT and an
ACPI part reusing and sharing as much code as possible (thanks mw!).

This makes the Synopsis XHCI root hubs attach correctly on SolidRun's
HoenyComb instead of just the generic XHCI root and this means we
are also doing proper chip setup and applying the quirk needed there [1].

There is one problem with ACPI attachment in that it uses the generic
XHCI PNP ID.  So we need to do extra checks in order to not claim
all xhci, which means we check for a known quirk to be present
in acpi_probe.  Long term this isn't scaling and this was discussed
in SolidRun's Discord Channel in 2021 with the intend that "jnettlet"
will take this to a steering committee.  Since then ACPI has kind-of
become a technology non grata (due to not getting changes into Linux
timely) so it is unclear if this will ever happen.  If there will be
further hardware with dwc3/ACPI we should go and make sure this problem
gets solved.

[1] 24698f90b7/Silicon/NXP/LX2160A/AcpiTables/Dsdt/Usb.asl

Reviewed by:		manu, mw
Differential Revision:	https://reviews.freebsd.org/D32256

(cherry picked from commit fbb5cb66f7)
2022-07-18 01:00:21 +00:00
Bjoern A. Zeeb
ae33d74d47 dwc3: improve debugging
Rather than hiding behind #if 0, hide the debugging behind DWC3_DEBUG
so it can be turned on with a single define.  Require bootverbose
to print anything so we can still avoid spamming the console if DWC3_DEBUG
is on.
Harmonize the format string in snsp_dwc3_dump_regs() to always print the
full register and also print the XHCI quirks.
Call snsp_dwc3_dump_regs() twice, before and after generic XHCI attachment
and initialisation as this may have an effect on the confirgumation state.

Obtained from:	an old debug patch
Reviewed by:	mw
Differential Revision: https://reviews.freebsd.org/D35700

(cherry picked from commit 11a7d5e5d9)
2022-07-18 01:00:21 +00:00
Bjoern A. Zeeb
a7717dc610 dwc3: add more quirks and checks
Rather than just printing the Global SNPS ID Register store it as well
so we can do a version check later.
In addition, for debugging purposes, read the Global Hardware Parameters
Registers and print them.

Based on the snpsid disable an XHCI feature using a quirk prepared
in 447c418da0.
Add the "snps,dis_u3_susphy_quirk" quirk and handle Suspend USB3.0 SS PHY
after power-on-reset/during core initialization (suggested to be cleared)
based on the DWC3_GHWPARAMS0 register.

Obtained from:	an old debugging patch
Reviewed by:	mw (earlier version), mmel
Differential Revision: https://reviews.freebsd.org/D35699

(cherry picked from commit 09cdf4878c)
(cherry picked from commit ec32fc2af5)
2022-07-18 01:00:21 +00:00
Bjoern A. Zeeb
486d99faa3 dwc3: uncondinationally enable Host IN Auto Retry
Enable dwc3's auto retry feature. For IN transfers with crc errors
or internal overruns this will make the host reply with a
non-terminating retry ACK.  I believe the hope was to improve
reliability after seeing occasional hiccups.

Obtained from:	an old debugging patch
Reviewed by:	mw
Differential Revision: https://reviews.freebsd.org/D35698

(cherry picked from commit cec0a5ec6b)
2022-07-18 01:00:21 +00:00
Bjoern A. Zeeb
9ffd5ef82f dwc3: fix snps,dis-del-phy-power-chg-quirk
If snps,dis-del-phy-power-chg-quirk is set, the register bit should be
cleared not ored on (it's the "dis" version).

Reviewed by:	mw
Differential Revision: https://reviews.freebsd.org/D35697

(cherry picked from commit 0084212bfd)
2022-07-18 01:00:20 +00:00
Bjoern A. Zeeb
bf7ce29414 USB: dwc3: use device_{has,get}_property()
Switch the driver to use device based functions which will work not
only with FDT but also ACPI.

While here make dr_mode a local variable as it is only used during
probe and not needed later in the softc.

Reviewed by:	mw
Differential Revision: https://reviews.freebsd.org/D33170

(cherry picked from commit b11f52f4db)
2022-07-18 01:00:20 +00:00
Bjoern A. Zeeb
39cd7aa134 USB: add quirks to XHCI
While XHCI is very generic some revisions of chipsets have problems.
On dwc3 <= 3.00a Port Disable does not seem to work so we need to not
enable it.
For that introduce quirks to xhci so that controllers can steer
certain features.  I would hope that this is and remains the only one.

Obtained from:	an old patch mainly debugging other problems
Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D35482

(cherry picked from commit 447c418da0)
2022-07-01 13:50:10 +00:00
Warner Losh
db761c6a64 Create wrapper for Giant taken for newbus
Create a wrapper for newbus to take giant and for busses to take it too.
bus_topo_lock() should be called before interacting with newbus routines
and unlocked with bus_topo_unlock(). If you need the topology lock for
some reason, bus_topo_mtx() will provide that.

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D31831

(cherry picked from commit c6df6f5322)
2022-06-21 17:13:20 +02:00
Emmanuel Vadot
0c7209c263 usb: Make ext_resources non-optional
EXT_RESOURCES have been introduced in 12-CURRENT and all supported
releases have it enabled in their kernel config.

MFC after:      1 month
Differential Revision:	https://reviews.freebsd.org/D33827

(cherry picked from commit fb6cebd8bd)
2022-05-16 13:45:36 +02:00
Hans Petter Selasky
75a5bdd453 xhci(4): Tweak USB port speed checks to allow newer super speed generations.
This allows setting the U1 and U2 port timeout values.

Sponsored by:	NVIDIA Networking

(cherry picked from commit a1c0442b41)
2022-05-10 10:05:32 +02:00
Hans Petter Selasky
a11ac66f1c xhci(4): Properly define all basic USB port speeds.
Sponsored by:	NVIDIA Networking

(cherry picked from commit d730333c80)
2022-05-10 10:05:29 +02:00
Hans Petter Selasky
6d8c6b24ee xhci(4): Always add and evaluate the slot context.
Because the maximum number of endpoint contexts is stored there.

Tested by:	ehaupt@
PR:		262882
Approved by:	re (gjb, early MFC)
Sponsored by:	NVIDIA Networking

(cherry picked from commit 09dd1adfa4)
2022-05-03 21:43:13 +02:00
Hans Petter Selasky
610528736f xhci(4): Only drop BULK and INTERRUPT endpoints to reset data toggle.
Only drop BULK and INTERRUPT endpoints, to reset the data toggle,
because for other endpoint types this is not critical.

While at it fix some whitespace.

Tested by:	ehaupt@
PR:		262882
Approved by:	re (gjb, early MFC)
Sponsored by:	NVIDIA Networking

(cherry picked from commit e276d28150)
2022-05-03 21:41:51 +02:00
Hans Petter Selasky
3644b92099 xhci(4): Ensure the so-called data toggle gets properly reset.
Use the drop and enable endpoint context commands to force a reset of
the data toggle for USB 2.0 and USB 3.0 after:
 - clear endpoint halt command (when the driver wishes).
 - set config command (when the kernel or user-space wants).
 - set alternate setting command (only affected endpoints).

Some XHCI HW implementations may not allow the endpoint reset command when
the endpoint context is not in the halted state.

Reported by:		Juniper and Gary Jennejohn
Sponsored by:		NVIDIA Networking

(cherry picked from commit cda31e7349)
2022-04-27 21:07:13 +02:00
Gordon Bergling
ecc10e7be9 usb(4): Remove a double word in a source code comment
- s/for for/for/

(cherry picked from commit 2e09a4ac3b)
2022-04-14 08:12:05 +02:00
Hans Petter Selasky
19b779498c xhci(4): Add quirk for "Fresco Logic FL1009 USB3.0 xHCI Controller".
Submitted by:		John F Carr <jfc@mit.edu>
Sponsored by:		NVIDIA Networking

(cherry picked from commit 19837718ab)
2022-03-17 10:55:18 +01:00
Hans Petter Selasky
ea318f1ad1 xhci(4): Add quirk for "TUSB73x0 USB3.0 xHCI Controller".
Tested by:	br@
Sponsored by:	NVIDIA Networking

(cherry picked from commit 33cbbf268f)
2022-03-16 15:55:22 +01:00
Hans Petter Selasky
cea6dbdf1b Make sure the avr32dci_odevd structure is used.
This fixes a compilation error.

Sponsored by:	NVIDIA Networking

(cherry picked from commit 3f5054862a)
2022-03-10 09:29:22 +01:00
Hans Petter Selasky
9997736943 Factor out repeated code in the USB controller drivers to avoid bugs
computing the same isochronous start frame number over and over again.

PR:		257082
Sponsored by:	NVIDIA Networking

(cherry picked from commit 8fc2a3c417)
(cherry picked from commit f52783fcf5)
(cherry picked from commit cf48d1f771)
2022-03-10 09:29:19 +01:00
Hans Petter Selasky
2db063c4ce Make sure the XHCI driver obeys the isochronous scheduling threshold value
as given by the XHCI hardware parameters to avoid scheduling isochronous
transfers too early.

Sponsored by:	NVIDIA Networking

(cherry picked from commit d038463bd2)
2022-03-10 09:27:41 +01:00
Hans Petter Selasky
afeeccfbed Let the xhci_hw_root structure span exactly XHCI_PAGE_SIZE bytes by increasing
the number of completion event TRBs. This avoids wasting memory.

Sponsored by:	NVIDIA Networking

(cherry picked from commit e036ee6ce2)
2022-03-10 09:18:04 +01:00
Hans Petter Selasky
15c4f94534 Add more USB host controller PCI ID's.
Submitted by:	Gary Jennejohn <gljennjohn@gmail.com>
Sponsored by:	NVIDIA Networking

(cherry picked from commit e85af89fa7)
2022-02-24 10:58:44 +01:00
Hans Petter Selasky
ce60a1fe6a xhci: add PCI IDs for USB controllers found on Supermicro M12SWA-TF
(cherry picked from commit 4b4cce02ac)
2022-02-24 10:58:39 +01:00
Hans Petter Selasky
ed5fb5ccdb usb(4): Belatedly add a PCI device ID for AMD Bolton chipset
(cherry picked from commit 379797d4b4)
2022-02-24 10:58:32 +01:00
Hans Petter Selasky
d9addaa0ba Add new USB host controller PCI ID's.
Submitted by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
Sponsored by:	NVIDIA Networking

(cherry picked from commit 42cf33dd1a)
2022-02-24 10:58:16 +01:00
Andrew Turner
24a205e328 Fix undefined behaviour in the USB controllers
The USB controller drivers assume they can cast a NULL pointer to a
struct and find the address of a member. KUBSan complains about this so
replace with the __offsetof and __containerof macros that use either a
builtin function where available, or the same NULL pointer on older
compilers without the builtin.

Reviewers: hselasky

Subscribers: imp

Reviewed by:	hselasky
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33865

(cherry picked from commit a3cea15680)
2022-02-22 16:23:07 +00:00
Bjoern A. Zeeb
8adc24f7c5 USB dwc3 controller: add quirk snps,dis_rxdet_inp3_quirk
Add support for the "snps,dis_rxdet_inp3_quirk" quirk needed
at least on SolidRun's HoneyComb.

Reviewed by:	manu, mw
Differential Revision: https://reviews.freebsd.org/D32921

(cherry picked from commit 3987e50611)
2021-12-29 16:02:51 +00:00
Alexander Motin
1fb199ffa6 xhci: Add PCI IDs for Thunderbolt 3/4 USB controllers.
MFC after:	2 weeks

(cherry picked from commit cfb0e4d76c)
2021-12-12 22:16:28 -05:00
Alexander Motin
155748c1e7 xhci: Add PCI IDs from recent Intel CPUs.
MFC after:	2 weeks

(cherry picked from commit 83d7b2f335)
2021-12-11 00:17:16 -05:00
Alexander Motin
1e5dc6aa18 Add some of Intel Alder Lake device IDs.
MFC after:	1 week

(cherry picked from commit dc238358f9)
2021-11-12 23:02:46 -05:00
Gordon Bergling
f296898fb7 Fix a common typo in source code comments
- s/aligment/alignment/

(cherry picked from commit a1581cd735)
2021-08-19 09:18:35 +02:00
Hans Petter Selasky
c834f30a0c Add new PCI ID for XHCI(4).
Submitted by: Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking
2021-01-07 15:35:35 +01:00
Marius Strobl
5db1ed2f33 ohci(4): remove support for Sun PCIO-2 USB controllers
It's no longer used since 58aa35d429
and r357455 respectively.
2020-12-25 19:47:46 +01:00
Hans Petter Selasky
1622a49852 No need to stop XHCI endpoints in disabled state.
Some AMD XHCI implementations apparently assert a permanent
internal failure if this happens.

Submitted by:	ali.abdallah@suse.com
PR:		251503
MFC after:	1 week
Sponsored by:	Mellanox Technologies // NVIDIA Networking
2020-12-23 12:04:51 +01:00
John Baldwin
52ab576d74 Use __containerof() instead of home-rolled versions.
Reviewed by:	imp, hselasky
Obtained from:	CheriBSD
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D27582
2020-12-17 20:45:10 +00:00
Hans Petter Selasky
eb985e1802 When doing a USB alternate setting on an USB interface we need to
re-configure the XHCI endpoint context.

Differential Revision:	https://reviews.freebsd.org/D27174
MFC after:	1 week
Sponsored by:	Mellanox Technologies // NVIDIA Networking
2020-11-12 09:15:07 +00:00
Emmanuel Vadot
03d0d84bf6 Plug minor memory leak in dwc3 USB2/USB3 controller.
OF_getprop_alloc called earlier requires corresponding OF_prop_free to release allocated memory.

Submitted by:	kjopek@gmail.com
Differential Revision:	https://reviews.freebsd.org/D27085
2020-11-04 18:23:59 +00:00