public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2] serial: nulldev: Add nulldev serial driver
@ 2017-08-25  3:29 Wilson Lee
  2017-08-29  1:41 ` Bin Meng
  2017-09-14  2:14 ` [U-Boot] [U-Boot, " Tom Rini
  0 siblings, 2 replies; 4+ messages in thread
From: Wilson Lee @ 2017-08-25  3:29 UTC (permalink / raw)
  To: u-boot

From: Keng Soon Cheah <keng.soon.cheah@ni.com>

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          |  7 ++++++
 drivers/serial/Makefile         |  1 +
 drivers/serial/serial_nulldev.c | 48 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 56 insertions(+)
 create mode 100644 drivers/serial/serial_nulldev.c

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index a8e9978..5064edf 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -409,6 +409,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
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index 72a6996..7adcee3 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -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
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,
+};
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH v2] serial: nulldev: Add nulldev serial driver
  2017-08-25  3:29 [U-Boot] [PATCH v2] serial: nulldev: Add nulldev serial driver Wilson Lee
@ 2017-08-29  1:41 ` Bin Meng
  2017-08-29  4:18   ` Wilson Lee
  2017-09-14  2:14 ` [U-Boot] [U-Boot, " Tom Rini
  1 sibling, 1 reply; 4+ messages in thread
From: Bin Meng @ 2017-08-29  1:41 UTC (permalink / raw)
  To: u-boot

Hi Wilson,

On Fri, Aug 25, 2017 at 11:29 AM, Wilson Lee <wilson.lee@ni.com> wrote:
> From: Keng Soon Cheah <keng.soon.cheah@ni.com>
>
> 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.
>

I still don't fully understand this. Shouldn't the FPGA serial driver
has some sort of register bits that determine if it's ready? And if
not ready, the FPGA serial driver can do nothing like your null serial
driver does?

> 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          |  7 ++++++
>  drivers/serial/Makefile         |  1 +
>  drivers/serial/serial_nulldev.c | 48 +++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 56 insertions(+)
>  create mode 100644 drivers/serial/serial_nulldev.c
>

[snip]

Regards,
Bin

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH v2] serial: nulldev: Add nulldev serial driver
  2017-08-29  1:41 ` Bin Meng
@ 2017-08-29  4:18   ` Wilson Lee
  0 siblings, 0 replies; 4+ messages in thread
From: Wilson Lee @ 2017-08-29  4:18 UTC (permalink / raw)
  To: u-boot

Hi Bin Meng,

On Tue, 2017-08-29 at 09:41 +0800, Bin Meng wrote:
> Hi Wilson,
> 
> On Fri, Aug 25, 2017 at 11:29 AM, Wilson Lee <wilson.lee@ni.com>
> wrote:
> > 
> > From: Keng Soon Cheah <keng.soon.cheah@ni.com>
> > 
> > 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.
> > 
> I still don't fully understand this. Shouldn't the FPGA serial driver
> has some sort of register bits that determine if it's ready? And if
> not ready, the FPGA serial driver can do nothing like your null
> serial
> driver does?
> 

In most case we will not implement new FPGA serial driver. For example,
we will try to implement the ns16550 serial module in FPGA and reuse
the ns16550 driver that already exist in u-boot. The ns16550 driver
will not know when is the right time to initialize the console hence
causing system halt.

This nulldev console will eventually help to prevent such situation.
Before the FPGA is ready, all the console initialization and output
will be redirect to this nulldev console. After the FPGA is ready,
"user" have the "flexibility" redirect the console to ns16550 serial
module in FPGA.

> > 
> > 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          |  7 ++++++
> >  drivers/serial/Makefile         |  1 +
> >  drivers/serial/serial_nulldev.c | 48
> > +++++++++++++++++++++++++++++++++++++++++
> >  3 files changed, 56 insertions(+)
> >  create mode 100644 drivers/serial/serial_nulldev.c
> > 
> [snip]
> 
> Regards,
> Bin

Thanks.

Best Regards,
Wilson Lee

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [U-Boot, v2] serial: nulldev: Add nulldev serial driver
  2017-08-25  3:29 [U-Boot] [PATCH v2] serial: nulldev: Add nulldev serial driver Wilson Lee
  2017-08-29  1:41 ` Bin Meng
@ 2017-09-14  2:14 ` Tom Rini
  1 sibling, 0 replies; 4+ messages in thread
From: Tom Rini @ 2017-09-14  2:14 UTC (permalink / raw)
  To: u-boot

On Thu, Aug 24, 2017 at 08:29:07PM -0700, Wilson Lee wrote:

> From: Keng Soon Cheah <keng.soon.cheah@ni.com>
> 
> 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>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170913/d0e74c26/attachment.sig>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-09-14  2:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-25  3:29 [U-Boot] [PATCH v2] serial: nulldev: Add nulldev serial driver Wilson Lee
2017-08-29  1:41 ` Bin Meng
2017-08-29  4:18   ` Wilson Lee
2017-09-14  2:14 ` [U-Boot] [U-Boot, " Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox