]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
serial: nulldev: Add nulldev serial driver
authorKeng Soon Cheah <keng.soon.cheah@ni.com>
Fri, 25 Aug 2017 03:29:07 +0000 (20:29 -0700)
committerTom Rini <trini@konsulko.com>
Wed, 13 Sep 2017 13:24:24 +0000 (09:24 -0400)
Some device the serial console's initialization cannot run early during
the boot process. Hence, nulldev serial device is helpful on that
situation.

For example, if the serial module was implemented in FPGA. Serial
initialization is prohibited to run until the FPGA was programmed.

This commit is to adding nulldev serial driver. This will allows the
default console to be specified as a nulldev.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Signed-off-by: Keng Soon Cheah <keng.soon.cheah@ni.com>
Cc: Chen Yee Chew <chen.yee.chew@ni.com>
drivers/serial/Kconfig
drivers/serial/Makefile
drivers/serial/serial_nulldev.c [new file with mode: 0644]

index aeed538fa4e8189d318a4d99b63576e9692ebed0..13b2550d3b42803c1ebe462f626f5ffea51c1aaf 100644 (file)
@@ -414,6 +414,13 @@ config MXC_UART
          If you have a machine based on a Motorola IMX CPU you
          can enable its onboard serial port by enabling this option.
 
+config NULLDEV_SERIAL
+       bool "Null serial device"
+       help
+         Select this to enable null serial device support. A null serial
+         device merely acts as a placeholder for a serial device and does
+         nothing for all it's operation.
+
 config PIC32_SERIAL
        bool "Support for Microchip PIC32 on-chip UART"
        depends on DM_SERIAL && MACH_PIC32
index 72a6996a0aa664c9d0f118d9801eaae36c2d0bc5..7adcee3e1045b027010308aa48a909b8ba56652d 100644 (file)
@@ -49,6 +49,7 @@ obj-$(CONFIG_BCM283X_MU_SERIAL) += serial_bcm283x_mu.o
 obj-$(CONFIG_MSM_SERIAL) += serial_msm.o
 obj-$(CONFIG_MVEBU_A3700_UART) += serial_mvebu_a3700.o
 obj-$(CONFIG_MPC8XX_CONS) += serial_mpc8xx.o
+obj-$(CONFIG_NULLDEV_SERIAL) += serial_nulldev.o
 
 ifndef CONFIG_SPL_BUILD
 obj-$(CONFIG_USB_TTY) += usbtty.o
diff --git a/drivers/serial/serial_nulldev.c b/drivers/serial/serial_nulldev.c
new file mode 100644 (file)
index 0000000..0768308
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2015 National Instruments
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <serial.h>
+
+static int nulldev_serial_setbrg(struct udevice *dev, int baudrate)
+{
+       return 0;
+}
+
+static int nulldev_serial_getc(struct udevice *dev)
+{
+       return -EAGAIN;
+}
+
+static int nulldev_serial_input(struct udevice *dev)
+{
+       return 0;
+}
+
+static int nulldev_serial_putc(struct udevice *dev, const char ch)
+{
+       return 0;
+}
+
+static const struct udevice_id nulldev_serial_ids[] = {
+       { .compatible = "nulldev-serial" },
+       { }
+};
+
+
+const struct dm_serial_ops nulldev_serial_ops = {
+       .putc = nulldev_serial_putc,
+       .getc = nulldev_serial_getc,
+       .setbrg = nulldev_serial_setbrg,
+};
+
+U_BOOT_DRIVER(serial_nulldev) = {
+       .name   = "serial_nulldev",
+       .id     = UCLASS_SERIAL,
+       .of_match = nulldev_serial_ids,
+       .ops    = &nulldev_serial_ops,
+};