From 2eaa790989e03900298ad24f77f1086dbbc1aebd Mon Sep 17 00:00:00 2001 From: Peter Hurley Date: Sat, 16 Jan 2016 15:23:39 -0800 Subject: 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. Acked-by: Rob Herring Signed-off-by: Peter Hurley Signed-off-by: Greg Kroah-Hartman --- drivers/of/fdt.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'drivers/of') diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 655f79d..1686118 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -796,14 +796,13 @@ static inline void early_init_dt_check_for_initrd(unsigned long node) #endif /* CONFIG_BLK_DEV_INITRD */ #ifdef CONFIG_SERIAL_EARLYCON -extern struct of_device_id __earlycon_of_table[]; static int __init early_init_dt_scan_chosen_serial(void) { int offset; const char *p; int l; - const struct of_device_id *match = __earlycon_of_table; + const struct earlycon_id *match; const void *fdt = initial_boot_params; offset = fdt_path_offset(fdt, "/chosen"); @@ -826,19 +825,20 @@ static int __init early_init_dt_scan_chosen_serial(void) if (offset < 0) return -ENODEV; - while (match->compatible[0]) { + for (match = __earlycon_table; match < __earlycon_table_end; match++) { u64 addr; - if (fdt_node_check_compatible(fdt, offset, match->compatible)) { - match++; + if (!match->compatible[0]) + continue; + + if (fdt_node_check_compatible(fdt, offset, match->compatible)) continue; - } addr = fdt_translate_address(fdt, offset); if (addr == OF_BAD_ADDR) return -ENXIO; - of_setup_earlycon(addr, match->data); + of_setup_earlycon(addr, match->setup); return 0; } return -ENODEV; -- cgit v1.1 From 05d961320ba624c98b16d72b32f947307674b341 Mon Sep 17 00:00:00 2001 From: Peter Hurley Date: Sat, 16 Jan 2016 15:23:41 -0800 Subject: of: earlycon: Fixup earlycon console name and index Use the console name embedded in the OF earlycon table by the OF_EARLYCON_DECLARE() macro to initialize the struct console 'name' and 'index' fields. Acked-by: Rob Herring Signed-off-by: Peter Hurley Signed-off-by: Greg Kroah-Hartman --- drivers/of/fdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/of') diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 1686118..ec14595 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -838,7 +838,7 @@ static int __init early_init_dt_scan_chosen_serial(void) if (addr == OF_BAD_ADDR) return -ENXIO; - of_setup_earlycon(addr, match->setup); + of_setup_earlycon(addr, match); return 0; } return -ENODEV; -- cgit v1.1 From 4d118c9a866590850dad8689262a95345d2c6e09 Mon Sep 17 00:00:00 2001 From: Peter Hurley Date: Sat, 16 Jan 2016 15:23:42 -0800 Subject: of: earlycon: Add options string handling Pass-through any options string in the 'stdout-path' property to the earlycon "driver" setup. Acked-by: Rob Herring Signed-off-by: Peter Hurley Signed-off-by: Greg Kroah-Hartman --- drivers/of/fdt.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'drivers/of') diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index ec14595..cfd3b35 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -800,7 +800,7 @@ static inline void early_init_dt_check_for_initrd(unsigned long node) static int __init early_init_dt_scan_chosen_serial(void) { int offset; - const char *p; + const char *p, *q, *options = NULL; int l; const struct earlycon_id *match; const void *fdt = initial_boot_params; @@ -817,11 +817,12 @@ static int __init early_init_dt_scan_chosen_serial(void) if (!p || !l) return -ENOENT; - /* Remove console options if present */ - l = strchrnul(p, ':') - p; + q = strchrnul(p, ':'); + if (*q != '\0') + options = q + 1; /* Get the node specified by stdout-path */ - offset = fdt_path_offset_namelen(fdt, p, l); + offset = fdt_path_offset_namelen(fdt, p, q - p); if (offset < 0) return -ENODEV; @@ -838,7 +839,7 @@ static int __init early_init_dt_scan_chosen_serial(void) if (addr == OF_BAD_ADDR) return -ENXIO; - of_setup_earlycon(addr, match); + of_setup_earlycon(addr, match, options); return 0; } return -ENODEV; -- cgit v1.1 From 088da2a17619cf0113b62a76ad38c6a14470ffa6 Mon Sep 17 00:00:00 2001 From: Peter Hurley Date: Sat, 16 Jan 2016 15:23:43 -0800 Subject: of: earlycon: Initialize port fields from DT properties Read the optional "reg-offset", "reg-shift", "reg-io-width" and endianness properties and initialize the respective struct uart_port field if found. NB: These bindings are common to several drivers and the values merely indicate the default value; the registering earlycon setup() method can simply override the values if required. Acked-by: Rob Herring Signed-off-by: Peter Hurley Signed-off-by: Greg Kroah-Hartman --- drivers/of/fdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/of') diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index cfd3b35..e8fd54a 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -839,7 +839,7 @@ static int __init early_init_dt_scan_chosen_serial(void) if (addr == OF_BAD_ADDR) return -ENXIO; - of_setup_earlycon(addr, match, options); + of_setup_earlycon(addr, match, offset, options); return 0; } return -ENODEV; -- cgit v1.1 From c90fe9c0394b068ceca16f66e9f35bcd8d948295 Mon Sep 17 00:00:00 2001 From: Peter Hurley Date: Sat, 16 Jan 2016 15:23:44 -0800 Subject: of: earlycon: Move address translation to of_setup_earlycon() Cleanup the early DT/earlycon separation; remove the 'addr' parameter from of_setup_earlycon() and get the uart phys addr directly with a new wrapper function, of_flat_dt_translate_addr(). Limit fdt_translate_address() to file scope. Acked-by: Rob Herring Signed-off-by: Peter Hurley Signed-off-by: Greg Kroah-Hartman --- drivers/of/fdt.c | 8 +------- drivers/of/fdt_address.c | 11 ++++++++++- 2 files changed, 11 insertions(+), 8 deletions(-) (limited to 'drivers/of') diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index e8fd54a..918809e 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -827,19 +827,13 @@ static int __init early_init_dt_scan_chosen_serial(void) return -ENODEV; for (match = __earlycon_table; match < __earlycon_table_end; match++) { - u64 addr; - if (!match->compatible[0]) continue; if (fdt_node_check_compatible(fdt, offset, match->compatible)) continue; - addr = fdt_translate_address(fdt, offset); - if (addr == OF_BAD_ADDR) - return -ENXIO; - - of_setup_earlycon(addr, match, offset, options); + of_setup_earlycon(match, offset, options); return 0; } return -ENODEV; diff --git a/drivers/of/fdt_address.c b/drivers/of/fdt_address.c index 8d3dc6f..dca8f9b 100644 --- a/drivers/of/fdt_address.c +++ b/drivers/of/fdt_address.c @@ -161,7 +161,7 @@ static int __init fdt_translate_one(const void *blob, int parent, * that can be mapped to a cpu physical address). This is not really specified * that way, but this is traditionally the way IBM at least do things */ -u64 __init fdt_translate_address(const void *blob, int node_offset) +static u64 __init fdt_translate_address(const void *blob, int node_offset) { int parent, len; const struct of_bus *bus, *pbus; @@ -239,3 +239,12 @@ u64 __init fdt_translate_address(const void *blob, int node_offset) bail: return result; } + +/** + * of_flat_dt_translate_address - translate DT addr into CPU phys addr + * @node: node in the flat blob + */ +u64 __init of_flat_dt_translate_address(unsigned long node) +{ + return fdt_translate_address(initial_boot_params, node); +} -- cgit v1.1 From 0fcc286f6a952d6ec40f74f26fd9cd5d63c25f9e Mon Sep 17 00:00:00 2001 From: Peter Hurley Date: Sat, 16 Jan 2016 15:23:48 -0800 Subject: of: earlycon: Log more helpful message if stdout-path node not found Earlycon may fail to initialize for a variety of reasons, most of which log the default early param message. If the stdout-path node is not found, log the path which was not found (and suppress the default early param message). Acked-by: Rob Herring Signed-off-by: Peter Hurley Signed-off-by: Greg Kroah-Hartman --- drivers/of/fdt.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'drivers/of') diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 918809e..e2295b2 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -820,11 +820,14 @@ static int __init early_init_dt_scan_chosen_serial(void) q = strchrnul(p, ':'); if (*q != '\0') options = q + 1; + l = q - p; /* Get the node specified by stdout-path */ - offset = fdt_path_offset_namelen(fdt, p, q - p); - if (offset < 0) - return -ENODEV; + offset = fdt_path_offset_namelen(fdt, p, l); + if (offset < 0) { + pr_warn("earlycon: stdout-path %.*s not found\n", l, p); + return 0; + } for (match = __earlycon_table; match < __earlycon_table_end; match++) { if (!match->compatible[0]) -- cgit v1.1