From e8bf5bc776edef44777b13b2eb4461d653519bae Mon Sep 17 00:00:00 2001 From: Ley Foon Tan Date: Tue, 10 Feb 2015 23:21:08 +0800 Subject: nios2: add early printk support Signed-off-by: Ley Foon Tan --- arch/nios2/kernel/prom.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) (limited to 'arch/nios2/kernel/prom.c') diff --git a/arch/nios2/kernel/prom.c b/arch/nios2/kernel/prom.c index 0522d3378e3f..718dd197909f 100644 --- a/arch/nios2/kernel/prom.c +++ b/arch/nios2/kernel/prom.c @@ -1,7 +1,7 @@ /* * Device tree support * - * Copyright (C) 2013 Altera Corporation + * Copyright (C) 2013, 2015 Altera Corporation * Copyright (C) 2010 Thomas Chou * * Based on MIPS support for CONFIG_OF device tree support @@ -30,6 +30,7 @@ #include #include +#include #include void __init early_init_dt_add_memory_arch(u64 base, u64 size) @@ -63,3 +64,52 @@ void __init early_init_devtree(void *params) early_init_dt_scan(params); } + +#ifdef CONFIG_EARLY_PRINTK +static int __init early_init_dt_scan_serial(unsigned long node, + const char *uname, int depth, void *data) +{ + u64 *addr64 = (u64 *) data; + const char *p; + + /* only consider serial nodes */ + if (strncmp(uname, "serial", 6) != 0) + return 0; + + p = of_get_flat_dt_prop(node, "compatible", NULL); + if (!p) + return 0; + + /* + * We found an altera_jtaguart but it wasn't configured for console, so + * skip it. + */ +#ifndef CONFIG_SERIAL_ALTERA_JTAGUART_CONSOLE + if (strncmp(p, "altr,juart", 10) == 0) + return 0; +#endif + + /* + * Same for altera_uart. + */ +#ifndef CONFIG_SERIAL_ALTERA_UART_CONSOLE + if (strncmp(p, "altr,uart", 9) == 0) + return 0; +#endif + + *addr64 = fdt_translate_address((const void *)initial_boot_params, + node); + + return *addr64 == OF_BAD_ADDR ? 0 : 1; +} + +unsigned long __init of_early_console(void) +{ + u64 base = 0; + + if (of_scan_flat_dt(early_init_dt_scan_serial, &base)) + return (u32)ioremap(base, 32); + else + return 0; +} +#endif /* CONFIG_EARLY_PRINTK */ -- cgit