Earlycon cleanup
Subsystems (8)
v3 cover Earlycon cleanup
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(-)
Signature · 1 line
2.3.5
PATCH v3 1/13 of: earlycon: Fix 'stdout-path' with ':' path terminator
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()"
--- drivers/of/fdt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/of/fdt.c +4 -2
@@ -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 ;
Signature · 1 line
2.3.5
Re: [PATCH v3 01/13] of: earlycon: Fix 'stdout-path' with ':' path terminator
Quoted 11 lines · Peter Hurley
stdout-path defines ':' as a path terminator and commit
75c28c09af99a("of: add optional options parameter toof_find_node_by_path()") added the necessary support to parse paths terminated with ':'. commit7914a7c5651a5("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
Quoted 34 lines
Cc Leif Lindholm <[email protected]>Signed-off-by Peter Hurley <[email protected]>--- drivers/of/fdt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/of/fdt.c +4
-3@@ -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
Re: [PATCH v3 01/13] of: earlycon: Fix 'stdout-path' with ':' path terminator
Quoted 8 lines · Rob Herring
Quoted 7 lines · Peter Hurley
stdout-path defines ':' as a path terminator and commit
75c28c09af99a("of: add optional options parameter toof_find_node_by_path()") added the necessary support to parse paths terminated with ':'. commit7914a7c5651a5("of: support passing console options with stdout-path") added options string support to the stdout-path property, which broke earlycon.
Quoted 8 lines
Quoted 4 lines
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
Greg Kroah-Hartman
maintainerRe: [PATCH v3 01/13] of: earlycon: Fix 'stdout-path' with ':' path terminator
Quoted 18 lines · Peter Hurley
Quoted 8 lines · Rob Herring
Quoted 7 lines · Peter Hurley
stdout-path defines ':' as a path terminator and commit
75c28c09af99a("of: add optional options parameter toof_find_node_by_path()") added the necessary support to parse paths terminated with ':'. commit7914a7c5651a5("of: support passing console options with stdout-path") added options string support to the stdout-path property, which broke earlycon.Quoted 8 lines
Quoted 4 lines
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.
Quoted 5 lines
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
Re: [PATCH v3 01/13] of: earlycon: Fix 'stdout-path' with ':' path terminator
Quoted 19 lines · Greg Kroah-Hartman
Quoted 18 lines · Peter Hurley
Quoted 16 lines · Rob Herring
Quoted 11 lines · Peter Hurley
stdout-path defines ':' as a path terminator and commit
75c28c09af99a("of: add optional options parameter toof_find_node_by_path()") added the necessary support to parse paths terminated with ':'. commit7914a7c5651a5("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.
Quoted 7 lines
Quoted 5 lines
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
Re: [PATCH v3 01/13] of: earlycon: Fix 'stdout-path' with ':' path terminator
Quoted 28 lines · Peter Hurley
Quoted 19 lines · Greg Kroah-Hartman
Quoted 18 lines · Peter Hurley
Quoted 16 lines · Rob Herring
Quoted 11 lines · Peter Hurley
stdout-path defines ':' as a path terminator and commit
75c28c09af99a("of: add optional options parameter toof_find_node_by_path()") added the necessary support to parse paths terminated with ':'. commit7914a7c5651a5("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.
Quoted 7 lines
Quoted 5 lines
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?
Quoted 8 lines
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
Re: [PATCH v3 01/13] of: earlycon: Fix 'stdout-path' with ':' path terminator
In reply to Peter HurleyQuoted 10 lines · Peter Hurley
stdout-path defines ':' as a path terminator and commit
75c28c09af99a("of: add optional options parameter toof_find_node_by_path()") added the necessary support to parse paths terminated with ':'. commit7914a7c5651a5("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
Quoted 40 lines
Requires: "libfdt: Add
fdt_path_offset_namelen()"Cc Leif Lindholm <[email protected]>Signed-off-by Peter Hurley <[email protected]>--- drivers/of/fdt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/of/fdt.c +4
-3@@ -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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
PATCH v3 2/13 earlycon: Use common framework for earlycon declarations
In reply to Peter HurleyUse 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.
--- 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(-)
drivers/of/fdt.c +8 -7
@@ -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 ;
drivers/tty/serial/amba-pl011.c +0 -1
@@ -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
drivers/tty/serial/arc_uart.c +0 -1
@@ -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 */
drivers/tty/serial/earlycon.c +1 -9
@@ -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))
drivers/tty/serial/msm_serial.c +0 -2
@@ -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);
drivers/tty/serial/samsung.c +0 -6
@@ -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" );
drivers/tty/serial/sprd_serial.c +0 -2
@@ -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);
include/asm-generic/vmlinux.lds.h +3 -5
@@ -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) \
include/linux/serial_core.h +13 -9
@@ -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,
Signature · 1 line
2.3.5
PATCH v3 3/13 serial: earlycon: Fixup earlycon console name and index
In reply to Peter HurleyProperly 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.
--- drivers/tty/serial/earlycon.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-)
drivers/tty/serial/earlycon.c +22 -3
@@ -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;
Signature · 1 line
2.3.5
PATCH v3 4/13 of: earlycon: Fixup earlycon console name and index
In reply to Peter HurleyUse the console name embedded in the OF earlycon table by the OF_EARLYCON_DECLARE() macro to initialize the struct console 'name' and 'index' fields.
--- drivers/of/fdt.c | 2 +- drivers/tty/serial/earlycon.c | 6 +++--- include/linux/serial_core.h | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-)
drivers/of/fdt.c +1 -1
@@ -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 ;
drivers/tty/serial/earlycon.c +3 -3
@@ -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)
include/linux/serial_core.h +1 -2
@@ -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);
Signature · 1 line
2.3.5
PATCH v3 5/13 of: earlycon: Add options string handling
In reply to Peter HurleyPass-through any options string in the 'stdout-path' property to the earlycon "driver" setup.
--- drivers/of/fdt.c | 6 ++++-- drivers/tty/serial/earlycon.c | 9 +++++++-- include/linux/serial_core.h | 3 ++- 3 files changed, 13 insertions(+), 5 deletions(-)
drivers/of/fdt.c +4 -2
@@ -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 ;
drivers/tty/serial/earlycon.c +7 -2
@@ -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)
include/linux/serial_core.h +2 -1
@@ -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);
Signature · 1 line
2.3.5
PATCH v3 6/13 of: earlycon: of_setup_earlycon() requires CONFIG_OF_EARLY_FLATTREE
In reply to Peter HurleyDT earlycon is only supported for CONFIG_OF_EARLY_FLATTREE=y; exclude of_setup_earlycon() if not defined.
--- drivers/tty/serial/earlycon.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/tty/serial/earlycon.c +4 -0
@@ -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 */
Signature · 1 line
2.3.5
PATCH v3 7/13 of: earlycon: Initialize port fields from DT properties
In reply to Peter HurleyRead 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.
--- drivers/of/fdt.c | 2 +- drivers/tty/serial/earlycon.c | 27 +++++++++++++++++++++++++++ include/linux/serial_core.h | 1 + 3 files changed, 29 insertions(+), 1 deletion(-)
drivers/of/fdt.c +1 -1
@@ -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 ;
drivers/tty/serial/earlycon.c +27 -0
@@ -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));
include/linux/serial_core.h +1 -0
@@ -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,
Signature · 1 line
2.3.5
PATCH v3 8/13 of: earlycon: Move address translation to of_setup_earlycon()
In reply to Peter HurleyCleanup 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.
--- 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(-)
drivers/of/fdt.c +1 -7
@@ -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 ;
drivers/of/fdt_address.c +10 -1
@@ -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); +}
drivers/tty/serial/earlycon.c +7 -4
@@ -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)
include/linux/of_fdt.h +1 -1
@@ -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 ) {}
include/linux/serial_core.h +1 -1
@@ -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);
Signature · 1 line
2.3.5
PATCH v3 9/13 serial: earlycon: Common log banner for command line and DT
In reply to Peter HurleyRefactor the command line earlycon banner into earlycon_init() so both earlycon startup methods output an info banner.
--- drivers/tty/serial/earlycon.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
drivers/tty/serial/earlycon.c +11 -10
@@ -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 ; }
Signature · 1 line
2.3.5
PATCH v3 10/13 serial: earlycon: Show the earlycon "driver" in banner
In reply to Peter HurleyOutput the earlycon "driver" from the just-parsed console 'name' and 'index' fields.
NB: ->mapbase is a resource_size_t so use %pa format specifier
--- drivers/tty/serial/earlycon.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/tty/serial/earlycon.c +5 -3
@@ -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); }
Signature · 1 line
2.3.5
PATCH v3 11/13 of: earlycon: Log more helpful message if earlycon not found
In reply to Peter HurleyEarlycon 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).
--- drivers/of/fdt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/of/fdt.c +2 -1
@@ -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)
Signature · 1 line
2.3.5
PATCH v3 12/13 serial: 8250_early: Use port->regshift
In reply to Peter Hurleyearlycon 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).
--- drivers/tty/serial/8250/8250_early.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/tty/serial/8250/8250_early.c +6 -2
@@ -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 offsevoid __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);
Signature · 1 line
2.3.5
Greg Kroah-Hartman
maintainerRe: [PATCH v3 12/13] serial: 8250_early: Use port->regshift
Quoted 11 lines · Peter Hurley
earlycon initializes struct
uart_port::regshiftto the correct value forUPIO_MEM32already. 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 <[email protected]>--- 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
PATCH v3 13/13 serial: 8250_omap: Add omap8250 earlycon
In reply to Peter HurleyAdd 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";
} };
};
--- drivers/tty/serial/8250/8250_early.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
drivers/tty/serial/8250/8250_early.c +21 -0
@@ -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
Signature · 1 line
2.3.5
Quoted 24 lines · 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 withof_serialproperties (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 compileof_setup_earlycon();
Note: this should have already been the case sinceof_setup_earlycon()is dead code withoutCONFIG_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
Quoted 8 lines
* 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"
Quoted 35 lines
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()requiresCONFIG_OF_EARLY_FLATTREE
of: earlycon: Initialize port fields from DT properties
of: earlycon: Move address translation toof_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: Useport->regshift
serial: 8250_omap: Add omap8250 earlycondrivers/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(-)
v4 cover Earlycon cleanup
In reply to Peter HurleyHi 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(-)
Signature · 1 line
2.7.0
PATCH v4 1/11 earlycon: Use common framework for earlycon declarations
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.
--- 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(-)
drivers/of/fdt.c +7 -7
@@ -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 ;
drivers/tty/serial/amba-pl011.c +0 -1
@@ -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
drivers/tty/serial/arc_uart.c +0 -1
@@ -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 */
drivers/tty/serial/earlycon.c +1 -9
@@ -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))
drivers/tty/serial/msm_serial.c +0 -2
@@ -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);
drivers/tty/serial/samsung.c +0 -6
@@ -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" );
drivers/tty/serial/sprd_serial.c +0 -2
@@ -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);
include/asm-generic/vmlinux.lds.h +2 -4
@@ -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) \
include/linux/serial_core.h +13 -9
@@ -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,
Signature · 1 line
2.7.0
PATCH v4 2/11 serial: earlycon: Fixup earlycon console name and index
In reply to Peter HurleyProperly 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.
--- drivers/tty/serial/earlycon.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-)
drivers/tty/serial/earlycon.c +22 -3
@@ -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;
Signature · 1 line
2.7.0
PATCH v4 3/11 of: earlycon: Fixup earlycon console name and index
In reply to Peter HurleyUse the console name embedded in the OF earlycon table by the OF_EARLYCON_DECLARE() macro to initialize the struct console 'name' and 'index' fields.
--- drivers/of/fdt.c | 2 +- drivers/tty/serial/earlycon.c | 6 +++--- include/linux/serial_core.h | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-)
drivers/of/fdt.c +1 -1
@@ -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 ;
drivers/tty/serial/earlycon.c +3 -3
@@ -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)
include/linux/serial_core.h +1 -2
@@ -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);
Signature · 1 line
2.7.0
PATCH v4 4/11 of: earlycon: Add options string handling
In reply to Peter HurleyPass-through any options string in the 'stdout-path' property to the earlycon "driver" setup.
--- drivers/of/fdt.c | 11 ++++++----- drivers/tty/serial/earlycon.c | 9 +++++++-- include/linux/serial_core.h | 3 ++- 3 files changed, 15 insertions(+), 8 deletions(-)
drivers/of/fdt.c +6 -5
@@ -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 ;
drivers/tty/serial/earlycon.c +7 -2
@@ -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)
include/linux/serial_core.h +2 -1
@@ -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);
Signature · 1 line
2.7.0
PATCH v4 5/11 of: earlycon: Initialize port fields from DT properties
In reply to Peter HurleyRead 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.
--- drivers/of/fdt.c | 2 +- drivers/tty/serial/earlycon.c | 34 ++++++++++++++++++++++++++++++++++ include/linux/serial_core.h | 1 + 3 files changed, 36 insertions(+), 1 deletion(-)
drivers/of/fdt.c +1 -1
@@ -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 ;
drivers/tty/serial/earlycon.c +34 -0
@@ -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));
include/linux/serial_core.h +1 -0
@@ -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,
Signature · 1 line
2.7.0
Re: [PATCH v4 05/11] of: earlycon: Initialize port fields from DT properties
Quoted 15 lines · Peter Hurley
Read the optional "reg-offset", "reg-shift", "reg-io-width" and endianness properties and initialize the respective struct
uart_portfield 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 <[email protected]>---
drivers/tty/serial/earlycon.c +0
-0
drivers/tty/serial/earlycon.c line 25
Quoted 6 lines
drivers/tty/serial/earlycon.c +3
-0@@ -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.
Quoted 4 lines
drivers/tty/serial/earlycon.c +1
-0+#ifdef CONFIG_FIX_EARLYCON_MEM #include <asm/fixmap.h> #endif
Re: [PATCH v4 05/11] of: earlycon: Initialize port fields from DT properties
Quoted 19 lines · Rob Herring
Quoted 18 lines · Peter Hurley
Read the optional "reg-offset", "reg-shift", "reg-io-width" and endianness properties and initialize the respective struct
uart_portfield 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 <[email protected]>---
drivers/tty/serial/earlycon.c +0
-0@@ -20,6 +20,10 @@#include <linux/serial_core.h> #include <linux/sizes.h>
Quoted 10 lines
drivers/tty/serial/earlycon.c line 25
Quoted 3 lines
drivers/tty/serial/earlycon.c +3
-0+#ifdef CONFIG_OF_EARLY_FLATTREE +#include <linux/of_fdt.h> +#endif I think you don't need the ifdef around this.
Quoted 4 lines
drivers/tty/serial/earlycon.c +1
-0+#ifdef CONFIG_FIX_EARLYCON_MEM #include <asm/fixmap.h> #endif
Ok, will take care of that.
PATCH v4 6/11 of: earlycon: Move address translation to of_setup_earlycon()
In reply to Peter HurleyCleanup 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.
--- 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(-)
drivers/of/fdt.c +1 -7
@@ -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 ;
drivers/of/fdt_address.c +10 -1
@@ -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); +}
drivers/tty/serial/earlycon.c +9 -3
@@ -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)
include/linux/of_fdt.h +1 -1
@@ -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 ) {}
include/linux/serial_core.h +1 -1
@@ -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);
Signature · 1 line
2.7.0
PATCH v4 7/11 serial: earlycon: Common log banner for command line and DT
In reply to Peter HurleyRefactor the command line earlycon banner into earlycon_init() so both earlycon startup methods output an info banner.
--- drivers/tty/serial/earlycon.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)
drivers/tty/serial/earlycon.c +14 -13
@@ -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 ; }
Signature · 1 line
2.7.0
PATCH v4 8/11 serial: earlycon: Show the earlycon "driver" in banner
In reply to Peter HurleyOutput the earlycon "driver" from the just-parsed console 'name' and 'index' fields.
NB: ->mapbase is a resource_size_t so use %pa format specifier
--- drivers/tty/serial/earlycon.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/tty/serial/earlycon.c +6 -6
@@ -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)
Signature · 1 line
2.7.0
PATCH v4 9/11 serial: 8250_early: Use port->regshift
In reply to Peter Hurleyearlycon 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).
--- drivers/tty/serial/8250/8250_early.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/tty/serial/8250/8250_early.c +10 -6
@@ -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 offsestatic 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);
Signature · 1 line
2.7.0
PATCH v4 10/11 of: earlycon: Log more helpful message if stdout-path node not found
In reply to Peter HurleyEarlycon 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).
--- drivers/of/fdt.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/of/fdt.c +6 -3
@@ -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 ])
Signature · 1 line
2.7.0
Re: [PATCH v4 10/11] of: earlycon: Log more helpful message if stdout-path node not found
Quoted 9 lines · 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 <[email protected]>--- drivers/of/fdt.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
PATCH v4 11/11 serial: 8250_omap: Add omap8250 earlycon
In reply to Peter HurleyAdd 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";
} };
};
--- drivers/tty/serial/8250/8250_early.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/tty/serial/8250/8250_early.c +20 -0
@@ -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
Signature · 1 line
2.7.0
Re: [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon
Wasn't planning on sending this patch just yet, but oh well.
Quoted 38 lines · 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, andCONFIG_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 <[email protected]>--- drivers/tty/serial/8250/8250_early.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)drivers/tty/serial/8250/8250_early.c +0
-0
drivers/tty/serial/8250/8250_early.c EARLYCON_DECLARE(rt288x, early_rt288x_setup); · line 203
Quoted 3 lines
drivers/tty/serial/8250/8250_early.c +0
-0@@ -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
Quoted 21 lines
drivers/tty/serial/8250/8250_early.c +20
-0+ +#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
Re: [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon
Quoted 51 lines · Peter Hurley
Wasn't planning on sending this patch just yet, but oh well.
Quoted 38 lines · 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, andCONFIG_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 <[email protected]>--- drivers/tty/serial/8250/8250_early.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)drivers/tty/serial/8250/8250_early.c +0
-0drivers/tty/serial/8250/8250_early.c EARLYCON_DECLARE(rt288x, early_rt288x_setup); · line 203
Quoted 3 lines
drivers/tty/serial/8250/8250_early.c +0
-0@@ -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
Quoted 15 lines
Quoted 5 lines
drivers/tty/serial/8250/8250_early.c +5
-0+ +#ifdef CONFIG_SERIAL_8250_OMAP + +static int __init early_omap8250_setup (struct earlycon_device *device, +const char *options)drivers/tty/serial/8250/8250_early.c EARLYCON_DECLARE(rt288x, early_rt288x_setup); · line 218
Quoted 10 lines
drivers/tty/serial/8250/8250_early.c +10
-0+{ +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?
Quoted 4 lines
drivers/tty/serial/8250/8250_early.c EARLYCON_DECLARE(rt288x, early_rt288x_setup); · line 223
Quoted 4 lines
drivers/tty/serial/8250/8250_early.c +4
-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
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
Re: [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon
Quoted 64 lines · Jon Hunter
Quoted 62 lines · Peter Hurley
Wasn't planning on sending this patch just yet, but oh well.
Quoted 38 lines · 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, andCONFIG_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 <[email protected]>--- drivers/tty/serial/8250/8250_early.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)drivers/tty/serial/8250/8250_early.c +0
-0drivers/tty/serial/8250/8250_early.c EARLYCON_DECLARE(rt288x, early_rt288x_setup); · line 203
Quoted 3 lines
drivers/tty/serial/8250/8250_early.c +0
-0@@ -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 HurleyQuoted 11 lines
drivers/tty/serial/8250/8250_early.c +11
-0+ +#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 ; +
Quoted 8 lines
Quoted 4 lines
drivers/tty/serial/8250/8250_early.c EARLYCON_DECLARE(rt288x, early_rt288x_setup); · line 218
Quoted 4 lines
drivers/tty/serial/8250/8250_early.c +4
-0+ 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.
Quoted 4 lines
Quoted 4 lines
drivers/tty/serial/8250/8250_early.c EARLYCON_DECLARE(rt288x, early_rt288x_setup); · line 223
Quoted 4 lines
drivers/tty/serial/8250/8250_early.c +4
-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
Jon
Re: [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon
In reply to Jon HunterQuoted 64 lines · Jon Hunter
Quoted 62 lines · Peter Hurley
Wasn't planning on sending this patch just yet, but oh well.
Quoted 38 lines · 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, andCONFIG_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 <[email protected]>--- drivers/tty/serial/8250/8250_early.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)drivers/tty/serial/8250/8250_early.c +0
-0drivers/tty/serial/8250/8250_early.c EARLYCON_DECLARE(rt288x, early_rt288x_setup); · line 203
Quoted 3 lines
drivers/tty/serial/8250/8250_early.c +0
-0@@ -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 HurleyQuoted 11 lines
drivers/tty/serial/8250/8250_early.c +11
-0+ +#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 ; +
Quoted 8 lines
Quoted 4 lines
drivers/tty/serial/8250/8250_early.c EARLYCON_DECLARE(rt288x, early_rt288x_setup); · line 218
Quoted 4 lines
drivers/tty/serial/8250/8250_early.c +4
-0+ 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
Re: [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon
Hi Jon,
Quoted 73 lines · Jon Hunter
Quoted 63 lines · Jon Hunter
Quoted 62 lines · Peter Hurley
Wasn't planning on sending this patch just yet, but oh well.
Quoted 38 lines · 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, andCONFIG_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 <[email protected]>--- drivers/tty/serial/8250/8250_early.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)drivers/tty/serial/8250/8250_early.c +0
-0drivers/tty/serial/8250/8250_early.c EARLYCON_DECLARE(rt288x, early_rt288x_setup); · line 203
Quoted 3 lines
drivers/tty/serial/8250/8250_early.c +0
-0@@ -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 HurleyQuoted 11 lines
drivers/tty/serial/8250/8250_early.c +11
-0+ +#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 ; +Quoted 8 lines
Quoted 4 lines
drivers/tty/serial/8250/8250_early.c EARLYCON_DECLARE(rt288x, early_rt288x_setup); · line 218
Quoted 4 lines
drivers/tty/serial/8250/8250_early.c +4
-0+ 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?
Quoted 2 lines
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
Quoted 4 lines
Jon
Re: [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon
Hi Peter,
Quoted 76 lines · Peter Hurley
Hi Jon,
Quoted 73 lines · Jon Hunter
Quoted 71 lines · Jon Hunter
Quoted 51 lines · Peter Hurley
Wasn't planning on sending this patch just yet, but oh well.
Quoted 38 lines · 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, andCONFIG_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 <[email protected]>--- drivers/tty/serial/8250/8250_early.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)drivers/tty/serial/8250/8250_early.c +0
-0drivers/tty/serial/8250/8250_early.c EARLYCON_DECLARE(rt288x, early_rt288x_setup); · line 203
Quoted 3 lines
drivers/tty/serial/8250/8250_early.c +0
-0@@ -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 HurleyQuoted 15 lines
Quoted 5 lines
drivers/tty/serial/8250/8250_early.c +5
-0+ +#ifdef CONFIG_SERIAL_8250_OMAP + +static int __init early_omap8250_setup (struct earlycon_device *device, +const char *options)drivers/tty/serial/8250/8250_early.c EARLYCON_DECLARE(rt288x, early_rt288x_setup); · line 218
Quoted 10 lines
drivers/tty/serial/8250/8250_early.c +10
-0+{ +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?
Quoted 4 lines
Quoted 2 lines
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.
Quoted 19 lines
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.cFor regular 8250 DT nodes, the only requirement should be the
OF_EARLYCON_DECLARE()to associate the compatible string withearly_serial8250_setup()(and a unique earlycon name such as the one you already used).
Quoted 7 lines
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.
Quoted 1 line
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
Quoted 20 lines · 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 withof_serialproperties (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)
Quoted 6 lines
Rob has expressed a desire to have the DT parts live in
drivers/of/fdt.cThe 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:
v5 cover Earlycon cleanup
In reply to Peter HurleyHi 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(-)
Signature · 1 line
2.7.0
PATCH v5 1/11 earlycon: Use common framework for earlycon declarations
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.
--- 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(-)
drivers/of/fdt.c +7 -7
@@ -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 ;
drivers/tty/serial/amba-pl011.c +0 -1
@@ -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
drivers/tty/serial/arc_uart.c +0 -1
@@ -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 */
drivers/tty/serial/earlycon.c +1 -9
@@ -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))
drivers/tty/serial/msm_serial.c +0 -2
@@ -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);
drivers/tty/serial/samsung.c +0 -6
@@ -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" );
drivers/tty/serial/sprd_serial.c +0 -2
@@ -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);
include/asm-generic/vmlinux.lds.h +2 -4
@@ -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) \
include/linux/serial_core.h +13 -9
@@ -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,
Signature · 1 line
2.7.0
PATCH v5 2/11 serial: earlycon: Fixup earlycon console name and index
In reply to Peter HurleyProperly 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.
--- drivers/tty/serial/earlycon.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-)
drivers/tty/serial/earlycon.c +22 -3
@@ -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;
Signature · 1 line
2.7.0
PATCH v5 3/11 of: earlycon: Fixup earlycon console name and index
In reply to Peter HurleyUse the console name embedded in the OF earlycon table by the OF_EARLYCON_DECLARE() macro to initialize the struct console 'name' and 'index' fields.
--- drivers/of/fdt.c | 2 +- drivers/tty/serial/earlycon.c | 6 +++--- include/linux/serial_core.h | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-)
drivers/of/fdt.c +1 -1
@@ -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 ;
drivers/tty/serial/earlycon.c +3 -3
@@ -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)
include/linux/serial_core.h +1 -2
@@ -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);
Signature · 1 line
2.7.0
PATCH v5 4/11 of: earlycon: Add options string handling
In reply to Peter HurleyPass-through any options string in the 'stdout-path' property to the earlycon "driver" setup.
--- drivers/of/fdt.c | 11 ++++++----- drivers/tty/serial/earlycon.c | 9 +++++++-- include/linux/serial_core.h | 3 ++- 3 files changed, 15 insertions(+), 8 deletions(-)
drivers/of/fdt.c +6 -5
@@ -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 ;
drivers/tty/serial/earlycon.c +7 -2
@@ -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)
include/linux/serial_core.h +2 -1
@@ -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);
Signature · 1 line
2.7.0
PATCH v5 5/11 of: earlycon: Initialize port fields from DT properties
In reply to Peter HurleyRead 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.
--- drivers/of/fdt.c | 2 +- drivers/tty/serial/earlycon.c | 31 +++++++++++++++++++++++++++++++ include/linux/serial_core.h | 1 + 3 files changed, 33 insertions(+), 1 deletion(-)
drivers/of/fdt.c +1 -1
@@ -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 ;
drivers/tty/serial/earlycon.c +31 -0
@@ -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));
include/linux/serial_core.h +1 -0
@@ -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,
Signature · 1 line
2.7.0
kbuild test robot
build botRe: [PATCH v5 05/11] of: earlycon: Initialize port fields from DT properties
reproduce:
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
PATCH v5 6/11 of: earlycon: Move address translation to of_setup_earlycon()
In reply to Peter HurleyCleanup 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.
--- 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(-)
drivers/of/fdt.c +1 -7
@@ -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 ;
drivers/of/fdt_address.c +10 -1
@@ -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); +}
drivers/tty/serial/earlycon.c +9 -3
@@ -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)
include/linux/of_fdt.h +1 -1
@@ -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 ) {}
include/linux/serial_core.h +1 -1
@@ -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);
Signature · 1 line
2.7.0
kbuild test robot
build botRe: [PATCH v5 06/11] of: earlycon: Move address translation to of_setup_earlycon()
reproduce:
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
PATCH v5 7/11 serial: earlycon: Common log banner for command line and DT
In reply to Peter HurleyRefactor the command line earlycon banner into earlycon_init() so both earlycon startup methods output an info banner.
--- drivers/tty/serial/earlycon.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)
drivers/tty/serial/earlycon.c +14 -13
@@ -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 ; }
Signature · 1 line
2.7.0
PATCH v5 8/11 serial: earlycon: Show the earlycon "driver" in banner
In reply to Peter HurleyOutput the earlycon "driver" from the just-parsed console 'name' and 'index' fields.
NB: ->mapbase is a resource_size_t so use %pa format specifier
--- drivers/tty/serial/earlycon.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/tty/serial/earlycon.c +6 -6
@@ -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)
Signature · 1 line
2.7.0
PATCH v5 9/11 serial: 8250_early: Use port->regshift
In reply to Peter Hurleyearlycon 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).
--- drivers/tty/serial/8250/8250_early.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/tty/serial/8250/8250_early.c +10 -6
@@ -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 offsestatic 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);
Signature · 1 line
2.7.0
PATCH v5 10/11 of: earlycon: Log more helpful message if stdout-path node not found
In reply to Peter HurleyEarlycon 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).
--- drivers/of/fdt.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/of/fdt.c +6 -3
@@ -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 ])
Signature · 1 line
2.7.0
PATCH v5 11/11 serial: 8250_omap: Add omap8250 earlycon
In reply to Peter HurleyAdd 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";
} };
};
--- drivers/tty/serial/8250/8250_early.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
drivers/tty/serial/8250/8250_early.c +21 -0
@@ -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
Signature · 1 line
2.7.0
v6 cover Earlycon cleanup
In reply to Peter HurleyHi 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(-)
Signature · 1 line
2.7.0
PATCH v6 1/12 of: earlycon: of_setup_earlycon() requires CONFIG_OF_EARLY_FLATTREE
DT earlycon is only supported for CONFIG_OF_EARLY_FLATTREE=y; exclude of_setup_earlycon() if not defined.
--- drivers/tty/serial/earlycon.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/tty/serial/earlycon.c +4 -0
@@ -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 */
Signature · 1 line
2.7.0
PATCH v6 2/12 earlycon: Use common framework for earlycon declarations
In reply to Peter HurleyUse 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.
--- 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(-)
drivers/of/fdt.c +7 -7
@@ -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 ;
drivers/tty/serial/amba-pl011.c +0 -1
@@ -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
drivers/tty/serial/arc_uart.c +0 -1
@@ -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 */
drivers/tty/serial/earlycon.c +1 -9
@@ -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))
drivers/tty/serial/msm_serial.c +0 -2
@@ -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);
drivers/tty/serial/samsung.c +0 -6
@@ -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" );
drivers/tty/serial/sprd_serial.c +0 -2
@@ -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);
include/asm-generic/vmlinux.lds.h +2 -4
@@ -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) \
include/linux/serial_core.h +13 -9
@@ -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,
Signature · 1 line
2.7.0
PATCH v6 3/12 serial: earlycon: Fixup earlycon console name and index
In reply to Peter HurleyProperly 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.
--- drivers/tty/serial/earlycon.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-)
drivers/tty/serial/earlycon.c +22 -3
@@ -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;
Signature · 1 line
2.7.0
PATCH v6 4/12 of: earlycon: Fixup earlycon console name and index
In reply to Peter HurleyUse the console name embedded in the OF earlycon table by the OF_EARLYCON_DECLARE() macro to initialize the struct console 'name' and 'index' fields.
--- drivers/of/fdt.c | 2 +- drivers/tty/serial/earlycon.c | 6 +++--- include/linux/serial_core.h | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-)
drivers/of/fdt.c +1 -1
@@ -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 ;
drivers/tty/serial/earlycon.c +3 -3
@@ -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)
include/linux/serial_core.h +1 -2
@@ -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);
Signature · 1 line
2.7.0
PATCH v6 5/12 of: earlycon: Add options string handling
In reply to Peter HurleyPass-through any options string in the 'stdout-path' property to the earlycon "driver" setup.
--- drivers/of/fdt.c | 11 ++++++----- drivers/tty/serial/earlycon.c | 9 +++++++-- include/linux/serial_core.h | 3 ++- 3 files changed, 15 insertions(+), 8 deletions(-)
drivers/of/fdt.c +6 -5
@@ -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 ;
drivers/tty/serial/earlycon.c +7 -2
@@ -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)
include/linux/serial_core.h +2 -1
@@ -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);
Signature · 1 line
2.7.0
PATCH v6 6/12 of: earlycon: Initialize port fields from DT properties
In reply to Peter HurleyRead 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.
--- drivers/of/fdt.c | 2 +- drivers/tty/serial/earlycon.c | 31 +++++++++++++++++++++++++++++++ include/linux/serial_core.h | 1 + 3 files changed, 33 insertions(+), 1 deletion(-)
drivers/of/fdt.c +1 -1
@@ -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 ;
drivers/tty/serial/earlycon.c +31 -0
@@ -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));
include/linux/serial_core.h +1 -0
@@ -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,
Signature · 1 line
2.7.0
PATCH v6 7/12 of: earlycon: Move address translation to of_setup_earlycon()
In reply to Peter HurleyCleanup 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.
--- 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(-)
drivers/of/fdt.c +1 -7
@@ -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 ;
drivers/of/fdt_address.c +10 -1
@@ -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); +}
drivers/tty/serial/earlycon.c +9 -3
@@ -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)
include/linux/of_fdt.h +1 -1
@@ -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 ) {}
include/linux/serial_core.h +1 -1
@@ -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);
Signature · 1 line
2.7.0
PATCH v6 8/12 serial: earlycon: Common log banner for command line and DT
In reply to Peter HurleyRefactor the command line earlycon banner into earlycon_init() so both earlycon startup methods output an info banner.
--- drivers/tty/serial/earlycon.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)
drivers/tty/serial/earlycon.c +14 -13
@@ -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 ; }
Signature · 1 line
2.7.0
PATCH v6 9/12 serial: earlycon: Show the earlycon "driver" in banner
In reply to Peter HurleyOutput the earlycon "driver" from the just-parsed console 'name' and 'index' fields.
NB: ->mapbase is a resource_size_t so use %pa format specifier
--- drivers/tty/serial/earlycon.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/tty/serial/earlycon.c +6 -6
@@ -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)
Signature · 1 line
2.7.0
PATCH v6 10/12 serial: 8250_early: Use port->regshift
In reply to Peter Hurleyearlycon 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).
--- drivers/tty/serial/8250/8250_early.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/tty/serial/8250/8250_early.c +10 -6
@@ -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 offsestatic 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);
Signature · 1 line
2.7.0
PATCH v6 11/12 of: earlycon: Log more helpful message if stdout-path node not found
In reply to Peter HurleyEarlycon 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).
--- drivers/of/fdt.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/of/fdt.c +6 -3
@@ -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 ])
Signature · 1 line
2.7.0
PATCH v6 12/12 serial: 8250_omap: Add omap8250 earlycon
In reply to Peter HurleyAdd 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";
} };
};
--- drivers/tty/serial/8250/8250_early.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
drivers/tty/serial/8250/8250_early.c +21 -0
@@ -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
Signature · 1 line
2.7.0
Hi all,
Quoted 4 lines · Peter Hurley
Hi Greg, Grant & Rob,
This patch series is a rebase of the v3 from April last year.
Quoted 10 lines
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 withof_serialproperties (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
Greg Kroah-Hartman
maintainerQuoted 18 lines · Jon Hunter
Hi all,
Quoted 4 lines · Peter Hurley
Hi Greg, Grant & Rob,
This patch series is a rebase of the v3 from April last year.
Quoted 10 lines
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 withof_serialproperties (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
Quoted 3 lines
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