This is a TLM model of the standard 8250/16550A UARTs used for serial I/O. It models the functional aspects of the real device, so it looks like a real UART for the software. However, most of the physical aspects have been omitted (e.g., data is transmitted instantly, transmission errors cannot occur, etc.).
The model uses a tx and rx port to connect to other UARTs. A common choice would
be the terminal uart model, which allows input and output via stdout
and stdin
from a terminal window. Input is polled once per quantum and is only fetched
from the backend if the FIFOs are not full, so data is never dropped.
The model can be operated in interrupt or polling mode.
This model has the following properties:
Property | Type | Default | Description |
---|---|---|---|
clock |
hz_t |
3686400 |
UART clock (in Hz) |
read_latency |
sc_time |
0ns |
Extra read delay |
write_latency |
sc_time |
0ns |
Extra write delay |
allow_dmi |
bool |
true |
Ignored |
loglvl |
log_level |
info |
Logging threshold |
trace_errors |
bool |
false |
Report TLM errors |
Extra properties are available from the specified backends
.
The properties loglvl
and trace_errors
require loggers
.
The following ports and sockets must be connected prior to simulating:
Port | Type | Description |
---|---|---|
IN |
tlm_target_socket<> |
Input socket for bus requests |
IRQ |
sc_out<bool> |
Interrupt port |
The model exposes the following memory mapped registers:
Name | Offset | Access | Width | Description |
---|---|---|---|---|
THR |
+0x0 |
R/W | 8 bit | Rx Buffer (R) / Tx Buffer (W) Register |
IER |
+0x1 |
R/W | 8 bit | Interrupt Enable Register |
IIR |
+0x2 |
R/W | 8 bit | Interrupt Ident. (R) / FIFO Control (W) |
LCR |
+0x3 |
R/W | 8 bit | Line Control Register |
MCR |
+0x4 |
R/W | 8 bit | Modem Control Register |
LSR |
+0x5 |
R | 8 bit | Line Status Register |
MSR |
+0x6 |
R | 8 bit | Modem Status Register |
SCR |
+0x7 |
R/W | 8 bit | Scratchpad Register |
This device model works with Linux:
- As early boot console: add
earlycon=uart,mmio,<addr>
to kernel parameters - As a serial device via the device tree: use
compatible = "16550a";
The corresponding drivers can be found in drivers/tty/serial/8250
. Below is
an example that adds a UART at address 0x91000000
and assigns it to interrupt
3
.
serial@91000000 {
compatible = "ns16550a";
clock-frequency = <3686400>; /* 3.6864MHz */
reg = <0x91000000 0x2000>;
interrupts = <3>;
};
Documentation December 2018