mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/8] console: add new $global.bootm.earlycon parameter
@ 2022-05-23  9:25 Ahmad Fatoum
  2022-05-23  9:25 ` [PATCH 2/8] serial: ns16550: add $global.bootm.earlycon fixup support Ahmad Fatoum
                   ` (6 more replies)
  0 siblings, 7 replies; 13+ messages in thread
From: Ahmad Fatoum @ 2022-05-23  9:25 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

barebox already fixes up a suitable console= parameter if it can
determine one into the kernel command line. This doesn't help with early
Linux issues, which can instead be debugged by the earlycon mechanism.

For earlycon to work, the kernel DT must have a stdout-path or the user
needs to explicitly specify what driver to use and how to access it
(base address, optionally access_type).

Make this easier by just having barebox fix up the needed information
when $global.bootm.earlycon is true and the barebox serial driver
provides the needed information. If the serial driver doesn't, a plain
"earlycon" parameter will be fixed up.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/bootm.c    | 24 ++++++++++++++++++++++++
 common/console.c  | 17 +++++++++++++++++
 include/console.h |  2 ++
 3 files changed, 43 insertions(+)

diff --git a/common/bootm.c b/common/bootm.c
index 3c80e8bf949b..712e6ebe4911 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -41,6 +41,7 @@ static struct image_handler *bootm_find_handler(enum filetype filetype,
 }
 
 static int bootm_appendroot;
+static int bootm_earlycon;
 static int bootm_provide_machine_id;
 static int bootm_verbosity;
 
@@ -732,6 +733,26 @@ int bootm_boot(struct bootm_data *bootm_data)
 		}
 	}
 
+	if (bootm_earlycon) {
+		struct console_device *console;
+		const char *earlycon = NULL;
+
+		for_each_console(console) {
+			if (!(console->f_active & (CONSOLE_STDOUT | CONSOLE_STDERR)))
+				continue;
+
+			earlycon = dev_get_param(&console->class_dev, "linux.bootargs.earlycon");
+			if (earlycon)
+				break;
+		}
+
+		if (!earlycon)
+			earlycon = "earlycon";
+
+		pr_info("Adding \"%s\" to Kernel commandline\n", earlycon);
+		globalvar_add_simple("linux.bootargs.bootm.earlycon", earlycon);
+	}
+
 	if (bootm_data->provide_machine_id) {
 		const char *machine_id = getenv_nonempty("global.machine_id");
 		char *machine_id_bootarg;
@@ -798,6 +819,7 @@ err_out:
 	if (data->of_root_node && data->of_root_node != of_get_root_node())
 		of_delete_node(data->of_root_node);
 
+	globalvar_remove("linux.bootargs.bootm.earlycon");
 	globalvar_remove("linux.bootargs.bootm.appendroot");
 	free(data->os_header);
 	free(data->os_file);
@@ -897,6 +919,7 @@ static int bootm_init(void)
 	globalvar_add_simple("bootm.root_dev", NULL);
 	globalvar_add_simple("bootm.tee", NULL);
 	globalvar_add_simple_bool("bootm.appendroot", &bootm_appendroot);
+	globalvar_add_simple_bool("bootm.earlycon", &bootm_earlycon);
 	globalvar_add_simple_bool("bootm.provide_machine_id", &bootm_provide_machine_id);
 	if (IS_ENABLED(CONFIG_BOOTM_INITRD)) {
 		globalvar_add_simple("bootm.initrd", NULL);
@@ -936,6 +959,7 @@ BAREBOX_MAGICVAR(global.bootm.oftree, "bootm default oftree");
 BAREBOX_MAGICVAR(global.bootm.tee, "bootm default tee image");
 BAREBOX_MAGICVAR(global.bootm.verify, "bootm default verify level");
 BAREBOX_MAGICVAR(global.bootm.verbose, "bootm default verbosity level (0=quiet)");
+BAREBOX_MAGICVAR(global.bootm.earlycon, "Add earlycon option to Kernel for early log output");
 BAREBOX_MAGICVAR(global.bootm.appendroot, "Add root= option to Kernel to mount rootfs from the device the Kernel comes from (default, device can be overridden via global.bootm.root_dev)");
 BAREBOX_MAGICVAR(global.bootm.root_dev, "bootm default root device (overrides default device in global.bootm.appendroot)");
 BAREBOX_MAGICVAR(global.bootm.provide_machine_id, "If true, append systemd.machine_id=$global.machine_id to Kernel command line");
diff --git a/common/console.c b/common/console.c
index 8727b187cf7c..c442c2dde132 100644
--- a/common/console.c
+++ b/common/console.c
@@ -220,6 +220,21 @@ static void console_init_early(void)
 	initialized = CONSOLE_INITIALIZED_BUFFER;
 }
 
+static void console_add_earlycon_param(struct console_device *cdev, unsigned baudrate)
+{
+	char *str;
+
+	if (!cdev->linux_earlycon_name)
+		return;
+
+	str = basprintf("earlycon=%s,0x%lx,%dn8", cdev->linux_earlycon_name,
+			(ulong)cdev->phys_base, baudrate);
+
+	dev_add_param_fixed(&cdev->class_dev, "linux.bootargs.earlycon", str);
+
+	free(str);
+}
+
 static void console_set_stdoutpath(struct console_device *cdev, unsigned baudrate)
 {
 	int id;
@@ -332,6 +347,8 @@ int console_register(struct console_device *newcdev)
 		console_set_stdoutpath(newcdev, baudrate);
 	}
 
+	console_add_earlycon_param(newcdev, baudrate);
+
 	if (newcdev->setbrg) {
 		ret = newcdev->setbrg(newcdev, baudrate);
 		if (ret)
diff --git a/include/console.h b/include/console.h
index 5d5783ca6668..7fea8eeb9e7d 100644
--- a/include/console.h
+++ b/include/console.h
@@ -53,6 +53,8 @@ struct console_device {
 	unsigned int baudrate_param;
 
 	const char *linux_console_name;
+	const char *linux_earlycon_name;
+	void __iomem *phys_base;
 
 	struct cdev devfs;
 	struct cdev_operations fops;
-- 
2.30.2


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


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

* [PATCH 2/8] serial: ns16550: add $global.bootm.earlycon fixup support
  2022-05-23  9:25 [PATCH 1/8] console: add new $global.bootm.earlycon parameter Ahmad Fatoum
@ 2022-05-23  9:25 ` Ahmad Fatoum
  2022-05-23  9:25 ` [PATCH 3/8] serial: amba-pl011: " Ahmad Fatoum
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Ahmad Fatoum @ 2022-05-23  9:25 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

There are too many ways to integrate a ns16550. Let barebox compute a
suitable earlycon for each device.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/serial/serial_ns16550.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c
index 464ae1aebc33..b4cea816ada7 100644
--- a/drivers/serial/serial_ns16550.c
+++ b/drivers/serial/serial_ns16550.c
@@ -39,11 +39,13 @@ struct ns16550_priv {
 	unsigned iobase;
 	void (*write_reg)(struct ns16550_priv *, uint8_t val, unsigned offset);
 	uint8_t (*read_reg)(struct ns16550_priv *, unsigned offset);
+	const char *access_type;
 };
 
 struct ns16550_drvdata {
         void (*init_port)(struct console_device *cdev);
         const char *linux_console_name;
+        const char *linux_earlycon_name;
 };
 
 static inline struct ns16550_priv *to_ns16550_priv(struct console_device *cdev)
@@ -323,22 +325,27 @@ static void ns16550_probe_dt(struct device_d *dev, struct ns16550_priv *priv)
 		priv->mmiobase += offset;
 	of_property_read_u32(np, "reg-shift", &priv->plat.shift);
 	of_property_read_u32(np, "reg-io-width", &width);
+
 	switch (width) {
 	case 1:
 		priv->read_reg = ns16550_read_reg_mmio_8;
 		priv->write_reg = ns16550_write_reg_mmio_8;
+		priv->access_type = "mmio";
 		break;
 	case 2:
 		priv->read_reg = ns16550_read_reg_mmio_16;
 		priv->write_reg = ns16550_write_reg_mmio_16;
+		priv->access_type = "mmio16";
 		break;
 	case 4:
 		if (of_device_is_big_endian(np)) {
 			priv->read_reg = ns16550_read_reg_mmio_32be;
 			priv->write_reg = ns16550_write_reg_mmio_32be;
+			priv->access_type = "mmio32be";
 		} else {
 			priv->read_reg = ns16550_read_reg_mmio_32;
 			priv->write_reg = ns16550_write_reg_mmio_32;
+			priv->access_type = "mmio32";
 		}
 		break;
 	default:
@@ -350,30 +357,36 @@ static void ns16550_probe_dt(struct device_d *dev, struct ns16550_priv *priv)
 static struct ns16550_drvdata ns16450_drvdata = {
 	.init_port = ns16450_serial_init_port,
 	.linux_console_name = "ttyS",
+	.linux_earlycon_name = "uart8250",
 };
 
 static struct ns16550_drvdata ns16550_drvdata = {
 	.init_port = ns16550_serial_init_port,
 	.linux_console_name = "ttyS",
+	.linux_earlycon_name = "uart8250",
 };
 
 static __maybe_unused struct ns16550_drvdata omap_drvdata = {
 	.init_port = ns16550_omap_init_port,
 	.linux_console_name = "ttyO",
+	.linux_earlycon_name = "omap8250",
 };
 
 static __maybe_unused struct ns16550_drvdata jz_drvdata = {
 	.init_port = ns16550_jz_init_port,
+	.linux_earlycon_name = "jz4740_uart",
 };
 
 static __maybe_unused struct ns16550_drvdata tegra_drvdata = {
 	.init_port = ns16550_serial_init_port,
 	.linux_console_name = "ttyS",
+	.linux_earlycon_name = "uart8250",
 };
 
 static __maybe_unused struct ns16550_drvdata rpi_drvdata = {
 	.init_port = rpi_init_port,
 	.linux_console_name = "ttyS",
+	.linux_earlycon_name = "bcm2835aux",
 };
 
 static int ns16550_init_iomem(struct device_d *dev, struct ns16550_priv *priv)
@@ -396,14 +409,17 @@ static int ns16550_init_iomem(struct device_d *dev, struct ns16550_priv *priv)
 	case IORESOURCE_MEM_8BIT:
 		priv->read_reg = ns16550_read_reg_mmio_8;
 		priv->write_reg = ns16550_write_reg_mmio_8;
+		priv->access_type = "mmio";
 		break;
 	case IORESOURCE_MEM_16BIT:
 		priv->read_reg = ns16550_read_reg_mmio_16;
 		priv->write_reg = ns16550_write_reg_mmio_16;
+		priv->access_type = "mmio16";
 		break;
 	case IORESOURCE_MEM_32BIT:
 		priv->read_reg = ns16550_read_reg_mmio_32;
 		priv->write_reg = ns16550_write_reg_mmio_32;
+		priv->access_type = "mmio32";
 		break;
 	}
 
@@ -441,6 +457,8 @@ static int ns16550_init_ioport(struct device_d *dev, struct ns16550_priv *priv)
 		break;
 	}
 
+	priv->access_type = "io";
+
 	return 0;
 }
 
@@ -502,6 +520,10 @@ static int ns16550_probe(struct device_d *dev)
 	cdev->setbrg = ns16550_setbaudrate;
 	cdev->flush = ns16550_flush;
 	cdev->linux_console_name = devtype->linux_console_name;
+	cdev->linux_earlycon_name = basprintf("%s,%s", devtype->linux_earlycon_name,
+					      priv->access_type);
+	cdev->phys_base = !strcmp(priv->access_type, "io") ?
+		IOMEM((ulong)priv->iobase) : priv->mmiobase;
 
 	priv->fcrval = FCRVAL;
 
-- 
2.30.2


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


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

* [PATCH 3/8] serial: amba-pl011: add $global.bootm.earlycon fixup support
  2022-05-23  9:25 [PATCH 1/8] console: add new $global.bootm.earlycon parameter Ahmad Fatoum
  2022-05-23  9:25 ` [PATCH 2/8] serial: ns16550: add $global.bootm.earlycon fixup support Ahmad Fatoum
@ 2022-05-23  9:25 ` Ahmad Fatoum
  2022-05-23  9:25 ` [PATCH 4/8] serial: atmel: " Ahmad Fatoum
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Ahmad Fatoum @ 2022-05-23  9:25 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Allow barebox compute a suitable earlycon parameter.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/serial/amba-pl011.c | 2 ++
 drivers/serial/stm-serial.c | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c
index 345c58e27426..b53ff6877b77 100644
--- a/drivers/serial/amba-pl011.c
+++ b/drivers/serial/amba-pl011.c
@@ -202,6 +202,8 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
 	cdev->getc = pl011_getc;
 	cdev->setbrg = pl011_setbaudrate;
 	cdev->linux_console_name = "ttyAMA";
+	cdev->linux_earlycon_name = "pl011";
+	cdev->phys_base = uart->base;
 
 	pl011_init_port(cdev);
 
diff --git a/drivers/serial/stm-serial.c b/drivers/serial/stm-serial.c
index 30aaba94f0ef..b4b2c4cc8f71 100644
--- a/drivers/serial/stm-serial.c
+++ b/drivers/serial/stm-serial.c
@@ -149,12 +149,14 @@ static int stm_serial_probe(struct device_d *dev)
 	cdev->setbrg = stm_serial_setbaudrate;
 	cdev->dev = dev;
 	cdev->linux_console_name = "ttyAMA";
+	cdev->linux_earlycon_name = "pl011";
 
 	dev->priv = priv;
 	iores = dev_request_mem_resource(dev, 0);
 	if (IS_ERR(iores))
 		return PTR_ERR(iores);
 	priv->base = IOMEM(iores->start);
+	cdev->phys_base = priv->base;
 	priv->clk = clk_get(dev, NULL);
 	if (IS_ERR(priv->clk))
 		return PTR_ERR(priv->clk);
-- 
2.30.2


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


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

* [PATCH 4/8] serial: atmel: add $global.bootm.earlycon fixup support
  2022-05-23  9:25 [PATCH 1/8] console: add new $global.bootm.earlycon parameter Ahmad Fatoum
  2022-05-23  9:25 ` [PATCH 2/8] serial: ns16550: add $global.bootm.earlycon fixup support Ahmad Fatoum
  2022-05-23  9:25 ` [PATCH 3/8] serial: amba-pl011: " Ahmad Fatoum
@ 2022-05-23  9:25 ` Ahmad Fatoum
  2022-05-23  9:25 ` [PATCH 5/8] serial: imx: " Ahmad Fatoum
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Ahmad Fatoum @ 2022-05-23  9:25 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Allow barebox compute a suitable earlycon parameter.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/serial/atmel.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/serial/atmel.c b/drivers/serial/atmel.c
index f83835da9ab7..9e20754998e9 100644
--- a/drivers/serial/atmel.c
+++ b/drivers/serial/atmel.c
@@ -427,11 +427,14 @@ static int atmel_serial_probe(struct device_d *dev)
 	cdev->setbrg = atmel_serial_setbaudrate;
 	cdev->set_mode = atmel_serial_set_mode;
 	cdev->linux_console_name = "ttyAT";
+	cdev->linux_earlycon_name = "atmel_serial";
 
 	ret = atmel_serial_init_port(cdev);
 	if (ret)
 		return ret;
 
+	cdev->phys_base = uart->base;
+
 	/* Enable UART */
 
 	console_register(cdev);
-- 
2.30.2


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


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

* [PATCH 5/8] serial: imx: add $global.bootm.earlycon fixup support
  2022-05-23  9:25 [PATCH 1/8] console: add new $global.bootm.earlycon parameter Ahmad Fatoum
                   ` (2 preceding siblings ...)
  2022-05-23  9:25 ` [PATCH 4/8] serial: atmel: " Ahmad Fatoum
@ 2022-05-23  9:25 ` Ahmad Fatoum
  2022-05-23 11:04   ` Sascha Hauer
  2022-05-23  9:25 ` [PATCH 6/8] serial: litex: add linux console/earlycon " Ahmad Fatoum
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 13+ messages in thread
From: Ahmad Fatoum @ 2022-05-23  9:25 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Allow barebox compute a suitable earlycon parameter.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/serial/serial_imx.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/serial/serial_imx.c b/drivers/serial/serial_imx.c
index 6a933c930e9b..cf9c3f02a7ef 100644
--- a/drivers/serial/serial_imx.c
+++ b/drivers/serial/serial_imx.c
@@ -234,6 +234,8 @@ static int imx_serial_probe(struct device_d *dev)
 	cdev->flush = imx_serial_flush;
 	cdev->setbrg = imx_serial_setbaudrate;
 	cdev->linux_console_name = "ttymxc";
+	cdev->linux_earlycon_name = "ec_imx6q";
+	cdev->phys_base = priv->regs;
 	if (dev->device_node) {
 		devname = of_alias_get(dev->device_node);
 		if (devname) {
-- 
2.30.2


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


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

* [PATCH 6/8] serial: litex: add linux console/earlycon fixup support
  2022-05-23  9:25 [PATCH 1/8] console: add new $global.bootm.earlycon parameter Ahmad Fatoum
                   ` (3 preceding siblings ...)
  2022-05-23  9:25 ` [PATCH 5/8] serial: imx: " Ahmad Fatoum
@ 2022-05-23  9:25 ` Ahmad Fatoum
  2022-05-23  9:25 ` [PATCH 7/8] serial: lpuart: add $global.bootm.earlycon " Ahmad Fatoum
  2022-05-23  9:25 ` [PATCH 8/8] video: efi_gop: add $global.bootm.earlycon fixup for framebuffer console Ahmad Fatoum
  6 siblings, 0 replies; 13+ messages in thread
From: Ahmad Fatoum @ 2022-05-23  9:25 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Allow barebox compute a suitable console= and earlycon parameter.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/serial/serial_litex.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/serial/serial_litex.c b/drivers/serial/serial_litex.c
index 3643427ef408..554fee71a3c4 100644
--- a/drivers/serial/serial_litex.c
+++ b/drivers/serial/serial_litex.c
@@ -74,6 +74,9 @@ static int litex_serial_probe(struct device_d *dev)
 	cdev->putc = &litex_serial_putc;
 	cdev->getc = &litex_serial_getc;
 	cdev->setbrg = NULL;
+	cdev->linux_console_name = "ttyLXU";
+	cdev->linux_earlycon_name = "liteuart";
+	cdev->phys_base = IOMEM(iores->start);
 
 	console_register(cdev);
 
-- 
2.30.2


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


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

* [PATCH 7/8] serial: lpuart: add $global.bootm.earlycon fixup support
  2022-05-23  9:25 [PATCH 1/8] console: add new $global.bootm.earlycon parameter Ahmad Fatoum
                   ` (4 preceding siblings ...)
  2022-05-23  9:25 ` [PATCH 6/8] serial: litex: add linux console/earlycon " Ahmad Fatoum
@ 2022-05-23  9:25 ` Ahmad Fatoum
  2022-05-23  9:25 ` [PATCH 8/8] video: efi_gop: add $global.bootm.earlycon fixup for framebuffer console Ahmad Fatoum
  6 siblings, 0 replies; 13+ messages in thread
From: Ahmad Fatoum @ 2022-05-23  9:25 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Allow barebox compute a suitable earlycon parameter.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/serial/serial_lpuart.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/serial/serial_lpuart.c b/drivers/serial/serial_lpuart.c
index b1a5d60b41c3..720018c9acba 100644
--- a/drivers/serial/serial_lpuart.c
+++ b/drivers/serial/serial_lpuart.c
@@ -160,6 +160,8 @@ static int lpuart_serial_probe(struct device_d *dev)
 	}
 
 	cdev->linux_console_name = "ttyLP";
+	cdev->linux_earlycon_name = "lpuart";
+	cdev->phys_base = lpuart->base;
 
 	lpuart_setup(lpuart->base, clk_get_rate(lpuart->clk));
 
-- 
2.30.2


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


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

* [PATCH 8/8] video: efi_gop: add $global.bootm.earlycon fixup for framebuffer console
  2022-05-23  9:25 [PATCH 1/8] console: add new $global.bootm.earlycon parameter Ahmad Fatoum
                   ` (5 preceding siblings ...)
  2022-05-23  9:25 ` [PATCH 7/8] serial: lpuart: add $global.bootm.earlycon " Ahmad Fatoum
@ 2022-05-23  9:25 ` Ahmad Fatoum
  6 siblings, 0 replies; 13+ messages in thread
From: Ahmad Fatoum @ 2022-05-23  9:25 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/video/efi_gop.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/video/efi_gop.c b/drivers/video/efi_gop.c
index 52387f30dcd0..5e9bc406e1b6 100644
--- a/drivers/video/efi_gop.c
+++ b/drivers/video/efi_gop.c
@@ -238,11 +238,23 @@ static int efi_gop_probe(struct efi_device *efidev)
 	priv->fb.current_mode = priv->mode;
 
 	ret = register_framebuffer(&priv->fb);
-	if (!ret) {
-		priv->dev->priv = &priv->fb;
-		return 0;
+	if (ret)
+		goto free_modes;
+
+	priv->dev->priv = &priv->fb;
+
+	if (IS_ENABLED(CONFIG_FRAMEBUFFER_CONSOLE)) {
+		struct console_device *cdev;
+
+		cdev = console_get_by_dev(&priv->fb.dev);
+		if (cdev)
+			dev_add_param_fixed(&cdev->class_dev, "linux.bootargs.earlycon",
+					    "earlycon=efifb");
 	}
 
+	return 0;
+
+free_modes:
 	if (priv->fb.modes.modes) {
 		int i;
 
-- 
2.30.2


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


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

* Re: [PATCH 5/8] serial: imx: add $global.bootm.earlycon fixup support
  2022-05-23  9:25 ` [PATCH 5/8] serial: imx: " Ahmad Fatoum
@ 2022-05-23 11:04   ` Sascha Hauer
  2022-05-23 11:10     ` Ahmad Fatoum
  0 siblings, 1 reply; 13+ messages in thread
From: Sascha Hauer @ 2022-05-23 11:04 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Mon, May 23, 2022 at 11:25:23AM +0200, Ahmad Fatoum wrote:
> Allow barebox compute a suitable earlycon parameter.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  drivers/serial/serial_imx.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/serial/serial_imx.c b/drivers/serial/serial_imx.c
> index 6a933c930e9b..cf9c3f02a7ef 100644
> --- a/drivers/serial/serial_imx.c
> +++ b/drivers/serial/serial_imx.c
> @@ -234,6 +234,8 @@ static int imx_serial_probe(struct device_d *dev)
>  	cdev->flush = imx_serial_flush;
>  	cdev->setbrg = imx_serial_setbaudrate;
>  	cdev->linux_console_name = "ttymxc";
> +	cdev->linux_earlycon_name = "ec_imx6q";

"ec_imx6q" sounds wrong for the older i.MX SoCs. I don't know how
OF_EARLYCON_DECLARE works, but this:

OF_EARLYCON_DECLARE(ec_imx6q, "fsl,imx6q-uart", imx_console_early_setup);
OF_EARLYCON_DECLARE(ec_imx21, "fsl,imx21-uart", imx_console_early_setup);

looks like it matches a device tree compatible entry. For the older SoCs
you should likely use "ec_imx21".

Anyway, plain "earlycon" just works, why the hassle?

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
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] 13+ messages in thread

* Re: [PATCH 5/8] serial: imx: add $global.bootm.earlycon fixup support
  2022-05-23 11:04   ` Sascha Hauer
@ 2022-05-23 11:10     ` Ahmad Fatoum
  2022-05-23 11:25       ` Sascha Hauer
  0 siblings, 1 reply; 13+ messages in thread
From: Ahmad Fatoum @ 2022-05-23 11:10 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Hi,

On 23.05.22 13:04, Sascha Hauer wrote:
> On Mon, May 23, 2022 at 11:25:23AM +0200, Ahmad Fatoum wrote:
>> Allow barebox compute a suitable earlycon parameter.
>>
>> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
>> ---
>>  drivers/serial/serial_imx.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/serial/serial_imx.c b/drivers/serial/serial_imx.c
>> index 6a933c930e9b..cf9c3f02a7ef 100644
>> --- a/drivers/serial/serial_imx.c
>> +++ b/drivers/serial/serial_imx.c
>> @@ -234,6 +234,8 @@ static int imx_serial_probe(struct device_d *dev)
>>  	cdev->flush = imx_serial_flush;
>>  	cdev->setbrg = imx_serial_setbaudrate;
>>  	cdev->linux_console_name = "ttymxc";
>> +	cdev->linux_earlycon_name = "ec_imx6q";
> 
> "ec_imx6q" sounds wrong for the older i.MX SoCs. I don't know how
> OF_EARLYCON_DECLARE works, but this:
> 
> OF_EARLYCON_DECLARE(ec_imx6q, "fsl,imx6q-uart", imx_console_early_setup);
> OF_EARLYCON_DECLARE(ec_imx21, "fsl,imx21-uart", imx_console_early_setup);
> 
> looks like it matches a device tree compatible entry. For the older SoCs
> you should likely use "ec_imx21".

Oh, I can fix this for v2.

> Anyway, plain "earlycon" just works, why the hassle?

Not all boards have a DT with stdout-path or probe from device tree.
I ran into this issue three times now (twice DT-enabled boards, but no
stdout-path, once on x86 with no DT) and figured it would be nifty
if barebox could just optionally generate it.

Cheers,
Ahmad

> 
> Sascha
> 


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
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] 13+ messages in thread

* Re: [PATCH 5/8] serial: imx: add $global.bootm.earlycon fixup support
  2022-05-23 11:10     ` Ahmad Fatoum
@ 2022-05-23 11:25       ` Sascha Hauer
  2022-05-24  7:35         ` Ahmad Fatoum
  0 siblings, 1 reply; 13+ messages in thread
From: Sascha Hauer @ 2022-05-23 11:25 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Mon, May 23, 2022 at 01:10:13PM +0200, Ahmad Fatoum wrote:
> Hi,
> 
> On 23.05.22 13:04, Sascha Hauer wrote:
> > On Mon, May 23, 2022 at 11:25:23AM +0200, Ahmad Fatoum wrote:
> >> Allow barebox compute a suitable earlycon parameter.
> >>
> >> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> >> ---
> >>  drivers/serial/serial_imx.c | 2 ++
> >>  1 file changed, 2 insertions(+)
> >>
> >> diff --git a/drivers/serial/serial_imx.c b/drivers/serial/serial_imx.c
> >> index 6a933c930e9b..cf9c3f02a7ef 100644
> >> --- a/drivers/serial/serial_imx.c
> >> +++ b/drivers/serial/serial_imx.c
> >> @@ -234,6 +234,8 @@ static int imx_serial_probe(struct device_d *dev)
> >>  	cdev->flush = imx_serial_flush;
> >>  	cdev->setbrg = imx_serial_setbaudrate;
> >>  	cdev->linux_console_name = "ttymxc";
> >> +	cdev->linux_earlycon_name = "ec_imx6q";
> > 
> > "ec_imx6q" sounds wrong for the older i.MX SoCs. I don't know how
> > OF_EARLYCON_DECLARE works, but this:
> > 
> > OF_EARLYCON_DECLARE(ec_imx6q, "fsl,imx6q-uart", imx_console_early_setup);
> > OF_EARLYCON_DECLARE(ec_imx21, "fsl,imx21-uart", imx_console_early_setup);
> > 
> > looks like it matches a device tree compatible entry. For the older SoCs
> > you should likely use "ec_imx21".
> 
> Oh, I can fix this for v2.
> 
> > Anyway, plain "earlycon" just works, why the hassle?
> 
> Not all boards have a DT with stdout-path or probe from device tree.
> I ran into this issue three times now (twice DT-enabled boards, but no
> stdout-path, once on x86 with no DT) and figured it would be nifty
> if barebox could just optionally generate it.

Can't we set the stdout-path property in barebox?

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
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] 13+ messages in thread

* Re: [PATCH 5/8] serial: imx: add $global.bootm.earlycon fixup support
  2022-05-23 11:25       ` Sascha Hauer
@ 2022-05-24  7:35         ` Ahmad Fatoum
  2022-06-09  9:25           ` Sascha Hauer
  0 siblings, 1 reply; 13+ messages in thread
From: Ahmad Fatoum @ 2022-05-24  7:35 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 23.05.22 13:25, Sascha Hauer wrote:
> On Mon, May 23, 2022 at 01:10:13PM +0200, Ahmad Fatoum wrote:
>> Hi,
>>
>> On 23.05.22 13:04, Sascha Hauer wrote:
>>> On Mon, May 23, 2022 at 11:25:23AM +0200, Ahmad Fatoum wrote:
>>>> Allow barebox compute a suitable earlycon parameter.
>>>>
>>>> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
>>>> ---
>>>>  drivers/serial/serial_imx.c | 2 ++
>>>>  1 file changed, 2 insertions(+)
>>>>
>>>> diff --git a/drivers/serial/serial_imx.c b/drivers/serial/serial_imx.c
>>>> index 6a933c930e9b..cf9c3f02a7ef 100644
>>>> --- a/drivers/serial/serial_imx.c
>>>> +++ b/drivers/serial/serial_imx.c
>>>> @@ -234,6 +234,8 @@ static int imx_serial_probe(struct device_d *dev)
>>>>  	cdev->flush = imx_serial_flush;
>>>>  	cdev->setbrg = imx_serial_setbaudrate;
>>>>  	cdev->linux_console_name = "ttymxc";
>>>> +	cdev->linux_earlycon_name = "ec_imx6q";
>>>
>>> "ec_imx6q" sounds wrong for the older i.MX SoCs. I don't know how
>>> OF_EARLYCON_DECLARE works, but this:
>>>
>>> OF_EARLYCON_DECLARE(ec_imx6q, "fsl,imx6q-uart", imx_console_early_setup);
>>> OF_EARLYCON_DECLARE(ec_imx21, "fsl,imx21-uart", imx_console_early_setup);
>>>
>>> looks like it matches a device tree compatible entry. For the older SoCs
>>> you should likely use "ec_imx21".
>>
>> Oh, I can fix this for v2.
>>
>>> Anyway, plain "earlycon" just works, why the hassle?
>>
>> Not all boards have a DT with stdout-path or probe from device tree.
>> I ran into this issue three times now (twice DT-enabled boards, but no
>> stdout-path, once on x86 with no DT) and figured it would be nifty
>> if barebox could just optionally generate it.
> 
> Can't we set the stdout-path property in barebox?

We could, but that doesn't help on x86.

> 
> Sascha
> 


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
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] 13+ messages in thread

* Re: [PATCH 5/8] serial: imx: add $global.bootm.earlycon fixup support
  2022-05-24  7:35         ` Ahmad Fatoum
@ 2022-06-09  9:25           ` Sascha Hauer
  0 siblings, 0 replies; 13+ messages in thread
From: Sascha Hauer @ 2022-06-09  9:25 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Tue, May 24, 2022 at 09:35:39AM +0200, Ahmad Fatoum wrote:
> On 23.05.22 13:25, Sascha Hauer wrote:
> > On Mon, May 23, 2022 at 01:10:13PM +0200, Ahmad Fatoum wrote:
> >> Hi,
> >>
> >> On 23.05.22 13:04, Sascha Hauer wrote:
> >>> On Mon, May 23, 2022 at 11:25:23AM +0200, Ahmad Fatoum wrote:
> >>>> Allow barebox compute a suitable earlycon parameter.
> >>>>
> >>>> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> >>>> ---
> >>>>  drivers/serial/serial_imx.c | 2 ++
> >>>>  1 file changed, 2 insertions(+)
> >>>>
> >>>> diff --git a/drivers/serial/serial_imx.c b/drivers/serial/serial_imx.c
> >>>> index 6a933c930e9b..cf9c3f02a7ef 100644
> >>>> --- a/drivers/serial/serial_imx.c
> >>>> +++ b/drivers/serial/serial_imx.c
> >>>> @@ -234,6 +234,8 @@ static int imx_serial_probe(struct device_d *dev)
> >>>>  	cdev->flush = imx_serial_flush;
> >>>>  	cdev->setbrg = imx_serial_setbaudrate;
> >>>>  	cdev->linux_console_name = "ttymxc";
> >>>> +	cdev->linux_earlycon_name = "ec_imx6q";
> >>>
> >>> "ec_imx6q" sounds wrong for the older i.MX SoCs. I don't know how
> >>> OF_EARLYCON_DECLARE works, but this:
> >>>
> >>> OF_EARLYCON_DECLARE(ec_imx6q, "fsl,imx6q-uart", imx_console_early_setup);
> >>> OF_EARLYCON_DECLARE(ec_imx21, "fsl,imx21-uart", imx_console_early_setup);
> >>>
> >>> looks like it matches a device tree compatible entry. For the older SoCs
> >>> you should likely use "ec_imx21".
> >>
> >> Oh, I can fix this for v2.
> >>
> >>> Anyway, plain "earlycon" just works, why the hassle?
> >>
> >> Not all boards have a DT with stdout-path or probe from device tree.
> >> I ran into this issue three times now (twice DT-enabled boards, but no
> >> stdout-path, once on x86 with no DT) and figured it would be nifty
> >> if barebox could just optionally generate it.
> > 
> > Can't we set the stdout-path property in barebox?
> 
> We could, but that doesn't help on x86.

As you made adding of the command line parameter optional with
$global.bootm.earlycon I guess it's ok. Applied, thanks

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
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] 13+ messages in thread

end of thread, other threads:[~2022-06-09  9:27 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-23  9:25 [PATCH 1/8] console: add new $global.bootm.earlycon parameter Ahmad Fatoum
2022-05-23  9:25 ` [PATCH 2/8] serial: ns16550: add $global.bootm.earlycon fixup support Ahmad Fatoum
2022-05-23  9:25 ` [PATCH 3/8] serial: amba-pl011: " Ahmad Fatoum
2022-05-23  9:25 ` [PATCH 4/8] serial: atmel: " Ahmad Fatoum
2022-05-23  9:25 ` [PATCH 5/8] serial: imx: " Ahmad Fatoum
2022-05-23 11:04   ` Sascha Hauer
2022-05-23 11:10     ` Ahmad Fatoum
2022-05-23 11:25       ` Sascha Hauer
2022-05-24  7:35         ` Ahmad Fatoum
2022-06-09  9:25           ` Sascha Hauer
2022-05-23  9:25 ` [PATCH 6/8] serial: litex: add linux console/earlycon " Ahmad Fatoum
2022-05-23  9:25 ` [PATCH 7/8] serial: lpuart: add $global.bootm.earlycon " Ahmad Fatoum
2022-05-23  9:25 ` [PATCH 8/8] video: efi_gop: add $global.bootm.earlycon fixup for framebuffer console Ahmad Fatoum

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