LKML Archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 00/13] Earlycon cleanup
@ 2015-04-08 17:45 Peter Hurley
  2015-04-08 17:45 ` [PATCH v3 01/13] of: earlycon: Fix 'stdout-path' with ':' path terminator Peter Hurley
                   ` (14 more replies)
  0 siblings, 15 replies; 73+ messages in thread
From: Peter Hurley @ 2015-04-08 17:45 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: linux-serial, linux-kernel, Kevin Cernekee, Peter Hurley

Hi Greg, Grant & Rob,

This patch series builds on my earlier "Extensible console matching &
direct earlycon" to add several useful features to earlycon:
* Proper port i/o configuration from DT node with of_serial properties
  (such as reg-io-width, reg-shift and reg-offset)
* Proper console name & index initialization from earlycon name
  (for both command line and DT-defined earlycons)
* Support for DT 'stdout-path' options pass-through to earlycon setup
* Improved log messages for troubleshooting
* Support for multiple OF earlycon declarations so different
  compatible strings can specify the same OF earlycon

* Changes from v1 *

- Rebase on top of device-tree compiler patch submission,
  "libfdt: Add fdt_path_offset_namelen()"
- Fixed x86 build breakage, conditionally compile of_setup_earlycon();
  Note: this should have already been the case since of_setup_earlycon()
  is dead code without CONFIG_OF_EARLY_FLATTREE
- Fixed Geert's suggestion to change the printf specifier for ->mapbase
- Fixed initial console index value for earlycon name without trailing
  numerals

* Changes from v2 *

- All earlycon declarations are now in a single table, with a common
  framework for devicetree and command line earlycons


Requires: 1) "libfdt: Add fdt_path_offset_namelen()" -- now in
	     upstream dtc
	  2) the last patch which adds omap8250 earlycon requires some
	     kind of fixmap support, such as "ARM: early fixmap support
	     for earlycon", which has not yet been accepted upstream.

Regards,

Peter Hurley (13):
  of: earlycon: Fix 'stdout-path' with ':' path terminator
  earlycon: Use common framework for earlycon declarations
  serial: earlycon: Fixup earlycon console name and index
  of: earlycon: Fixup earlycon console name and index
  of: earlycon: Add options string handling
  of: earlycon: of_setup_earlycon() requires CONFIG_OF_EARLY_FLATTREE
  of: earlycon: Initialize port fields from DT properties
  of: earlycon: Move address translation to of_setup_earlycon()
  serial: earlycon: Common log banner for command line and DT
  serial: earlycon: Show the earlycon "driver" in banner
  of: earlycon: Log more helpful message if earlycon not found
  serial: 8250_early: Use port->regshift
  serial: 8250_omap: Add omap8250 earlycon

 drivers/of/fdt.c                     |  28 ++++-----
 drivers/of/fdt_address.c             |  11 +++-
 drivers/tty/serial/8250/8250_early.c |  29 +++++++++-
 drivers/tty/serial/amba-pl011.c      |   1 -
 drivers/tty/serial/arc_uart.c        |   1 -
 drivers/tty/serial/earlycon.c        | 109 ++++++++++++++++++++++++++---------
 drivers/tty/serial/msm_serial.c      |   2 -
 drivers/tty/serial/samsung.c         |   6 --
 drivers/tty/serial/sprd_serial.c     |   2 -
 include/asm-generic/vmlinux.lds.h    |   8 +--
 include/linux/of_fdt.h               |   2 +-
 include/linux/serial_core.h          |  25 ++++----
 12 files changed, 151 insertions(+), 73 deletions(-)

-- 
2.3.5


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

* [PATCH v3 01/13] of: earlycon: Fix 'stdout-path' with ':' path terminator
  2015-04-08 17:45 [PATCH v3 00/13] Earlycon cleanup Peter Hurley
@ 2015-04-08 17:45 ` Peter Hurley
  2015-04-08 21:24   ` Rob Herring
  2015-07-22 10:16   ` Sudeep Holla
  2015-04-08 17:45 ` [PATCH v3 02/13] earlycon: Use common framework for earlycon declarations Peter Hurley
                   ` (13 subsequent siblings)
  14 siblings, 2 replies; 73+ messages in thread
From: Peter Hurley @ 2015-04-08 17:45 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: linux-serial, linux-kernel, Kevin Cernekee, Peter Hurley,
	Leif Lindholm

stdout-path defines ':' as a path terminator and commit 75c28c09af99a
("of: add optional options parameter to of_find_node_by_path()") added
the necessary support to parse paths terminated with ':'.
commit 7914a7c5651a5 ("of: support passing console options with
stdout-path") added options string support to the stdout-path property,
which broke earlycon.

Add the same support to earlycon to process 'stdout-path' properties
which contain an options string.

Requires: "libfdt: Add fdt_path_offset_namelen()"
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/of/fdt.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 3a896c9..7cef9f9 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -765,7 +765,7 @@ extern struct of_device_id __earlycon_of_table[];
 static int __init early_init_dt_scan_chosen_serial(void)
 {
 	int offset;
-	const char *p;
+	const char *p, *q;
 	int l;
 	const struct of_device_id *match = __earlycon_of_table;
 	const void *fdt = initial_boot_params;
@@ -782,8 +782,10 @@ static int __init early_init_dt_scan_chosen_serial(void)
 	if (!p || !l)
 		return -ENOENT;
 
+	q = strchrnul(p, ':');
+
 	/* Get the node specified by stdout-path */
-	offset = fdt_path_offset(fdt, p);
+	offset = fdt_path_offset_namelen(fdt, p, (int)(q - p));
 	if (offset < 0)
 		return -ENODEV;
 
-- 
2.3.5


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

* [PATCH v3 02/13] earlycon: Use common framework for earlycon declarations
  2015-04-08 17:45 [PATCH v3 00/13] Earlycon cleanup Peter Hurley
  2015-04-08 17:45 ` [PATCH v3 01/13] of: earlycon: Fix 'stdout-path' with ':' path terminator Peter Hurley
@ 2015-04-08 17:45 ` Peter Hurley
  2015-04-08 17:45 ` [PATCH v3 03/13] serial: earlycon: Fixup earlycon console name and index Peter Hurley
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2015-04-08 17:45 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: linux-serial, linux-kernel, Kevin Cernekee, Peter Hurley

Use a single common table of struct earlycon_id for both command line
and devicetree. Re-define OF_EARLYCON_DECLARE() macro to instance a
unique earlycon declaration (the declaration is only guaranteed to be
unique within a compilation unit; separate compilation units must still
use unique earlycon names).

The semantics of OF_EARLYCON_DECLARE() is different; it declares an
earlycon which can matched either on the command line or by devicetree.
EARLYCON_DECLARE() is semantically unchanged; it declares an earlycon
which is matched by command line only. Remove redundant instances of
EARLYCON_DECLARE().

This enables all earlycons to properly initialize struct console
with the appropriate name and index, which improves diagnostics and
enables direct earlycon-to-console handoff.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/of/fdt.c                  | 15 ++++++++-------
 drivers/tty/serial/amba-pl011.c   |  1 -
 drivers/tty/serial/arc_uart.c     |  1 -
 drivers/tty/serial/earlycon.c     | 10 +---------
 drivers/tty/serial/msm_serial.c   |  2 --
 drivers/tty/serial/samsung.c      |  6 ------
 drivers/tty/serial/sprd_serial.c  |  2 --
 include/asm-generic/vmlinux.lds.h |  8 +++-----
 include/linux/serial_core.h       | 22 +++++++++++++---------
 9 files changed, 25 insertions(+), 42 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 7cef9f9..0ec1643 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -760,14 +760,13 @@ static inline void early_init_dt_check_for_initrd(unsigned long node)
 #endif /* CONFIG_BLK_DEV_INITRD */
 
 #ifdef CONFIG_SERIAL_EARLYCON
-extern struct of_device_id __earlycon_of_table[];
 
 static int __init early_init_dt_scan_chosen_serial(void)
 {
 	int offset;
 	const char *p, *q;
 	int l;
-	const struct of_device_id *match = __earlycon_of_table;
+	const struct earlycon_id *match;
 	const void *fdt = initial_boot_params;
 
 	offset = fdt_path_offset(fdt, "/chosen");
@@ -789,18 +788,20 @@ static int __init early_init_dt_scan_chosen_serial(void)
 	if (offset < 0)
 		return -ENODEV;
 
-	while (match->compatible[0]) {
+	for (match = __earlycon_table; match < __earlycon_table_end; match++) {
 		unsigned long addr;
-		if (fdt_node_check_compatible(fdt, offset, match->compatible)) {
-			match++;
+
+		if (!match->compatible[0])
+			continue;
+
+		if (fdt_node_check_compatible(fdt, offset, match->compatible))
 			continue;
-		}
 
 		addr = fdt_translate_address(fdt, offset);
 		if (!addr)
 			return -ENXIO;
 
-		of_setup_earlycon(addr, match->data);
+		of_setup_earlycon(addr, match->setup);
 		return 0;
 	}
 	return -ENODEV;
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 5a4e9d5..a73a01f 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -2149,7 +2149,6 @@ static int __init pl011_early_console_setup(struct earlycon_device *device,
 	device->con->write = pl011_early_write;
 	return 0;
 }
-EARLYCON_DECLARE(pl011, pl011_early_console_setup);
 OF_EARLYCON_DECLARE(pl011, "arm,pl011", pl011_early_console_setup);
 
 #else
diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c
index 03ebe40..3a1de5c 100644
--- a/drivers/tty/serial/arc_uart.c
+++ b/drivers/tty/serial/arc_uart.c
@@ -576,7 +576,6 @@ static int __init arc_early_console_setup(struct earlycon_device *dev,
 	dev->con->write = arc_early_serial_write;
 	return 0;
 }
-EARLYCON_DECLARE(arc_uart, arc_early_console_setup);
 OF_EARLYCON_DECLARE(arc_uart, "snps,arc-uart", arc_early_console_setup);
 
 #endif	/* CONFIG_SERIAL_ARC_CONSOLE */
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 5fdc9f3..45c443b 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -19,7 +19,6 @@
 #include <linux/io.h>
 #include <linux/serial_core.h>
 #include <linux/sizes.h>
-#include <linux/mod_devicetable.h>
 
 #ifdef CONFIG_FIX_EARLYCON_MEM
 #include <asm/fixmap.h>
@@ -37,13 +36,6 @@ static struct earlycon_device early_console_dev = {
 	.con = &early_con,
 };
 
-extern struct earlycon_id __earlycon_table[];
-static const struct earlycon_id __earlycon_table_sentinel
-	__used __section(__earlycon_table_end);
-
-static const struct of_device_id __earlycon_of_table_sentinel
-	__used __section(__earlycon_of_table_end);
-
 static void __iomem * __init earlycon_map(unsigned long paddr, size_t size)
 {
 	void __iomem *base;
@@ -155,7 +147,7 @@ int __init setup_earlycon(char *buf)
 	if (early_con.flags & CON_ENABLED)
 		return -EALREADY;
 
-	for (match = __earlycon_table; match->name[0]; match++) {
+	for (match = __earlycon_table; match < __earlycon_table_end; match++) {
 		size_t len = strlen(match->name);
 
 		if (strncmp(buf, match->name, len))
diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
index b73889c..855b56c 100644
--- a/drivers/tty/serial/msm_serial.c
+++ b/drivers/tty/serial/msm_serial.c
@@ -960,7 +960,6 @@ msm_serial_early_console_setup(struct earlycon_device *device, const char *opt)
 	device->con->write = msm_serial_early_write;
 	return 0;
 }
-EARLYCON_DECLARE(msm_serial, msm_serial_early_console_setup);
 OF_EARLYCON_DECLARE(msm_serial, "qcom,msm-uart",
 		    msm_serial_early_console_setup);
 
@@ -982,7 +981,6 @@ msm_serial_early_console_setup_dm(struct earlycon_device *device,
 	device->con->write = msm_serial_early_write_dm;
 	return 0;
 }
-EARLYCON_DECLARE(msm_serial_dm, msm_serial_early_console_setup_dm);
 OF_EARLYCON_DECLARE(msm_serial_dm, "qcom,msm-uartdm",
 		    msm_serial_early_console_setup_dm);
 
diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
index cf08876..091171c 100644
--- a/drivers/tty/serial/samsung.c
+++ b/drivers/tty/serial/samsung.c
@@ -2460,7 +2460,6 @@ static int __init s3c2410_early_console_setup(struct earlycon_device *device,
 }
 OF_EARLYCON_DECLARE(s3c2410, "samsung,s3c2410-uart",
 			s3c2410_early_console_setup);
-EARLYCON_DECLARE(s3c2410, s3c2410_early_console_setup);
 
 /* S3C2412, S3C2440, S3C64xx */
 static struct samsung_early_console_data s3c2440_early_console_data = {
@@ -2479,9 +2478,6 @@ OF_EARLYCON_DECLARE(s3c2440, "samsung,s3c2440-uart",
 			s3c2440_early_console_setup);
 OF_EARLYCON_DECLARE(s3c6400, "samsung,s3c6400-uart",
 			s3c2440_early_console_setup);
-EARLYCON_DECLARE(s3c2412, s3c2440_early_console_setup);
-EARLYCON_DECLARE(s3c2440, s3c2440_early_console_setup);
-EARLYCON_DECLARE(s3c6400, s3c2440_early_console_setup);
 
 /* S5PV210, EXYNOS */
 static struct samsung_early_console_data s5pv210_early_console_data = {
@@ -2498,8 +2494,6 @@ OF_EARLYCON_DECLARE(s5pv210, "samsung,s5pv210-uart",
 			s5pv210_early_console_setup);
 OF_EARLYCON_DECLARE(exynos4210, "samsung,exynos4210-uart",
 			s5pv210_early_console_setup);
-EARLYCON_DECLARE(s5pv210, s5pv210_early_console_setup);
-EARLYCON_DECLARE(exynos4210, s5pv210_early_console_setup);
 #endif
 
 MODULE_ALIAS("platform:samsung-uart");
diff --git a/drivers/tty/serial/sprd_serial.c b/drivers/tty/serial/sprd_serial.c
index 582d272..1e42574 100644
--- a/drivers/tty/serial/sprd_serial.c
+++ b/drivers/tty/serial/sprd_serial.c
@@ -624,8 +624,6 @@ static int __init sprd_early_console_setup(
 	device->con->write = sprd_early_write;
 	return 0;
 }
-
-EARLYCON_DECLARE(sprd_serial, sprd_early_console_setup);
 OF_EARLYCON_DECLARE(sprd_serial, "sprd,sc9836-uart",
 		    sprd_early_console_setup);
 
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 561daf4..e47fc02 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -154,7 +154,7 @@
 #define EARLYCON_TABLE() STRUCT_ALIGN();			\
 			 VMLINUX_SYMBOL(__earlycon_table) = .;	\
 			 *(__earlycon_table)			\
-			 *(__earlycon_table_end)
+			 VMLINUX_SYMBOL(__earlycon_table_end) = .;
 #else
 #define EARLYCON_TABLE()
 #endif
@@ -175,7 +175,6 @@
 #define IOMMU_OF_TABLES()	OF_TABLE(CONFIG_OF_IOMMU, iommu)
 #define RESERVEDMEM_OF_TABLES()	OF_TABLE(CONFIG_OF_RESERVED_MEM, reservedmem)
 #define CPU_METHOD_OF_TABLES()	OF_TABLE(CONFIG_SMP, cpu_method)
-#define EARLYCON_OF_TABLES()	OF_TABLE(CONFIG_SERIAL_EARLYCON, earlycon)
 
 #define KERNEL_DTB()							\
 	STRUCT_ALIGN();							\
@@ -503,6 +502,7 @@
 	FTRACE_EVENTS()							\
 	TRACE_SYSCALLS()						\
 	KPROBE_BLACKLIST()						\
+	EARLYCON_TABLE()						\
 	MEM_DISCARD(init.rodata)					\
 	CLK_OF_TABLES()							\
 	RESERVEDMEM_OF_TABLES()						\
@@ -510,9 +510,7 @@
 	IOMMU_OF_TABLES()						\
 	CPU_METHOD_OF_TABLES()						\
 	KERNEL_DTB()							\
-	IRQCHIP_OF_MATCH_TABLE()					\
-	EARLYCON_TABLE()						\
-	EARLYCON_OF_TABLES()
+	IRQCHIP_OF_MATCH_TABLE()
 
 #define INIT_TEXT							\
 	*(.init.text)							\
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 025dad9..b8367c0 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -341,22 +341,26 @@ struct earlycon_device {
 
 struct earlycon_id {
 	char	name[16];
+	char	compatible[128];
 	int	(*setup)(struct earlycon_device *, const char *options);
 } __aligned(32);
 
+extern const struct earlycon_id __earlycon_table[];
+extern const struct earlycon_id __earlycon_table_end[];
+
+#define OF_EARLYCON_DECLARE(_name, compat, fn)				\
+	static const struct earlycon_id __UNIQUE_ID(__earlycon_##_name)	\
+	     __used __section(__earlycon_table)				\
+		= { .name = __stringify(_name),				\
+		    .compatible = compat,				\
+		    .setup = fn  }
+
+#define EARLYCON_DECLARE(_name, fn)	OF_EARLYCON_DECLARE(_name, "", fn)
+
 extern int setup_earlycon(char *buf);
 extern int of_setup_earlycon(unsigned long addr,
 			     int (*setup)(struct earlycon_device *, const char *));
 
-#define EARLYCON_DECLARE(_name, func)					\
-	static const struct earlycon_id __earlycon_##_name		\
-		__used __section(__earlycon_table)			\
-		 = { .name  = __stringify(_name),			\
-		     .setup = func  }
-
-#define OF_EARLYCON_DECLARE(name, compat, fn)				\
-	_OF_DECLARE(earlycon, name, compat, fn, void *)
-
 struct uart_port *uart_get_console(struct uart_port *ports, int nr,
 				   struct console *c);
 int uart_parse_earlycon(char *p, unsigned char *iotype, unsigned long *addr,
-- 
2.3.5


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

* [PATCH v3 03/13] serial: earlycon: Fixup earlycon console name and index
  2015-04-08 17:45 [PATCH v3 00/13] Earlycon cleanup Peter Hurley
  2015-04-08 17:45 ` [PATCH v3 01/13] of: earlycon: Fix 'stdout-path' with ':' path terminator Peter Hurley
  2015-04-08 17:45 ` [PATCH v3 02/13] earlycon: Use common framework for earlycon declarations Peter Hurley
@ 2015-04-08 17:45 ` Peter Hurley
  2015-04-08 17:45 ` [PATCH v3 04/13] of: " Peter Hurley
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2015-04-08 17:45 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: linux-serial, linux-kernel, Kevin Cernekee, Peter Hurley

Properly initialize the struct console 'name' and 'index' fields for
the registering earlycon. For earlycons w/o trailing numerals, the
index is set to 0; otherwise, the index is set to the value of the
trailing numeral. For example, the 'exynos4210' earlycon name == "exynos"
and index == 4210. Earlycons with embedded numerals will have all
non-trailing numerals as part of the name; for example, the 's3c2412'
earlycon name == "s3c" and index == 2412.

This ackward scheme was initially added for the uart8250 earlycon;
adopt this scheme for the other earlycon "drivers".

Introduce earlycon_init() which performs the string scanning and
initializes the name and index fields; encapsulate the other console
field initializations within.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/tty/serial/earlycon.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 45c443b..1bd822c 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -27,9 +27,9 @@
 #include <asm/serial.h>
 
 static struct console early_con = {
-	.name =		"uart", /* 8250 console switch requires this name */
+	.name =		"uart",		/* fixed up at earlycon registration */
 	.flags =	CON_PRINTBUFFER | CON_BOOT,
-	.index =	-1,
+	.index =	0,
 };
 
 static struct earlycon_device early_console_dev = {
@@ -53,6 +53,25 @@ static void __iomem * __init earlycon_map(unsigned long paddr, size_t size)
 	return base;
 }
 
+static void __init earlycon_init(struct earlycon_device *device,
+				 const char *name)
+{
+	struct console *earlycon = device->con;
+	const char *s;
+	size_t len;
+
+	/* scan backwards from end of string for first non-numeral */
+	for (s = name + strlen(name);
+	     s > name && s[-1] >= '0' && s[-1] <= '9';
+	     s--)
+		;
+	if (*s)
+		earlycon->index = simple_strtoul(s, NULL, 10);
+	len = s - name;
+	strlcpy(earlycon->name, name, min(len + 1, sizeof(earlycon->name)));
+	earlycon->data = &early_console_dev;
+}
+
 static int __init parse_options(struct earlycon_device *device, char *options)
 {
 	struct uart_port *port = &device->port;
@@ -108,7 +127,7 @@ static int __init register_earlycon(char *buf, const struct earlycon_id *match)
 	if (port->mapbase)
 		port->membase = earlycon_map(port->mapbase, 64);
 
-	early_console_dev.con->data = &early_console_dev;
+	earlycon_init(&early_console_dev, match->name);
 	err = match->setup(&early_console_dev, buf);
 	if (err < 0)
 		return err;
-- 
2.3.5


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

* [PATCH v3 04/13] of: earlycon: Fixup earlycon console name and index
  2015-04-08 17:45 [PATCH v3 00/13] Earlycon cleanup Peter Hurley
                   ` (2 preceding siblings ...)
  2015-04-08 17:45 ` [PATCH v3 03/13] serial: earlycon: Fixup earlycon console name and index Peter Hurley
@ 2015-04-08 17:45 ` Peter Hurley
  2015-04-08 17:45 ` [PATCH v3 05/13] of: earlycon: Add options string handling Peter Hurley
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2015-04-08 17:45 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: linux-serial, linux-kernel, Kevin Cernekee, Peter Hurley

Use the console name embedded in the OF earlycon table by the
OF_EARLYCON_DECLARE() macro to initialize the struct console 'name'
and 'index' fields.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/of/fdt.c              | 2 +-
 drivers/tty/serial/earlycon.c | 6 +++---
 include/linux/serial_core.h   | 3 +--
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 0ec1643..89fc70c 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -801,7 +801,7 @@ static int __init early_init_dt_scan_chosen_serial(void)
 		if (!addr)
 			return -ENXIO;
 
-		of_setup_earlycon(addr, match->setup);
+		of_setup_earlycon(addr, match);
 		return 0;
 	}
 	return -ENODEV;
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 1bd822c..1cb2864 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -210,7 +210,7 @@ static int __init param_setup_earlycon(char *buf)
 early_param("earlycon", param_setup_earlycon);
 
 int __init of_setup_earlycon(unsigned long addr,
-			     int (*setup)(struct earlycon_device *, const char *))
+			     const struct earlycon_id *match)
 {
 	int err;
 	struct uart_port *port = &early_console_dev.port;
@@ -220,8 +220,8 @@ int __init of_setup_earlycon(unsigned long addr,
 	port->uartclk = BASE_BAUD * 16;
 	port->membase = earlycon_map(addr, SZ_4K);
 
-	early_console_dev.con->data = &early_console_dev;
-	err = setup(&early_console_dev, NULL);
+	earlycon_init(&early_console_dev, match->name);
+	err = match->setup(&early_console_dev, NULL);
 	if (err < 0)
 		return err;
 	if (!early_console_dev.con->write)
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index b8367c0..63662e8 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -358,8 +358,7 @@ extern const struct earlycon_id __earlycon_table_end[];
 #define EARLYCON_DECLARE(_name, fn)	OF_EARLYCON_DECLARE(_name, "", fn)
 
 extern int setup_earlycon(char *buf);
-extern int of_setup_earlycon(unsigned long addr,
-			     int (*setup)(struct earlycon_device *, const char *));
+extern int of_setup_earlycon(unsigned long addr, const struct earlycon_id *match);
 
 struct uart_port *uart_get_console(struct uart_port *ports, int nr,
 				   struct console *c);
-- 
2.3.5


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

* [PATCH v3 05/13] of: earlycon: Add options string handling
  2015-04-08 17:45 [PATCH v3 00/13] Earlycon cleanup Peter Hurley
                   ` (3 preceding siblings ...)
  2015-04-08 17:45 ` [PATCH v3 04/13] of: " Peter Hurley
@ 2015-04-08 17:45 ` Peter Hurley
  2015-04-08 17:45 ` [PATCH v3 06/13] of: earlycon: of_setup_earlycon() requires CONFIG_OF_EARLY_FLATTREE Peter Hurley
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2015-04-08 17:45 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: linux-serial, linux-kernel, Kevin Cernekee, Peter Hurley

Pass-through any options string in the 'stdout-path' property to the
earlycon "driver" setup.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/of/fdt.c              | 6 ++++--
 drivers/tty/serial/earlycon.c | 9 +++++++--
 include/linux/serial_core.h   | 3 ++-
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 89fc70c..e0b8013 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -764,7 +764,7 @@ static inline void early_init_dt_check_for_initrd(unsigned long node)
 static int __init early_init_dt_scan_chosen_serial(void)
 {
 	int offset;
-	const char *p, *q;
+	const char *p, *q, *options = NULL;
 	int l;
 	const struct earlycon_id *match;
 	const void *fdt = initial_boot_params;
@@ -782,6 +782,8 @@ static int __init early_init_dt_scan_chosen_serial(void)
 		return -ENOENT;
 
 	q = strchrnul(p, ':');
+	if (*q != '\0')
+		options = q + 1;
 
 	/* Get the node specified by stdout-path */
 	offset = fdt_path_offset_namelen(fdt, p, (int)(q - p));
@@ -801,7 +803,7 @@ static int __init early_init_dt_scan_chosen_serial(void)
 		if (!addr)
 			return -ENXIO;
 
-		of_setup_earlycon(addr, match);
+		of_setup_earlycon(addr, match, options);
 		return 0;
 	}
 	return -ENODEV;
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 1cb2864..46f39c9 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -210,7 +210,8 @@ static int __init param_setup_earlycon(char *buf)
 early_param("earlycon", param_setup_earlycon);
 
 int __init of_setup_earlycon(unsigned long addr,
-			     const struct earlycon_id *match)
+			     const struct earlycon_id *match,
+			     const char *options)
 {
 	int err;
 	struct uart_port *port = &early_console_dev.port;
@@ -220,8 +221,12 @@ int __init of_setup_earlycon(unsigned long addr,
 	port->uartclk = BASE_BAUD * 16;
 	port->membase = earlycon_map(addr, SZ_4K);
 
+	if (options) {
+		strlcpy(early_console_dev.options, options,
+			sizeof(early_console_dev.options));
+	}
 	earlycon_init(&early_console_dev, match->name);
-	err = match->setup(&early_console_dev, NULL);
+	err = match->setup(&early_console_dev, options);
 	if (err < 0)
 		return err;
 	if (!early_console_dev.con->write)
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 63662e8..3cc5e42 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -358,7 +358,8 @@ extern const struct earlycon_id __earlycon_table_end[];
 #define EARLYCON_DECLARE(_name, fn)	OF_EARLYCON_DECLARE(_name, "", fn)
 
 extern int setup_earlycon(char *buf);
-extern int of_setup_earlycon(unsigned long addr, const struct earlycon_id *match);
+extern int of_setup_earlycon(unsigned long addr, const struct earlycon_id *match,
+			     const char *options);
 
 struct uart_port *uart_get_console(struct uart_port *ports, int nr,
 				   struct console *c);
-- 
2.3.5


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

* [PATCH v3 06/13] of: earlycon: of_setup_earlycon() requires CONFIG_OF_EARLY_FLATTREE
  2015-04-08 17:45 [PATCH v3 00/13] Earlycon cleanup Peter Hurley
                   ` (4 preceding siblings ...)
  2015-04-08 17:45 ` [PATCH v3 05/13] of: earlycon: Add options string handling Peter Hurley
@ 2015-04-08 17:45 ` Peter Hurley
  2015-04-08 17:45 ` [PATCH v3 07/13] of: earlycon: Initialize port fields from DT properties Peter Hurley
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2015-04-08 17:45 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: linux-serial, linux-kernel, Kevin Cernekee, Peter Hurley

DT earlycon is only supported for CONFIG_OF_EARLY_FLATTREE=y; exclude
of_setup_earlycon() if not defined.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/tty/serial/earlycon.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 46f39c9..96e3ad1 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -209,6 +209,8 @@ static int __init param_setup_earlycon(char *buf)
 }
 early_param("earlycon", param_setup_earlycon);
 
+#ifdef CONFIG_OF_EARLY_FLATTREE
+
 int __init of_setup_earlycon(unsigned long addr,
 			     const struct earlycon_id *match,
 			     const char *options)
@@ -236,3 +238,5 @@ int __init of_setup_earlycon(unsigned long addr,
 	register_console(early_console_dev.con);
 	return 0;
 }
+
+#endif /* CONFIG_OF_EARLY_FLATTREE */
-- 
2.3.5


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

* [PATCH v3 07/13] of: earlycon: Initialize port fields from DT properties
  2015-04-08 17:45 [PATCH v3 00/13] Earlycon cleanup Peter Hurley
                   ` (5 preceding siblings ...)
  2015-04-08 17:45 ` [PATCH v3 06/13] of: earlycon: of_setup_earlycon() requires CONFIG_OF_EARLY_FLATTREE Peter Hurley
@ 2015-04-08 17:45 ` Peter Hurley
  2015-04-08 17:45 ` [PATCH v3 08/13] of: earlycon: Move address translation to of_setup_earlycon() Peter Hurley
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2015-04-08 17:45 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: linux-serial, linux-kernel, Kevin Cernekee, Peter Hurley

Read the optional "reg-offset", "reg-shift" and "reg-io-width" properties
and initialize the respective struct uart_port field if found.

NB: These bindings are common to several drivers and the values merely
indicate the default value; the registering earlycon setup() method can
simply override the values if required.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/of/fdt.c              |  2 +-
 drivers/tty/serial/earlycon.c | 27 +++++++++++++++++++++++++++
 include/linux/serial_core.h   |  1 +
 3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index e0b8013..47d5054 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -803,7 +803,7 @@ static int __init early_init_dt_scan_chosen_serial(void)
 		if (!addr)
 			return -ENXIO;
 
-		of_setup_earlycon(addr, match, options);
+		of_setup_earlycon(addr, match, offset, options);
 		return 0;
 	}
 	return -ENODEV;
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 96e3ad1..b618015 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -20,6 +20,10 @@
 #include <linux/serial_core.h>
 #include <linux/sizes.h>
 
+#ifdef CONFIG_OF_EARLY_FLATTREE
+#include <linux/of_fdt.h>
+#endif
+
 #ifdef CONFIG_FIX_EARLYCON_MEM
 #include <asm/fixmap.h>
 #endif
@@ -213,16 +217,39 @@ early_param("earlycon", param_setup_earlycon);
 
 int __init of_setup_earlycon(unsigned long addr,
 			     const struct earlycon_id *match,
+			     unsigned long node,
 			     const char *options)
 {
 	int err;
 	struct uart_port *port = &early_console_dev.port;
+	const __be32 *val;
 
 	port->iotype = UPIO_MEM;
 	port->mapbase = addr;
 	port->uartclk = BASE_BAUD * 16;
 	port->membase = earlycon_map(addr, SZ_4K);
 
+	val = of_get_flat_dt_prop(node, "reg-offset", NULL);
+	if (val)
+		port->mapbase += be32_to_cpu(*val);
+	val = of_get_flat_dt_prop(node, "reg-shift", NULL);
+	if (val)
+		port->regshift = be32_to_cpu(*val);
+	val = of_get_flat_dt_prop(node, "reg-io-width", NULL);
+	if (val) {
+		switch (be32_to_cpu(*val)) {
+		case 1:
+			port->iotype = UPIO_MEM;
+			break;
+		case 4:
+			port->iotype = UPIO_MEM32;
+			break;
+		default:
+			pr_warn("[%s] unsupported reg-io-width\n", match->name);
+			return -EINVAL;
+		}
+	}
+
 	if (options) {
 		strlcpy(early_console_dev.options, options,
 			sizeof(early_console_dev.options));
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 3cc5e42..fe48f4e 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -359,6 +359,7 @@ extern const struct earlycon_id __earlycon_table_end[];
 
 extern int setup_earlycon(char *buf);
 extern int of_setup_earlycon(unsigned long addr, const struct earlycon_id *match,
+			     unsigned long node,
 			     const char *options);
 
 struct uart_port *uart_get_console(struct uart_port *ports, int nr,
-- 
2.3.5


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

* [PATCH v3 08/13] of: earlycon: Move address translation to of_setup_earlycon()
  2015-04-08 17:45 [PATCH v3 00/13] Earlycon cleanup Peter Hurley
                   ` (6 preceding siblings ...)
  2015-04-08 17:45 ` [PATCH v3 07/13] of: earlycon: Initialize port fields from DT properties Peter Hurley
@ 2015-04-08 17:45 ` Peter Hurley
  2015-04-08 17:45 ` [PATCH v3 09/13] serial: earlycon: Common log banner for command line and DT Peter Hurley
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2015-04-08 17:45 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: linux-serial, linux-kernel, Kevin Cernekee, Peter Hurley

Cleanup the early DT/earlycon separation; remove the 'addr' parameter
from of_setup_earlycon() and get the uart phys addr directly with a
new wrapper function, of_flat_dt_translate_addr(). Limit
fdt_translate_address() to file scope.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/of/fdt.c              |  8 +-------
 drivers/of/fdt_address.c      | 11 ++++++++++-
 drivers/tty/serial/earlycon.c | 11 +++++++----
 include/linux/of_fdt.h        |  2 +-
 include/linux/serial_core.h   |  2 +-
 5 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 47d5054..007c330 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -791,19 +791,13 @@ static int __init early_init_dt_scan_chosen_serial(void)
 		return -ENODEV;
 
 	for (match = __earlycon_table; match < __earlycon_table_end; match++) {
-		unsigned long addr;
-
 		if (!match->compatible[0])
 			continue;
 
 		if (fdt_node_check_compatible(fdt, offset, match->compatible))
 			continue;
 
-		addr = fdt_translate_address(fdt, offset);
-		if (!addr)
-			return -ENXIO;
-
-		of_setup_earlycon(addr, match, offset, options);
+		of_setup_earlycon(match, offset, options);
 		return 0;
 	}
 	return -ENODEV;
diff --git a/drivers/of/fdt_address.c b/drivers/of/fdt_address.c
index 8d3dc6f..dca8f9b 100644
--- a/drivers/of/fdt_address.c
+++ b/drivers/of/fdt_address.c
@@ -161,7 +161,7 @@ static int __init fdt_translate_one(const void *blob, int parent,
  * that can be mapped to a cpu physical address). This is not really specified
  * that way, but this is traditionally the way IBM at least do things
  */
-u64 __init fdt_translate_address(const void *blob, int node_offset)
+static u64 __init fdt_translate_address(const void *blob, int node_offset)
 {
 	int parent, len;
 	const struct of_bus *bus, *pbus;
@@ -239,3 +239,12 @@ u64 __init fdt_translate_address(const void *blob, int node_offset)
  bail:
 	return result;
 }
+
+/**
+ * of_flat_dt_translate_address - translate DT addr into CPU phys addr
+ * @node: node in the flat blob
+ */
+u64 __init of_flat_dt_translate_address(unsigned long node)
+{
+	return fdt_translate_address(initial_boot_params, node);
+}
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index b618015..0d8f187 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -215,8 +215,7 @@ early_param("earlycon", param_setup_earlycon);
 
 #ifdef CONFIG_OF_EARLY_FLATTREE
 
-int __init of_setup_earlycon(unsigned long addr,
-			     const struct earlycon_id *match,
+int __init of_setup_earlycon(const struct earlycon_id *match,
 			     unsigned long node,
 			     const char *options)
 {
@@ -225,9 +224,13 @@ int __init of_setup_earlycon(unsigned long addr,
 	const __be32 *val;
 
 	port->iotype = UPIO_MEM;
-	port->mapbase = addr;
+	port->mapbase = of_flat_dt_translate_address(node);
+	if (!port->mapbase) {
+		pr_warn("[%s] bad address\n", match->name);
+		return -ENXIO;
+	}
 	port->uartclk = BASE_BAUD * 16;
-	port->membase = earlycon_map(addr, SZ_4K);
+	port->membase = earlycon_map(port->mapbase, SZ_4K);
 
 	val = of_get_flat_dt_prop(node, "reg-offset", NULL);
 	if (val)
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
index 0ff360d..d31e6cb 100644
--- a/include/linux/of_fdt.h
+++ b/include/linux/of_fdt.h
@@ -85,7 +85,7 @@ extern void unflatten_device_tree(void);
 extern void unflatten_and_copy_device_tree(void);
 extern void early_init_devtree(void *);
 extern void early_get_first_memblock_info(void *, phys_addr_t *);
-extern u64 fdt_translate_address(const void *blob, int node_offset);
+extern u64 of_flat_dt_translate_address(unsigned long node);
 extern void of_fdt_limit_memory(int limit);
 #else /* CONFIG_OF_FLATTREE */
 static inline void early_init_fdt_scan_reserved_mem(void) {}
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index fe48f4e..16ee372 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -358,7 +358,7 @@ extern const struct earlycon_id __earlycon_table_end[];
 #define EARLYCON_DECLARE(_name, fn)	OF_EARLYCON_DECLARE(_name, "", fn)
 
 extern int setup_earlycon(char *buf);
-extern int of_setup_earlycon(unsigned long addr, const struct earlycon_id *match,
+extern int of_setup_earlycon(const struct earlycon_id *match,
 			     unsigned long node,
 			     const char *options);
 
-- 
2.3.5


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

* [PATCH v3 09/13] serial: earlycon: Common log banner for command line and DT
  2015-04-08 17:45 [PATCH v3 00/13] Earlycon cleanup Peter Hurley
                   ` (7 preceding siblings ...)
  2015-04-08 17:45 ` [PATCH v3 08/13] of: earlycon: Move address translation to of_setup_earlycon() Peter Hurley
@ 2015-04-08 17:45 ` Peter Hurley
  2015-04-08 17:45 ` [PATCH v3 10/13] serial: earlycon: Show the earlycon "driver" in banner Peter Hurley
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2015-04-08 17:45 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: linux-serial, linux-kernel, Kevin Cernekee, Peter Hurley

Refactor the command line earlycon banner into earlycon_init() so
both earlycon startup methods output an info banner.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/tty/serial/earlycon.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 0d8f187..7c61581 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -61,6 +61,7 @@ static void __init earlycon_init(struct earlycon_device *device,
 				 const char *name)
 {
 	struct console *earlycon = device->con;
+	struct uart_port *port = &device->port;
 	const char *s;
 	size_t len;
 
@@ -74,6 +75,16 @@ static void __init earlycon_init(struct earlycon_device *device,
 	len = s - name;
 	strlcpy(earlycon->name, name, min(len + 1, sizeof(earlycon->name)));
 	earlycon->data = &early_console_dev;
+
+	if (port->iotype == UPIO_MEM || port->iotype == UPIO_MEM32)
+		pr_info("Early serial console at MMIO%s 0x%llx (options '%s')\n",
+			(port->iotype == UPIO_MEM32) ? "32" : "",
+			(unsigned long long)port->mapbase,
+			device->options);
+	else
+		pr_info("Early serial console at I/O port 0x%lx (options '%s')\n",
+			port->iobase,
+			device->options);
 }
 
 static int __init parse_options(struct earlycon_device *device, char *options)
@@ -105,16 +116,6 @@ static int __init parse_options(struct earlycon_device *device, char *options)
 		strlcpy(device->options, options, length);
 	}
 
-	if (port->iotype == UPIO_MEM || port->iotype == UPIO_MEM32)
-		pr_info("Early serial console at MMIO%s 0x%llx (options '%s')\n",
-			(port->iotype == UPIO_MEM32) ? "32" : "",
-			(unsigned long long)port->mapbase,
-			device->options);
-	else
-		pr_info("Early serial console at I/O port 0x%lx (options '%s')\n",
-			port->iobase,
-			device->options);
-
 	return 0;
 }
 
-- 
2.3.5


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

* [PATCH v3 10/13] serial: earlycon: Show the earlycon "driver" in banner
  2015-04-08 17:45 [PATCH v3 00/13] Earlycon cleanup Peter Hurley
                   ` (8 preceding siblings ...)
  2015-04-08 17:45 ` [PATCH v3 09/13] serial: earlycon: Common log banner for command line and DT Peter Hurley
@ 2015-04-08 17:45 ` Peter Hurley
  2015-04-08 17:45 ` [PATCH v3 11/13] of: earlycon: Log more helpful message if earlycon not found Peter Hurley
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2015-04-08 17:45 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: linux-serial, linux-kernel, Kevin Cernekee, Peter Hurley

Output the earlycon "driver" from the just-parsed console 'name'
and 'index' fields.

NB: ->mapbase is a resource_size_t so use %pa format specifier
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/tty/serial/earlycon.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 7c61581..9834afc 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -77,12 +77,14 @@ static void __init earlycon_init(struct earlycon_device *device,
 	earlycon->data = &early_console_dev;
 
 	if (port->iotype == UPIO_MEM || port->iotype == UPIO_MEM32)
-		pr_info("Early serial console at MMIO%s 0x%llx (options '%s')\n",
+		pr_info("%s%d at MMIO%s %pa (options '%s')\n",
+			earlycon->name, earlycon->index,
 			(port->iotype == UPIO_MEM32) ? "32" : "",
-			(unsigned long long)port->mapbase,
+			&port->mapbase,
 			device->options);
 	else
-		pr_info("Early serial console at I/O port 0x%lx (options '%s')\n",
+		pr_info("%s%d at I/O port 0x%lx (options '%s')\n",
+			earlycon->name, earlycon->index,
 			port->iobase,
 			device->options);
 }
-- 
2.3.5


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

* [PATCH v3 11/13] of: earlycon: Log more helpful message if earlycon not found
  2015-04-08 17:45 [PATCH v3 00/13] Earlycon cleanup Peter Hurley
                   ` (9 preceding siblings ...)
  2015-04-08 17:45 ` [PATCH v3 10/13] serial: earlycon: Show the earlycon "driver" in banner Peter Hurley
@ 2015-04-08 17:45 ` Peter Hurley
  2015-04-08 17:45 ` [PATCH v3 12/13] serial: 8250_early: Use port->regshift Peter Hurley
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2015-04-08 17:45 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: linux-serial, linux-kernel, Kevin Cernekee, Peter Hurley

Earlycon may fail to initialize for a variety of reasons, most of
which log the default early param message. If the earlycon is
not found, log the OF path which was not found (and suppress the
default early param message).

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/of/fdt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 007c330..f55c77c 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -800,7 +800,8 @@ static int __init early_init_dt_scan_chosen_serial(void)
 		of_setup_earlycon(match, offset, options);
 		return 0;
 	}
-	return -ENODEV;
+	pr_warn("earlycon: %.*s no match\n", (int)(q - p), p);
+	return 0;
 }
 
 static int __init setup_of_earlycon(char *buf)
-- 
2.3.5


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

* [PATCH v3 12/13] serial: 8250_early: Use port->regshift
  2015-04-08 17:45 [PATCH v3 00/13] Earlycon cleanup Peter Hurley
                   ` (10 preceding siblings ...)
  2015-04-08 17:45 ` [PATCH v3 11/13] of: earlycon: Log more helpful message if earlycon not found Peter Hurley
@ 2015-04-08 17:45 ` Peter Hurley
  2015-04-28 11:38   ` Greg Kroah-Hartman
  2015-04-08 17:45 ` [PATCH v3 13/13] serial: 8250_omap: Add omap8250 earlycon Peter Hurley
                   ` (2 subsequent siblings)
  14 siblings, 1 reply; 73+ messages in thread
From: Peter Hurley @ 2015-04-08 17:45 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: linux-serial, linux-kernel, Kevin Cernekee, Peter Hurley

earlycon initializes struct uart_port::regshift to the correct
value for UPIO_MEM32 already. Use the port field rather than
hard-coded value.

This enables broader support for various i/o access methods in
8250 earlycon (eg., omap8250 earlycon).

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/tty/serial/8250/8250_early.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
index 8e11968..1b5aca3 100644
--- a/drivers/tty/serial/8250/8250_early.c
+++ b/drivers/tty/serial/8250/8250_early.c
@@ -37,11 +37,13 @@
 
 unsigned int __weak __init serial8250_early_in(struct uart_port *port, int offset)
 {
+	offset <<= port->regshift;
+
 	switch (port->iotype) {
 	case UPIO_MEM:
 		return readb(port->membase + offset);
 	case UPIO_MEM32:
-		return readl(port->membase + (offset << 2));
+		return readl(port->membase + offset);
 	case UPIO_PORT:
 		return inb(port->iobase + offset);
 	default:
@@ -51,12 +53,14 @@ unsigned int __weak __init serial8250_early_in(struct uart_port *port, int offse
 
 void __weak __init serial8250_early_out(struct uart_port *port, int offset, int value)
 {
+	offset <<= port->regshift;
+
 	switch (port->iotype) {
 	case UPIO_MEM:
 		writeb(value, port->membase + offset);
 		break;
 	case UPIO_MEM32:
-		writel(value, port->membase + (offset << 2));
+		writel(value, port->membase + offset);
 		break;
 	case UPIO_PORT:
 		outb(value, port->iobase + offset);
-- 
2.3.5


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

* [PATCH v3 13/13] serial: 8250_omap: Add omap8250 earlycon
  2015-04-08 17:45 [PATCH v3 00/13] Earlycon cleanup Peter Hurley
                   ` (11 preceding siblings ...)
  2015-04-08 17:45 ` [PATCH v3 12/13] serial: 8250_early: Use port->regshift Peter Hurley
@ 2015-04-08 17:45 ` Peter Hurley
  2015-04-08 18:07 ` [PATCH v3 00/13] Earlycon cleanup Peter Hurley
  2016-01-12 19:41 ` [PATCH v4 00/11] " Peter Hurley
  14 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2015-04-08 17:45 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: linux-serial, linux-kernel, Kevin Cernekee, Peter Hurley

Add DT earlycon for 8250_omap driver. This boot console is included
for kernels built with CONFIG_SERIAL_EARLYCON=y, CONFIG_OF=y,
CONFIG_SERIAL_8250_OMAP=y, and CONFIG_OF_EARLY_FLATTREE=y.

This boot console is enabled with the command line option "earlycon"
(without "=<name>...") when the DT 'stdout-path' property matches a
compatible uart. For example,

/ {
   chosen {
   	stdout-path = "serial0:115200";
   };

   ....

   aliases {
   	serial0 = &uart0;
   };

   ....

   ocp : ocp {
   	uart0 : serial@44e09000 {
	      compatible = "ti,omap3-uart";
	}
   };
};

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/tty/serial/8250/8250_early.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
index 1b5aca3..e5ce06e 100644
--- a/drivers/tty/serial/8250/8250_early.c
+++ b/drivers/tty/serial/8250/8250_early.c
@@ -149,5 +149,26 @@ static int __init early_serial8250_setup(struct earlycon_device *device,
 	device->con->write = early_serial8250_write;
 	return 0;
 }
+
 EARLYCON_DECLARE(uart8250, early_serial8250_setup);
 EARLYCON_DECLARE(uart, early_serial8250_setup);
+
+#ifdef CONFIG_SERIAL_8250_OMAP
+
+static int __init early_omap8250_setup(struct earlycon_device *device,
+					 const char *options)
+{
+	struct uart_port *port = &device->port;
+
+	if (!(device->port.membase || device->port.iobase))
+		return -ENODEV;
+
+	port->regshift = 2;
+	device->con->write = early_serial8250_write;
+	return 0;
+}
+
+OF_EARLYCON_DECLARE(omap8250, "ti,omap2-uart", early_omap8250_setup);
+OF_EARLYCON_DECLARE(omap8250, "ti,omap3-uart", early_omap8250_setup);
+OF_EARLYCON_DECLARE(omap8250, "ti,omap4-uart", early_omap8250_setup);
+#endif
-- 
2.3.5


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

* Re: [PATCH v3 00/13] Earlycon cleanup
  2015-04-08 17:45 [PATCH v3 00/13] Earlycon cleanup Peter Hurley
                   ` (12 preceding siblings ...)
  2015-04-08 17:45 ` [PATCH v3 13/13] serial: 8250_omap: Add omap8250 earlycon Peter Hurley
@ 2015-04-08 18:07 ` Peter Hurley
  2016-01-12 19:41 ` [PATCH v4 00/11] " Peter Hurley
  14 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2015-04-08 18:07 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: linux-serial, linux-kernel, Kevin Cernekee

On 04/08/2015 01:45 PM, Peter Hurley wrote:
> Hi Greg, Grant & Rob,
> 
> This patch series builds on my earlier "Extensible console matching &
> direct earlycon" to add several useful features to earlycon:
> * Proper port i/o configuration from DT node with of_serial properties
>   (such as reg-io-width, reg-shift and reg-offset)
> * Proper console name & index initialization from earlycon name
>   (for both command line and DT-defined earlycons)
> * Support for DT 'stdout-path' options pass-through to earlycon setup
> * Improved log messages for troubleshooting
> * Support for multiple OF earlycon declarations so different
>   compatible strings can specify the same OF earlycon
> 
> * Changes from v1 *
> 
> - Rebase on top of device-tree compiler patch submission,
>   "libfdt: Add fdt_path_offset_namelen()"
> - Fixed x86 build breakage, conditionally compile of_setup_earlycon();
>   Note: this should have already been the case since of_setup_earlycon()
>   is dead code without CONFIG_OF_EARLY_FLATTREE
> - Fixed Geert's suggestion to change the printf specifier for ->mapbase
> - Fixed initial console index value for earlycon name without trailing
>   numerals
> 
> * Changes from v2 *
> 
> - All earlycon declarations are now in a single table, with a common
>   framework for devicetree and command line earlycons
> 
> 
> Requires: 1) "libfdt: Add fdt_path_offset_namelen()" -- now in
> 	     upstream dtc

also requires "earlycon: Fix __earlycon_table stride"


> 	  2) the last patch which adds omap8250 earlycon requires some
> 	     kind of fixmap support, such as "ARM: early fixmap support
> 	     for earlycon", which has not yet been accepted upstream.
> 
> Regards,
> 
> Peter Hurley (13):
>   of: earlycon: Fix 'stdout-path' with ':' path terminator
>   earlycon: Use common framework for earlycon declarations
>   serial: earlycon: Fixup earlycon console name and index
>   of: earlycon: Fixup earlycon console name and index
>   of: earlycon: Add options string handling
>   of: earlycon: of_setup_earlycon() requires CONFIG_OF_EARLY_FLATTREE
>   of: earlycon: Initialize port fields from DT properties
>   of: earlycon: Move address translation to of_setup_earlycon()
>   serial: earlycon: Common log banner for command line and DT
>   serial: earlycon: Show the earlycon "driver" in banner
>   of: earlycon: Log more helpful message if earlycon not found
>   serial: 8250_early: Use port->regshift
>   serial: 8250_omap: Add omap8250 earlycon
> 
>  drivers/of/fdt.c                     |  28 ++++-----
>  drivers/of/fdt_address.c             |  11 +++-
>  drivers/tty/serial/8250/8250_early.c |  29 +++++++++-
>  drivers/tty/serial/amba-pl011.c      |   1 -
>  drivers/tty/serial/arc_uart.c        |   1 -
>  drivers/tty/serial/earlycon.c        | 109 ++++++++++++++++++++++++++---------
>  drivers/tty/serial/msm_serial.c      |   2 -
>  drivers/tty/serial/samsung.c         |   6 --
>  drivers/tty/serial/sprd_serial.c     |   2 -
>  include/asm-generic/vmlinux.lds.h    |   8 +--
>  include/linux/of_fdt.h               |   2 +-
>  include/linux/serial_core.h          |  25 ++++----
>  12 files changed, 151 insertions(+), 73 deletions(-)
> 


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

* Re: [PATCH v3 01/13] of: earlycon: Fix 'stdout-path' with ':' path terminator
  2015-04-08 17:45 ` [PATCH v3 01/13] of: earlycon: Fix 'stdout-path' with ':' path terminator Peter Hurley
@ 2015-04-08 21:24   ` Rob Herring
  2015-04-28 13:07     ` Peter Hurley
  2015-07-22 10:16   ` Sudeep Holla
  1 sibling, 1 reply; 73+ messages in thread
From: Rob Herring @ 2015-04-08 21:24 UTC (permalink / raw)
  To: Peter Hurley
  Cc: Greg Kroah-Hartman, Rob Herring, Grant Likely,
	linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
	Kevin Cernekee, Leif Lindholm

On Wed, Apr 8, 2015 at 12:45 PM, Peter Hurley <peter@hurleysoftware.com> wrote:
> stdout-path defines ':' as a path terminator and commit 75c28c09af99a
> ("of: add optional options parameter to of_find_node_by_path()") added
> the necessary support to parse paths terminated with ':'.
> commit 7914a7c5651a5 ("of: support passing console options with
> stdout-path") added options string support to the stdout-path property,
> which broke earlycon.
>
> Add the same support to earlycon to process 'stdout-path' properties
> which contain an options string.
>
> Requires: "libfdt: Add fdt_path_offset_namelen()"

Since David has applied this, we can cherrypick that commit for the
kernel copy. Ideally, we would do a dtc sync, but it's not going to
happen for 4.1.

Rob

> Cc: Leif Lindholm <leif.lindholm@linaro.org>
> Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
> ---
>  drivers/of/fdt.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index 3a896c9..7cef9f9 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -765,7 +765,7 @@ extern struct of_device_id __earlycon_of_table[];
>  static int __init early_init_dt_scan_chosen_serial(void)
>  {
>         int offset;
> -       const char *p;
> +       const char *p, *q;
>         int l;
>         const struct of_device_id *match = __earlycon_of_table;
>         const void *fdt = initial_boot_params;
> @@ -782,8 +782,10 @@ static int __init early_init_dt_scan_chosen_serial(void)
>         if (!p || !l)
>                 return -ENOENT;
>
> +       q = strchrnul(p, ':');
> +
>         /* Get the node specified by stdout-path */
> -       offset = fdt_path_offset(fdt, p);
> +       offset = fdt_path_offset_namelen(fdt, p, (int)(q - p));
>         if (offset < 0)
>                 return -ENODEV;
>
> --
> 2.3.5
>

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

* Re: [PATCH v3 12/13] serial: 8250_early: Use port->regshift
  2015-04-08 17:45 ` [PATCH v3 12/13] serial: 8250_early: Use port->regshift Peter Hurley
@ 2015-04-28 11:38   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 73+ messages in thread
From: Greg Kroah-Hartman @ 2015-04-28 11:38 UTC (permalink / raw)
  To: Peter Hurley
  Cc: Rob Herring, Grant Likely, linux-serial, linux-kernel,
	Kevin Cernekee

On Wed, Apr 08, 2015 at 01:45:18PM -0400, Peter Hurley wrote:
> earlycon initializes struct uart_port::regshift to the correct
> value for UPIO_MEM32 already. Use the port field rather than
> hard-coded value.
> 
> This enables broader support for various i/o access methods in
> 8250 earlycon (eg., omap8250 earlycon).
> 
> Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
> ---
>  drivers/tty/serial/8250/8250_early.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)

This patch fails to apply to my tty-testing branch.  Can you refresh it
and resend this one, and patch 13/13 so that I can apply them?

thanks,

greg k-h

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

* Re: [PATCH v3 01/13] of: earlycon: Fix 'stdout-path' with ':' path terminator
  2015-04-08 21:24   ` Rob Herring
@ 2015-04-28 13:07     ` Peter Hurley
  2015-04-28 13:28       ` Greg Kroah-Hartman
  0 siblings, 1 reply; 73+ messages in thread
From: Peter Hurley @ 2015-04-28 13:07 UTC (permalink / raw)
  To: Rob Herring, Greg Kroah-Hartman
  Cc: Rob Herring, Grant Likely, linux-serial@vger.kernel.org,
	linux-kernel@vger.kernel.org, Kevin Cernekee, Leif Lindholm

On 04/08/2015 05:24 PM, Rob Herring wrote:
> On Wed, Apr 8, 2015 at 12:45 PM, Peter Hurley <peter@hurleysoftware.com> wrote:
>> stdout-path defines ':' as a path terminator and commit 75c28c09af99a
>> ("of: add optional options parameter to of_find_node_by_path()") added
>> the necessary support to parse paths terminated with ':'.
>> commit 7914a7c5651a5 ("of: support passing console options with
>> stdout-path") added options string support to the stdout-path property,
>> which broke earlycon.
>>
>> Add the same support to earlycon to process 'stdout-path' properties
>> which contain an options string.
>>
>> Requires: "libfdt: Add fdt_path_offset_namelen()"
> 
> Since David has applied this, we can cherrypick that commit for the
> kernel copy. Ideally, we would do a dtc sync, but it's not going to
> happen for 4.1.

Rob,

Greg pulled this series for -next and kbuild robot promptly blew up
because of this missing commit. Are you planning on cherry-picking
"libfdt: Add fdt_path_offset_namelen()"?

Regards,
Peter Hurley

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

* Re: [PATCH v3 01/13] of: earlycon: Fix 'stdout-path' with ':' path terminator
  2015-04-28 13:07     ` Peter Hurley
@ 2015-04-28 13:28       ` Greg Kroah-Hartman
  2015-04-28 13:58         ` Peter Hurley
  0 siblings, 1 reply; 73+ messages in thread
From: Greg Kroah-Hartman @ 2015-04-28 13:28 UTC (permalink / raw)
  To: Peter Hurley
  Cc: Rob Herring, Rob Herring, Grant Likely,
	linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
	Kevin Cernekee, Leif Lindholm

On Tue, Apr 28, 2015 at 09:07:54AM -0400, Peter Hurley wrote:
> On 04/08/2015 05:24 PM, Rob Herring wrote:
> > On Wed, Apr 8, 2015 at 12:45 PM, Peter Hurley <peter@hurleysoftware.com> wrote:
> >> stdout-path defines ':' as a path terminator and commit 75c28c09af99a
> >> ("of: add optional options parameter to of_find_node_by_path()") added
> >> the necessary support to parse paths terminated with ':'.
> >> commit 7914a7c5651a5 ("of: support passing console options with
> >> stdout-path") added options string support to the stdout-path property,
> >> which broke earlycon.
> >>
> >> Add the same support to earlycon to process 'stdout-path' properties
> >> which contain an options string.
> >>
> >> Requires: "libfdt: Add fdt_path_offset_namelen()"
> > 
> > Since David has applied this, we can cherrypick that commit for the
> > kernel copy. Ideally, we would do a dtc sync, but it's not going to
> > happen for 4.1.
> 
> Rob,
> 
> Greg pulled this series for -next and kbuild robot promptly blew up
> because of this missing commit. Are you planning on cherry-picking
> "libfdt: Add fdt_path_offset_namelen()"?

Can I just take that patch so I don't see the build issues in my branch?

thanks,

greg k-h

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

* Re: [PATCH v3 01/13] of: earlycon: Fix 'stdout-path' with ':' path terminator
  2015-04-28 13:28       ` Greg Kroah-Hartman
@ 2015-04-28 13:58         ` Peter Hurley
  2015-04-28 14:02           ` Rob Herring
  0 siblings, 1 reply; 73+ messages in thread
From: Peter Hurley @ 2015-04-28 13:58 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Rob Herring, Rob Herring, Grant Likely,
	linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
	Kevin Cernekee, Leif Lindholm

On 04/28/2015 09:28 AM, Greg Kroah-Hartman wrote:
> On Tue, Apr 28, 2015 at 09:07:54AM -0400, Peter Hurley wrote:
>> On 04/08/2015 05:24 PM, Rob Herring wrote:
>>> On Wed, Apr 8, 2015 at 12:45 PM, Peter Hurley <peter@hurleysoftware.com> wrote:
>>>> stdout-path defines ':' as a path terminator and commit 75c28c09af99a
>>>> ("of: add optional options parameter to of_find_node_by_path()") added
>>>> the necessary support to parse paths terminated with ':'.
>>>> commit 7914a7c5651a5 ("of: support passing console options with
>>>> stdout-path") added options string support to the stdout-path property,
>>>> which broke earlycon.
>>>>
>>>> Add the same support to earlycon to process 'stdout-path' properties
>>>> which contain an options string.
>>>>
>>>> Requires: "libfdt: Add fdt_path_offset_namelen()"
>>>
>>> Since David has applied this, we can cherrypick that commit for the
>>> kernel copy. Ideally, we would do a dtc sync, but it's not going to
>>> happen for 4.1.
>>
>> Rob,
>>
>> Greg pulled this series for -next and kbuild robot promptly blew up
>> because of this missing commit. Are you planning on cherry-picking
>> "libfdt: Add fdt_path_offset_namelen()"?
> 
> Can I just take that patch so I don't see the build issues in my branch?

It's ok with me, fwiw.

However, you should be aware that the patch is for the out-of-tree
devicetree compiler at git://git.kernel.org/pub/scm/utils/dtc/dtc.git,
which is not the same as in-tree compiler.

I could send you an edited patch that applies cleanly to the
in-tree compiler but I don't know how Rob and Grant feel about that.

Regards,
Peter Hurley


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

* Re: [PATCH v3 01/13] of: earlycon: Fix 'stdout-path' with ':' path terminator
  2015-04-28 13:58         ` Peter Hurley
@ 2015-04-28 14:02           ` Rob Herring
  0 siblings, 0 replies; 73+ messages in thread
From: Rob Herring @ 2015-04-28 14:02 UTC (permalink / raw)
  To: Peter Hurley
  Cc: Greg Kroah-Hartman, Rob Herring, Grant Likely,
	linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
	Kevin Cernekee, Leif Lindholm

On Tue, Apr 28, 2015 at 8:58 AM, Peter Hurley <peter@hurleysoftware.com> wrote:
> On 04/28/2015 09:28 AM, Greg Kroah-Hartman wrote:
>> On Tue, Apr 28, 2015 at 09:07:54AM -0400, Peter Hurley wrote:
>>> On 04/08/2015 05:24 PM, Rob Herring wrote:
>>>> On Wed, Apr 8, 2015 at 12:45 PM, Peter Hurley <peter@hurleysoftware.com> wrote:
>>>>> stdout-path defines ':' as a path terminator and commit 75c28c09af99a
>>>>> ("of: add optional options parameter to of_find_node_by_path()") added
>>>>> the necessary support to parse paths terminated with ':'.
>>>>> commit 7914a7c5651a5 ("of: support passing console options with
>>>>> stdout-path") added options string support to the stdout-path property,
>>>>> which broke earlycon.
>>>>>
>>>>> Add the same support to earlycon to process 'stdout-path' properties
>>>>> which contain an options string.
>>>>>
>>>>> Requires: "libfdt: Add fdt_path_offset_namelen()"
>>>>
>>>> Since David has applied this, we can cherrypick that commit for the
>>>> kernel copy. Ideally, we would do a dtc sync, but it's not going to
>>>> happen for 4.1.
>>>
>>> Rob,
>>>
>>> Greg pulled this series for -next and kbuild robot promptly blew up
>>> because of this missing commit. Are you planning on cherry-picking
>>> "libfdt: Add fdt_path_offset_namelen()"?
>>
>> Can I just take that patch so I don't see the build issues in my branch?
>
> It's ok with me, fwiw.
>
> However, you should be aware that the patch is for the out-of-tree
> devicetree compiler at git://git.kernel.org/pub/scm/utils/dtc/dtc.git,
> which is not the same as in-tree compiler.
>
> I could send you an edited patch that applies cleanly to the
> in-tree compiler but I don't know how Rob and Grant feel about that.

That is what I suggested above if it was for 4.1. I would like to get
a full sync of dtc done for 4.2 though. Give me a few days and I'll
try to get that done.

Rob

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

* Re: [PATCH v3 01/13] of: earlycon: Fix 'stdout-path' with ':' path terminator
  2015-04-08 17:45 ` [PATCH v3 01/13] of: earlycon: Fix 'stdout-path' with ':' path terminator Peter Hurley
  2015-04-08 21:24   ` Rob Herring
@ 2015-07-22 10:16   ` Sudeep Holla
  1 sibling, 0 replies; 73+ messages in thread
From: Sudeep Holla @ 2015-07-22 10:16 UTC (permalink / raw)
  To: Peter Hurley
  Cc: Greg Kroah-Hartman, Rob Herring, Grant Likely, linux-serial,
	open list, Kevin Cernekee, Leif Lindholm

On Wed, Apr 8, 2015 at 6:45 PM, Peter Hurley <peter@hurleysoftware.com> wrote:
> stdout-path defines ':' as a path terminator and commit 75c28c09af99a
> ("of: add optional options parameter to of_find_node_by_path()") added
> the necessary support to parse paths terminated with ':'.
> commit 7914a7c5651a5 ("of: support passing console options with
> stdout-path") added options string support to the stdout-path property,
> which broke earlycon.
>
> Add the same support to earlycon to process 'stdout-path' properties
> which contain an options string.
>

Any update on this patch ? Without this earlycon fails to parse stdout-path
with baud separated by ':'

Regards,
sudeep

> Requires: "libfdt: Add fdt_path_offset_namelen()"
> Cc: Leif Lindholm <leif.lindholm@linaro.org>
> Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
> ---
>  drivers/of/fdt.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index 3a896c9..7cef9f9 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -765,7 +765,7 @@ extern struct of_device_id __earlycon_of_table[];
>  static int __init early_init_dt_scan_chosen_serial(void)
>  {
>         int offset;
> -       const char *p;
> +       const char *p, *q;
>         int l;
>         const struct of_device_id *match = __earlycon_of_table;
>         const void *fdt = initial_boot_params;
> @@ -782,8 +782,10 @@ static int __init early_init_dt_scan_chosen_serial(void)
>         if (!p || !l)
>                 return -ENOENT;
>
> +       q = strchrnul(p, ':');
> +
>         /* Get the node specified by stdout-path */
> -       offset = fdt_path_offset(fdt, p);
> +       offset = fdt_path_offset_namelen(fdt, p, (int)(q - p));
>         if (offset < 0)
>                 return -ENODEV;
>
> --
> 2.3.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

* [PATCH v4 00/11] Earlycon cleanup
  2015-04-08 17:45 [PATCH v3 00/13] Earlycon cleanup Peter Hurley
                   ` (13 preceding siblings ...)
  2015-04-08 18:07 ` [PATCH v3 00/13] Earlycon cleanup Peter Hurley
@ 2016-01-12 19:41 ` Peter Hurley
  2016-01-12 19:41   ` [PATCH v4 01/11] earlycon: Use common framework for earlycon declarations Peter Hurley
                     ` (12 more replies)
  14 siblings, 13 replies; 73+ messages in thread
From: Peter Hurley @ 2016-01-12 19:41 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Masahiro Yamada
  Cc: Rob Herring, Grant Likely, linux-serial, linux-kernel,
	Kevin Cernekee, Jon Hunter, Sebastian Frias, Paul Burton,
	Peter Hurley

Hi Greg, Grant & Rob,

This patch series is a rebase of the v3 from April last year.

This patch series builds on my earlier "Extensible console matching &
direct earlycon" to add several useful features to earlycon:
* Proper port i/o configuration from DT node with of_serial properties
  (such as reg-io-width, reg-shift and reg-offset, and endianness)
* Proper console name & index initialization from earlycon name
  (for both command line and DT-defined earlycons)
* Support for DT 'stdout-path' options pass-through to earlycon setup
* Improved log messages for troubleshooting
* Support for multiple OF earlycon declarations so different
  compatible strings can specify the same OF earlycon

* Changes from v3
  - Added 32-bit big-endian support
  - Removed the omap8250 earlycon (will follow later)


Rob has expressed a desire to have the DT parts live in drivers/of/fdt.c
The problem with this approach is two-fold. Firstly, the number of required
parameters quickly becomes ugly (base address, io reg width, io reg offset,
io reg stride, endianness, earlycon name). Secondly, drivers are already
requiring access to alternate DT properties, like clocks, to initialize
earlycons, and this requirement will continue.

Regards,

Peter Hurley (11):
  earlycon: Use common framework for earlycon declarations
  serial: earlycon: Fixup earlycon console name and index
  of: earlycon: Fixup earlycon console name and index
  of: earlycon: Add options string handling
  of: earlycon: Initialize port fields from DT properties
  of: earlycon: Move address translation to of_setup_earlycon()
  serial: earlycon: Common log banner for command line and DT
  serial: earlycon: Show the earlycon "driver" in banner
  serial: 8250_early: Use port->regshift
  of: earlycon: Log more helpful message if stdout-path node not found
  serial: 8250_omap: Add omap8250 earlycon

 drivers/of/fdt.c                     |  32 +++++-----
 drivers/of/fdt_address.c             |  11 +++-
 drivers/tty/serial/8250/8250_early.c |  36 +++++++++--
 drivers/tty/serial/amba-pl011.c      |   1 -
 drivers/tty/serial/arc_uart.c        |   1 -
 drivers/tty/serial/earlycon.c        | 117 ++++++++++++++++++++++++++---------
 drivers/tty/serial/msm_serial.c      |   2 -
 drivers/tty/serial/samsung.c         |   6 --
 drivers/tty/serial/sprd_serial.c     |   2 -
 include/asm-generic/vmlinux.lds.h    |   6 +-
 include/linux/of_fdt.h               |   2 +-
 include/linux/serial_core.h          |  25 +++++---
 12 files changed, 160 insertions(+), 81 deletions(-)

-- 
2.7.0

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

* [PATCH v4 01/11] earlycon: Use common framework for earlycon declarations
  2016-01-12 19:41 ` [PATCH v4 00/11] " Peter Hurley
@ 2016-01-12 19:41   ` Peter Hurley
  2016-01-12 19:41   ` [PATCH v4 02/11] serial: earlycon: Fixup earlycon console name and index Peter Hurley
                     ` (11 subsequent siblings)
  12 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2016-01-12 19:41 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Masahiro Yamada
  Cc: Rob Herring, Grant Likely, linux-serial, linux-kernel,
	Kevin Cernekee, Jon Hunter, Sebastian Frias, Paul Burton,
	Peter Hurley

Use a single common table of struct earlycon_id for both command line
and devicetree. Re-define OF_EARLYCON_DECLARE() macro to instance a
unique earlycon declaration (the declaration is only guaranteed to be
unique within a compilation unit; separate compilation units must still
use unique earlycon names).

The semantics of OF_EARLYCON_DECLARE() is different; it declares an
earlycon which can matched either on the command line or by devicetree.
EARLYCON_DECLARE() is semantically unchanged; it declares an earlycon
which is matched by command line only. Remove redundant instances of
EARLYCON_DECLARE().

This enables all earlycons to properly initialize struct console
with the appropriate name and index, which improves diagnostics and
enables direct earlycon-to-console handoff.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/of/fdt.c                  | 14 +++++++-------
 drivers/tty/serial/amba-pl011.c   |  1 -
 drivers/tty/serial/arc_uart.c     |  1 -
 drivers/tty/serial/earlycon.c     | 10 +---------
 drivers/tty/serial/msm_serial.c   |  2 --
 drivers/tty/serial/samsung.c      |  6 ------
 drivers/tty/serial/sprd_serial.c  |  2 --
 include/asm-generic/vmlinux.lds.h |  6 ++----
 include/linux/serial_core.h       | 22 +++++++++++++---------
 9 files changed, 23 insertions(+), 41 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 655f79d..1686118 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -796,14 +796,13 @@ static inline void early_init_dt_check_for_initrd(unsigned long node)
 #endif /* CONFIG_BLK_DEV_INITRD */
 
 #ifdef CONFIG_SERIAL_EARLYCON
-extern struct of_device_id __earlycon_of_table[];
 
 static int __init early_init_dt_scan_chosen_serial(void)
 {
 	int offset;
 	const char *p;
 	int l;
-	const struct of_device_id *match = __earlycon_of_table;
+	const struct earlycon_id *match;
 	const void *fdt = initial_boot_params;
 
 	offset = fdt_path_offset(fdt, "/chosen");
@@ -826,19 +825,20 @@ static int __init early_init_dt_scan_chosen_serial(void)
 	if (offset < 0)
 		return -ENODEV;
 
-	while (match->compatible[0]) {
+	for (match = __earlycon_table; match < __earlycon_table_end; match++) {
 		u64 addr;
 
-		if (fdt_node_check_compatible(fdt, offset, match->compatible)) {
-			match++;
+		if (!match->compatible[0])
+			continue;
+
+		if (fdt_node_check_compatible(fdt, offset, match->compatible))
 			continue;
-		}
 
 		addr = fdt_translate_address(fdt, offset);
 		if (addr == OF_BAD_ADDR)
 			return -ENXIO;
 
-		of_setup_earlycon(addr, match->data);
+		of_setup_earlycon(addr, match->setup);
 		return 0;
 	}
 	return -ENODEV;
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index c0da0cc..de84602 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -2327,7 +2327,6 @@ static int __init pl011_early_console_setup(struct earlycon_device *device,
 	device->con->write = pl011_early_write;
 	return 0;
 }
-EARLYCON_DECLARE(pl011, pl011_early_console_setup);
 OF_EARLYCON_DECLARE(pl011, "arm,pl011", pl011_early_console_setup);
 
 #else
diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c
index 03ebe40..3a1de5c 100644
--- a/drivers/tty/serial/arc_uart.c
+++ b/drivers/tty/serial/arc_uart.c
@@ -576,7 +576,6 @@ static int __init arc_early_console_setup(struct earlycon_device *dev,
 	dev->con->write = arc_early_serial_write;
 	return 0;
 }
-EARLYCON_DECLARE(arc_uart, arc_early_console_setup);
 OF_EARLYCON_DECLARE(arc_uart, "snps,arc-uart", arc_early_console_setup);
 
 #endif	/* CONFIG_SERIAL_ARC_CONSOLE */
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 54419a2..d50b700 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -19,7 +19,6 @@
 #include <linux/io.h>
 #include <linux/serial_core.h>
 #include <linux/sizes.h>
-#include <linux/mod_devicetable.h>
 
 #ifdef CONFIG_FIX_EARLYCON_MEM
 #include <asm/fixmap.h>
@@ -37,13 +36,6 @@ static struct earlycon_device early_console_dev = {
 	.con = &early_con,
 };
 
-extern struct earlycon_id __earlycon_table[];
-static const struct earlycon_id __earlycon_table_sentinel
-	__used __section(__earlycon_table_end);
-
-static const struct of_device_id __earlycon_of_table_sentinel
-	__used __section(__earlycon_of_table_end);
-
 static void __iomem * __init earlycon_map(unsigned long paddr, size_t size)
 {
 	void __iomem *base;
@@ -166,7 +158,7 @@ int __init setup_earlycon(char *buf)
 	if (early_con.flags & CON_ENABLED)
 		return -EALREADY;
 
-	for (match = __earlycon_table; match->name[0]; match++) {
+	for (match = __earlycon_table; match < __earlycon_table_end; match++) {
 		size_t len = strlen(match->name);
 
 		if (strncmp(buf, match->name, len))
diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
index dcde955..96d3ce8 100644
--- a/drivers/tty/serial/msm_serial.c
+++ b/drivers/tty/serial/msm_serial.c
@@ -1478,7 +1478,6 @@ msm_serial_early_console_setup(struct earlycon_device *device, const char *opt)
 	device->con->write = msm_serial_early_write;
 	return 0;
 }
-EARLYCON_DECLARE(msm_serial, msm_serial_early_console_setup);
 OF_EARLYCON_DECLARE(msm_serial, "qcom,msm-uart",
 		    msm_serial_early_console_setup);
 
@@ -1500,7 +1499,6 @@ msm_serial_early_console_setup_dm(struct earlycon_device *device,
 	device->con->write = msm_serial_early_write_dm;
 	return 0;
 }
-EARLYCON_DECLARE(msm_serial_dm, msm_serial_early_console_setup_dm);
 OF_EARLYCON_DECLARE(msm_serial_dm, "qcom,msm-uartdm",
 		    msm_serial_early_console_setup_dm);
 
diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
index d72cd73..fd9c47f 100644
--- a/drivers/tty/serial/samsung.c
+++ b/drivers/tty/serial/samsung.c
@@ -2451,7 +2451,6 @@ static int __init s3c2410_early_console_setup(struct earlycon_device *device,
 }
 OF_EARLYCON_DECLARE(s3c2410, "samsung,s3c2410-uart",
 			s3c2410_early_console_setup);
-EARLYCON_DECLARE(s3c2410, s3c2410_early_console_setup);
 
 /* S3C2412, S3C2440, S3C64xx */
 static struct samsung_early_console_data s3c2440_early_console_data = {
@@ -2470,9 +2469,6 @@ OF_EARLYCON_DECLARE(s3c2440, "samsung,s3c2440-uart",
 			s3c2440_early_console_setup);
 OF_EARLYCON_DECLARE(s3c6400, "samsung,s3c6400-uart",
 			s3c2440_early_console_setup);
-EARLYCON_DECLARE(s3c2412, s3c2440_early_console_setup);
-EARLYCON_DECLARE(s3c2440, s3c2440_early_console_setup);
-EARLYCON_DECLARE(s3c6400, s3c2440_early_console_setup);
 
 /* S5PV210, EXYNOS */
 static struct samsung_early_console_data s5pv210_early_console_data = {
@@ -2489,8 +2485,6 @@ OF_EARLYCON_DECLARE(s5pv210, "samsung,s5pv210-uart",
 			s5pv210_early_console_setup);
 OF_EARLYCON_DECLARE(exynos4210, "samsung,exynos4210-uart",
 			s5pv210_early_console_setup);
-EARLYCON_DECLARE(s5pv210, s5pv210_early_console_setup);
-EARLYCON_DECLARE(exynos4210, s5pv210_early_console_setup);
 #endif
 
 MODULE_ALIAS("platform:samsung-uart");
diff --git a/drivers/tty/serial/sprd_serial.c b/drivers/tty/serial/sprd_serial.c
index ef26c4a..1897106 100644
--- a/drivers/tty/serial/sprd_serial.c
+++ b/drivers/tty/serial/sprd_serial.c
@@ -624,8 +624,6 @@ static int __init sprd_early_console_setup(
 	device->con->write = sprd_early_write;
 	return 0;
 }
-
-EARLYCON_DECLARE(sprd_serial, sprd_early_console_setup);
 OF_EARLYCON_DECLARE(sprd_serial, "sprd,sc9836-uart",
 		    sprd_early_console_setup);
 
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index c4bd0e2..e9a81a6 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -157,7 +157,7 @@
 #define EARLYCON_TABLE() STRUCT_ALIGN();			\
 			 VMLINUX_SYMBOL(__earlycon_table) = .;	\
 			 *(__earlycon_table)			\
-			 *(__earlycon_table_end)
+			 VMLINUX_SYMBOL(__earlycon_table_end) = .;
 #else
 #define EARLYCON_TABLE()
 #endif
@@ -179,7 +179,6 @@
 #define RESERVEDMEM_OF_TABLES()	OF_TABLE(CONFIG_OF_RESERVED_MEM, reservedmem)
 #define CPU_METHOD_OF_TABLES()	OF_TABLE(CONFIG_SMP, cpu_method)
 #define CPUIDLE_METHOD_OF_TABLES() OF_TABLE(CONFIG_CPU_IDLE, cpuidle_method)
-#define EARLYCON_OF_TABLES()	OF_TABLE(CONFIG_SERIAL_EARLYCON, earlycon)
 
 #ifdef CONFIG_ACPI
 #define ACPI_PROBE_TABLE(name)						\
@@ -526,8 +525,7 @@
 	IRQCHIP_OF_MATCH_TABLE()					\
 	ACPI_PROBE_TABLE(irqchip)					\
 	ACPI_PROBE_TABLE(clksrc)					\
-	EARLYCON_TABLE()						\
-	EARLYCON_OF_TABLES()
+	EARLYCON_TABLE()
 
 #define INIT_TEXT							\
 	*(.init.text)							\
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index e03d6ba..25e0514 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -342,22 +342,26 @@ struct earlycon_device {
 
 struct earlycon_id {
 	char	name[16];
+	char	compatible[128];
 	int	(*setup)(struct earlycon_device *, const char *options);
 } __aligned(32);
 
+extern const struct earlycon_id __earlycon_table[];
+extern const struct earlycon_id __earlycon_table_end[];
+
+#define OF_EARLYCON_DECLARE(_name, compat, fn)				\
+	static const struct earlycon_id __UNIQUE_ID(__earlycon_##_name)	\
+	     __used __section(__earlycon_table)				\
+		= { .name = __stringify(_name),				\
+		    .compatible = compat,				\
+		    .setup = fn  }
+
+#define EARLYCON_DECLARE(_name, fn)	OF_EARLYCON_DECLARE(_name, "", fn)
+
 extern int setup_earlycon(char *buf);
 extern int of_setup_earlycon(unsigned long addr,
 			     int (*setup)(struct earlycon_device *, const char *));
 
-#define EARLYCON_DECLARE(_name, func)					\
-	static const struct earlycon_id __earlycon_##_name		\
-		__used __section(__earlycon_table)			\
-		 = { .name  = __stringify(_name),			\
-		     .setup = func  }
-
-#define OF_EARLYCON_DECLARE(name, compat, fn)				\
-	_OF_DECLARE(earlycon, name, compat, fn, void *)
-
 struct uart_port *uart_get_console(struct uart_port *ports, int nr,
 				   struct console *c);
 int uart_parse_earlycon(char *p, unsigned char *iotype, unsigned long *addr,
-- 
2.7.0

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

* [PATCH v4 02/11] serial: earlycon: Fixup earlycon console name and index
  2016-01-12 19:41 ` [PATCH v4 00/11] " Peter Hurley
  2016-01-12 19:41   ` [PATCH v4 01/11] earlycon: Use common framework for earlycon declarations Peter Hurley
@ 2016-01-12 19:41   ` Peter Hurley
  2016-01-12 19:41   ` [PATCH v4 03/11] of: " Peter Hurley
                     ` (10 subsequent siblings)
  12 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2016-01-12 19:41 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Masahiro Yamada
  Cc: Rob Herring, Grant Likely, linux-serial, linux-kernel,
	Kevin Cernekee, Jon Hunter, Sebastian Frias, Paul Burton,
	Peter Hurley

Properly initialize the struct console 'name' and 'index' fields for
the registering earlycon. For earlycons w/o trailing numerals, the
index is set to 0; otherwise, the index is set to the value of the
trailing numeral. For example, the 'exynos4210' earlycon name == "exynos"
and index == 4210. Earlycons with embedded numerals will have all
non-trailing numerals as part of the name; for example, the 's3c2412'
earlycon name == "s3c" and index == 2412.

This ackward scheme was initially added for the uart8250 earlycon;
adopt this scheme for the other earlycon "drivers".

Introduce earlycon_init() which performs the string scanning and
initializes the name and index fields; encapsulate the other console
field initializations within.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/tty/serial/earlycon.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index d50b700..90b064f 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -27,9 +27,9 @@
 #include <asm/serial.h>
 
 static struct console early_con = {
-	.name =		"uart", /* 8250 console switch requires this name */
+	.name =		"uart",		/* fixed up at earlycon registration */
 	.flags =	CON_PRINTBUFFER | CON_BOOT,
-	.index =	-1,
+	.index =	0,
 };
 
 static struct earlycon_device early_console_dev = {
@@ -53,6 +53,25 @@ static void __iomem * __init earlycon_map(unsigned long paddr, size_t size)
 	return base;
 }
 
+static void __init earlycon_init(struct earlycon_device *device,
+				 const char *name)
+{
+	struct console *earlycon = device->con;
+	const char *s;
+	size_t len;
+
+	/* scan backwards from end of string for first non-numeral */
+	for (s = name + strlen(name);
+	     s > name && s[-1] >= '0' && s[-1] <= '9';
+	     s--)
+		;
+	if (*s)
+		earlycon->index = simple_strtoul(s, NULL, 10);
+	len = s - name;
+	strlcpy(earlycon->name, name, min(len + 1, sizeof(earlycon->name)));
+	earlycon->data = &early_console_dev;
+}
+
 static int __init parse_options(struct earlycon_device *device, char *options)
 {
 	struct uart_port *port = &device->port;
@@ -119,7 +138,7 @@ static int __init register_earlycon(char *buf, const struct earlycon_id *match)
 	if (port->mapbase)
 		port->membase = earlycon_map(port->mapbase, 64);
 
-	early_console_dev.con->data = &early_console_dev;
+	earlycon_init(&early_console_dev, match->name);
 	err = match->setup(&early_console_dev, buf);
 	if (err < 0)
 		return err;
-- 
2.7.0

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

* [PATCH v4 03/11] of: earlycon: Fixup earlycon console name and index
  2016-01-12 19:41 ` [PATCH v4 00/11] " Peter Hurley
  2016-01-12 19:41   ` [PATCH v4 01/11] earlycon: Use common framework for earlycon declarations Peter Hurley
  2016-01-12 19:41   ` [PATCH v4 02/11] serial: earlycon: Fixup earlycon console name and index Peter Hurley
@ 2016-01-12 19:41   ` Peter Hurley
  2016-01-12 19:41   ` [PATCH v4 04/11] of: earlycon: Add options string handling Peter Hurley
                     ` (9 subsequent siblings)
  12 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2016-01-12 19:41 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Masahiro Yamada
  Cc: Rob Herring, Grant Likely, linux-serial, linux-kernel,
	Kevin Cernekee, Jon Hunter, Sebastian Frias, Paul Burton,
	Peter Hurley

Use the console name embedded in the OF earlycon table by the
OF_EARLYCON_DECLARE() macro to initialize the struct console 'name'
and 'index' fields.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/of/fdt.c              | 2 +-
 drivers/tty/serial/earlycon.c | 6 +++---
 include/linux/serial_core.h   | 3 +--
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 1686118..ec14595 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -838,7 +838,7 @@ static int __init early_init_dt_scan_chosen_serial(void)
 		if (addr == OF_BAD_ADDR)
 			return -ENXIO;
 
-		of_setup_earlycon(addr, match->setup);
+		of_setup_earlycon(addr, match);
 		return 0;
 	}
 	return -ENODEV;
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 90b064f..47e54de 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -218,7 +218,7 @@ early_param("earlycon", param_setup_earlycon);
 #ifdef CONFIG_OF_EARLY_FLATTREE
 
 int __init of_setup_earlycon(unsigned long addr,
-			     int (*setup)(struct earlycon_device *, const char *))
+			     const struct earlycon_id *match)
 {
 	int err;
 	struct uart_port *port = &early_console_dev.port;
@@ -229,8 +229,8 @@ int __init of_setup_earlycon(unsigned long addr,
 	port->uartclk = BASE_BAUD * 16;
 	port->membase = earlycon_map(addr, SZ_4K);
 
-	early_console_dev.con->data = &early_console_dev;
-	err = setup(&early_console_dev, NULL);
+	earlycon_init(&early_console_dev, match->name);
+	err = match->setup(&early_console_dev, NULL);
 	if (err < 0)
 		return err;
 	if (!early_console_dev.con->write)
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 25e0514..63fdb55 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -359,8 +359,7 @@ extern const struct earlycon_id __earlycon_table_end[];
 #define EARLYCON_DECLARE(_name, fn)	OF_EARLYCON_DECLARE(_name, "", fn)
 
 extern int setup_earlycon(char *buf);
-extern int of_setup_earlycon(unsigned long addr,
-			     int (*setup)(struct earlycon_device *, const char *));
+extern int of_setup_earlycon(unsigned long addr, const struct earlycon_id *match);
 
 struct uart_port *uart_get_console(struct uart_port *ports, int nr,
 				   struct console *c);
-- 
2.7.0

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

* [PATCH v4 04/11] of: earlycon: Add options string handling
  2016-01-12 19:41 ` [PATCH v4 00/11] " Peter Hurley
                     ` (2 preceding siblings ...)
  2016-01-12 19:41   ` [PATCH v4 03/11] of: " Peter Hurley
@ 2016-01-12 19:41   ` Peter Hurley
  2016-01-12 19:41   ` [PATCH v4 05/11] of: earlycon: Initialize port fields from DT properties Peter Hurley
                     ` (8 subsequent siblings)
  12 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2016-01-12 19:41 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Masahiro Yamada
  Cc: Rob Herring, Grant Likely, linux-serial, linux-kernel,
	Kevin Cernekee, Jon Hunter, Sebastian Frias, Paul Burton,
	Peter Hurley

Pass-through any options string in the 'stdout-path' property to the
earlycon "driver" setup.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/of/fdt.c              | 11 ++++++-----
 drivers/tty/serial/earlycon.c |  9 +++++++--
 include/linux/serial_core.h   |  3 ++-
 3 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index ec14595..cfd3b35 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -800,7 +800,7 @@ static inline void early_init_dt_check_for_initrd(unsigned long node)
 static int __init early_init_dt_scan_chosen_serial(void)
 {
 	int offset;
-	const char *p;
+	const char *p, *q, *options = NULL;
 	int l;
 	const struct earlycon_id *match;
 	const void *fdt = initial_boot_params;
@@ -817,11 +817,12 @@ static int __init early_init_dt_scan_chosen_serial(void)
 	if (!p || !l)
 		return -ENOENT;
 
-	/* Remove console options if present */
-	l = strchrnul(p, ':') - p;
+	q = strchrnul(p, ':');
+	if (*q != '\0')
+		options = q + 1;
 
 	/* Get the node specified by stdout-path */
-	offset = fdt_path_offset_namelen(fdt, p, l);
+	offset = fdt_path_offset_namelen(fdt, p, q - p);
 	if (offset < 0)
 		return -ENODEV;
 
@@ -838,7 +839,7 @@ static int __init early_init_dt_scan_chosen_serial(void)
 		if (addr == OF_BAD_ADDR)
 			return -ENXIO;
 
-		of_setup_earlycon(addr, match);
+		of_setup_earlycon(addr, match, options);
 		return 0;
 	}
 	return -ENODEV;
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 47e54de..7509ee34d 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -218,7 +218,8 @@ early_param("earlycon", param_setup_earlycon);
 #ifdef CONFIG_OF_EARLY_FLATTREE
 
 int __init of_setup_earlycon(unsigned long addr,
-			     const struct earlycon_id *match)
+			     const struct earlycon_id *match,
+			     const char *options)
 {
 	int err;
 	struct uart_port *port = &early_console_dev.port;
@@ -229,8 +230,12 @@ int __init of_setup_earlycon(unsigned long addr,
 	port->uartclk = BASE_BAUD * 16;
 	port->membase = earlycon_map(addr, SZ_4K);
 
+	if (options) {
+		strlcpy(early_console_dev.options, options,
+			sizeof(early_console_dev.options));
+	}
 	earlycon_init(&early_console_dev, match->name);
-	err = match->setup(&early_console_dev, NULL);
+	err = match->setup(&early_console_dev, options);
 	if (err < 0)
 		return err;
 	if (!early_console_dev.con->write)
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 63fdb55..62a4df0 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -359,7 +359,8 @@ extern const struct earlycon_id __earlycon_table_end[];
 #define EARLYCON_DECLARE(_name, fn)	OF_EARLYCON_DECLARE(_name, "", fn)
 
 extern int setup_earlycon(char *buf);
-extern int of_setup_earlycon(unsigned long addr, const struct earlycon_id *match);
+extern int of_setup_earlycon(unsigned long addr, const struct earlycon_id *match,
+			     const char *options);
 
 struct uart_port *uart_get_console(struct uart_port *ports, int nr,
 				   struct console *c);
-- 
2.7.0

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

* [PATCH v4 05/11] of: earlycon: Initialize port fields from DT properties
  2016-01-12 19:41 ` [PATCH v4 00/11] " Peter Hurley
                     ` (3 preceding siblings ...)
  2016-01-12 19:41   ` [PATCH v4 04/11] of: earlycon: Add options string handling Peter Hurley
@ 2016-01-12 19:41   ` Peter Hurley
  2016-01-12 23:49     ` Rob Herring
  2016-01-12 19:41   ` [PATCH v4 06/11] of: earlycon: Move address translation to of_setup_earlycon() Peter Hurley
                     ` (7 subsequent siblings)
  12 siblings, 1 reply; 73+ messages in thread
From: Peter Hurley @ 2016-01-12 19:41 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Masahiro Yamada
  Cc: Rob Herring, Grant Likely, linux-serial, linux-kernel,
	Kevin Cernekee, Jon Hunter, Sebastian Frias, Paul Burton,
	Peter Hurley

Read the optional "reg-offset", "reg-shift", "reg-io-width" and endianness
properties and initialize the respective struct uart_port field if found.

NB: These bindings are common to several drivers and the values merely
indicate the default value; the registering earlycon setup() method can
simply override the values if required.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/of/fdt.c              |  2 +-
 drivers/tty/serial/earlycon.c | 34 ++++++++++++++++++++++++++++++++++
 include/linux/serial_core.h   |  1 +
 3 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index cfd3b35..e8fd54a 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -839,7 +839,7 @@ static int __init early_init_dt_scan_chosen_serial(void)
 		if (addr == OF_BAD_ADDR)
 			return -ENXIO;
 
-		of_setup_earlycon(addr, match, options);
+		of_setup_earlycon(addr, match, offset, options);
 		return 0;
 	}
 	return -ENODEV;
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 7509ee34d..03eac4a 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -20,6 +20,10 @@
 #include <linux/serial_core.h>
 #include <linux/sizes.h>
 
+#ifdef CONFIG_OF_EARLY_FLATTREE
+#include <linux/of_fdt.h>
+#endif
+
 #ifdef CONFIG_FIX_EARLYCON_MEM
 #include <asm/fixmap.h>
 #endif
@@ -219,10 +223,13 @@ early_param("earlycon", param_setup_earlycon);
 
 int __init of_setup_earlycon(unsigned long addr,
 			     const struct earlycon_id *match,
+			     unsigned long node,
 			     const char *options)
 {
 	int err;
 	struct uart_port *port = &early_console_dev.port;
+	const __be32 *val;
+	bool big_endian;
 
 	spin_lock_init(&port->lock);
 	port->iotype = UPIO_MEM;
@@ -230,6 +237,33 @@ int __init of_setup_earlycon(unsigned long addr,
 	port->uartclk = BASE_BAUD * 16;
 	port->membase = earlycon_map(addr, SZ_4K);
 
+	val = of_get_flat_dt_prop(node, "reg-offset", NULL);
+	if (val)
+		port->mapbase += be32_to_cpu(*val);
+	val = of_get_flat_dt_prop(node, "reg-shift", NULL);
+	if (val)
+		port->regshift = be32_to_cpu(*val);
+	big_endian = of_get_flat_dt_prop(node, "big-endian", NULL) != NULL ||
+		(IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) &&
+		 of_get_flat_dt_prop(node, "native-endian", NULL) != NULL);
+	val = of_get_flat_dt_prop(node, "reg-io-width", NULL);
+	if (val) {
+		switch (be32_to_cpu(*val)) {
+		case 1:
+			port->iotype = UPIO_MEM;
+			break;
+		case 2:
+			port->iotype = UPIO_MEM16;
+			break;
+		case 4:
+			port->iotype = (big_endian) ? UPIO_MEM32BE : UPIO_MEM32;
+			break;
+		default:
+			pr_warn("[%s] unsupported reg-io-width\n", match->name);
+			return -EINVAL;
+		}
+	}
+
 	if (options) {
 		strlcpy(early_console_dev.options, options,
 			sizeof(early_console_dev.options));
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 62a4df0..6d1bed8 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -360,6 +360,7 @@ extern const struct earlycon_id __earlycon_table_end[];
 
 extern int setup_earlycon(char *buf);
 extern int of_setup_earlycon(unsigned long addr, const struct earlycon_id *match,
+			     unsigned long node,
 			     const char *options);
 
 struct uart_port *uart_get_console(struct uart_port *ports, int nr,
-- 
2.7.0

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

* [PATCH v4 06/11] of: earlycon: Move address translation to of_setup_earlycon()
  2016-01-12 19:41 ` [PATCH v4 00/11] " Peter Hurley
                     ` (4 preceding siblings ...)
  2016-01-12 19:41   ` [PATCH v4 05/11] of: earlycon: Initialize port fields from DT properties Peter Hurley
@ 2016-01-12 19:41   ` Peter Hurley
  2016-01-12 19:41   ` [PATCH v4 07/11] serial: earlycon: Common log banner for command line and DT Peter Hurley
                     ` (6 subsequent siblings)
  12 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2016-01-12 19:41 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Masahiro Yamada
  Cc: Rob Herring, Grant Likely, linux-serial, linux-kernel,
	Kevin Cernekee, Jon Hunter, Sebastian Frias, Paul Burton,
	Peter Hurley

Cleanup the early DT/earlycon separation; remove the 'addr' parameter
from of_setup_earlycon() and get the uart phys addr directly with a
new wrapper function, of_flat_dt_translate_addr(). Limit
fdt_translate_address() to file scope.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/of/fdt.c              |  8 +-------
 drivers/of/fdt_address.c      | 11 ++++++++++-
 drivers/tty/serial/earlycon.c | 12 +++++++++---
 include/linux/of_fdt.h        |  2 +-
 include/linux/serial_core.h   |  2 +-
 5 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index e8fd54a..918809e 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -827,19 +827,13 @@ static int __init early_init_dt_scan_chosen_serial(void)
 		return -ENODEV;
 
 	for (match = __earlycon_table; match < __earlycon_table_end; match++) {
-		u64 addr;
-
 		if (!match->compatible[0])
 			continue;
 
 		if (fdt_node_check_compatible(fdt, offset, match->compatible))
 			continue;
 
-		addr = fdt_translate_address(fdt, offset);
-		if (addr == OF_BAD_ADDR)
-			return -ENXIO;
-
-		of_setup_earlycon(addr, match, offset, options);
+		of_setup_earlycon(match, offset, options);
 		return 0;
 	}
 	return -ENODEV;
diff --git a/drivers/of/fdt_address.c b/drivers/of/fdt_address.c
index 8d3dc6f..dca8f9b 100644
--- a/drivers/of/fdt_address.c
+++ b/drivers/of/fdt_address.c
@@ -161,7 +161,7 @@ static int __init fdt_translate_one(const void *blob, int parent,
  * that can be mapped to a cpu physical address). This is not really specified
  * that way, but this is traditionally the way IBM at least do things
  */
-u64 __init fdt_translate_address(const void *blob, int node_offset)
+static u64 __init fdt_translate_address(const void *blob, int node_offset)
 {
 	int parent, len;
 	const struct of_bus *bus, *pbus;
@@ -239,3 +239,12 @@ u64 __init fdt_translate_address(const void *blob, int node_offset)
  bail:
 	return result;
 }
+
+/**
+ * of_flat_dt_translate_address - translate DT addr into CPU phys addr
+ * @node: node in the flat blob
+ */
+u64 __init of_flat_dt_translate_address(unsigned long node)
+{
+	return fdt_translate_address(initial_boot_params, node);
+}
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 03eac4a..4182185 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -21,6 +21,7 @@
 #include <linux/sizes.h>
 
 #ifdef CONFIG_OF_EARLY_FLATTREE
+#include <linux/of.h>
 #include <linux/of_fdt.h>
 #endif
 
@@ -221,8 +222,7 @@ early_param("earlycon", param_setup_earlycon);
 
 #ifdef CONFIG_OF_EARLY_FLATTREE
 
-int __init of_setup_earlycon(unsigned long addr,
-			     const struct earlycon_id *match,
+int __init of_setup_earlycon(const struct earlycon_id *match,
 			     unsigned long node,
 			     const char *options)
 {
@@ -230,12 +230,18 @@ int __init of_setup_earlycon(unsigned long addr,
 	struct uart_port *port = &early_console_dev.port;
 	const __be32 *val;
 	bool big_endian;
+	u64 addr;
 
 	spin_lock_init(&port->lock);
 	port->iotype = UPIO_MEM;
+	addr = of_flat_dt_translate_address(node);
+	if (addr == OF_BAD_ADDR) {
+		pr_warn("[%s] bad address\n", match->name);
+		return -ENXIO;
+	}
 	port->mapbase = addr;
 	port->uartclk = BASE_BAUD * 16;
-	port->membase = earlycon_map(addr, SZ_4K);
+	port->membase = earlycon_map(port->mapbase, SZ_4K);
 
 	val = of_get_flat_dt_prop(node, "reg-offset", NULL);
 	if (val)
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
index df9ef38..2fbe868 100644
--- a/include/linux/of_fdt.h
+++ b/include/linux/of_fdt.h
@@ -88,7 +88,7 @@ extern void unflatten_device_tree(void);
 extern void unflatten_and_copy_device_tree(void);
 extern void early_init_devtree(void *);
 extern void early_get_first_memblock_info(void *, phys_addr_t *);
-extern u64 fdt_translate_address(const void *blob, int node_offset);
+extern u64 of_flat_dt_translate_address(unsigned long node);
 extern void of_fdt_limit_memory(int limit);
 #else /* CONFIG_OF_FLATTREE */
 static inline void early_init_fdt_scan_reserved_mem(void) {}
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 6d1bed8..cbfcf38 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -359,7 +359,7 @@ extern const struct earlycon_id __earlycon_table_end[];
 #define EARLYCON_DECLARE(_name, fn)	OF_EARLYCON_DECLARE(_name, "", fn)
 
 extern int setup_earlycon(char *buf);
-extern int of_setup_earlycon(unsigned long addr, const struct earlycon_id *match,
+extern int of_setup_earlycon(const struct earlycon_id *match,
 			     unsigned long node,
 			     const char *options);
 
-- 
2.7.0

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

* [PATCH v4 07/11] serial: earlycon: Common log banner for command line and DT
  2016-01-12 19:41 ` [PATCH v4 00/11] " Peter Hurley
                     ` (5 preceding siblings ...)
  2016-01-12 19:41   ` [PATCH v4 06/11] of: earlycon: Move address translation to of_setup_earlycon() Peter Hurley
@ 2016-01-12 19:41   ` Peter Hurley
  2016-01-12 19:41   ` [PATCH v4 08/11] serial: earlycon: Show the earlycon "driver" in banner Peter Hurley
                     ` (5 subsequent siblings)
  12 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2016-01-12 19:41 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Masahiro Yamada
  Cc: Rob Herring, Grant Likely, linux-serial, linux-kernel,
	Kevin Cernekee, Jon Hunter, Sebastian Frias, Paul Burton,
	Peter Hurley

Refactor the command line earlycon banner into earlycon_init() so
both earlycon startup methods output an info banner.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/tty/serial/earlycon.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 4182185..10a2ae3 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -62,6 +62,7 @@ static void __init earlycon_init(struct earlycon_device *device,
 				 const char *name)
 {
 	struct console *earlycon = device->con;
+	struct uart_port *port = &device->port;
 	const char *s;
 	size_t len;
 
@@ -75,6 +76,19 @@ static void __init earlycon_init(struct earlycon_device *device,
 	len = s - name;
 	strlcpy(earlycon->name, name, min(len + 1, sizeof(earlycon->name)));
 	earlycon->data = &early_console_dev;
+
+	if (port->iotype == UPIO_MEM || port->iotype == UPIO_MEM16 ||
+	    port->iotype == UPIO_MEM32 || port->iotype == UPIO_MEM32BE)
+		pr_info("Early serial console at MMIO%s 0x%llx (options '%s')\n",
+			(port->iotype == UPIO_MEM) ? "" :
+			(port->iotype == UPIO_MEM16) ? "16" :
+			(port->iotype == UPIO_MEM32) ? "32" : "32be",
+			(unsigned long long)port->mapbase,
+			device->options);
+	else
+		pr_info("Early serial console at I/O port 0x%lx (options '%s')\n",
+			port->iobase,
+			device->options);
 }
 
 static int __init parse_options(struct earlycon_device *device, char *options)
@@ -113,19 +127,6 @@ static int __init parse_options(struct earlycon_device *device, char *options)
 		strlcpy(device->options, options, length);
 	}
 
-	if (port->iotype == UPIO_MEM || port->iotype == UPIO_MEM16 ||
-	    port->iotype == UPIO_MEM32 || port->iotype == UPIO_MEM32BE)
-		pr_info("Early serial console at MMIO%s 0x%llx (options '%s')\n",
-			(port->iotype == UPIO_MEM) ? "" :
-			(port->iotype == UPIO_MEM16) ? "16" :
-			(port->iotype == UPIO_MEM32) ? "32" : "32be",
-			(unsigned long long)port->mapbase,
-			device->options);
-	else
-		pr_info("Early serial console at I/O port 0x%lx (options '%s')\n",
-			port->iobase,
-			device->options);
-
 	return 0;
 }
 
-- 
2.7.0

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

* [PATCH v4 08/11] serial: earlycon: Show the earlycon "driver" in banner
  2016-01-12 19:41 ` [PATCH v4 00/11] " Peter Hurley
                     ` (6 preceding siblings ...)
  2016-01-12 19:41   ` [PATCH v4 07/11] serial: earlycon: Common log banner for command line and DT Peter Hurley
@ 2016-01-12 19:41   ` Peter Hurley
  2016-01-12 19:41   ` [PATCH v4 09/11] serial: 8250_early: Use port->regshift Peter Hurley
                     ` (4 subsequent siblings)
  12 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2016-01-12 19:41 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Masahiro Yamada
  Cc: Rob Herring, Grant Likely, linux-serial, linux-kernel,
	Kevin Cernekee, Jon Hunter, Sebastian Frias, Paul Burton,
	Peter Hurley

Output the earlycon "driver" from the just-parsed console 'name'
and 'index' fields.

NB: ->mapbase is a resource_size_t so use %pa format specifier
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/tty/serial/earlycon.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 10a2ae3..0acb60d 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -79,16 +79,16 @@ static void __init earlycon_init(struct earlycon_device *device,
 
 	if (port->iotype == UPIO_MEM || port->iotype == UPIO_MEM16 ||
 	    port->iotype == UPIO_MEM32 || port->iotype == UPIO_MEM32BE)
-		pr_info("Early serial console at MMIO%s 0x%llx (options '%s')\n",
+		pr_info("%s%d at MMIO%s %pa (options '%s')\n",
+			earlycon->name, earlycon->index,
 			(port->iotype == UPIO_MEM) ? "" :
 			(port->iotype == UPIO_MEM16) ? "16" :
 			(port->iotype == UPIO_MEM32) ? "32" : "32be",
-			(unsigned long long)port->mapbase,
-			device->options);
+			&port->mapbase, device->options);
 	else
-		pr_info("Early serial console at I/O port 0x%lx (options '%s')\n",
-			port->iobase,
-			device->options);
+		pr_info("%s%d at I/O port 0x%lx (options '%s')\n",
+			earlycon->name, earlycon->index,
+			port->iobase, device->options);
 }
 
 static int __init parse_options(struct earlycon_device *device, char *options)
-- 
2.7.0

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

* [PATCH v4 09/11] serial: 8250_early: Use port->regshift
  2016-01-12 19:41 ` [PATCH v4 00/11] " Peter Hurley
                     ` (7 preceding siblings ...)
  2016-01-12 19:41   ` [PATCH v4 08/11] serial: earlycon: Show the earlycon "driver" in banner Peter Hurley
@ 2016-01-12 19:41   ` Peter Hurley
  2016-01-12 19:41   ` [PATCH v4 10/11] of: earlycon: Log more helpful message if stdout-path node not found Peter Hurley
                     ` (3 subsequent siblings)
  12 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2016-01-12 19:41 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Masahiro Yamada
  Cc: Rob Herring, Grant Likely, linux-serial, linux-kernel,
	Kevin Cernekee, Jon Hunter, Sebastian Frias, Paul Burton,
	Peter Hurley

earlycon initializes struct uart_port::regshift to the correct
value for UPIO_MEM32 already. Use the port field rather than
hard-coded value.

This enables broader support for various i/o access methods in
8250 earlycon (eg., omap8250 earlycon).

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/tty/serial/8250/8250_early.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
index 307fb23..e7cdc0c 100644
--- a/drivers/tty/serial/8250/8250_early.c
+++ b/drivers/tty/serial/8250/8250_early.c
@@ -39,15 +39,17 @@
 
 static unsigned int __init serial8250_early_in(struct uart_port *port, int offset)
 {
+	offset <<= port->regshift;
+
 	switch (port->iotype) {
 	case UPIO_MEM:
 		return readb(port->membase + offset);
 	case UPIO_MEM16:
-		return readw(port->membase + (offset << 1));
+		return readw(port->membase + offset);
 	case UPIO_MEM32:
-		return readl(port->membase + (offset << 2));
+		return readl(port->membase + offset);
 	case UPIO_MEM32BE:
-		return ioread32be(port->membase + (offset << 2));
+		return ioread32be(port->membase + offset);
 	case UPIO_PORT:
 		return inb(port->iobase + offset);
 	default:
@@ -57,18 +59,20 @@ static unsigned int __init serial8250_early_in(struct uart_port *port, int offse
 
 static void __init serial8250_early_out(struct uart_port *port, int offset, int value)
 {
+	offset <<= port->regshift;
+
 	switch (port->iotype) {
 	case UPIO_MEM:
 		writeb(value, port->membase + offset);
 		break;
 	case UPIO_MEM16:
-		writew(value, port->membase + (offset << 1));
+		writew(value, port->membase + offset);
 		break;
 	case UPIO_MEM32:
-		writel(value, port->membase + (offset << 2));
+		writel(value, port->membase + offset);
 		break;
 	case UPIO_MEM32BE:
-		iowrite32be(value, port->membase + (offset << 2));
+		iowrite32be(value, port->membase + offset);
 		break;
 	case UPIO_PORT:
 		outb(value, port->iobase + offset);
-- 
2.7.0

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

* [PATCH v4 10/11] of: earlycon: Log more helpful message if stdout-path node not found
  2016-01-12 19:41 ` [PATCH v4 00/11] " Peter Hurley
                     ` (8 preceding siblings ...)
  2016-01-12 19:41   ` [PATCH v4 09/11] serial: 8250_early: Use port->regshift Peter Hurley
@ 2016-01-12 19:41   ` Peter Hurley
  2016-01-12 23:38     ` Rob Herring
  2016-01-12 19:41   ` [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon Peter Hurley
                     ` (2 subsequent siblings)
  12 siblings, 1 reply; 73+ messages in thread
From: Peter Hurley @ 2016-01-12 19:41 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Masahiro Yamada
  Cc: Rob Herring, Grant Likely, linux-serial, linux-kernel,
	Kevin Cernekee, Jon Hunter, Sebastian Frias, Paul Burton,
	Peter Hurley

Earlycon may fail to initialize for a variety of reasons, most of
which log the default early param message. If the stdout-path node is
not found, log the path which was not found (and suppress the
default early param message).

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/of/fdt.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 918809e..e2295b2 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -820,11 +820,14 @@ static int __init early_init_dt_scan_chosen_serial(void)
 	q = strchrnul(p, ':');
 	if (*q != '\0')
 		options = q + 1;
+	l = q - p;
 
 	/* Get the node specified by stdout-path */
-	offset = fdt_path_offset_namelen(fdt, p, q - p);
-	if (offset < 0)
-		return -ENODEV;
+	offset = fdt_path_offset_namelen(fdt, p, l);
+	if (offset < 0) {
+		pr_warn("earlycon: stdout-path %.*s not found\n", l, p);
+		return 0;
+	}
 
 	for (match = __earlycon_table; match < __earlycon_table_end; match++) {
 		if (!match->compatible[0])
-- 
2.7.0

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

* [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon
  2016-01-12 19:41 ` [PATCH v4 00/11] " Peter Hurley
                     ` (9 preceding siblings ...)
  2016-01-12 19:41   ` [PATCH v4 10/11] of: earlycon: Log more helpful message if stdout-path node not found Peter Hurley
@ 2016-01-12 19:41   ` Peter Hurley
  2016-01-12 19:51     ` Peter Hurley
  2016-01-12 23:52   ` [PATCH v4 00/11] Earlycon cleanup Rob Herring
  2016-01-16 21:37   ` [PATCH v5 " Peter Hurley
  12 siblings, 1 reply; 73+ messages in thread
From: Peter Hurley @ 2016-01-12 19:41 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Masahiro Yamada
  Cc: Rob Herring, Grant Likely, linux-serial, linux-kernel,
	Kevin Cernekee, Jon Hunter, Sebastian Frias, Paul Burton,
	Peter Hurley

Add DT earlycon for 8250_omap driver. This boot console is included
for kernels built with CONFIG_SERIAL_EARLYCON=y, CONFIG_OF=y,
CONFIG_SERIAL_8250_OMAP=y, and CONFIG_OF_EARLY_FLATTREE=y.

This boot console is enabled with the command line option "earlycon"
(without "=<name>...") when the DT 'stdout-path' property matches a
compatible uart. For example,

/ {
   chosen {
        stdout-path = "serial0:115200";
   };

   ....

   aliases {
        serial0 = &uart0;
   };

   ....

   ocp : ocp {
        uart0 : serial@44e09000 {
             compatible = "ti,omap3-uart";
        }
   };
};

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/tty/serial/8250/8250_early.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
index e7cdc0c..d1f6310 100644
--- a/drivers/tty/serial/8250/8250_early.c
+++ b/drivers/tty/serial/8250/8250_early.c
@@ -201,3 +201,23 @@ EARLYCON_DECLARE(rt288x, early_rt288x_setup);
 OF_EARLYCON_DECLARE(rt288x, "ralink,rt2880-uart", early_rt288x_setup);
 
 #endif /* CONFIG_SERIAL_8250_RT288X */
+
+#ifdef CONFIG_SERIAL_8250_OMAP
+
+static int __init early_omap8250_setup(struct earlycon_device *device,
+				       const char *options)
+{
+	struct uart_port *port = &device->port;
+
+	if (!(device->port.membase || device->port.iobase))
+		return -ENODEV;
+
+	port->regshift = 2;
+	device->con->write = early_serial8250_write;
+	return 0;
+}
+
+OF_EARLYCON_DECLARE(omap8250, "ti,omap2-uart", early_omap8250_setup);
+OF_EARLYCON_DECLARE(omap8250, "ti,omap3-uart", early_omap8250_setup);
+OF_EARLYCON_DECLARE(omap8250, "ti,omap4-uart", early_omap8250_setup);
+#endif
-- 
2.7.0

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

* Re: [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon
  2016-01-12 19:41   ` [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon Peter Hurley
@ 2016-01-12 19:51     ` Peter Hurley
  2016-01-13  9:19       ` Jon Hunter
  0 siblings, 1 reply; 73+ messages in thread
From: Peter Hurley @ 2016-01-12 19:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Masahiro Yamada, Rob Herring, Grant Likely, linux-serial,
	linux-kernel, Kevin Cernekee, Jon Hunter, Sebastian Frias,
	Paul Burton

Wasn't planning on sending this patch just yet, but oh well.

On 01/12/2016 11:41 AM, Peter Hurley wrote:
> Add DT earlycon for 8250_omap driver. This boot console is included
> for kernels built with CONFIG_SERIAL_EARLYCON=y, CONFIG_OF=y,
> CONFIG_SERIAL_8250_OMAP=y, and CONFIG_OF_EARLY_FLATTREE=y.
> 
> This boot console is enabled with the command line option "earlycon"
> (without "=<name>...") when the DT 'stdout-path' property matches a
> compatible uart. For example,
> 
> / {
>    chosen {
>         stdout-path = "serial0:115200";
>    };
> 
>    ....
> 
>    aliases {
>         serial0 = &uart0;
>    };
> 
>    ....
> 
>    ocp : ocp {
>         uart0 : serial@44e09000 {
>              compatible = "ti,omap3-uart";
>         }
>    };
> };
> 
> Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
> ---
>  drivers/tty/serial/8250/8250_early.c | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
> index e7cdc0c..d1f6310 100644
> --- a/drivers/tty/serial/8250/8250_early.c
> +++ b/drivers/tty/serial/8250/8250_early.c
> @@ -201,3 +201,23 @@ EARLYCON_DECLARE(rt288x, early_rt288x_setup);
>  OF_EARLYCON_DECLARE(rt288x, "ralink,rt2880-uart", early_rt288x_setup);
>  
>  #endif /* CONFIG_SERIAL_8250_RT288X */

This patch may not apply because the context is sitting on top of
unsubmitted code. Sorry.

Regards,
Peter Hurley

> +
> +#ifdef CONFIG_SERIAL_8250_OMAP
> +
> +static int __init early_omap8250_setup(struct earlycon_device *device,
> +				       const char *options)
> +{
> +	struct uart_port *port = &device->port;
> +
> +	if (!(device->port.membase || device->port.iobase))
> +		return -ENODEV;
> +
> +	port->regshift = 2;
> +	device->con->write = early_serial8250_write;
> +	return 0;
> +}
> +
> +OF_EARLYCON_DECLARE(omap8250, "ti,omap2-uart", early_omap8250_setup);
> +OF_EARLYCON_DECLARE(omap8250, "ti,omap3-uart", early_omap8250_setup);
> +OF_EARLYCON_DECLARE(omap8250, "ti,omap4-uart", early_omap8250_setup);
> +#endif
> 

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

* Re: [PATCH v4 10/11] of: earlycon: Log more helpful message if stdout-path node not found
  2016-01-12 19:41   ` [PATCH v4 10/11] of: earlycon: Log more helpful message if stdout-path node not found Peter Hurley
@ 2016-01-12 23:38     ` Rob Herring
  0 siblings, 0 replies; 73+ messages in thread
From: Rob Herring @ 2016-01-12 23:38 UTC (permalink / raw)
  To: Peter Hurley
  Cc: Greg Kroah-Hartman, Masahiro Yamada, Grant Likely,
	linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
	Kevin Cernekee, Jon Hunter, Sebastian Frias, Paul Burton

On Tue, Jan 12, 2016 at 1:41 PM, Peter Hurley <peter@hurleysoftware.com> wrote:
> Earlycon may fail to initialize for a variety of reasons, most of
> which log the default early param message. If the stdout-path node is
> not found, log the path which was not found (and suppress the
> default early param message).
>
> Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
> ---
>  drivers/of/fdt.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)

Acked-by: Rob Herring <robh@kernel.org>

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

* Re: [PATCH v4 05/11] of: earlycon: Initialize port fields from DT properties
  2016-01-12 19:41   ` [PATCH v4 05/11] of: earlycon: Initialize port fields from DT properties Peter Hurley
@ 2016-01-12 23:49     ` Rob Herring
  2016-01-13 16:35       ` Peter Hurley
  0 siblings, 1 reply; 73+ messages in thread
From: Rob Herring @ 2016-01-12 23:49 UTC (permalink / raw)
  To: Peter Hurley
  Cc: Greg Kroah-Hartman, Masahiro Yamada, Grant Likely,
	linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
	Kevin Cernekee, Jon Hunter, Sebastian Frias, Paul Burton

On Tue, Jan 12, 2016 at 1:41 PM, Peter Hurley <peter@hurleysoftware.com> wrote:
> Read the optional "reg-offset", "reg-shift", "reg-io-width" and endianness
> properties and initialize the respective struct uart_port field if found.
>
> NB: These bindings are common to several drivers and the values merely
> indicate the default value; the registering earlycon setup() method can
> simply override the values if required.
>
> Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
> ---

> diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
> index 7509ee34d..03eac4a 100644
> --- a/drivers/tty/serial/earlycon.c
> +++ b/drivers/tty/serial/earlycon.c
> @@ -20,6 +20,10 @@
>  #include <linux/serial_core.h>
>  #include <linux/sizes.h>
>
> +#ifdef CONFIG_OF_EARLY_FLATTREE
> +#include <linux/of_fdt.h>
> +#endif

I think you don't need the ifdef around this.

> +
>  #ifdef CONFIG_FIX_EARLYCON_MEM
>  #include <asm/fixmap.h>
>  #endif

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

* Re: [PATCH v4 00/11] Earlycon cleanup
  2016-01-12 19:41 ` [PATCH v4 00/11] " Peter Hurley
                     ` (10 preceding siblings ...)
  2016-01-12 19:41   ` [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon Peter Hurley
@ 2016-01-12 23:52   ` Rob Herring
  2016-01-16 21:37   ` [PATCH v5 " Peter Hurley
  12 siblings, 0 replies; 73+ messages in thread
From: Rob Herring @ 2016-01-12 23:52 UTC (permalink / raw)
  To: Peter Hurley
  Cc: Greg Kroah-Hartman, Masahiro Yamada, Grant Likely,
	linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
	Kevin Cernekee, Jon Hunter, Sebastian Frias, Paul Burton

On Tue, Jan 12, 2016 at 1:41 PM, Peter Hurley <peter@hurleysoftware.com> wrote:
> Hi Greg, Grant & Rob,
>
> This patch series is a rebase of the v3 from April last year.
>
> This patch series builds on my earlier "Extensible console matching &
> direct earlycon" to add several useful features to earlycon:
> * Proper port i/o configuration from DT node with of_serial properties
>   (such as reg-io-width, reg-shift and reg-offset, and endianness)
> * Proper console name & index initialization from earlycon name
>   (for both command line and DT-defined earlycons)
> * Support for DT 'stdout-path' options pass-through to earlycon setup
> * Improved log messages for troubleshooting
> * Support for multiple OF earlycon declarations so different
>   compatible strings can specify the same OF earlycon
>
> * Changes from v3
>   - Added 32-bit big-endian support
>   - Removed the omap8250 earlycon (will follow later)
>
>
> Rob has expressed a desire to have the DT parts live in drivers/of/fdt.c
> The problem with this approach is two-fold. Firstly, the number of required
> parameters quickly becomes ugly (base address, io reg width, io reg offset,
> io reg stride, endianness, earlycon name). Secondly, drivers are already
> requiring access to alternate DT properties, like clocks, to initialize
> earlycons, and this requirement will continue.

I dislike ugliness more. So other than my one nit, for the series:

Acked-by: Rob Herring <robh@kernel.org>

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

* Re: [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon
  2016-01-12 19:51     ` Peter Hurley
@ 2016-01-13  9:19       ` Jon Hunter
  2016-01-13  9:57         ` Jon Hunter
  2016-01-13 10:09         ` Jon Hunter
  0 siblings, 2 replies; 73+ messages in thread
From: Jon Hunter @ 2016-01-13  9:19 UTC (permalink / raw)
  To: Peter Hurley, Greg Kroah-Hartman
  Cc: Masahiro Yamada, Rob Herring, Grant Likely, linux-serial,
	linux-kernel, Kevin Cernekee, Sebastian Frias, Paul Burton,
	Arnd Bergmann


On 12/01/16 19:51, Peter Hurley wrote:
> Wasn't planning on sending this patch just yet, but oh well.
> 
> On 01/12/2016 11:41 AM, Peter Hurley wrote:
>> Add DT earlycon for 8250_omap driver. This boot console is included
>> for kernels built with CONFIG_SERIAL_EARLYCON=y, CONFIG_OF=y,
>> CONFIG_SERIAL_8250_OMAP=y, and CONFIG_OF_EARLY_FLATTREE=y.
>>
>> This boot console is enabled with the command line option "earlycon"
>> (without "=<name>...") when the DT 'stdout-path' property matches a
>> compatible uart. For example,
>>
>> / {
>>    chosen {
>>         stdout-path = "serial0:115200";
>>    };
>>
>>    ....
>>
>>    aliases {
>>         serial0 = &uart0;
>>    };
>>
>>    ....
>>
>>    ocp : ocp {
>>         uart0 : serial@44e09000 {
>>              compatible = "ti,omap3-uart";
>>         }
>>    };
>> };
>>
>> Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
>> ---
>>  drivers/tty/serial/8250/8250_early.c | 20 ++++++++++++++++++++
>>  1 file changed, 20 insertions(+)
>>
>> diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
>> index e7cdc0c..d1f6310 100644
>> --- a/drivers/tty/serial/8250/8250_early.c
>> +++ b/drivers/tty/serial/8250/8250_early.c
>> @@ -201,3 +201,23 @@ EARLYCON_DECLARE(rt288x, early_rt288x_setup);
>>  OF_EARLYCON_DECLARE(rt288x, "ralink,rt2880-uart", early_rt288x_setup);
>>  
>>  #endif /* CONFIG_SERIAL_8250_RT288X */
> 
> This patch may not apply because the context is sitting on top of
> unsubmitted code. Sorry.
> 
> Regards,
> Peter Hurley
> 
>> +
>> +#ifdef CONFIG_SERIAL_8250_OMAP
>> +
>> +static int __init early_omap8250_setup(struct earlycon_device *device,
>> +				       const char *options)
>> +{
>> +	struct uart_port *port = &device->port;
>> +
>> +	if (!(device->port.membase || device->port.iobase))
>> +		return -ENODEV;
>> +
>> +	port->regshift = 2;
>> +	device->con->write = early_serial8250_write;
>> +	return 0;
>> +}

I see you did not mean to send this out, but would the above still be
necessary with my patch [0]? I am wondering if with my patch you can
just add the below OF_EARLYCON_DECLARE() for OMAP?

>> +OF_EARLYCON_DECLARE(omap8250, "ti,omap2-uart", early_omap8250_setup);
>> +OF_EARLYCON_DECLARE(omap8250, "ti,omap3-uart", early_omap8250_setup);
>> +OF_EARLYCON_DECLARE(omap8250, "ti,omap4-uart", early_omap8250_setup);
>> +#endif

If so, would it make sense to include my patches [0] and [1] with this
series, or would you prefer that I just rebase on top of this? I see
that you have already made the same change that I made in patch 2 of my
series.

Cheers
Jon

[0] http://marc.info/?l=linux-serial&m=145259482325332&w=2
[1] http://marc.info/?l=linux-serial&m=145259482825342&w=2

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

* Re: [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon
  2016-01-13  9:19       ` Jon Hunter
@ 2016-01-13  9:57         ` Jon Hunter
  2016-01-13 10:09         ` Jon Hunter
  1 sibling, 0 replies; 73+ messages in thread
From: Jon Hunter @ 2016-01-13  9:57 UTC (permalink / raw)
  To: Peter Hurley, Greg Kroah-Hartman
  Cc: Masahiro Yamada, Rob Herring, Grant Likely, linux-serial,
	linux-kernel, Kevin Cernekee, Sebastian Frias, Paul Burton,
	Arnd Bergmann


On 13/01/16 09:19, Jon Hunter wrote:
> 
> On 12/01/16 19:51, Peter Hurley wrote:
>> Wasn't planning on sending this patch just yet, but oh well.
>>
>> On 01/12/2016 11:41 AM, Peter Hurley wrote:
>>> Add DT earlycon for 8250_omap driver. This boot console is included
>>> for kernels built with CONFIG_SERIAL_EARLYCON=y, CONFIG_OF=y,
>>> CONFIG_SERIAL_8250_OMAP=y, and CONFIG_OF_EARLY_FLATTREE=y.
>>>
>>> This boot console is enabled with the command line option "earlycon"
>>> (without "=<name>...") when the DT 'stdout-path' property matches a
>>> compatible uart. For example,
>>>
>>> / {
>>>    chosen {
>>>         stdout-path = "serial0:115200";
>>>    };
>>>
>>>    ....
>>>
>>>    aliases {
>>>         serial0 = &uart0;
>>>    };
>>>
>>>    ....
>>>
>>>    ocp : ocp {
>>>         uart0 : serial@44e09000 {
>>>              compatible = "ti,omap3-uart";
>>>         }
>>>    };
>>> };
>>>
>>> Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
>>> ---
>>>  drivers/tty/serial/8250/8250_early.c | 20 ++++++++++++++++++++
>>>  1 file changed, 20 insertions(+)
>>>
>>> diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
>>> index e7cdc0c..d1f6310 100644
>>> --- a/drivers/tty/serial/8250/8250_early.c
>>> +++ b/drivers/tty/serial/8250/8250_early.c
>>> @@ -201,3 +201,23 @@ EARLYCON_DECLARE(rt288x, early_rt288x_setup);
>>>  OF_EARLYCON_DECLARE(rt288x, "ralink,rt2880-uart", early_rt288x_setup);
>>>  
>>>  #endif /* CONFIG_SERIAL_8250_RT288X */
>>
>> This patch may not apply because the context is sitting on top of
>> unsubmitted code. Sorry.
>>
>> Regards,
>> Peter Hurley
>>
>>> +
>>> +#ifdef CONFIG_SERIAL_8250_OMAP
>>> +
>>> +static int __init early_omap8250_setup(struct earlycon_device *device,
>>> +				       const char *options)
>>> +{
>>> +	struct uart_port *port = &device->port;
>>> +
>>> +	if (!(device->port.membase || device->port.iobase))
>>> +		return -ENODEV;
>>> +
>>> +	port->regshift = 2;
>>> +	device->con->write = early_serial8250_write;
>>> +	return 0;
>>> +}
> 
> I see you did not mean to send this out, but would the above still be
> necessary with my patch [0]? I am wondering if with my patch you can
> just add the below OF_EARLYCON_DECLARE() for OMAP?

And replace early_omap8250_setup with early_serial8250_setup, in the
below that is.

>>> +OF_EARLYCON_DECLARE(omap8250, "ti,omap2-uart", early_omap8250_setup);
>>> +OF_EARLYCON_DECLARE(omap8250, "ti,omap3-uart", early_omap8250_setup);
>>> +OF_EARLYCON_DECLARE(omap8250, "ti,omap4-uart", early_omap8250_setup);
>>> +#endif

Jon

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

* Re: [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon
  2016-01-13  9:19       ` Jon Hunter
  2016-01-13  9:57         ` Jon Hunter
@ 2016-01-13 10:09         ` Jon Hunter
  2016-01-13 17:06           ` Peter Hurley
  1 sibling, 1 reply; 73+ messages in thread
From: Jon Hunter @ 2016-01-13 10:09 UTC (permalink / raw)
  To: Peter Hurley, Greg Kroah-Hartman
  Cc: Masahiro Yamada, Rob Herring, Grant Likely, linux-serial,
	linux-kernel, Kevin Cernekee, Sebastian Frias, Paul Burton,
	Arnd Bergmann


On 13/01/16 09:19, Jon Hunter wrote:
> 
> On 12/01/16 19:51, Peter Hurley wrote:
>> Wasn't planning on sending this patch just yet, but oh well.
>>
>> On 01/12/2016 11:41 AM, Peter Hurley wrote:
>>> Add DT earlycon for 8250_omap driver. This boot console is included
>>> for kernels built with CONFIG_SERIAL_EARLYCON=y, CONFIG_OF=y,
>>> CONFIG_SERIAL_8250_OMAP=y, and CONFIG_OF_EARLY_FLATTREE=y.
>>>
>>> This boot console is enabled with the command line option "earlycon"
>>> (without "=<name>...") when the DT 'stdout-path' property matches a
>>> compatible uart. For example,
>>>
>>> / {
>>>    chosen {
>>>         stdout-path = "serial0:115200";
>>>    };
>>>
>>>    ....
>>>
>>>    aliases {
>>>         serial0 = &uart0;
>>>    };
>>>
>>>    ....
>>>
>>>    ocp : ocp {
>>>         uart0 : serial@44e09000 {
>>>              compatible = "ti,omap3-uart";
>>>         }
>>>    };
>>> };
>>>
>>> Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
>>> ---
>>>  drivers/tty/serial/8250/8250_early.c | 20 ++++++++++++++++++++
>>>  1 file changed, 20 insertions(+)
>>>
>>> diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
>>> index e7cdc0c..d1f6310 100644
>>> --- a/drivers/tty/serial/8250/8250_early.c
>>> +++ b/drivers/tty/serial/8250/8250_early.c
>>> @@ -201,3 +201,23 @@ EARLYCON_DECLARE(rt288x, early_rt288x_setup);
>>>  OF_EARLYCON_DECLARE(rt288x, "ralink,rt2880-uart", early_rt288x_setup);
>>>  
>>>  #endif /* CONFIG_SERIAL_8250_RT288X */
>>
>> This patch may not apply because the context is sitting on top of
>> unsubmitted code. Sorry.
>>
>> Regards,
>> Peter Hurley
>>
>>> +
>>> +#ifdef CONFIG_SERIAL_8250_OMAP
>>> +
>>> +static int __init early_omap8250_setup(struct earlycon_device *device,
>>> +				       const char *options)
>>> +{
>>> +	struct uart_port *port = &device->port;
>>> +
>>> +	if (!(device->port.membase || device->port.iobase))
>>> +		return -ENODEV;
>>> +
>>> +	port->regshift = 2;
>>> +	device->con->write = early_serial8250_write;
>>> +	return 0;
>>> +}
> 
> I see you did not mean to send this out, but would the above still be
> necessary with my patch [0]? I am wondering if with my patch you can
> just add the below OF_EARLYCON_DECLARE() for OMAP?

Sorry, I see that you have also already made the changes I have in patch
[0]. However, still curious why you need the above for OMAP?

Jon

[0] http://marc.info/?l=linux-serial&m=145259482325332&w=2

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

* Re: [PATCH v4 05/11] of: earlycon: Initialize port fields from DT properties
  2016-01-12 23:49     ` Rob Herring
@ 2016-01-13 16:35       ` Peter Hurley
  0 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2016-01-13 16:35 UTC (permalink / raw)
  To: Rob Herring
  Cc: Greg Kroah-Hartman, Masahiro Yamada, Grant Likely,
	linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
	Kevin Cernekee, Jon Hunter, Sebastian Frias, Paul Burton

On 01/12/2016 03:49 PM, Rob Herring wrote:
> On Tue, Jan 12, 2016 at 1:41 PM, Peter Hurley <peter@hurleysoftware.com> wrote:
>> Read the optional "reg-offset", "reg-shift", "reg-io-width" and endianness
>> properties and initialize the respective struct uart_port field if found.
>>
>> NB: These bindings are common to several drivers and the values merely
>> indicate the default value; the registering earlycon setup() method can
>> simply override the values if required.
>>
>> Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
>> ---
> 
>> diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
>> index 7509ee34d..03eac4a 100644
>> --- a/drivers/tty/serial/earlycon.c
>> +++ b/drivers/tty/serial/earlycon.c
>> @@ -20,6 +20,10 @@
>>  #include <linux/serial_core.h>
>>  #include <linux/sizes.h>
>>
>> +#ifdef CONFIG_OF_EARLY_FLATTREE
>> +#include <linux/of_fdt.h>
>> +#endif
> 
> I think you don't need the ifdef around this.
> 
>> +
>>  #ifdef CONFIG_FIX_EARLYCON_MEM
>>  #include <asm/fixmap.h>
>>  #endif

Ok, will take care of that.

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

* Re: [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon
  2016-01-13 10:09         ` Jon Hunter
@ 2016-01-13 17:06           ` Peter Hurley
  2016-01-13 17:15             ` Jon Hunter
  0 siblings, 1 reply; 73+ messages in thread
From: Peter Hurley @ 2016-01-13 17:06 UTC (permalink / raw)
  To: Jon Hunter
  Cc: Greg Kroah-Hartman, Masahiro Yamada, Rob Herring, Grant Likely,
	linux-serial, linux-kernel, Kevin Cernekee, Sebastian Frias,
	Paul Burton, Arnd Bergmann

Hi Jon,

On 01/13/2016 02:09 AM, Jon Hunter wrote:
> On 13/01/16 09:19, Jon Hunter wrote:
>> On 12/01/16 19:51, Peter Hurley wrote:
>>> Wasn't planning on sending this patch just yet, but oh well.
>>>
>>> On 01/12/2016 11:41 AM, Peter Hurley wrote:
>>>> Add DT earlycon for 8250_omap driver. This boot console is included
>>>> for kernels built with CONFIG_SERIAL_EARLYCON=y, CONFIG_OF=y,
>>>> CONFIG_SERIAL_8250_OMAP=y, and CONFIG_OF_EARLY_FLATTREE=y.
>>>>
>>>> This boot console is enabled with the command line option "earlycon"
>>>> (without "=<name>...") when the DT 'stdout-path' property matches a
>>>> compatible uart. For example,
>>>>
>>>> / {
>>>>    chosen {
>>>>         stdout-path = "serial0:115200";
>>>>    };
>>>>
>>>>    ....
>>>>
>>>>    aliases {
>>>>         serial0 = &uart0;
>>>>    };
>>>>
>>>>    ....
>>>>
>>>>    ocp : ocp {
>>>>         uart0 : serial@44e09000 {
>>>>              compatible = "ti,omap3-uart";
>>>>         }
>>>>    };
>>>> };
>>>>
>>>> Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
>>>> ---
>>>>  drivers/tty/serial/8250/8250_early.c | 20 ++++++++++++++++++++
>>>>  1 file changed, 20 insertions(+)
>>>>
>>>> diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
>>>> index e7cdc0c..d1f6310 100644
>>>> --- a/drivers/tty/serial/8250/8250_early.c
>>>> +++ b/drivers/tty/serial/8250/8250_early.c
>>>> @@ -201,3 +201,23 @@ EARLYCON_DECLARE(rt288x, early_rt288x_setup);
>>>>  OF_EARLYCON_DECLARE(rt288x, "ralink,rt2880-uart", early_rt288x_setup);
>>>>  
>>>>  #endif /* CONFIG_SERIAL_8250_RT288X */
>>>
>>> This patch may not apply because the context is sitting on top of
>>> unsubmitted code. Sorry.
>>>
>>> Regards,
>>> Peter Hurley
>>>
>>>> +
>>>> +#ifdef CONFIG_SERIAL_8250_OMAP
>>>> +
>>>> +static int __init early_omap8250_setup(struct earlycon_device *device,
>>>> +				       const char *options)
>>>> +{
>>>> +	struct uart_port *port = &device->port;
>>>> +
>>>> +	if (!(device->port.membase || device->port.iobase))
>>>> +		return -ENODEV;
>>>> +
>>>> +	port->regshift = 2;
>>>> +	device->con->write = early_serial8250_write;
>>>> +	return 0;
>>>> +}
>>
>> I see you did not mean to send this out, but would the above still be
>> necessary with my patch [0]? I am wondering if with my patch you can
>> just add the below OF_EARLYCON_DECLARE() for OMAP?
> 
> Sorry, I see that you have also already made the changes I have in patch
> [0]. However, still curious why you need the above for OMAP?

Yeah, sorry about trouncing your patches.

I let that series from the beginning of last year stall after writing the
dtc compiler patch waiting for the kernel libfdt copy to catch up, and
then forgot about it, until the flood of recent earlycon patches.

Since it rebased (and retested) fairly trivially, I thought I'd just
push it out again.

The reason the omap8250 earlycon needs the regshift init is that the
omap uart DT nodes don't adequately describe the register layout; the
8250_omap sub-driver handles the uart port initialization (iow, it
doesn't use the 8250_of properties to describe i/o register access).
This situation is an artifact of the original omap uart driver,
omap-serial.c

For regular 8250 DT nodes, the only requirement should be the
OF_EARLYCON_DECLARE() to associate the compatible string with
early_serial8250_setup() (and a unique earlycon name such as the one
you already used).

NB: You should be able to re-use the earlycon name itself when
declaring new OF earlycons now. IOW,

OF_EARLYCON_DECLARE(uart, "nvidia,tegra20-uart", early_serial8250_setup);

should work. And this will keep the proliferation of command line
options to a minimum.

Please let me know if that doesn't work.

Regards,
Peter Hurley


> Jon
> 
> [0] http://marc.info/?l=linux-serial&m=145259482325332&w=2
> 

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

* Re: [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon
  2016-01-13 17:06           ` Peter Hurley
@ 2016-01-13 17:15             ` Jon Hunter
  0 siblings, 0 replies; 73+ messages in thread
From: Jon Hunter @ 2016-01-13 17:15 UTC (permalink / raw)
  To: Peter Hurley
  Cc: Greg Kroah-Hartman, Masahiro Yamada, Rob Herring, Grant Likely,
	linux-serial, linux-kernel, Kevin Cernekee, Sebastian Frias,
	Paul Burton, Arnd Bergmann

Hi Peter,

On 13/01/16 17:06, Peter Hurley wrote:
> Hi Jon,
> 
> On 01/13/2016 02:09 AM, Jon Hunter wrote:
>> On 13/01/16 09:19, Jon Hunter wrote:
>>> On 12/01/16 19:51, Peter Hurley wrote:
>>>> Wasn't planning on sending this patch just yet, but oh well.
>>>>
>>>> On 01/12/2016 11:41 AM, Peter Hurley wrote:
>>>>> Add DT earlycon for 8250_omap driver. This boot console is included
>>>>> for kernels built with CONFIG_SERIAL_EARLYCON=y, CONFIG_OF=y,
>>>>> CONFIG_SERIAL_8250_OMAP=y, and CONFIG_OF_EARLY_FLATTREE=y.
>>>>>
>>>>> This boot console is enabled with the command line option "earlycon"
>>>>> (without "=<name>...") when the DT 'stdout-path' property matches a
>>>>> compatible uart. For example,
>>>>>
>>>>> / {
>>>>>    chosen {
>>>>>         stdout-path = "serial0:115200";
>>>>>    };
>>>>>
>>>>>    ....
>>>>>
>>>>>    aliases {
>>>>>         serial0 = &uart0;
>>>>>    };
>>>>>
>>>>>    ....
>>>>>
>>>>>    ocp : ocp {
>>>>>         uart0 : serial@44e09000 {
>>>>>              compatible = "ti,omap3-uart";
>>>>>         }
>>>>>    };
>>>>> };
>>>>>
>>>>> Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
>>>>> ---
>>>>>  drivers/tty/serial/8250/8250_early.c | 20 ++++++++++++++++++++
>>>>>  1 file changed, 20 insertions(+)
>>>>>
>>>>> diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
>>>>> index e7cdc0c..d1f6310 100644
>>>>> --- a/drivers/tty/serial/8250/8250_early.c
>>>>> +++ b/drivers/tty/serial/8250/8250_early.c
>>>>> @@ -201,3 +201,23 @@ EARLYCON_DECLARE(rt288x, early_rt288x_setup);
>>>>>  OF_EARLYCON_DECLARE(rt288x, "ralink,rt2880-uart", early_rt288x_setup);
>>>>>  
>>>>>  #endif /* CONFIG_SERIAL_8250_RT288X */
>>>>
>>>> This patch may not apply because the context is sitting on top of
>>>> unsubmitted code. Sorry.
>>>>
>>>> Regards,
>>>> Peter Hurley
>>>>
>>>>> +
>>>>> +#ifdef CONFIG_SERIAL_8250_OMAP
>>>>> +
>>>>> +static int __init early_omap8250_setup(struct earlycon_device *device,
>>>>> +				       const char *options)
>>>>> +{
>>>>> +	struct uart_port *port = &device->port;
>>>>> +
>>>>> +	if (!(device->port.membase || device->port.iobase))
>>>>> +		return -ENODEV;
>>>>> +
>>>>> +	port->regshift = 2;
>>>>> +	device->con->write = early_serial8250_write;
>>>>> +	return 0;
>>>>> +}
>>>
>>> I see you did not mean to send this out, but would the above still be
>>> necessary with my patch [0]? I am wondering if with my patch you can
>>> just add the below OF_EARLYCON_DECLARE() for OMAP?
>>
>> Sorry, I see that you have also already made the changes I have in patch
>> [0]. However, still curious why you need the above for OMAP?
> 
> Yeah, sorry about trouncing your patches.

No problem, it is fine with me.

> I let that series from the beginning of last year stall after writing the
> dtc compiler patch waiting for the kernel libfdt copy to catch up, and
> then forgot about it, until the flood of recent earlycon patches.
> 
> Since it rebased (and retested) fairly trivially, I thought I'd just
> push it out again.
> 
> The reason the omap8250 earlycon needs the regshift init is that the
> omap uart DT nodes don't adequately describe the register layout; the
> 8250_omap sub-driver handles the uart port initialization (iow, it
> doesn't use the 8250_of properties to describe i/o register access).
> This situation is an artifact of the original omap uart driver,
> omap-serial.c
> 
> For regular 8250 DT nodes, the only requirement should be the
> OF_EARLYCON_DECLARE() to associate the compatible string with
> early_serial8250_setup() (and a unique earlycon name such as the one
> you already used).
> 
> NB: You should be able to re-use the earlycon name itself when
> declaring new OF earlycons now. IOW,
> 
> OF_EARLYCON_DECLARE(uart, "nvidia,tegra20-uart", early_serial8250_setup);
> 
> should work. And this will keep the proliferation of command line
> options to a minimum.

Ok.

> Please let me know if that doesn't work.

I am sure it will. I will re-send a patch for this, once this series is
merged.

Cheers
Jon

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

* [PATCH v5 00/11] Earlycon cleanup
  2016-01-12 19:41 ` [PATCH v4 00/11] " Peter Hurley
                     ` (11 preceding siblings ...)
  2016-01-12 23:52   ` [PATCH v4 00/11] Earlycon cleanup Rob Herring
@ 2016-01-16 21:37   ` Peter Hurley
  2016-01-16 21:37     ` [PATCH v5 01/11] earlycon: Use common framework for earlycon declarations Peter Hurley
                       ` (11 more replies)
  12 siblings, 12 replies; 73+ messages in thread
From: Peter Hurley @ 2016-01-16 21:37 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: Jiri Slaby, linux-serial, linux-kernel, Kevin Cernekee,
	Jon Hunter, Paul Burton, Masahiro Yamada, Sebastian Frias,
	Peter Hurley

Hi Greg, Grant & Rob,

This patch series is a rebase of the v3 from April last year.

This patch series builds on my earlier "Extensible console matching &
direct earlycon" to add several useful features to earlycon:
* Proper port i/o configuration from DT node with of_serial properties
  (such as reg-io-width, reg-shift and reg-offset, and endianness)
* Proper console name & index initialization from earlycon name
  (for both command line and DT-defined earlycons)
* Support for DT 'stdout-path' options pass-through to earlycon setup
* Improved log messages for troubleshooting
* Support for multiple OF earlycon declarations so different
  compatible strings can specify the same OF earlycon

* Changes from v3
  - Added 32-bit big-endian support
  - Removed the omap8250 earlycon (will follow later)
* Changes from v4
  - Rolled in Rob's acks (thanks for reviewing this series)
  - Removed the conditional guard of of_fdt.h header inclusion (Rob's comment)
  - Left in the omap8250 earlycon (rebased w/o the wip so applies cleanly)

Regards,

Peter Hurley (11):
  earlycon: Use common framework for earlycon declarations
  serial: earlycon: Fixup earlycon console name and index
  of: earlycon: Fixup earlycon console name and index
  of: earlycon: Add options string handling
  of: earlycon: Initialize port fields from DT properties
  of: earlycon: Move address translation to of_setup_earlycon()
  serial: earlycon: Common log banner for command line and DT
  serial: earlycon: Show the earlycon "driver" in banner
  serial: 8250_early: Use port->regshift
  of: earlycon: Log more helpful message if stdout-path node not found
  serial: 8250_omap: Add omap8250 earlycon

 drivers/of/fdt.c                     |  32 +++++-----
 drivers/of/fdt_address.c             |  11 +++-
 drivers/tty/serial/8250/8250_early.c |  37 ++++++++++--
 drivers/tty/serial/amba-pl011.c      |   1 -
 drivers/tty/serial/arc_uart.c        |   1 -
 drivers/tty/serial/earlycon.c        | 114 ++++++++++++++++++++++++++---------
 drivers/tty/serial/msm_serial.c      |   2 -
 drivers/tty/serial/samsung.c         |   6 --
 drivers/tty/serial/sprd_serial.c     |   2 -
 include/asm-generic/vmlinux.lds.h    |   6 +-
 include/linux/of_fdt.h               |   2 +-
 include/linux/serial_core.h          |  25 +++++---
 12 files changed, 158 insertions(+), 81 deletions(-)

-- 
2.7.0

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

* [PATCH v5 01/11] earlycon: Use common framework for earlycon declarations
  2016-01-16 21:37   ` [PATCH v5 " Peter Hurley
@ 2016-01-16 21:37     ` Peter Hurley
  2016-01-16 21:37     ` [PATCH v5 02/11] serial: earlycon: Fixup earlycon console name and index Peter Hurley
                       ` (10 subsequent siblings)
  11 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2016-01-16 21:37 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: Jiri Slaby, linux-serial, linux-kernel, Kevin Cernekee,
	Jon Hunter, Paul Burton, Masahiro Yamada, Sebastian Frias,
	Peter Hurley

Use a single common table of struct earlycon_id for both command line
and devicetree. Re-define OF_EARLYCON_DECLARE() macro to instance a
unique earlycon declaration (the declaration is only guaranteed to be
unique within a compilation unit; separate compilation units must still
use unique earlycon names).

The semantics of OF_EARLYCON_DECLARE() is different; it declares an
earlycon which can matched either on the command line or by devicetree.
EARLYCON_DECLARE() is semantically unchanged; it declares an earlycon
which is matched by command line only. Remove redundant instances of
EARLYCON_DECLARE().

This enables all earlycons to properly initialize struct console
with the appropriate name and index, which improves diagnostics and
enables direct earlycon-to-console handoff.

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/of/fdt.c                  | 14 +++++++-------
 drivers/tty/serial/amba-pl011.c   |  1 -
 drivers/tty/serial/arc_uart.c     |  1 -
 drivers/tty/serial/earlycon.c     | 10 +---------
 drivers/tty/serial/msm_serial.c   |  2 --
 drivers/tty/serial/samsung.c      |  6 ------
 drivers/tty/serial/sprd_serial.c  |  2 --
 include/asm-generic/vmlinux.lds.h |  6 ++----
 include/linux/serial_core.h       | 22 +++++++++++++---------
 9 files changed, 23 insertions(+), 41 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 655f79d..1686118 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -796,14 +796,13 @@ static inline void early_init_dt_check_for_initrd(unsigned long node)
 #endif /* CONFIG_BLK_DEV_INITRD */
 
 #ifdef CONFIG_SERIAL_EARLYCON
-extern struct of_device_id __earlycon_of_table[];
 
 static int __init early_init_dt_scan_chosen_serial(void)
 {
 	int offset;
 	const char *p;
 	int l;
-	const struct of_device_id *match = __earlycon_of_table;
+	const struct earlycon_id *match;
 	const void *fdt = initial_boot_params;
 
 	offset = fdt_path_offset(fdt, "/chosen");
@@ -826,19 +825,20 @@ static int __init early_init_dt_scan_chosen_serial(void)
 	if (offset < 0)
 		return -ENODEV;
 
-	while (match->compatible[0]) {
+	for (match = __earlycon_table; match < __earlycon_table_end; match++) {
 		u64 addr;
 
-		if (fdt_node_check_compatible(fdt, offset, match->compatible)) {
-			match++;
+		if (!match->compatible[0])
+			continue;
+
+		if (fdt_node_check_compatible(fdt, offset, match->compatible))
 			continue;
-		}
 
 		addr = fdt_translate_address(fdt, offset);
 		if (addr == OF_BAD_ADDR)
 			return -ENXIO;
 
-		of_setup_earlycon(addr, match->data);
+		of_setup_earlycon(addr, match->setup);
 		return 0;
 	}
 	return -ENODEV;
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index c0da0cc..de84602 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -2327,7 +2327,6 @@ static int __init pl011_early_console_setup(struct earlycon_device *device,
 	device->con->write = pl011_early_write;
 	return 0;
 }
-EARLYCON_DECLARE(pl011, pl011_early_console_setup);
 OF_EARLYCON_DECLARE(pl011, "arm,pl011", pl011_early_console_setup);
 
 #else
diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c
index 03ebe40..3a1de5c 100644
--- a/drivers/tty/serial/arc_uart.c
+++ b/drivers/tty/serial/arc_uart.c
@@ -576,7 +576,6 @@ static int __init arc_early_console_setup(struct earlycon_device *dev,
 	dev->con->write = arc_early_serial_write;
 	return 0;
 }
-EARLYCON_DECLARE(arc_uart, arc_early_console_setup);
 OF_EARLYCON_DECLARE(arc_uart, "snps,arc-uart", arc_early_console_setup);
 
 #endif	/* CONFIG_SERIAL_ARC_CONSOLE */
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 3f24236..765bce6 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -19,7 +19,6 @@
 #include <linux/io.h>
 #include <linux/serial_core.h>
 #include <linux/sizes.h>
-#include <linux/mod_devicetable.h>
 
 #ifdef CONFIG_FIX_EARLYCON_MEM
 #include <asm/fixmap.h>
@@ -37,13 +36,6 @@ static struct earlycon_device early_console_dev = {
 	.con = &early_con,
 };
 
-extern struct earlycon_id __earlycon_table[];
-static const struct earlycon_id __earlycon_table_sentinel
-	__used __section(__earlycon_table_end);
-
-static const struct of_device_id __earlycon_of_table_sentinel
-	__used __section(__earlycon_of_table_end);
-
 static void __iomem * __init earlycon_map(unsigned long paddr, size_t size)
 {
 	void __iomem *base;
@@ -166,7 +158,7 @@ int __init setup_earlycon(char *buf)
 	if (early_con.flags & CON_ENABLED)
 		return -EALREADY;
 
-	for (match = __earlycon_table; match->name[0]; match++) {
+	for (match = __earlycon_table; match < __earlycon_table_end; match++) {
 		size_t len = strlen(match->name);
 
 		if (strncmp(buf, match->name, len))
diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
index dcde955..96d3ce8 100644
--- a/drivers/tty/serial/msm_serial.c
+++ b/drivers/tty/serial/msm_serial.c
@@ -1478,7 +1478,6 @@ msm_serial_early_console_setup(struct earlycon_device *device, const char *opt)
 	device->con->write = msm_serial_early_write;
 	return 0;
 }
-EARLYCON_DECLARE(msm_serial, msm_serial_early_console_setup);
 OF_EARLYCON_DECLARE(msm_serial, "qcom,msm-uart",
 		    msm_serial_early_console_setup);
 
@@ -1500,7 +1499,6 @@ msm_serial_early_console_setup_dm(struct earlycon_device *device,
 	device->con->write = msm_serial_early_write_dm;
 	return 0;
 }
-EARLYCON_DECLARE(msm_serial_dm, msm_serial_early_console_setup_dm);
 OF_EARLYCON_DECLARE(msm_serial_dm, "qcom,msm-uartdm",
 		    msm_serial_early_console_setup_dm);
 
diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
index d72cd73..fd9c47f 100644
--- a/drivers/tty/serial/samsung.c
+++ b/drivers/tty/serial/samsung.c
@@ -2451,7 +2451,6 @@ static int __init s3c2410_early_console_setup(struct earlycon_device *device,
 }
 OF_EARLYCON_DECLARE(s3c2410, "samsung,s3c2410-uart",
 			s3c2410_early_console_setup);
-EARLYCON_DECLARE(s3c2410, s3c2410_early_console_setup);
 
 /* S3C2412, S3C2440, S3C64xx */
 static struct samsung_early_console_data s3c2440_early_console_data = {
@@ -2470,9 +2469,6 @@ OF_EARLYCON_DECLARE(s3c2440, "samsung,s3c2440-uart",
 			s3c2440_early_console_setup);
 OF_EARLYCON_DECLARE(s3c6400, "samsung,s3c6400-uart",
 			s3c2440_early_console_setup);
-EARLYCON_DECLARE(s3c2412, s3c2440_early_console_setup);
-EARLYCON_DECLARE(s3c2440, s3c2440_early_console_setup);
-EARLYCON_DECLARE(s3c6400, s3c2440_early_console_setup);
 
 /* S5PV210, EXYNOS */
 static struct samsung_early_console_data s5pv210_early_console_data = {
@@ -2489,8 +2485,6 @@ OF_EARLYCON_DECLARE(s5pv210, "samsung,s5pv210-uart",
 			s5pv210_early_console_setup);
 OF_EARLYCON_DECLARE(exynos4210, "samsung,exynos4210-uart",
 			s5pv210_early_console_setup);
-EARLYCON_DECLARE(s5pv210, s5pv210_early_console_setup);
-EARLYCON_DECLARE(exynos4210, s5pv210_early_console_setup);
 #endif
 
 MODULE_ALIAS("platform:samsung-uart");
diff --git a/drivers/tty/serial/sprd_serial.c b/drivers/tty/serial/sprd_serial.c
index ef26c4a..1897106 100644
--- a/drivers/tty/serial/sprd_serial.c
+++ b/drivers/tty/serial/sprd_serial.c
@@ -624,8 +624,6 @@ static int __init sprd_early_console_setup(
 	device->con->write = sprd_early_write;
 	return 0;
 }
-
-EARLYCON_DECLARE(sprd_serial, sprd_early_console_setup);
 OF_EARLYCON_DECLARE(sprd_serial, "sprd,sc9836-uart",
 		    sprd_early_console_setup);
 
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index c4bd0e2..e9a81a6 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -157,7 +157,7 @@
 #define EARLYCON_TABLE() STRUCT_ALIGN();			\
 			 VMLINUX_SYMBOL(__earlycon_table) = .;	\
 			 *(__earlycon_table)			\
-			 *(__earlycon_table_end)
+			 VMLINUX_SYMBOL(__earlycon_table_end) = .;
 #else
 #define EARLYCON_TABLE()
 #endif
@@ -179,7 +179,6 @@
 #define RESERVEDMEM_OF_TABLES()	OF_TABLE(CONFIG_OF_RESERVED_MEM, reservedmem)
 #define CPU_METHOD_OF_TABLES()	OF_TABLE(CONFIG_SMP, cpu_method)
 #define CPUIDLE_METHOD_OF_TABLES() OF_TABLE(CONFIG_CPU_IDLE, cpuidle_method)
-#define EARLYCON_OF_TABLES()	OF_TABLE(CONFIG_SERIAL_EARLYCON, earlycon)
 
 #ifdef CONFIG_ACPI
 #define ACPI_PROBE_TABLE(name)						\
@@ -526,8 +525,7 @@
 	IRQCHIP_OF_MATCH_TABLE()					\
 	ACPI_PROBE_TABLE(irqchip)					\
 	ACPI_PROBE_TABLE(clksrc)					\
-	EARLYCON_TABLE()						\
-	EARLYCON_OF_TABLES()
+	EARLYCON_TABLE()
 
 #define INIT_TEXT							\
 	*(.init.text)							\
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index e03d6ba..25e0514 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -342,22 +342,26 @@ struct earlycon_device {
 
 struct earlycon_id {
 	char	name[16];
+	char	compatible[128];
 	int	(*setup)(struct earlycon_device *, const char *options);
 } __aligned(32);
 
+extern const struct earlycon_id __earlycon_table[];
+extern const struct earlycon_id __earlycon_table_end[];
+
+#define OF_EARLYCON_DECLARE(_name, compat, fn)				\
+	static const struct earlycon_id __UNIQUE_ID(__earlycon_##_name)	\
+	     __used __section(__earlycon_table)				\
+		= { .name = __stringify(_name),				\
+		    .compatible = compat,				\
+		    .setup = fn  }
+
+#define EARLYCON_DECLARE(_name, fn)	OF_EARLYCON_DECLARE(_name, "", fn)
+
 extern int setup_earlycon(char *buf);
 extern int of_setup_earlycon(unsigned long addr,
 			     int (*setup)(struct earlycon_device *, const char *));
 
-#define EARLYCON_DECLARE(_name, func)					\
-	static const struct earlycon_id __earlycon_##_name		\
-		__used __section(__earlycon_table)			\
-		 = { .name  = __stringify(_name),			\
-		     .setup = func  }
-
-#define OF_EARLYCON_DECLARE(name, compat, fn)				\
-	_OF_DECLARE(earlycon, name, compat, fn, void *)
-
 struct uart_port *uart_get_console(struct uart_port *ports, int nr,
 				   struct console *c);
 int uart_parse_earlycon(char *p, unsigned char *iotype, unsigned long *addr,
-- 
2.7.0

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

* [PATCH v5 02/11] serial: earlycon: Fixup earlycon console name and index
  2016-01-16 21:37   ` [PATCH v5 " Peter Hurley
  2016-01-16 21:37     ` [PATCH v5 01/11] earlycon: Use common framework for earlycon declarations Peter Hurley
@ 2016-01-16 21:37     ` Peter Hurley
  2016-01-16 21:37     ` [PATCH v5 03/11] of: " Peter Hurley
                       ` (9 subsequent siblings)
  11 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2016-01-16 21:37 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: Jiri Slaby, linux-serial, linux-kernel, Kevin Cernekee,
	Jon Hunter, Paul Burton, Masahiro Yamada, Sebastian Frias,
	Peter Hurley

Properly initialize the struct console 'name' and 'index' fields for
the registering earlycon. For earlycons w/o trailing numerals, the
index is set to 0; otherwise, the index is set to the value of the
trailing numeral. For example, the 'exynos4210' earlycon name == "exynos"
and index == 4210. Earlycons with embedded numerals will have all
non-trailing numerals as part of the name; for example, the 's3c2412'
earlycon name == "s3c" and index == 2412.

This ackward scheme was initially added for the uart8250 earlycon;
adopt this scheme for the other earlycon "drivers".

Introduce earlycon_init() which performs the string scanning and
initializes the name and index fields; encapsulate the other console
field initializations within.

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/tty/serial/earlycon.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 765bce6..0da5698 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -27,9 +27,9 @@
 #include <asm/serial.h>
 
 static struct console early_con = {
-	.name =		"uart", /* 8250 console switch requires this name */
+	.name =		"uart",		/* fixed up at earlycon registration */
 	.flags =	CON_PRINTBUFFER | CON_BOOT,
-	.index =	-1,
+	.index =	0,
 };
 
 static struct earlycon_device early_console_dev = {
@@ -53,6 +53,25 @@ static void __iomem * __init earlycon_map(unsigned long paddr, size_t size)
 	return base;
 }
 
+static void __init earlycon_init(struct earlycon_device *device,
+				 const char *name)
+{
+	struct console *earlycon = device->con;
+	const char *s;
+	size_t len;
+
+	/* scan backwards from end of string for first non-numeral */
+	for (s = name + strlen(name);
+	     s > name && s[-1] >= '0' && s[-1] <= '9';
+	     s--)
+		;
+	if (*s)
+		earlycon->index = simple_strtoul(s, NULL, 10);
+	len = s - name;
+	strlcpy(earlycon->name, name, min(len + 1, sizeof(earlycon->name)));
+	earlycon->data = &early_console_dev;
+}
+
 static int __init parse_options(struct earlycon_device *device, char *options)
 {
 	struct uart_port *port = &device->port;
@@ -119,7 +138,7 @@ static int __init register_earlycon(char *buf, const struct earlycon_id *match)
 	if (port->mapbase)
 		port->membase = earlycon_map(port->mapbase, 64);
 
-	early_console_dev.con->data = &early_console_dev;
+	earlycon_init(&early_console_dev, match->name);
 	err = match->setup(&early_console_dev, buf);
 	if (err < 0)
 		return err;
-- 
2.7.0

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

* [PATCH v5 03/11] of: earlycon: Fixup earlycon console name and index
  2016-01-16 21:37   ` [PATCH v5 " Peter Hurley
  2016-01-16 21:37     ` [PATCH v5 01/11] earlycon: Use common framework for earlycon declarations Peter Hurley
  2016-01-16 21:37     ` [PATCH v5 02/11] serial: earlycon: Fixup earlycon console name and index Peter Hurley
@ 2016-01-16 21:37     ` Peter Hurley
  2016-01-16 21:37     ` [PATCH v5 04/11] of: earlycon: Add options string handling Peter Hurley
                       ` (8 subsequent siblings)
  11 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2016-01-16 21:37 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: Jiri Slaby, linux-serial, linux-kernel, Kevin Cernekee,
	Jon Hunter, Paul Burton, Masahiro Yamada, Sebastian Frias,
	Peter Hurley

Use the console name embedded in the OF earlycon table by the
OF_EARLYCON_DECLARE() macro to initialize the struct console 'name'
and 'index' fields.

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/of/fdt.c              | 2 +-
 drivers/tty/serial/earlycon.c | 6 +++---
 include/linux/serial_core.h   | 3 +--
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 1686118..ec14595 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -838,7 +838,7 @@ static int __init early_init_dt_scan_chosen_serial(void)
 		if (addr == OF_BAD_ADDR)
 			return -ENXIO;
 
-		of_setup_earlycon(addr, match->setup);
+		of_setup_earlycon(addr, match);
 		return 0;
 	}
 	return -ENODEV;
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 0da5698..f4b5490 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -216,7 +216,7 @@ static int __init param_setup_earlycon(char *buf)
 early_param("earlycon", param_setup_earlycon);
 
 int __init of_setup_earlycon(unsigned long addr,
-			     int (*setup)(struct earlycon_device *, const char *))
+			     const struct earlycon_id *match)
 {
 	int err;
 	struct uart_port *port = &early_console_dev.port;
@@ -227,8 +227,8 @@ int __init of_setup_earlycon(unsigned long addr,
 	port->uartclk = BASE_BAUD * 16;
 	port->membase = earlycon_map(addr, SZ_4K);
 
-	early_console_dev.con->data = &early_console_dev;
-	err = setup(&early_console_dev, NULL);
+	earlycon_init(&early_console_dev, match->name);
+	err = match->setup(&early_console_dev, NULL);
 	if (err < 0)
 		return err;
 	if (!early_console_dev.con->write)
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 25e0514..63fdb55 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -359,8 +359,7 @@ extern const struct earlycon_id __earlycon_table_end[];
 #define EARLYCON_DECLARE(_name, fn)	OF_EARLYCON_DECLARE(_name, "", fn)
 
 extern int setup_earlycon(char *buf);
-extern int of_setup_earlycon(unsigned long addr,
-			     int (*setup)(struct earlycon_device *, const char *));
+extern int of_setup_earlycon(unsigned long addr, const struct earlycon_id *match);
 
 struct uart_port *uart_get_console(struct uart_port *ports, int nr,
 				   struct console *c);
-- 
2.7.0

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

* [PATCH v5 04/11] of: earlycon: Add options string handling
  2016-01-16 21:37   ` [PATCH v5 " Peter Hurley
                       ` (2 preceding siblings ...)
  2016-01-16 21:37     ` [PATCH v5 03/11] of: " Peter Hurley
@ 2016-01-16 21:37     ` Peter Hurley
  2016-01-16 21:37     ` [PATCH v5 05/11] of: earlycon: Initialize port fields from DT properties Peter Hurley
                       ` (7 subsequent siblings)
  11 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2016-01-16 21:37 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: Jiri Slaby, linux-serial, linux-kernel, Kevin Cernekee,
	Jon Hunter, Paul Burton, Masahiro Yamada, Sebastian Frias,
	Peter Hurley

Pass-through any options string in the 'stdout-path' property to the
earlycon "driver" setup.

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/of/fdt.c              | 11 ++++++-----
 drivers/tty/serial/earlycon.c |  9 +++++++--
 include/linux/serial_core.h   |  3 ++-
 3 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index ec14595..cfd3b35 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -800,7 +800,7 @@ static inline void early_init_dt_check_for_initrd(unsigned long node)
 static int __init early_init_dt_scan_chosen_serial(void)
 {
 	int offset;
-	const char *p;
+	const char *p, *q, *options = NULL;
 	int l;
 	const struct earlycon_id *match;
 	const void *fdt = initial_boot_params;
@@ -817,11 +817,12 @@ static int __init early_init_dt_scan_chosen_serial(void)
 	if (!p || !l)
 		return -ENOENT;
 
-	/* Remove console options if present */
-	l = strchrnul(p, ':') - p;
+	q = strchrnul(p, ':');
+	if (*q != '\0')
+		options = q + 1;
 
 	/* Get the node specified by stdout-path */
-	offset = fdt_path_offset_namelen(fdt, p, l);
+	offset = fdt_path_offset_namelen(fdt, p, q - p);
 	if (offset < 0)
 		return -ENODEV;
 
@@ -838,7 +839,7 @@ static int __init early_init_dt_scan_chosen_serial(void)
 		if (addr == OF_BAD_ADDR)
 			return -ENXIO;
 
-		of_setup_earlycon(addr, match);
+		of_setup_earlycon(addr, match, options);
 		return 0;
 	}
 	return -ENODEV;
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index f4b5490..d50ed78 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -216,7 +216,8 @@ static int __init param_setup_earlycon(char *buf)
 early_param("earlycon", param_setup_earlycon);
 
 int __init of_setup_earlycon(unsigned long addr,
-			     const struct earlycon_id *match)
+			     const struct earlycon_id *match,
+			     const char *options)
 {
 	int err;
 	struct uart_port *port = &early_console_dev.port;
@@ -227,8 +228,12 @@ int __init of_setup_earlycon(unsigned long addr,
 	port->uartclk = BASE_BAUD * 16;
 	port->membase = earlycon_map(addr, SZ_4K);
 
+	if (options) {
+		strlcpy(early_console_dev.options, options,
+			sizeof(early_console_dev.options));
+	}
 	earlycon_init(&early_console_dev, match->name);
-	err = match->setup(&early_console_dev, NULL);
+	err = match->setup(&early_console_dev, options);
 	if (err < 0)
 		return err;
 	if (!early_console_dev.con->write)
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 63fdb55..62a4df0 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -359,7 +359,8 @@ extern const struct earlycon_id __earlycon_table_end[];
 #define EARLYCON_DECLARE(_name, fn)	OF_EARLYCON_DECLARE(_name, "", fn)
 
 extern int setup_earlycon(char *buf);
-extern int of_setup_earlycon(unsigned long addr, const struct earlycon_id *match);
+extern int of_setup_earlycon(unsigned long addr, const struct earlycon_id *match,
+			     const char *options);
 
 struct uart_port *uart_get_console(struct uart_port *ports, int nr,
 				   struct console *c);
-- 
2.7.0

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

* [PATCH v5 05/11] of: earlycon: Initialize port fields from DT properties
  2016-01-16 21:37   ` [PATCH v5 " Peter Hurley
                       ` (3 preceding siblings ...)
  2016-01-16 21:37     ` [PATCH v5 04/11] of: earlycon: Add options string handling Peter Hurley
@ 2016-01-16 21:37     ` Peter Hurley
  2016-01-16 21:54       ` kbuild test robot
  2016-01-16 21:37     ` [PATCH v5 06/11] of: earlycon: Move address translation to of_setup_earlycon() Peter Hurley
                       ` (6 subsequent siblings)
  11 siblings, 1 reply; 73+ messages in thread
From: Peter Hurley @ 2016-01-16 21:37 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: Jiri Slaby, linux-serial, linux-kernel, Kevin Cernekee,
	Jon Hunter, Paul Burton, Masahiro Yamada, Sebastian Frias,
	Peter Hurley

Read the optional "reg-offset", "reg-shift", "reg-io-width" and endianness
properties and initialize the respective struct uart_port field if found.

NB: These bindings are common to several drivers and the values merely
indicate the default value; the registering earlycon setup() method can
simply override the values if required.

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/of/fdt.c              |  2 +-
 drivers/tty/serial/earlycon.c | 31 +++++++++++++++++++++++++++++++
 include/linux/serial_core.h   |  1 +
 3 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index cfd3b35..e8fd54a 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -839,7 +839,7 @@ static int __init early_init_dt_scan_chosen_serial(void)
 		if (addr == OF_BAD_ADDR)
 			return -ENXIO;
 
-		of_setup_earlycon(addr, match, options);
+		of_setup_earlycon(addr, match, offset, options);
 		return 0;
 	}
 	return -ENODEV;
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index d50ed78..75679b0 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -19,6 +19,7 @@
 #include <linux/io.h>
 #include <linux/serial_core.h>
 #include <linux/sizes.h>
+#include <linux/of_fdt.h>
 
 #ifdef CONFIG_FIX_EARLYCON_MEM
 #include <asm/fixmap.h>
@@ -217,10 +218,13 @@ early_param("earlycon", param_setup_earlycon);
 
 int __init of_setup_earlycon(unsigned long addr,
 			     const struct earlycon_id *match,
+			     unsigned long node,
 			     const char *options)
 {
 	int err;
 	struct uart_port *port = &early_console_dev.port;
+	const __be32 *val;
+	bool big_endian;
 
 	spin_lock_init(&port->lock);
 	port->iotype = UPIO_MEM;
@@ -228,6 +232,33 @@ int __init of_setup_earlycon(unsigned long addr,
 	port->uartclk = BASE_BAUD * 16;
 	port->membase = earlycon_map(addr, SZ_4K);
 
+	val = of_get_flat_dt_prop(node, "reg-offset", NULL);
+	if (val)
+		port->mapbase += be32_to_cpu(*val);
+	val = of_get_flat_dt_prop(node, "reg-shift", NULL);
+	if (val)
+		port->regshift = be32_to_cpu(*val);
+	big_endian = of_get_flat_dt_prop(node, "big-endian", NULL) != NULL ||
+		(IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) &&
+		 of_get_flat_dt_prop(node, "native-endian", NULL) != NULL);
+	val = of_get_flat_dt_prop(node, "reg-io-width", NULL);
+	if (val) {
+		switch (be32_to_cpu(*val)) {
+		case 1:
+			port->iotype = UPIO_MEM;
+			break;
+		case 2:
+			port->iotype = UPIO_MEM16;
+			break;
+		case 4:
+			port->iotype = (big_endian) ? UPIO_MEM32BE : UPIO_MEM32;
+			break;
+		default:
+			pr_warn("[%s] unsupported reg-io-width\n", match->name);
+			return -EINVAL;
+		}
+	}
+
 	if (options) {
 		strlcpy(early_console_dev.options, options,
 			sizeof(early_console_dev.options));
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 62a4df0..6d1bed8 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -360,6 +360,7 @@ extern const struct earlycon_id __earlycon_table_end[];
 
 extern int setup_earlycon(char *buf);
 extern int of_setup_earlycon(unsigned long addr, const struct earlycon_id *match,
+			     unsigned long node,
 			     const char *options);
 
 struct uart_port *uart_get_console(struct uart_port *ports, int nr,
-- 
2.7.0

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

* [PATCH v5 06/11] of: earlycon: Move address translation to of_setup_earlycon()
  2016-01-16 21:37   ` [PATCH v5 " Peter Hurley
                       ` (4 preceding siblings ...)
  2016-01-16 21:37     ` [PATCH v5 05/11] of: earlycon: Initialize port fields from DT properties Peter Hurley
@ 2016-01-16 21:37     ` Peter Hurley
  2016-01-16 22:02       ` kbuild test robot
  2016-01-16 21:37     ` [PATCH v5 07/11] serial: earlycon: Common log banner for command line and DT Peter Hurley
                       ` (5 subsequent siblings)
  11 siblings, 1 reply; 73+ messages in thread
From: Peter Hurley @ 2016-01-16 21:37 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: Jiri Slaby, linux-serial, linux-kernel, Kevin Cernekee,
	Jon Hunter, Paul Burton, Masahiro Yamada, Sebastian Frias,
	Peter Hurley

Cleanup the early DT/earlycon separation; remove the 'addr' parameter
from of_setup_earlycon() and get the uart phys addr directly with a
new wrapper function, of_flat_dt_translate_addr(). Limit
fdt_translate_address() to file scope.

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/of/fdt.c              |  8 +-------
 drivers/of/fdt_address.c      | 11 ++++++++++-
 drivers/tty/serial/earlycon.c | 12 +++++++++---
 include/linux/of_fdt.h        |  2 +-
 include/linux/serial_core.h   |  2 +-
 5 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index e8fd54a..918809e 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -827,19 +827,13 @@ static int __init early_init_dt_scan_chosen_serial(void)
 		return -ENODEV;
 
 	for (match = __earlycon_table; match < __earlycon_table_end; match++) {
-		u64 addr;
-
 		if (!match->compatible[0])
 			continue;
 
 		if (fdt_node_check_compatible(fdt, offset, match->compatible))
 			continue;
 
-		addr = fdt_translate_address(fdt, offset);
-		if (addr == OF_BAD_ADDR)
-			return -ENXIO;
-
-		of_setup_earlycon(addr, match, offset, options);
+		of_setup_earlycon(match, offset, options);
 		return 0;
 	}
 	return -ENODEV;
diff --git a/drivers/of/fdt_address.c b/drivers/of/fdt_address.c
index 8d3dc6f..dca8f9b 100644
--- a/drivers/of/fdt_address.c
+++ b/drivers/of/fdt_address.c
@@ -161,7 +161,7 @@ static int __init fdt_translate_one(const void *blob, int parent,
  * that can be mapped to a cpu physical address). This is not really specified
  * that way, but this is traditionally the way IBM at least do things
  */
-u64 __init fdt_translate_address(const void *blob, int node_offset)
+static u64 __init fdt_translate_address(const void *blob, int node_offset)
 {
 	int parent, len;
 	const struct of_bus *bus, *pbus;
@@ -239,3 +239,12 @@ u64 __init fdt_translate_address(const void *blob, int node_offset)
  bail:
 	return result;
 }
+
+/**
+ * of_flat_dt_translate_address - translate DT addr into CPU phys addr
+ * @node: node in the flat blob
+ */
+u64 __init of_flat_dt_translate_address(unsigned long node)
+{
+	return fdt_translate_address(initial_boot_params, node);
+}
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 75679b0..24f9adb 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -19,6 +19,7 @@
 #include <linux/io.h>
 #include <linux/serial_core.h>
 #include <linux/sizes.h>
+#include <linux/of.h>
 #include <linux/of_fdt.h>
 
 #ifdef CONFIG_FIX_EARLYCON_MEM
@@ -216,8 +217,7 @@ static int __init param_setup_earlycon(char *buf)
 }
 early_param("earlycon", param_setup_earlycon);
 
-int __init of_setup_earlycon(unsigned long addr,
-			     const struct earlycon_id *match,
+int __init of_setup_earlycon(const struct earlycon_id *match,
 			     unsigned long node,
 			     const char *options)
 {
@@ -225,12 +225,18 @@ int __init of_setup_earlycon(unsigned long addr,
 	struct uart_port *port = &early_console_dev.port;
 	const __be32 *val;
 	bool big_endian;
+	u64 addr;
 
 	spin_lock_init(&port->lock);
 	port->iotype = UPIO_MEM;
+	addr = of_flat_dt_translate_address(node);
+	if (addr == OF_BAD_ADDR) {
+		pr_warn("[%s] bad address\n", match->name);
+		return -ENXIO;
+	}
 	port->mapbase = addr;
 	port->uartclk = BASE_BAUD * 16;
-	port->membase = earlycon_map(addr, SZ_4K);
+	port->membase = earlycon_map(port->mapbase, SZ_4K);
 
 	val = of_get_flat_dt_prop(node, "reg-offset", NULL);
 	if (val)
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
index df9ef38..2fbe868 100644
--- a/include/linux/of_fdt.h
+++ b/include/linux/of_fdt.h
@@ -88,7 +88,7 @@ extern void unflatten_device_tree(void);
 extern void unflatten_and_copy_device_tree(void);
 extern void early_init_devtree(void *);
 extern void early_get_first_memblock_info(void *, phys_addr_t *);
-extern u64 fdt_translate_address(const void *blob, int node_offset);
+extern u64 of_flat_dt_translate_address(unsigned long node);
 extern void of_fdt_limit_memory(int limit);
 #else /* CONFIG_OF_FLATTREE */
 static inline void early_init_fdt_scan_reserved_mem(void) {}
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 6d1bed8..cbfcf38 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -359,7 +359,7 @@ extern const struct earlycon_id __earlycon_table_end[];
 #define EARLYCON_DECLARE(_name, fn)	OF_EARLYCON_DECLARE(_name, "", fn)
 
 extern int setup_earlycon(char *buf);
-extern int of_setup_earlycon(unsigned long addr, const struct earlycon_id *match,
+extern int of_setup_earlycon(const struct earlycon_id *match,
 			     unsigned long node,
 			     const char *options);
 
-- 
2.7.0

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

* [PATCH v5 07/11] serial: earlycon: Common log banner for command line and DT
  2016-01-16 21:37   ` [PATCH v5 " Peter Hurley
                       ` (5 preceding siblings ...)
  2016-01-16 21:37     ` [PATCH v5 06/11] of: earlycon: Move address translation to of_setup_earlycon() Peter Hurley
@ 2016-01-16 21:37     ` Peter Hurley
  2016-01-16 21:37     ` [PATCH v5 08/11] serial: earlycon: Show the earlycon "driver" in banner Peter Hurley
                       ` (4 subsequent siblings)
  11 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2016-01-16 21:37 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: Jiri Slaby, linux-serial, linux-kernel, Kevin Cernekee,
	Jon Hunter, Paul Burton, Masahiro Yamada, Sebastian Frias,
	Peter Hurley

Refactor the command line earlycon banner into earlycon_init() so
both earlycon startup methods output an info banner.

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/tty/serial/earlycon.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 24f9adb..ff22200 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -59,6 +59,7 @@ static void __init earlycon_init(struct earlycon_device *device,
 				 const char *name)
 {
 	struct console *earlycon = device->con;
+	struct uart_port *port = &device->port;
 	const char *s;
 	size_t len;
 
@@ -72,6 +73,19 @@ static void __init earlycon_init(struct earlycon_device *device,
 	len = s - name;
 	strlcpy(earlycon->name, name, min(len + 1, sizeof(earlycon->name)));
 	earlycon->data = &early_console_dev;
+
+	if (port->iotype == UPIO_MEM || port->iotype == UPIO_MEM16 ||
+	    port->iotype == UPIO_MEM32 || port->iotype == UPIO_MEM32BE)
+		pr_info("Early serial console at MMIO%s 0x%llx (options '%s')\n",
+			(port->iotype == UPIO_MEM) ? "" :
+			(port->iotype == UPIO_MEM16) ? "16" :
+			(port->iotype == UPIO_MEM32) ? "32" : "32be",
+			(unsigned long long)port->mapbase,
+			device->options);
+	else
+		pr_info("Early serial console at I/O port 0x%lx (options '%s')\n",
+			port->iobase,
+			device->options);
 }
 
 static int __init parse_options(struct earlycon_device *device, char *options)
@@ -110,19 +124,6 @@ static int __init parse_options(struct earlycon_device *device, char *options)
 		strlcpy(device->options, options, length);
 	}
 
-	if (port->iotype == UPIO_MEM || port->iotype == UPIO_MEM16 ||
-	    port->iotype == UPIO_MEM32 || port->iotype == UPIO_MEM32BE)
-		pr_info("Early serial console at MMIO%s 0x%llx (options '%s')\n",
-			(port->iotype == UPIO_MEM) ? "" :
-			(port->iotype == UPIO_MEM16) ? "16" :
-			(port->iotype == UPIO_MEM32) ? "32" : "32be",
-			(unsigned long long)port->mapbase,
-			device->options);
-	else
-		pr_info("Early serial console at I/O port 0x%lx (options '%s')\n",
-			port->iobase,
-			device->options);
-
 	return 0;
 }
 
-- 
2.7.0

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

* [PATCH v5 08/11] serial: earlycon: Show the earlycon "driver" in banner
  2016-01-16 21:37   ` [PATCH v5 " Peter Hurley
                       ` (6 preceding siblings ...)
  2016-01-16 21:37     ` [PATCH v5 07/11] serial: earlycon: Common log banner for command line and DT Peter Hurley
@ 2016-01-16 21:37     ` Peter Hurley
  2016-01-16 21:37     ` [PATCH v5 09/11] serial: 8250_early: Use port->regshift Peter Hurley
                       ` (3 subsequent siblings)
  11 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2016-01-16 21:37 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: Jiri Slaby, linux-serial, linux-kernel, Kevin Cernekee,
	Jon Hunter, Paul Burton, Masahiro Yamada, Sebastian Frias,
	Peter Hurley

Output the earlycon "driver" from the just-parsed console 'name'
and 'index' fields.

NB: ->mapbase is a resource_size_t so use %pa format specifier

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/tty/serial/earlycon.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index ff22200..eec8dfe 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -76,16 +76,16 @@ static void __init earlycon_init(struct earlycon_device *device,
 
 	if (port->iotype == UPIO_MEM || port->iotype == UPIO_MEM16 ||
 	    port->iotype == UPIO_MEM32 || port->iotype == UPIO_MEM32BE)
-		pr_info("Early serial console at MMIO%s 0x%llx (options '%s')\n",
+		pr_info("%s%d at MMIO%s %pa (options '%s')\n",
+			earlycon->name, earlycon->index,
 			(port->iotype == UPIO_MEM) ? "" :
 			(port->iotype == UPIO_MEM16) ? "16" :
 			(port->iotype == UPIO_MEM32) ? "32" : "32be",
-			(unsigned long long)port->mapbase,
-			device->options);
+			&port->mapbase, device->options);
 	else
-		pr_info("Early serial console at I/O port 0x%lx (options '%s')\n",
-			port->iobase,
-			device->options);
+		pr_info("%s%d at I/O port 0x%lx (options '%s')\n",
+			earlycon->name, earlycon->index,
+			port->iobase, device->options);
 }
 
 static int __init parse_options(struct earlycon_device *device, char *options)
-- 
2.7.0

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

* [PATCH v5 09/11] serial: 8250_early: Use port->regshift
  2016-01-16 21:37   ` [PATCH v5 " Peter Hurley
                       ` (7 preceding siblings ...)
  2016-01-16 21:37     ` [PATCH v5 08/11] serial: earlycon: Show the earlycon "driver" in banner Peter Hurley
@ 2016-01-16 21:37     ` Peter Hurley
  2016-01-16 21:37     ` [PATCH v5 10/11] of: earlycon: Log more helpful message if stdout-path node not found Peter Hurley
                       ` (2 subsequent siblings)
  11 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2016-01-16 21:37 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: Jiri Slaby, linux-serial, linux-kernel, Kevin Cernekee,
	Jon Hunter, Paul Burton, Masahiro Yamada, Sebastian Frias,
	Peter Hurley

earlycon initializes struct uart_port::regshift to the correct
value for UPIO_MEM32 already. Use the port field rather than
hard-coded value.

This enables broader support for various i/o access methods in
8250 earlycon (eg., omap8250 earlycon).

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/tty/serial/8250/8250_early.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
index af62131..180143c 100644
--- a/drivers/tty/serial/8250/8250_early.c
+++ b/drivers/tty/serial/8250/8250_early.c
@@ -39,15 +39,17 @@
 
 static unsigned int __init serial8250_early_in(struct uart_port *port, int offset)
 {
+	offset <<= port->regshift;
+
 	switch (port->iotype) {
 	case UPIO_MEM:
 		return readb(port->membase + offset);
 	case UPIO_MEM16:
-		return readw(port->membase + (offset << 1));
+		return readw(port->membase + offset);
 	case UPIO_MEM32:
-		return readl(port->membase + (offset << 2));
+		return readl(port->membase + offset);
 	case UPIO_MEM32BE:
-		return ioread32be(port->membase + (offset << 2));
+		return ioread32be(port->membase + offset);
 	case UPIO_PORT:
 		return inb(port->iobase + offset);
 	default:
@@ -57,18 +59,20 @@ static unsigned int __init serial8250_early_in(struct uart_port *port, int offse
 
 static void __init serial8250_early_out(struct uart_port *port, int offset, int value)
 {
+	offset <<= port->regshift;
+
 	switch (port->iotype) {
 	case UPIO_MEM:
 		writeb(value, port->membase + offset);
 		break;
 	case UPIO_MEM16:
-		writew(value, port->membase + (offset << 1));
+		writew(value, port->membase + offset);
 		break;
 	case UPIO_MEM32:
-		writel(value, port->membase + (offset << 2));
+		writel(value, port->membase + offset);
 		break;
 	case UPIO_MEM32BE:
-		iowrite32be(value, port->membase + (offset << 2));
+		iowrite32be(value, port->membase + offset);
 		break;
 	case UPIO_PORT:
 		outb(value, port->iobase + offset);
-- 
2.7.0

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

* [PATCH v5 10/11] of: earlycon: Log more helpful message if stdout-path node not found
  2016-01-16 21:37   ` [PATCH v5 " Peter Hurley
                       ` (8 preceding siblings ...)
  2016-01-16 21:37     ` [PATCH v5 09/11] serial: 8250_early: Use port->regshift Peter Hurley
@ 2016-01-16 21:37     ` Peter Hurley
  2016-01-16 21:37     ` [PATCH v5 11/11] serial: 8250_omap: Add omap8250 earlycon Peter Hurley
  2016-01-16 23:23     ` [PATCH v6 00/12] Earlycon cleanup Peter Hurley
  11 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2016-01-16 21:37 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: Jiri Slaby, linux-serial, linux-kernel, Kevin Cernekee,
	Jon Hunter, Paul Burton, Masahiro Yamada, Sebastian Frias,
	Peter Hurley

Earlycon may fail to initialize for a variety of reasons, most of
which log the default early param message. If the stdout-path node is
not found, log the path which was not found (and suppress the
default early param message).

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/of/fdt.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 918809e..e2295b2 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -820,11 +820,14 @@ static int __init early_init_dt_scan_chosen_serial(void)
 	q = strchrnul(p, ':');
 	if (*q != '\0')
 		options = q + 1;
+	l = q - p;
 
 	/* Get the node specified by stdout-path */
-	offset = fdt_path_offset_namelen(fdt, p, q - p);
-	if (offset < 0)
-		return -ENODEV;
+	offset = fdt_path_offset_namelen(fdt, p, l);
+	if (offset < 0) {
+		pr_warn("earlycon: stdout-path %.*s not found\n", l, p);
+		return 0;
+	}
 
 	for (match = __earlycon_table; match < __earlycon_table_end; match++) {
 		if (!match->compatible[0])
-- 
2.7.0

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

* [PATCH v5 11/11] serial: 8250_omap: Add omap8250 earlycon
  2016-01-16 21:37   ` [PATCH v5 " Peter Hurley
                       ` (9 preceding siblings ...)
  2016-01-16 21:37     ` [PATCH v5 10/11] of: earlycon: Log more helpful message if stdout-path node not found Peter Hurley
@ 2016-01-16 21:37     ` Peter Hurley
  2016-01-16 23:23     ` [PATCH v6 00/12] Earlycon cleanup Peter Hurley
  11 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2016-01-16 21:37 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: Jiri Slaby, linux-serial, linux-kernel, Kevin Cernekee,
	Jon Hunter, Paul Burton, Masahiro Yamada, Sebastian Frias,
	Peter Hurley

Add DT earlycon for 8250_omap driver. This boot console is included
for kernels built with CONFIG_SERIAL_EARLYCON=y, CONFIG_OF=y,
CONFIG_SERIAL_8250_OMAP=y, and CONFIG_OF_EARLY_FLATTREE=y.

This boot console is enabled with the command line option "earlycon"
(without "=<name>...") when the DT 'stdout-path' property matches a
compatible uart. For example,

/ {
   chosen {
        stdout-path = "serial0:115200";
   };

   ....

   aliases {
        serial0 = &uart0;
   };

   ....

   ocp : ocp {
        uart0 : serial@44e09000 {
             compatible = "ti,omap3-uart";
        }
   };
};

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/tty/serial/8250/8250_early.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
index 180143c..3b3dbdc 100644
--- a/drivers/tty/serial/8250/8250_early.c
+++ b/drivers/tty/serial/8250/8250_early.c
@@ -149,3 +149,24 @@ 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_OMAP
+
+static int __init early_omap8250_setup(struct earlycon_device *device,
+				       const char *options)
+{
+	struct uart_port *port = &device->port;
+
+	if (!(device->port.membase || device->port.iobase))
+		return -ENODEV;
+
+	port->regshift = 2;
+	device->con->write = early_serial8250_write;
+	return 0;
+}
+
+OF_EARLYCON_DECLARE(omap8250, "ti,omap2-uart", early_omap8250_setup);
+OF_EARLYCON_DECLARE(omap8250, "ti,omap3-uart", early_omap8250_setup);
+OF_EARLYCON_DECLARE(omap8250, "ti,omap4-uart", early_omap8250_setup);
+
+#endif
-- 
2.7.0

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

* Re: [PATCH v5 05/11] of: earlycon: Initialize port fields from DT properties
  2016-01-16 21:37     ` [PATCH v5 05/11] of: earlycon: Initialize port fields from DT properties Peter Hurley
@ 2016-01-16 21:54       ` kbuild test robot
  0 siblings, 0 replies; 73+ messages in thread
From: kbuild test robot @ 2016-01-16 21:54 UTC (permalink / raw)
  To: Peter Hurley
  Cc: kbuild-all, Greg Kroah-Hartman, Rob Herring, Grant Likely,
	Jiri Slaby, linux-serial, linux-kernel, Kevin Cernekee,
	Jon Hunter, Paul Burton, Masahiro Yamada, Sebastian Frias,
	Peter Hurley

[-- Attachment #1: Type: text/plain, Size: 2846 bytes --]

Hi Peter,

[auto build test ERROR on tty/tty-testing]
[also build test ERROR on v4.4 next-20160115]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Peter-Hurley/Earlycon-cleanup/20160117-054602
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-testing
config: x86_64-randconfig-x012-201603 (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All error/warnings (new ones prefixed by >>):

   drivers/tty/serial/earlycon.c: In function 'of_setup_earlycon':
>> drivers/tty/serial/earlycon.c:235:8: error: implicit declaration of function 'of_get_flat_dt_prop' [-Werror=implicit-function-declaration]
     val = of_get_flat_dt_prop(node, "reg-offset", NULL);
           ^
>> drivers/tty/serial/earlycon.c:235:6: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
     val = of_get_flat_dt_prop(node, "reg-offset", NULL);
         ^
   drivers/tty/serial/earlycon.c:238:6: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
     val = of_get_flat_dt_prop(node, "reg-shift", NULL);
         ^
>> drivers/tty/serial/earlycon.c:241:61: warning: comparison between pointer and integer
     big_endian = of_get_flat_dt_prop(node, "big-endian", NULL) != NULL ||
                                                                ^
   drivers/tty/serial/earlycon.c:243:53: warning: comparison between pointer and integer
       of_get_flat_dt_prop(node, "native-endian", NULL) != NULL);
                                                        ^
   drivers/tty/serial/earlycon.c:244:6: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
     val = of_get_flat_dt_prop(node, "reg-io-width", NULL);
         ^
   cc1: some warnings being treated as errors

vim +/of_get_flat_dt_prop +235 drivers/tty/serial/earlycon.c

   229		spin_lock_init(&port->lock);
   230		port->iotype = UPIO_MEM;
   231		port->mapbase = addr;
   232		port->uartclk = BASE_BAUD * 16;
   233		port->membase = earlycon_map(addr, SZ_4K);
   234	
 > 235		val = of_get_flat_dt_prop(node, "reg-offset", NULL);
   236		if (val)
   237			port->mapbase += be32_to_cpu(*val);
   238		val = of_get_flat_dt_prop(node, "reg-shift", NULL);
   239		if (val)
   240			port->regshift = be32_to_cpu(*val);
 > 241		big_endian = of_get_flat_dt_prop(node, "big-endian", NULL) != NULL ||
   242			(IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) &&
   243			 of_get_flat_dt_prop(node, "native-endian", NULL) != NULL);
   244		val = of_get_flat_dt_prop(node, "reg-io-width", NULL);

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 21330 bytes --]

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

* Re: [PATCH v5 06/11] of: earlycon: Move address translation to of_setup_earlycon()
  2016-01-16 21:37     ` [PATCH v5 06/11] of: earlycon: Move address translation to of_setup_earlycon() Peter Hurley
@ 2016-01-16 22:02       ` kbuild test robot
  0 siblings, 0 replies; 73+ messages in thread
From: kbuild test robot @ 2016-01-16 22:02 UTC (permalink / raw)
  To: Peter Hurley
  Cc: kbuild-all, Greg Kroah-Hartman, Rob Herring, Grant Likely,
	Jiri Slaby, linux-serial, linux-kernel, Kevin Cernekee,
	Jon Hunter, Paul Burton, Masahiro Yamada, Sebastian Frias,
	Peter Hurley

[-- Attachment #1: Type: text/plain, Size: 2670 bytes --]

Hi Peter,

[auto build test ERROR on tty/tty-testing]
[also build test ERROR on v4.4 next-20160115]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Peter-Hurley/Earlycon-cleanup/20160117-054602
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-testing
config: x86_64-randconfig-x012-201603 (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

   drivers/tty/serial/earlycon.c: In function 'of_setup_earlycon':
>> drivers/tty/serial/earlycon.c:232:9: error: implicit declaration of function 'of_flat_dt_translate_address' [-Werror=implicit-function-declaration]
     addr = of_flat_dt_translate_address(node);
            ^
   drivers/tty/serial/earlycon.c:241:8: error: implicit declaration of function 'of_get_flat_dt_prop' [-Werror=implicit-function-declaration]
     val = of_get_flat_dt_prop(node, "reg-offset", NULL);
           ^
   drivers/tty/serial/earlycon.c:241:6: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
     val = of_get_flat_dt_prop(node, "reg-offset", NULL);
         ^
   drivers/tty/serial/earlycon.c:244:6: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
     val = of_get_flat_dt_prop(node, "reg-shift", NULL);
         ^
   drivers/tty/serial/earlycon.c:247:61: warning: comparison between pointer and integer
     big_endian = of_get_flat_dt_prop(node, "big-endian", NULL) != NULL ||
                                                                ^
   drivers/tty/serial/earlycon.c:249:53: warning: comparison between pointer and integer
       of_get_flat_dt_prop(node, "native-endian", NULL) != NULL);
                                                        ^
   drivers/tty/serial/earlycon.c:250:6: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
     val = of_get_flat_dt_prop(node, "reg-io-width", NULL);
         ^
   cc1: some warnings being treated as errors

vim +/of_flat_dt_translate_address +232 drivers/tty/serial/earlycon.c

   226		const __be32 *val;
   227		bool big_endian;
   228		u64 addr;
   229	
   230		spin_lock_init(&port->lock);
   231		port->iotype = UPIO_MEM;
 > 232		addr = of_flat_dt_translate_address(node);
   233		if (addr == OF_BAD_ADDR) {
   234			pr_warn("[%s] bad address\n", match->name);
   235			return -ENXIO;

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 21330 bytes --]

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

* [PATCH v6 00/12] Earlycon cleanup
  2016-01-16 21:37   ` [PATCH v5 " Peter Hurley
                       ` (10 preceding siblings ...)
  2016-01-16 21:37     ` [PATCH v5 11/11] serial: 8250_omap: Add omap8250 earlycon Peter Hurley
@ 2016-01-16 23:23     ` Peter Hurley
  2016-01-16 23:23       ` [PATCH v6 01/12] of: earlycon: of_setup_earlycon() requires CONFIG_OF_EARLY_FLATTREE Peter Hurley
                         ` (12 more replies)
  11 siblings, 13 replies; 73+ messages in thread
From: Peter Hurley @ 2016-01-16 23:23 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: Jiri Slaby, linux-serial, linux-kernel, Kevin Cernekee,
	Jon Hunter, Paul Burton, Masahiro Yamada, Sebastian Frias,
	Peter Hurley

Hi Greg, Grant & Rob,

This patch series is a rebase of the v3 from April last year.

This patch series builds on my earlier "Extensible console matching &
direct earlycon" to add several useful features to earlycon:
* Proper port i/o configuration from DT node with of_serial properties
  (such as reg-io-width, reg-shift and reg-offset, and endianness)
* Proper console name & index initialization from earlycon name
  (for both command line and DT-defined earlycons)
* Support for DT 'stdout-path' options pass-through to earlycon setup
* Improved log messages for troubleshooting
* Support for multiple OF earlycon declarations so different
  compatible strings can specify the same OF earlycon

* Changes from v3
  - Added 32-bit big-endian support
  - Removed the omap8250 earlycon (will follow later)
* Changes from v4
  - Rolled in Rob's acks (thanks for reviewing this series)
  - Removed the conditional guard of of_fdt.h header inclusion (Rob's comment)
  - Left in the omap8250 earlycon (rebased w/o the wip so applies cleanly)
* Changes from v5
  - Builds :/
    "of: earlycon: of_setup_earlycon() requires CONFIG_OF_EARLY_FLATREE"
    didn't make it into v4 so I left it out of v5. That'll teach me.

Regards,

Peter Hurley (12):
  of: earlycon: of_setup_earlycon() requires CONFIG_OF_EARLY_FLATTREE
  earlycon: Use common framework for earlycon declarations
  serial: earlycon: Fixup earlycon console name and index
  of: earlycon: Fixup earlycon console name and index
  of: earlycon: Add options string handling
  of: earlycon: Initialize port fields from DT properties
  of: earlycon: Move address translation to of_setup_earlycon()
  serial: earlycon: Common log banner for command line and DT
  serial: earlycon: Show the earlycon "driver" in banner
  serial: 8250_early: Use port->regshift
  of: earlycon: Log more helpful message if stdout-path node not found
  serial: 8250_omap: Add omap8250 earlycon

 drivers/of/fdt.c                     |  32 +++++-----
 drivers/of/fdt_address.c             |  11 +++-
 drivers/tty/serial/8250/8250_early.c |  37 +++++++++--
 drivers/tty/serial/amba-pl011.c      |   1 -
 drivers/tty/serial/arc_uart.c        |   1 -
 drivers/tty/serial/earlycon.c        | 118 ++++++++++++++++++++++++++---------
 drivers/tty/serial/msm_serial.c      |   2 -
 drivers/tty/serial/samsung.c         |   6 --
 drivers/tty/serial/sprd_serial.c     |   2 -
 include/asm-generic/vmlinux.lds.h    |   6 +-
 include/linux/of_fdt.h               |   2 +-
 include/linux/serial_core.h          |  25 +++++---
 12 files changed, 162 insertions(+), 81 deletions(-)

-- 
2.7.0

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

* [PATCH v6 01/12] of: earlycon: of_setup_earlycon() requires CONFIG_OF_EARLY_FLATTREE
  2016-01-16 23:23     ` [PATCH v6 00/12] Earlycon cleanup Peter Hurley
@ 2016-01-16 23:23       ` Peter Hurley
  2016-01-16 23:23       ` [PATCH v6 02/12] earlycon: Use common framework for earlycon declarations Peter Hurley
                         ` (11 subsequent siblings)
  12 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2016-01-16 23:23 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: Jiri Slaby, linux-serial, linux-kernel, Kevin Cernekee,
	Jon Hunter, Paul Burton, Masahiro Yamada, Sebastian Frias,
	Peter Hurley

DT earlycon is only supported for CONFIG_OF_EARLY_FLATTREE=y; exclude
of_setup_earlycon() if not defined.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/tty/serial/earlycon.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 3f24236..54419a2 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -204,6 +204,8 @@ static int __init param_setup_earlycon(char *buf)
 }
 early_param("earlycon", param_setup_earlycon);
 
+#ifdef CONFIG_OF_EARLY_FLATTREE
+
 int __init of_setup_earlycon(unsigned long addr,
 			     int (*setup)(struct earlycon_device *, const char *))
 {
@@ -227,3 +229,5 @@ int __init of_setup_earlycon(unsigned long addr,
 	register_console(early_console_dev.con);
 	return 0;
 }
+
+#endif /* CONFIG_OF_EARLY_FLATTREE */
-- 
2.7.0

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

* [PATCH v6 02/12] earlycon: Use common framework for earlycon declarations
  2016-01-16 23:23     ` [PATCH v6 00/12] Earlycon cleanup Peter Hurley
  2016-01-16 23:23       ` [PATCH v6 01/12] of: earlycon: of_setup_earlycon() requires CONFIG_OF_EARLY_FLATTREE Peter Hurley
@ 2016-01-16 23:23       ` Peter Hurley
  2016-01-16 23:23       ` [PATCH v6 03/12] serial: earlycon: Fixup earlycon console name and index Peter Hurley
                         ` (10 subsequent siblings)
  12 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2016-01-16 23:23 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: Jiri Slaby, linux-serial, linux-kernel, Kevin Cernekee,
	Jon Hunter, Paul Burton, Masahiro Yamada, Sebastian Frias,
	Peter Hurley

Use a single common table of struct earlycon_id for both command line
and devicetree. Re-define OF_EARLYCON_DECLARE() macro to instance a
unique earlycon declaration (the declaration is only guaranteed to be
unique within a compilation unit; separate compilation units must still
use unique earlycon names).

The semantics of OF_EARLYCON_DECLARE() is different; it declares an
earlycon which can matched either on the command line or by devicetree.
EARLYCON_DECLARE() is semantically unchanged; it declares an earlycon
which is matched by command line only. Remove redundant instances of
EARLYCON_DECLARE().

This enables all earlycons to properly initialize struct console
with the appropriate name and index, which improves diagnostics and
enables direct earlycon-to-console handoff.

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/of/fdt.c                  | 14 +++++++-------
 drivers/tty/serial/amba-pl011.c   |  1 -
 drivers/tty/serial/arc_uart.c     |  1 -
 drivers/tty/serial/earlycon.c     | 10 +---------
 drivers/tty/serial/msm_serial.c   |  2 --
 drivers/tty/serial/samsung.c      |  6 ------
 drivers/tty/serial/sprd_serial.c  |  2 --
 include/asm-generic/vmlinux.lds.h |  6 ++----
 include/linux/serial_core.h       | 22 +++++++++++++---------
 9 files changed, 23 insertions(+), 41 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 655f79d..1686118 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -796,14 +796,13 @@ static inline void early_init_dt_check_for_initrd(unsigned long node)
 #endif /* CONFIG_BLK_DEV_INITRD */
 
 #ifdef CONFIG_SERIAL_EARLYCON
-extern struct of_device_id __earlycon_of_table[];
 
 static int __init early_init_dt_scan_chosen_serial(void)
 {
 	int offset;
 	const char *p;
 	int l;
-	const struct of_device_id *match = __earlycon_of_table;
+	const struct earlycon_id *match;
 	const void *fdt = initial_boot_params;
 
 	offset = fdt_path_offset(fdt, "/chosen");
@@ -826,19 +825,20 @@ static int __init early_init_dt_scan_chosen_serial(void)
 	if (offset < 0)
 		return -ENODEV;
 
-	while (match->compatible[0]) {
+	for (match = __earlycon_table; match < __earlycon_table_end; match++) {
 		u64 addr;
 
-		if (fdt_node_check_compatible(fdt, offset, match->compatible)) {
-			match++;
+		if (!match->compatible[0])
+			continue;
+
+		if (fdt_node_check_compatible(fdt, offset, match->compatible))
 			continue;
-		}
 
 		addr = fdt_translate_address(fdt, offset);
 		if (addr == OF_BAD_ADDR)
 			return -ENXIO;
 
-		of_setup_earlycon(addr, match->data);
+		of_setup_earlycon(addr, match->setup);
 		return 0;
 	}
 	return -ENODEV;
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index c0da0cc..de84602 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -2327,7 +2327,6 @@ static int __init pl011_early_console_setup(struct earlycon_device *device,
 	device->con->write = pl011_early_write;
 	return 0;
 }
-EARLYCON_DECLARE(pl011, pl011_early_console_setup);
 OF_EARLYCON_DECLARE(pl011, "arm,pl011", pl011_early_console_setup);
 
 #else
diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c
index 03ebe40..3a1de5c 100644
--- a/drivers/tty/serial/arc_uart.c
+++ b/drivers/tty/serial/arc_uart.c
@@ -576,7 +576,6 @@ static int __init arc_early_console_setup(struct earlycon_device *dev,
 	dev->con->write = arc_early_serial_write;
 	return 0;
 }
-EARLYCON_DECLARE(arc_uart, arc_early_console_setup);
 OF_EARLYCON_DECLARE(arc_uart, "snps,arc-uart", arc_early_console_setup);
 
 #endif	/* CONFIG_SERIAL_ARC_CONSOLE */
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 54419a2..d50b700 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -19,7 +19,6 @@
 #include <linux/io.h>
 #include <linux/serial_core.h>
 #include <linux/sizes.h>
-#include <linux/mod_devicetable.h>
 
 #ifdef CONFIG_FIX_EARLYCON_MEM
 #include <asm/fixmap.h>
@@ -37,13 +36,6 @@ static struct earlycon_device early_console_dev = {
 	.con = &early_con,
 };
 
-extern struct earlycon_id __earlycon_table[];
-static const struct earlycon_id __earlycon_table_sentinel
-	__used __section(__earlycon_table_end);
-
-static const struct of_device_id __earlycon_of_table_sentinel
-	__used __section(__earlycon_of_table_end);
-
 static void __iomem * __init earlycon_map(unsigned long paddr, size_t size)
 {
 	void __iomem *base;
@@ -166,7 +158,7 @@ int __init setup_earlycon(char *buf)
 	if (early_con.flags & CON_ENABLED)
 		return -EALREADY;
 
-	for (match = __earlycon_table; match->name[0]; match++) {
+	for (match = __earlycon_table; match < __earlycon_table_end; match++) {
 		size_t len = strlen(match->name);
 
 		if (strncmp(buf, match->name, len))
diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
index dcde955..96d3ce8 100644
--- a/drivers/tty/serial/msm_serial.c
+++ b/drivers/tty/serial/msm_serial.c
@@ -1478,7 +1478,6 @@ msm_serial_early_console_setup(struct earlycon_device *device, const char *opt)
 	device->con->write = msm_serial_early_write;
 	return 0;
 }
-EARLYCON_DECLARE(msm_serial, msm_serial_early_console_setup);
 OF_EARLYCON_DECLARE(msm_serial, "qcom,msm-uart",
 		    msm_serial_early_console_setup);
 
@@ -1500,7 +1499,6 @@ msm_serial_early_console_setup_dm(struct earlycon_device *device,
 	device->con->write = msm_serial_early_write_dm;
 	return 0;
 }
-EARLYCON_DECLARE(msm_serial_dm, msm_serial_early_console_setup_dm);
 OF_EARLYCON_DECLARE(msm_serial_dm, "qcom,msm-uartdm",
 		    msm_serial_early_console_setup_dm);
 
diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
index d72cd73..fd9c47f 100644
--- a/drivers/tty/serial/samsung.c
+++ b/drivers/tty/serial/samsung.c
@@ -2451,7 +2451,6 @@ static int __init s3c2410_early_console_setup(struct earlycon_device *device,
 }
 OF_EARLYCON_DECLARE(s3c2410, "samsung,s3c2410-uart",
 			s3c2410_early_console_setup);
-EARLYCON_DECLARE(s3c2410, s3c2410_early_console_setup);
 
 /* S3C2412, S3C2440, S3C64xx */
 static struct samsung_early_console_data s3c2440_early_console_data = {
@@ -2470,9 +2469,6 @@ OF_EARLYCON_DECLARE(s3c2440, "samsung,s3c2440-uart",
 			s3c2440_early_console_setup);
 OF_EARLYCON_DECLARE(s3c6400, "samsung,s3c6400-uart",
 			s3c2440_early_console_setup);
-EARLYCON_DECLARE(s3c2412, s3c2440_early_console_setup);
-EARLYCON_DECLARE(s3c2440, s3c2440_early_console_setup);
-EARLYCON_DECLARE(s3c6400, s3c2440_early_console_setup);
 
 /* S5PV210, EXYNOS */
 static struct samsung_early_console_data s5pv210_early_console_data = {
@@ -2489,8 +2485,6 @@ OF_EARLYCON_DECLARE(s5pv210, "samsung,s5pv210-uart",
 			s5pv210_early_console_setup);
 OF_EARLYCON_DECLARE(exynos4210, "samsung,exynos4210-uart",
 			s5pv210_early_console_setup);
-EARLYCON_DECLARE(s5pv210, s5pv210_early_console_setup);
-EARLYCON_DECLARE(exynos4210, s5pv210_early_console_setup);
 #endif
 
 MODULE_ALIAS("platform:samsung-uart");
diff --git a/drivers/tty/serial/sprd_serial.c b/drivers/tty/serial/sprd_serial.c
index ef26c4a..1897106 100644
--- a/drivers/tty/serial/sprd_serial.c
+++ b/drivers/tty/serial/sprd_serial.c
@@ -624,8 +624,6 @@ static int __init sprd_early_console_setup(
 	device->con->write = sprd_early_write;
 	return 0;
 }
-
-EARLYCON_DECLARE(sprd_serial, sprd_early_console_setup);
 OF_EARLYCON_DECLARE(sprd_serial, "sprd,sc9836-uart",
 		    sprd_early_console_setup);
 
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index c4bd0e2..e9a81a6 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -157,7 +157,7 @@
 #define EARLYCON_TABLE() STRUCT_ALIGN();			\
 			 VMLINUX_SYMBOL(__earlycon_table) = .;	\
 			 *(__earlycon_table)			\
-			 *(__earlycon_table_end)
+			 VMLINUX_SYMBOL(__earlycon_table_end) = .;
 #else
 #define EARLYCON_TABLE()
 #endif
@@ -179,7 +179,6 @@
 #define RESERVEDMEM_OF_TABLES()	OF_TABLE(CONFIG_OF_RESERVED_MEM, reservedmem)
 #define CPU_METHOD_OF_TABLES()	OF_TABLE(CONFIG_SMP, cpu_method)
 #define CPUIDLE_METHOD_OF_TABLES() OF_TABLE(CONFIG_CPU_IDLE, cpuidle_method)
-#define EARLYCON_OF_TABLES()	OF_TABLE(CONFIG_SERIAL_EARLYCON, earlycon)
 
 #ifdef CONFIG_ACPI
 #define ACPI_PROBE_TABLE(name)						\
@@ -526,8 +525,7 @@
 	IRQCHIP_OF_MATCH_TABLE()					\
 	ACPI_PROBE_TABLE(irqchip)					\
 	ACPI_PROBE_TABLE(clksrc)					\
-	EARLYCON_TABLE()						\
-	EARLYCON_OF_TABLES()
+	EARLYCON_TABLE()
 
 #define INIT_TEXT							\
 	*(.init.text)							\
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index e03d6ba..25e0514 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -342,22 +342,26 @@ struct earlycon_device {
 
 struct earlycon_id {
 	char	name[16];
+	char	compatible[128];
 	int	(*setup)(struct earlycon_device *, const char *options);
 } __aligned(32);
 
+extern const struct earlycon_id __earlycon_table[];
+extern const struct earlycon_id __earlycon_table_end[];
+
+#define OF_EARLYCON_DECLARE(_name, compat, fn)				\
+	static const struct earlycon_id __UNIQUE_ID(__earlycon_##_name)	\
+	     __used __section(__earlycon_table)				\
+		= { .name = __stringify(_name),				\
+		    .compatible = compat,				\
+		    .setup = fn  }
+
+#define EARLYCON_DECLARE(_name, fn)	OF_EARLYCON_DECLARE(_name, "", fn)
+
 extern int setup_earlycon(char *buf);
 extern int of_setup_earlycon(unsigned long addr,
 			     int (*setup)(struct earlycon_device *, const char *));
 
-#define EARLYCON_DECLARE(_name, func)					\
-	static const struct earlycon_id __earlycon_##_name		\
-		__used __section(__earlycon_table)			\
-		 = { .name  = __stringify(_name),			\
-		     .setup = func  }
-
-#define OF_EARLYCON_DECLARE(name, compat, fn)				\
-	_OF_DECLARE(earlycon, name, compat, fn, void *)
-
 struct uart_port *uart_get_console(struct uart_port *ports, int nr,
 				   struct console *c);
 int uart_parse_earlycon(char *p, unsigned char *iotype, unsigned long *addr,
-- 
2.7.0

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

* [PATCH v6 03/12] serial: earlycon: Fixup earlycon console name and index
  2016-01-16 23:23     ` [PATCH v6 00/12] Earlycon cleanup Peter Hurley
  2016-01-16 23:23       ` [PATCH v6 01/12] of: earlycon: of_setup_earlycon() requires CONFIG_OF_EARLY_FLATTREE Peter Hurley
  2016-01-16 23:23       ` [PATCH v6 02/12] earlycon: Use common framework for earlycon declarations Peter Hurley
@ 2016-01-16 23:23       ` Peter Hurley
  2016-01-16 23:23       ` [PATCH v6 04/12] of: " Peter Hurley
                         ` (9 subsequent siblings)
  12 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2016-01-16 23:23 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: Jiri Slaby, linux-serial, linux-kernel, Kevin Cernekee,
	Jon Hunter, Paul Burton, Masahiro Yamada, Sebastian Frias,
	Peter Hurley

Properly initialize the struct console 'name' and 'index' fields for
the registering earlycon. For earlycons w/o trailing numerals, the
index is set to 0; otherwise, the index is set to the value of the
trailing numeral. For example, the 'exynos4210' earlycon name == "exynos"
and index == 4210. Earlycons with embedded numerals will have all
non-trailing numerals as part of the name; for example, the 's3c2412'
earlycon name == "s3c" and index == 2412.

This ackward scheme was initially added for the uart8250 earlycon;
adopt this scheme for the other earlycon "drivers".

Introduce earlycon_init() which performs the string scanning and
initializes the name and index fields; encapsulate the other console
field initializations within.

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/tty/serial/earlycon.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index d50b700..90b064f 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -27,9 +27,9 @@
 #include <asm/serial.h>
 
 static struct console early_con = {
-	.name =		"uart", /* 8250 console switch requires this name */
+	.name =		"uart",		/* fixed up at earlycon registration */
 	.flags =	CON_PRINTBUFFER | CON_BOOT,
-	.index =	-1,
+	.index =	0,
 };
 
 static struct earlycon_device early_console_dev = {
@@ -53,6 +53,25 @@ static void __iomem * __init earlycon_map(unsigned long paddr, size_t size)
 	return base;
 }
 
+static void __init earlycon_init(struct earlycon_device *device,
+				 const char *name)
+{
+	struct console *earlycon = device->con;
+	const char *s;
+	size_t len;
+
+	/* scan backwards from end of string for first non-numeral */
+	for (s = name + strlen(name);
+	     s > name && s[-1] >= '0' && s[-1] <= '9';
+	     s--)
+		;
+	if (*s)
+		earlycon->index = simple_strtoul(s, NULL, 10);
+	len = s - name;
+	strlcpy(earlycon->name, name, min(len + 1, sizeof(earlycon->name)));
+	earlycon->data = &early_console_dev;
+}
+
 static int __init parse_options(struct earlycon_device *device, char *options)
 {
 	struct uart_port *port = &device->port;
@@ -119,7 +138,7 @@ static int __init register_earlycon(char *buf, const struct earlycon_id *match)
 	if (port->mapbase)
 		port->membase = earlycon_map(port->mapbase, 64);
 
-	early_console_dev.con->data = &early_console_dev;
+	earlycon_init(&early_console_dev, match->name);
 	err = match->setup(&early_console_dev, buf);
 	if (err < 0)
 		return err;
-- 
2.7.0

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

* [PATCH v6 04/12] of: earlycon: Fixup earlycon console name and index
  2016-01-16 23:23     ` [PATCH v6 00/12] Earlycon cleanup Peter Hurley
                         ` (2 preceding siblings ...)
  2016-01-16 23:23       ` [PATCH v6 03/12] serial: earlycon: Fixup earlycon console name and index Peter Hurley
@ 2016-01-16 23:23       ` Peter Hurley
  2016-01-16 23:23       ` [PATCH v6 05/12] of: earlycon: Add options string handling Peter Hurley
                         ` (8 subsequent siblings)
  12 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2016-01-16 23:23 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: Jiri Slaby, linux-serial, linux-kernel, Kevin Cernekee,
	Jon Hunter, Paul Burton, Masahiro Yamada, Sebastian Frias,
	Peter Hurley

Use the console name embedded in the OF earlycon table by the
OF_EARLYCON_DECLARE() macro to initialize the struct console 'name'
and 'index' fields.

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/of/fdt.c              | 2 +-
 drivers/tty/serial/earlycon.c | 6 +++---
 include/linux/serial_core.h   | 3 +--
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 1686118..ec14595 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -838,7 +838,7 @@ static int __init early_init_dt_scan_chosen_serial(void)
 		if (addr == OF_BAD_ADDR)
 			return -ENXIO;
 
-		of_setup_earlycon(addr, match->setup);
+		of_setup_earlycon(addr, match);
 		return 0;
 	}
 	return -ENODEV;
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 90b064f..47e54de 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -218,7 +218,7 @@ early_param("earlycon", param_setup_earlycon);
 #ifdef CONFIG_OF_EARLY_FLATTREE
 
 int __init of_setup_earlycon(unsigned long addr,
-			     int (*setup)(struct earlycon_device *, const char *))
+			     const struct earlycon_id *match)
 {
 	int err;
 	struct uart_port *port = &early_console_dev.port;
@@ -229,8 +229,8 @@ int __init of_setup_earlycon(unsigned long addr,
 	port->uartclk = BASE_BAUD * 16;
 	port->membase = earlycon_map(addr, SZ_4K);
 
-	early_console_dev.con->data = &early_console_dev;
-	err = setup(&early_console_dev, NULL);
+	earlycon_init(&early_console_dev, match->name);
+	err = match->setup(&early_console_dev, NULL);
 	if (err < 0)
 		return err;
 	if (!early_console_dev.con->write)
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 25e0514..63fdb55 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -359,8 +359,7 @@ extern const struct earlycon_id __earlycon_table_end[];
 #define EARLYCON_DECLARE(_name, fn)	OF_EARLYCON_DECLARE(_name, "", fn)
 
 extern int setup_earlycon(char *buf);
-extern int of_setup_earlycon(unsigned long addr,
-			     int (*setup)(struct earlycon_device *, const char *));
+extern int of_setup_earlycon(unsigned long addr, const struct earlycon_id *match);
 
 struct uart_port *uart_get_console(struct uart_port *ports, int nr,
 				   struct console *c);
-- 
2.7.0

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

* [PATCH v6 05/12] of: earlycon: Add options string handling
  2016-01-16 23:23     ` [PATCH v6 00/12] Earlycon cleanup Peter Hurley
                         ` (3 preceding siblings ...)
  2016-01-16 23:23       ` [PATCH v6 04/12] of: " Peter Hurley
@ 2016-01-16 23:23       ` Peter Hurley
  2016-01-16 23:23       ` [PATCH v6 06/12] of: earlycon: Initialize port fields from DT properties Peter Hurley
                         ` (7 subsequent siblings)
  12 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2016-01-16 23:23 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: Jiri Slaby, linux-serial, linux-kernel, Kevin Cernekee,
	Jon Hunter, Paul Burton, Masahiro Yamada, Sebastian Frias,
	Peter Hurley

Pass-through any options string in the 'stdout-path' property to the
earlycon "driver" setup.

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/of/fdt.c              | 11 ++++++-----
 drivers/tty/serial/earlycon.c |  9 +++++++--
 include/linux/serial_core.h   |  3 ++-
 3 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index ec14595..cfd3b35 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -800,7 +800,7 @@ static inline void early_init_dt_check_for_initrd(unsigned long node)
 static int __init early_init_dt_scan_chosen_serial(void)
 {
 	int offset;
-	const char *p;
+	const char *p, *q, *options = NULL;
 	int l;
 	const struct earlycon_id *match;
 	const void *fdt = initial_boot_params;
@@ -817,11 +817,12 @@ static int __init early_init_dt_scan_chosen_serial(void)
 	if (!p || !l)
 		return -ENOENT;
 
-	/* Remove console options if present */
-	l = strchrnul(p, ':') - p;
+	q = strchrnul(p, ':');
+	if (*q != '\0')
+		options = q + 1;
 
 	/* Get the node specified by stdout-path */
-	offset = fdt_path_offset_namelen(fdt, p, l);
+	offset = fdt_path_offset_namelen(fdt, p, q - p);
 	if (offset < 0)
 		return -ENODEV;
 
@@ -838,7 +839,7 @@ static int __init early_init_dt_scan_chosen_serial(void)
 		if (addr == OF_BAD_ADDR)
 			return -ENXIO;
 
-		of_setup_earlycon(addr, match);
+		of_setup_earlycon(addr, match, options);
 		return 0;
 	}
 	return -ENODEV;
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 47e54de..7509ee34d 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -218,7 +218,8 @@ early_param("earlycon", param_setup_earlycon);
 #ifdef CONFIG_OF_EARLY_FLATTREE
 
 int __init of_setup_earlycon(unsigned long addr,
-			     const struct earlycon_id *match)
+			     const struct earlycon_id *match,
+			     const char *options)
 {
 	int err;
 	struct uart_port *port = &early_console_dev.port;
@@ -229,8 +230,12 @@ int __init of_setup_earlycon(unsigned long addr,
 	port->uartclk = BASE_BAUD * 16;
 	port->membase = earlycon_map(addr, SZ_4K);
 
+	if (options) {
+		strlcpy(early_console_dev.options, options,
+			sizeof(early_console_dev.options));
+	}
 	earlycon_init(&early_console_dev, match->name);
-	err = match->setup(&early_console_dev, NULL);
+	err = match->setup(&early_console_dev, options);
 	if (err < 0)
 		return err;
 	if (!early_console_dev.con->write)
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 63fdb55..62a4df0 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -359,7 +359,8 @@ extern const struct earlycon_id __earlycon_table_end[];
 #define EARLYCON_DECLARE(_name, fn)	OF_EARLYCON_DECLARE(_name, "", fn)
 
 extern int setup_earlycon(char *buf);
-extern int of_setup_earlycon(unsigned long addr, const struct earlycon_id *match);
+extern int of_setup_earlycon(unsigned long addr, const struct earlycon_id *match,
+			     const char *options);
 
 struct uart_port *uart_get_console(struct uart_port *ports, int nr,
 				   struct console *c);
-- 
2.7.0

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

* [PATCH v6 06/12] of: earlycon: Initialize port fields from DT properties
  2016-01-16 23:23     ` [PATCH v6 00/12] Earlycon cleanup Peter Hurley
                         ` (4 preceding siblings ...)
  2016-01-16 23:23       ` [PATCH v6 05/12] of: earlycon: Add options string handling Peter Hurley
@ 2016-01-16 23:23       ` Peter Hurley
  2016-01-16 23:23       ` [PATCH v6 07/12] of: earlycon: Move address translation to of_setup_earlycon() Peter Hurley
                         ` (6 subsequent siblings)
  12 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2016-01-16 23:23 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: Jiri Slaby, linux-serial, linux-kernel, Kevin Cernekee,
	Jon Hunter, Paul Burton, Masahiro Yamada, Sebastian Frias,
	Peter Hurley

Read the optional "reg-offset", "reg-shift", "reg-io-width" and endianness
properties and initialize the respective struct uart_port field if found.

NB: These bindings are common to several drivers and the values merely
indicate the default value; the registering earlycon setup() method can
simply override the values if required.

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/of/fdt.c              |  2 +-
 drivers/tty/serial/earlycon.c | 31 +++++++++++++++++++++++++++++++
 include/linux/serial_core.h   |  1 +
 3 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index cfd3b35..e8fd54a 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -839,7 +839,7 @@ static int __init early_init_dt_scan_chosen_serial(void)
 		if (addr == OF_BAD_ADDR)
 			return -ENXIO;
 
-		of_setup_earlycon(addr, match, options);
+		of_setup_earlycon(addr, match, offset, options);
 		return 0;
 	}
 	return -ENODEV;
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 7509ee34d..7089667 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -19,6 +19,7 @@
 #include <linux/io.h>
 #include <linux/serial_core.h>
 #include <linux/sizes.h>
+#include <linux/of_fdt.h>
 
 #ifdef CONFIG_FIX_EARLYCON_MEM
 #include <asm/fixmap.h>
@@ -219,10 +220,13 @@ early_param("earlycon", param_setup_earlycon);
 
 int __init of_setup_earlycon(unsigned long addr,
 			     const struct earlycon_id *match,
+			     unsigned long node,
 			     const char *options)
 {
 	int err;
 	struct uart_port *port = &early_console_dev.port;
+	const __be32 *val;
+	bool big_endian;
 
 	spin_lock_init(&port->lock);
 	port->iotype = UPIO_MEM;
@@ -230,6 +234,33 @@ int __init of_setup_earlycon(unsigned long addr,
 	port->uartclk = BASE_BAUD * 16;
 	port->membase = earlycon_map(addr, SZ_4K);
 
+	val = of_get_flat_dt_prop(node, "reg-offset", NULL);
+	if (val)
+		port->mapbase += be32_to_cpu(*val);
+	val = of_get_flat_dt_prop(node, "reg-shift", NULL);
+	if (val)
+		port->regshift = be32_to_cpu(*val);
+	big_endian = of_get_flat_dt_prop(node, "big-endian", NULL) != NULL ||
+		(IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) &&
+		 of_get_flat_dt_prop(node, "native-endian", NULL) != NULL);
+	val = of_get_flat_dt_prop(node, "reg-io-width", NULL);
+	if (val) {
+		switch (be32_to_cpu(*val)) {
+		case 1:
+			port->iotype = UPIO_MEM;
+			break;
+		case 2:
+			port->iotype = UPIO_MEM16;
+			break;
+		case 4:
+			port->iotype = (big_endian) ? UPIO_MEM32BE : UPIO_MEM32;
+			break;
+		default:
+			pr_warn("[%s] unsupported reg-io-width\n", match->name);
+			return -EINVAL;
+		}
+	}
+
 	if (options) {
 		strlcpy(early_console_dev.options, options,
 			sizeof(early_console_dev.options));
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 62a4df0..6d1bed8 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -360,6 +360,7 @@ extern const struct earlycon_id __earlycon_table_end[];
 
 extern int setup_earlycon(char *buf);
 extern int of_setup_earlycon(unsigned long addr, const struct earlycon_id *match,
+			     unsigned long node,
 			     const char *options);
 
 struct uart_port *uart_get_console(struct uart_port *ports, int nr,
-- 
2.7.0

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

* [PATCH v6 07/12] of: earlycon: Move address translation to of_setup_earlycon()
  2016-01-16 23:23     ` [PATCH v6 00/12] Earlycon cleanup Peter Hurley
                         ` (5 preceding siblings ...)
  2016-01-16 23:23       ` [PATCH v6 06/12] of: earlycon: Initialize port fields from DT properties Peter Hurley
@ 2016-01-16 23:23       ` Peter Hurley
  2016-01-16 23:23       ` [PATCH v6 08/12] serial: earlycon: Common log banner for command line and DT Peter Hurley
                         ` (5 subsequent siblings)
  12 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2016-01-16 23:23 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: Jiri Slaby, linux-serial, linux-kernel, Kevin Cernekee,
	Jon Hunter, Paul Burton, Masahiro Yamada, Sebastian Frias,
	Peter Hurley

Cleanup the early DT/earlycon separation; remove the 'addr' parameter
from of_setup_earlycon() and get the uart phys addr directly with a
new wrapper function, of_flat_dt_translate_addr(). Limit
fdt_translate_address() to file scope.

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/of/fdt.c              |  8 +-------
 drivers/of/fdt_address.c      | 11 ++++++++++-
 drivers/tty/serial/earlycon.c | 12 +++++++++---
 include/linux/of_fdt.h        |  2 +-
 include/linux/serial_core.h   |  2 +-
 5 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index e8fd54a..918809e 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -827,19 +827,13 @@ static int __init early_init_dt_scan_chosen_serial(void)
 		return -ENODEV;
 
 	for (match = __earlycon_table; match < __earlycon_table_end; match++) {
-		u64 addr;
-
 		if (!match->compatible[0])
 			continue;
 
 		if (fdt_node_check_compatible(fdt, offset, match->compatible))
 			continue;
 
-		addr = fdt_translate_address(fdt, offset);
-		if (addr == OF_BAD_ADDR)
-			return -ENXIO;
-
-		of_setup_earlycon(addr, match, offset, options);
+		of_setup_earlycon(match, offset, options);
 		return 0;
 	}
 	return -ENODEV;
diff --git a/drivers/of/fdt_address.c b/drivers/of/fdt_address.c
index 8d3dc6f..dca8f9b 100644
--- a/drivers/of/fdt_address.c
+++ b/drivers/of/fdt_address.c
@@ -161,7 +161,7 @@ static int __init fdt_translate_one(const void *blob, int parent,
  * that can be mapped to a cpu physical address). This is not really specified
  * that way, but this is traditionally the way IBM at least do things
  */
-u64 __init fdt_translate_address(const void *blob, int node_offset)
+static u64 __init fdt_translate_address(const void *blob, int node_offset)
 {
 	int parent, len;
 	const struct of_bus *bus, *pbus;
@@ -239,3 +239,12 @@ u64 __init fdt_translate_address(const void *blob, int node_offset)
  bail:
 	return result;
 }
+
+/**
+ * of_flat_dt_translate_address - translate DT addr into CPU phys addr
+ * @node: node in the flat blob
+ */
+u64 __init of_flat_dt_translate_address(unsigned long node)
+{
+	return fdt_translate_address(initial_boot_params, node);
+}
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 7089667..baee9ad 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -19,6 +19,7 @@
 #include <linux/io.h>
 #include <linux/serial_core.h>
 #include <linux/sizes.h>
+#include <linux/of.h>
 #include <linux/of_fdt.h>
 
 #ifdef CONFIG_FIX_EARLYCON_MEM
@@ -218,8 +219,7 @@ early_param("earlycon", param_setup_earlycon);
 
 #ifdef CONFIG_OF_EARLY_FLATTREE
 
-int __init of_setup_earlycon(unsigned long addr,
-			     const struct earlycon_id *match,
+int __init of_setup_earlycon(const struct earlycon_id *match,
 			     unsigned long node,
 			     const char *options)
 {
@@ -227,12 +227,18 @@ int __init of_setup_earlycon(unsigned long addr,
 	struct uart_port *port = &early_console_dev.port;
 	const __be32 *val;
 	bool big_endian;
+	u64 addr;
 
 	spin_lock_init(&port->lock);
 	port->iotype = UPIO_MEM;
+	addr = of_flat_dt_translate_address(node);
+	if (addr == OF_BAD_ADDR) {
+		pr_warn("[%s] bad address\n", match->name);
+		return -ENXIO;
+	}
 	port->mapbase = addr;
 	port->uartclk = BASE_BAUD * 16;
-	port->membase = earlycon_map(addr, SZ_4K);
+	port->membase = earlycon_map(port->mapbase, SZ_4K);
 
 	val = of_get_flat_dt_prop(node, "reg-offset", NULL);
 	if (val)
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
index df9ef38..2fbe868 100644
--- a/include/linux/of_fdt.h
+++ b/include/linux/of_fdt.h
@@ -88,7 +88,7 @@ extern void unflatten_device_tree(void);
 extern void unflatten_and_copy_device_tree(void);
 extern void early_init_devtree(void *);
 extern void early_get_first_memblock_info(void *, phys_addr_t *);
-extern u64 fdt_translate_address(const void *blob, int node_offset);
+extern u64 of_flat_dt_translate_address(unsigned long node);
 extern void of_fdt_limit_memory(int limit);
 #else /* CONFIG_OF_FLATTREE */
 static inline void early_init_fdt_scan_reserved_mem(void) {}
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 6d1bed8..cbfcf38 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -359,7 +359,7 @@ extern const struct earlycon_id __earlycon_table_end[];
 #define EARLYCON_DECLARE(_name, fn)	OF_EARLYCON_DECLARE(_name, "", fn)
 
 extern int setup_earlycon(char *buf);
-extern int of_setup_earlycon(unsigned long addr, const struct earlycon_id *match,
+extern int of_setup_earlycon(const struct earlycon_id *match,
 			     unsigned long node,
 			     const char *options);
 
-- 
2.7.0

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

* [PATCH v6 08/12] serial: earlycon: Common log banner for command line and DT
  2016-01-16 23:23     ` [PATCH v6 00/12] Earlycon cleanup Peter Hurley
                         ` (6 preceding siblings ...)
  2016-01-16 23:23       ` [PATCH v6 07/12] of: earlycon: Move address translation to of_setup_earlycon() Peter Hurley
@ 2016-01-16 23:23       ` Peter Hurley
  2016-01-16 23:23       ` [PATCH v6 09/12] serial: earlycon: Show the earlycon "driver" in banner Peter Hurley
                         ` (4 subsequent siblings)
  12 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2016-01-16 23:23 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: Jiri Slaby, linux-serial, linux-kernel, Kevin Cernekee,
	Jon Hunter, Paul Burton, Masahiro Yamada, Sebastian Frias,
	Peter Hurley

Refactor the command line earlycon banner into earlycon_init() so
both earlycon startup methods output an info banner.

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/tty/serial/earlycon.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index baee9ad..36b79f1 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -59,6 +59,7 @@ static void __init earlycon_init(struct earlycon_device *device,
 				 const char *name)
 {
 	struct console *earlycon = device->con;
+	struct uart_port *port = &device->port;
 	const char *s;
 	size_t len;
 
@@ -72,6 +73,19 @@ static void __init earlycon_init(struct earlycon_device *device,
 	len = s - name;
 	strlcpy(earlycon->name, name, min(len + 1, sizeof(earlycon->name)));
 	earlycon->data = &early_console_dev;
+
+	if (port->iotype == UPIO_MEM || port->iotype == UPIO_MEM16 ||
+	    port->iotype == UPIO_MEM32 || port->iotype == UPIO_MEM32BE)
+		pr_info("Early serial console at MMIO%s 0x%llx (options '%s')\n",
+			(port->iotype == UPIO_MEM) ? "" :
+			(port->iotype == UPIO_MEM16) ? "16" :
+			(port->iotype == UPIO_MEM32) ? "32" : "32be",
+			(unsigned long long)port->mapbase,
+			device->options);
+	else
+		pr_info("Early serial console at I/O port 0x%lx (options '%s')\n",
+			port->iobase,
+			device->options);
 }
 
 static int __init parse_options(struct earlycon_device *device, char *options)
@@ -110,19 +124,6 @@ static int __init parse_options(struct earlycon_device *device, char *options)
 		strlcpy(device->options, options, length);
 	}
 
-	if (port->iotype == UPIO_MEM || port->iotype == UPIO_MEM16 ||
-	    port->iotype == UPIO_MEM32 || port->iotype == UPIO_MEM32BE)
-		pr_info("Early serial console at MMIO%s 0x%llx (options '%s')\n",
-			(port->iotype == UPIO_MEM) ? "" :
-			(port->iotype == UPIO_MEM16) ? "16" :
-			(port->iotype == UPIO_MEM32) ? "32" : "32be",
-			(unsigned long long)port->mapbase,
-			device->options);
-	else
-		pr_info("Early serial console at I/O port 0x%lx (options '%s')\n",
-			port->iobase,
-			device->options);
-
 	return 0;
 }
 
-- 
2.7.0

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

* [PATCH v6 09/12] serial: earlycon: Show the earlycon "driver" in banner
  2016-01-16 23:23     ` [PATCH v6 00/12] Earlycon cleanup Peter Hurley
                         ` (7 preceding siblings ...)
  2016-01-16 23:23       ` [PATCH v6 08/12] serial: earlycon: Common log banner for command line and DT Peter Hurley
@ 2016-01-16 23:23       ` Peter Hurley
  2016-01-16 23:23       ` [PATCH v6 10/12] serial: 8250_early: Use port->regshift Peter Hurley
                         ` (3 subsequent siblings)
  12 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2016-01-16 23:23 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: Jiri Slaby, linux-serial, linux-kernel, Kevin Cernekee,
	Jon Hunter, Paul Burton, Masahiro Yamada, Sebastian Frias,
	Peter Hurley

Output the earlycon "driver" from the just-parsed console 'name'
and 'index' fields.

NB: ->mapbase is a resource_size_t so use %pa format specifier

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/tty/serial/earlycon.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 36b79f1..067783f 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -76,16 +76,16 @@ static void __init earlycon_init(struct earlycon_device *device,
 
 	if (port->iotype == UPIO_MEM || port->iotype == UPIO_MEM16 ||
 	    port->iotype == UPIO_MEM32 || port->iotype == UPIO_MEM32BE)
-		pr_info("Early serial console at MMIO%s 0x%llx (options '%s')\n",
+		pr_info("%s%d at MMIO%s %pa (options '%s')\n",
+			earlycon->name, earlycon->index,
 			(port->iotype == UPIO_MEM) ? "" :
 			(port->iotype == UPIO_MEM16) ? "16" :
 			(port->iotype == UPIO_MEM32) ? "32" : "32be",
-			(unsigned long long)port->mapbase,
-			device->options);
+			&port->mapbase, device->options);
 	else
-		pr_info("Early serial console at I/O port 0x%lx (options '%s')\n",
-			port->iobase,
-			device->options);
+		pr_info("%s%d at I/O port 0x%lx (options '%s')\n",
+			earlycon->name, earlycon->index,
+			port->iobase, device->options);
 }
 
 static int __init parse_options(struct earlycon_device *device, char *options)
-- 
2.7.0

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

* [PATCH v6 10/12] serial: 8250_early: Use port->regshift
  2016-01-16 23:23     ` [PATCH v6 00/12] Earlycon cleanup Peter Hurley
                         ` (8 preceding siblings ...)
  2016-01-16 23:23       ` [PATCH v6 09/12] serial: earlycon: Show the earlycon "driver" in banner Peter Hurley
@ 2016-01-16 23:23       ` Peter Hurley
  2016-01-16 23:23       ` [PATCH v6 11/12] of: earlycon: Log more helpful message if stdout-path node not found Peter Hurley
                         ` (2 subsequent siblings)
  12 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2016-01-16 23:23 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: Jiri Slaby, linux-serial, linux-kernel, Kevin Cernekee,
	Jon Hunter, Paul Burton, Masahiro Yamada, Sebastian Frias,
	Peter Hurley

earlycon initializes struct uart_port::regshift to the correct
value for UPIO_MEM32 already. Use the port field rather than
hard-coded value.

This enables broader support for various i/o access methods in
8250 earlycon (eg., omap8250 earlycon).

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/tty/serial/8250/8250_early.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
index af62131..180143c 100644
--- a/drivers/tty/serial/8250/8250_early.c
+++ b/drivers/tty/serial/8250/8250_early.c
@@ -39,15 +39,17 @@
 
 static unsigned int __init serial8250_early_in(struct uart_port *port, int offset)
 {
+	offset <<= port->regshift;
+
 	switch (port->iotype) {
 	case UPIO_MEM:
 		return readb(port->membase + offset);
 	case UPIO_MEM16:
-		return readw(port->membase + (offset << 1));
+		return readw(port->membase + offset);
 	case UPIO_MEM32:
-		return readl(port->membase + (offset << 2));
+		return readl(port->membase + offset);
 	case UPIO_MEM32BE:
-		return ioread32be(port->membase + (offset << 2));
+		return ioread32be(port->membase + offset);
 	case UPIO_PORT:
 		return inb(port->iobase + offset);
 	default:
@@ -57,18 +59,20 @@ static unsigned int __init serial8250_early_in(struct uart_port *port, int offse
 
 static void __init serial8250_early_out(struct uart_port *port, int offset, int value)
 {
+	offset <<= port->regshift;
+
 	switch (port->iotype) {
 	case UPIO_MEM:
 		writeb(value, port->membase + offset);
 		break;
 	case UPIO_MEM16:
-		writew(value, port->membase + (offset << 1));
+		writew(value, port->membase + offset);
 		break;
 	case UPIO_MEM32:
-		writel(value, port->membase + (offset << 2));
+		writel(value, port->membase + offset);
 		break;
 	case UPIO_MEM32BE:
-		iowrite32be(value, port->membase + (offset << 2));
+		iowrite32be(value, port->membase + offset);
 		break;
 	case UPIO_PORT:
 		outb(value, port->iobase + offset);
-- 
2.7.0

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

* [PATCH v6 11/12] of: earlycon: Log more helpful message if stdout-path node not found
  2016-01-16 23:23     ` [PATCH v6 00/12] Earlycon cleanup Peter Hurley
                         ` (9 preceding siblings ...)
  2016-01-16 23:23       ` [PATCH v6 10/12] serial: 8250_early: Use port->regshift Peter Hurley
@ 2016-01-16 23:23       ` Peter Hurley
  2016-01-16 23:23       ` [PATCH v6 12/12] serial: 8250_omap: Add omap8250 earlycon Peter Hurley
  2016-02-05  9:19       ` [PATCH v6 00/12] Earlycon cleanup Jon Hunter
  12 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2016-01-16 23:23 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: Jiri Slaby, linux-serial, linux-kernel, Kevin Cernekee,
	Jon Hunter, Paul Burton, Masahiro Yamada, Sebastian Frias,
	Peter Hurley

Earlycon may fail to initialize for a variety of reasons, most of
which log the default early param message. If the stdout-path node is
not found, log the path which was not found (and suppress the
default early param message).

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/of/fdt.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 918809e..e2295b2 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -820,11 +820,14 @@ static int __init early_init_dt_scan_chosen_serial(void)
 	q = strchrnul(p, ':');
 	if (*q != '\0')
 		options = q + 1;
+	l = q - p;
 
 	/* Get the node specified by stdout-path */
-	offset = fdt_path_offset_namelen(fdt, p, q - p);
-	if (offset < 0)
-		return -ENODEV;
+	offset = fdt_path_offset_namelen(fdt, p, l);
+	if (offset < 0) {
+		pr_warn("earlycon: stdout-path %.*s not found\n", l, p);
+		return 0;
+	}
 
 	for (match = __earlycon_table; match < __earlycon_table_end; match++) {
 		if (!match->compatible[0])
-- 
2.7.0

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

* [PATCH v6 12/12] serial: 8250_omap: Add omap8250 earlycon
  2016-01-16 23:23     ` [PATCH v6 00/12] Earlycon cleanup Peter Hurley
                         ` (10 preceding siblings ...)
  2016-01-16 23:23       ` [PATCH v6 11/12] of: earlycon: Log more helpful message if stdout-path node not found Peter Hurley
@ 2016-01-16 23:23       ` Peter Hurley
  2016-02-05  9:19       ` [PATCH v6 00/12] Earlycon cleanup Jon Hunter
  12 siblings, 0 replies; 73+ messages in thread
From: Peter Hurley @ 2016-01-16 23:23 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: Jiri Slaby, linux-serial, linux-kernel, Kevin Cernekee,
	Jon Hunter, Paul Burton, Masahiro Yamada, Sebastian Frias,
	Peter Hurley

Add DT earlycon for 8250_omap driver. This boot console is included
for kernels built with CONFIG_SERIAL_EARLYCON=y, CONFIG_OF=y,
CONFIG_SERIAL_8250_OMAP=y, and CONFIG_OF_EARLY_FLATTREE=y.

This boot console is enabled with the command line option "earlycon"
(without "=<name>...") when the DT 'stdout-path' property matches a
compatible uart. For example,

/ {
   chosen {
        stdout-path = "serial0:115200";
   };

   ....

   aliases {
        serial0 = &uart0;
   };

   ....

   ocp : ocp {
        uart0 : serial@44e09000 {
             compatible = "ti,omap3-uart";
        }
   };
};

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/tty/serial/8250/8250_early.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
index 180143c..3b3dbdc 100644
--- a/drivers/tty/serial/8250/8250_early.c
+++ b/drivers/tty/serial/8250/8250_early.c
@@ -149,3 +149,24 @@ 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_OMAP
+
+static int __init early_omap8250_setup(struct earlycon_device *device,
+				       const char *options)
+{
+	struct uart_port *port = &device->port;
+
+	if (!(device->port.membase || device->port.iobase))
+		return -ENODEV;
+
+	port->regshift = 2;
+	device->con->write = early_serial8250_write;
+	return 0;
+}
+
+OF_EARLYCON_DECLARE(omap8250, "ti,omap2-uart", early_omap8250_setup);
+OF_EARLYCON_DECLARE(omap8250, "ti,omap3-uart", early_omap8250_setup);
+OF_EARLYCON_DECLARE(omap8250, "ti,omap4-uart", early_omap8250_setup);
+
+#endif
-- 
2.7.0

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

* Re: [PATCH v6 00/12] Earlycon cleanup
  2016-01-16 23:23     ` [PATCH v6 00/12] Earlycon cleanup Peter Hurley
                         ` (11 preceding siblings ...)
  2016-01-16 23:23       ` [PATCH v6 12/12] serial: 8250_omap: Add omap8250 earlycon Peter Hurley
@ 2016-02-05  9:19       ` Jon Hunter
  2016-02-07  6:08         ` Greg Kroah-Hartman
  12 siblings, 1 reply; 73+ messages in thread
From: Jon Hunter @ 2016-02-05  9:19 UTC (permalink / raw)
  To: Peter Hurley, Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: Jiri Slaby, linux-serial, linux-kernel, Kevin Cernekee,
	Paul Burton, Masahiro Yamada, Sebastian Frias

Hi all,

On 16/01/16 23:23, Peter Hurley wrote:
> Hi Greg, Grant & Rob,
> 
> This patch series is a rebase of the v3 from April last year.
> 
> This patch series builds on my earlier "Extensible console matching &
> direct earlycon" to add several useful features to earlycon:
> * Proper port i/o configuration from DT node with of_serial properties
>   (such as reg-io-width, reg-shift and reg-offset, and endianness)
> * Proper console name & index initialization from earlycon name
>   (for both command line and DT-defined earlycons)
> * Support for DT 'stdout-path' options pass-through to earlycon setup
> * Improved log messages for troubleshooting
> * Support for multiple OF earlycon declarations so different
>   compatible strings can specify the same OF earlycon

I just wanted to check the status of this series. I have not seen it
appear in -next yet. I was waiting for this to get merged so that I can
enable earlycon via DT for Tegra.

Cheers
Jon

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

* Re: [PATCH v6 00/12] Earlycon cleanup
  2016-02-05  9:19       ` [PATCH v6 00/12] Earlycon cleanup Jon Hunter
@ 2016-02-07  6:08         ` Greg Kroah-Hartman
  0 siblings, 0 replies; 73+ messages in thread
From: Greg Kroah-Hartman @ 2016-02-07  6:08 UTC (permalink / raw)
  To: Jon Hunter
  Cc: Peter Hurley, Rob Herring, Grant Likely, Jiri Slaby, linux-serial,
	linux-kernel, Kevin Cernekee, Paul Burton, Masahiro Yamada,
	Sebastian Frias

On Fri, Feb 05, 2016 at 09:19:56AM +0000, Jon Hunter wrote:
> Hi all,
> 
> On 16/01/16 23:23, Peter Hurley wrote:
> > Hi Greg, Grant & Rob,
> > 
> > This patch series is a rebase of the v3 from April last year.
> > 
> > This patch series builds on my earlier "Extensible console matching &
> > direct earlycon" to add several useful features to earlycon:
> > * Proper port i/o configuration from DT node with of_serial properties
> >   (such as reg-io-width, reg-shift and reg-offset, and endianness)
> > * Proper console name & index initialization from earlycon name
> >   (for both command line and DT-defined earlycons)
> > * Support for DT 'stdout-path' options pass-through to earlycon setup
> > * Improved log messages for troubleshooting
> > * Support for multiple OF earlycon declarations so different
> >   compatible strings can specify the same OF earlycon
> 
> I just wanted to check the status of this series. I have not seen it
> appear in -next yet. I was waiting for this to get merged so that I can
> enable earlycon via DT for Tegra.

Now in my testing branch, if all goes well, will show up in -next in a
few days.

thanks,

greg k-h

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

end of thread, other threads:[~2016-02-07  6:08 UTC | newest]

Thread overview: 73+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-08 17:45 [PATCH v3 00/13] Earlycon cleanup Peter Hurley
2015-04-08 17:45 ` [PATCH v3 01/13] of: earlycon: Fix 'stdout-path' with ':' path terminator Peter Hurley
2015-04-08 21:24   ` Rob Herring
2015-04-28 13:07     ` Peter Hurley
2015-04-28 13:28       ` Greg Kroah-Hartman
2015-04-28 13:58         ` Peter Hurley
2015-04-28 14:02           ` Rob Herring
2015-07-22 10:16   ` Sudeep Holla
2015-04-08 17:45 ` [PATCH v3 02/13] earlycon: Use common framework for earlycon declarations Peter Hurley
2015-04-08 17:45 ` [PATCH v3 03/13] serial: earlycon: Fixup earlycon console name and index Peter Hurley
2015-04-08 17:45 ` [PATCH v3 04/13] of: " Peter Hurley
2015-04-08 17:45 ` [PATCH v3 05/13] of: earlycon: Add options string handling Peter Hurley
2015-04-08 17:45 ` [PATCH v3 06/13] of: earlycon: of_setup_earlycon() requires CONFIG_OF_EARLY_FLATTREE Peter Hurley
2015-04-08 17:45 ` [PATCH v3 07/13] of: earlycon: Initialize port fields from DT properties Peter Hurley
2015-04-08 17:45 ` [PATCH v3 08/13] of: earlycon: Move address translation to of_setup_earlycon() Peter Hurley
2015-04-08 17:45 ` [PATCH v3 09/13] serial: earlycon: Common log banner for command line and DT Peter Hurley
2015-04-08 17:45 ` [PATCH v3 10/13] serial: earlycon: Show the earlycon "driver" in banner Peter Hurley
2015-04-08 17:45 ` [PATCH v3 11/13] of: earlycon: Log more helpful message if earlycon not found Peter Hurley
2015-04-08 17:45 ` [PATCH v3 12/13] serial: 8250_early: Use port->regshift Peter Hurley
2015-04-28 11:38   ` Greg Kroah-Hartman
2015-04-08 17:45 ` [PATCH v3 13/13] serial: 8250_omap: Add omap8250 earlycon Peter Hurley
2015-04-08 18:07 ` [PATCH v3 00/13] Earlycon cleanup Peter Hurley
2016-01-12 19:41 ` [PATCH v4 00/11] " Peter Hurley
2016-01-12 19:41   ` [PATCH v4 01/11] earlycon: Use common framework for earlycon declarations Peter Hurley
2016-01-12 19:41   ` [PATCH v4 02/11] serial: earlycon: Fixup earlycon console name and index Peter Hurley
2016-01-12 19:41   ` [PATCH v4 03/11] of: " Peter Hurley
2016-01-12 19:41   ` [PATCH v4 04/11] of: earlycon: Add options string handling Peter Hurley
2016-01-12 19:41   ` [PATCH v4 05/11] of: earlycon: Initialize port fields from DT properties Peter Hurley
2016-01-12 23:49     ` Rob Herring
2016-01-13 16:35       ` Peter Hurley
2016-01-12 19:41   ` [PATCH v4 06/11] of: earlycon: Move address translation to of_setup_earlycon() Peter Hurley
2016-01-12 19:41   ` [PATCH v4 07/11] serial: earlycon: Common log banner for command line and DT Peter Hurley
2016-01-12 19:41   ` [PATCH v4 08/11] serial: earlycon: Show the earlycon "driver" in banner Peter Hurley
2016-01-12 19:41   ` [PATCH v4 09/11] serial: 8250_early: Use port->regshift Peter Hurley
2016-01-12 19:41   ` [PATCH v4 10/11] of: earlycon: Log more helpful message if stdout-path node not found Peter Hurley
2016-01-12 23:38     ` Rob Herring
2016-01-12 19:41   ` [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon Peter Hurley
2016-01-12 19:51     ` Peter Hurley
2016-01-13  9:19       ` Jon Hunter
2016-01-13  9:57         ` Jon Hunter
2016-01-13 10:09         ` Jon Hunter
2016-01-13 17:06           ` Peter Hurley
2016-01-13 17:15             ` Jon Hunter
2016-01-12 23:52   ` [PATCH v4 00/11] Earlycon cleanup Rob Herring
2016-01-16 21:37   ` [PATCH v5 " Peter Hurley
2016-01-16 21:37     ` [PATCH v5 01/11] earlycon: Use common framework for earlycon declarations Peter Hurley
2016-01-16 21:37     ` [PATCH v5 02/11] serial: earlycon: Fixup earlycon console name and index Peter Hurley
2016-01-16 21:37     ` [PATCH v5 03/11] of: " Peter Hurley
2016-01-16 21:37     ` [PATCH v5 04/11] of: earlycon: Add options string handling Peter Hurley
2016-01-16 21:37     ` [PATCH v5 05/11] of: earlycon: Initialize port fields from DT properties Peter Hurley
2016-01-16 21:54       ` kbuild test robot
2016-01-16 21:37     ` [PATCH v5 06/11] of: earlycon: Move address translation to of_setup_earlycon() Peter Hurley
2016-01-16 22:02       ` kbuild test robot
2016-01-16 21:37     ` [PATCH v5 07/11] serial: earlycon: Common log banner for command line and DT Peter Hurley
2016-01-16 21:37     ` [PATCH v5 08/11] serial: earlycon: Show the earlycon "driver" in banner Peter Hurley
2016-01-16 21:37     ` [PATCH v5 09/11] serial: 8250_early: Use port->regshift Peter Hurley
2016-01-16 21:37     ` [PATCH v5 10/11] of: earlycon: Log more helpful message if stdout-path node not found Peter Hurley
2016-01-16 21:37     ` [PATCH v5 11/11] serial: 8250_omap: Add omap8250 earlycon Peter Hurley
2016-01-16 23:23     ` [PATCH v6 00/12] Earlycon cleanup Peter Hurley
2016-01-16 23:23       ` [PATCH v6 01/12] of: earlycon: of_setup_earlycon() requires CONFIG_OF_EARLY_FLATTREE Peter Hurley
2016-01-16 23:23       ` [PATCH v6 02/12] earlycon: Use common framework for earlycon declarations Peter Hurley
2016-01-16 23:23       ` [PATCH v6 03/12] serial: earlycon: Fixup earlycon console name and index Peter Hurley
2016-01-16 23:23       ` [PATCH v6 04/12] of: " Peter Hurley
2016-01-16 23:23       ` [PATCH v6 05/12] of: earlycon: Add options string handling Peter Hurley
2016-01-16 23:23       ` [PATCH v6 06/12] of: earlycon: Initialize port fields from DT properties Peter Hurley
2016-01-16 23:23       ` [PATCH v6 07/12] of: earlycon: Move address translation to of_setup_earlycon() Peter Hurley
2016-01-16 23:23       ` [PATCH v6 08/12] serial: earlycon: Common log banner for command line and DT Peter Hurley
2016-01-16 23:23       ` [PATCH v6 09/12] serial: earlycon: Show the earlycon "driver" in banner Peter Hurley
2016-01-16 23:23       ` [PATCH v6 10/12] serial: 8250_early: Use port->regshift Peter Hurley
2016-01-16 23:23       ` [PATCH v6 11/12] of: earlycon: Log more helpful message if stdout-path node not found Peter Hurley
2016-01-16 23:23       ` [PATCH v6 12/12] serial: 8250_omap: Add omap8250 earlycon Peter Hurley
2016-02-05  9:19       ` [PATCH v6 00/12] Earlycon cleanup Jon Hunter
2016-02-07  6:08         ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).