Thread (9 messages) 9 messages, 2 authors, 2020-06-04

Re: [PATCH v6 5/5] drivers/tty/serial: add LiteUART driver

From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date: 2020-06-04 07:57:28
Also in: linux-devicetree, lkml

On Thu, Jun 04, 2020 at 09:16:25AM +0200, Mateusz Holenko wrote:
On Wed, May 27, 2020 at 6:27 PM Mateusz Holenko [off-list ref] wrote:
quoted
From: Filip Kokosinski <redacted>

This commit adds driver for the FPGA-based LiteUART serial controller
from LiteX SoC builder.

The current implementation supports LiteUART configured
for 32 bit data width and 8 bit CSR bus width.

It does not support IRQ.

Signed-off-by: Filip Kokosinski <redacted>
Signed-off-by: Mateusz Holenko <mholenko@antmicro.com>
---

Notes:
    Changes in v6:
    - LiteUART ports now stored in xArray
    - removed PORT_LITEUART
    - fixed formatting
    - removed some unnecessary defines

    No changes in v5.

    Changes in v4:
    - fixed copyright header
    - removed a wrong dependency on UARTLITE from Kconfig
    - added a dependency on LITEX_SOC_CONTROLLER to LITEUART in Kconfig

    Changes in v3:
    - aliases made optional
    - used litex_get_reg/litex_set_reg functions instead of macros
    - SERIAL_LITEUART_NR_PORTS renamed to SERIAL_LITEUART_MAX_PORTS
    - PORT_LITEUART changed from 122 to 123
    - added dependency on LITEX_SOC_CONTROLLER
    - patch number changed from 4 to 5

    No changes in v2.

 MAINTAINERS                   |   1 +
 drivers/tty/serial/Kconfig    |  31 +++
 drivers/tty/serial/Makefile   |   1 +
 drivers/tty/serial/liteuart.c | 404 ++++++++++++++++++++++++++++++++++
 4 files changed, 437 insertions(+)
 create mode 100644 drivers/tty/serial/liteuart.c
diff --git a/MAINTAINERS b/MAINTAINERS
index 51d2d6a61fb0..d855fe807833 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -9846,6 +9846,7 @@ M:        Mateusz Holenko <mholenko@antmicro.com>
 S:     Maintained
 F:     Documentation/devicetree/bindings/*/litex,*.yaml
 F:     drivers/soc/litex/litex_soc_ctrl.c
+F:     drivers/tty/serial/liteuart.c
 F:     include/linux/litex.h

 LIVE PATCHING
diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index adf9e80e7dc9..17aaf0afb27a 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -1562,6 +1562,37 @@ config SERIAL_MILBEAUT_USIO_CONSOLE
          receives all kernel messages and warnings and which allows logins in
          single user mode).

+config SERIAL_LITEUART
+       tristate "LiteUART serial port support"
+       depends on HAS_IOMEM
+       depends on OF || COMPILE_TEST
+       depends on LITEX_SOC_CONTROLLER
+       select SERIAL_CORE
+       help
+         This driver is for the FPGA-based LiteUART serial controller from LiteX
+         SoC builder.
+
+         Say 'Y' here if you wish to use the LiteUART serial controller.
+         Otherwise, say 'N'.
+
+config SERIAL_LITEUART_MAX_PORTS
+       int "Maximum number of LiteUART ports"
+       depends on SERIAL_LITEUART
+       default "1"
+       help
+         Set this to the maximum number of serial ports you want the driver
+         to support.
+
+config SERIAL_LITEUART_CONSOLE
+       bool "LiteUART serial port console support"
+       depends on SERIAL_LITEUART=y
+       select SERIAL_CORE_CONSOLE
+       help
+         Say 'Y' here if you wish to use the FPGA-based LiteUART serial controller
+         from LiteX SoC builder as the system console (the system console is the
+         device which receives all kernel messages and warnings and which allows
+         logins in single user mode). Otherwise, say 'N'.
+
 endmenu

 config SERIAL_MCTRL_GPIO
diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile
index d056ee6cca33..9f8ba419ff3b 100644
--- a/drivers/tty/serial/Makefile
+++ b/drivers/tty/serial/Makefile
@@ -89,6 +89,7 @@ obj-$(CONFIG_SERIAL_OWL)      += owl-uart.o
 obj-$(CONFIG_SERIAL_RDA)       += rda-uart.o
 obj-$(CONFIG_SERIAL_MILBEAUT_USIO) += milbeaut_usio.o
 obj-$(CONFIG_SERIAL_SIFIVE)    += sifive.o
+obj-$(CONFIG_SERIAL_LITEUART) += liteuart.o

 # GPIOLIB helpers for modem control lines
 obj-$(CONFIG_SERIAL_MCTRL_GPIO)        += serial_mctrl_gpio.o
diff --git a/drivers/tty/serial/liteuart.c b/drivers/tty/serial/liteuart.c
new file mode 100644
index 000000000000..22b7612c13ca
--- /dev/null
+++ b/drivers/tty/serial/liteuart.c
@@ -0,0 +1,404 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * LiteUART serial controller (LiteX) Driver
+ *
+ * Copyright (C) 2019-2020 Antmicro <www.antmicro.com>
+ */
+
+#include <linux/console.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_platform.h>
+#include <linux/serial.h>
+#include <linux/serial_core.h>
+#include <linux/timer.h>
+#include <linux/tty_flip.h>
+#include <linux/litex.h>
+#include <linux/xarray.h>
kbuild test robot reported problems with this patch, namely: implicit
declaration of function 'kzalloc'
This is caused by the missing include directive. When I was testing it
I must have missed the warning, but the compilation succeeded and the
resulting binary worked fine on HW (LiteX/mor1kx platform).
The fix is a simple one-liner, adding a new include:

+#include <linux/slab.h>

Since this is a very small fix and does not modify the actual code of
the driver I want to wait for more feedback on all patches in the
series before resubmitting, in order to limit traffic on the list.
Or should I generate the next version and resend the whole patchset
with this single fix, as otherwise it won't be reviewed at all?
Please fix up and resend.  We can't do anything until after 5.8-rc1 is
out anyway...

thanks,

greg k-h
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help