Commit Graph

451 Commits

Author SHA1 Message Date
Matt Macy
f30f0f2b47 Add busy detect quirk to list of console options
This change allows one to set the busy_detect flag
required by the synopsys UART at the loader prompt.
This is needed by the EPYC 3000 SoC.

This will give users a working console up to the point where getty is required:
hw.uart.console="mm:0xfedc9000,rs:2,bd:1"

Reviewed by:	imp
MFC after:	4 weeks
Differential Revision:	https://reviews.freebsd.org/D16399
2018-07-22 23:32:21 +00:00
Diane Bruce
5bede50958 Add a driver for the BCM2835 Mini-UART as seen on the RPi3
Reviewed by:	andrew
Approved by:	andrew
Differential Revision:	https://reviews.freebsd.org/D15684
2018-06-12 13:26:31 +00:00
Andriy Gapon
ec6faf94c4 add support for console resuming, implement it for uart, use on x86
This change adds a new optional console method cn_resume and a kernel
console interface cnresume.  Consoles that may need to re-initialize
their hardware after suspend (e.g., because firmware does not care to do
it) will implement cn_resume.  Note that it is called in rather early
environment not unlike early boot, so the same restrictions apply.
Platform specific code, for platforms that support hardware suspend,
should call cnresume early after resume, before any console output is
expected.

This change fixes a problem with a system of mine failing to resume when
a serial console is used.  I found that the serial port was in a strange
configuration and an attempt to write to it likely resulted in an
infinite loop.

To avoid adding cn_resume method to every console driver, CONSOLE_DRIVER
macro has been extended to support optional methods.

Reviewed by:	imp, mav
MFC after:	3 weeks
Differential Revision: https://reviews.freebsd.org/D15552
2018-05-29 16:16:24 +00:00
Emmanuel Vadot
837db84723 uart_snps: Add early printf support
Move the allwinner early printf support to the snps driver as it
should work with all implementation.
While here add instruction for enabling it on 64bits SoCs.
2018-05-01 13:57:08 +00:00
Brooks Davis
6469bdcdb6 Move most of the contents of opt_compat.h to opt_global.h.
opt_compat.h is mentioned in nearly 180 files. In-progress network
driver compabibility improvements may add over 100 more so this is
closer to "just about everywhere" than "only some files" per the
guidance in sys/conf/options.

Keep COMPAT_LINUX32 in opt_compat.h as it is confined to a subset of
sys/compat/linux/*.c.  A fake _COMPAT_LINUX option ensure opt_compat.h
is created on all architectures.

Move COMPAT_LINUXKPI to opt_dontuse.h as it is only used to control the
set of compiled files.

Reviewed by:	kib, cem, jhb, jtl
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D14941
2018-04-06 17:35:35 +00:00
Andrew Turner
92457451f4 The Arm pl011 driver assumes it's running a devicetree based system.
It calls OF_* functions to check if it needs to implement workarounds.
This may not be the case on arm64 where we support both FDT and ACPI.
Fix this by checking if we are booting on FDT before calling these checks.

Reviewed by:	ian
Sponsored by:	DARPA, AFRL
Sponsored by:	Cavium (Hardware)
Differential Revision:	https://reviews.freebsd.org/D14515
2018-02-28 15:02:27 +00:00
Andrew Turner
104518ad6d Check all entries in the ACPI uart compat table and not just the first.
Sponsored by:	DARPA, AFRL
2018-02-26 08:45:38 +00:00
Andrew Turner
615395d985 Teach the Arm pl011 driver to attach to a SBSA uart. This is defined in
the Server Base System Architecture to be a subset of the pl011 r1p5. As
we don't use the removed features it is safe to just attach to the existing
driver as is.

Sponsored by:	DARPA, AFRL
2018-02-25 19:43:00 +00:00
Andrew Turner
db65b25f88 Rename the FDT compat_data array to a bus-specific name.
Sponsored by:	DARPA, AFRL
2018-02-25 19:33:27 +00:00
Andrew Turner
c81131d9ec Disable EARLY_PRINTF from the Armada 3700 uart, it breaks when we want
to use EARLY_PRINTF on other SoCs.

Sponsored by:	DARPA, AFRL
2018-02-01 15:05:17 +00:00
Emmanuel Vadot
09ac343759 arm: lpc: Remove support
Code hasn't been touch this it's original commit in 2012 beside api changes.

Reviewed by:	ian
Differential Revision:	https://reviews.freebsd.org/D13625
Discussed with:		freebsd-arm@freebsd.org (no reply)
2018-01-24 22:04:16 +00:00
Ruslan Bukin
e6dd0a0e92 UART Clock Selection Register holds a divider value for a supplied clock,
not a final baud rate. The value for this register has to be calculated.

Sponsored by:	DARPA, AFRL
2018-01-18 18:19:31 +00:00
Ruslan Bukin
9f7743f2c8 Support for UART device found in Qualcomm Snapdragon 410E SoC.
Tested on DragonBoard 410c.

Reviewed by:	andrew
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D13972
2018-01-18 17:43:32 +00:00
Alexander Kabaev
151ba7933a Do pass removing some write-only variables from the kernel.
This reduces noise when kernel is compiled by newer GCC versions,
such as one used by external toolchain ports.

Reviewed by: kib, andrew(sys/arm and sys/arm64), emaste(partial), erj(partial)
Reviewed by: jhb (sys/dev/pci/* sys/kern/vfs_aio.c and sys/kern/kern_synch.c)
Differential Revision: https://reviews.freebsd.org/D10385
2017-12-25 04:48:39 +00:00
Warner Losh
5fe4723c70 Create a new ISA_PNP_INFO macro. Use this macro every where we have
ISA PNP card support (replace by hand version in if_ed). Move module
declarations to the end of some files. Fix PCCARD_PNP_INFO to use
nitems(). Remove some stale comments about pc98, turns out the comment
was simply wrong.
2017-12-23 06:49:27 +00:00
Andrew Turner
fb006e46e7 Set the io width when using an ACPI uart. Previously it would only ever be
set when finding the uart from the device tree.

Sponsored by:	DARPA, AFRL
2017-12-08 10:05:23 +00:00
Pedro F. Giffuni
718cf2ccb9 sys/dev: further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.
2017-11-27 14:52:40 +00:00
Ed Maste
6e71b3c3ed uart: detect 256-byte FIFOs
Submitted by:	Zakary Nafziger <worldofzak@gmail.com>
Sponsored by:	The FreeBSD Foundation
2017-10-10 20:08:30 +00:00
Marcin Wojtas
ac0770ddb3 Introduce UART driver module for Armada 3700
This patch adds support for UART in Armada 3700 family.
It exposes both low-level UART interface, as well as
standard driver methods.

Submitted by: Patryk Duda <pdk@semihalf.com>
Obtained from: Semihalf
Sponsored by: Semihalf
Differential Revision: https://reviews.freebsd.org/D12250
2017-09-09 11:42:32 +00:00
Ed Maste
059178b639 uart: add AX99100 chipset support
PR:		215837
Submitted by:	joe@thrallingpenguin.com
MFC after:	2 weeks
2017-07-27 02:53:18 +00:00
Andrew Turner
88df15adf6 Fix device lookup of for the stdout-path chosen property.
The stdout-path chosen property may include the serial connection details,
e.g. the baud rate. When passing the device to OF_finddevice we need to
strip off this information as it will cause the lookup to fail.

Reviewed by:	emaste, manu
Differential Revision:	https://reviews.freebsd.org/D6846
2017-06-02 14:01:17 +00:00
Ed Maste
ef7161e774 uart: add AMT SOL PCI ID
I adjusted the description to be similar to existing AMT entries.

PR:		219384
Submitted by:	"Tooker"
MFC after:	1 week
2017-05-27 02:07:22 +00:00
Alexander Motin
31da007f7e Fix typo in r317659.
MFC after:	2 weeks
2017-05-03 16:34:03 +00:00
Alexander Motin
4e352a4583 Make some UART consoles to not spin wait for data to be sent.
At least with Tx FIFO enabled it shows me ~10% reduction of verbose boot
time with serial console at 115200 baud.

Reviewed by:	marcel
MFC after:	2 weeks
2017-05-01 19:47:10 +00:00
Ian Lepore
bf8bdd6762 Extend the pl011 small-fifos fix to other SoCs that indicate rev 5
hardware but lack the larger fifos rev 5 hardware should have.

The linux world (where our FDT data comes from) solved this by adding
a new property to pl011 nodes, "arm,primecell-periphid".  When this
property is present, its values override the values in the hardware
periphid registers.  For pl011 rev 5 hardware with small fifos, they
override the id so that it appears to be rev 4 hardware.

The driver now uses the new property when present.  It also continues
to check the device compat string, to handle older fdt data that may
still be in use on existing systems (on RPi systems it is common to
update system software without updating fdt data which is part of the
boot firmware).

Reviewed by:	imp
2017-03-11 22:34:02 +00:00
Ian Lepore
43597fd575 Update the comment for the Wacom WACF00e to make it clear it's not an
accidental duplicate of WACF004.

PR:		217306
2017-03-08 20:58:56 +00:00
Ian Lepore
a90beeeb44 Add the pnp id for a Wacom 'WACF00e' tablet.
PR:		217306
Submitted by:	large.hadron.collider@gmx.com
2017-03-08 20:41:27 +00:00
Ian Lepore
2cb357c5cd Handle fifo size differences between older and newer revs of pl011 hardware.
Starting with rev 5 (which is inexplicably indicated by a version number
of '3' in the Peripheral ID register), the pl011 doubled the size of the
rx and tx fifos, to 32 bytes, so read the ID register and set the size
variables in the softc accordingly.

An interesting wrinkle in this otherwise-simple concept is that the
bcm2835 SoC, used in Raspberry Pi systems among others, has the rev 5
pl011 hardware, but somehow also has the older 16-byte fifos.  We check
the FDT data to see if the hardware is part of a bcm283x system and use
the smaller size if so.

Thanks to jchandra@ for pointing out that newer hardware has bigger fifos.
2017-03-08 18:53:32 +00:00
Ian Lepore
ac0577afe9 Reconfigure the fifo watermark levels on the pl011 uart to interrupt when
the fifos are 3/4 full (rc) or empty (tx).
2017-03-04 22:00:05 +00:00
Ian Lepore
752e8c08fb Fix bugs exposed by the recent enabling of FIFOs in the pl011 uart. These
have been in the code all along, but were masked by having a fifo depth of
one byte at the hardware level, so everything kinda worked by accident.

The hardware interrupts when the TX fifo is half empty, so set
sc->sc_txfifosz to 8 bytes (half the hardware fifo size) to match.  This
eliminates dropped characters on output.

Restructure the read loop to consume all the bytes in the fifo by using
the "rx fifo empty" bit of the flags register rather than the "rx ready"
bit of the interrupt status register.  The rx-ready interrupt is cleared
when the number of bytes in the fifo fall below the interrupt trigger
level, leaving the fifo half full every time receive routine was called.
Now it loops until the fifo is completely empty every time (including
when the function is called due to a receive timeout as well as for
fifo-full).
2017-03-04 21:47:43 +00:00
Ruslan Bukin
c214a270f5 Allow setting access-width for UART registers.
This is required for FDT's standard "reg-io-width" property
(similar to "reg-shift" property) found in many DTS files.

This fixes operation on Altera Arria 10 SOC Development Kit,
where standard ns8250 uart allows 4-byte access only.

Reviewed by:	kan, marcel
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D9785
2017-02-27 20:08:42 +00:00
Ruslan Bukin
2770885882 Revert r314212 as it break Allwinner boards.
Reported by:	manu
2017-02-27 19:46:27 +00:00
Jayachandran C.
43ad57d358 Enable pl011 UART FIFOs
The pl011 UART has a 16 entry Tx FIFO and a 16 entry Rx FIFO that
have not been used so far. Update the driver to enable the FIFOs
and use them in transmit and receive.

Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D8819
2017-02-26 22:05:22 +00:00
Ruslan Bukin
e42e2a1edc Use correct macro for Synopsys UART driver declaration. 2017-02-24 16:37:35 +00:00
Yoshihiro Takahashi
2b375b4edd Remove pc98 support completely.
I thank all developers and contributors for pc98.

Relnotes:	yes
2017-01-28 02:22:15 +00:00
Bruce M Simpson
fb1d9b7f41 Allow uart(4) to use MSI interrupts on single-port PCI instances.
Do this here as puc(4) disallows single-port instances; at least
one multi-port PCIe UART chip (in this case, the ASIX MCS9922)
present separate PCI configuration space (functions) for each UART.

Tested using lrzsz and a null-modem cable. The ExpressCard/34
variants containing the MCS9922 should also use MSI with this change.

Reviewed by:		jhb, imp, rpokala
MFC after:		2 weeks
Differential Revision:	https://reviews.freebsd.org/D9123
2017-01-12 16:30:27 +00:00
Jayachandran C.
e4ad7e3451 Fix whitespace issues in pl011 uart driver
Fix up trailing whitespace introduced by r310190. While there,
fix a couple of earlier whitespace errors as well.
2016-12-19 19:40:11 +00:00
Jayachandran C.
660c1ea0b4 Simplify interrupt mask programming in pl011 uart
Remove unused fields from uart_pl011_softc. Add an interrupt mask
field to the softc and use it to set the interrupt mask register.

There should be no functional change introduced here except in the
grab and ungrab functions. In these functions, we now disable and
enable all interrupts rather than just the receive interrupt.
2016-12-17 18:04:59 +00:00
Jayachandran C.
cbee50f1df Fix interrupt clear in pl011 uart receive function
Clear the interrupt state before reading the input char from the
input FIFO. In the current code there is a window between the read
to the data register and the write to the the ICR, during which an
input char will not cause an interrupt.

This fixes the issue by which the serial port input on QEMU freezes
when using the emulated pl011 serial port.
2016-11-29 04:32:14 +00:00
Andrew Turner
ef022bb1de Include the missing accommon.h from the ACPI uart code.
Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
2016-11-21 19:38:57 +00:00
Andrew Turner
eba1a249df Add support to find the arm64 serial using the ACPI tables. This uses the
Serial Port Console Redirection Table to find the device to use.

Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
2016-11-21 19:26:58 +00:00
Sean Bruno
cb3c7e7f93 Add Intel Atom Cherryview SOC HSUART support
PR:	207910
Submitted by:	johannes@brilliantservice.co.jp
MFC after:	1 week
2016-11-21 14:43:31 +00:00
Andrew Turner
0812ab3141 Add an arm64 specific uart cpu driver. As arm64 may use ACPI to find the
uart we need to handle both it and FDT, and as such we need to have an
architecture specific driver.

Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D7796
2016-11-21 11:27:14 +00:00
Ruslan Bukin
5515b0cb39 Do not reallocate driver softc for uart unnecessarily.
Do not assume that all uart drivers use uart_softc structure as is.
Some do a sensible thing and do declare their uart class and driver
properly and arrive into uart_bus_attach with suitably sized softc.

Submitted by:	kan
Sponsored by:	DARPA, AFRL
2016-11-17 16:06:53 +00:00
Ruslan Bukin
b192bae67e Add support for UART found in the Ingenic XBurst system on chips.
These CPUs has non-standard UART enable bit hidden in the UART FIFO
Control Register.

Sponsored by:	DARPA, AFRL
2016-11-17 14:41:22 +00:00
Andrew Turner
a2696bf3c0 Use ofw_bus_node_is_compatible in more drivers used on arm.
Sponsored by:	ABT Systems Ltd
2016-11-11 15:42:12 +00:00
Justin Hibbits
24f4202df8 Check all compatible strings on uart devices in powerpc
Summary:
Some device trees put "fsl,ns16650" first in the compatible list.  This causes
the probe code to choke, even though the device is compatible with ns16650, and
has it listed later in the tree.

Reviewed by:	nwhitehorn
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D7676
2016-08-28 21:31:21 +00:00
Justin Hibbits
7bd8311dec Fix UART PPS capture mode printing
* Add breaks to prevent fallthrough and printing of multiple modes.
* Only check the mode, mask out all other bits.
2016-08-28 04:40:27 +00:00
Andrew Turner
07ef31f240 Remove now unused functions from the FDT uart cpu driver.
Obtained from:	ABT Systems Ltd
MFC after:	1 month
X-MFC with:	r303100
Sponsored by:	The FreeBSD Foundation
2016-07-24 08:52:49 +00:00
Andrew Turner
951154084f Fix the build:
* Add acpi_if.h to the SRC list in the uart module
 * Only include new acpi headers when they are needed

Obtained from:	ABT Systems Ltd
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-07-21 13:01:35 +00:00
Andrew Turner
cf9df3c56b Add support for arm64 to uart_dev_acpi by using the _HID property to find
the uart class to use in a similar way as the fdt driver.

Obtained from:	ABT Systems Ltd
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D7248
2016-07-21 09:32:55 +00:00
Andrew Turner
d4c893910d We will be switching to a new arm64 uart cpu driver that handles both FDT
and ACPI. As such pull out what will be the common parts of the FDT cpu
detection to a new function that can be shared between them.

Reviewed by:	manu
Obtained from:	ABT Systems Ltd
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D7262
2016-07-20 17:19:47 +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
Pedro F. Giffuni
453130d9bf sys/dev: minor spelling fixes.
Most affect comments, very few have user-visible effects.
2016-05-03 03:41:25 +00:00
Andrew Turner
9c42d415a3 Stop including machine/fdt.h from the fdt uart code, it's unneeded.
Sponsored by:	ABT Systems Ltd
2016-04-26 13:16:45 +00:00
Ruslan Bukin
5c3a3f25ce Do not include fdt.h on RISC-V. 2016-04-26 12:31:23 +00:00
Pedro F. Giffuni
323b076e9c sys: use our nitems() macro when param.h is available.
This should cover all the remaining cases in the kernel.

Discussed in:	freebsd-current
2016-04-21 19:40:10 +00:00
Pedro F. Giffuni
8dfea46460 Remove slightly used const values that can be replaced with nitems().
Suggested by:	jhb
2016-04-21 15:38:28 +00:00
Pedro F. Giffuni
74b8d63dcc Cleanup unnecessary semicolons from the kernel.
Found with devel/coccinelle.
2016-04-10 23:07:00 +00:00
Jared McNeill
b738dafd90 Move support for Synopsys Designware APB UART out of ns8250 and into a
separate driver. Add support for activating clock and hwreset resources
for these devices when the EXT_RESOURCES option is present.

Reviewed by:		andrew, mmel, Emmanuel Vadot <manu@bidouilliste.com>
Approved by:		adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D5749
2016-04-01 20:26:45 +00:00
Wojciech Macek
3b654e081a Add ns16550a compatible string in UART 8250 driver
Obtained from:         Semihalf
Submitted by:          Michal Stanek <mst@semihalf.com>
Sponsored by:          Annapurna Labs
Approved by:           cognet (mentor)
Reviewed by:           imp, wma
Differential revision: https://reviews.freebsd.org/D5404
2016-02-26 08:43:36 +00:00
Ian Lepore
3f817dd216 Stop using the global fdtbus_bs_tag and instead use the tag from the softc
that was set up properly at init time.
2016-02-23 03:34:36 +00:00
Ian Lepore
b1c2e02c10 This code no longer references fdtbus_bs_tag, no need for a special extern
declaration of it for aarch64.
2016-02-23 03:01:46 +00:00
Ian Lepore
99c4102214 Now that we have OF_decode_addr(), with proper MD implementations, to obtain
the bus space tag and handle for a uart console, use the values returned by
that routine to set the global uart_bus_space_mem, instead of assuming that
there will be a global variable named fdtbus_bs_tag to set it from.

Also, use OF_getencprop() instead calling fdt32_to_cpu() separately.
2016-02-23 02:57:45 +00:00
Andrew Turner
45fd186285 Allow callers of OF_decode_addr to get the size of the found mapping. This
will allow for code that uses the old fdt_get_range and fdt_regsize
functions to find a range, map it, access, then unmap to replace this, up
to and including the map, with a call to OF_decode_addr.

As this function should only be used in the early boot code the unmap is
mostly do document we no longer need the mapping as it's a no-op, at least
on arm.

Reviewed by:	jhibbits
Sponsored by:	ABT Systems Ltd
Differential Revision:	https://reviews.freebsd.org/D5258
2016-02-16 15:18:12 +00:00
Michal Meloun
3c7b90774d UART: Fix spurious interrupts generated by ns8250 and lpc drivers:
- don't enable transmitter empty interrupt before filling TX FIFO.
 - add missing uart_barrier() call in interrupt service routine
2016-02-12 05:14:58 +00:00
Andrew Turner
4f42bf9497 Explicitly include <sys/systm.h>. Previously we were pulling it in due to
header pollution.
2016-02-10 16:49:20 +00:00
Marius Strobl
57169cea64 - Make the code consistent with itself style-wise and bring it closer
to style(9).
- Mark unused arguments as such.
- Make the ttystates table const.
2016-01-25 22:58:06 +00:00
Zbigniew Bodek
8abfc69d11 Fix busy-detect when using DesignWare UART
uart_dev_ns8250 now relies on compatible property instead of additional
'busy-detect' cell. All drivers with compatible = "snps,dw-apb-uart" have
busy detection turned on. DTS files of devices affected by the change
were modified and 'busy-detect' property was removed.

Reviewed by:    andrew, ian, imp
Obtained from:  Semihalf
Sponsored by:   Stormshield
Submitted by:   Bartosz Szczepanek <bsz@semihalf.com>
Differential revision:  https://reviews.freebsd.org/D4218
2016-01-20 13:51:14 +00:00
Zbigniew Bodek
a6c981778c Add compatibility string for dw-apb-uart in ns8250 driver
This compatibility string is used in .dts file of Armada38x
and isrequired for driver attachment.

Reviewed by:    andrew, ian, imp
Obtained from:  Semihalf
Sponsored by:   Stormshield
Submitted by:   Michal Stanek <mst@semihalf.com>
Differential revision:  https://reviews.freebsd.org/D4216
2016-01-20 13:47:44 +00:00
Marius Strobl
9750d9e5b6 Fix tty_drain() and, thus, TIOCDRAIN of the current tty(4) incarnation
to actually wait until the TX FIFOs of UARTs have be drained before
returning. This is done by bringing the equivalent of the TS_BUSY flag
found in the previous implementation back in an ABI-preserving way.
Reported and tested by: Patrick Powell

Most likely, drivers for USB-serial-adapters likewise incorporating
TX FIFOs as well as other terminal devices that buffer output in some
form should also provide implementations of tsw_busy.

MFC after:	3 days
2016-01-19 23:34:27 +00:00
Ian Lepore
2a81017500 Use OF_decode_addr() to create a bus_space tag and handle for the console
on FDT/OFW platforms.

After the refactoring of the powerpc code so that OF_decode_addr() is usable
on all FDT/OFW platforms, this switches uart(4) to using it.

Differential Revision:	https://reviews.freebsd.org/D4675
2016-01-18 17:03:12 +00:00
Ian Lepore
fdfbb3f5b1 Restore uart PPS signal capture polarity to its historical norm, and add an
option to invert the polarity in software. Also add an option to capture
very narrow pulses by using the hardware's MSR delta-bit capability of
latching line state changes.

This effectively reverts the mistake I made in r286595 which was based on
empirical measurements made on hardware using TTL-level signaling, in which
the logic levels are inverted from RS-232. Thus, this re-syncs the polarity
with the requirements of RFC 2783, which is writen in terms of RS-232
signaling.

Narrow-pulse mode uses the ability of most ns8250 and similar chips to
provide a delta indication in the modem status register. The hardware is
able to notice and latch the change when the pulse width is shorter than
interrupt latency, which results in the signal no longer being asserted by
time the interrupt service code runs. When running in this mode we get
notified only that "a pulse happened" so the driver synthesizes both an
ASSERT and a CLEAR event (with the same timestamp for each). When the pulse
width is about equal to the interrupt latency the driver may intermittantly
see both edges of the pulse. To prevent generating spurious events, the
driver implements a half-second lockout period after generating an event
before it will generate another.

Differential Revision:	https://reviews.freebsd.org/D4477
2016-01-12 18:42:00 +00:00
Warner Losh
f6cea53f9d Create a generic PCCARD_PNP_INFO from the MODULE_PNP_INFO building
block. Use it in all the PNP drivers to export either the current PNP
table. For uart, create a custom table and export it using
MODULE_PNP_INFO since it's the only one that matches on function
number.

Differential Review: https://reviews.freebsd.org/D3461
2015-12-11 05:27:56 +00:00
Kevin Lo
d4438cd2b4 Remove a duplicate definition. 2015-12-05 15:09:19 +00:00
Adrian Chadd
e0fe7c958f uart(4) - make the 8250 uart baudrate tolerance build time tweakable.
It turns out on a 16550 w/ a 25MHz SoC reference clock you get a little
over 3% error at 115200 baud, which causes this to fail.

Just .. cope. Things cope these days.

Default to 30 (3.0%) as before, but allow UART_DEV_TOLERANCE_PCT to be
set at build time to change that.
2015-11-18 06:24:21 +00:00
Alexander Motin
0a5c75e53c Add ID for Intel Panther Point KT Controller
Found on ASUS P8Q77-M motherboard.

Submitted by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after:	2 weeks
2015-09-13 12:08:25 +00:00
Andrew Turner
d5ad1d0d6d Allow us to set the console device tree node. This is needed as not all
vendor supplied device trees contain the needed properties for us to select
the correct uart to use as the kernel console.

An example of this would be to add the following to loader.conf.
hw.fdt.console="/smb/uart@f7113000"

The intention of this is slightly different than the existing
hw.uart.console option. The new option will mean the boot serial
configuration will be derived from the device node, while the existing
option expects the user to configure all this themselves.

Further work is planned to allow the uart configuration to be set based on
the stdout-path property devicetree bindings.

Sponsored by:	ABT Systems Ltd
Differential Revision:	https://reviews.freebsd.org/D3559
2015-09-08 16:06:04 +00:00
Marcel Moolenaar
7bd6f3d060 Add support for the Broadcom TruManage integrated serial port.
PR:		191266
2015-08-12 15:48:14 +00:00
Marcel Moolenaar
9def69ec5f Use bus_alloc_resource_any(), rather than bus_alloc_resource()
with start 0 and end ~0. This avoids confusion WRT to what the
value of length can or should be.
2015-08-12 04:03:04 +00:00
Ian Lepore
dc4aaf6dd1 Style fix, no functional changes -- do the braces for switches correctly. 2015-08-11 02:30:54 +00:00
Ian Lepore
fac6a198c3 Correct the polarity of the PPS assert and clear events with respect to the
electrical signals on the serial port.  Virtually all devices which output a
PPS signal generate a brief higher-voltage pulse, the leading edge of which
is the on-time point.

Both DCD and CTS are active-low signals on the wire, meaning the assertion
of their status bits in the modem status register corresponds to the lower
voltage level on the wire.  So when the status bit transitions to not-set,
create a PPS assert event; when the status bit transitions to set, create a
PPS clear event.
2015-08-10 20:54:03 +00:00
Ian Lepore
196d3019a8 Allow the choice of PPS signal captured by uart(4) to be runtime-configured,
eliminating the need to build a custom kernel to use the CTS signal.

The historical UART_PPS_ON_CTS kernel option is still honored, but now it
can be overridden at runtime using a tunable to configure all uart devices
(hw.uart.pps_mode) or specific devices (dev.uart.#.pps_mode).  The per-
device config is both a tunable and a writable sysctl.

This syncs the PPS capabilities of uart(4) with the enhancements recently
recently added to ucom(4) for capturing from USB serial devices.

Relnotes:	yes
2015-08-10 20:08:09 +00:00
Ian Lepore
b59236cece Provide the tty-layer mutex when initializing the pps api. This allows
time_pps_fetch() to be used in blocking mode.

Also, don't init the pps api for system devices (consoles) that provide a
custom attach routine.  The device may actually be a keyboard or other non-
tty device.  If it wants to do pps processing (unlikely) it must handle
everything for itself.  (In reality, only a sun keyboard uses a custom
attach routine, and it doesn't make a good pps device.)
2015-08-08 20:11:47 +00:00
Marius Strobl
86fb540033 - Since r253161, uart_intr() abuses FILTER_SCHEDULE_THREAD for signaling
uart_bus_attach() during its test that 20 iterations weren't sufficient
  for clearing all pending interrupts, assuming this means that hardware
  is broken and doesn't deassert interrupts. However, under pressure, 20
  iterations also can be insufficient for clearing all pending interrupts,
  leading to a panic as intr_event_handle() tries to schedule an interrupt
  handler not registered. Solve this by introducing a flag that is set in
  test mode and otherwise restores pre-r253161 behavior of uart_intr(). The
  approach of additionally registering uart_intr() as handler as suggested
  in PR 194979 is not taken as that in turn would abuse special pccard and
  pccbb handling code of intr_event_handle(). [1]
- Const'ify uart_driver_name.
- Fix some minor style bugs.

PR:		194979 [1]
Reviewed by:	marcel (earlier version)
MFC after:	3 days
2015-07-24 17:01:16 +00:00
Neel Natu
62145ff347 If uart interrupts are not functioning then schedule the callout to do the
polling at device attach time [1].

Add tunables 'debug.uart_force_poll' and 'debug.uart_poll_freq' to control
uart polling.

Submitted by:	Aleksey Kuleshov (rndfax@yandex.ru) [1]
2015-07-16 04:15:22 +00:00
Sean Bruno
4abd25091d Add new UART device presented on newer AMT enabled systems/laptops.
Tested on Dell Latitude E7240.

MFC after:	2 weeks
Relnotes:	yes
2015-06-22 17:16:09 +00:00
Marcel Moolenaar
9308005ed9 Add support for the Intel Atom E3800 series SoC (aka Bay Trail).
Sponsored by:	XipLink, Inc
2015-06-20 04:02:33 +00:00
Luiz Otavio O Souza
b1621f22b3 Actually check the DTS node value to enable the uart quirks.
Without this fix, you cannot disable the quirks by setting it to 0, just
the presence of the FDT node was enough to enable it.
2015-05-30 16:30:51 +00:00
Oleksandr Tymoshenko
5b03aba6c8 Switch TI platform support code from using FreeBSD's custom-baked DTS
files to vendor-provided ones. It should make easier to adopt platform
code to new revisions of hardware and to use DTS overlays for various
Beaglebone extensions (shields/capes).

Original dts filenames were not changed, they're now wrappers over dts
files provided by TI. So make sure you update .dtb files on your
devices as part of kernel update

GPIO addressing was changed: instead of one global /dev/gpioc0 there
are per-bank instances of /dev/gpiocX. Each bank has 32 pins so for
instance pin 121 on /dev/gpioc0 in old addressing scheme is now pin 25
on /dev/gpioc3

On Pandaboard serial console devices was changed from /dev/ttyu0 to
/dev/ttyu2 so you'll have to update /etc/ttys to get login prompt
on serial port in multiuser mode. Single user mode serial console
should work as-is

Differential Revision:	https://reviews.freebsd.org/D2146
Reviewed by:	rpaulo, ian, Michal Meloun, Svatopluk Kraus
2015-05-22 03:16:18 +00:00
Andrew Turner
405ada37fb Add support for the uart classes to set their default register shift value.
This is needed with the pl011 driver. Before this change it would default
to a shift of 0, however the hardware places the registers at 4-byte
addresses meaning the value should be 2.

This patch fixes this for the pl011 when configured using the fdt. The
other drivers have a default value of 0 to keep this a no-op.

MFC after:	1 week
2015-04-11 17:16:23 +00:00
Andrew Turner
be3b046ce8 Get the fdt uart driver working on arm64, there is no machine/fdt.h, and
the default shift should be 2 for the SoCs we support.

Sponsored by:	The FreeBSD Foundation
2015-04-07 15:12:03 +00:00
Andrew Turner
7966cc995c Fix uart_fdt_get_clock. It should have beed using the cell variable passed
in, not value on the stack.
2015-04-07 12:42:06 +00:00
Andrew Turner
a8b295acf3 Move uart_fdt_get_clock and uart_fdt_get_shift to uart_bus_fdt.c, we may
not build uart_cpu_fdt.c in all configs.
2015-04-04 18:45:25 +00:00
Andrew Turner
06d8b1ed6e Remove the extra copy of uart_fdt_get_clock and uart_fdt_get_shift. While
here also use OF_getencprop in uart_fdt_get_clock.

Sponsored by:	The FreeBSD Foundation
2015-04-04 09:57:52 +00:00
Andrew Turner
3d2a63f5ac Use OF_getencprop over OF_getprop and fdt32_to_cpu. The latter may give
us the wrong data in the failure case if shift was not zero.

Sponsored by:	The FreeBSD Foundation
2015-04-04 09:21:56 +00:00
Eitan Adler
918057d9a9 And it turns out someone beat me to it....
PR:		199013
2015-03-30 08:54:59 +00:00
Eitan Adler
d930009250 Add support for "MosChip MCS9922 PCIe to Peripheral Controller" to uart
Submitted by:	<mlsemon35@gmail.com>
PR:		199013
MFC After:	1 month
2015-03-30 08:48:35 +00:00
Ian Lepore
3bb693af87 Move the uart_class definitions and fdt compat data into the individual
uart implementations, and export them using the new linker-set mechanism.

Differential Revision:	https://reviews.freebsd.org/D1993
Submitted by:	Michal Meloun
2015-03-07 15:24:15 +00:00
Ian Lepore
bd69e3ad2f Define new linker set, UART_FDT_CLASS_AND_DEVICE, for registering full
(class and device) FDT UART. Define second one, UART_FDT_CLASS, for UART
class only.

This paves the way for declaring uart_class data and ofw/fdt compat data
with a uart implementation, rather than needing a big global table of
compat data and weak-symbol declarations of every existing implementation.

Differential Revision:	https://reviews.freebsd.org/D1992
Submitted by:	Michal Meloun
2015-03-07 15:18:57 +00:00