serial: add driver for the MPC52xx PSC UARTs and RS485 mode
cover serial: add driver for the MPC52xx PSC UARTs and RS485 mode
From: Wolfgang Grandegger <[email protected]>
This series of patches adds a RTserial driver for the MPC52xx PSC UARTs on the MPC5200 SOCs. It includes support for RS485 mode and shift register empty events (RTSER_EVENT_TXEMPTY), which is introduced first.
Wolfgang Grandegger (3):
serial/16650a: fix missing value in default_config initialization
serial: add shift register empty event and RS485 support flag
serial: add driver for the MPC52xx PSC UARTs
include/rtdm/rtserial.h | 14 + ksrc/drivers/serial/16550A.c | 4 +- ksrc/drivers/serial/Kconfig | 6 + ksrc/drivers/serial/Makefile | 2 + ksrc/drivers/serial/rt_mpc52xx_uart.c | 1462 +++++++++++++++++++++++++++++++++ 5 files changed, 1486 insertions(+), 2 deletions(-) create mode 100644 ksrc/drivers/serial/rt_mpc52xx_uart.c
Signature · 1 line
1.7.6.4
PATCH 1/3 serial/16650a: fix missing value in default_config initialization
From: Wolfgang Grandegger <[email protected]>
--- ksrc/drivers/serial/16550A.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
ksrc/drivers/serial/16550A.c +1 -1
@@ -111,7 +111,7 @@ struct rt_16550_context {static const struct rtser_config default_config = {0xFFFF ,RTSER_DEF_BAUD ,RTSER_DEF_PARITY ,RTSER_DEF_BITS , -RTSER_DEF_STOPB ,RTSER_DEF_HAND ,RTSER_DEF_FIFO_DEPTH , +RTSER_DEF_STOPB ,RTSER_DEF_HAND ,RTSER_DEF_FIFO_DEPTH ,0 ,RTSER_DEF_TIMEOUT ,RTSER_DEF_TIMEOUT ,RTSER_DEF_TIMEOUT ,RTSER_DEF_TIMESTAMP_HISTORY ,RTSER_DEF_EVENT_MASK };
Signature · 1 line
1.7.6.4
PATCH 2/3 serial: add shift register empty event and RS485 support flag
In reply to Wolfgang GrandeggerFrom: Wolfgang Grandegger <[email protected]>
This patch extends rtserial.h to support RS485 and shift register empty events. In contrast to the MPC5200 PSC UART, the 16550A seem not be able to signal that event via interrupt. The "Tramsmitter Empty" bit in the line status register needs to be polled.
--- include/rtdm/rtserial.h | 14 ++++++++++++++ ksrc/drivers/serial/16550A.c | 2 +- 2 files changed, 15 insertions(+), 1 deletions(-)
include/rtdm/rtserial.h +14 -0
@@ -130,6 +130,15 @@/** @} */ /*! +* @anchor RTSER_RS485_xxx @name RTSER_RS485_xxx +* RS485 mode with automatic RTS handling +* @{ */ +#define RTSER_RS485_DISABLE 0x00 +#define RTSER_RS485_ENABLE 0x01 +#define RTSER_DEF_RS485 RTSER_RS485_DISABLE +/** @} */ + +/*! * @anchor RTSER_FIFO_xxx @name RTSER_FIFO_xxx * Reception FIFO interrupt threshold * @{ */
@@ -165,6 +174,7 @@#define RTSER_EVENT_ERRPEND 0x02#define RTSER_EVENT_MODEMHI 0x04#define RTSER_EVENT_MODEMLO 0x08 +#define RTSER_EVENT_TXEMPTY 0x10#define RTSER_DEF_EVENT_MASK 0x00/** @} */
@@ -184,6 +194,7 @@#define RTSER_SET_TIMEOUT_EVENT 0x0400#define RTSER_SET_TIMESTAMP_HISTORY 0x0800#define RTSER_SET_EVENT_MASK 0x1000 +#define RTSER_SET_RS485 0x2000/** @} */
@@ -282,6 +293,9 @@ typedef struct rtser_config {/** event mask to be used with @ref RTSER_RTIOC_WAIT_EVENT, see * @ref RTSER_EVENT_xxx */ int event_mask; + +/** enable RS485 mode, see @ref RTSER_RS485_xxx */ +int rs485; } rtser_config_t;/**
ksrc/drivers/serial/16550A.c +1 -1
@@ -113,7 +113,7 @@ static const struct rtser_config default_config = {0xFFFF ,RTSER_DEF_BAUD ,RTSER_DEF_PARITY ,RTSER_DEF_BITS ,RTSER_DEF_STOPB ,RTSER_DEF_HAND ,RTSER_DEF_FIFO_DEPTH ,0 ,RTSER_DEF_TIMEOUT ,RTSER_DEF_TIMEOUT ,RTSER_DEF_TIMEOUT , -RTSER_DEF_TIMESTAMP_HISTORY ,RTSER_DEF_EVENT_MASK +RTSER_DEF_TIMESTAMP_HISTORY ,RTSER_DEF_EVENT_MASK ,RTSER_DEF_RS485 };static struct rtdm_device *device[MAX_DEVICES ];
Signature · 1 line
1.7.6.4
PATCH 3/3 serial: add driver for the MPC52xx PSC UARTs
In reply to Wolfgang GrandeggerFrom: Wolfgang Grandegger <[email protected]>
This driver tries to fake the ioctl interface of the 16650A as good as possible. The device gets the name "rtserPSCx" where "x" is the sequential PSC device number similar to the linux MPC52xx UART driver (using ttyPSCx). You may need to unbind the Linux serial driver first e.g. for PSC3:
-bash-3.2# echo f0002400.serial \ > /sys/devices/f0000000.soc5200/f0002400.serial/driver/unbind
This driver also supports the recently introduced RTSER_EVENT_TXEMPTY event and the RS485 mode.
--- ksrc/drivers/serial/Kconfig | 6 + ksrc/drivers/serial/Makefile | 2 + ksrc/drivers/serial/rt_mpc52xx_uart.c | 1462 +++++++++++++++++++++++++++++++++ 3 files changed, 1470 insertions(+), 0 deletions(-) create mode 100644 ksrc/drivers/serial/rt_mpc52xx_uart.c
ksrc/drivers/serial/Kconfig +6 -0
@@ -63,4 +63,10 @@ config XENO_DRIVERS_16550A_PCI_MOXA CP-132U, CP-134U, CP-138U CP-168U +config XENO_DRIVERS_MPC52XX_UART + depends on XENO_SKIN_RTDM && PPC_MPC52xx + tristate "MPC52xx PSC UART driver" + help + Real-time UART driver for the PSC on the MPC5200 processor. + endmenu
ksrc/drivers/serial/Makefile +2 -0
@@ -5,8 +5,10 @@ ifneq ($(VERSION).$(PATCHLEVEL),2.4) EXTRA_CFLAGS += -D__IN_XENOMAI__ -Iinclude/xenomai obj-$(CONFIG_XENO_DRIVERS_16550A) += xeno_16550A.o +obj-$(CONFIG_XENO_DRIVERS_MPC52XX_UART) += xeno_mpc52xx_uart.o xeno_16550A-y := 16550A.o +xeno_mpc52xx_uart-y := rt_mpc52xx_uart.o else
ksrc/drivers/serial/rt_mpc52xx_uart.c new file +1462 -0
1,462 lines not on this page · raw message
Signature · 1 line
1.7.6.4