Commit graph

43793 commits

Author SHA1 Message Date
Ruslan Bukin
253c83058d mmc: SPI-mode support for SD cards.
Introduce SPI-mode support which allows an SD card to communicate with a
host system using SPI protocol, as described in the SD Card Specification.

This feature is useful for low-end, FPGA or RISC-V research systems when a
SoC is limited in terms of peripherals available (e.g. lack of a dedicated
MMC controller in hardware). Examples of such systems include Codasip,
lowRISC and CVA6.

Project timeline:
2007: Warner first discussed SPI operational mode in his MMC presentation:
      https://people.freebsd.org/~imp/bsdcan2007.pdf
2012: Patrick Kelsey engineered the support.
2025: Ruslan cleaned up, tested on Codasip X730 platform (RISC-V FPGA)
      and put the patch to review.
2025: Patrick Kelsey reviewed the patch and aligned with the current MMC
      code.

Reviewed by:	pkelsey
Sponsored by:	UKRI
Differential Revision:	https://reviews.freebsd.org/D49248
2025-04-09 12:21:05 +01:00
Ruslan Bukin
07da3bb5d5 mmc: support for SPI bus type
- Introduce the bus_type accessor, which allows to skip card selection
  and timing settings in SPI mode;
- Add MMC_CMD_IS_APP flag for commands followed by the APP command,
  which is required by the upcoming MMCSPI driver.

Reviewed by:	pkelsey
Sponsored by:	UKRI
Differential Revision:	https://reviews.freebsd.org/D49249
2025-04-09 12:20:54 +01:00
Ariel Ehrenberg
89e0e3814e mlx5en: Use connector type instead of cable type for media detection
Replace cable type detection with connector type for more accurate media
type selection. The connector type is queried directly from the PTYS
register and provides more reliable information about the physical port
type compared to cable type.

Reviewed by:	slavash
Sponsored by:	NVidia networking
MFC after:	1 week
2025-04-09 07:55:27 +03:00
Andrew Turner
17c67ba24d sys: Move Marvell specific fdt code to sys/arm/mv
fdt_immr_* are only used by the armv7 Marvell code. Move setting the
variables there as no new code should need to set them.

Reviewed by:	cognet
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D49535
2025-04-08 11:48:28 +01:00
Andrew Turner
a2aff11aeb dev/fdt: Add const to pointers to const data
fdt_data_get and fdt_data_to_res don't change the value of the data
passed to them via a pointer. Add const to these pointers.

Reviewed by:	emaste
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D49703
2025-04-08 11:48:28 +01:00
Andrew Turner
211ca9061b dev/fdt: Remove old fdt_get memory functions
These have been replaces with fdt_foreach equivalents so are unused.

Reviewed by:	imp
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D49702
2025-04-08 11:48:28 +01:00
Andrew Turner
28bc1919f5 dev/fdt: Add fdt_foreach_reserved_region
As with fdt_foreach_mem_region add a function that calls a callback
for each reserved memory region in /memreserve. This allows us to
exclude this memory from the physical map in a way that is safe from
overflowing a fixed array on the stack.

Reviewed by:	imp
Sponsored by:   Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D49699
2025-04-08 11:48:28 +01:00
Andrew Turner
8d5b63efd1 dev/fdt: Add fdt_foreach_reserved_mem
As with fdt_foreach_mem_region add a function that calls a callback
for each reserved memory region. This allows us to exclude this memory
from the physical map in a way that is safe from overflowing a fixed
array on the stack.

Reviewed by:	imp
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D49698
2025-04-08 11:48:28 +01:00
Andrew Turner
0593e41106 dev/fdt: Add fdt_foreach_mem_region
This is used early in the boot to find physical memory. Previously it
needed an array of memory regions to be passed in. We keep finding
hardware where this array is too small causing the kernel to smash the
stack.

Replace with a function that takes a callback that can insert the
memory into the physical map directly.

Reviewed by:	imp
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D49697
2025-04-08 11:48:27 +01:00
Andrew Turner
fd9f67e689 virtio_p9fs: Support attaching to pci and mmio
Some implementations of the virtio 9p transport are implemented on
virtio_mmio, e.g. the Arm FVP. Use the correct macro so the driver
attaches when this is the case.

Reviewed by:	markj
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D49600
2025-04-08 11:48:27 +01:00
Andrew Turner
451f0333b7 sys: Make the iommu xref uintptr_t
On arm64 we use the iommu base address as an xref. This fails when
the address has the lower 32-bits in common with another iommu as
they will share an xref.

Reviewed by:	kib
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D48726
2025-04-08 11:48:22 +01:00
Poul-Henning Kamp
7611368063 QCOM GENI I²C driver
This is a from scratch, minimally viable, I²C driver for QCOM's
GENI serial engine.

No QCOM documentation is available, so other FOSS device drivers
were consulted to figure things out

The driver works on T14s G6 "Snapdragon" hardware, to such a degree
that ACPI clients and HID devices work (polling mode & needs
modifications to iichid)

Differential Revision: https://reviews.freebsd.org/D49676
Reviews by: adrian
2025-04-08 05:51:54 +00:00
Adrian Chadd
0c5a770cc4 fdt: fix panic in fdt_slicer/geom due to recent geom changes
A recent change in GEOM ordering (c11b701915 -
"geom: Push GEOM sysinit ordering to after devctl" changed the GEOM init
ordering to SI_ORDER_THIRD.  However, the FDT slicer / GEOM flash
slice code needs the GEOM subsystem to be initialised before it
starts loading in flash slices from FDT, and will panic because
the mutex isn't initialised.

So bump this now to SI_ORDER_FOURTH, so it occurs after the GEOM
initialisation.

Differential Revision:	https://reviews.freebsd.org/D49692
Reviewed by:	jhibbits
2025-04-07 20:47:09 -07:00
Adrian Chadd
489489b4bc fdt: bump FDT_MEM_REGIONS to 64
The Snapdragon X1E / Lenovo T14s device tree has 47 reserved memory
regions.  The reserved region parsing doesn't boundary check and will
just end up array bounds smashing, which leads to a reboot before
any console IO is written.

Differential Revision:	https://reviews.freebsd.org/D49689
Reviewed by:	manu, phk
2025-04-07 20:46:21 -07:00
Adrian Chadd
7d2eef229f qcom_gcc: migrate to use sleep_clk directly
gcc_sleep_clk_src does not exist, just use sleep_clk directly.
I believe this is what feeds them anyway!

This node isn't in the Linux clock driver (drivers/clk/qcom) ipq401x
clock tree, but there are sleep_clk_src nodes in the tree in
ipq50xx, ipq54xx, ipq60xx, ipq8xxxx, ipq9xxxx, msm8xxx, etc.

Differential Revision:	https://reviews.freebsd.org/D49686
2025-04-07 20:46:02 -07:00
Adrian Chadd
dc1d78b2c2 qcom_dwc3: update naming to match the later device tree drops.
The device tree renamed master -> core, so rename the fields here.

Locally tested:

* IPQ4019, ASUS RT-AC58U, USB works (enough for umass!)

Differential Revision:	https://reviews.freebsd.org/D49684
Reviewed by:	manu
2025-04-07 20:45:07 -07:00
Adrian Chadd
7fead5f144 qcom_gcc: begin refactoring sys/dev/qcom_gcc to support multiple chipsets
Although the driver structure is almost supportive of multiple
chipsets, there's a lot of subtle hard coded IPQ4018 assumptions
here.

This is a partial refactor of the driver in order to have a single
qcom_gcc driver that will eventually support multiple chipsets.

* rename qcom_gcc_ipq4018 -> qcom_gcc
* remove the ipq4018 specific naming from things
* create a table to drive probe/attach, with a chipset id to
  use during attach
* migrate the clock register accessors to not be ipq4018 specific
* migrate the reset register accessors to not be ipq4018 specific

Note this won't compile (yet) for an arm64 kernel because there's
a hard-coded clock tree for an earlier 64 bit MSM part in
sys/arm64/qualcomm/qcom_gcc.c . That will need to be rolled into this
driver.

Differential Revision:	https://reviews.freebsd.org/D49683
2025-04-07 20:44:52 -07:00
Vee Agarwal
22fe926a62 gve: Add feature to change TX/RX ring size
This change introduces new sysctl handlers that allow the user to change
RX/TX ring sizes. As before, the default ring sizes will come from the
device (usually 1024). We also get the max/min limits from the device.
In the case min values are not provided we have statically defined
constants for the min values. Additionally, if the modify ring option is
not enabled on the device, changing ring sizes via sysctl will not be
possible.  When changing ring sizes, the interface turns down
momentarily while allocating/freeing resources as necessary.

Signed-off-by: Vee Agarwal <veethebee@google.com>

Reviewed by:	markj
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D49428
2025-04-04 23:24:49 +00:00
Vee Agarwal
e0464f74d5 gve: Add feature to adjust RX/TX queue counts
This change introduces new sysctl handlers that allow the user to change
RX/TX queue counts. As before, the default queue counts will be the max
value the device can support. When chaning queue counts, the interface turns
down momentarily while allocating/freeing resources as necessary.

Signed-off-by: Vee Agarwal <veethebee@google.com>

Reviewed by:	markj
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D49427
2025-04-04 23:24:49 +00:00
Vee Agarwal
f8ed8382da gve: Allocate qpl per ring at ring allocation time
Every tx and rx ring has its own queue-page-list (QPL) that serves as
the bounce buffer. Previously we were allocating QPLs for all queues
before the queues themselves were allocated and later associating a QPL
with a queue. This is avoidable complexity: it is much more natural for
each queue to allocate and free its own QPL.

Signed-off-by: Vee Agarwal <veethebee@google.com>

Reviewed by:	markj
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D49426
2025-04-04 23:24:49 +00:00
Emannuel Vadot
944eda42fa openfirm: Add OF_device_unregister_xref
When a device fails to attach, or a module is unloaded, we want to be
able to unregister the xref as the device goes away.  While the device_t
may still be valid, it won't be providing whatever functionality the
consumer that follows the xref wants it for and thus, we should not
keep it discoverable.

[Commit message re-worded by kevans@]

Reviewed by:	ian, imp
Differential Revision:	https://reviews.freebsd.org/D22945
2025-04-03 09:03:44 -05:00
Tom Jones
74a6f2a76b iwx: Shorten log code field
The widest value used with code is 32 bits, other values are smaller.
Reduce this down. Update printfs.

This fixes the build on i386.

Reviewed by:	bapt, emast, kevans, adrian
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D49634
2025-04-03 08:06:40 +01:00
Mitchell Horne
b847e406e1 Revert "mccomphy: add support for YT8531"
The new code makes use of FDT/OFW types and interfaces, and obviously
fails to build on amd64. Revert to fix.

Pointy-hat-to: mhorne

This reverts commit e69623451e.
2025-04-02 23:26:58 -03:00
Konstantin Belousov
fd748c7d5b efirt: add a tunable to disable printing faults during EFIRT calls
PR:	285797
Reported and tested by:	 Bakul Shah <bakul@iitbombay.org>
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D49592
2025-04-02 23:21:56 +03:00
Colin Percival
9be42ee6c9 pci: Make PCIe Eject timeout configurable
PCIe mandates a 5 second delay between when the "Attention Button" is
pressed and when the associated device is detached; this is to allow
for the button to be pressed a second time to cancel the ejection.  On
some systems this 5 second delay may not be desireable; so introduce a
hw.pci.pcie_hp_detach_timeout sysctl (which can also be set as a loader
tunable) which specifies the timeout in milliseconds (default 5000).
If set to zero, the device is detached immediately.

Reviewed by:	jhb
MFC after:	2 weeks
Sponsored by:	Amazon
Differential Revision:	https://reviews.freebsd.org/D49585
2025-04-02 13:14:24 -07:00
Jari Sihvola
cd92dd2324 eqos: Add StarFive JH7110 variant
Found on the VisionFive v2 SBC, and similar.

Reviewed by:	mhorne
Tested by:	mhorne
Discussed with:	sos
Differential Revision:	https://reviews.freebsd.org/D45600
2025-04-02 13:56:38 -03:00
Jari Sihvola
e69623451e mccomphy: add support for YT8531
Reviewed by:	mhorne
Tested by:	mhorne
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D45600
2025-04-02 13:56:36 -03:00
Kyle Evans
ba2336d304 arm64: add a driver for the uart found on Apple Silicon machines
This is a revival of the old exynos4210 driver, with some additional
bits to configure the apple "s5l" uart (which is actually slightly
different to operate).

This hasn't been tested on anything that would hit the non-s5l path, so
banish it off to the apple/ domain until someone cares to confirm that
none of the other hardware is broken -- it may be that nobody does, but
the complexity isn't too bad: mostly the driver1 construct added to the
uart_bas that we use to avoid having a whole bunch of shims for uart
driver methods and hardcoded references to the cfg structs.

Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D48120
2025-04-01 21:57:17 -05:00
Konstantin Belousov
45f70f98fc iommu_gas_map_region(): add comment explaining the ma array shift
and the difference between start and entry->start values at this point.

Sponsored by:	Advanced Micro Devices (AMD)
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2025-04-02 01:23:17 +03:00
Nia Alarie
426f4e5e2e if_run: Add sitecom device id
Reviewed by:	thj, adrian
Obtained from:	NetBSD
Differential Revision:	https://reviews.freebsd.org/D49588
2025-04-01 09:00:07 +01:00
Nia Alarie
9f3e7b7597 if_rsu: Add sitecom device id
Approved by:	thj, adrian
Obtained from:	NetBSD
Differential Revision:	https://reviews.freebsd.org/D49588
2025-04-01 08:59:42 +01:00
Colin Percival
680d34896c Revert "pci: Only re-route IRQs based on firmware on x86"
This reverts commit 0e33c2e6df.
2025-03-31 14:01:09 -07:00
Konstantin Belousov
f0adc907fc mlx5en: sync channel close with the rq completion processing
Without the wait, mlx5e_destroy_rq() might free mbuf that is passed up
to the network stack on receive in mlx5e_poll_rx_cq().

Sponsored by:	NVidia networking
MFC after:	1 week
2025-03-31 21:59:50 +03:00
Tom Jones
2ad0f7e915 Import iwx as ported from OpenBSD by Future Crew.
This driver originates from OpenBSD and was ported to FreeBSD by Future
Crew LLC who kindly provided a source release.

iwx supports many recent Intel WiFi card and this driver should support running
these cards with legacy, HT and VHT rates. There are some issues remaining in
the port, but at this point wider testing is sought.

To avoid breaking deployed WiFi configurations iwx probes with a lower
priority than iwlwifi. This can be changed by blocking iwlwifi with
devmatch.

Reviewed by:	adrian
Obtained from:	Future Crew LLC
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D49259
2025-03-31 13:42:31 +01:00
Mark Johnston
54a3920dc9 hyperv/storvsc: Avoid conditional asserts in storvsc_xferbuf_prepare()
whu@ cannot reproduce the assertion failure which led to these ifdefs
being added in the first place, and since they appear wrong, i.e., the
assertions ought to apply to all platforms, let's remove them.

This reverts commits 0af5a0cd27 and
6f7b1310b6.

PR:		285681
Tested by:	whu
MFC after:	2 weeks
2025-03-31 07:15:45 -04:00
Mark Johnston
a319ba6945 hyperv/storvsc: Fix busdma constraints
- The BUS_DMA_KEEP_PG_OFFSET flag is needed, since
  storvsc_xferbuf_prepare() assumes that only the first segment may have
  a non-zero offset, and that all following segments are page-sized and
  -aligned.
- storvsc_xferbuf_prepare() handles 64-bit bus addresses, so avoid
  unneeded bouncing on i386.

PR:		285681
Reported by:	dim
Tested by:	dim, whu
MFC after:	2 weeks
2025-03-31 07:14:42 -04:00
Christos Margiolis
b6420b5ea5 sound: Fix regression in pcm/feeder_mixer.c
This call was meant to be the default case in the first place, but
somehow missed this.

Reported by:	glebius
Fixes:		4021fa32d9 ("sound: Simplify pcm/feeder_mixer.c")
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2025-03-30 23:27:09 +02:00
Christos Margiolis
35400672df sound: Use bus_topo_lock() where appropriate
Lock around uses of devclass_*() and replace leftover
CTLFLAG_NEEDGIANTs with CTLFLAG_MPSAFE.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	imp, jhb
Differential Revision:	https://reviews.freebsd.org/D46700
2025-03-30 19:46:14 +02:00
Christos Margiolis
a4aff024fd sound: Improve afmt_tab
Reduce ifdefs, and add aliases for the unsigned formats.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D48009
2025-03-30 19:45:53 +02:00
Christos Margiolis
e1bbaa71d6 sound: Implement AFMT_FLOAT support
Even though the OSS manual [1] advises against using AFMT_FLOAT, there
are applications that expect the sound driver to support it, and might
not work properly without it.

This patch adds AFMT_F32_LE|BE (as well as AFMT_FLOAT for OSS
compatibility) in sys/soundcard.h and implements AFMT_F32_LE|BE <->
AFMT_S32_LE|BE conversion functions. As a result, applications can
write/read floats to/from sound(4), but internally, because sound(4)
works with integers, we convert floating point samples to integer ones,
before doing any processing.

The reason for encoding/decoding IEEE754s manually, instead of using
fpu_kern(9), is that fpu_kern(9) is not supported by all architectures,
and also introduces significant overhead.

The IEEE754 encoding/decoding implementation has been written by Ariff
Abdullah [2].

[1] http://manuals.opensound.com/developer/AFMT_FLOAT.html
[2] https://people.freebsd.org/~ariff/utils/ieee754.c

PR:		157050, 184380, 264973, 280612, 281390
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D47638
2025-03-30 19:45:38 +02:00
Christos Margiolis
e372211be5 sound: Fix vchanrate and vchanformat
Make vchanrate and vchanformat reflect the primary channel's software
buffer's rate and format respectively. Fix previous inconsistencies.

Get rid of the initializations in vchan_create() and move them to
chn_init().

Without the feeder_rate_round check in sysctl_dev_pcm_vchanrate(), we
can set the software rate to anything between feeder_rate_min and
feeder_rate_max. If we keep the check, however, the rate is limited to
whatever the driver's min/max is, which can be a problem if, for
example, the driver supports only a single rate, in which case we won't
be able to set anything other than the driver rate.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D48961
2025-03-30 19:45:34 +02:00
Colin Percival
0e33c2e6df pci: Only re-route IRQs based on firmware on x86
There is a (very historical) call to pci_assign_interrupt for the
purpose of routing IRQs which may have been set up wrong by x86 BIOS
or firmware.  On non-x86 systems, this is unnecessary; and on INTRNG
systems it results in a (synthetic) IRQ leak and ultimately a kernel
panic after many hotplug/unplug cycles.

Suggested by:	jhb
Reviewed by:	jhb
MFC after:	2 weeks
Sponsored by:	Amazon
Differential Revision:	https://reviews.freebsd.org/D49560
2025-03-29 13:17:29 -07:00
Norbert Ciosek
1580f8d9c1 ixgbe: fix mailbox ack handling
Check if CTS bit is set in the mailbox message before waiting for ACK.
Otherwise ACK will never be received causing the function to timeout. Add
a note for ixgbe_write_mbx that it should be called while holding a lock.

Fixes: 6d243d2 ("net/ixgbe/base: introduce new mailbox API")
Cc: stable@dpdk.org

Signed-off-by: Norbert Ciosek <norbertx.ciosek@intel.com>
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>

Obtained from:	DPDK (1f119e4)
MFC after:	1 week
2025-03-28 17:02:37 -07:00
Adrian Chadd
8b0acd8538 mtw: fix compilation with IEEE80211_SUPPORT_SUPERG enabled
It looks like this was missed during the driver development and
porting.

Differential Revision:	https://reviews.freebsd.org/D49512
Reviewed by:	thj
2025-03-28 11:59:35 -07:00
John Baldwin
86dd379d3e pci: Use a single variable for the offset of the power management registers
This is the more typical pattern for other capability register sets,
and two of these variables weren't used.

Differential Revision:	https://reviews.freebsd.org/D49267
2025-03-27 16:57:04 -04:00
John Baldwin
931baeb62b acpi_pci: Use pci_has_pm and pci_clear_pme
Differential Revision:	https://reviews.freebsd.org/D49266
2025-03-27 16:56:08 -04:00
John Baldwin
ddaf652468 dev: Use recently added improvements to PME# support to simplify drivers
Depend on the PCI bus driver clearing PME# after resume to remove the
need for clearing PME# from DEVICE_RESUME methods.

Use pci_has_pm and pci_enable_pme.

Reviewed by:	Krzysztof Galazka <krzysztof.galazka@intel.com>
Differential Revision:	https://reviews.freebsd.org/D49251
2025-03-27 16:55:12 -04:00
John Baldwin
e5cbf0e881 pci: Add helper routines to manage PME in device drivers
pci_has_pm is a quick check that returns true if a PCI device supports
the power management capability.

pci_enable_pme can be used in DEVICE_SUSPEND driver methods to enable
PME# during suspend.

Reviewed by:	Krzysztof Galazka <krzysztof.galazka@intel.com>x
Differential Revision:	https://reviews.freebsd.org/D49250
2025-03-27 16:55:03 -04:00
John Baldwin
82d6927712 pci: Clear active PME# and disable PME# generation
The PCI power management specification requires that the OS clear any
pending PME# interrupt and generation of PME# interrupts during
"initial operating system load".  Note that clearing a pending PME#
interrupt requires writing a 1 to the Read/Write-Clear PME bit in the
power management status register.  To handle the boot time case, clear
PME# state in pci_read_cap() when scanning new PCI devices.  This
should also cover hotplug devices.

In addition, clear this state on every PCI device after resume from
sleep in pci_resume_child before invoking the driver's DEVICE_RESUME
method.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D49222
2025-03-27 16:53:24 -04:00
John Baldwin
7a5b9c4abc netmap: Add a cdev_pg_path hook that returns the name of the cdev
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D49337
2025-03-27 16:45:06 -04:00