Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1306635

Re: [RFC PATCH] always probe UART HW when options are not specified

From Peter Hurley <peter@hurleysoftware.com>
Newsgroups linux.kernel
Subject Re: [RFC PATCH] always probe UART HW when options are not specified
Date 2016-01-11 21:00 +0100
Message-ID <qPQNb-6Wu-1@gated-at.bofh.it> (permalink)
References (9 earlier) <qIzo5-70P-5@gated-at.bofh.it> <qPMgy-434-29@gated-at.bofh.it> <qPNmh-4Mf-7@gated-at.bofh.it> <qPOV5-5Iz-7@gated-at.bofh.it> <qPQ0O-6AV-21@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 01/11/2016 11:06 AM, Peter Hurley wrote:
> On 01/11/2016 09:56 AM, Sebastian Frias wrote:
>> On 01/11/2016 05:11 PM, Peter Hurley wrote:
>>> On 01/11/2016 07:07 AM, Sebastian Frias wrote:
>>>> On 12/22/2015 06:56 PM, Sebastian Frias wrote:

[...]

>> 2) What would it take to make the "rt2880" work with the 8250
>> earlycon? I mean, it is already pretty much supported in there, what
>> would be missing? (I don't see why it blocks on earlycon_map) And
>> would it be worth doing?
> 
> The rt2880 does not have the same register locations as a 8250.
> The 8250 port driver remaps all register accesses with a LUT.
> 
> Adding support would be trivial.

Please test.

--- >% ---
Subject: [PATCH] serial: 8250: Add Au1x00/RT288x earlycon support

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/tty/serial/8250/8250_early.c | 52 ++++++++++++++++++++++++++++++++++++
 include/uapi/linux/serial_reg.h      | 13 +++++++++
 2 files changed, 65 insertions(+)

diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
index af62131..307fb23 100644
--- a/drivers/tty/serial/8250/8250_early.c
+++ b/drivers/tty/serial/8250/8250_early.c
@@ -145,3 +145,55 @@ EARLYCON_DECLARE(uart8250, early_serial8250_setup);
 EARLYCON_DECLARE(uart, early_serial8250_setup);
 OF_EARLYCON_DECLARE(ns16550, "ns16550", early_serial8250_setup);
 OF_EARLYCON_DECLARE(ns16550a, "ns16550a", early_serial8250_setup);
+
+
+#ifdef CONFIG_SERIAL_8250_RT288X
+
+static void __init rt288x_putc(struct uart_port *port, int c)
+{
+	unsigned int status;
+
+	serial8250_early_out(port, AU1x00_TX, c);
+
+	for (;;) {
+		status = serial8250_early_in(port, AU1x00_LSR);
+		if ((status & BOTH_EMPTY) == BOTH_EMPTY)
+			break;
+		cpu_relax();
+	}
+}
+
+static void __init early_rt288x_write(struct console *console,
+				      const char *s, unsigned int count)
+{
+	struct earlycon_device *device = console->data;
+	struct uart_port *port = &device->port;
+
+	uart_console_write(port, s, count, rt288x_putc);
+}
+
+static int __init early_rt288x_setup(struct earlycon_device *device,
+				     const char *options)
+{
+	struct uart_port *port = &device->port;
+	unsigned int ier;
+
+	if (!(device->port.membase || device->port.iobase))
+		return -ENODEV;
+
+	/* Don't support direct init or any line-setting options */
+	if (device->baud)
+		return -EINVAL;
+
+	/* assume the device was initialized, only mask interrupts */
+	ier = serial8250_early_in(port, AU1x00_IER);
+	serial8250_early_out(port, AU1x00_IER, ier);
+
+	device->con->write = early_rt288x_write;
+	return 0;
+}
+
+EARLYCON_DECLARE(rt288x, early_rt288x_setup);
+OF_EARLYCON_DECLARE(rt288x, "ralink,rt2880-uart", early_rt288x_setup);
+
+#endif /* CONFIG_SERIAL_8250_RT288X */
diff --git a/include/uapi/linux/serial_reg.h b/include/uapi/linux/serial_reg.h
index 1e5ac4e7..4d068ac 100644
--- a/include/uapi/linux/serial_reg.h
+++ b/include/uapi/linux/serial_reg.h
@@ -376,5 +376,18 @@
 #define UART_EXAR_TXTRG		0x0a	/* Tx FIFO trigger level write-only */
 #define UART_EXAR_RXTRG		0x0b	/* Rx FIFO trigger level write-only */
 
+/*
+ * Register offsets for Au1x00/RT288x 8250-workalikes
+ */
+#define AU1x00_RX	0
+#define AU1x00_TX	1
+#define AU1x00_IER	2
+#define AU1x00_IIR	3
+#define AU1x00_FCR	4
+#define AU1x00_LCR	5
+#define AU1x00_MCR	6
+#define AU1x00_LSR	7
+#define AU1x00_MSR	8
+
 #endif /* _LINUX_SERIAL_REG_H */
 
-- 
2.7.0

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [RFC PATCH] always probe UART HW when options are not specified Sebastian Frias <sf84@laposte.net> - 2016-01-11 16:10 +0100
  Re: [RFC PATCH] always probe UART HW when options are not specified Peter Hurley <peter@hurleysoftware.com> - 2016-01-11 17:20 +0100
    Re: [RFC PATCH] always probe UART HW when options are not specified Sebastian Frias <sf84@laposte.net> - 2016-01-11 19:00 +0100
      Re: [RFC PATCH] always probe UART HW when options are not specified Peter Hurley <peter@hurleysoftware.com> - 2016-01-11 20:10 +0100
        Re: [RFC PATCH] always probe UART HW when options are not specified Peter Hurley <peter@hurleysoftware.com> - 2016-01-11 21:00 +0100
          Re: [RFC PATCH] always probe UART HW when options are not specified Peter Hurley <peter@hurleysoftware.com> - 2016-01-11 21:30 +0100
        Re: [RFC PATCH] always probe UART HW when options are not specified Mason <slash.tmp@free.fr> - 2016-01-12 10:40 +0100
          Re: [RFC PATCH] always probe UART HW when options are not specified Sebastian Frias <sf84@laposte.net> - 2016-01-12 15:30 +0100
            Re: [RFC PATCH] always probe UART HW when options are not specified Peter Hurley <peter@hurleysoftware.com> - 2016-01-12 20:50 +0100
              Re: [RFC PATCH] always probe UART HW when options are not specified Mason <slash.tmp@free.fr> - 2016-01-12 23:30 +0100
                Re: [RFC PATCH] always probe UART HW when options are not specified Peter Hurley <peter@hurleysoftware.com> - 2016-01-12 23:50 +0100
              Re: [RFC PATCH] always probe UART HW when options are not specified Sebastian Frias <sf84@laposte.net> - 2016-01-13 12:20 +0100
                Re: [RFC PATCH] always probe UART HW when options are not specified Peter Hurley <peter@hurleysoftware.com> - 2016-01-13 17:40 +0100
        Re: [RFC PATCH] always probe UART HW when options are not specified Sebastian Frias <sf84@laposte.net> - 2016-01-12 15:20 +0100
          Re: [RFC PATCH] always probe UART HW when options are not specified Peter Hurley <peter@hurleysoftware.com> - 2016-01-12 22:20 +0100

csiph-web