Commit Graph

385 Commits

Author SHA1 Message Date
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
Andrew Turner
83724a87a4 Fix the pl011 driver to work when the uart will write in zero cycles. This
is the case, depending on the options, in some of the ARM hardware
simulators. In these cases we don't get an interrupt so will need to
schedule the task to write more data to the uart.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2015-03-03 09:48:19 +00:00
Ruslan Bukin
83dbea149e Enable 'receive timeout' interrupt allowing us to not
loose 'rx buffer full' event.

This fixes operation on ARMv8 Foundation Model.

Sponsored by:	DARPA, AFRL
2015-02-24 15:35:26 +00:00
John Baldwin
a1d18b6615 Add the device ID for the AMT serial port on my Thinkpad T400.
MFC after:	1 week
2015-02-05 21:50:51 +00:00
Ruslan Bukin
eff43c7467 Rename Exynos UART driver. No functional change.
Submitted by:	Michal Meloun <meloun@miracle.cz>
2015-01-13 15:04:28 +00:00
Peter Grehan
7e47312c46 Add PCI ID for the Oxford Semiconductor OXPCIe952 device.
Seen on the StarTech "1 Port Native ExpressCard RS232 Serial AdapterCard
 with 16950 UART"

Reported and tested by:	Michael Dexter
MFC after:	1 week
2015-01-12 03:39:56 +00:00
Marius Strobl
393677427c Don't use a sub-device/-vendor wildcard for probing MCS9922 as other
chips with the same device and vendor IDs actually may provide different
functionality. While at it, canonicalize the description to match other
MosChip UARTs.

PR:		186891
MFC after:	3 days
2014-12-28 21:36:20 +00:00
Alexander Motin
e67f3bec39 Add bunch of PCI IDs of Intel Wildcat Point (9 Series) chipsets.
MFC after:	1 week
2014-11-26 04:23:21 +00:00
Zbigniew Bodek
bf39c5e8d5 Make uart_bus_fdt a decendant of ofwbus
This will allow to attach UART drivers lying directly on the root node
instead of simple-bus compatible bus only.

Obtained from:   Semihalf
Sponsored by:    The FreeBSD Foundation
2014-11-12 21:41:15 +00:00
Zbigniew Bodek
17d2ee0132 Make PL011 UART to wait on putc only when TX FIFO is full
Instead of waiting for empty TX FIFO it is more reasonable to
block on full FIFO. As soon as FIFO slot is free the character
can be transmitted.
In case of TX FIFO disabled, TXFF bit indicates that transmit
register is not empty.

Obtained from:   Semihalf
Reviewed by:     andrew, emaste
Sponsored by:    The FreeBSD Foundation
2014-11-12 21:38:31 +00:00
Marcelo Araujo
3bde81092c Drop __DECONST as well as few fixes of style(9).
Phabric:	D1012
Suggested by:	mjg, jhb
Reviewed by:	mjg, jhb
Sponsored by:	QNAP Systems Inc.
2014-10-28 03:42:09 +00:00
Marcelo Araujo
f695e0468c Fix a leaked Storage Variable.
Phabric:	D981
Submitted by:	myself
Reported by:	Coverity
CID:		1248848
Reworked by:	kevlo
Reviewed by:	marcel, davide, ray, kevlo
Approved by:	marcel, kevlo
2014-10-24 05:39:32 +00:00
Davide Italiano
2be111bf7d Follow up to r225617. In order to maximize the re-usability of kernel code
in userland rename in-kernel getenv()/setenv() to kern_setenv()/kern_getenv().
This fixes a namespace collision with libc symbols.

Submitted by:   kmacy
Tested by:      make universe
2014-10-16 18:04:43 +00:00
Ian Lepore
0dc54d18b2 Use the FIFOs in the imx5/imx6 uart hardware instead of interrupting on
each byte sent or received.
2014-10-12 17:56:02 +00:00
Ganbold Tsagaankhuu
7f29c69aee Use documented compat string for msm uart.
Whilst here use tab instead of spaces.

Approved by:    stas (mentor)
2014-10-06 09:00:53 +00:00
Ganbold Tsagaankhuu
dc7717a863 Add uart driver for Qualcomm MSM 7000/8000 series chips.
It is working on IFC6410 board which has Qualcomm Snapdragon SoC.

Approved by:    stas (mentor)
2014-10-02 08:12:42 +00:00
Ian Lepore
c3f0f2847f Return the actual baud rate programmed in the hardware rather than 115200.
This allows the "3wire" entry in /etc/ttys (with no speed specified) to work.
2014-09-30 23:01:11 +00:00
Marcel Moolenaar
359ee827e1 Do not fail the low-level device probe simply because the kernel
doesn't have support for the Z8530. Embedded PowerPC platforms
typically don't. Fail when the device class we actually need is
not present.

Obtained from:	Juniper Networks, Inc.
2014-07-26 17:49:40 +00:00
Marcel Moolenaar
e7d939bda2 Remove ia64.
This includes:
o   All directories named *ia64*
o   All files named *ia64*
o   All ia64-specific code guarded by __ia64__
o   All ia64-specific makefile logic
o   Mention of ia64 in comments and documentation

This excludes:
o   Everything under contrib/
o   Everything under crypto/
o   sys/xen/interface
o   sys/sys/elf_common.h

Discussed at: BSDcan
2014-07-07 00:27:09 +00:00
Hans Petter Selasky
af3b2549c4 Pull in r267961 and r267973 again. Fix for issues reported will follow. 2014-06-28 03:56:17 +00:00
Glen Barber
37a107a407 Revert r267961, r267973:
These changes prevent sysctl(8) from returning proper output,
such as:

 1) no output from sysctl(8)
 2) erroneously returning ENOMEM with tools like truss(1)
    or uname(1)
 truss: can not get etype: Cannot allocate memory
2014-06-27 22:05:21 +00:00
Hans Petter Selasky
3da1cf1e88 Extend the meaning of the CTLFLAG_TUN flag to automatically check if
there is an environment variable which shall initialize the SYSCTL
during early boot. This works for all SYSCTL types both statically and
dynamically created ones, except for the SYSCTL NODE type and SYSCTLs
which belong to VNETs. A new flag, CTLFLAG_NOFETCH, has been added to
be used in the case a tunable sysctl has a custom initialisation
function allowing the sysctl to still be marked as a tunable. The
kernel SYSCTL API is mostly the same, with a few exceptions for some
special operations like iterating childrens of a static/extern SYSCTL
node. This operation should probably be made into a factored out
common macro, hence some device drivers use this. The reason for
changing the SYSCTL API was the need for a SYSCTL parent OID pointer
and not only the SYSCTL parent OID list pointer in order to quickly
generate the sysctl path. The motivation behind this patch is to avoid
parameter loading cludges inside the OFED driver subsystem. Instead of
adding special code to the OFED driver subsystem to post-load tunables
into dynamically created sysctls, we generalize this in the kernel.

Other changes:
- Corrected a possibly incorrect sysctl name from "hw.cbb.intr_mask"
to "hw.pcic.intr_mask".
- Removed redundant TUNABLE statements throughout the kernel.
- Some minor code rewrites in connection to removing not needed
TUNABLE statements.
- Added a missing SYSCTL_DECL().
- Wrapped two very long lines.
- Avoid malloc()/free() inside sysctl string handling, in case it is
called to initialize a sysctl from a tunable, hence malloc()/free() is
not ready when sysctls from the sysctl dataset are registered.
- Bumped FreeBSD version to indicate SYSCTL API change.

MFC after:	2 weeks
Sponsored by:	Mellanox Technologies
2014-06-27 16:33:43 +00:00
John-Mark Gurney
aae6c4d071 add support for MosChip MCS9922... This is found on an ExpressCard..
tested to work w/ cu talking to itself (the two ports connected via
null modem cable)...
2014-06-22 06:54:36 +00:00
Olivier Houchard
8bc9a079ef In uart_bus_grab(), use the ier_mask instead of a custom hack for XScale.
Suggested by:	jmg
2014-05-29 21:00:06 +00:00
Olivier Houchard
caf6d6b491 In the grab function, keep the bit 6 on in the IER, on XScale, using 0
turns the UART off, which is unfortunate if one want to use it as a console.
2014-05-29 19:57:51 +00:00
Sean Bruno
aa475e141c Add PCI ID for AMT based serial interface found on the Lenovo T61.
uart2: <Intel AMT - PM965/GM965 KT Controller> port 0x1830-0x1837
	mem 0xfe024000-0xfe024fff irq 17 at device 3.3 on pci0
uart2: console (115200,n,8,1)

Tested as tty and serial console.  Seems "fine"
2014-05-27 13:35:31 +00:00
Ian Lepore
49d0a4c3ff Reword a comment block a bit; no functional changes. 2014-04-26 20:27:58 +00:00
Ian Lepore
2d40ec16a8 Flesh out imx_uart_init() so that we're not relying on u-boot to init
the hardware (meaning uarts other than the console will work).
2014-04-26 20:03:04 +00:00
Ian Lepore
a90f19753f The freescale imx uart driver works for the whole i.MX family, so rename the
header file to not have "5xx" in the name.
2014-04-26 17:56:39 +00:00
Marius Strobl
50c0e894a0 Distinguish between the different variants and configurations of Sunix
{MIO,SER}5xxxx chips instead of treating all of them as PUC_PORT_2S.
Among others, this fixes the hang seen when trying to probe the none-
existent second UART on an actually 1-port chip.

Obtained from:	NetBSD (BAR layouts)
MFC after:	3 days
Sponsored by:	Bally Wulff Games & Entertainment GmbH
2014-04-08 07:32:32 +00:00
Rui Paulo
3329109cb9 Use a more professional device description. 2014-04-07 05:18:27 +00:00
Marcel Moolenaar
4c710b6756 Do not prevent processes from making changes to the baudrate or the
CLOCAL and HUPCL control flags. There are legit reasons for allowing
those to be changed. When /etc/ttys has the "3wire" type (without a
baudrate) for the serial port that is the low-level console, then
this change has no effect.

Obtained from:	Juniper Networks, Inc.
2014-04-05 22:25:10 +00:00
Marcel Moolenaar
f725b213a7 Pass the actual baudrate to tty_init_console(). This defines the initial
baudrate of the device special file, and makes sure that on open(2) the
UART is programmed with the correct baudrate. This then eliminates the
need in uart_tty_param() to override the speed setting.
2014-03-11 03:20:10 +00:00
Warner Losh
5dceed8aeb Back out r262921. I don't know what I was thinking, but it is lame. 2014-03-08 19:59:52 +00:00
Warner Losh
803253c874 Set the baud rate if it isn't 0 (meaning it has been specified) not
only if it is 0 (meaning that it hasn't been specified and is likely
to turn off the UART's transmitter).
2014-03-08 03:39:15 +00:00
Warner Losh
d1c4878039 Make clock optional on uart nodes. It is a FreeBSD-specific extention,
and won't be present in vendor supplied dts files.
2014-03-08 03:39:09 +00:00
Ian Lepore
add35ed5b8 Follow r261352 by updating all drivers which are children of simplebus
to check the status property in their probe routines.

Simplebus used to only instantiate its children whose status="okay"
but that was improper behavior, fixed in r261352.  Now that it doesn't
check anymore and probes all its children; the children all have to
do the check because really only the children know how to properly
interpret their status property strings.

Right now all existing drivers only understand "okay" versus something-
that's-not-okay, so they all use the new ofw_bus_status_okay() helper.
2014-02-02 19:17:28 +00:00
Warner Losh
65e79cf474 clock-frequency is a FreeBSD-specific extention. Make it optional and
allow the client uart drivers to decide if a frequency is required.
2014-01-24 00:14:14 +00:00
Warner Losh
df10106a87 Add Atmel serial drivers. 2014-01-23 18:09:10 +00:00
Warner Losh
138277120c Don't lock in the generic grab just to lock again in the specific grabs.
(I committed the wrong version of uart_core.c, which still had this).

Pointy hat: imp
2014-01-20 17:45:36 +00:00
Warner Losh
d76a1ef4e1 Introduce grab and ungrab upcalls. When the kernel desires to grab the
console, it calls the grab functions. These functions should turn off
the RX interrupts, and any others that interfere. This makes mountroot
prompt work again. If there's more generalized need other than
prompting, many of these routines should be expanded to do those new
things.

Should have been part of r260889, but waasn't due to command line typo.

Reviewed by:	bde (with reservations)
2014-01-19 19:39:13 +00:00
Nathan Whitehorn
dcd08302e5 Retire machine/fdt.h as a header used by MI code, as its function is now
obsolete. This involves the following pieces:
- Remove it entirely on PowerPC, where it is not used by MD code either
- Remove all references to machine/fdt.h in non-architecture-specific code
  (aside from uart_cpu_fdt.c, shared by ARM and MIPS, and so is somewhat
  non-arch-specific).
- Fix code relying on header pollution from machine/fdt.h includes
- Legacy fdtbus.c (still used on x86 FDT systems) now passes resource
  requests to its parent (nexus). This allows x86 FDT devices to allocate
  both memory and IO requests and removes the last notionally MI use of
  fdtbus_bs_tag.
- On those architectures that retain a machine/fdt.h, unused bits like
  FDT_MAP_IRQ and FDT_INTR_MAX have been removed.
2014-01-05 18:46:58 +00:00
Ian Lepore
51dbd04609 Convert from using fdt_immr style to arm_devmap_add_entry() to make
static device mappings.

This SoC relied heavily on the fact that all devices were static-mapped
at a fixed address, and it (rather bogusly) used bus_space read and write
calls passing hard-coded virtual addresses instead of proper bus handles,
relying on the fact that the virtual addresses of the mappings were known
at compile time, and relying on the implementation details of arm
bus_space never changing.  All such usage was replaced with calls to
bus_space_map() to obtain a proper bus handle for the read/write calls.

This required adjusting some of the #define values that map out hardware
registers, and some of them were renamed in the process to make it clear
which were defining absolute physical addresses and which were defining
offsets.  (The ones that just define offsets don't appear to be referenced
and probably serve no value other than perhaps documentation.)
2014-01-05 18:40:06 +00:00
Marcel Moolenaar
b1a64a96d0 Add another HP iLO serial (console) port, found on Itanium servers.
Derived from information provided by: felip.nadal@hob.de
2013-12-24 19:58:27 +00:00
Warner Losh
f83ed22cb6 Plumb the cn_grab and cn_ungrab routines down into the uart
clients. Mask RX interrupts while grabbed on the atmel serial
driver. This UART interrupts every character. When interrupts are
enabled at the mountroot> prompt, this means the ISR eats the
characters. Rather than try to create a cooperative buffering system
for the low level kernel console, instead just mask out the ISR. For
NS8250 and decsendents this isn't needed, since interrupts only happen
after 14 or more characters (depending on the fifo settings). Plumb
such that these are optional so there's no change in behavior for all
the other UART clients. ddb worked on this platform because all
interrupts were disabled while it was running, so this problem wasn't
noticed. The mountroot> issue has been around for a very very long
time.

MFC after:	3 days
2013-12-21 16:23:31 +00:00
Nathan Whitehorn
02ef3f33de Real OF systems have an ihandle under /chosen/stdout, not a phandle. Use
the right type.
2013-12-01 19:05:32 +00:00
Nathan Whitehorn
49aba28afe Make uart_cpu_powerpc work on both FDT and OFW systems. This is the last
remaining modification required to build kernels that work with both on
PowerPC.
2013-12-01 16:02:22 +00:00
Ruslan Bukin
5c263f43ef Add support for Freescale Vybrid Family VF600 heterogeneous
ARM Cortex-A5/M4 SoC (M4 core is not used in this work).

Support includes device drivers for:
- NAND Flash Controller (NFC)
- USB Enhanced Host Controller Interface (EHCI)
- General-Purpose Input/Output (GPIO)
- Universal Asynchronous Receiver/Transmitter (UART)

Also supported:
- Generic Interrupt Controller (GIC)
- MPCore timer
- ffec ethernet driver

Reviewed by:	ray
Approved by:	cognet (mentor)
2013-11-12 18:02:56 +00:00
Sean Bruno
f478527d75 Add new AMT serial port PCI ID on Intel Lynx Point chipset
Submitted by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after:	2 weeks
2013-11-07 19:38:19 +00:00
Ian Lepore
6495818590 Arrange for uart_cpu_fdt's probe() routine to use the same table of compat
strings as uart_bus_fdt's probe().

The bus code uses ofw_bus_search_compatible() and that's not an option in
cpu (console) code -- it runs way before the ofw routines are usable.  So
the console probe has its own loop to search the table, but now at least
there's only one table to be maintained when new devices are added.
2013-11-02 20:14:39 +00:00
Ian Lepore
8ef18b3b15 Convert the if/else list of compatible devices to the table-driven
ofw_bus_search_compatible() routine.  In addition to converting existing
strings to table entries, also add compat strings for the whole imx family.
2013-10-31 23:57:33 +00:00
Nathan Whitehorn
94f33b0ab6 Try even harder to find a console before giving up. 2013-10-26 20:06:50 +00:00
Nathan Whitehorn
dce533f390 Be a bit more flexible in how we find the console from the properties on
/chosen, following the list of allowed console properties in ePAPR. Also
do not require that stdin be defined and equal to stdout: stdin is
nonstandard (for ePAPR) and console in an unexpected place is after all
better than no console.
2013-10-26 18:25:55 +00:00
Zbigniew Bodek
49e368ac48 Wait for DesignWare UART transfers completion before accessing line control
When using DW UART with BUSY detection it is necessary to wait
until all serial transfers are finished before manipulating the
line control. LCR will not be affected when UART is busy.
In addition, if Divisor Latch Access Bit is being set in order to
modify UART divisors:
1. We will get BUSY interrupt if interrupts are enabled.
2. Because LCR will not be affected the THR and (even worse) IER
   contents will be corrupted. This will lead to console hang.

Approved by:	cognet (mentor)
2013-10-26 17:24:59 +00:00
Nathan Whitehorn
e889db8841 machine/pmap.h is included by vm/pmap.h, so is redundant here. Thanks to
Alan Cox for pointing this out.
2013-10-26 13:18:39 +00:00
Nathan Whitehorn
c20809e143 Fix build after r257111 by including headers with definition of pmap_kextract(). 2013-10-26 03:22:57 +00:00
Aleksandr Rybalko
4162dff98a Test UARTs physical address instead of virtual. 2013-10-25 11:44:39 +00:00
Aleksandr Rybalko
3a1f3e0d0c Fix crossed fingers output. Only comment changed. 2013-10-24 09:27:06 +00:00
Ian Lepore
6dd028d8f8 Calculate the baud rate divisor rather than using a hard-coded value.
Submitted by:	Steven Lawrance <stl@koffein.net>
2013-10-20 23:40:16 +00:00
Marcel Moolenaar
40a827b6f0 A final test with unmodified code has shown that a delay of 150ms
is not giving us a 100% success rate. Bump the delay to 200ms as
that seems to do the trick.

Note that during testing the delay was added to uart_bus_attach()
in uart_core.c. While having the delay in a different place can
change the behaviour, it was not expected. Having to bump the
delay with another 50ms could therefore be an indication that
the problem can not be solved with delays.

Reported by: kevlo@
Tested by: kevlo@
2013-08-30 15:26:45 +00:00
Marcel Moolenaar
4fc4997535 Work-around a timing problem with the ITE IT8513E now that the core
calls ns8250_bus_ipend() almost immediately after ns8250_bus_attach().
As it appears, a line break condition is being signalled for almost
all received characters due to this. A delay of 150ms seems enough
to allow the H/W to settle and to avoid the problem.
More analysis is needed, but for now a regression has been addressed.

Reported by: kevlo@
Tested by: kevlo@
2013-08-29 16:26:04 +00:00
Ian Lepore
aef60d8c4a Add support for uarts other than the serial console in TI OMAP SoCs.
The TI uart hardware is ns16550-compatible, except that before it can
be used the clocks and power have to be enabled and a non-standard
mode control register has to be set to put the device in uart mode
(as opposed to irDa or other serial protocols).  This adds the extra
code in an extension to the standard ns8250 probe routine, and the
rest of the driver is just the standard ns8250 code.
2013-08-21 14:33:02 +00:00
Ian Lepore
167cb33f85 Make the uart ns8250 high-level interface public rather than static.
This makes it easier to implement new drivers which are "mostly ns8250"
but with some small difference such as needing to enable clocks or poke
a non-standard register at probe or attach time.
2013-08-21 14:26:15 +00:00
Ian Lepore
6fd28cd9ff Use an if/else sequence rather than unrelated if statements, so that a
device compatible with multiple drivers matches the more specific driver
first and doesn't overwrite it later with the more generic.  Move the
generic ns16550 to the end of the list.
2013-08-21 04:08:58 +00:00
Ian Lepore
d081029a4f Check for generic ns16550 after all other types. A device may be compatible
with 16550 but also have a more specific/capable driver earlier in the list.
2013-08-21 04:05:06 +00:00
Ian Lepore
1662b00871 Allow UART_POLL_FREQ to be set as a kernel option as well as via tunable
(the code was already set up for this, just needs to be in conf/options).

Also, if reporting that polling is being used, report the frequency too.
2013-08-19 15:51:30 +00:00
Marcel Moolenaar
a177309ff9 Set the device description after we call uart_probe(). In uart_probe()
we call device-specific probe functions, which can (and typically will)
set the device description based on low-level device probe information.
In the end we never actually used the device description that we so
carefully maintained in the PCI match table. By setting the device
description after we call uart_probe(), we'll print the more user-
friendly description by default.
2013-07-25 16:57:27 +00:00