serial: nulldev: Add nulldev serial driver
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>
diff --git a/drivers/serial/serial_nulldev.c b/drivers/serial/serial_nulldev.c
new file mode 100644
index 0000000..0768308
--- /dev/null
+++ b/drivers/serial/serial_nulldev.c
@@ -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,
+};