xref: /freebsd/share/man/man4/uart.4 (revision 4f4acb65e8f2f63d8cae1a9459566d6f60f3e95c)
127d5dc18SMarcel Moolenaar.\"
227d5dc18SMarcel Moolenaar.\" Copyright (c) 2003 Marcel Moolenaar
327d5dc18SMarcel Moolenaar.\" All rights reserved.
427d5dc18SMarcel Moolenaar.\"
527d5dc18SMarcel Moolenaar.\" Redistribution and use in source and binary forms, with or without
627d5dc18SMarcel Moolenaar.\" modification, are permitted provided that the following conditions
727d5dc18SMarcel Moolenaar.\" are met:
827d5dc18SMarcel Moolenaar.\"
927d5dc18SMarcel Moolenaar.\" 1. Redistributions of source code must retain the above copyright
1027d5dc18SMarcel Moolenaar.\"    notice, this list of conditions and the following disclaimer.
1127d5dc18SMarcel Moolenaar.\" 2. Redistributions in binary form must reproduce the above copyright
1227d5dc18SMarcel Moolenaar.\"    notice, this list of conditions and the following disclaimer in the
1327d5dc18SMarcel Moolenaar.\"    documentation and/or other materials provided with the distribution.
1427d5dc18SMarcel Moolenaar.\"
1527d5dc18SMarcel Moolenaar.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1627d5dc18SMarcel Moolenaar.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1727d5dc18SMarcel Moolenaar.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1827d5dc18SMarcel Moolenaar.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
1927d5dc18SMarcel Moolenaar.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2027d5dc18SMarcel Moolenaar.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2127d5dc18SMarcel Moolenaar.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2227d5dc18SMarcel Moolenaar.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2327d5dc18SMarcel Moolenaar.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2427d5dc18SMarcel Moolenaar.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2527d5dc18SMarcel Moolenaar.\"
2627d5dc18SMarcel Moolenaar.\" $FreeBSD$
2727d5dc18SMarcel Moolenaar.\"
28*4f4acb65SEdward Tomasz Napierala.Dd April 26, 2017
2927d5dc18SMarcel Moolenaar.Dt UART 4
3027d5dc18SMarcel Moolenaar.Os
3127d5dc18SMarcel Moolenaar.Sh NAME
3227d5dc18SMarcel Moolenaar.Nm uart
3327d5dc18SMarcel Moolenaar.Nd driver for Universal Asynchronous Receiver/Transmitter (UART) devices
3427d5dc18SMarcel Moolenaar.Sh SYNOPSIS
3527d5dc18SMarcel Moolenaar.Cd "device uart"
3627d5dc18SMarcel Moolenaar.Pp
3727d5dc18SMarcel Moolenaar.Cd "device puc"
3827d5dc18SMarcel Moolenaar.Cd "device uart"
39af2e25a6SMarcel Moolenaar.Pp
40af2e25a6SMarcel Moolenaar.Cd "device scc"
41af2e25a6SMarcel Moolenaar.Cd "device uart"
42def2344dSSam Leffler.Pp
43def2344dSSam LefflerIn
44def2344dSSam Leffler.Pa /boot/device.hints :
45def2344dSSam Leffler.Cd hint.uart.0.disabled="1"
46def2344dSSam Leffler.Cd hint.uart.0.baud="38400"
47def2344dSSam Leffler.Cd hint.uart.0.port="0x3f8"
48def2344dSSam Leffler.Cd hint.uart.0.flags="0x10"
49def2344dSSam Leffler.Pp
50def2344dSSam LefflerWith
51def2344dSSam Leffler.Ar flags
52def2344dSSam Lefflerencoded as:
53def2344dSSam Leffler.Bl -tag -compact -width 0x000000
54def2344dSSam Leffler.It 0x00010
55def2344dSSam Lefflerdevice is potential system console
56def2344dSSam Leffler.It 0x00080
57def2344dSSam Leffleruse this port for remote kernel debugging
58def2344dSSam Leffler.It 0x00100
59def2344dSSam Lefflerset RX FIFO trigger level to ``low'' (NS8250 only)
60def2344dSSam Leffler.It 0x00200
61def2344dSSam Lefflerset RX FIFO trigger level to ``medium low'' (NS8250 only)
62def2344dSSam Leffler.It 0x00400
63def2344dSSam Lefflerset RX FIFO trigger level to ``medium high'' (default, NS8250 only)
64def2344dSSam Leffler.It 0x00800
65def2344dSSam Lefflerset RX FIFO trigger level to ``high'' (NS8250 only)
66def2344dSSam Leffler.El
6727d5dc18SMarcel Moolenaar.\"
6827d5dc18SMarcel Moolenaar.Sh DESCRIPTION
6927d5dc18SMarcel MoolenaarThe
7027d5dc18SMarcel Moolenaar.Nm
7127d5dc18SMarcel Moolenaardevice driver provides support for various classes of UARTs implementing the
7227d5dc18SMarcel MoolenaarEIA RS-232C (CCITT V.24) serial communications interface.
73c48524c2SMike PritchardEach such interface is controlled by a separate and independent instance of
7427d5dc18SMarcel Moolenaarthe
7527d5dc18SMarcel Moolenaar.Nm
7627d5dc18SMarcel Moolenaardriver.
7727d5dc18SMarcel MoolenaarThe primary support for devices that contain multiple serial interfaces or
7827d5dc18SMarcel Moolenaarthat contain other functionality besides one or more serial interfaces is
7927d5dc18SMarcel Moolenaarprovided by the
80af2e25a6SMarcel Moolenaar.Xr puc 4 ,
81af2e25a6SMarcel Moolenaaror
82af2e25a6SMarcel Moolenaar.Xr scc 4
83af2e25a6SMarcel Moolenaardevice drivers.
8427d5dc18SMarcel MoolenaarHowever, the serial interfaces of those devices that are managed by the
85af2e25a6SMarcel Moolenaar.Xr puc 4 ,
86af2e25a6SMarcel Moolenaaror
87af2e25a6SMarcel Moolenaar.Xr scc 4
88af2e25a6SMarcel Moolenaardriver are each independently controlled by the
8927d5dc18SMarcel Moolenaar.Nm
9027d5dc18SMarcel Moolenaardriver.
9127d5dc18SMarcel MoolenaarAs such, the
92af2e25a6SMarcel Moolenaar.Xr puc 4 ,
93af2e25a6SMarcel Moolenaaror
94af2e25a6SMarcel Moolenaar.Xr scc 4
9527d5dc18SMarcel Moolenaardriver provides umbrella functionality for the
9627d5dc18SMarcel Moolenaar.Nm
9727d5dc18SMarcel Moolenaardriver and hides the complexities that are inherent when elementary components
9827d5dc18SMarcel Moolenaarare packaged together.
9927d5dc18SMarcel Moolenaar.Pp
10027d5dc18SMarcel MoolenaarThe
10127d5dc18SMarcel Moolenaar.Nm
10227d5dc18SMarcel Moolenaardriver has a modular design to allow it to be used on differing hardware and
10327d5dc18SMarcel Moolenaarfor various purposes.
10427d5dc18SMarcel MoolenaarIn the following sections the components are discussed in detail.
10527d5dc18SMarcel MoolenaarOptions are described in the section that covers the component to which each
10627d5dc18SMarcel Moolenaaroption applies.
10727d5dc18SMarcel Moolenaar.\"
10827d5dc18SMarcel Moolenaar.Ss CORE COMPONENT
10927d5dc18SMarcel MoolenaarAt the heart of the
11027d5dc18SMarcel Moolenaar.Nm
111fdae0df4SHiten Pandyadriver is the core component.
112fdae0df4SHiten PandyaIt contains the bus attachments and the low-level interrupt handler.
11327d5dc18SMarcel Moolenaar.\"
11427d5dc18SMarcel Moolenaar.Ss HARDWARE DRIVERS
11527d5dc18SMarcel MoolenaarThe core component and the kernel interfaces talk to the hardware through the
11627d5dc18SMarcel Moolenaarhardware interface.
11727d5dc18SMarcel MoolenaarThis interface serves as an abstraction of the hardware and allows varying
11827d5dc18SMarcel MoolenaarUARTs to be used for serial communications.
11927d5dc18SMarcel Moolenaar.\"
12027d5dc18SMarcel Moolenaar.Ss SYSTEM DEVICES
12127d5dc18SMarcel MoolenaarSystem devices are UARTs that have a special purpose by way of hardware
12227d5dc18SMarcel Moolenaardesign or software setup.
12327d5dc18SMarcel MoolenaarFor example, Sun UltraSparc machines use UARTs as their keyboard interface.
12427d5dc18SMarcel MoolenaarSuch an UART cannot be used for general purpose communications.
12527d5dc18SMarcel MoolenaarLikewise, when the kernel is configured for a serial console, the
12627d5dc18SMarcel Moolenaarcorresponding UART will in turn be a system device so that the kernel can
12727d5dc18SMarcel Moolenaaroutput boot messages early on in the boot process.
12827d5dc18SMarcel Moolenaar.\"
12927d5dc18SMarcel Moolenaar.Ss KERNEL INTERFACES
13027d5dc18SMarcel MoolenaarThe last but not least of the components is the kernel interface.
13127d5dc18SMarcel MoolenaarThis component ultimately determines how the UART is made visible to the
13227d5dc18SMarcel Moolenaarkernel in particular and to users in general.
13327d5dc18SMarcel MoolenaarThe default kernel interface is the TTY interface.
13427d5dc18SMarcel MoolenaarThis allows the UART to be used for terminals, modems and serial line IP
13527d5dc18SMarcel Moolenaarapplications.
13627d5dc18SMarcel MoolenaarSystem devices, with the notable exception of serial consoles, generally
13727d5dc18SMarcel Moolenaarhave specialized kernel interfaces.
13827d5dc18SMarcel Moolenaar.\"
139a814fd62SMarcel Moolenaar.Sh HARDWARE
140a814fd62SMarcel MoolenaarThe
141a814fd62SMarcel Moolenaar.Nm
142a814fd62SMarcel Moolenaardriver supports the following classes of UARTs:
143a814fd62SMarcel Moolenaar.Pp
144a814fd62SMarcel Moolenaar.Bl -bullet -compact
145a814fd62SMarcel Moolenaar.It
146a814fd62SMarcel MoolenaarNS8250: standard hardware based on the 8250, 16450, 16550, 16650, 16750 or
147af2e25a6SMarcel Moolenaarthe 16950 UARTs.
148a814fd62SMarcel Moolenaar.It
149af2e25a6SMarcel MoolenaarSCC: serial communications controllers supported by the
150af2e25a6SMarcel Moolenaar.Xr scc 4
151af2e25a6SMarcel Moolenaardevice driver.
152a814fd62SMarcel Moolenaar.El
153a814fd62SMarcel Moolenaar.\"
154196d3019SIan Lepore.Sh Pulse Per Second (PPS) Timing Interface
155196d3019SIan LeporeThe
156196d3019SIan Lepore.Nm
157196d3019SIan Leporedriver can capture PPS timing information as defined in RFC 2783.
158196d3019SIan LeporeThe API, accessed via
1592017d1b0SEdward Tomasz Napierala.Xr ioctl 2 ,
160196d3019SIan Leporeis available on the tty device.
161196d3019SIan LeporeTo use the PPS capture feature with
162196d3019SIan Lepore.Xr ntpd 8 ,
163fdfbb3f5SIan Leporesymlink the tty callout device
164fdfbb3f5SIan Lepore.Va /dev/cuau?
165fdfbb3f5SIan Leporeto
166196d3019SIan Lepore.Va /dev/pps0.
167196d3019SIan Lepore.Pp
168196d3019SIan LeporeThe
169196d3019SIan Lepore.Va hw.uart.pps_mode
170196d3019SIan Leporetunable configures the PPS capture mode for all uart devices;
171196d3019SIan Leporeit can be set in
172196d3019SIan Lepore.Xr loader.conf 5 .
173196d3019SIan LeporeThe
174196d3019SIan Lepore.Va dev.uart.0.pps_mode
175196d3019SIan Leporesysctl configures the PPS capture mode for a specific uart device;
176196d3019SIan Leporeit can be set in
177196d3019SIan Lepore.Xr loader.conf 5
178196d3019SIan Leporeor
179196d3019SIan Lepore.Xr sysctl.conf 5 .
180fdfbb3f5SIan Lepore.Pp
181196d3019SIan LeporeThe following capture modes are available:
182196d3019SIan Lepore.Bl -tag -compact -offset "mmmm" -width "mmmm"
183fdfbb3f5SIan Lepore.It 0x00
184196d3019SIan LeporeCapture disabled.
185fdfbb3f5SIan Lepore.It 0x01
186196d3019SIan LeporeCapture pulses on the CTS line.
187fdfbb3f5SIan Lepore.It 0x02
188fdfbb3f5SIan LeporeCapture pulses on the DCD line.
189196d3019SIan Lepore.El
190fdfbb3f5SIan Lepore.Pp
191fdfbb3f5SIan LeporeThe following values may be ORed with the capture mode to configure
192fdfbb3f5SIan Leporecapture processing options:
193fdfbb3f5SIan Lepore.Bl -tag -compact -offset "mmmm" -width "mmmm"
194fdfbb3f5SIan Lepore.It 0x10
195fdfbb3f5SIan LeporeInvert the pulse (RS-232 logic low = ASSERT, high = CLEAR).
196fdfbb3f5SIan Lepore.It 0x20
197fdfbb3f5SIan LeporeAttempt to capture narrow pulses.
198fdfbb3f5SIan Lepore.El
199fdfbb3f5SIan Lepore.Pp
200fdfbb3f5SIan LeporeAdd the narrow pulse option when the incoming PPS pulse width is small
201fdfbb3f5SIan Leporeenough to prevent reliable capture in normal mode.
202fdfbb3f5SIan LeporeIn narrow mode the driver uses the hardware's ability to latch a line
203fdfbb3f5SIan Leporestate change; not all hardware has this capability.
204fdfbb3f5SIan LeporeThe hardware latch provides a reliable indication that a pulse occurred,
205fdfbb3f5SIan Leporebut prevents distinguishing between the CLEAR and ASSERT edges of the pulse.
206fdfbb3f5SIan LeporeFor each detected pulse, the driver synthesizes both an ASSERT and a CLEAR
207fdfbb3f5SIan Leporeevent, using the same timestamp for each.
208fdfbb3f5SIan LeporeTo prevent spurious events when the hardware is intermittently able to
209fdfbb3f5SIan Leporesee both edges of a pulse, the driver will not generate a new pair of
210fdfbb3f5SIan Leporeevents within a half second of the prior pair.
211fdfbb3f5SIan LeporeBoth normal and narrow pulse modes work with
212fdfbb3f5SIan Lepore.Xr ntpd 8 .
213fdfbb3f5SIan Lepore.Pp
214fdfbb3f5SIan LeporeAdd the invert option when the connection to the uart device uses TTL
215fdfbb3f5SIan Leporelevel signals, or when the PPS source emits inverted pulses.
216fdfbb3f5SIan LeporeRFC 2783 defines an ASSERT event as a higher-voltage line level, and a CLEAR
217fdfbb3f5SIan Leporeevent as a lower-voltage line level, in the context of the RS-232 protocol.
218fdfbb3f5SIan LeporeThe modem control signals on a TTL-level connection are typically
219fdfbb3f5SIan Leporeinverted from the RS-232 levels.
220fdfbb3f5SIan LeporeFor example, carrier presence is indicated by a high signal on an RS-232
221fdfbb3f5SIan LeporeDCD line, and by a low signal on a TTL DCD line.
222fdfbb3f5SIan LeporeThis is due to the use of inverting line driver buffers to convert between
223fdfbb3f5SIan LeporeTTL and RS-232 line levels in most hardware designs.
224fdfbb3f5SIan LeporeGenerally speaking, a connection to a DB-9 style connector is an RS-232
225fdfbb3f5SIan Leporelevel signal at up to 12 volts.
226fdfbb3f5SIan LeporeA connection to header pins or an edge-connector on an embedded board
227fdfbb3f5SIan Leporeis typically a TTL signal at 3.3 or 5 volts.
22806f40e96SJohn-Mark Gurney.Sh FILES
229*4f4acb65SEdward Tomasz Napierala.Bl -tag -width "/dev/ttyu?.init" -compact
23006f40e96SJohn-Mark Gurney.It Pa /dev/ttyu?
23106f40e96SJohn-Mark Gurneyfor callin ports
23206f40e96SJohn-Mark Gurney.It Pa /dev/ttyu?.init
23306f40e96SJohn-Mark Gurney.It Pa /dev/ttyu?.lock
23406f40e96SJohn-Mark Gurneycorresponding callin initial-state and lock-state devices
23506f40e96SJohn-Mark Gurney.Pp
236*4f4acb65SEdward Tomasz Napierala.It Pa /dev/cuau*
23706f40e96SJohn-Mark Gurneyfor callout ports
23806f40e96SJohn-Mark Gurney.It Pa /dev/cuau?.init
23906f40e96SJohn-Mark Gurney.It Pa /dev/cuau?.lock
24006f40e96SJohn-Mark Gurneycorresponding callout initial-state and lock-state devices
24106f40e96SJohn-Mark Gurney.El
24227d5dc18SMarcel Moolenaar.Sh SEE ALSO
243af2e25a6SMarcel Moolenaar.Xr puc 4 ,
244af2e25a6SMarcel Moolenaar.Xr scc 4
24527d5dc18SMarcel Moolenaar.\"
24627d5dc18SMarcel Moolenaar.Sh HISTORY
24727d5dc18SMarcel MoolenaarThe
24827d5dc18SMarcel Moolenaar.Nm
24927d5dc18SMarcel Moolenaardevice driver first appeared in
25027d5dc18SMarcel Moolenaar.Fx 5.2 .
251fdae0df4SHiten Pandya.Sh AUTHORS
252af2e25a6SMarcel MoolenaarThe
253af2e25a6SMarcel Moolenaar.Nm
254af2e25a6SMarcel Moolenaardevice driver and this manual page were written by
2556c899950SBaptiste Daroussin.An Marcel Moolenaar Aq Mt marcel@xcllnt.net .
256