microblaze: Simplify early console binding from DT
Recognize early Linux console from chosen - linux,stdout-path instead of detecting the first console with appropriate compatible strings. This patch solved the problem on system with multiple consoles. Signed-off-by: Michal Simek <monstr@monstr.eu>
This commit is contained in:
@@ -26,8 +26,12 @@
|
|||||||
#define HAVE_ARCH_DEVTREE_FIXUPS
|
#define HAVE_ARCH_DEVTREE_FIXUPS
|
||||||
|
|
||||||
/* Other Prototypes */
|
/* Other Prototypes */
|
||||||
extern int early_uartlite_console(void);
|
enum early_consoles {
|
||||||
extern int early_uart16550_console(void);
|
UARTLITE = 1,
|
||||||
|
UART16550 = 2,
|
||||||
|
};
|
||||||
|
|
||||||
|
extern int of_early_console(void *version);
|
||||||
|
|
||||||
#ifdef CONFIG_PCI
|
#ifdef CONFIG_PCI
|
||||||
/*
|
/*
|
||||||
|
@@ -127,45 +127,41 @@ void early_printk(const char *fmt, ...)
|
|||||||
|
|
||||||
int __init setup_early_printk(char *opt)
|
int __init setup_early_printk(char *opt)
|
||||||
{
|
{
|
||||||
|
int version = 0;
|
||||||
|
|
||||||
if (early_console_initialized)
|
if (early_console_initialized)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
base_addr = of_early_console(&version);
|
||||||
|
if (base_addr) {
|
||||||
|
#ifdef CONFIG_MMU
|
||||||
|
early_console_reg_tlb_alloc(base_addr);
|
||||||
|
#endif
|
||||||
|
switch (version) {
|
||||||
#ifdef CONFIG_SERIAL_UARTLITE_CONSOLE
|
#ifdef CONFIG_SERIAL_UARTLITE_CONSOLE
|
||||||
base_addr = early_uartlite_console();
|
case UARTLITE:
|
||||||
if (base_addr) {
|
printk(KERN_INFO "Early console on uartlite "
|
||||||
early_console_initialized = 1;
|
"at 0x%08x\n", base_addr);
|
||||||
#ifdef CONFIG_MMU
|
|
||||||
early_console_reg_tlb_alloc(base_addr);
|
|
||||||
#endif
|
|
||||||
early_console = &early_serial_uartlite_console;
|
early_console = &early_serial_uartlite_console;
|
||||||
early_printk("early_printk_console is enabled at 0x%08x\n",
|
break;
|
||||||
base_addr);
|
|
||||||
|
|
||||||
register_console(early_console);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif /* CONFIG_SERIAL_UARTLITE_CONSOLE */
|
|
||||||
|
|
||||||
#ifdef CONFIG_SERIAL_8250_CONSOLE
|
|
||||||
base_addr = early_uart16550_console();
|
|
||||||
base_addr &= ~3; /* clear register offset */
|
|
||||||
if (base_addr) {
|
|
||||||
early_console_initialized = 1;
|
|
||||||
#ifdef CONFIG_MMU
|
|
||||||
early_console_reg_tlb_alloc(base_addr);
|
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CONFIG_SERIAL_8250_CONSOLE
|
||||||
|
case UART16550:
|
||||||
|
printk(KERN_INFO "Early console on uart16650 "
|
||||||
|
"at 0x%08x\n", base_addr);
|
||||||
early_console = &early_serial_uart16550_console;
|
early_console = &early_serial_uart16550_console;
|
||||||
|
break;
|
||||||
early_printk("early_printk_console is enabled at 0x%08x\n",
|
#endif
|
||||||
base_addr);
|
default:
|
||||||
|
printk(KERN_INFO "Unsupported early console %d\n",
|
||||||
|
version);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
register_console(early_console);
|
register_console(early_console);
|
||||||
|
early_console_initialized = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_SERIAL_8250_CONSOLE */
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -53,69 +53,57 @@ void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_EARLY_PRINTK
|
#ifdef CONFIG_EARLY_PRINTK
|
||||||
/* MS this is Microblaze specifig function */
|
char *stdout;
|
||||||
static int __init early_init_dt_scan_serial(unsigned long node,
|
|
||||||
|
int __init early_init_dt_scan_chosen_serial(unsigned long node,
|
||||||
const char *uname, int depth, void *data)
|
const char *uname, int depth, void *data)
|
||||||
{
|
{
|
||||||
unsigned long l;
|
unsigned long l;
|
||||||
char *p;
|
char *p;
|
||||||
const __be32 *addr;
|
|
||||||
|
|
||||||
pr_debug("search \"serial\", depth: %d, uname: %s\n", depth, uname);
|
pr_debug("%s: depth: %d, uname: %s\n", __func__, depth, uname);
|
||||||
|
|
||||||
/* find all serial nodes */
|
if (depth == 1 && (strcmp(uname, "chosen") == 0 ||
|
||||||
if (strncmp(uname, "serial", 6) != 0)
|
strcmp(uname, "chosen@0") == 0)) {
|
||||||
return 0;
|
p = of_get_flat_dt_prop(node, "linux,stdout-path", &l);
|
||||||
|
if (p != NULL && l > 0)
|
||||||
|
stdout = p; /* store pointer to stdout-path */
|
||||||
|
}
|
||||||
|
|
||||||
/* find compatible node with uartlite */
|
if (stdout && strstr(stdout, uname)) {
|
||||||
p = of_get_flat_dt_prop(node, "compatible", &l);
|
p = of_get_flat_dt_prop(node, "compatible", &l);
|
||||||
if ((strncmp(p, "xlnx,xps-uartlite", 17) != 0) &&
|
pr_debug("Compatible string: %s\n", p);
|
||||||
(strncmp(p, "xlnx,opb-uartlite", 17) != 0) &&
|
|
||||||
(strncmp(p, "xlnx,axi-uartlite", 17) != 0))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
addr = of_get_flat_dt_prop(node, "reg", &l);
|
if ((strncmp(p, "xlnx,xps-uart16550", 18) == 0) ||
|
||||||
return be32_to_cpup(addr); /* return address */
|
(strncmp(p, "xlnx,axi-uart16550", 18) == 0)) {
|
||||||
}
|
|
||||||
|
|
||||||
/* this function is looking for early uartlite console - Microblaze specific */
|
|
||||||
int __init early_uartlite_console(void)
|
|
||||||
{
|
|
||||||
return of_scan_flat_dt(early_init_dt_scan_serial, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* MS this is Microblaze specifig function */
|
|
||||||
static int __init early_init_dt_scan_serial_full(unsigned long node,
|
|
||||||
const char *uname, int depth, void *data)
|
|
||||||
{
|
|
||||||
unsigned long l;
|
|
||||||
char *p;
|
|
||||||
unsigned int addr;
|
unsigned int addr;
|
||||||
|
|
||||||
pr_debug("search \"chosen\", depth: %d, uname: %s\n", depth, uname);
|
*(u32 *)data = UART16550;
|
||||||
|
|
||||||
/* find all serial nodes */
|
|
||||||
if (strncmp(uname, "serial", 6) != 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
early_init_dt_check_for_initrd(node);
|
|
||||||
|
|
||||||
/* find compatible node with uartlite */
|
|
||||||
p = of_get_flat_dt_prop(node, "compatible", &l);
|
|
||||||
|
|
||||||
if ((strncmp(p, "xlnx,xps-uart16550", 18) != 0) &&
|
|
||||||
(strncmp(p, "xlnx,axi-uart16550", 18) != 0))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
addr = *(u32 *)of_get_flat_dt_prop(node, "reg", &l);
|
addr = *(u32 *)of_get_flat_dt_prop(node, "reg", &l);
|
||||||
addr += *(u32 *)of_get_flat_dt_prop(node, "reg-offset", &l);
|
addr += *(u32 *)of_get_flat_dt_prop(node,
|
||||||
return be32_to_cpu(addr); /* return address */
|
"reg-offset", &l);
|
||||||
|
/* clear register offset */
|
||||||
|
return be32_to_cpu(addr) & ~3;
|
||||||
|
}
|
||||||
|
if ((strncmp(p, "xlnx,xps-uartlite", 17) == 0) ||
|
||||||
|
(strncmp(p, "xlnx,opb-uartlite", 17) == 0) ||
|
||||||
|
(strncmp(p, "xlnx,axi-uartlite", 17) == 0)) {
|
||||||
|
unsigned int *addrp;
|
||||||
|
|
||||||
|
*(u32 *)data = UARTLITE;
|
||||||
|
|
||||||
|
addrp = of_get_flat_dt_prop(node, "reg", &l);
|
||||||
|
return be32_to_cpup(addrp); /* return address */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this function is looking for early uartlite console - Microblaze specific */
|
/* this function is looking for early console - Microblaze specific */
|
||||||
int __init early_uart16550_console(void)
|
int __init of_early_console(void *version)
|
||||||
{
|
{
|
||||||
return of_scan_flat_dt(early_init_dt_scan_serial_full, NULL);
|
return of_scan_flat_dt(early_init_dt_scan_chosen_serial, version);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user