mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/3] Earlycon command line option support
@ 2019-03-12  7:45 Andrey Smirnov
  2019-03-12  7:45 ` [PATCH 1/3] console: Add plumbing to expose earlycon/bootconsole parameter Andrey Smirnov
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Andrey Smirnov @ 2019-03-12  7:45 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Everyone:

This small series is something I came up with to avoid having to look
up the syntax and manually specify earlycon kernel command line option
every time I needed it. The series is purely optional in case I am not
the only one who thinks this is useful.

Feedback is welcome!

Thanks,
Andrey Smirnov

Andrey Smirnov (3):
  console: Add plumbing to expose earlycon/bootconsole parameter
  serial: i.MX: Add code to export "earlycon" setting
  serial: lpuart: Add code to export "earlycon" setting

 Documentation/user/variables.rst |  1 +
 common/console.c                 | 25 +++++++++++++++++++++++++
 drivers/serial/serial_imx.c      |  3 +++
 drivers/serial/serial_lpuart.c   |  1 +
 include/console.h                |  1 +
 5 files changed, 31 insertions(+)

-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 1/3] console: Add plumbing to expose earlycon/bootconsole parameter
  2019-03-12  7:45 [PATCH 0/3] Earlycon command line option support Andrey Smirnov
@ 2019-03-12  7:45 ` Andrey Smirnov
  2019-03-12  7:45 ` [PATCH 2/3] serial: i.MX: Add code to export "earlycon" setting Andrey Smirnov
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Andrey Smirnov @ 2019-03-12  7:45 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Similar to what we already do to kernel's "console" parameter, add
code to allow serial drivers to expose their "earlycon"
setting. Unlike the plumbing for "console", "earlycon" is not
automatically added to kernel command line and has to be enabled by
the user.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 Documentation/user/variables.rst |  1 +
 common/console.c                 | 25 +++++++++++++++++++++++++
 include/console.h                |  1 +
 3 files changed, 27 insertions(+)

diff --git a/Documentation/user/variables.rst b/Documentation/user/variables.rst
index ddfd48574..f3bcaa3a8 100644
--- a/Documentation/user/variables.rst
+++ b/Documentation/user/variables.rst
@@ -114,5 +114,6 @@ of all variables with special meaning along with a short description:
   bootsource                       The source barebox has been booted from
   bootsource_instance              The instance of the source barebox has been booted from
   global.boot.default              default boot order
+  global.linux.bootconsole         current console's "earlycon" setting for Linux kernel
   ...
 
diff --git a/common/console.c b/common/console.c
index 47ccf2e54..29d0f2779 100644
--- a/common/console.c
+++ b/common/console.c
@@ -253,6 +253,30 @@ static void console_set_stdoutpath(struct console_device *cdev)
 	free(str);
 }
 
+static void console_set_boot_stdoutpath(struct console_device *cdev)
+{
+	char *str;
+
+	if (!cdev->linux_bootconsole_name)
+		return;
+
+	str = basprintf("earlycon=%s,%dn8", cdev->linux_bootconsole_name,
+			cdev->baudrate);
+	/*
+	 * linux.bootconsole is used instead of
+	 * linux.bootargs.bootconsole in orger to make this feature
+	 * optional. To enable, add
+	 *
+	 *     global linux.bootargs.bootconsole
+	 *     global.linux.bootargs.bootconsole=${global.linux.bootconsole}
+	 *
+	 * somwhere in your boot scripts
+	 */
+	globalvar_add_simple("linux.bootconsole", str);
+
+	free(str);
+}
+
 static int __console_puts(struct console_device *cdev, const char *s)
 {
 	int n = 0;
@@ -360,6 +384,7 @@ int console_register(struct console_device *newcdev)
 	if (newcdev->dev && of_device_is_stdout_path(newcdev->dev)) {
 		activate = 1;
 		console_set_stdoutpath(newcdev);
+		console_set_boot_stdoutpath(newcdev);
 	}
 
 	list_add_tail(&newcdev->list, &console_list);
diff --git a/include/console.h b/include/console.h
index 673921331..09d7ebae5 100644
--- a/include/console.h
+++ b/include/console.h
@@ -64,6 +64,7 @@ struct console_device {
 	unsigned int baudrate_param;
 
 	const char *linux_console_name;
+	const char *linux_bootconsole_name;
 
 	struct cdev devfs;
 	struct cdev_operations fops;
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 2/3] serial: i.MX: Add code to export "earlycon" setting
  2019-03-12  7:45 [PATCH 0/3] Earlycon command line option support Andrey Smirnov
  2019-03-12  7:45 ` [PATCH 1/3] console: Add plumbing to expose earlycon/bootconsole parameter Andrey Smirnov
@ 2019-03-12  7:45 ` Andrey Smirnov
  2019-03-12  7:45 ` [PATCH 3/3] serial: lpuart: " Andrey Smirnov
  2019-03-12  9:43 ` [PATCH 0/3] Earlycon command line option support Lucas Stach
  3 siblings, 0 replies; 6+ messages in thread
From: Andrey Smirnov @ 2019-03-12  7:45 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Add code to generate appropriate "earlycon" setting that can be passed
to Linux kernel.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/serial/serial_imx.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/serial/serial_imx.c b/drivers/serial/serial_imx.c
index 09341af87..e5d41c0bc 100644
--- a/drivers/serial/serial_imx.c
+++ b/drivers/serial/serial_imx.c
@@ -241,6 +241,9 @@ static int imx_serial_probe(struct device_d *dev)
 	cdev->flush = imx_serial_flush;
 	cdev->setbrg = imx_serial_setbaudrate;
 	cdev->linux_console_name = "ttymxc";
+	if (devtype == &imx21_data)
+		cdev->linux_bootconsole_name = basprintf("ec_imx21,0x%p",
+							 priv->regs);
 	if (dev->device_node) {
 		devname = of_alias_get(dev->device_node);
 		if (devname) {
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 3/3] serial: lpuart: Add code to export "earlycon" setting
  2019-03-12  7:45 [PATCH 0/3] Earlycon command line option support Andrey Smirnov
  2019-03-12  7:45 ` [PATCH 1/3] console: Add plumbing to expose earlycon/bootconsole parameter Andrey Smirnov
  2019-03-12  7:45 ` [PATCH 2/3] serial: i.MX: Add code to export "earlycon" setting Andrey Smirnov
@ 2019-03-12  7:45 ` Andrey Smirnov
  2019-03-12  9:43 ` [PATCH 0/3] Earlycon command line option support Lucas Stach
  3 siblings, 0 replies; 6+ messages in thread
From: Andrey Smirnov @ 2019-03-12  7:45 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Add code to generate appropriate "earlycon" setting that can be passed
to Linux kernel.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/serial/serial_lpuart.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/serial/serial_lpuart.c b/drivers/serial/serial_lpuart.c
index 246fc3d3a..40789d720 100644
--- a/drivers/serial/serial_lpuart.c
+++ b/drivers/serial/serial_lpuart.c
@@ -172,6 +172,7 @@ static int lpuart_serial_probe(struct device_d *dev)
 	}
 
 	cdev->linux_console_name = "ttyLP";
+	cdev->linux_bootconsole_name = basprintf("lpuart,0x%p", lpuart->base);
 
 	lpuart_setup(lpuart->base, clk_get_rate(lpuart->clk));
 
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 0/3] Earlycon command line option support
  2019-03-12  7:45 [PATCH 0/3] Earlycon command line option support Andrey Smirnov
                   ` (2 preceding siblings ...)
  2019-03-12  7:45 ` [PATCH 3/3] serial: lpuart: " Andrey Smirnov
@ 2019-03-12  9:43 ` Lucas Stach
  2019-03-13  8:45   ` Sascha Hauer
  3 siblings, 1 reply; 6+ messages in thread
From: Lucas Stach @ 2019-03-12  9:43 UTC (permalink / raw)
  To: Andrey Smirnov, barebox

Hi Andrey,

Am Dienstag, den 12.03.2019, 00:45 -0700 schrieb Andrey Smirnov:
> Everyone:
> 
> This small series is something I came up with to avoid having to look
> up the syntax and manually specify earlycon kernel command line option
> every time I needed it. The series is purely optional in case I am not
> the only one who thinks this is useful.
> 
> Feedback is welcome!
> 
> Thanks,
> Andrey Smirnov
> 
> Andrey Smirnov (3):
>   console: Add plumbing to expose earlycon/bootconsole parameter
>   serial: i.MX: Add code to export "earlycon" setting
>   serial: lpuart: Add code to export "earlycon" setting
> 
>  Documentation/user/variables.rst |  1 +
>  common/console.c                 | 25 +++++++++++++++++++++++++
>  drivers/serial/serial_imx.c      |  3 +++
>  drivers/serial/serial_lpuart.c   |  1 +
>  include/console.h                |  1 +
>  5 files changed, 31 insertions(+)

I don't think any of this is necessary. For DT based platforms earlycon
will use the console specified via the "stdout-path" property, so it's
entirely sufficient to add "earlycon" to the kernel command line and
the kernel will do the right thing. No need for any more elaborate
kernel commandline options.

Regards,
Lucas

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 0/3] Earlycon command line option support
  2019-03-12  9:43 ` [PATCH 0/3] Earlycon command line option support Lucas Stach
@ 2019-03-13  8:45   ` Sascha Hauer
  0 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2019-03-13  8:45 UTC (permalink / raw)
  To: Lucas Stach; +Cc: Andrey Smirnov, barebox

On Tue, Mar 12, 2019 at 10:43:37AM +0100, Lucas Stach wrote:
> Hi Andrey,
> 
> Am Dienstag, den 12.03.2019, 00:45 -0700 schrieb Andrey Smirnov:
> > Everyone:
> > 
> > This small series is something I came up with to avoid having to look
> > up the syntax and manually specify earlycon kernel command line option
> > every time I needed it. The series is purely optional in case I am not
> > the only one who thinks this is useful.
> > 
> > Feedback is welcome!
> > 
> > Thanks,
> > Andrey Smirnov
> > 
> > Andrey Smirnov (3):
> >   console: Add plumbing to expose earlycon/bootconsole parameter
> >   serial: i.MX: Add code to export "earlycon" setting
> >   serial: lpuart: Add code to export "earlycon" setting
> > 
> >  Documentation/user/variables.rst |  1 +
> >  common/console.c                 | 25 +++++++++++++++++++++++++
> >  drivers/serial/serial_imx.c      |  3 +++
> >  drivers/serial/serial_lpuart.c   |  1 +
> >  include/console.h                |  1 +
> >  5 files changed, 31 insertions(+)
> 
> I don't think any of this is necessary. For DT based platforms earlycon
> will use the console specified via the "stdout-path" property, so it's
> entirely sufficient to add "earlycon" to the kernel command line and
> the kernel will do the right thing. No need for any more elaborate
> kernel commandline options.

I'm with Lucas here unless some good arguments come up why this is
needed.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2019-03-13  8:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-12  7:45 [PATCH 0/3] Earlycon command line option support Andrey Smirnov
2019-03-12  7:45 ` [PATCH 1/3] console: Add plumbing to expose earlycon/bootconsole parameter Andrey Smirnov
2019-03-12  7:45 ` [PATCH 2/3] serial: i.MX: Add code to export "earlycon" setting Andrey Smirnov
2019-03-12  7:45 ` [PATCH 3/3] serial: lpuart: " Andrey Smirnov
2019-03-12  9:43 ` [PATCH 0/3] Earlycon command line option support Lucas Stach
2019-03-13  8:45   ` Sascha Hauer

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