serial/arc-uart: Add new driver
Subsystems (2)
PATCH 1/1 serial/arc-uart: Add new driver
From: Vineet Gupta <[email protected]>
Driver for non-standard on-chip UART, instantiated in the ARC (Synopsys) FPGA Boards such as ARCAngel4/ML50x
This is based off of current Linus tree, build tested for x86.
--- drivers/tty/serial/Kconfig | 25 ++ drivers/tty/serial/Makefile | 1 + drivers/tty/serial/arc_uart.c | 742 +++++++++++++++++++++++++++++++++++++++++ include/linux/serial_core.h | 3 + 4 files changed, 771 insertions(+), 0 deletions(-) create mode 100644 drivers/tty/serial/arc_uart.c
drivers/tty/serial/Kconfig +25 -0
@@ -1360,4 +1360,29 @@ config SERIAL_EFM32_UART_CONSOLE depends on SERIAL_EFM32_UART=y select SERIAL_CORE_CONSOLE +config SERIAL_ARC + bool "ARC UART driver support" + select SERIAL_CORE + default y + help + Driver for on-chip UART for ARC(Synopsys) for the legacy + FPGA Boards (ML50x/ARCAngel4) + +config SERIAL_ARC_CONSOLE + bool + select SERIAL_CORE_CONSOLE + depends on SERIAL_ARC=y + default y + help + Enable system Console on ARC UART + +config SERIAL_ARC_NR_PORTS + int 'Number of ports' + range 1 3 + default 1 + depends on SERIAL_ARC + help + Set this to the number of serial ports you want the driver + to support. + endmenu
drivers/tty/serial/Makefile +1 -0
@@ -79,3 +79,4 @@ obj-$(CONFIG_SERIAL_XILINX_PS_UART) += xilinx_uartps.o obj-$(CONFIG_SERIAL_SIRFSOC) += sirfsoc_uart.o obj-$(CONFIG_SERIAL_AR933X) += ar933x_uart.o obj-$(CONFIG_SERIAL_EFM32_UART) += efm32-uart.o +obj-$(CONFIG_SERIAL_ARC) += arc_uart.o
drivers/tty/serial/arc_uart.c new file +742 -0
742 lines not on this page · raw message
include/linux/serial_core.h +3 -0
@@ -214,6 +214,9 @@/* Energy Micro efm32 SoC */ #define PORT_EFMUART 100 +/* ARC (Synopsys) on-chip UART */ +#define PORT_ARC 101 +#ifdef __KERNEL__#include <linux/compiler.h>
Signature · 1 line
1.7.4.1
Quoted 1 line
+int __attribute__((weak))
running_on_iss;
Globals really ought to have sensible names, if they must exist at all. Why is this needed ?
Quoted 1 line
+#define
ARC_SERIAL_DEV_NAME"ttyS"
ttyS is reserved by the 8250 driver. Use a different name
drivers/tty/serial/arc_uart.c line 102
Quoted 3 lines
/* ttySxx per
Documentation/devices.txt*/drivers/tty/serial/arc_uart.c new file +2
-0+#define ARC_SERIAL_MAJOR 4 +#define ARC_SERIAL_MINOR 64
Use dynamic assignments
drivers/tty/serial/arc_uart.c line 222
Quoted 6 lines
drivers/tty/serial/arc_uart.c new file +6
-0+static void arc_serial_rx_chars (struct arc_uart_port *uart) +{ +struct tty_struct *tty =NULL ; +unsigned int status, ch, flg =0 ; + + tty = uart->port.state->port.tty;
Please get rid of the unneeded initialisers for things like tty - they just hide bugs later.
For locking purposes you need to be doing
tty = tty_port_tty_get(&uart->port.state->port);
if (tty) {
stuff
tty_kref_put(tty);so that the tty cannot vanish under you on a hangup. As you reference it in several spots it might make sense to do that once if either RXIENB/TXIENB is set and then pass it to the tx/rx handlers ?
drivers/tty/serial/arc_uart.c line 355
Quoted 3 lines
+static void
arc_serial_break_ctl(struct uart_port *port, int break_state)+{drivers/tty/serial/arc_uart.c new file +1
-0+/* ARC UART doesn't support sendind Break signal */
sending ..
drivers/tty/serial/arc_uart.c line 386
Quoted 4 lines
drivers/tty/serial/arc_uart.c new file +4
-0+static void arc_serial_set_ldisc (struct uart_port *port,int ld) +{ +/* this might need implementing for the touch driver */ +}
Is this a left over comment or somehting else ?
drivers/tty/serial/arc_uart.c line 395
Quoted 9 lines
(quoted diff) +2
-0+static void +arc_serial_set_termios(struct uart_port *port, struct ktermios*termios,
drivers/tty/serial/arc_uart.c new file +6
-0+ struct ktermios *old) +{ +struct arc_uart_port *uart = (struct arc_uart_port *)port; +unsigned int baud, uartl, uarth, hw_val; +unsigned long flags; +
Two things here. Firstly you want to write the actual baud back to the termios (tty_termios_encode_baud_rate) unless B0 is set.
Secondly if you don't support hardware flow control, character size setting etc then you need to set those bits back so the caller knows. Two ways to do that. Either initialise the default termios for the tty type to the correct values and use tty_termios_copy_hw() or set them in the termios handler.
Alan
Quoted 12 lines · Alan Cox
drivers/tty/serial/arc_uart.c line 395
Quoted 9 lines
(quoted diff) +2
-0+static void +arc_serial_set_termios(struct uart_port *port, struct ktermios*termios,
drivers/tty/serial/arc_uart.c new file +6
-0+ struct ktermios *old) +{ +struct arc_uart_port *uart = (struct arc_uart_port *)port; +unsigned int baud, uartl, uarth, hw_val; +unsigned long flags; +Two things here. Firstly you want to write the actual baud back to the termios (
tty_termios_encode_baud_rate) unless B0 is set.
Quoted 5 lines
Secondly if you don't support hardware flow control, character size setting etc then you need to set those bits back so the caller knows. Two ways to do that. Either initialise the default termios for the tty type to the correct values and use
tty_termios_copy_hw()or set them in the termios handler.
Just to give you an idea, is something on the lines of following OK for both the above points above !
- uart_update_timeout(port, termios->c_cflag, baud);
+ new->c_cflag &= ~(CMSPAR|CRTSCTS); /* Don't care for
parity/flow ctrl */
+
+ if (old)
+ tty_termios_copy_hw(new, old);
+
+ /* Don't rewrite B0 */
+ if (tty_termios_baud_rate(new))
+ tty_termios_encode_baud_rate(new, baud, baud);
+
+ uart_update_timeout(port, new->c_cflag, baud);
Respun patch to follow shortly.
Thx,
Vineet