Introduction


The UART operations are controlled by the configuration and mode registers. The state of the FIFOs, modem signals, and other controller functions are read using the status, interrupt
status, and modem status registers.The controller is structured with separate RX and TX data paths. Each path includes a 64-byte FIFO. The controller serializes and deserializes data
in the TX and RX FIFOs and includes a mode switch to support various loopback configurations for the RxD and TxD signals. The FIFO interrupt status bits support polling or interrupt
driven handler. Software reads and writes data bytes using the RX and TX data port registers.When using the UART in a modem-like application, the modem control module detects and
generates the modem handshake signals and also controls the receiver and transmitter paths according to the handshaking protocol.
The PS Uart is in Zynq Ultrascale+ MpSoC and Zynq platforms.

HW IP Features

  • Programmable baud rate generator
  • 64-byte receive and transmit FIFOs
  • Programmable protocol:° 6, 7, or 8 data bits 1, 1.5, or 2 stop bits
  • Odd, even, space, mark, or no parity
  • Parity, framing and overrun error detection
  • Line-break generation and detection
  • Interrupts generation
  • Automatic echo, local loopback, and remote loopback channel modes
  • Modem control signals: CTS, RTS, DSR, DTR, RI, and DCD

Features supported in driver

  • Programmable baud rate generator
  • 64-byte receive and transmit FIFOs
  • Programmable protocol:° 6, 7, or 8 data bits 1, 1.5, or 2 stop bits
  • Odd, even, space, mark, or no parity
  • Parity, framing and overrun error detection
  • Line-break generation and detection
  • Interrupts generation
  • Automatic echo, local loopback, and remote loopback channel modes
  • Modem control signals: CTS, RTS, DSR, DTR, RI, and DCD

Missing Features, Known Issues and Limitations

  • None

Kernel Configuration

To enable the uart driver in the linux kernel you either have to integrate it or build it as kernel module (.ko). you can enable it with:
CONFIG_SERIAL_XILINX_PS_UART=y
CONFIG_SERIAL_XILINX_PS_UART_CONSOLE=y
When more than two UARTs are required in the system (including PL UARTs) the user should also configure the following configuration item to increase the number of UART ports.
The driver statically allocates port data structures based on this configuration item. A kernel error similar to "Cannot get uart_port structure" may be seen during kernel boot when this is an issue.
CONFIG_SERIAL_XILINX_NR_UARTS=<number of expected UARTs>
Devicetree
Here's how the devicetree entry could look like.

        uart0: serial@e0000000 {
            compatible = "xlnx,xuartps", "cdns,uart-r1p8";
            clocks = <&clkc 23>, <&clkc 40>;
            clock-names = "uart_clk", "pclk";
            reg = <0xE0000000 0x1000>;
            interrupts = <0 27 4>;
        };

Test procedure



stty-Linux Commands Related to configuration and Testing:
  • stty -all --> command can be used to display the terminal configuration parameters of a tty device. To display all of the active settings on a tty device.
  • stty -F /dev/ttyPS0 crtscts /-crtscts) --> Enable/Disable hardware handshaking.
  • stty -F /dev/ttyPS0 ixon / -ixon --> Enable/Disable XON/XOFF flow control.
  • stty -F /dev/ttyPS0 clocal / -clocal --> Enable/Disable modem control signals such as DTR/DTS and DCD. This is necessary if you are using a "three wire" serial cable because it does not supply these signals.
  • stty -F /dev/ttyPS0 cs5 / cs6 / cs7 / cs8 --> Set number of data bits to 5, 6, 7, or 8, respectively.
  • stty -F /dev/ttyPS0 parodd / -parodd --> Enable odd parity. Disabling this flag enables even parity.
  • stty -F /dev/ttyPS0 parenb / -parenb --> Enable parity checking. When this flag is negated, no parity is used.
  • stty -F /dev/ttyPS0 cstopb / -cstopb --> Enable use of two stop bits per character. When this flag is negated, one stop bit per character is used.
  • stty -F /dev/ttyPS0 echo / -echo --> Enable/Disable echoing of received characters back to sender.


UART BREAK DETECTION:





  • To test the Uart break detection the above setup is required.
  • Connect the ep108 serial port with PC serial port with the help of either DB 9 connector or USB to serial cable.
  • Form PC side with the help of Tera term application go to following options and issue the break signal.
    • Contol ----> Send break or Alt + B
  • With the help of proc file system (proc/tty/driver/xuartps) we can check whether the board serial port is receiving the break signal or not.
root@Xilinx-ZynqMP-EAApr2015:~# cat  /proc/tty/driver/xuartps
serinfo:1.0 driver revision:
0: uart:xuartps mmio:0xFF000000 irq:16 tx:21556 rx:401 brk:1 RTS|CTS|DTR|DSR|CD
 

Expected Output

root@Xilinx-ZCU102-2015_4:~# cat /proc/tty/driver/xuartps
serinfo:1.0 driver revision:
0: uart:xuartps mmio:0xFF000000 irq:204 tx:1008 rx:51 RTS|CTS|DTR|DSR|CD
1: uart:xuartps mmio:0xFF010000 irq:205 tx:0 rx:0 CTS|DSR|CD
root@Xilinx-ZCU102-2015_4:~# [   79.344585] sysrq: SysRq : HELP : loglevel(0-9) reboot(b) crash(c) terminate-all-tasks(e) memory-full-oom-kill(f) kill-all-tasks(i) thaw-filesystems(j) show-backtrace-all-active-cpus(l) show-memory-usage(m) nice-all-RT-tasks(n) poweroff(o) show-registers(p) show-all-timers(q) sync(s) show-task-states(t) unmount(u) show-blocked-tasks(w) dump-ftrace-buffer(z)
 
root@Xilinx-ZCU102-2015_4:~# cat /proc/tty/driver/xuartps
serinfo:1.0 driver revision:
0: uart:xuartps mmio:0xFF000000 irq:204 tx:1267 rx:64 brk:1 RTS|CTS|DTR|DSR|CD
1: uart:xuartps mmio:0xFF010000 irq:205 tx:0 rx:0 CTS|DSR|CD
root@Xilinx-ZCU102-2015_4:~# stty -F /dev/ttyPS0 -a
speed 115200 baud;stty: /dev/ttyPS0
 line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol =
; eol2 = <undef>;
swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon ixoff
-iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon -iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke
root@Xilinx-ZCU102-2015_4:~# stty -F /dev/ttyPS1 -a
speed 9600 baud;stty: /dev/ttyPS1
 line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
-iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke
root@Xilinx-ZCU102-2015_4:~# cat < /dev/ttyPS1
^C
root@Xilinx-ZCU102-2015_4:~# cat /proc/tty/driver/xuartps
serinfo:1.0 driver revision:
0: uart:xuartps mmio:0xFF000000 irq:204 tx:2975 rx:162 brk:1 RTS|CTS|DTR|DSR|CD
1: uart:xuartps mmio:0xFF010000 irq:205 tx:0 rx:1 brk:1 CTS|DSR|CD
root@Xilinx-ZCU102-2015_4:~# stty -F /dev/ttyPS1 inpck
root@Xilinx-ZCU102-2015_4:~# cat < /dev/ttyPS1
^C
root@Xilinx-ZCU102-2015_4:~# cat /proc/tty/driver/xuartps
serinfo:1.0 driver revision:
0: uart:xuartps mmio:0xFF000000 irq:204 tx:3646 rx:200 brk:1 RTS|CTS|DTR|DSR|CD
1: uart:xuartps mmio:0xFF010000 irq:205 tx:0 rx:2 fe:1 brk:1 CTS|DSR|CD
root@Xilinx-ZCU102-2015_4:~# cat < /dev/ttyPS1
^C
root@Xilinx-ZCU102-2015_4:~# cat /proc/tty/driver/xuartps
serinfo:1.0 driver revision:
0: uart:xuartps mmio:0xFF000000 irq:204 tx:4042 rx:215 brk:1 RTS|CTS|DTR|DSR|CD
1: uart:xuartps mmio:0xFF010000 irq:205 tx:0 rx:7 fe:6 brk:1 CTS|DSR|CD
root@Xilinx-ZCU102-2015_4:~# stty -F /dev/ttyPS1 parenb
root@Xilinx-ZCU102-2015_4:~# cat < /dev/ttyPS1
^C
root@Xilinx-ZCU102-2015_4:~# cat /proc/tty/driver/xuartps
serinfo:1.0 driver revision:
0: uart:xuartps mmio:0xFF000000 irq:204 tx:4835 rx:263 brk:1 RTS|CTS|DTR|DSR|CD
1: uart:xuartps mmio:0xFF010000 irq:205 tx:0 rx:8 fe:6 pe:1 brk:1 CTS|DSR|CD
root@Xilinx-ZCU102-2015_4:~# cat < /dev/ttyPS1
^C
root@Xilinx-ZCU102-2015_4:~# cat /proc/tty/driver/xuartps
serinfo:1.0 driver revision:
0: uart:xuartps mmio:0xFF000000 irq:204 tx:5236 rx:278 brk:1 RTS|CTS|DTR|DSR|CD
1: uart:xuartps mmio:0xFF010000 irq:205 tx:0 rx:9 fe:6 pe:1 brk:2 CTS|DSR|CD
root@Xilinx-ZCU102-2015_4:~# cat < /dev/ttyPS1[  363.850712] random: nonblocking pool is initialized
 
^C
root@Xilinx-ZCU102-2015_4:~# cat /proc/tty/driver/xuartps
serinfo:1.0 driver revision:
0: uart:xuartps mmio:0xFF000000 irq:204 tx:5637 rx:293 brk:1 RTS|CTS|DTR|DSR|CD
1: uart:xuartps mmio:0xFF010000 irq:205 tx:0 rx:13 fe:6 pe:5 brk:2 CTS|DSR|CD
root@Xilinx-ZCU102-2015_4:~#

Mainline status

  • The below commits needs to be upstream
    • tty: xilinx_uartps: Check the clk_enable return value
    • tty: xilinx_uartps: Add check for runtime_get_sync calls
    • tty: xilinx_uartps: Make the timeout unsigned
    • tty: xilinx_uartps: Check clk_enable return type
    • serial: uartps: Change uart ID port allocation
    • serial: uartps: Fix the ignore_status
    • serial: uartps: Prevent writes when the controller is disabled
    • serial: uartps: Fix stuck ISR if RX disabled with non-empty FIFO

Change Log

2016.3
Summary:
  • tty: serial: xuartps: Wait for rx and tx done status
Commits:
  • 0db7a24 tty: serial: xuartps: Wait for rx and tx done status

2016.4
  • None
2017.1
Summary:
  • serial: xuartps: Enable uart loopback mode
  • tty: serial: xilinx: Use mainline driver version
  • serial: xuartps: Fix interrupt mask issue to handle the RX interrupts properly.
  • serial: xilinx_uartps: Add pm runtime support
  • serial: xuartps: Fix the early_console junk character issue
  • serial: xuartps: Cleanup the clock enable
  • serial: xuartps: Enable clocks in the pm disable case
  • serial: xuartps: Enable uart loopback mode
  • serial: xuartps: Fix the error handling logic in probe().
  • tty: serial: Added a CONFIG_SERIAL_XILINX_NR_UARTS option.
Commits:
  • 6226051 serial: xuartps: Enable uart loopback mode
  • 25c25a1 tty: serial: xilinx: Use mainline driver version
  • a96b8d2 serial: xuartps: Fix interrupt mask issue to handle the RX interrupts properly.
  • 870d6d6 serial: xilinx_uartps: Add pm runtime support
  • 2e5cc8e serial: xuartps: Fix the early_console junk character issue
  • f26b7ab serial: xuartps: Cleanup the clock enable
  • 7bf059f serial: xuartps: Enable clocks in the pm disable case
  • 9fb8e58 serial: xuartps: Enable uart loopback mode
  • 0cd0559 serial: xuartps: Fix the error handling logic in probe().
  • 0f44bb0 tty: serial: Added a CONFIG_SERIAL_XILINX_NR_UARTS option.

2017.2
  • None

2017.3
Summary:
  • serial: xilinx_uartps: Fix kernel doc warnings
  • serial: xilinx_uartps: Fix warnings in the driver
Commits:
  • 0240098 serial: xilinx_uartps: Fix kernel doc warnings
  • 6ba85c7 serial: xilinx_uartps: Fix warnings in the driver

2017.4
Summary:
  • tty: xilinx_uartps: move to arch_initcall for earlier console
Commits:
  • ea9d34b tty: xilinx_uartps: move to arch_initcall for earlier console


2018.1
Summary:
  • serial: xilinx_uartps: Add pm runtime support
Commits:
  • d62100f serial: xilinx_uartps: Add pm runtime support

2018.2
  • None
2018.3
Summary:
  • serial: xuartps: Enable clocks in the pm disable case also
  • serial: xuartps: Enable uart loopback mode
  •  serial: uartps: Fix kernel doc warnings
  • tty: xilinx_uartps: move to arch_initcall for earlier console
  • tty: xilinx_uartps: Enable automatic flow control
  • serial: uartps: Use dynamic array for console port
  • serial: uartps: Move cnds_uart_get_port to probe
  • serial: uartps: Remove static port array
  • serial: uartps: Do not use static struct uart_driver out of probe()
  • serial: uartps: Move alias reading higher in probe()
  • serial: uartps: Change logic how console_port is setup
  • serial: uartps: Register own uart console and driver structures
  • serial: uartps: Change uart ID port allocation
  • serial: uartps: Check if the device is a console
Commits:
    • 7bf059fserial: xuartps: Enable clocks in the pm disable case also
    • 9fb8e58serial: xuartps: Enable uart loopback mode
    • 94094a9 serial: uartps: Fix kernel doc warnings
    • ea9d34btty: xilinx_uartps: move to arch_initcall for earlier console
    • 5d29fa5tty: xilinx_uartps: Enable automatic flow control
    • 2288a8eserial: uartps: Use dynamic array for console port
    • 47fe24d serial: uartps: Move cnds_uart_get_port to probe
    • 8d2b924serial: uartps: Remove static port array
    • 317f163serial: uartps: Do not use static struct uart_driver out of probe()
    • b09b499serial: uartps: Move alias reading higher in probe()
    • 00639b5 serial: uartps: Change logic how console_port is setup
    • 2f65317serial: uartps: Register own uart console and driver structures
    • 906433dserial: uartps: Change uart ID port allocation
    • 9ec4aaeserial: uartps: Check if the device is a console

  • 2019.1
    Summary:
    • serial: uartps: Fix stuck ISR if RX disabled with non-empty FIFO
    • serial: xuartps: fix typo in cdns_uart_startup
    • serial: xuartps: reduce hardware TX race condition
    • serial: xuartps: remove unnecessary register write
    • serial: uartps: Remove console_initcall from the driver
    • serial: uartps: Move cnds_uart_get_port to probe
    • of: base: Change logic in of_alias_get_alias_list()
    • serial: uartps: Do not allow use aliases >= MAX_UART_INSTANCES
    • serial: uartps: Fix the ignore_status
    • serial: uartps: Add support for cts-override

Commits:

    • d5d53b4serial: uartps: Fix stuck ISR if RX disabled with non-empty FIFO
    • 22032cserial: xuartps: fix typo in cdns_uart_startup
    • de4ed39serial: xuartps: reduce hardware TX race condition
    • b41609aserial: xuartps: remove unnecessary register write
    • 7a3741serial: uartps: Remove console_initcall from the driver
    • 1f21072serial: uartps: Move cnds_uart_get_port to probe
    • e03af1of: base: Change logic in of_alias_get_alias_list()
    • 41cdfeaserial: uartps: Do not allow use aliases >= MAX_UART_INSTANCES
    • fc5337serial: uartps: Fix the ignore_status
    • 0f3d182serial: uartps: Add support for cts-override

                     Summary:

  • tty: xilinx_uartps: Add the id to the console
  • serial: uartps: Use cdns_uart_tx_empty in console_write
  • serial: uartps: Wait for tx_empty in console setup
  • serial: uartps: Revert dynamic port allocation
  • serial: uartps: Add TACTIVE check in cdns_uart_tx_empty function
  • serial: uartps: Remove unconditional wait inside set_termios

                 Commits:

2020.2

   Summary:

  • Revert "tty: xilinx_uartps: Fix missing id assignment to the console"
  • tty: xilinx_uartps: Really fix id assignment

Commits:

2021.1

Summary:

  • tty: xilinx_uartps: Check the clk_enable return value
  • tty: xilinx_uartps: Add check for runtime_get_sync calls
  • tty: xilinx_uartps: Make the timeout unsigned
  • tty: xilinx_uartps: Check clk_enable return type
  • serial: uartps: Change uart ID port allocation
  • serial: uartps: Fix the ignore_status
  • serial: uartps: Prevent writes when the controller is disabled
  • serial: uartps: Fix stuck ISR if RX disabled with non-empty FIFO

Commits: