aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/uart
Commit message (Collapse)AuthorAgeFilesLines
...
* dev/uart: Support the pl011 uart in hw.uart.consoleAndrew Turner2024-02-131-1/+2
| | | | | | | | | | Add the pl011 uart to the list of supported uarts for use by hw.uart.console. This is commonly found in Arm based devices, and a variant is standardised in the Arm SBSA. Reviewed by: imp Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D43363
* dev/uart: Support setting the register io widthAndrew Turner2024-02-131-0/+9
| | | | | | | | | Some uarts require a specific register width. Support setting this in the kernel environment. Reviewed by: imp (earlier version) Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D43362
* dev/uart: Use a linker set to find uart classesAndrew Turner2024-02-134-9/+9
| | | | | | | | | | | | | | When the uart is configured via the environment we need to find the uart class with a specified name. Currently to do this with an incomplete list of uarts. As we may not have included all uarts in the kernel each class is defined as weak. Switch to a linker set so the list is always up to date based on what is included in the kernel, and the class can be static. Reviewed by: imp Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D43361
* sys: Simplify enabling EARLY_PRINTF uartsAndrew Turner2024-02-134-21/+30
| | | | | | | | | | | | | | | | Support selecting the early uart with "options EARLY_PRINTF=foo" in the kernel configuration file. This allows us to not have to change source files when enabling EARLY_PRINTF, simplifying enabling it. New uart drivers can be enabled by defining a new early_printf_foo value to be unique, then using "#if CHECK_EARLY_PRINTF(foo)" to decide when to enable the uart. While here add pl011 early printf support. Reviewed by: imp (earlier version) Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D43360
* uart(4): Honor hardware state of NS8250-class for tsw_busyMarius Strobl2024-01-146-3/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | In 9750d9e5, I brought the equivalent of the TS_BUSY flag back in a mostly hardware-agnostic way in order to fix tty_drain() and, thus, TIOCDRAIN for UARTs with TX FIFOs. This proved to be sufficient for fixing the regression reported. So in light of the release cycle of FreeBSD 10.3, I decided that this change was be good enough for the time being and opted to go with the smallest possible yet generic (for all UARTs driven by uart(4)) solution addressing the problem at hand. However, at least for the NS8250-class the above isn't a complete fix as these UARTs only trigger an interrupt when the TX FIFO became empty. At this point, there still can be an outstanding character left in the transmit shift register as indicated via the LSR. Thus, this change adds the 3rd (besides the tty(4) and generic uart(4) bits) part I had in my tree ever since, adding a uart_txbusy method to be queried in addition for tsw_busy and hooking it up as appropriate for the NS8250-class. As it turns out, the exact equivalent of this 3rd part later on was implemented for uftdi(4) in 9ad221a5. While at it, explain the rational behind the deliberately missing locking in uart_tty_busy() (also applying to the generic sc_txbusy testing already present).
* hwreset: Move reset code in dev/hwresetEmmanuel Vadot2024-01-101-1/+1
| | | | | | | | | | | We've removed kernel option EXT_RESOURCES almost two years ago. While it was ok to have some code under a common 'extres' subdirectory at first, we now have a lot of consumer of it and we made it mandatory so no need to have it under a cryptic name. Reviewed by: imp Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D43192
* clk: Move clock code in dev/clkEmmanuel Vadot2024-01-102-2/+2
| | | | | | | | | | | We've removed kernel option EXT_RESOURCES almost two years ago. While it was ok to have some code under a common 'extres' subdirectory at first, we now have a lot of consumer of it and we made it mandatory so no need to have it under a cryptic name. Reviewed by: mhorne Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D43191
* sys: Automated cleanup of cdefs and other formattingWarner Losh2023-11-2721-21/+0
| | | | | | | | | | | | | | | | Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row. Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/ Sponsored by: Netflix
* UART: Remove ingenic xburst (mips) code from ns8250 driverOskar Holmlund2023-11-081-37/+6
| | | | | | | | | | Since ingenic JZ4780 SOC support has been removed there is no need to support ingenic quirks in the UART driver. Invert of commit b192bae67ea835b7e431225bad375b5d5fe4297f Reviewed by: imp, manu Approved by: imp, manu (mentor) Differential Revision: https://reviews.freebsd.org/D42497
* uart: Support EARLY_PRINTF on x86 for port-mapped COM portsWarner Losh2023-10-201-0/+21
| | | | | | | | | | | | | | | | Support early printf for the ns8250 uart driver. Adding options UART_NS8250_EARLY_PORT=0xYYY options EARLY_PRINTF to your kernel config will enable it. The code is rather simple minded, so caveat emptor. This will enable printf before cninit. cninit automatically disables this and switches to the real routine. It only works for port-mapped COM ports, and only if you know the port's address at compile time. It's intended for be a debugging aide, not a general purpose thing. Sponsored by: Netflix Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D42306
* sys: Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-161-1/+0
| | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
* sys: Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-1626-52/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* sys: Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-1611-22/+0
| | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-05-1224-24/+24
| | | | | | | | | The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
* Revert "uart(4): add Sunrise Point UART controllers"Kyle Evans2023-05-091-2/+0
| | | | | | | | | | This reverts commit d1b6271118188dd25a18f2372ab1d3004335ea3c. I've received multiple reports of machines failing to boot with this hardware; back it out for now until we can fix it. PR: 271147 MFC after: Morning coffee
* Use bool for one-bit wide bit-fieldsDimitry Andric2023-04-251-10/+10
| | | | | | | | | | | | A signed one-bit wide bit-field can take only the values 0 and -1. Clang 16 introduced a warning that "implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1". Fix the warnings by using C99 bool. Reported by: Clang 16 Reviewed by: emaste, jhb MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D39705
* uart(4): add Sunrise Point UART controllersKyle Evans2023-04-141-0/+2
| | | | | Sponsored by: Zenith Electronics LLC Sponsored by: Klara, Inc.
* uart: Don't change settings or throttle putc for Hyper-VWei Hu2023-03-181-7/+13
| | | | | | | | | | | | | | | | Azure setup does not like it when FreeBSD overrides the settings of the UART device. When Hyper-V is detected, don't do this and also don't throttle putc() output. This is a workaround for the early boot hang of FreeBSD on Azure. Tested on Azure, ESXi (VM with serial port), and SG-8200 PR: 264267 Reviewed by: kevans, whu Tested by: whu Obtained from: Rubicon Communications, LLC (Netgate) MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC (Netgate)
* Add support for the new Arm Generic UART _HIDAndrew Turner2022-12-221-2/+2
| | | | | | | | | | | Historically the ACPI _HID for both the Arm PL011 and Generic UARTs was ARMH0011. In the Arm Base Boot Requirements 2.0 the Generic UART _HID is changed to ARMHB000. Use this new value in the PL011 driver where we support both UART types. This has been observed in some recent EDK2 builds. Sponsored by: Arm Ltd
* uart(4): Add support for AMT virtual serial port (C610/X99 series)Stuart McLaren2022-12-201-0/+2
| | | | | PR: 267053 MFC after: 3 days
* ns8250: Fix sense of LSR_TEMT FCR checkColin Percival2022-10-281-1/+1
| | | | | | | | | When flushing the UART, we need to drain manually if LSR_TEMT is *not* asserted, aka. if the transmit FIFO is not empty. Reported by: void <void@f-m.fm> Fixes: c4b68e7e53bb "ns8250: Check if flush via FCR succeeded" Differential Revision: https://reviews.freebsd.org/D37185
* ns8250: Check if flush via FCR succeededColin Percival2022-10-181-0/+19
| | | | | | | | | | | | | The emulated UART in the Firecracker VMM (aka the implementation in the rust-vmm/vm-superio project) includes FIFOs but does not implement the FCR register, which is used by ns8250_flush to flush the FIFOs. Check the LSR to see if there is still data in the FIFOs and call ns8250_drain if necessary. Discussed with: emaste, imp, jrtc27 Sponsored by: https://patreon.com/cperciva Differential Revision: https://reviews.freebsd.org/D36979
* Downgrade tty_intr_event from a globalMitchell Horne2022-10-121-0/+3
| | | | | | | | | | It can be static within uart_tty.c. It is an open question whether there remains any real benefit to having uart instances share a swi thread. Reviewed by: imp, markj, jhb MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D36938
* ns8250_drain: Drain without DELAY firstColin Percival2022-10-081-3/+10
| | | | | | | | | | | | | | | | In virtual machines with virtual UARTs which have fictitious baud rates, it may be possible to drain the receive queue very quickly, without needing to DELAY after each character. Attempt to read (and discard) the receive queue as fast as possible, stopping for a DELAY only when LSR_RXRDY is no longer asserted; assume that we have finished draining the queue when LSR_RXRDY is asserted both before and after a DELAY. This speeds up the boot process in FreeBSD/Firecracker by 27 ms. Reviewed by: imp, jrtc27 Sponsored by: https://www.patreon.com/cperciva Differential Revision: https://reviews.freebsd.org/D36184
* uart_dev_snps: Fix device probingKornel Dulęba2022-10-061-2/+2
| | | | | | | | | | | | | | The "uart_bus_probe" function is used as a generic part of uart probe logic. It returns a driver priority(negative number) if successful and an error code otherwise. Fix the error checking condition to account for that. Also, while here return "BUS_PROBE_VENDOR", instead of "0". This fixes uart on clearfog pro with recent DT. PR: 266657 Reviewed by: mw Obtained from: Semihalf Differential Revision: https://reviews.freebsd.org/D36880
* uart: Remove sbbc referenceWarner Losh2022-10-011-1/+0
| | | | | | sbbc support is for sparc64 only, which was removed in 58aa35d42975. Sponsored by: Netflix
* arm: Catch up with Samsung S3C2xx0 code removalWarner Losh2022-10-012-4/+0
| | | | | | | The code backing these uart_class was removed 7 years ago in 4648ee952520. Sponsored by: Netflix
* uart: uart_cpu_arm64: fix the build without FDTKyle Evans2022-09-291-21/+31
| | | | | | | | | | clang 14 doesn't properly determine that we're unconditionally returning if we have ACPI but not FDT. Push FDT setup entirely into a new function, much like we currently do with ACPI, and just return ENXIO if that doesn't succeed. Reviewed by: andrew, manu (earlier version) Differential Revision: https://reviews.freebsd.org/D36788
* uart_bus_acpi: Read clock frequency from busMateusz Kozyra2022-09-071-9/+19
| | | | | | | | | | | | It is stored in the clock-frequency property. In case of failure, fallback to the harcoded value stored in the compat data. Also, while here improve style. Tested on LS1046ARDB and x86 PC. Reviewed by: mw Obtained from: Semihalf Differential Revision: https://reviews.freebsd.org/D36326
* uart: Add ACPI entry for LS1046A UARTMateusz Kozyra2022-08-221-0/+1
| | | | | | | | | | | | NXP defines unique name for LS1046A UART - "NXP0018". It is ns8250 compatible, adding a new uart compat data entry is enough to make it work. Tested on LS1046ARDB. Approved by: mw(mentor) Reviewed by: mw, kd Obtained from: Semihalf Differential Revision: https://reviews.freebsd.org/D36260
* uart: Don't check SPCR tables if !late_consoleColin Percival2022-07-141-2/+8
| | | | | | | | | | | | | | | | On x86 systems, the debug.late_console tunable makes it possible to set up the console before we call pmap_bootstrap. (The tunable is turned on by default; setting late_console=0 results in consoles being probed early.) Unfortunately this is not compatible with using the ACPI SPCR table to find the console, since consulting ACPI tables requires mapping memory addresses. As such, we skip the call to uart_cpu_acpi_spcr from uart_cpu_x86 in the !late_console case. Reviewed by: imp Sponsored by: https://www.patreon.com/cperciva Differential Revision: https://reviews.freebsd.org/D35794
* Remove unused uart_devclass.John Baldwin2022-05-069-10/+8
|
* uart: plug a set-but-not-used varMateusz Guzik2022-04-191-0/+2
| | | | Sponsored by: Rubicon Communications, LLC ("Netgate")
* uart_dev_lowrisc: Remove unused variables in stub functions.John Baldwin2022-04-121-6/+0
|
* uart_mu: Remove unused variables.John Baldwin2022-04-091-4/+0
|
* quicc_bus_setsig: eliminate write only variable basWarner Losh2022-04-051-2/+0
| | | | Sponsored by: Netflix
* uart(4): Add a concept of "unique" serial devicesColin Percival2022-03-313-0/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | FreeBSD detects serial ports twice: First, very early in the boot process, in order to obtain a usable console; and second, during the device probe/attach process. When a UART is discovered during device probing, FreeBSD attempts to determine whether it is a device which was already being used as a console; without this, the console doesn't work in userland. Unfortunately it's possible for a UART to be mapped to a different location in memory when it is discovered on a bus than it has when it is announced via the ACPI SPCR table; this breaks the matching process, which relies on comparing bus addresses. To address this, we introduce a concept of "unique" serial devices, i.e. devices which are guaranteed to be present *only once* on any system. If we discover one of these during device probing, we can match it to a same-PCI-vendor-and-device-numbers console which was announced via the ACPI SPCR table, regardless of the differing bus addresses. At present, the only unique serial device is the "Amazon PCI serial device" (vendor 0x1d0f, device 0x8250) found in some EC2 instances. This unbreaks the serial console on those systems. Reviewed by: imp MFC after: 3 days Sponsored by: https://www.patreon.com/cperciva Differential Revision: https://reviews.freebsd.org/D34703
* uart_dev_snps: Make ext_resources non-optionalEmmanuel Vadot2022-02-211-18/+0
| | | | | | | | 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/D33828
* uart_dev_imx: Make ext_resources non-optionalEmmanuel Vadot2022-02-211-1/+1
| | | | | | | | 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/D33826
* uart: Remove CTLFLAG_NEEDGIANT from sysctl.Alexander Motin2021-12-261-1/+1
| | | | MFC after: 2 weeks
* uart: Match simple commWarner Losh2021-09-301-0/+15
| | | | | | | | | | | | Match the PCI simple comm devices (or try to). Be conservative and use legacy interrupts rather than msi messages by default for this 'catch all' since it matches what Linux does (it has opt-in generally for MSI, but also matches more devices because it does a catch-all like implemented in this commit). Sponsored by: Netflix Reviewed by: kbowling Differential Revision: https://reviews.freebsd.org/D32228
* uart: Allow PCI quirk for not using MSI interruptsWarner Losh2021-09-301-3/+11
| | | | | | | | | Some setups claim to have one MSI, but they don't actually work. Allow these to be flagged. Sponsored by: Netflix Reviewed by: kbowling Differential Revision: https://reviews.freebsd.org/D32229
* uart: Add PCI ID for intel 100 Series/C230 Series AMTSean Bruno2021-09-251-0/+2
| | | | | | Reviewed by: kib Tested by: kbowling Differential Revision: https://reviews.freebsd.org/D32146
* Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrightsEd Maste2021-08-085-5/+0
| | | | | | | These ones were unambiguous cases where the Foundation was the only listed copyright holder (in the associated license block). Sponsored by: The FreeBSD Foundation
* uart: Fix an out-of-bounds read in ns8250_bus_probe()Mark Johnston2021-07-131-3/+2
| | | | | | | | | | | | | | | | | | | | | | The problem is that ns8250_bus_probe() accesses a field from the ns8250_softc, which embeds the generic UART softc, but the ns8250_softc hasn't yet been allocated because we're still probing. This is a regression from commit 0aefb0a63c50. This fixed a problem where one of the upper four IER bits, which are usually reserved, needs to be set in order to get RX interrupts before the RX FIFO is full. At the same time, we avoid clearing those reserved bits (see commit 58957d87173, though other UART drivers I looked at do not bother with this). So, copy what ns8250_init() does to disable interrupts, since we don't know what the "right" mask is at this point. Reported by: syzbot+f256beefd0df9eb796e7@syzkaller.appspotmail.com Reviewed by: imp MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31124
* uart_dev_ns8250: Switch ACPI UART subtype for Marvell SoCsMarcin Wojtas2021-06-021-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | DBG2 ACPI table description [1] specifies three subtypes related to 16550 UART: 0x0 - 16550 compatible 0x1 - 16550 subset 0x12 - 16550 compatible with parameters defined in Generic Address Structure (GAS) It turned out however, that the Windows OS treats 0x0 subtype as legacy x86 UART with 8-bit access. ARM SoCs can use types 0x1 (16550 with fixed mmio32 access) or 0x12 (16550 with fully respected GAS contents). Switch Marvell SoCs ACPI UART subtype to 0x1 - thanks to that the same firmware can run properly with UART output in FreeBSD, Windows 10, Linux and ESXI hypervisor. Tests showed the older firmware versions that use 0x0 UART subtype in SPCR table continue to display output properly. [1] https://docs.microsoft.com/en-us/windows-hardware/drivers/bringup/acpi-debug-port-table Obtained from: Semihalf Sponsored by: ARM Differential revision: https://reviews.freebsd.org/D30386 MFC after: 2 weeks
* Add support for Gemini Lake LPSS UARTs.Konstantin Belousov2021-05-231-0/+8
| | | | | | | | | | | | | With this patch: % dmesg | grep -i uart uart2: <Intel Gemini Lake SIO/LPSS UART 0> mem 0xa1426000-0xa1426fff,0xa1425000-0xa1425fff irq 4 at device 24.0 on pci0 uart3: <Intel Gemini Lake SIO/LPSS UART 1> mem 0xa1424000-0xa1424fff,0xa1423000-0xa1423fff irq 5 at device 24.1 on pci0 uart4: <Intel Gemini Lake SIO/LPSS UART 2> mem 0xfea10000-0xfea10fff irq 6 at device 24.2 on pci0 uart5: <Intel Gemini Lake SIO/LPSS UART 3> mem 0xa1422000-0xa1422fff,0xa1421000-0xa1421fff irq 7 at device 24.3 on pci0 PR: 256101 Submitted by: Daniel Ponte <amigan@gmail.com> MFC after: 1 week
* Add Apollo Lake SIO/LPSS UARTs PCI IDsJose Luis Duran2021-05-031-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | Add PCI IDs for Intel Apollo Lake Series HSUARTs: # pciconf -ll drv selector class rev hdr vendor device subven subdev uart0@pci0:0:24:0: 118000 0b 00 8086 5abc 8086 7270 uart1@pci0:0:24:1: 118000 0b 00 8086 5abe 8086 7270 uart2@pci0:0:24:2: 118000 0b 00 8086 5ac0 8086 7270 uart3@pci0:0:24:3: 118000 0b 00 8086 5aee 8086 7270 NB (Intel Document Number 336256-004US): 1. The E3900 and A3900 Series Processors support four LPSS_UART ports, while the N- and J- Series Processors support only LPSS_UART [2:1] ports. 2. The LPSS_UART1 port is dedicated for discrete Global Navigation Satellite System (GNSS). This port can be used for generic UART functionality if GNSS is not used. 3. The LPSS_UART2 port is dedicated for host OS debug. 4. The LPSS_UART0 and LPSS_UART3 ports are for generic UART functionality. 5. Only UART [1:0] ports support DMA. PR: 255556 Submitted by: Jose Luis Duran <jlduran@gmail.com> MFC after: 1 week
* uart_bus_pci.c: StyleJose Luis Duran2021-05-031-3/+4
| | | | | | | | Wrap long lines, use tab instead of spaces. PR: 255556 Submitted by: Jose Luis Duran <jlduran@gmail.com> MFC after: 1 week
* ns8250: don't drop IER_TXRDY on bus_grab/ungrabMitchell Horne2021-03-101-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | It has been observed that some systems are often unable to resume from ddb after entering with debug.kdb.enter=1. Checking the status further shows the terminal is blocked waiting in tty_drain(), but it never makes progress in clearing the output queue, because sc->sc_txbusy is high. I noticed that when entering polling mode for the debugger, IER_TXRDY is set in the failure case. Since this bit is never tracked by the softc, it will not be restored by ns8250_bus_ungrab(). This creates a race in which a TX interrupt can be lost, creating the hang described above. Ensuring that this bit is restored is enough to prevent this, and resume from ddb as expected. The solution is to track this bit in the sc->ier field, for the same lifetime that TX interrupts are enabled. PR: 223917, 240122 Reviewed by: imp, manu Tested by: bz MFC after: 5 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D29130