serial/xlnx_ps: add common Xilinx UART Peripheral System (XUARTPS) support

This PR adds complete driver support for the Xilinx UART Peripheral System (XUARTPS)
in the NuttX serial driver framework. The implementation includes the core driver code
(uart_xlnx_ps.c), configuration files (Kconfig-xlnxps), header definitions (uart_xlnx_ps.h),
and integration with the existing NuttX build system (CMakeLists.txt, Make.defs, Kconfig).

The driver supports UART0 configuration with customizable parameters (base address,
clock frequency, IRQ number, baud rate, parity, data bits, stop bits), RX/TX buffer sizing,
hardware flow control (RTS/CTS), interrupt-driven data transfer, and console mapping for XUARTPS UART0.
It also provides standard serial driver operations (setup, shutdown, attach/detach, ioctl, send/receive)
and early serial initialization for boot-time console access.

Signed-off-by: chao an <anchao.archer@bytedance.com>
This commit is contained in:
chao an 2026-02-26 16:25:38 +08:00 committed by Alan C. Assis
parent 18be6955c6
commit cfd1771981
6 changed files with 1473 additions and 0 deletions

View file

@ -46,6 +46,10 @@ if(CONFIG_UART_PL011)
list(APPEND SRCS uart_pl011.c)
endif()
if(CONFIG_UART_XLNXPS)
list(APPEND SRCS uart_xlnx_ps.c)
endif()
if(CONFIG_RPMSG_UART)
list(APPEND SRCS uart_rpmsg.c)
endif()

View file

@ -114,6 +114,14 @@ if UART_PL011
source "drivers/serial/Kconfig-pl011"
endif
menuconfig UART_XLNXPS
bool "Xilinx UART Peripheral System (XUARTPS) Chip support"
default n
if UART_XLNXPS
source "drivers/serial/Kconfig-xlnxps"
endif # UART_XLNXPS
menuconfig CMSDK_UART
bool "CMSDK UART Chip support"
select ARCH_HAVE_SERIAL_TERMIOS

View file

@ -0,0 +1,128 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
if UART_XLNXPS
config XLNXPS_SERIAL_DISABLE_REORDERING
bool "Disable reordering of ttySx devices."
default n
---help---
NuttX per default reorders the serial ports (/dev/ttySx) so that the
console is always on /dev/ttyS0. If more than one UART is in use this
can, however, have the side-effect that all port mappings
(hardware USART1 -> /dev/ttyS0) change if the console is moved to another
UART. This option disables that re-ordering for XLNXPS UARTs.
config UART_XLNXPS0
bool "XLNXPS UART0"
default n
if UART_XLNXPS0
config UART_XLNXPS0_BASE
hex "XLNXPS UART0 base address"
default 0x0
config UART_XLNXPS0_CLOCK
int "XLNXPS UART0 clock"
default 0
config UART_XLNXPS0_IRQ
int "XLNXPS UART0 IRQ number"
default 0
config UART_XLNXPS0_BAUD
int "XLNXPS UART0 BAUD"
default 115200
config UART_XLNXPS0_PARITY
int "XLNXPS UART0 parity"
default 0
range 0 2
---help---
XLNXPS UART0 parity. 0=None, 1=Odd, 2=Even. Default: None
config UART_XLNXPS0_BITS
int "XLNXPS UART0 number of bits"
default 8
---help---
XLNXPS UART0 number of bits. Default: 8
config UART_XLNXPS0_2STOP
int "XLNXPS UART0 two stop bits"
default 0
---help---
0=1 stop bit, 1=Two stop bits. Default: 1 stop bit
config UART_XLNXPS0_RX_TRIGGER
int "XLNXPS UART0 RX interrupt trigger level"
default 2
range 0 3
config UART_XLNXPS0_RXBUFSIZE
int "XLNXPS UART0 Rx buffer size"
default 256
---help---
XLNXPS UART0 Rx buffer size. Default: 256
config UART_XLNXPS0_TXBUFSIZE
int "XLNXPS UART0 Tx buffer size"
default 256
---help---
XLNXPS UART0 Tx buffer size. Default: 256
config UART_XLNXPS0_IFLOWCONTROL
bool "XLNXPS UART0 RTS flow control"
default n
select SERIAL_IFLOWCONTROL
---help---
Enable XLNXPS UART0 RTS flow control
config UART_XLNXPS0_OFLOWCONTROL
bool "XLNXPS UART0 CTS flow control"
default n
select SERIAL_OFLOWCONTROL
---help---
Enable XLNXPS UART0 CTS flow control
endif # UART_XLNXPS0
choice
prompt "XLNXPS Serial Console"
default XLNXPS_NO_SERIAL_CONSOLE
depends on DEV_CONSOLE
config UART_XLNXPS0_SERIAL_CONSOLE
bool "XLNXPS UART0 serial console"
depends on UART_XLNXPS0
select SERIAL_CONSOLE
config XLNXPS_NO_SERIAL_CONSOLE
bool "No XLNXPS serial console"
endchoice # XLNXPS Serial Console
config XLNXPS_SUPRESS_CONFIG
bool "Suppress XLNXPS configuration"
default n
config XLNXPS_SUPRESS_INITIAL_CONFIG
bool "Suppress initial XLNXPS configuration"
depends on !XLNXPS_SUPRESS_CONFIG
default n
---help---
This option is useful, for example, if you are using a bootloader
that configures the UART_XLNXPS. In that case, you may want to
just leave the existing console configuration in place. Default: n
config SERIAL_UART_ARCH_MMIO
bool "Platform access register through the memory mapping"
default n
config SERIAL_UART_ARCH_IOCTL
bool "Platform has own custom IOCTL"
default n
endif # UART_XLNXPS

View file

@ -58,6 +58,10 @@ ifeq ($(CONFIG_UART_HOSTFS),y)
CSRCS += uart_hostfs.c
endif
ifeq ($(CONFIG_UART_XLNXPS),y)
CSRCS += uart_xlnx_ps.c
endif
# Pseudo-terminal support
ifeq ($(CONFIG_PSEUDOTERM),y)

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,48 @@
/****************************************************************************
* include/nuttx/serial/uart_xlnx_ps.h
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __INCLUDE_NUTTX_SERIAL_UART_XLNXPS_H
#define __INCLUDE_NUTTX_SERIAL_UART_XLNXPS_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#ifdef CONFIG_UART_XLNXPS
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Functions Prototypes
****************************************************************************/
void xlnxps_earlyserialinit(void);
void xlnxps_serialinit(void);
#endif /* CONFIG_UART_XLNXPS */
#endif /* __INCLUDE_NUTTX_SERIAL_UART_XLNXPS_H */