aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Hurley <peter@hurleysoftware.com>2016-01-16 18:23:44 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-02-07 01:07:37 -0500
commitc90fe9c0394b068ceca16f66e9f35bcd8d948295 (patch)
treee4fc1ed180a6d159ec179a093dcef27691b9569e
parent088da2a17619cf0113b62a76ad38c6a14470ffa6 (diff)
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 <robh@kernel.org> Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/of/fdt.c8
-rw-r--r--drivers/of/fdt_address.c11
-rw-r--r--drivers/tty/serial/earlycon.c12
-rw-r--r--include/linux/of_fdt.h2
-rw-r--r--include/linux/serial_core.h2
5 files changed, 22 insertions, 13 deletions
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index e8fd54a30802..918809e6f913 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)
827 return -ENODEV; 827 return -ENODEV;
828 828
829 for (match = __earlycon_table; match < __earlycon_table_end; match++) { 829 for (match = __earlycon_table; match < __earlycon_table_end; match++) {
830 u64 addr;
831
832 if (!match->compatible[0]) 830 if (!match->compatible[0])
833 continue; 831 continue;
834 832
835 if (fdt_node_check_compatible(fdt, offset, match->compatible)) 833 if (fdt_node_check_compatible(fdt, offset, match->compatible))
836 continue; 834 continue;
837 835
838 addr = fdt_translate_address(fdt, offset); 836 of_setup_earlycon(match, offset, options);
839 if (addr == OF_BAD_ADDR)
840 return -ENXIO;
841
842 of_setup_earlycon(addr, match, offset, options);
843 return 0; 837 return 0;
844 } 838 }
845 return -ENODEV; 839 return -ENODEV;
diff --git a/drivers/of/fdt_address.c b/drivers/of/fdt_address.c
index 8d3dc6fbdb7a..dca8f9b93745 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,
161 * that can be mapped to a cpu physical address). This is not really specified 161 * that can be mapped to a cpu physical address). This is not really specified
162 * that way, but this is traditionally the way IBM at least do things 162 * that way, but this is traditionally the way IBM at least do things
163 */ 163 */
164u64 __init fdt_translate_address(const void *blob, int node_offset) 164static u64 __init fdt_translate_address(const void *blob, int node_offset)
165{ 165{
166 int parent, len; 166 int parent, len;
167 const struct of_bus *bus, *pbus; 167 const struct of_bus *bus, *pbus;
@@ -239,3 +239,12 @@ u64 __init fdt_translate_address(const void *blob, int node_offset)
239 bail: 239 bail:
240 return result; 240 return result;
241} 241}
242
243/**
244 * of_flat_dt_translate_address - translate DT addr into CPU phys addr
245 * @node: node in the flat blob
246 */
247u64 __init of_flat_dt_translate_address(unsigned long node)
248{
249 return fdt_translate_address(initial_boot_params, node);
250}
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 7089667bde93..baee9ad59af7 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -19,6 +19,7 @@
19#include <linux/io.h> 19#include <linux/io.h>
20#include <linux/serial_core.h> 20#include <linux/serial_core.h>
21#include <linux/sizes.h> 21#include <linux/sizes.h>
22#include <linux/of.h>
22#include <linux/of_fdt.h> 23#include <linux/of_fdt.h>
23 24
24#ifdef CONFIG_FIX_EARLYCON_MEM 25#ifdef CONFIG_FIX_EARLYCON_MEM
@@ -218,8 +219,7 @@ early_param("earlycon", param_setup_earlycon);
218 219
219#ifdef CONFIG_OF_EARLY_FLATTREE 220#ifdef CONFIG_OF_EARLY_FLATTREE
220 221
221int __init of_setup_earlycon(unsigned long addr, 222int __init of_setup_earlycon(const struct earlycon_id *match,
222 const struct earlycon_id *match,
223 unsigned long node, 223 unsigned long node,
224 const char *options) 224 const char *options)
225{ 225{
@@ -227,12 +227,18 @@ int __init of_setup_earlycon(unsigned long addr,
227 struct uart_port *port = &early_console_dev.port; 227 struct uart_port *port = &early_console_dev.port;
228 const __be32 *val; 228 const __be32 *val;
229 bool big_endian; 229 bool big_endian;
230 u64 addr;
230 231
231 spin_lock_init(&port->lock); 232 spin_lock_init(&port->lock);
232 port->iotype = UPIO_MEM; 233 port->iotype = UPIO_MEM;
234 addr = of_flat_dt_translate_address(node);
235 if (addr == OF_BAD_ADDR) {
236 pr_warn("[%s] bad address\n", match->name);
237 return -ENXIO;
238 }
233 port->mapbase = addr; 239 port->mapbase = addr;
234 port->uartclk = BASE_BAUD * 16; 240 port->uartclk = BASE_BAUD * 16;
235 port->membase = earlycon_map(addr, SZ_4K); 241 port->membase = earlycon_map(port->mapbase, SZ_4K);
236 242
237 val = of_get_flat_dt_prop(node, "reg-offset", NULL); 243 val = of_get_flat_dt_prop(node, "reg-offset", NULL);
238 if (val) 244 if (val)
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
index df9ef3801812..2fbe8682a66f 100644
--- a/include/linux/of_fdt.h
+++ b/include/linux/of_fdt.h
@@ -88,7 +88,7 @@ extern void unflatten_device_tree(void);
88extern void unflatten_and_copy_device_tree(void); 88extern void unflatten_and_copy_device_tree(void);
89extern void early_init_devtree(void *); 89extern void early_init_devtree(void *);
90extern void early_get_first_memblock_info(void *, phys_addr_t *); 90extern void early_get_first_memblock_info(void *, phys_addr_t *);
91extern u64 fdt_translate_address(const void *blob, int node_offset); 91extern u64 of_flat_dt_translate_address(unsigned long node);
92extern void of_fdt_limit_memory(int limit); 92extern void of_fdt_limit_memory(int limit);
93#else /* CONFIG_OF_FLATTREE */ 93#else /* CONFIG_OF_FLATTREE */
94static inline void early_init_fdt_scan_reserved_mem(void) {} 94static inline void early_init_fdt_scan_reserved_mem(void) {}
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 6d1bed821181..cbfcf38e220d 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[];
359#define EARLYCON_DECLARE(_name, fn) OF_EARLYCON_DECLARE(_name, "", fn) 359#define EARLYCON_DECLARE(_name, fn) OF_EARLYCON_DECLARE(_name, "", fn)
360 360
361extern int setup_earlycon(char *buf); 361extern int setup_earlycon(char *buf);
362extern int of_setup_earlycon(unsigned long addr, const struct earlycon_id *match, 362extern int of_setup_earlycon(const struct earlycon_id *match,
363 unsigned long node, 363 unsigned long node,
364 const char *options); 364 const char *options);
365 365