nios2: add early printk support

Signed-off-by: Ley Foon Tan <lftan@altera.com>
This commit is contained in:
Ley Foon Tan
2015-02-10 23:21:08 +08:00
parent 96f3a5cc33
commit e8bf5bc776
6 changed files with 207 additions and 1 deletions

View File

@@ -1,7 +1,7 @@
/*
* Device tree support
*
* Copyright (C) 2013 Altera Corporation
* Copyright (C) 2013, 2015 Altera Corporation
* Copyright (C) 2010 Thomas Chou <thomas@wytron.com.tw>
*
* Based on MIPS support for CONFIG_OF device tree support
@@ -30,6 +30,7 @@
#include <linux/of_fdt.h>
#include <linux/io.h>
#include <asm/prom.h>
#include <asm/sections.h>
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 */