mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 2/8] serial: ns16550: add $global.bootm.earlycon fixup support
Date: Mon, 23 May 2022 11:25:20 +0200	[thread overview]
Message-ID: <20220523092526.791716-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20220523092526.791716-1-a.fatoum@pengutronix.de>

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


  reply	other threads:[~2022-05-23 10:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-23  9:25 [PATCH 1/8] console: add new $global.bootm.earlycon parameter Ahmad Fatoum
2022-05-23  9:25 ` Ahmad Fatoum [this message]
2022-05-23  9:25 ` [PATCH 3/8] serial: amba-pl011: add $global.bootm.earlycon fixup support 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220523092526.791716-2-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox