LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v2 -next 00/14] OF earlycon cleanup
@ 2015-03-06 19:25 Peter Hurley
2015-03-06 19:25 ` [PATCH v2 -next 01/14] of: earlycon: Fix 'stdout-path' with ':' path terminator Peter Hurley
` (13 more replies)
0 siblings, 14 replies; 15+ messages in thread
From: Peter Hurley @ 2015-03-06 19:25 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Grant Likely
Cc: linux-serial, linux-kernel, Peter Hurley
I thought I'd respin this to address the bugs in v1.
I'm still having an open conversation with Rob Herring about the
OF_EARLYCON_DECLARE macro and earlycon console names.
* 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
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
Lastly, this patch series adds an omap8250 OF earlycon. I don't think
the last patch requires the "Split 8250 driver" to work but it won't
apply cleanly without it.
Requires: 1) "libfdt: Add fdt_path_offset_namelen()"
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 (14):
of: earlycon: Fix 'stdout-path' with ':' path terminator
serial: earlycon: Fixup earlycon console name and index
serial: earlycon: Emit earlycon name in the OF table
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: Allow multiple OF_EARLYCON_DECLARE() with same name
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 | 18 +++----
drivers/of/fdt_address.c | 11 +++-
drivers/tty/serial/8250/8250_early.c | 29 +++++++++-
drivers/tty/serial/earlycon.c | 100 ++++++++++++++++++++++++++++-------
include/linux/of_fdt.h | 2 +-
include/linux/serial_core.h | 20 +++++--
6 files changed, 144 insertions(+), 36 deletions(-)
--
2.3.1
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v2 -next 01/14] of: earlycon: Fix 'stdout-path' with ':' path terminator
2015-03-06 19:25 [PATCH v2 -next 00/14] OF earlycon cleanup Peter Hurley
@ 2015-03-06 19:25 ` Peter Hurley
2015-03-06 19:25 ` [PATCH v2 -next 02/14] serial: earlycon: Fixup earlycon console name and index Peter Hurley
` (12 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Peter Hurley @ 2015-03-06 19:25 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Grant Likely
Cc: linux-serial, linux-kernel, 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.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 -next 02/14] serial: earlycon: Fixup earlycon console name and index
2015-03-06 19:25 [PATCH v2 -next 00/14] OF earlycon cleanup Peter Hurley
2015-03-06 19:25 ` [PATCH v2 -next 01/14] of: earlycon: Fix 'stdout-path' with ':' path terminator Peter Hurley
@ 2015-03-06 19:25 ` Peter Hurley
2015-03-06 19:25 ` [PATCH v2 -next 03/14] serial: earlycon: Emit earlycon name in the OF table Peter Hurley
` (11 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Peter Hurley @ 2015-03-06 19:25 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Grant Likely
Cc: linux-serial, linux-kernel, Peter Hurley
Properly initialize the struct console::name and ::index for
the registering earlycon. The earlycon's ::index == 0
for earlycons without trailing numerals and the numeral value
for earlycons with trailing numerals. For example, exynos4210
earlycon ::name == "exynos" and ::index = 4210. Earlycons with
embedded numerals will have all non-trailing numerals as part of
the name; for example, s3c2412 earlycon ::name == "s3c" and ::index
== 2412. This ackward scheme was initially supported for the
uart8250 earlycon; this patch extends this support to 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 5fdc9f3..1ffdb61 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -28,9 +28,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 = {
@@ -61,6 +61,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;
@@ -116,7 +135,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.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 -next 03/14] serial: earlycon: Emit earlycon name in the OF table
2015-03-06 19:25 [PATCH v2 -next 00/14] OF earlycon cleanup Peter Hurley
2015-03-06 19:25 ` [PATCH v2 -next 01/14] of: earlycon: Fix 'stdout-path' with ':' path terminator Peter Hurley
2015-03-06 19:25 ` [PATCH v2 -next 02/14] serial: earlycon: Fixup earlycon console name and index Peter Hurley
@ 2015-03-06 19:25 ` Peter Hurley
2015-03-06 19:25 ` [PATCH v2 -next 04/14] of: earlycon: Fixup earlycon console name and index Peter Hurley
` (10 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Peter Hurley @ 2015-03-06 19:25 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Grant Likely
Cc: linux-serial, linux-kernel, Peter Hurley
The OF device name of the earlycon is never used because there is no
device; re-purpose the name field to store the earlycon name in
the OF earlycon table. Earlycon will use the table entry to
fixup the console name and index.
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
include/linux/serial_core.h | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 8aeec49..c523785 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -29,6 +29,7 @@
#include <linux/tty.h>
#include <linux/mutex.h>
#include <linux/sysrq.h>
+#include <linux/mod_devicetable.h>
#include <uapi/linux/serial_core.h>
#ifdef CONFIG_SERIAL_CORE_CONSOLE
@@ -353,8 +354,18 @@ extern int of_setup_earlycon(unsigned long addr,
= { .name = __stringify(_name), \
.setup = func }
-#define OF_EARLYCON_DECLARE(name, compat, fn) \
- _OF_DECLARE(earlycon, name, compat, fn, void *)
+#ifdef CONFIG_OF
+#define EARLYCON_OF_TABLE_ATTR __used __section(__earlycon_of_table)
+#else
+#define EARLYCON_OF_TABLE_ATTR __attribute__((unused))
+#endif
+
+#define OF_EARLYCON_DECLARE(_name, compat, fn) \
+ static const struct of_device_id __of_table_##_name \
+ EARLYCON_OF_TABLE_ATTR \
+ = { .name = __stringify(_name), \
+ .compatible = compat, \
+ .data = (fn == (void *)NULL) ? fn : fn }
struct uart_port *uart_get_console(struct uart_port *ports, int nr,
struct console *c);
--
2.3.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 -next 04/14] of: earlycon: Fixup earlycon console name and index
2015-03-06 19:25 [PATCH v2 -next 00/14] OF earlycon cleanup Peter Hurley
` (2 preceding siblings ...)
2015-03-06 19:25 ` [PATCH v2 -next 03/14] serial: earlycon: Emit earlycon name in the OF table Peter Hurley
@ 2015-03-06 19:25 ` Peter Hurley
2015-03-06 19:25 ` [PATCH v2 -next 05/14] of: earlycon: Add options string handling Peter Hurley
` (9 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Peter Hurley @ 2015-03-06 19:25 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Grant Likely
Cc: linux-serial, linux-kernel, 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 | 5 +++--
include/linux/serial_core.h | 2 +-
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 7cef9f9..777c894 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -800,7 +800,7 @@ static int __init early_init_dt_scan_chosen_serial(void)
if (!addr)
return -ENXIO;
- of_setup_earlycon(addr, match->data);
+ of_setup_earlycon(addr, match);
return 0;
}
return -ENODEV;
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 1ffdb61..bfe5e27 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -218,17 +218,18 @@ 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 of_device_id *match)
{
int err;
struct uart_port *port = &early_console_dev.port;
+ int (*setup)(struct earlycon_device *, const char *) = match->data;
port->iotype = UPIO_MEM;
port->mapbase = addr;
port->uartclk = BASE_BAUD * 16;
port->membase = earlycon_map(addr, SZ_4K);
- early_console_dev.con->data = &early_console_dev;
+ earlycon_init(&early_console_dev, match->name);
err = setup(&early_console_dev, NULL);
if (err < 0)
return err;
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index c523785..a2db5bd 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -346,7 +346,7 @@ struct earlycon_id {
extern int setup_earlycon(char *buf);
extern int of_setup_earlycon(unsigned long addr,
- int (*setup)(struct earlycon_device *, const char *));
+ const struct of_device_id *match);
#define EARLYCON_DECLARE(_name, func) \
static const struct earlycon_id __earlycon_##_name \
--
2.3.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 -next 05/14] of: earlycon: Add options string handling
2015-03-06 19:25 [PATCH v2 -next 00/14] OF earlycon cleanup Peter Hurley
` (3 preceding siblings ...)
2015-03-06 19:25 ` [PATCH v2 -next 04/14] of: earlycon: Fixup earlycon console name and index Peter Hurley
@ 2015-03-06 19:25 ` Peter Hurley
2015-03-06 19:25 ` [PATCH v2 -next 06/14] of: earlycon: of_setup_earlycon() requires CONFIG_OF_EARLY_FLATTREE Peter Hurley
` (8 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Peter Hurley @ 2015-03-06 19:25 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Grant Likely
Cc: linux-serial, linux-kernel, 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 777c894..a8ad540 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, *q;
+ const char *p, *q, *options = NULL;
int l;
const struct of_device_id *match = __earlycon_of_table;
const void *fdt = initial_boot_params;
@@ -783,6 +783,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));
@@ -800,7 +802,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 bfe5e27..023ebbb 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -218,7 +218,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 of_device_id *match)
+ const struct of_device_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 = setup(&early_console_dev, NULL);
+ err = 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 a2db5bd..ebbcd43 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -346,7 +346,8 @@ struct earlycon_id {
extern int setup_earlycon(char *buf);
extern int of_setup_earlycon(unsigned long addr,
- const struct of_device_id *match);
+ const struct of_device_id *match,
+ const char *options);
#define EARLYCON_DECLARE(_name, func) \
static const struct earlycon_id __earlycon_##_name \
--
2.3.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 -next 06/14] of: earlycon: of_setup_earlycon() requires CONFIG_OF_EARLY_FLATTREE
2015-03-06 19:25 [PATCH v2 -next 00/14] OF earlycon cleanup Peter Hurley
` (4 preceding siblings ...)
2015-03-06 19:25 ` [PATCH v2 -next 05/14] of: earlycon: Add options string handling Peter Hurley
@ 2015-03-06 19:25 ` Peter Hurley
2015-03-06 19:25 ` [PATCH v2 -next 07/14] of: earlycon: Initialize port fields from DT properties Peter Hurley
` (7 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Peter Hurley @ 2015-03-06 19:25 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Grant Likely
Cc: linux-serial, linux-kernel, 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 023ebbb..1a37f27 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -217,6 +217,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 of_device_id *match,
const char *options)
@@ -245,3 +247,5 @@ int __init of_setup_earlycon(unsigned long addr,
register_console(early_console_dev.con);
return 0;
}
+
+#endif /* CONFIG_OF_EARLY_FLATTREE */
--
2.3.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 -next 07/14] of: earlycon: Initialize port fields from DT properties
2015-03-06 19:25 [PATCH v2 -next 00/14] OF earlycon cleanup Peter Hurley
` (5 preceding siblings ...)
2015-03-06 19:25 ` [PATCH v2 -next 06/14] of: earlycon: of_setup_earlycon() requires CONFIG_OF_EARLY_FLATTREE Peter Hurley
@ 2015-03-06 19:25 ` Peter Hurley
2015-03-06 19:25 ` [PATCH v2 -next 08/14] of: earlycon: Move address translation to of_setup_earlycon() Peter Hurley
` (6 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Peter Hurley @ 2015-03-06 19:25 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Grant Likely
Cc: linux-serial, linux-kernel, 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 a8ad540..4de1171 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -802,7 +802,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 1a37f27..5b3d2b5 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -21,6 +21,10 @@
#include <linux/sizes.h>
#include <linux/mod_devicetable.h>
+#ifdef CONFIG_OF_EARLY_FLATTREE
+#include <linux/of_fdt.h>
+#endif
+
#ifdef CONFIG_FIX_EARLYCON_MEM
#include <asm/fixmap.h>
#endif
@@ -221,17 +225,40 @@ early_param("earlycon", param_setup_earlycon);
int __init of_setup_earlycon(unsigned long addr,
const struct of_device_id *match,
+ unsigned long node,
const char *options)
{
int err;
struct uart_port *port = &early_console_dev.port;
int (*setup)(struct earlycon_device *, const char *) = match->data;
+ 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 ebbcd43..c8e4e8f 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -347,6 +347,7 @@ struct earlycon_id {
extern int setup_earlycon(char *buf);
extern int of_setup_earlycon(unsigned long addr,
const struct of_device_id *match,
+ unsigned long node,
const char *options);
#define EARLYCON_DECLARE(_name, func) \
--
2.3.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 -next 08/14] of: earlycon: Move address translation to of_setup_earlycon()
2015-03-06 19:25 [PATCH v2 -next 00/14] OF earlycon cleanup Peter Hurley
` (6 preceding siblings ...)
2015-03-06 19:25 ` [PATCH v2 -next 07/14] of: earlycon: Initialize port fields from DT properties Peter Hurley
@ 2015-03-06 19:25 ` Peter Hurley
2015-03-06 19:25 ` [PATCH v2 -next 09/14] serial: earlycon: Common log banner for command line and DT Peter Hurley
` (5 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Peter Hurley @ 2015-03-06 19:25 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Grant Likely
Cc: linux-serial, linux-kernel, 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 | 7 +------
drivers/of/fdt_address.c | 11 ++++++++++-
drivers/tty/serial/earlycon.c | 11 +++++++----
include/linux/of_fdt.h | 2 +-
include/linux/serial_core.h | 3 +--
5 files changed, 20 insertions(+), 14 deletions(-)
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 4de1171..0850517 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -792,17 +792,12 @@ static int __init early_init_dt_scan_chosen_serial(void)
return -ENODEV;
while (match->compatible[0]) {
- unsigned long addr;
if (fdt_node_check_compatible(fdt, offset, match->compatible)) {
match++;
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 5b3d2b5..6449834 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -223,8 +223,7 @@ early_param("earlycon", param_setup_earlycon);
#ifdef CONFIG_OF_EARLY_FLATTREE
-int __init of_setup_earlycon(unsigned long addr,
- const struct of_device_id *match,
+int __init of_setup_earlycon(const struct of_device_id *match,
unsigned long node,
const char *options)
{
@@ -234,9 +233,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 c8e4e8f..675d36f 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -345,8 +345,7 @@ struct earlycon_id {
};
extern int setup_earlycon(char *buf);
-extern int of_setup_earlycon(unsigned long addr,
- const struct of_device_id *match,
+extern int of_setup_earlycon(const struct of_device_id *match,
unsigned long node,
const char *options);
--
2.3.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 -next 09/14] serial: earlycon: Common log banner for command line and DT
2015-03-06 19:25 [PATCH v2 -next 00/14] OF earlycon cleanup Peter Hurley
` (7 preceding siblings ...)
2015-03-06 19:25 ` [PATCH v2 -next 08/14] of: earlycon: Move address translation to of_setup_earlycon() Peter Hurley
@ 2015-03-06 19:25 ` Peter Hurley
2015-03-06 19:25 ` [PATCH v2 -next 10/14] serial: earlycon: Show the earlycon "driver" in banner Peter Hurley
` (4 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Peter Hurley @ 2015-03-06 19:25 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Grant Likely
Cc: linux-serial, linux-kernel, 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 6449834..680ff4a 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -69,6 +69,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;
@@ -82,6 +83,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)
@@ -113,16 +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_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.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 -next 10/14] serial: earlycon: Show the earlycon "driver" in banner
2015-03-06 19:25 [PATCH v2 -next 00/14] OF earlycon cleanup Peter Hurley
` (8 preceding siblings ...)
2015-03-06 19:25 ` [PATCH v2 -next 09/14] serial: earlycon: Common log banner for command line and DT Peter Hurley
@ 2015-03-06 19:25 ` Peter Hurley
2015-03-06 19:25 ` [PATCH v2 -next 11/14] of: earlycon: Allow multiple OF_EARLYCON_DECLARE() with same name Peter Hurley
` (3 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Peter Hurley @ 2015-03-06 19:25 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Grant Likely
Cc: linux-serial, linux-kernel, 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 680ff4a..0d93c36 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -85,12 +85,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.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 -next 11/14] of: earlycon: Allow multiple OF_EARLYCON_DECLARE() with same name
2015-03-06 19:25 [PATCH v2 -next 00/14] OF earlycon cleanup Peter Hurley
` (9 preceding siblings ...)
2015-03-06 19:25 ` [PATCH v2 -next 10/14] serial: earlycon: Show the earlycon "driver" in banner Peter Hurley
@ 2015-03-06 19:25 ` Peter Hurley
2015-03-06 19:25 ` [PATCH v2 -next 12/14] of: earlycon: Log more helpful message if earlycon not found Peter Hurley
` (2 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Peter Hurley @ 2015-03-06 19:25 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Grant Likely
Cc: linux-serial, linux-kernel, Peter Hurley
Since matching is performed only on the compatible string, allow
multiple declarations of OF_EARLYCON_DECLARE() with the same name.
For example,
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);
Generate a unique identifier for each declaration in the current
compilation unit.
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
include/linux/serial_core.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 675d36f..0a711a7 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -362,7 +362,7 @@ extern int of_setup_earlycon(const struct of_device_id *match,
#endif
#define OF_EARLYCON_DECLARE(_name, compat, fn) \
- static const struct of_device_id __of_table_##_name \
+ static const struct of_device_id __UNIQUE_ID(_name) \
EARLYCON_OF_TABLE_ATTR \
= { .name = __stringify(_name), \
.compatible = compat, \
--
2.3.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 -next 12/14] of: earlycon: Log more helpful message if earlycon not found
2015-03-06 19:25 [PATCH v2 -next 00/14] OF earlycon cleanup Peter Hurley
` (10 preceding siblings ...)
2015-03-06 19:25 ` [PATCH v2 -next 11/14] of: earlycon: Allow multiple OF_EARLYCON_DECLARE() with same name Peter Hurley
@ 2015-03-06 19:25 ` Peter Hurley
2015-03-06 19:25 ` [PATCH v2 -next 13/14] serial: 8250_early: Use port->regshift Peter Hurley
2015-03-06 19:25 ` [PATCH v2 -next 14/14] serial: 8250_omap: Add omap8250 earlycon Peter Hurley
13 siblings, 0 replies; 15+ messages in thread
From: Peter Hurley @ 2015-03-06 19:25 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Grant Likely
Cc: linux-serial, linux-kernel, 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 0850517..7b8eae3 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", p);
+ return 0;
}
static int __init setup_of_earlycon(char *buf)
--
2.3.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 -next 13/14] serial: 8250_early: Use port->regshift
2015-03-06 19:25 [PATCH v2 -next 00/14] OF earlycon cleanup Peter Hurley
` (11 preceding siblings ...)
2015-03-06 19:25 ` [PATCH v2 -next 12/14] of: earlycon: Log more helpful message if earlycon not found Peter Hurley
@ 2015-03-06 19:25 ` Peter Hurley
2015-03-06 19:25 ` [PATCH v2 -next 14/14] serial: 8250_omap: Add omap8250 earlycon Peter Hurley
13 siblings, 0 replies; 15+ messages in thread
From: Peter Hurley @ 2015-03-06 19:25 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Grant Likely
Cc: linux-serial, linux-kernel, 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 a2b4e58..53db31c 100644
--- a/drivers/tty/serial/8250/8250_early.c
+++ b/drivers/tty/serial/8250/8250_early.c
@@ -38,11 +38,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:
@@ -52,12 +54,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.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 -next 14/14] serial: 8250_omap: Add omap8250 earlycon
2015-03-06 19:25 [PATCH v2 -next 00/14] OF earlycon cleanup Peter Hurley
` (12 preceding siblings ...)
2015-03-06 19:25 ` [PATCH v2 -next 13/14] serial: 8250_early: Use port->regshift Peter Hurley
@ 2015-03-06 19:25 ` Peter Hurley
13 siblings, 0 replies; 15+ messages in thread
From: Peter Hurley @ 2015-03-06 19:25 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Grant Likely
Cc: linux-serial, linux-kernel, 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 53db31c..daa983d 100644
--- a/drivers/tty/serial/8250/8250_early.c
+++ b/drivers/tty/serial/8250/8250_early.c
@@ -169,5 +169,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.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
end of thread, other threads:[~2015-03-06 19:30 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-06 19:25 [PATCH v2 -next 00/14] OF earlycon cleanup Peter Hurley
2015-03-06 19:25 ` [PATCH v2 -next 01/14] of: earlycon: Fix 'stdout-path' with ':' path terminator Peter Hurley
2015-03-06 19:25 ` [PATCH v2 -next 02/14] serial: earlycon: Fixup earlycon console name and index Peter Hurley
2015-03-06 19:25 ` [PATCH v2 -next 03/14] serial: earlycon: Emit earlycon name in the OF table Peter Hurley
2015-03-06 19:25 ` [PATCH v2 -next 04/14] of: earlycon: Fixup earlycon console name and index Peter Hurley
2015-03-06 19:25 ` [PATCH v2 -next 05/14] of: earlycon: Add options string handling Peter Hurley
2015-03-06 19:25 ` [PATCH v2 -next 06/14] of: earlycon: of_setup_earlycon() requires CONFIG_OF_EARLY_FLATTREE Peter Hurley
2015-03-06 19:25 ` [PATCH v2 -next 07/14] of: earlycon: Initialize port fields from DT properties Peter Hurley
2015-03-06 19:25 ` [PATCH v2 -next 08/14] of: earlycon: Move address translation to of_setup_earlycon() Peter Hurley
2015-03-06 19:25 ` [PATCH v2 -next 09/14] serial: earlycon: Common log banner for command line and DT Peter Hurley
2015-03-06 19:25 ` [PATCH v2 -next 10/14] serial: earlycon: Show the earlycon "driver" in banner Peter Hurley
2015-03-06 19:25 ` [PATCH v2 -next 11/14] of: earlycon: Allow multiple OF_EARLYCON_DECLARE() with same name Peter Hurley
2015-03-06 19:25 ` [PATCH v2 -next 12/14] of: earlycon: Log more helpful message if earlycon not found Peter Hurley
2015-03-06 19:25 ` [PATCH v2 -next 13/14] serial: 8250_early: Use port->regshift Peter Hurley
2015-03-06 19:25 ` [PATCH v2 -next 14/14] serial: 8250_omap: Add omap8250 earlycon Peter Hurley
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 NNTP newsgroup(s).