diff options
author | Michal Simek <monstr@monstr.eu> | 2010-09-28 02:17:03 -0400 |
---|---|---|
committer | Michal Simek <monstr@monstr.eu> | 2010-10-21 01:51:53 -0400 |
commit | 67f4aaa21cf8cf09726cd26b506f3407ad7f11f9 (patch) | |
tree | 3a7162f933bcc2a54bf9a423e1830ee2a604b559 /arch | |
parent | 51f5fa50942ab013aa2e321bdfdba1c34ebf3256 (diff) |
microblaze: Support early console on uart16550
Early console support reuse setting from U-BOOT that's why
it is not necessary to setup baudrates, etc.
Signed-off-by: Michal Simek <monstr@monstr.eu>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/microblaze/Kconfig.debug | 2 | ||||
-rw-r--r-- | arch/microblaze/include/asm/prom.h | 1 | ||||
-rw-r--r-- | arch/microblaze/kernel/early_printk.c | 63 | ||||
-rw-r--r-- | arch/microblaze/kernel/prom.c | 34 |
4 files changed, 99 insertions, 1 deletions
diff --git a/arch/microblaze/Kconfig.debug b/arch/microblaze/Kconfig.debug index e6e5e0da28c3..e66e25c4b0b2 100644 --- a/arch/microblaze/Kconfig.debug +++ b/arch/microblaze/Kconfig.debug | |||
@@ -10,7 +10,7 @@ source "lib/Kconfig.debug" | |||
10 | 10 | ||
11 | config EARLY_PRINTK | 11 | config EARLY_PRINTK |
12 | bool "Early printk function for kernel" | 12 | bool "Early printk function for kernel" |
13 | depends on SERIAL_UARTLITE_CONSOLE | 13 | depends on SERIAL_UARTLITE_CONSOLE || SERIAL_8250_CONSOLE |
14 | default n | 14 | default n |
15 | help | 15 | help |
16 | This option turns on/off early printk messages to console. | 16 | This option turns on/off early printk messages to console. |
diff --git a/arch/microblaze/include/asm/prom.h b/arch/microblaze/include/asm/prom.h index 101fa098f62a..bdc38312ae4a 100644 --- a/arch/microblaze/include/asm/prom.h +++ b/arch/microblaze/include/asm/prom.h | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | /* Other Prototypes */ | 28 | /* Other Prototypes */ |
29 | extern int early_uartlite_console(void); | 29 | extern int early_uartlite_console(void); |
30 | extern int early_uart16550_console(void); | ||
30 | 31 | ||
31 | #ifdef CONFIG_PCI | 32 | #ifdef CONFIG_PCI |
32 | /* | 33 | /* |
diff --git a/arch/microblaze/kernel/early_printk.c b/arch/microblaze/kernel/early_printk.c index 685a64e93ede..c3616a080ebf 100644 --- a/arch/microblaze/kernel/early_printk.c +++ b/arch/microblaze/kernel/early_printk.c | |||
@@ -65,6 +65,50 @@ static struct console early_serial_uartlite_console = { | |||
65 | }; | 65 | }; |
66 | #endif /* CONFIG_SERIAL_UARTLITE_CONSOLE */ | 66 | #endif /* CONFIG_SERIAL_UARTLITE_CONSOLE */ |
67 | 67 | ||
68 | #ifdef CONFIG_SERIAL_8250_CONSOLE | ||
69 | static void early_printk_uart16550_putc(char c) | ||
70 | { | ||
71 | /* | ||
72 | * Limit how many times we'll spin waiting for TX FIFO status. | ||
73 | * This will prevent lockups if the base address is incorrectly | ||
74 | * set, or any other issue on the UARTLITE. | ||
75 | * This limit is pretty arbitrary, unless we are at about 10 baud | ||
76 | * we'll never timeout on a working UART. | ||
77 | */ | ||
78 | |||
79 | #define UART_LSR_TEMT 0x40 /* Transmitter empty */ | ||
80 | #define UART_LSR_THRE 0x20 /* Transmit-hold-register empty */ | ||
81 | #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE) | ||
82 | |||
83 | unsigned retries = 10000; | ||
84 | |||
85 | while (--retries && | ||
86 | !((in_be32(base_addr + 0x14) & BOTH_EMPTY) == BOTH_EMPTY)) | ||
87 | ; | ||
88 | |||
89 | if (retries) | ||
90 | out_be32(base_addr, c & 0xff); | ||
91 | } | ||
92 | |||
93 | static void early_printk_uart16550_write(struct console *unused, | ||
94 | const char *s, unsigned n) | ||
95 | { | ||
96 | while (*s && n-- > 0) { | ||
97 | early_printk_uart16550_putc(*s); | ||
98 | if (*s == '\n') | ||
99 | early_printk_uart16550_putc('\r'); | ||
100 | s++; | ||
101 | } | ||
102 | } | ||
103 | |||
104 | static struct console early_serial_uart16550_console = { | ||
105 | .name = "earlyser", | ||
106 | .write = early_printk_uart16550_write, | ||
107 | .flags = CON_PRINTBUFFER, | ||
108 | .index = -1, | ||
109 | }; | ||
110 | #endif /* CONFIG_SERIAL_8250_CONSOLE */ | ||
111 | |||
68 | static struct console *early_console; | 112 | static struct console *early_console; |
69 | 113 | ||
70 | void early_printk(const char *fmt, ...) | 114 | void early_printk(const char *fmt, ...) |
@@ -103,6 +147,25 @@ int __init setup_early_printk(char *opt) | |||
103 | } | 147 | } |
104 | #endif /* CONFIG_SERIAL_UARTLITE_CONSOLE */ | 148 | #endif /* CONFIG_SERIAL_UARTLITE_CONSOLE */ |
105 | 149 | ||
150 | #ifdef CONFIG_SERIAL_8250_CONSOLE | ||
151 | base_addr = early_uart16550_console(); | ||
152 | base_addr &= ~3; /* clear register offset */ | ||
153 | if (base_addr) { | ||
154 | early_console_initialized = 1; | ||
155 | #ifdef CONFIG_MMU | ||
156 | early_console_reg_tlb_alloc(base_addr); | ||
157 | #endif | ||
158 | early_console = &early_serial_uart16550_console; | ||
159 | |||
160 | early_printk("early_printk_console is enabled at 0x%08x\n", | ||
161 | base_addr); | ||
162 | |||
163 | /* register_console(early_console); */ | ||
164 | |||
165 | return 0; | ||
166 | } | ||
167 | #endif /* CONFIG_SERIAL_8250_CONSOLE */ | ||
168 | |||
106 | return 1; | 169 | return 1; |
107 | } | 170 | } |
108 | 171 | ||
diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c index 427b13b4740f..608e5cf2e10a 100644 --- a/arch/microblaze/kernel/prom.c +++ b/arch/microblaze/kernel/prom.c | |||
@@ -89,6 +89,40 @@ int __init early_uartlite_console(void) | |||
89 | { | 89 | { |
90 | return of_scan_flat_dt(early_init_dt_scan_serial, NULL); | 90 | return of_scan_flat_dt(early_init_dt_scan_serial, NULL); |
91 | } | 91 | } |
92 | |||
93 | /* MS this is Microblaze specifig function */ | ||
94 | static int __init early_init_dt_scan_serial_full(unsigned long node, | ||
95 | const char *uname, int depth, void *data) | ||
96 | { | ||
97 | unsigned long l; | ||
98 | char *p; | ||
99 | unsigned int addr; | ||
100 | |||
101 | pr_debug("search \"chosen\", depth: %d, uname: %s\n", depth, uname); | ||
102 | |||
103 | /* find all serial nodes */ | ||
104 | if (strncmp(uname, "serial", 6) != 0) | ||
105 | return 0; | ||
106 | |||
107 | early_init_dt_check_for_initrd(node); | ||
108 | |||
109 | /* find compatible node with uartlite */ | ||
110 | p = of_get_flat_dt_prop(node, "compatible", &l); | ||
111 | |||
112 | if ((strncmp(p, "xlnx,xps-uart16550", 18) != 0) && | ||
113 | (strncmp(p, "xlnx,axi-uart16550", 18) != 0)) | ||
114 | return 0; | ||
115 | |||
116 | addr = *(u32 *)of_get_flat_dt_prop(node, "reg", &l); | ||
117 | addr += *(u32 *)of_get_flat_dt_prop(node, "reg-offset", &l); | ||
118 | return addr; /* return address */ | ||
119 | } | ||
120 | |||
121 | /* this function is looking for early uartlite console - Microblaze specific */ | ||
122 | int __init early_uart16550_console(void) | ||
123 | { | ||
124 | return of_scan_flat_dt(early_init_dt_scan_serial_full, NULL); | ||
125 | } | ||
92 | #endif | 126 | #endif |
93 | 127 | ||
94 | void __init early_init_devtree(void *params) | 128 | void __init early_init_devtree(void *params) |