aboutsummaryrefslogtreecommitdiffstats
path: root/arch/microblaze/kernel/prom.c
diff options
context:
space:
mode:
authorMichal Simek <monstr@monstr.eu>2011-04-14 05:48:43 -0400
committerMichal Simek <monstr@monstr.eu>2011-07-25 03:25:13 -0400
commit2aa8e37596933a43fc3e46e1e385045635674429 (patch)
tree79cbf1212d42d583a5a5951e28d90e27e94df4e4 /arch/microblaze/kernel/prom.c
parente721a45fbed13a52093d2cc1962dbb8a754462ea (diff)
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>
Diffstat (limited to 'arch/microblaze/kernel/prom.c')
-rw-r--r--arch/microblaze/kernel/prom.c96
1 files changed, 42 insertions, 54 deletions
diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c
index b15cc219b1d9..18d9371d9b26 100644
--- a/arch/microblaze/kernel/prom.c
+++ b/arch/microblaze/kernel/prom.c
@@ -53,69 +53,57 @@ void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
53} 53}
54 54
55#ifdef CONFIG_EARLY_PRINTK 55#ifdef CONFIG_EARLY_PRINTK
56/* MS this is Microblaze specifig function */ 56char *stdout;
57static int __init early_init_dt_scan_serial(unsigned long node,
58 const char *uname, int depth, void *data)
59{
60 unsigned long l;
61 char *p;
62 const __be32 *addr;
63
64 pr_debug("search \"serial\", depth: %d, uname: %s\n", depth, uname);
65
66/* find all serial nodes */
67 if (strncmp(uname, "serial", 6) != 0)
68 return 0;
69
70/* find compatible node with uartlite */
71 p = of_get_flat_dt_prop(node, "compatible", &l);
72 if ((strncmp(p, "xlnx,xps-uartlite", 17) != 0) &&
73 (strncmp(p, "xlnx,opb-uartlite", 17) != 0) &&
74 (strncmp(p, "xlnx,axi-uartlite", 17) != 0))
75 return 0;
76
77 addr = of_get_flat_dt_prop(node, "reg", &l);
78 return be32_to_cpup(addr); /* return address */
79}
80 57
81/* this function is looking for early uartlite console - Microblaze specific */ 58int __init early_init_dt_scan_chosen_serial(unsigned long node,
82int __init early_uartlite_console(void)
83{
84 return of_scan_flat_dt(early_init_dt_scan_serial, NULL);
85}
86
87/* MS this is Microblaze specifig function */
88static int __init early_init_dt_scan_serial_full(unsigned long node,
89 const char *uname, int depth, void *data) 59 const char *uname, int depth, void *data)
90{ 60{
91 unsigned long l; 61 unsigned long l;
92 char *p; 62 char *p;
93 unsigned int addr;
94
95 pr_debug("search \"chosen\", depth: %d, uname: %s\n", depth, uname);
96
97/* find all serial nodes */
98 if (strncmp(uname, "serial", 6) != 0)
99 return 0;
100 63
101 early_init_dt_check_for_initrd(node); 64 pr_debug("%s: depth: %d, uname: %s\n", __func__, depth, uname);
102 65
103/* find compatible node with uartlite */ 66 if (depth == 1 && (strcmp(uname, "chosen") == 0 ||
104 p = of_get_flat_dt_prop(node, "compatible", &l); 67 strcmp(uname, "chosen@0") == 0)) {
105 68 p = of_get_flat_dt_prop(node, "linux,stdout-path", &l);
106 if ((strncmp(p, "xlnx,xps-uart16550", 18) != 0) && 69 if (p != NULL && l > 0)
107 (strncmp(p, "xlnx,axi-uart16550", 18) != 0)) 70 stdout = p; /* store pointer to stdout-path */
108 return 0; 71 }
109 72
110 addr = *(u32 *)of_get_flat_dt_prop(node, "reg", &l); 73 if (stdout && strstr(stdout, uname)) {
111 addr += *(u32 *)of_get_flat_dt_prop(node, "reg-offset", &l); 74 p = of_get_flat_dt_prop(node, "compatible", &l);
112 return be32_to_cpu(addr); /* return address */ 75 pr_debug("Compatible string: %s\n", p);
76
77 if ((strncmp(p, "xlnx,xps-uart16550", 18) == 0) ||
78 (strncmp(p, "xlnx,axi-uart16550", 18) == 0)) {
79 unsigned int addr;
80
81 *(u32 *)data = UART16550;
82
83 addr = *(u32 *)of_get_flat_dt_prop(node, "reg", &l);
84 addr += *(u32 *)of_get_flat_dt_prop(node,
85 "reg-offset", &l);
86 /* clear register offset */
87 return be32_to_cpu(addr) & ~3;
88 }
89 if ((strncmp(p, "xlnx,xps-uartlite", 17) == 0) ||
90 (strncmp(p, "xlnx,opb-uartlite", 17) == 0) ||
91 (strncmp(p, "xlnx,axi-uartlite", 17) == 0)) {
92 unsigned int *addrp;
93
94 *(u32 *)data = UARTLITE;
95
96 addrp = of_get_flat_dt_prop(node, "reg", &l);
97 return be32_to_cpup(addrp); /* return address */
98 }
99 }
100 return 0;
113} 101}
114 102
115/* this function is looking for early uartlite console - Microblaze specific */ 103/* this function is looking for early console - Microblaze specific */
116int __init early_uart16550_console(void) 104int __init of_early_console(void *version)
117{ 105{
118 return of_scan_flat_dt(early_init_dt_scan_serial_full, NULL); 106 return of_scan_flat_dt(early_init_dt_scan_chosen_serial, version);
119} 107}
120#endif 108#endif
121 109