LKML Archive mirror
 help / color / mirror / Atom feed
From: Peter Hurley <peter@hurleysoftware.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Rob Herring <robh+dt@kernel.org>,
	Grant Likely <grant.likely@linaro.org>,
	linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
	Kevin Cernekee <cernekee@gmail.com>,
	Jon Hunter <jonathanh@nvidia.com>,
	Sebastian Frias <sf84@laposte.net>,
	Paul Burton <paul.burton@imgtec.com>,
	Peter Hurley <peter@hurleysoftware.com>
Subject: [PATCH v4 06/11] of: earlycon: Move address translation to of_setup_earlycon()
Date: Tue, 12 Jan 2016 11:41:07 -0800	[thread overview]
Message-ID: <1452627672-9482-7-git-send-email-peter@hurleysoftware.com> (raw)
In-Reply-To: <1452627672-9482-1-git-send-email-peter@hurleysoftware.com>

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

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

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

  parent reply	other threads:[~2016-01-12 19:42 UTC|newest]

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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1452627672-9482-7-git-send-email-peter@hurleysoftware.com \
    --to=peter@hurleysoftware.com \
    --cc=cernekee@gmail.com \
    --cc=grant.likely@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jonathanh@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=paul.burton@imgtec.com \
    --cc=robh+dt@kernel.org \
    --cc=sf84@laposte.net \
    --cc=yamada.masahiro@socionext.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).